Repository navigation
Expand file tree
/
Copy pathbuilder.html
More file actions
1009 lines (986 loc) · 94.9 KB
/
Copy pathbuilder.html
File metadata and controls
1009 lines (986 loc) · 94.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
customPOS — the builder (customPOS.com in one file)
===================================================
Trade-first wizard + a DEEP editor: click a workstation to configure it, click an item to
configure everything that follows it (its path through the workstations, modifiers, flags,
performer, 86 limit…), plus business-wide payments/tips/deposit/loyalty/timer/capacity.
Then DOWNLOAD a self-contained POS with your config baked in + a generated CLAUDE.md.
Assembles by embedding the engine (window.__ENGINE_SRC__ from a build, or fetch('pos.html')).
Serve alongside pos.html over http, or build a standalone file with `node build.js`.
-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Build Your POS — customPOS · free POS builder for any business</title>
<meta name="description" content="The customPOS builder: pick your trade, then set prices, workstations, taxes, tips and staff with no code — and download a self-contained point-of-sale you own forever. Free and open-source.">
<meta name="robots" content="index, follow, max-image-preview:large">
<link rel="canonical" href="https://custompos.org/builder.html">
<meta name="theme-color" content="#1f6feb">
<meta property="og:type" content="website">
<meta property="og:site_name" content="customPOS">
<meta property="og:url" content="https://custompos.org/builder.html">
<meta property="og:title" content="Build your POS — customPOS free POS builder">
<meta property="og:description" content="Pick your trade, customize everything with no code, and download a POS you own. Free, open-source, no lock-in.">
<meta property="og:image" content="https://custompos.org/og.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Build your POS — customPOS free POS builder">
<meta name="twitter:description" content="Pick your trade, customize with no code, download a POS you own. Free and open-source.">
<meta name="twitter:image" content="https://custompos.org/og.png">
<style>
:root { --brand:#1f6feb; --bg:#0f1115; --card:#181b22; --line:#272b33; --ink:#e6e9ef; --dim:#9aa4b2; --good:#2ea043; --bad:#d0433a; }
* { box-sizing:border-box; }
body { margin:0; font:15px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif; background:var(--bg); color:var(--ink); }
header { padding:16px 20px; border-bottom:1px solid var(--line); background:var(--card); }
header b { font-size:18px; } header .tag { color:var(--dim); margin-left:8px; }
main { max-width:940px; margin:0 auto; padding:20px 18px 70px; }
h2 { font-size:13px; text-transform:uppercase; letter-spacing:.03em; color:var(--dim); margin:22px 0 10px; }
.cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:12px; }
.trade { text-align:left; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px; cursor:pointer; color:var(--ink); font:inherit; }
.trade:hover, .trade.sel { border-color:var(--brand); }
.trade b { font-size:16px; display:block; } .trade small { color:var(--dim); }
input, select { font:inherit; color:var(--ink); background:#222834; border:1px solid var(--line); border-radius:8px; padding:8px 10px; }
input[type=color]{ padding:2px; width:44px; height:34px; }
input.sm{ width:80px; } input.nm{ width:200px; }
button { background:#222834; border:1px solid var(--line); border-radius:8px; padding:9px 14px; cursor:pointer; color:var(--ink); font:inherit; margin:6px 8px 0 0; }
button:hover { border-color:var(--brand); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline:2px solid var(--brand); outline-offset:2px; } /* keyboard nav */
.floorcanvas { position:relative; height:320px; border:1px dashed var(--line); border-radius:12px; background:var(--card); background-image:linear-gradient(var(--line) 1px,transparent 1px),linear-gradient(90deg,var(--line) 1px,transparent 1px); background-size:24px 24px; overflow:hidden; touch-action:none; }
.ftile { position:absolute; width:84px; min-height:56px; padding:8px; border-radius:10px; background:var(--brand); color:#fff; cursor:grab; user-select:none; }
.ftile.sel { outline:2px solid #fff; }
.ftile small { display:block; opacity:.85; font-size:10px; margin-top:2px; }
button.primary { background:var(--brand); border-color:var(--brand); color:#fff; font-weight:600; }
button.big { padding:13px 20px; font-size:16px; }
button.on { border-color:var(--brand); color:#cfe0ff; background:#1b2536; }
button.danger { border-color:var(--bad); color:#f2a49d; }
.panel { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px; margin:12px 0; }
.flow { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:10px 0; }
.node { background:#1b2536; border:1px solid var(--brand); color:#cfe0ff; border-radius:20px; padding:6px 12px; font-size:13px; cursor:pointer; }
.node.fixed { background:#14301f; border-color:var(--good); color:#bdf0cd; cursor:default; }
.arrow { color:var(--dim); }
.chips { display:flex; gap:8px; flex-wrap:wrap; }
.chip { background:#1b2130; border:1px solid var(--line); border-radius:10px; padding:8px 12px; cursor:pointer; font-size:14px; }
.chip:hover { border-color:var(--brand); } .chip.sel { border-color:var(--brand); color:#cfe0ff; background:#1b2536; }
.chip .t { color:var(--dim); font-size:12px; margin-left:6px; }
.muted { color:var(--dim); } .pill { font-size:12px; border:1px solid var(--line); border-radius:20px; padding:2px 8px; color:var(--dim); margin-right:5px; }
.fld { display:flex; align-items:center; gap:10px; margin:8px 0; flex-wrap:wrap; } .flab { color:var(--dim); min-width:130px; font-size:13px; }
.ed { border:1px solid var(--brand); border-radius:12px; padding:14px; margin:10px 0; background:#141a24; }
.ed h3 { margin:0 0 8px; font-size:15px; }
.row2 { display:flex; gap:8px; align-items:center; margin:5px 0; flex-wrap:wrap; }
iframe { width:100%; height:460px; border:1px solid var(--line); border-radius:12px; background:#0f1115; margin-top:10px; }
a.dl { display:inline-block; } .step { color:var(--dim); font-size:13px; margin-bottom:4px; }
.hint { color:var(--dim); font-size:13px; margin:4px 0 0; }
</style>
<header><b>customPOS</b><span class="tag">build your point-of-sale · download it · own the code</span></header>
<main id="app"></main>
<script>
/* tiny DOM helper */
function h(tag, attrs, kids){ const e=document.createElement(tag); if(attrs) for(const k in attrs){ if(k==='class') e.className=attrs[k]; else if(k==='html') e.innerHTML=attrs[k]; else if(k.slice(0,2)==='on') e[k.toLowerCase()]=attrs[k]; else if(k==='style') e.style.cssText=attrs[k]; else if(e[k]!==undefined && k!=='list') e[k]=attrs[k]; else e.setAttribute(k,attrs[k]); } (kids||[]).forEach(c=>{ if(c==null) return; e.appendChild(typeof c==='string'?document.createTextNode(c):c); }); return e; }
const uid = () => 'x'+Math.random().toString(36).slice(2,8);
/* ---- starter trade templates (each a valid engine FLOW) ---- */
const TEMPLATES = {
retail: { flowId:"retail", label:"Shop / Retail", topology:"linear", blurb:"Ring up items from stock",
branding:{ name:"My Shop", brandColor:"#1f6feb" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", split:true }, loyalty:{earnPerDollar:1,redeemPoints:100,redeemValue:5}, tax:{rate:0.07}, discounts:true, scan:true },
catalog:[ {id:"p1",name:"Item A",price:12,category:"retail",barcode:"1001",stock:20,reorderAt:5,path:[]}, {id:"p2",name:"Item B",price:24,category:"retail",barcode:"1002",stock:12,reorderAt:4,path:[]}, {id:"g",name:"Gift card $25",price:25,category:"giftcard",path:[]} ],
stations:[ {id:"reg",type:"central",label:"Register",view:{money:true}}, {id:"office",type:"report",label:"Office",view:{money:true}}, {id:"board",type:"board",label:"Sales Board",view:{money:false}} ] },
convenience: { flowId:"convenience", label:"Convenience / Gas station", topology:"linear", blurb:"High-volume counter — scan, ID-check, lottery, inventory",
branding:{ name:"Quick Stop", brandColor:"#0a7d33" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0" }, tax:{rate:0.08}, scan:true },
catalog:[
{id:"water",name:"Water 20oz",price:1.79,category:"drink",barcode:"2001",cost:0.55,stock:60,reorderAt:12,path:[]},
{id:"soda",name:"Soda 20oz",price:2.29,category:"drink",barcode:"2002",cost:0.85,stock:60,reorderAt:12,path:[]},
{id:"coffee",name:"Coffee 16oz",price:1.99,category:"drink",cost:0.35,path:[]},
{id:"chips",name:"Chips",price:2.49,category:"snack",barcode:"2003",cost:0.90,stock:40,reorderAt:10,path:[]},
{id:"candy",name:"Candy bar",price:1.89,category:"snack",barcode:"2004",cost:0.70,stock:50,reorderAt:12,path:[]},
{id:"beer",name:"Beer 6-pack",price:9.99,category:"beer",barcode:"2010",ageRestricted:21,cost:6.20,stock:24,reorderAt:6,path:[]},
{id:"cigs",name:"Cigarettes",price:8.49,category:"tobacco",barcode:"2011",ageRestricted:21,cost:6.90,stock:30,reorderAt:8,path:[]},
{id:"lotto",name:"Lottery ticket",price:2,category:"lottery",ageRestricted:18,path:[]},
{id:"fuel10",name:"Fuel prepay $10",price:10,category:"fuel",path:[]},
{id:"fuel20",name:"Fuel prepay $20",price:20,category:"fuel",path:[]}
],
stations:[ {id:"reg",type:"central",label:"Register",view:{money:true}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
counter: { flowId:"counter", label:"Simple counter", topology:"linear", blurb:"Just a register — one screen, ring it up, take the money",
branding:{ name:"My Counter", brandColor:"#1f6feb" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0" } },
catalog:[ {id:"a",name:"Item A",price:5,category:"item",path:[]}, {id:"b",name:"Item B",price:10,category:"item",path:[]}, {id:"c",name:"Item C",price:3,category:"item",path:[]} ],
stations:[ {id:"reg",type:"central",label:"Register",view:{money:true}} ] },
foodtruck: { flowId:"foodtruck", label:"Food truck", topology:"linear", blurb:"One window — food, drinks, cash & card, no clutter",
branding:{ name:"Street Eats", brandColor:"#e0632b" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[10,15,20]} } },
catalog:[
{id:"t1",name:"Taco al Pastor",price:3.5,category:"taco",cost:1.1,path:[]},
{id:"t2",name:"Taco Carne Asada",price:3.75,category:"taco",cost:1.2,path:[]},
{id:"t3",name:"Taco Veggie",price:3.25,category:"taco",cost:0.9,path:[]},
{id:"b1",name:"Burrito",price:8.5,category:"entree",cost:2.6,path:[]},
{id:"q1",name:"Quesadilla",price:7,category:"entree",cost:2.1,path:[]},
{id:"c1",name:"Chips & Salsa",price:3,category:"side",cost:0.6,path:[]},
{id:"d1",name:"Jarritos",price:2.5,category:"drink",cost:0.8,path:[]},
{id:"d2",name:"Bottled Water",price:1.5,category:"drink",cost:0.4,path:[]}
],
stations:[ {id:"reg",type:"central",label:"Window",view:{money:true}} ] },
market: { flowId:"market", label:"Market stall / booth", topology:"linear", blurb:"Flea market, farmers market, craft booth — cash, no tax, dead simple",
branding:{ name:"My Stall", brandColor:"#2f8f5b" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0" } },
catalog:[
{id:"a",name:"Item — $2",price:2,category:"goods",path:[]},
{id:"b",name:"Item — $5",price:5,category:"goods",path:[]},
{id:"c",name:"Item — $10",price:10,category:"goods",path:[]},
{id:"d",name:"Item — $20",price:20,category:"goods",path:[]},
{id:"misc",name:"Anything (custom price)",price:0,category:"goods",customPrice:true,path:[]}
],
stations:[ {id:"reg",type:"central",label:"Register",view:{money:true}} ] },
mobile: { flowId:"mobile", label:"Mobile / home services", topology:"linear", blurb:"Groomer, cleaner, handyman on the go — services, tips, text-when-done",
branding:{ name:"On-the-Go", brandColor:"#7a4fd0" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[15,18,20]} }, notify:{template:"Hi {name}, {number} is all done — thanks for choosing {biz}!"} },
catalog:[
{id:"s1",name:"Bath & Brush",price:45,category:"service",path:[]},
{id:"s2",name:"Full Groom",price:75,category:"service",path:[]},
{id:"s3",name:"Nail Trim",price:15,category:"service",path:[]},
{id:"s4",name:"De-shed Add-on",price:20,category:"service",path:[]}
],
stations:[ {id:"reg",type:"central",label:"Checkout",view:{money:true}}, {id:"book",type:"booking",label:"Appointments",view:{}} ] },
bar: { flowId:"bar", label:"Bar / pub", topology:"linear", blurb:"Tabs by seat, 21+ ID check, tips",
branding:{ name:"The Tap", brandColor:"#8a5a1f" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[15,20,25]} } },
floor:{ label:"Bar", tables:[ {id:"s1",label:"Seat 1",seats:1}, {id:"s2",label:"Seat 2",seats:1}, {id:"s3",label:"Seat 3",seats:1}, {id:"s4",label:"Seat 4",seats:1}, {id:"bo1",label:"Booth 1",seats:4} ] },
catalog:[
{id:"d1",name:"Draft Beer",price:6,category:"beer",ageRestricted:21,path:[]},
{id:"d2",name:"Well Cocktail",price:9,category:"cocktail",ageRestricted:21,path:[]},
{id:"d3",name:"Glass of Wine",price:8,category:"wine",ageRestricted:21,path:[]},
{id:"d4",name:"Soda",price:3,category:"na",path:[]},
{id:"f1",name:"Wings",price:11,category:"food",path:[]}
],
stations:[ {id:"reg",type:"central",label:"Bar",view:{money:true}}, {id:"floor",type:"floor",label:"Seats & Tabs",view:{}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
dispensary: { flowId:"dispensary", label:"Dispensary (21+)", topology:"linear", blurb:"Age-gated retail — ID check, member accounts, tracked inventory",
branding:{ name:"Green Door", brandColor:"#1f8f3a" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","account"], closeGate:"balanceLE0" }, tax:{rate:0.15}, scan:true },
catalog:[
{id:"f1",name:"Flower 1/8 oz",price:35,category:"flower",ageRestricted:21,cost:18,stock:40,reorderAt:8,path:[]},
{id:"p1",name:"Pre-roll",price:9,category:"preroll",ageRestricted:21,cost:4,stock:80,reorderAt:15,path:[]},
{id:"e1",name:"Edible 100mg",price:20,category:"edible",ageRestricted:21,cost:9,stock:50,reorderAt:10,path:[]},
{id:"v1",name:"Vape Cartridge",price:40,category:"vape",ageRestricted:21,cost:22,stock:30,reorderAt:6,path:[]}
],
stations:[ {id:"reg",type:"central",label:"Register",view:{money:true}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
// ── Community-seed starters (from the AI-persona stress test) ─────────────────────────────────────────
bakery: { flowId:"bakery", label:"Bakery (pre-order + counter)", topology:"linear", blurb:"Custom cake pre-orders with a deposit, plus pastries over the counter",
branding:{ name:"Sweet Crumb", brandColor:"#c2708a" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", deposit:{pct:50} }, notify:{template:"Hi {name}, your order #{number} at {biz} is ready for pickup! Balance due at pickup: {balance}."} },
timer:{ mode:"due", promiseSec:86400, warnSec:43200, label:"ready by" },
catalog:[
{id:"cake",name:"Custom Cake (quote)",price:0,category:"custom",customPrice:true,path:["kitchen"]},
{id:"cupcake",name:"Cupcake (each)",price:3.5,category:"pastry",cost:0.8,path:[]},
{id:"croissant",name:"Croissant",price:4,category:"pastry",cost:1,path:[]},
{id:"loaf",name:"Sourdough Loaf",price:8,category:"bread",cost:2,path:[]},
{id:"cookie",name:"Cookie (each)",price:2.5,category:"pastry",cost:0.5,path:[]}
],
stations:[ {id:"counter",type:"central",label:"Counter",view:{money:true}}, {id:"kitchen",type:"production",label:"Kitchen",view:{money:false}}, {id:"board",type:"board",label:"Order Board",view:{money:false}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
butcher: { flowId:"butcher", label:"Butcher / Deli (by weight)", topology:"linear", blurb:"Price-by-the-pound meats plus fixed-price deli items — weigh, price, ring",
branding:{ name:"Prime Cuts", brandColor:"#a33b3b" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0" }, scan:true },
catalog:[
{id:"ribeye",name:"Ribeye",price:15.99,category:"beef",byWeight:true,unit:"lb",cost:9,path:[]},
{id:"ground",name:"Ground Beef",price:6.49,category:"beef",byWeight:true,unit:"lb",cost:3.5,path:[]},
{id:"chicken",name:"Chicken Breast",price:4.99,category:"poultry",byWeight:true,unit:"lb",cost:2.2,path:[]},
{id:"bacon",name:"Bacon",price:7.99,category:"pork",byWeight:true,unit:"lb",cost:4,path:[]},
{id:"sub",name:"Deli Sandwich",price:8.5,category:"deli",cost:2.5,path:[]},
{id:"side",name:"Side Salad",price:4,category:"deli",cost:1,path:[]}
],
stations:[ {id:"reg",type:"central",label:"Counter",view:{money:true}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
pizzeria: { flowId:"pizzeria", label:"Pizzeria (+ delivery)", topology:"linear", blurb:"Walk-in & phone orders, made in back, delivered to the door",
branding:{ name:"Slice House", brandColor:"#c9462c" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[10,15,20]} }, notify:{template:"Hi {name}, your order #{number} from {biz} is on the way!"},
tax:{ rate:0.08, zones:[ {name:"Downtown", rate:0.09}, {name:"Across the river", rate:0.0825} ] } }, // delivery = tax at the destination's rate; rename these to your real delivery towns
timer:{ mode:"aging", warnSec:900, badSec:1800, label:"in kitchen" },
catalog:[
{id:"cheese",name:"Cheese Pizza",price:12,category:"pizza",cost:3,path:["kitchen"],modifiers:[{group:"Size",required:true,options:[{name:"Sm",price:0},{name:"Md",price:3},{name:"Lg",price:6}]}],addons:[{name:"Pepperoni",price:2},{name:"Mushroom",price:1.5},{name:"Extra cheese",price:2}]},
{id:"wings",name:"Wings (10)",price:11,category:"sides",cost:3.5,path:["kitchen"]},
{id:"salad",name:"House Salad",price:7,category:"sides",cost:1.5,path:["kitchen"]},
{id:"soda",name:"2-Liter Soda",price:3,category:"drink",cost:1,path:[]}
],
stations:[ {id:"reg",type:"intake",label:"Register",view:{money:true}}, {id:"kitchen",type:"production",label:"Kitchen",view:{money:false}}, {id:"kds",type:"kds",label:"Kitchen Display",view:{money:false}}, {id:"route",type:"route",label:"Delivery",view:{money:true}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
florist: { flowId:"florist", label:"Florist (+ delivery)", topology:"linear", blurb:"Custom arrangements, phone orders, delivered with a gift card",
branding:{ name:"Petal & Stem", brandColor:"#d15b93" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", deposit:{pct:50} }, notify:{template:"Hi {name}, your flowers (order #{number}) from {biz} are ready! Balance due at pickup: {balance}."}, quotes:true,
tax:{ rate:0.075, zones:[ {name:"Next town over", rate:0.09} ] } }, // deliveries taxed at the destination's rate
timer:{ mode:"due", promiseSec:86400, warnSec:43200, label:"needed by" },
catalog:[
{id:"custom",name:"Custom Arrangement (quote)",price:0,category:"custom",customPrice:true,path:["bench"]},
{id:"dozen",name:"Dozen Roses",price:60,category:"arrangement",cost:22,path:["bench"]},
{id:"bouquet",name:"Mixed Bouquet",price:40,category:"arrangement",cost:14,path:["bench"]},
{id:"vase",name:"Vase Add-on",price:12,category:"addon",cost:4,path:[]},
{id:"note",name:"Gift Card Message",price:3,category:"addon",path:[]}
],
stations:[ {id:"counter",type:"central",label:"Counter",view:{money:true}}, {id:"bench",type:"production",label:"Design Bench",view:{money:false}}, {id:"route",type:"route",label:"Delivery",view:{money:true}}, {id:"board",type:"board",label:"Order Board",view:{money:false}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
scoop: { flowId:"scoop", label:"Ice cream / Scoop shop", topology:"linear", blurb:"Fast summer counter — pick a size, a cone or cup, done",
branding:{ name:"Sweet Scoops", brandColor:"#5bb5d1" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[10,15,20]} } },
catalog:[
{id:"scoopitem",name:"Ice Cream",price:3.5,category:"cream",cost:0.7,path:[],modifiers:[{group:"Size",required:true,options:[{name:"Single",price:0},{name:"Double",price:2},{name:"Triple",price:3.5}]},{group:"Serve",required:true,options:[{name:"Cup",price:0},{name:"Cone",price:0.5},{name:"Waffle cone",price:1.5}]}],addons:[{name:"Sprinkles",price:0.5},{name:"Hot fudge",price:0.75}]},
{id:"sundae",name:"Sundae",price:6,category:"cream",cost:1.5,path:[]},
{id:"shake",name:"Milkshake",price:5.5,category:"cream",cost:1.3,path:[]},
{id:"water",name:"Bottled Water",price:1.5,category:"drink",cost:0.4,path:[]}
],
stations:[ {id:"reg",type:"central",label:"Window",view:{money:true}} ] },
consignment: { flowId:"consignment", label:"Consignment / Thrift", topology:"linear", blurb:"One-of-a-kind items priced individually, with consignor store-credit accounts",
branding:{ name:"Second Look", brandColor:"#6a8f3a" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card","account"], closeGate:"balanceLE0" }, scan:true },
catalog:[
{id:"item",name:"Consigned Item (enter price)",price:0,category:"resale",customPrice:true,path:[]},
{id:"cloth",name:"Clothing",price:8,category:"apparel",path:[]},
{id:"home",name:"Home Goods",price:12,category:"home",path:[]},
{id:"book",name:"Book",price:3,category:"media",path:[]}
],
stations:[ {id:"reg",type:"central",label:"Register",view:{money:true}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
laundromat: { flowId:"laundromat", label:"Laundromat / Wash & Fold", topology:"linear", blurb:"Self-serve loads plus drop-off wash-and-fold priced by the pound",
branding:{ name:"Sudsy", brandColor:"#2b8fd0" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0" }, notify:{template:"Hi {name}, your wash & fold #{number} at {biz} is ready!"} },
timer:{ mode:"due", promiseSec:86400, warnSec:43200, label:"ready by" },
catalog:[
{id:"wf",name:"Wash & Fold",price:1.75,category:"washfold",byWeight:true,unit:"lb",cost:0.4,path:["laundry"]},
{id:"comforter",name:"Comforter (each)",price:20,category:"washfold",cost:4,path:["laundry"]},
{id:"wash",name:"Self-serve Wash (per load)",price:3.5,category:"selfserve",path:[]},
{id:"dry",name:"Self-serve Dry (per load)",price:2.5,category:"selfserve",path:[]},
{id:"soap",name:"Detergent",price:1.5,category:"goods",cost:0.5,path:[]}
],
stations:[ {id:"reg",type:"central",label:"Counter",view:{money:true}}, {id:"laundry",type:"production",label:"Wash & Fold",view:{money:false}}, {id:"board",type:"board",label:"Board",view:{money:false}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
tattoo: { flowId:"tattoo", label:"Tattoo / Piercing studio", topology:"linear", blurb:"By-artist appointments with a deposit, 18+ ID & waiver, commission",
branding:{ name:"Ink & Iron", brandColor:"#7a3fd0" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[15,20,25]}, deposit:{pct:25} }, notify:{template:"Hi {name}, your appointment at {biz} is set — deposit paid, balance at your session: {balance}."} },
performers:["Artist A","Artist B"], commission:{pct:50},
catalog:[
{id:"small",name:"Small Tattoo (quote)",price:0,category:"tattoo",customPrice:true,ageRestricted:18,performer:true,path:[],flags:["Consent / waiver signed","Aftercare explained"]},
{id:"large",name:"Large / custom piece (quote)",price:0,category:"tattoo",customPrice:true,ageRestricted:18,performer:true,path:[],flags:["Consent / waiver signed","Aftercare explained"]},
{id:"pierce",name:"Piercing",price:45,category:"piercing",ageRestricted:18,performer:true,path:[],flags:["Consent / waiver signed"]},
{id:"jewelry",name:"Jewelry / Aftercare",price:25,category:"goods",cost:9,path:[]}
],
stations:[ {id:"reg",type:"central",label:"Front Desk",view:{money:true}}, {id:"book",type:"booking",label:"Appointments",view:{}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
cafe: { flowId:"cafe", label:"Café / Counter", topology:"linear", blurb:"Made-to-order food & drinks",
branding:{ name:"My Café", brandColor:"#8a5a2b" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[15,18,20]}, split:true} },
timer:{ mode:"aging", warnSec:300, badSec:600, label:"prep" }, capacity:{ perOrderMins:4, max:8 }, kds:{warnSec:300,badSec:600},
catalog:[ {id:"c1",name:"Coffee",price:3.5,category:"drink",path:["bar"]},
{id:"c2",name:"Latte",price:4.75,category:"drink",path:["bar"],modifiers:[{group:"Size",required:true,options:[{name:"Sm",price:0},{name:"Md",price:.5},{name:"Lg",price:1}]}],addons:[{name:"Oat milk",price:.75}]},
{id:"c3",name:"Sandwich",price:8,category:"food",path:["kitchen"]} ],
stations:[ {id:"order",type:"intake",label:"Register",view:{money:true}}, {id:"bar",type:"production",label:"Bar",view:{money:false}}, {id:"kitchen",type:"production",label:"Kitchen",view:{money:false}}, {id:"kds",type:"kds",label:"Kitchen Display",view:{money:false}}, {id:"pickup",type:"fulfillment",label:"Pickup",view:{money:true}} ] },
cleaner: { flowId:"cleaner", label:"Dry cleaner / Laundry", topology:"hub-and-spoke", blurb:"Full dry-clean & laundry — tag, clean, assemble, rack, pickup",
branding:{ name:"My Cleaners", brandColor:"#2ea043" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card","account"], closeGate:"balanceLE0"}, loyalty:{earnPerDollar:1,redeemPoints:100,redeemValue:5}, notify:{template:"Hi {name}, your order #{number} at {biz} is ready for pickup."}, quotes:true },
timer:{ mode:"due", promiseSec:172800, warnSec:86400, label:"promise" },
catalog:[
{id:"shirt",name:"Laundered Shirt",price:2.99,category:"laundry",path:["detail","assembly","rack"],modifiers:[{group:"Starch",required:true,options:[{name:"None",price:0},{name:"Light",price:0},{name:"Medium",price:0},{name:"Heavy",price:0.5}]}],flags:["Pre-existing damage","Stain noted"]},
{id:"pants",name:"Pants / Slacks",price:7.5,category:"drycleaning",path:["detail","assembly","rack"]},
{id:"suit",name:"2-pc Suit",price:14,category:"drycleaning",path:["detail","assembly","rack"]},
{id:"dress",name:"Dress",price:12,category:"drycleaning",path:["detail","assembly","rack"],flags:["Beads / sequins"]},
{id:"coat",name:"Coat / Jacket",price:11,category:"drycleaning",path:["detail","assembly","rack"]},
{id:"comforter",name:"Comforter",price:25,category:"household",path:["detail","rack"]},
{id:"wf",name:"Wash & Fold (per lb)",price:1.75,category:"wf",path:["rack"]},
{id:"alter",name:"Alterations",price:0,category:"alteration",path:["detail","rack"]}
],
stations:[
{id:"counter",type:"central",label:"Front Counter",view:{money:true}},
{id:"detail",type:"production",label:"Detail / Tag",view:{money:false}},
{id:"assembly",type:"production",label:"Assembly",view:{money:false}},
{id:"rack",type:"staging",label:"Rack",view:{money:false},checklist:["Piece count matches in vs out","Spots checked"]},
{id:"board",type:"board",label:"Status Board",view:{money:false}},
{id:"tracker",type:"tracker",label:"Customer Tracker",view:{money:false,external:true}},
{id:"office",type:"report",label:"Office",view:{money:true}}
] },
// OZARK-GRADE cleaner — the full plant build: everything the generalized engine can do for a cleaner turned
// on at once (multi-store plant + drop, per-piece HSL tags, quick-drop→detail, smart bag split + in/out
// reconciliation, printing routed by store, a pickup/delivery route, and manager-approved refunds). Proof
// that a plant-grade dry cleaner is buildable from generalized config alone. Names/PINs are generic samples.
ozark: { flowId:"ozark", label:"Full-plant cleaner + route (advanced)", topology:"hub-and-spoke",
blurb:"Everything on — 2-store plant, HSL piece tags, smart assembly, pickup/delivery route, approvals",
branding:{ name:"My Cleaners", brandColor:"#2ea043" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card","account"], closeGate:"balanceLE0", deposit:{pct:50}},
loyalty:{earnPerDollar:1,redeemPoints:100,redeemValue:5}, notify:{template:"Hi {name}, your order #{number} at {biz} is ready for pickup."},
quotes:true, print:true, approvals:{refund:true} },
timer:{ mode:"due", promiseSec:172800, warnSec:86400, label:"promise" },
lifecycle:{ received:"Received — in line", ready:"Ready for pickup", done:"Picked up", dropped:"Received — being itemized",
byStation:{ detail:"Being tagged", assembly:"In cleaning & pressing", rack:"Being racked" },
public:{ byStation:{ detail:"Checking in your order", assembly:"Cleaning your order", rack:"Almost ready" } } },
stores:[ {id:"plant",name:"Main Plant",plant:true}, {id:"drop",name:"Drop Store"} ],
route:{ days:["Mon","Wed","Fri"] },
staff:[ {id:"own",name:"Owner",pin:"1234",role:"owner"}, {id:"mgr",name:"Manager",pin:"2345",role:"manager"}, {id:"prs",name:"Presser",pin:"3456",role:"staff"} ],
catalog:[
{id:"shirt",name:"Laundered Shirt",price:2.99,category:"laundry",path:["assembly","rack"],serialized:true,tagLabel:"HSL",
modifiers:[{group:"Starch",required:true,options:[{name:"None",price:0},{name:"Light",price:0},{name:"Medium",price:0},{name:"Heavy",price:0.5}]}],flags:["Pre-existing damage","Stain noted"]},
{id:"pants",name:"Pants / Slacks",price:7.5,category:"drycleaning",path:["assembly","rack"],serialized:true,tagLabel:"HSL"},
{id:"suit",name:"2-pc Suit",price:14,category:"drycleaning",path:["assembly","rack"],serialized:true,tagLabel:"HSL"},
{id:"dress",name:"Dress",price:12,category:"drycleaning",path:["assembly","rack"],serialized:true,tagLabel:"HSL",flags:["Beads / sequins"]},
{id:"coat",name:"Coat / Jacket",price:11,category:"drycleaning",path:["assembly","rack"],serialized:true,tagLabel:"HSL"},
{id:"comforter",name:"Comforter",price:25,category:"household",path:["assembly","rack"],serialized:true,tagLabel:"HSL"},
{id:"wf",name:"Wash & Fold (per lb)",price:1.75,category:"wf",path:["rack"]}
],
stations:[
{id:"counter",type:"central",label:"Front Counter",view:{money:true}},
{id:"detail",type:"detail",label:"Detail / Tag",view:{money:true}},
{id:"assembly",type:"production",label:"Assembly",view:{money:false},bag:{max:4,solo:["household"],spread:["drycleaning"]},reconcile:true},
{id:"rack",type:"staging",label:"Rack",view:{money:false}},
{id:"route",type:"route",label:"Delivery Route",view:{money:true}},
{id:"board",type:"board",label:"Status Board",view:{money:false}},
{id:"tracker",type:"tracker",label:"Customer Tracker",view:{money:false,external:true}},
{id:"office",type:"report",label:"Office",view:{money:true}}
] },
repair: { flowId:"repair", label:"Repair shop", topology:"hub-and-spoke", blurb:"Intake, estimate, fix, return",
branding:{ name:"My Repair Shop", brandColor:"#e3893c" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", points:["deposit-balance"], deposit:{pct:50}}, quotes:true, notify:{template:"Hi {name}, your repair #{number} at {biz} is ready."} },
timer:{ mode:"aging", warnSec:600, badSec:1200, label:"in shop" },
catalog:[ {id:"r1",name:"Screen repair",price:129,category:"repair",path:["diagnose","repair","ready"],flags:["Data-loss waiver"]},
{id:"r2",name:"Battery",price:59,category:"repair",path:["repair","ready"]}, {id:"r3",name:"Diagnostic",price:25,category:"repair",path:["diagnose","ready"]} ],
stations:[ {id:"counter",type:"central",label:"Front Counter",view:{money:true}}, {id:"diagnose",type:"production",label:"Diagnostics",view:{money:false}}, {id:"repair",type:"production",label:"Repair Bench",view:{money:false}}, {id:"ready",type:"staging",label:"Ready Shelf",view:{money:false},checklist:["Powered on & tested","Cleaned"]}, {id:"board",type:"board",label:"Job Board",view:{money:false}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] },
salon: { flowId:"salon", label:"Salon / Services", topology:"hub-and-spoke", blurb:"Appointments, commission, tips",
branding:{ name:"My Salon", brandColor:"#b06fdb" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[15,18,20]}}, loyalty:{earnPerDollar:1,redeemPoints:20,redeemValue:5}, notify:{template:"Hi {name}, you're all set at {biz} — see you soon!"} },
performers:["Alex","Sam","Jordan"], commission:{ pct:40 },
staff:[{id:"e1",name:"Alex",pin:"1111"},{id:"e2",name:"Sam",pin:"2222"},{id:"e3",name:"Jordan",pin:"3333"}],
welcome:{ message:"Make someone's day today ✂️", specials:["Ask about the color special"] },
catalog:[ {id:"s1",name:"Haircut",price:35,category:"service",path:["chair"],performer:true}, {id:"s2",name:"Color",price:85,category:"service",path:["chair"],performer:true}, {id:"s3",name:"Product",price:22,category:"retail",path:[]} ],
stations:[ {id:"desk",type:"central",label:"Front Desk",view:{money:true}}, {id:"chair",type:"production",label:"Chair",view:{money:false}}, {id:"book",type:"booking",label:"Appointments",view:{}}, {id:"clock",type:"timeclock",label:"Time Clock",view:{}}, {id:"sched",type:"schedule",label:"Schedule",view:{}}, {id:"office",type:"report",label:"Back Office",view:{money:true}} ] },
// A REAL restaurant template — the Hamburger Barn menu (Arkadelphia, AR). Public menu; prices are
// sensible estimates the owner edits. One order fans out to the grill, the fry station, and the shake bar.
burgerbarn: { flowId:"burgerbarn", label:"Hamburger Barn (burger joint)", topology:"hub-and-spoke", blurb:"A real burger-joint menu — grill · fry · shakes",
branding:{ name:"Hamburger Barn", brandColor:"#a3312a" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[15,18,20]}, split:true} },
timer:{ mode:"aging", warnSec:360, badSec:720, label:"ticket" }, capacity:{ perOrderMins:6, max:15 }, kds:{warnSec:360,badSec:720},
catalog:[
// ---- BURGERS → grill ----
{id:"bubba",name:"Bubba Burger",price:13,category:"burger",path:["grill"],
modifiers:[{group:"Patty",required:true,options:[{name:"Single",price:0},{name:"Double",price:3}]}],
addons:[{name:"Bacon",price:1.5},{name:"Extra cheese",price:1},{name:"Jalapeños",price:0.5},{name:"Grilled onions",price:0.5}],
flags:["Allergy note"]},
{id:"mushswiss",name:"Mushroom Swiss Burger",price:12.5,category:"burger",path:["grill"],addons:[{name:"Bacon",price:1.5}]},
{id:"gouda",name:"Gouda Burger",price:12.5,category:"burger",path:["grill"]},
{id:"chipotle",name:"Chipotle Burger",price:12.5,category:"burger",path:["grill"]},
{id:"cheeseburger",name:"Cheeseburger",price:9,category:"burger",path:["grill"],
modifiers:[{group:"Cheese",required:true,options:[{name:"American",price:0},{name:"Swiss",price:0},{name:"Cheddar",price:0},{name:"Pepper Jack",price:0}]}]},
{id:"cfs",name:"Chicken Fried Steak",price:13,category:"plate",path:["grill"]},
{id:"grillchick",name:"Grilled Chicken Sandwich",price:10,category:"sandwich",path:["grill"]},
// ---- FRIED APPS & PLATES → fry ----
{id:"onionrings",name:"Onion Rings",price:6,category:"app",path:["fry"]},
{id:"friedpickles",name:"Fried Pickles",price:6,category:"app",path:["fry"]},
{id:"greenbeans",name:"Fried Green Beans",price:6,category:"app",path:["fry"]},
{id:"cheesesticks",name:"Big Cheese Sticks",price:7,category:"app",path:["fry"]},
{id:"friedmush",name:"Fried Mushrooms",price:6,category:"app",path:["fry"]},
{id:"trio",name:"Big Teaser Trio",price:9,category:"app",path:["fry"]},
{id:"catfish",name:"3-pc Catfish Plate",price:13,category:"plate",path:["fry"]},
{id:"fries",name:"Fries",price:3,category:"side",path:["fry"]},
// ---- SHAKES → shake bar ----
{id:"shake",name:"Milkshake",price:5,category:"shake",path:["shakes"],
modifiers:[{group:"Flavor",required:true,options:[{name:"Vanilla",price:0},{name:"Chocolate",price:0},{name:"Strawberry",price:0}]}]},
// ---- DRINKS → handed over at the counter (no path) ----
{id:"drink",name:"Fountain Drink",price:2.5,category:"drink",path:[]},
{id:"tea",name:"Sweet Tea",price:2.5,category:"drink",path:[]},
// ---- daily special with an 86 count ----
{id:"special",name:"Blue Plate Special",price:10,category:"plate",path:["grill"],par:10}
],
stations:[
{id:"counter",type:"central",label:"Front Counter",view:{money:true}},
{id:"grill",type:"production",label:"Grill",view:{money:false}},
{id:"fry",type:"production",label:"Fry Station",view:{money:false}},
{id:"shakes",type:"production",label:"Shake Bar",view:{money:false}},
{id:"kds",type:"kds",label:"Kitchen Display",view:{money:false}},
{id:"office",type:"report",label:"Office",view:{money:true}}
] },
bistro: { flowId:"bistro", label:"Full-service restaurant", topology:"hub-and-spoke", blurb:"Dine-in — tables, floor plan, kitchen & bar",
branding:{ name:"My Bistro", brandColor:"#7a1f2b" },
endpoints:{ customer:{persist:false}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", tip:{presets:[18,20,22]}, split:true}, coursing:true },
courses:["Appetizers","Entrées","Desserts"],
timer:{ mode:"aging", warnSec:600, badSec:1200, label:"ticket" }, kds:{warnSec:420,badSec:900},
floor:{ label:"Dining Room", warnSec:900, sections:["Main","Patio","Bar"], tables:[
{id:"t1",label:"1",seats:2,section:"Main"}, {id:"t2",label:"2",seats:2,section:"Main"}, {id:"t3",label:"3",seats:4,section:"Main"},
{id:"t4",label:"4",seats:4,section:"Main"}, {id:"t5",label:"5",seats:6,section:"Main"},
{id:"p1",label:"P1",seats:4,section:"Patio"}, {id:"p2",label:"P2",seats:4,section:"Patio"},
{id:"b1",label:"B1",seats:1,section:"Bar"}, {id:"b2",label:"B2",seats:1,section:"Bar"}, {id:"b3",label:"B3",seats:1,section:"Bar"} ] },
catalog:[
{id:"cala",name:"Calamari",price:12,category:"app",path:["line"],course:1},
{id:"wedge",name:"Wedge Salad",price:9,category:"salad",path:["cold"],course:1},
{id:"steak",name:"Ribeye",price:34,category:"entree",path:["line"],course:2,modifiers:[{group:"Temp",required:true,options:[{name:"Rare",price:0},{name:"Med rare",price:0},{name:"Medium",price:0},{name:"Well",price:0}]}]},
{id:"salmon",name:"Salmon",price:26,category:"entree",path:["line"],course:2},
{id:"burger",name:"Bistro Burger",price:16,category:"entree",path:["line"],course:2},
{id:"wine",name:"House Wine",price:11,category:"drink",path:["bar"],course:1},
{id:"beer",name:"Draft Beer",price:7,category:"drink",path:["bar"],course:1},
{id:"cake",name:"Chocolate Cake",price:10,category:"dessert",path:["cold"],course:3}
],
stations:[
{id:"floor",type:"floor",label:"Floor",view:{}},
{id:"server",type:"central",label:"Server Station",view:{money:true}},
{id:"line",type:"production",label:"Kitchen Line",view:{money:false}},
{id:"cold",type:"production",label:"Cold Station",view:{money:false}},
{id:"bar",type:"production",label:"Bar",view:{money:false}},
{id:"kds",type:"kds",label:"Kitchen Display",view:{money:false}},
{id:"office",type:"report",label:"Office",view:{money:true}}
] },
blank: { flowId:"blank", label:"Start from scratch", topology:"linear", blurb:"A blank slate — add your own items, stations & rules",
branding:{ name:"My Business", brandColor:"#1f6feb" },
endpoints:{ customer:{persist:true}, payment:{tenders:["cash","card"], closeGate:"balanceLE0", split:true }, tax:{rate:0}, discounts:true },
catalog:[],
stations:[ {id:"reg",type:"central",label:"Register",view:{money:true}}, {id:"office",type:"report",label:"Office",view:{money:true}} ] }
};
const STATION_TYPES = [
["intake","Intake — starts orders"], ["central","Counter — starts & finishes"], ["production","Work station — items pass through"],
["staging","Staging / rack — hold until ready"], ["fulfillment","Checkout — finishes orders"],
["board","Status board (view only)"], ["tracker","Customer tracker (sanitized)"], ["report","Reports / Z-report / refunds"],
["timeclock","Time clock (staff PIN in/out)"], ["booking","Appointments (book & check in)"],
["kds","Kitchen display (bump tickets)"], ["floor","Floor / table plan (dine-in)"],
["schedule","Staff scheduling (weekly grid)"], ["worker","Worker portal (staff self-service)"]
];
const PATH_TYPES = ["production","staging"]; // the station types an item can flow THROUGH
/* ---- wizard state ---- */
let step=1, tradeKey=null, cfg=null, selStation=-1, selItem=-1, showImport=false, selFloorTable=null;
let gstep=1, guide={}; // guided-interview sub-wizard (Shape → Config → People → Pay → Deployment)
function flashB(msg){ let t=document.getElementById('bToast'); if(!t){ t=document.createElement('div'); t.id='bToast'; t.style.cssText='position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:#1f6feb;color:#fff;padding:10px 16px;border-radius:8px;z-index:99;font-weight:600'; document.body.appendChild(t); } t.textContent=msg; t.style.display='block'; }
// bulk item import: parse "name, price, category, barcode" rows (header auto-detected) into the catalog
function importItemsCSV(text){
const rows=(text||'').split(/\r?\n/).map(r=>r.trim()).filter(Boolean);
let added=0;
rows.forEach((row,i)=>{
const c=row.split(',').map(s=>s.trim());
if(i===0 && /name/i.test(c[0]) && (/(price|cost)/i.test(c[1]||''))) return; // skip a header row
if(!c[0]) return;
const it={ id:uid(), name:c[0], price:Number(c[1])||0, category:c[2]||'item', path:[] };
if(c[3]) it.barcode=c[3];
cfg.catalog.push(it); added++;
});
return added;
}
function chooseTrade(k){ tradeKey=k; cfg=JSON.parse(JSON.stringify(TEMPLATES[k])); selStation=-1; selItem=-1; step=2; render(); }
/* ---- guided interview: a plain-language path for non-technical owners (Shape → Config → People → Pay → Run) ---- */
const DEPLOY_NOTE = {
one: "**One computer.** Everything lives in this browser on that device — no server, no monthly fee. Use **Data & backup → Backup (JSON)** now and then (or let Claude Code automate it) so a copy lives somewhere safe.",
several: "**Several computers.** Run one small sync hub on an always-on machine (a spare PC or a ~a-few-dollars/month cloud box): `CUSTOMPOS_ADMIN_KEY=<a long random key> node facts/server.js --db ../custompos-hub-data/facts.db --with-blob` (Node 22+; its data folder sits beside the app's folder, never inside it — the hub refuses that, since it serves the app's folder). It answers both the time clock, which runs on the v2 engine so every punch is on every station, and the shared records. Give each device a name and a setup token from the hub (`POST /v2/admin/enroll` with your key — ask Claude Code to do it for you); the time clock asks for them once. Each device keeps its own copy, so a dropped connection never stops a sale or a punch. The records part is open, as the sync hub always was: keep the hub on your own network, or put a proxy with a password in front before opening it to the internet.",
backup: "**Several computers + off-site backup.** As above with the sync hub, plus schedule the hub's rolling snapshots to copy off-site (another drive or cloud) on a timer — so a dead hard drive is never the end of your data. Ask Claude Code to set the backup schedule up for you."
};
function startGuide(){ step='guide'; gstep=1; guide={}; render(); }
function guideTrade(k){ tradeKey=k; cfg=JSON.parse(JSON.stringify(TEMPLATES[k])); selStation=-1; selItem=-1; render(); }
function ensureStation(type,label){ if(!cfg.stations.some(s=>s.type===type)) cfg.stations.push({ id:uid(), type, label, view:{} }); }
function dropStation(type){ cfg.stations=cfg.stations.filter(s=>s.type!==type); }
function guideTeam(has){ guide.team=has;
if(has){ ensureStation('timeclock','Time Clock'); ensureStation('schedule','Schedule'); ensureStation('worker','My Portal');
if(!cfg.staff||!cfg.staff.length) cfg.staff=[{ id:uid(), name:'You', pin:'1111', wage:0 }];
if(!cfg.endpoints.notify) cfg.endpoints.notify={template:"Hi {name}, your order #{number} at {biz} is ready."}; } // scheduling/safety texts ride the notify seam
else { dropStation('timeclock'); dropStation('schedule'); dropStation('worker'); }
render();
}
/* several stations → facts mode for the time clock, with the hub's address if it is known (the device asks for it otherwise) */
function guideFinish(){
if(guide.deploy==='several' || guide.deploy==='backup'){
const hub=(guide.hub||'').trim();
if(hub && !/^https?:\/\/[^\s"'<>]+$/.test(hub)){ flashB("The hub's address should look like https://hub.example — or leave it blank and fill it in on each device"); return; } // stage-2 review: it goes into the download
cfg.storage='facts'; cfg.factsHub=hub; }
else { delete cfg.storage; delete cfg.factsHub; }
buildAndShow();
}
/* ---- flow preview (clickable stations) ---- */
function flowPreview(cfg, clickable){
const intake = cfg.stations.find(s=>["intake","central"].includes(s.type)) || cfg.stations[0];
const end = cfg.stations.find(s=>s.type==="fulfillment") || cfg.stations.find(s=>s.type==="central") || intake;
const mids = cfg.stations.filter(s=>PATH_TYPES.includes(s.type));
const wrap=h('div',{class:'flow',id:'flowPrev'});
const add=(label,idx,fixed)=>{ const n=h('span',{class:'node'+(fixed?' fixed':''), onclick: (!fixed&&clickable&&idx>=0)?(()=>selectStation(idx)):null}, [label]); wrap.appendChild(n); };
add('Customer',-1,true);
wrap.appendChild(h('span',{class:'arrow'},['→']));
add(intake.label, cfg.stations.indexOf(intake));
mids.forEach(m=>{ wrap.appendChild(h('span',{class:'arrow'},['→'])); add(m.label, cfg.stations.indexOf(m)); });
if(end!==intake){ wrap.appendChild(h('span',{class:'arrow'},['→'])); add(end.label, cfg.stations.indexOf(end)); }
wrap.appendChild(h('span',{class:'arrow'},['→'])); add('Payment',-1,true);
return wrap;
}
function enabledCount(cfg){ return { items:cfg.catalog.length, stations:cfg.stations.length }; }
/* ---- selection ---- */
function selectStation(i){ selStation=i; selItem=-1; render(); }
function selectItem(i){ selItem=i; selStation=-1; render(); }
/* ---- business + payments controls ---- */
function pay(){ return cfg.endpoints.payment; }
function hasTender(t){ return (pay().tenders||[]).includes(t); }
function toggleTender(t){ const a=pay().tenders||(pay().tenders=[]); const i=a.indexOf(t); if(i<0)a.push(t); else a.splice(i,1); render(); }
function toggleTip(){ if(pay().tip) delete pay().tip; else pay().tip={presets:[15,18,20]}; render(); }
function toggleTipPool(){ if(pay().tipPool) delete pay().tipPool; else pay().tipPool=true; render(); }
function toggleRoundUp(){ if(pay().roundUp) delete pay().roundUp; else pay().roundUp={cause:"a local cause"}; render(); }
function toggleLoyalty(){ if(cfg.endpoints.loyalty) delete cfg.endpoints.loyalty; else cfg.endpoints.loyalty={earnPerDollar:1,redeemPoints:100,redeemValue:5}; render(); }
function setDeposit(v){ v=Number(v)||0; if(v>0){ pay().deposit={pct:v}; if(!(pay().points||[]).includes("deposit-balance")) pay().points=["deposit-balance"]; } else { delete pay().deposit; } }
function setTimer(mode){ if(mode==="off"){ delete cfg.timer; } else if(mode==="aging"){ cfg.timer={mode:"aging",warnSec:300,badSec:600,label:"prep"}; } else { cfg.timer={mode:"due",promiseSec:172800,warnSec:86400,label:"promise"}; } render(); }
function setCapacity(v){ v=Number(v)||0; if(v>0) cfg.capacity={perOrderMins:(cfg.capacity&&cfg.capacity.perOrderMins)||4, max:v}; else delete cfg.capacity; }
function toggleDiscounts(){ if(cfg.endpoints.discounts) delete cfg.endpoints.discounts; else cfg.endpoints.discounts=true; render(); }
function toggleNotify(){ if(cfg.endpoints.notify) delete cfg.endpoints.notify; else cfg.endpoints.notify={template:"Hi {name}, your order #{number} at {biz} is ready."}; render(); }
function toggleSplit(){ if(pay().split) delete pay().split; else pay().split=true; render(); }
function toggleScan(){ if(cfg.endpoints.scan) delete cfg.endpoints.scan; else cfg.endpoints.scan=true; render(); }
function toggleQuotes(){ if(cfg.endpoints.quotes) delete cfg.endpoints.quotes; else cfg.endpoints.quotes=true; render(); }
function toggleCoursing(){ if(cfg.endpoints.coursing) delete cfg.endpoints.coursing; else { cfg.endpoints.coursing=true; if(!cfg.courses) cfg.courses=["Appetizers","Entrées","Desserts"]; } render(); }
function couponList(){ return Array.isArray(cfg.endpoints.discounts)?cfg.endpoints.discounts:[]; }
function addCoupon(){ const list=couponList(); list.push({code:"SAVE10", pct:10}); cfg.endpoints.discounts=list; render(); }
function removeCoupon(i){ const list=couponList(); list.splice(i,1); cfg.endpoints.discounts=list.length?list:true; render(); }
function setTax(v){ v=Number(v)||0; const prev=cfg.endpoints.tax||{}; if(v>0){ cfg.endpoints.tax={rate:v/100}; if(prev.included) cfg.endpoints.tax.included=true; if(Array.isArray(prev.zones)&&prev.zones.length) cfg.endpoints.tax.zones=prev.zones; if(prev.classes&&Object.keys(prev.classes).length) cfg.endpoints.tax.classes=prev.classes; } else delete cfg.endpoints.tax; }
function taxClassNames(){ const t=cfg.endpoints.tax; return (t&&t.classes)?Object.keys(t.classes):[]; }
function taxClassesEditor(){ // per-category tax rates (grocery 0%, prepared food 8%, …)
if(!cfg.endpoints.tax) return null;
const cls=cfg.endpoints.tax.classes||{}; const entries=Object.keys(cls).map(k=>[k, cls[k]]);
const rebuild=(es)=>{ const o={}; es.forEach(([k,v])=>{ const kk=(k||'').trim(); if(kk) o[kk]=(+v||0); }); if(Object.keys(o).length) cfg.endpoints.tax.classes=o; else delete cfg.endpoints.tax.classes; render(); };
const rows=entries.map((pair,i)=>h('div',{class:'row2'},[
h('input',{class:'nm', value:pair[0], placeholder:'class name (e.g. grocery)', onchange:e=>{ entries[i][0]=e.target.value; rebuild(entries); }}),
h('span',{class:'muted'},['%']), h('input',{class:'sm',type:'number',step:'0.01', value:+((+pair[1]||0)*100).toFixed(2), oninput:e=>{ entries[i][1]=(Number(e.target.value)||0)/100; }, onchange:()=>rebuild(entries)}),
h('button',{class:'danger', onclick:()=>{ entries.splice(i,1); rebuild(entries); }},['×']) ]));
return h('div',{class:'fld', style:'flex-direction:column;align-items:stretch'},[
h('div',{},[ h('span',{class:'flab'},['Tax classes']), h('span',{class:'hint'},['charge different rates for different kinds of item (e.g. grocery 0%, prepared food 8%) — then set each item’s class in its editor; items with no class use the rate above']) ]),
...rows, h('button',{onclick:()=>{ cfg.endpoints.tax.classes=cfg.endpoints.tax.classes||{}; let n=1; while(cfg.endpoints.tax.classes['class'+n]!=null) n++; cfg.endpoints.tax.classes['class'+n]=cfg.endpoints.tax.rate||0; render(); }},['+ Add a tax class']) ]);
}
function addTaxZone(){ if(!cfg.endpoints.tax) return; cfg.endpoints.tax.zones=cfg.endpoints.tax.zones||[]; cfg.endpoints.tax.zones.push({name:"Delivery area", rate:cfg.endpoints.tax.rate||0}); render(); }
function removeTaxZone(i){ if(!(cfg.endpoints.tax&&cfg.endpoints.tax.zones)) return; cfg.endpoints.tax.zones.splice(i,1); if(!cfg.endpoints.tax.zones.length) delete cfg.endpoints.tax.zones; render(); }
function taxZonesEditor(){ // destination sales tax for delivery: name + rate per area
if(!cfg.endpoints.tax) return null;
const zones=cfg.endpoints.tax.zones||[];
const rows=zones.map((z,i)=>h('div',{class:'row2'},[
h('input',{class:'nm', value:z.name, placeholder:'Town / area', oninput:e=>z.name=e.target.value}),
h('span',{class:'muted'},['%']), h('input',{class:'sm',type:'number',step:'0.01', value:+( (z.rate||0)*100).toFixed(2), oninput:e=>z.rate=(Number(e.target.value)||0)/100}),
h('button',{class:'danger', onclick:()=>removeTaxZone(i)},['×']) ]));
return h('div',{class:'fld', style:'flex-direction:column;align-items:stretch'},[
h('div',{},[ h('span',{class:'flab'},['Delivery tax areas']), h('span',{class:'hint'},['deliveries are taxed at the destination\'s rate — add each town you deliver to (the shop\'s own rate above is the default)']) ]),
...rows, h('button',{onclick:addTaxZone},['+ Add a delivery area']) ]);
}
function toggleTaxIncluded(){ if(!cfg.endpoints.tax) return; if(cfg.endpoints.tax.included) delete cfg.endpoints.tax.included; else cfg.endpoints.tax.included=true; render(); }
/* ---- staff & time clock ---- */
function addStaff(){ cfg.staff=cfg.staff||[]; cfg.staff.push({ id:uid(), name:"New person", pin:String(1000+cfg.staff.length) }); render(); }
function removeStaff(i){ cfg.staff.splice(i,1); if(!cfg.staff.length) delete cfg.staff; render(); }
function setWelcome(field,v){ cfg.welcome=cfg.welcome||{}; if(field==='specials'){ cfg.welcome.specials=v.split('\n').map(s=>s.trim()).filter(Boolean); if(!cfg.welcome.specials.length) delete cfg.welcome.specials; } else { if(v) cfg.welcome[field]=v; else delete cfg.welcome[field]; } if(!Object.keys(cfg.welcome).length) delete cfg.welcome; }
/* ---- stations ---- */
function addStation(){ cfg.stations.push({ id:uid(), type:"production", label:"New station", view:{money:false} }); selStation=cfg.stations.length-1; selItem=-1; render(); }
function removeStation(i){ const id=cfg.stations[i].id; cfg.stations.splice(i,1); cfg.catalog.forEach(it=>{ it.path=(it.path||[]).filter(p=>p!==id); }); selStation=-1; render(); }
function moveStation(i, dir){ const j=i+dir; if(j<0||j>=cfg.stations.length) return; const s=cfg.stations; const t=s[i]; s[i]=s[j]; s[j]=t; selStation=j; render(); } // reorder the flow
/* ---- floor plan designer (drag tables to lay out the room) ---- */
function floorTables(){ cfg.floor=cfg.floor||{label:'Floor',tables:[]}; cfg.floor.tables=cfg.floor.tables||[]; return cfg.floor.tables; }
function addTable(){ const list=floorTables(); const n=list.length; list.push({ id:uid(), label:String(n+1), seats:2, section:'', x:10+(n%6)*96, y:10+Math.floor(n/6)*80 }); selFloorTable=list[list.length-1].id; render(); }
function removeTable(id){ cfg.floor.tables=floorTables().filter(t=>t.id!==id); selFloorTable=null; render(); }
function floorDesigner(){
const list=floorTables();
list.forEach((t,i)=>{ if(t.x==null) t.x=10+(i%6)*96; if(t.y==null) t.y=10+Math.floor(i/6)*80; }); // auto-place any without a position
const canvas=h('div',{class:'floorcanvas'},[]);
list.forEach(t=>{
const tile=h('div',{class:'ftile'+(selFloorTable===t.id?' sel':''), style:`left:${t.x}px;top:${t.y}px`},[ h('b',{},[t.label||'?']), h('small',{},[(t.seats||0)+' seats'+(t.section?' · '+t.section:'')]) ]);
tile.onpointerdown=(e)=>{ e.preventDefault(); const sx=e.clientX, sy=e.clientY, ox=t.x, oy=t.y; let moved=false;
const mv=(ev)=>{ const dx=ev.clientX-sx, dy=ev.clientY-sy; if(Math.abs(dx)+Math.abs(dy)>3) moved=true; tile.style.left=Math.max(0,ox+dx)+'px'; tile.style.top=Math.max(0,oy+dy)+'px'; };
const up=(ev)=>{ document.removeEventListener('pointermove',mv); document.removeEventListener('pointerup',up);
if(moved){ const dx=ev.clientX-sx, dy=ev.clientY-sy; t.x=Math.max(0,Math.round((ox+dx)/8)*8); t.y=Math.max(0,Math.round((oy+dy)/8)*8); selFloorTable=t.id; render(); }
else { selFloorTable=(selFloorTable===t.id?null:t.id); render(); } };
document.addEventListener('pointermove',mv); document.addEventListener('pointerup',up); };
canvas.appendChild(tile);
});
const wrap=h('div',{},[ canvas, h('button',{onclick:addTable},['+ Add table']) ]);
const t=list.find(x=>x.id===selFloorTable);
if(t){ wrap.appendChild(h('div',{class:'ed', style:'margin-top:10px'},[
h('h3',{},['Table '+(t.label||'')]),
h('div',{class:'fld'},[ h('span',{class:'flab'},['Label']), h('input',{class:'sm',value:t.label||'', oninput:e=>{ t.label=e.target.value; }}),
h('span',{class:'flab'},['Seats']), h('input',{class:'sm',type:'number',value:t.seats||'', oninput:e=>t.seats=Number(e.target.value)||0}),
h('span',{class:'flab'},['Section']), h('input',{class:'sm',value:t.section||'', placeholder:'e.g. Patio', oninput:e=>{ if(e.target.value) t.section=e.target.value; else delete t.section; }}) ]),
h('button',{class:'danger', onclick:()=>removeTable(t.id)},['Delete table'])
])); }
return wrap;
}
function stationEditor(i){
const s=cfg.stations[i];
const typeSel=h('select',{onchange:e=>{ s.type=e.target.value; if(!PATH_TYPES.includes(s.type)&&s.type!=='production') s.view=s.view||{money:false}; render(); }},
STATION_TYPES.map(([v,l])=>h('option',{value:v, selected:s.type===v},[l])));
const nameInp=h('input',{id:'stationName', class:'nm',value:s.label, oninput:e=>{ s.label=e.target.value; document.getElementById('flowPrev').replaceWith(flowPreview(cfg,true)); }});
const moneyBtn=h('button',{class:(s.view&&s.view.money)?'on':'', onclick:()=>{ s.view=s.view||{}; s.view.money=!s.view.money; render(); }}, [(s.view&&s.view.money)?'✓ shows prices':'prices hidden']);
// checklist
const cl=s.checklist||[];
const clRows=h('div',{}, cl.map((step,idx)=>h('div',{class:'row2'},[
h('input',{class:'nm',value:step, oninput:e=>{ s.checklist[idx]=e.target.value; }}),
h('button',{class:'danger', onclick:()=>{ s.checklist.splice(idx,1); if(!s.checklist.length) delete s.checklist; render(); }},['remove'])
])));
const addStep=h('button',{onclick:()=>{ s.checklist=s.checklist||[]; s.checklist.push("New step"); render(); }},['+ checklist step']);
return h('div',{class:'ed'},[
h('h3',{},['Workstation']),
h('div',{class:'fld'},[h('span',{class:'flab'},['Name']), nameInp]),
h('div',{class:'fld'},[h('span',{class:'flab'},['Role']), typeSel]),
h('div',{class:'fld'},[h('span',{class:'flab'},['Money view']), moneyBtn, h('span',{class:'hint'},['work stations usually hide prices'])]),
h('div',{class:'fld'},[h('span',{class:'flab'},['QC checklist']), h('span',{class:'hint'},['all steps must be ticked before this station can pass an order on'])]),
clRows, addStep,
h('div',{class:'fld'},[ h('span',{class:'flab'},['Order in flow']),
h('button',{disabled:i===0, onclick:()=>moveStation(i,-1)},['▲ earlier']),
h('button',{disabled:i===cfg.stations.length-1, onclick:()=>moveStation(i,1)},['▼ later']),
h('span',{class:'hint'},['position '+(i+1)+' of '+cfg.stations.length]) ]),
h('div',{style:'margin-top:12px'},[ h('button',{class:'danger', onclick:()=>removeStation(i)},['Delete workstation']), h('button',{onclick:()=>{selStation=-1;render();}},['Done']) ])
]);
}
/* ---- items ---- */
function addItem(){ cfg.catalog.push({ id:uid(), name:"New item", price:0, category:"item", path:[] }); selItem=cfg.catalog.length-1; selStation=-1; render(); }
function removeItem(i){ cfg.catalog.splice(i,1); selItem=-1; render(); }
function itemEditor(i){
const it=cfg.catalog[i];
const pathStations=cfg.stations.filter(s=>PATH_TYPES.includes(s.type));
// PATH — which workstations this item flows through (modules follow the item)
const pathRow=h('div',{class:'row2'}, pathStations.length?pathStations.map(s=>{
const on=(it.path||[]).includes(s.id);
return h('button',{class:on?'on':'', onclick:()=>{ it.path=it.path||[]; const j=it.path.indexOf(s.id); if(j<0){ // keep station order
it.path = cfg.stations.filter(x=>PATH_TYPES.includes(x.type)&&(x.id===s.id||it.path.includes(x.id))).map(x=>x.id);
} else it.path.splice(j,1); document.getElementById('flowPrev').replaceWith(flowPreview(cfg,true)); render(); }},[s.label]);
}):[h('span',{class:'hint'},['(no work stations yet — add one below to give items a path)'])]);
// modifiers (one required choice group, optional)
const mod=(it.modifiers&&it.modifiers[0])||null;
const modBlock=h('div',{},[]);
if(mod){
modBlock.appendChild(h('div',{class:'row2'},[ h('span',{class:'flab'},['Choice name']), h('input',{class:'nm', value:mod.group, oninput:e=>mod.group=e.target.value}), h('button',{class:'danger',onclick:()=>{ delete it.modifiers; render(); }},['remove choice']) ]));
mod.options.forEach((o,oi)=>modBlock.appendChild(h('div',{class:'row2'},[
h('input',{class:'nm',value:o.name, oninput:e=>o.name=e.target.value}),
h('span',{class:'muted'},['+$']), h('input',{class:'sm',type:'number',value:o.price, oninput:e=>o.price=Number(e.target.value)||0}),
h('button',{class:'danger',onclick:()=>{ mod.options.splice(oi,1); render(); }},['×'])
])));
modBlock.appendChild(h('button',{onclick:()=>{ mod.options.push({name:"Option",price:0}); render(); }},['+ option']));
} else {
modBlock.appendChild(h('button',{onclick:()=>{ it.modifiers=[{group:"Size",required:true,options:[{name:"Regular",price:0}]}]; render(); }},['+ add a required choice (size, temp, starch…)']));
}
// add-ons
const addons=it.addons||[];
const addonRows=h('div',{}, addons.map((a,ai)=>h('div',{class:'row2'},[ h('input',{class:'nm',value:a.name,oninput:e=>a.name=e.target.value}), h('span',{class:'muted'},['+$']), h('input',{class:'sm',type:'number',value:a.price,oninput:e=>a.price=Number(e.target.value)||0}), h('button',{class:'danger',onclick:()=>{ it.addons.splice(ai,1); if(!it.addons.length) delete it.addons; render(); }},['×']) ])));
// flags
const flags=it.flags||[];
const flagRows=h('div',{}, flags.map((f,fi)=>h('div',{class:'row2'},[ h('input',{class:'nm',value:f,oninput:e=>it.flags[fi]=e.target.value}), h('button',{class:'danger',onclick:()=>{ it.flags.splice(fi,1); if(!it.flags.length) delete it.flags; render(); }},['×']) ])));
return h('div',{class:'ed'},[
h('h3',{},['Item']),
h('div',{class:'fld'},[h('span',{class:'flab'},['Name']), h('input',{id:'itemName', class:'nm',value:it.name, oninput:e=>{ it.name=e.target.value; }})]),
h('div',{class:'fld'},[h('span',{class:'flab'},['Price $']), h('input',{id:'itemPrice', class:'sm',type:'number',value:it.price, oninput:e=>it.price=Number(e.target.value)||0}), h('span',{class:'flab'},['Cost $']), h('input',{class:'sm',type:'number',value:it.cost||'', placeholder:'0', title:'what it costs you (for margin)', oninput:e=>{ const v=Number(e.target.value)||0; if(v) it.cost=v; else delete it.cost; }}), h('span',{class:'flab'},['Category']), h('input',{class:'nm',value:it.category, oninput:e=>it.category=e.target.value})]),
h('div',{class:'fld'},[h('span',{class:'flab'},['Flows through']), h('span',{class:'hint'},['the workstations this item visits, in order — modules follow the item'])]),
pathRow,
h('div',{class:'fld'},[h('span',{class:'flab'},['Required choice']), h('span',{class:'hint'},['must be picked before it can be sent'])]), modBlock,
h('div',{class:'fld'},[h('span',{class:'flab'},['Add-ons (upsell)'])]), addonRows, h('button',{onclick:()=>{ it.addons=it.addons||[]; it.addons.push({name:"Add-on",price:0}); render(); }},['+ add-on']),
h('div',{class:'fld'},[h('span',{class:'flab'},['Flags / warnings']), h('span',{class:'hint'},['e.g. allergy, pre-existing damage — shown bold, must be acknowledged'])]), flagRows, h('button',{onclick:()=>{ it.flags=it.flags||[]; it.flags.push("Warning"); render(); }},['+ flag']),
h('div',{class:'fld'},[
h('span',{class:'flab'},['Performed by staff']), h('button',{class:it.performer?'on':'', onclick:()=>{ it.performer=!it.performer; if(!it.performer) delete it.performer; if(it.performer&&!cfg.performers) cfg.performers=["Alex","Sam"]; render(); }},[it.performer?'✓ pick a provider':'no']),
h('span',{class:'flab'},['86 limit']), h('input',{class:'sm',type:'number',value:it.par!=null?it.par:'', placeholder:'∞', oninput:e=>{ const v=Number(e.target.value); if(e.target.value===''||v<=0) delete it.par; else it.par=v; }}),
h('span',{class:'flab'},['Taxable']), h('button',{class:(it.taxable!==false)?'on':'', onclick:()=>{ if(it.taxable===false) delete it.taxable; else it.taxable=false; render(); }},[(it.taxable!==false)?'✓ taxed':'tax-exempt']),
(it.taxable!==false && taxClassNames().length) ? h('span',{class:'flab'},['Tax class']) : null,
(it.taxable!==false && taxClassNames().length) ? h('select',{class:'sm', onchange:e=>{ if(e.target.value) it.taxClass=e.target.value; else delete it.taxClass; }}, [h('option',{value:'', selected:!it.taxClass},['standard rate']), ...taxClassNames().map(n=>h('option',{value:n, selected:it.taxClass===n},[n]))]) : null,
h('span',{class:'flab'},['Age check']), h('button',{class:it.ageRestricted?'on':'', onclick:()=>{ if(it.ageRestricted) delete it.ageRestricted; else it.ageRestricted=21; render(); }},[it.ageRestricted?('✓ '+(it.ageRestricted===true?21:it.ageRestricted)+'+ ID'):'none']),
it.ageRestricted ? h('input',{class:'sm',type:'number',value:(it.ageRestricted===true?21:it.ageRestricted), title:'minimum age', oninput:e=>{ const v=Number(e.target.value)||21; it.ageRestricted=v; }}) : null
]),
h('div',{class:'fld'},[
h('span',{class:'flab'},['Pricing']), h('span',{class:'hint'},['most items are a fixed price; pick another mode only if this one is priced at the counter'])]),
h('div',{class:'fld'},[
h('span',{class:'flab'},['Custom price']), h('button',{class:it.customPrice?'on':'', title:'ask for the price at ring time (quotes, haggling)', onclick:()=>{ if(it.customPrice) delete it.customPrice; else { it.customPrice=true; delete it.byWeight; delete it.unit; } render(); }},[it.customPrice?'✓ ask at ring':'no']),
h('span',{class:'flab'},['By weight']), h('button',{class:it.byWeight?'on':'', title:'price per unit — ask the amount and multiply (per lb, per ft…)', onclick:()=>{ if(it.byWeight){ delete it.byWeight; delete it.unit; } else { it.byWeight=true; it.unit=it.unit||'lb'; delete it.customPrice; } render(); }},[it.byWeight?('✓ per '+(it.unit||'lb')):'no']),
it.byWeight ? h('input',{class:'sm',value:it.unit||'lb', title:'unit: lb, oz, ft, yd…', oninput:e=>{ it.unit=e.target.value||'lb'; }}) : null,
it.byWeight ? h('span',{class:'hint'},['the price above is per '+(it.unit||'lb')]) : null
]),
h('div',{class:'fld'},[
h('span',{class:'flab'},['In stock']), h('input',{class:'sm',type:'number',value:it.stock!=null?it.stock:'', placeholder:'∞', oninput:e=>{ const v=e.target.value; if(v==='') delete it.stock; else it.stock=Number(v)||0; }}),
h('span',{class:'flab'},['Reorder at']), h('input',{class:'sm',type:'number',value:it.reorderAt!=null?it.reorderAt:'', placeholder:'0', oninput:e=>{ const v=e.target.value; if(v==='') delete it.reorderAt; else it.reorderAt=Number(v)||0; }}),
h('span',{class:'hint'},['track on-hand — warns when low, blocks when out'])
]),
h('div',{class:'fld'},[
h('span',{class:'flab'},['Barcode / SKU']), h('input',{class:'nm',value:it.barcode||'', placeholder:'scan or type', oninput:e=>{ if(e.target.value) it.barcode=e.target.value; else delete it.barcode; }}),
h('span',{class:'hint'},['a scanner types this + Enter to ring it (turn on "barcode scan")'])
]),
cfg.endpoints.coursing ? h('div',{class:'fld'},[
h('span',{class:'flab'},['Course']), h('select',{onchange:e=>{ const v=Number(e.target.value); if(v>1) it.course=v; else delete it.course; }},
(cfg.courses||['Course 1','Course 2','Course 3']).map((lab,idx)=>h('option',{value:idx+1, selected:(it.course||1)===idx+1},[lab]))),
h('span',{class:'hint'},['later courses hold in the kitchen until the expo fires them'])
]) : null,
h('div',{style:'margin-top:12px'},[ h('button',{class:'danger', onclick:()=>removeItem(i)},['Delete item']), h('button',{onclick:()=>{selItem=-1;render();}},['Done']) ])
]);
}
/* ---- generated CLAUDE.md ---- */
function genClaudeMd(cfg, build){
const stations=cfg.stations.map(s=>"- **"+s.label+"** ("+s.type+")"+(s.checklist?" · checklist: "+s.checklist.join(", "):"")).join("\n");
const items=cfg.catalog.map(i=>"- "+i.name+" — $"+i.price+(i.path&&i.path.length?" (flows: "+i.path.join(" → ")+")":"")+(i.performer?" · by staff":"")+(i.par!=null?" · 86 at "+i.par:"")).join("\n");
const stamp = build ? `\n> Engine **v${build.version}** · built **${build.builtAt}**. Keep this file with your POS so you know what you're running.\n` : "";
return `# CLAUDE.md — ${cfg.branding.name} (your point-of-sale)
${stamp}
This is **your** customPOS, generated for a ${(TEMPLATES[tradeKey]||{label:'business'}).label.toLowerCase()}. One self-contained
HTML file, runs in a browser, stores data locally. **You own it.** Open this folder in
[Claude Code](https://claude.com/claude-code) and change anything in plain English.
## It's all one object
The \`window.CUSTOMPOS_FLOW = { ... }\` at the top of the HTML is your whole setup:
- **branding** — name, color. **endpoints** — tax, tips, deposits, loyalty, card payments.
- **catalog** — your items. Each has a \`path\` = the workstations it flows through (empty = sold at the counter),
plus optional modifiers, add-ons, flags, a performer, and an 86 limit.
- **stations** — your ${cfg.stations.length} screens/devices. Each device opens the file, signs in, and picks which
station it is; a station may carry a QC \`checklist\` that gates it.
## Your setup
**Business:** ${cfg.branding.name} · **Layout:** ${cfg.topology}${cfg.staff&&cfg.staff.length?` · **Staff:** ${cfg.staff.length} (clock in by PIN on a Time Clock station)`:''}
**Workstations**
${stations}
**Catalog**
${items}
## How you'll run it
${DEPLOY_NOTE[guide.deploy] || DEPLOY_NOTE.one}
## Across devices & payments
Run the optional hub (\`hub.js\`) to share one live POS across devices; otherwise each device is local.
Card payments are PCI-safe — the browser never sees a card number (see \`docs/PAYMENTS-MODULE.md\`); your
processor credentials live only on your own server.
## Ask Claude Code things like
- "Add an item ___ for $___ that flows through ${ (cfg.stations.find(s=>PATH_TYPES.includes(s.type))||{label:'the work station'}).label }."
- "Put a checklist on ___ before it can be marked ready."
- "Text the customer when their order is ready."
*Built with customPOS — software is free, knowledge is free, and this code is yours.*`;
}
/* ---- assemble + download ---- */
/* JSON that is safe inside a script tag: a name holding a closing script tag (or an HTML comment opener) can never end the tag early (stage-2 review) */
function jsonInScript(v){ return JSON.stringify(v).replace(new RegExp("[<" + String.fromCharCode(0x2028, 0x2029) + "]", "g"), function(c){ return String.fromCharCode(92) + "u" + ("000" + c.charCodeAt(0).toString(16)).slice(-4); }); }
async function assemble(cfg){
const engine = (typeof window!=="undefined" && window.__ENGINE_SRC__) ? window.__ENGINE_SRC__ : await fetch('pos.html').then(r=>r.text());
const verM = engine.match(/CUSTOMPOS_VERSION\s*=\s*"([^"]+)"/);
const build = { version: verM?verM[1]:"?", builtAt: new Date().toISOString().slice(0,10), business: cfg.branding.name };
const banner = "<!-- customPOS · "+String(build.business||"").replace(/[<>]|--/g," ")+" · engine v"+build.version+" · built "+build.builtAt+" · your software, your data -->\n";
/* a several-stations download carries NO PINs (stage-2 review): each is typed on a device when the team joins the hub and leaves it only
as a hash, and every PIN screen checks the hub's hashes — the hub serves this file to anyone on its network */
const flow = cfg.storage==='facts' ? Object.assign({}, cfg, { staff: (cfg.staff||[]).map(function(p){ const c=Object.assign({}, p); delete c.pin; return c; }) }) : cfg;
let inject = "<script>window.CUSTOMPOS_FLOW = "+jsonInScript(flow)+"; window.CUSTOMPOS_BUILD = "+jsonInScript(build)+";<\/script>\n";
/* Stage 2: a 'several stations' download carries the v2 engine (facts/bundle.js, built by build.js) and points both the time clock
(facts) and the records (blob sync) at the same hub — one hub answers both (facts/server.js --with-blob) */
if(cfg.storage==='facts'){
let fb = (typeof window!=="undefined" && window.__FACTS_BUNDLE__) ? window.__FACTS_BUNDLE__ : null;
if(!fb){ try{ const r=await fetch('facts.bundle.js'); if(r.ok) fb=await r.text(); }catch(e){} } // facts.bundle.js sits beside pos.html (generated: node facts/bundle.js --out facts.bundle.js)
if(!fb) throw new Error('the v2 engine bundle (facts.bundle.js) could not be loaded beside the builder');
inject = "<script>"+fb.replace(/<\/script/gi,"<\\/script")+"<\/script>\n" + inject + (cfg.factsHub ? "<script>window.CUSTOMPOS_HUB = "+jsonInScript(cfg.factsHub)+";<\/script>\n" : "");
}
/* a replacer FUNCTION, not a string: a replacement string reads $& $' $` $1 as codes, and the engine bundle holds such text (Stage 2:
a "several stations" download broke with "Invalid or unexpected token" until this) */
const html = banner + engine.replace("<script>", function(){ return inject+"<script>"; });
const claudeMd = genClaudeMd(cfg, build);
window.__build = { flow:cfg, html, claudeMd, build };
return { html, claudeMd };
}
function blobUrl(text, type){ return URL.createObjectURL(new Blob([text], {type:type||'text/plain'})); }
async function buildAndShow(){ await assemble(cfg); step=3; render(); }
/* ---- render ---- */
function render(){
const app=document.getElementById('app'); app.innerHTML="";
// ---- guided interview (opt-in from step 1) — plain-language questions for a non-technical owner ----
if(step==='guide'){
app.appendChild(h('div',{class:'step'},['Guided setup · '+gstep+' of 6']));
const cont=(label,to)=>h('button',{class:'primary big', onclick:()=>{ gstep=to; render(); }},[label||'Continue →']);
const back=(to)=>h('button',{onclick:()=>{ gstep=to; render(); }},['← back']);
if(gstep===1){
app.appendChild(h('h2',{},['First — what kind of business is this?']));
app.appendChild(h('p',{class:'hint'},['Pick the closest match; you can change anything later.']));
app.appendChild(h('div',{class:'cards'}, Object.keys(TEMPLATES).map(k=>{ const t=TEMPLATES[k];
return h('button',{class:'trade'+(tradeKey===k?' on':''), onclick:()=>guideTrade(k)},[ h('b',{},[t.label]), h('small',{},[t.blurb]) ]); })));
if(tradeKey) app.appendChild(h('div',{style:'margin-top:12px'},[cont('Continue →',2)]));
return;
}
if(gstep===2){
app.appendChild(h('h2',{},['What should we call it?']));
app.appendChild(h('div',{class:'panel'},[
h('div',{class:'fld'},[ h('span',{class:'flab'},['Business name']), h('input',{id:'gName', class:'nm', style:'flex:1', value:cfg.branding.name, oninput:e=>cfg.branding.name=e.target.value||cfg.branding.name}) ]),
h('div',{class:'fld'},[ h('span',{class:'flab'},['Brand color']), h('input',{type:'color', value:cfg.branding.brandColor, oninput:e=>cfg.branding.brandColor=e.target.value}) ]) ]));
app.appendChild(h('div',{},[ back(1), ' ', cont('Continue →',3) ]));
return;
}
if(gstep===3){
app.appendChild(h('h2',{},['What do you sell?']));
app.appendChild(h('p',{class:'hint'},['We started you with examples — change them to your real items and prices, add more, or paste your whole list.']));
const irows=h('div',{}, cfg.catalog.map((it,i)=>h('div',{class:'row2'},[
h('input',{class:'nm', value:it.name, oninput:e=>it.name=e.target.value}),
h('span',{class:'muted'},['$']), h('input',{class:'sm',type:'number',step:'0.01', value:it.price, oninput:e=>it.price=Number(e.target.value)||0}),
h('input',{class:'sm', value:it.category||'', placeholder:'category', oninput:e=>it.category=e.target.value}),
h('button',{class:'danger', onclick:()=>{ cfg.catalog.splice(i,1); render(); }},['×']) ])));
app.appendChild(h('div',{class:'panel'},[
h('div',{class:'fld'},[ h('span',{class:'flab'},['Your items']), h('span',{class:'hint'},['name · price · a category like "drink" or "service" (a downloaded POS groups by category)'])]),
irows,
h('button',{onclick:()=>{ cfg.catalog.push({id:uid(), name:'New item', price:0, category:'item', path:[]}); render(); }},['+ Add item']),
h('button',{style:'margin-left:8px', onclick:()=>{ guide.showPaste=!guide.showPaste; render(); }},[guide.showPaste?'Close paste':'⇪ Paste a list']),
guide.showPaste ? h('div',{style:'margin-top:10px'},[
h('div',{class:'hint'},['one per line: name, price, category — e.g. "Coffee, 3.50, drink"']),
h('textarea',{id:'gPaste', class:'nm', style:'width:100%;min-height:88px', placeholder:'Coffee, 3.50, drink\nMuffin, 2.75, food'}, []),
h('button',{class:'primary', style:'margin-top:8px', onclick:()=>{ const n=importItemsCSV(document.getElementById('gPaste').value); flashB(n?('Added '+n+' item'+(n>1?'s':'')):'Nothing to add — check the format'); guide.showPaste=false; render(); }},['Add these'])
]) : null
]));
app.appendChild(h('div',{style:'margin-top:8px'},[ back(2), ' ', cont('Continue →',4) ]));
return;
}
if(gstep===4){
app.appendChild(h('h2',{},['Who works here?']));
app.appendChild(h('div',{class:'cards'},[
h('button',{class:'trade'+(guide.team===false?' on':''), onclick:()=>guideTeam(false)},[h('b',{},['Just me']), h('small',{},['No time clock or scheduling — keep it simple.'])]),
h('button',{class:'trade'+(guide.team===true?' on':''), onclick:()=>guideTeam(true)},[h('b',{},['I have a team']), h('small',{},['Time clock, fair scheduling, a worker portal, and a safety line — all on.'])]) ]));
if(guide.team){
const staff=cfg.staff||[];
const rows=h('div',{}, staff.map((s,i)=>h('div',{class:'row2'},[
h('input',{class:'nm', value:s.name, oninput:e=>s.name=e.target.value}),
h('span',{class:'muted'},['PIN']), h('input',{class:'sm', value:s.pin, oninput:e=>s.pin=e.target.value.replace(/\D/g,'').slice(0,8)}),
h('span',{class:'muted'},['$/hr']), h('input',{class:'sm', value:s.wage||'', placeholder:'0', oninput:e=>{ const v=e.target.value.replace(/[^\d.]/g,''); if(v) s.wage=+v; else delete s.wage; }}),
h('span',{class:'muted'},['Role']), h('select',{class:'sm', onchange:e=>{ if(e.target.value==='staff') delete s.role; else s.role=e.target.value; render(); }}, [['staff','staff'],['manager','manager'],['owner','owner']].map(([v,l])=>h('option',{value:v, selected:(s.role||'staff')===v},[l]))),
h('button',{class:'danger', onclick:()=>{ cfg.staff.splice(i,1); render(); }},['×']) ])));
const hasApprover = staff.some(s=>s.role==='manager'||s.role==='owner');
app.appendChild(h('div',{class:'panel'},[
h('h2',{},['Your team']),
h('div',{class:'fld'},[h('span',{class:'flab'},['People']), h('span',{class:'hint'},['name · a PIN they clock in with · hourly wage · role (managers/owners can approve refunds)'])]),
rows, h('button',{onclick:addStaff},['+ Add person']),
h('div',{class:'fld', style:'margin-top:10px'},[ h('span',{class:'flab'},['Tips']), h('button',{class:pay().tipPool?'on':'', onclick:()=>toggleTipPool()},['pool tips by hours (fair split)']) ]),
hasApprover ? h('div',{class:'fld'},[ h('span',{class:'flab'},['Refunds']), h('button',{class:(cfg.endpoints.approvals&&cfg.endpoints.approvals.refund)?'on':'', onclick:()=>{ if(cfg.endpoints.approvals&&cfg.endpoints.approvals.refund) delete cfg.endpoints.approvals; else cfg.endpoints.approvals={refund:true}; render(); }},['require a manager/owner to approve refunds']) ]) : null ]));
}
if(guide.team!=null) app.appendChild(h('div',{style:'margin-top:8px'},[ back(3), ' ', cont('Continue →',5) ]));
return;
}
if(gstep===5){
app.appendChild(h('h2',{},['How do people pay?']));
app.appendChild(h('div',{class:'panel'},[
h('div',{class:'fld'},[ h('span',{class:'flab'},['Take']),
h('button',{class:'on'},['cash']),
h('button',{class:hasTender('card')?'on':'', onclick:()=>toggleTender('card')},['cards']),
h('button',{class:pay().tip?'on':'', onclick:()=>toggleTip()},['tips']),
h('button',{class:cfg.endpoints.notify?'on':'', onclick:()=>toggleNotify()},['text customers when ready']) ]),
hasTender('card') ? h('div',{class:'hint'},['Heads up: "cards" records a card sale — it doesn\'t charge the card yet. Connect a processor later (see docs/PAYMENTS-MODULE.md) to actually run cards; cash works fully today.']) : null,
cfg.endpoints.notify ? h('div',{class:'fld'},[ h('span',{class:'flab'},['Ready message']), h('input',{class:'nm', style:'flex:1', value:cfg.endpoints.notify.template, oninput:e=>cfg.endpoints.notify.template=e.target.value, placeholder:'Hi {name}, your order #{number} at {biz} is ready.'}) ]) : null,
cfg.endpoints.notify ? h('div',{class:'hint'},['{name} {number} {biz} get filled in automatically'+((cfg.endpoints.payment&&cfg.endpoints.payment.deposit)?' — and {balance} shows what they still owe at pickup.':'.')]) : null,
h('div',{class:'fld'},[ h('span',{class:'flab'},['Sales tax %']), h('input',{class:'sm',type:'number',step:'0.01', value:(cfg.endpoints.tax&&(cfg.endpoints.tax.rate*100))||'', placeholder:'0', oninput:e=>setTax(e.target.value)}), h('span',{class:'hint'},['leave blank if you don\'t charge sales tax']) ]),
(cfg.endpoints.tax && ((cfg.stations||[]).some(s=>s.type==='route') || (cfg.endpoints.tax.zones&&cfg.endpoints.tax.zones.length))) ? taxZonesEditor() : null ]));
app.appendChild(h('div',{},[ back(4), ' ', cont('Continue →',6) ]));
return;
}
if(gstep===6){
app.appendChild(h('h2',{},['Last thing — how will you run it?']));
app.appendChild(h('div',{class:'cards'},[
h('button',{class:'trade'+(guide.deploy==='one'?' on':''), onclick:()=>{ guide.deploy='one'; render(); }},[h('b',{},['Just one computer']), h('small',{},['Everything on that device. Free. Export a backup any time.'])]),
h('button',{class:'trade'+(guide.deploy==='several'?' on':''), onclick:()=>{ guide.deploy='several'; render(); }},[h('b',{},['Several computers']), h('small',{},['Add a small sync hub so registers share one live POS. ~a few $/mo.'])]),
h('button',{class:'trade'+(guide.deploy==='backup'?' on':''), onclick:()=>{ guide.deploy='backup'; render(); }},[h('b',{},['…and off-site backup']), h('small',{},['The hub plus rolling off-site snapshots — a dead drive is never the end.'])]) ]));
app.appendChild(h('p',{class:'hint', style:'margin-top:10px'},['However you run it: your POS works offline on your own device (cash sales need no internet), your data lives with you, and you can export a backup any time. It\'s one file — keep a copy somewhere safe.']));
/* Stage 2 (docs/V2-MODULAR-IMPORT.md): several stations run the time clock on the v2 engine — every punch on every station, through one hub */
if(guide.deploy==='several' || guide.deploy==='backup'){
const hubIn=h('input',{id:'guideHub', placeholder:'https://hub.example (you can add it later)', value: guide.hub||'', style:'display:block;width:100%;max-width:420px;margin-top:4px'});
hubIn.oninput=()=>{ guide.hub=hubIn.value.trim(); };
app.appendChild(h('div',{class:'card', style:'margin-top:10px'},[ h('b',{},['Your hub\'s address']),
h('p',{class:'hint'},['Your stations share one hub. The time clock runs on the v2 engine there: a clock-in on one station is on every station, and nothing is lost while one is offline. Leave this blank to fill it in on each device later.']), hubIn ]));
}
if(guide.deploy) app.appendChild(h('div',{style:'margin-top:12px'},[ back(5), ' ', h('button',{class:'primary big', onclick:guideFinish},['✨ Build my POS']) ]));
return;
}
return;
}
if(step===1){
app.appendChild(h('div',{class:'step'},['Step 1 of 3']));
app.appendChild(h('h2',{},['What kind of business do you run?']));
app.appendChild(h('div',{style:'margin-bottom:14px'},[ h('button',{class:'primary big', onclick:startGuide},['✨ Guided setup — answer a few questions']), h('span',{class:'hint', style:'margin-left:10px'},['new to this? start here — or pick a template below to jump into the full editor']) ]));
const cards=h('div',{class:'cards'}, Object.keys(TEMPLATES).map(k=>{ const t=TEMPLATES[k];
return h('button',{class:'trade', onclick:()=>chooseTrade(k)},[ h('b',{},[t.label]), h('small',{},[t.blurb]) ]); }));
app.appendChild(cards);
return;
}
if(step===2){
app.appendChild(h('div',{class:'step'},['Step 2 of 3 — customize (or just build it)']));
// Business + payments
const biz=h('div',{class:'panel'},[
h('h2',{},['Business']),
h('div',{class:'fld'},[ h('span',{class:'flab'},['Name']), h('input',{id:'bizName', class:'nm', value:cfg.branding.name, oninput:e=>cfg.branding.name=e.target.value||cfg.branding.name}),
h('span',{class:'flab'},['Color']), h('input',{type:'color', value:cfg.branding.brandColor, oninput:e=>cfg.branding.brandColor=e.target.value}) ]),
h('h2',{},['Payments & money']),
h('div',{class:'fld'},[ h('span',{class:'flab'},['Take']),
h('button',{class:'on'},['cash']),
h('button',{class:hasTender('card')?'on':'', onclick:()=>toggleTender('card')},['cards']),
h('button',{class:hasTender('account')?'on':'', onclick:()=>toggleTender('account')},['house accounts']),
h('button',{class:pay().tip?'on':'', onclick:()=>toggleTip()},['tips']),
h('button',{class:pay().tipPool?'on':'', onclick:()=>toggleTipPool()},['pool tips by hours']),
h('button',{class:pay().roundUp?'on':'', onclick:()=>toggleRoundUp()},['round up for charity']),
h('button',{class:cfg.endpoints.loyalty?'on':'', onclick:()=>toggleLoyalty()},['loyalty']),
h('button',{class:cfg.endpoints.discounts?'on':'', onclick:()=>toggleDiscounts()},['discounts']),
h('button',{class:cfg.endpoints.notify?'on':'', onclick:()=>toggleNotify()},['text when ready']),
h('button',{class:pay().split?'on':'', onclick:()=>toggleSplit()},['split checks']),
h('button',{class:cfg.endpoints.scan?'on':'', onclick:()=>toggleScan()},['barcode scan']),
h('button',{class:cfg.endpoints.quotes?'on':'', onclick:()=>toggleQuotes()},['quotes / estimates']),
h('button',{class:cfg.endpoints.coursing?'on':'', onclick:()=>toggleCoursing()},['course pacing']) ]),
h('div',{class:'fld'},[ h('span',{class:'flab'},['Sales tax %']), h('input',{class:'sm',type:'number', step:'0.01', value:(cfg.endpoints.tax&&(cfg.endpoints.tax.rate*100))||'', placeholder:'0', oninput:e=>setTax(e.target.value)}),
h('button',{class:(cfg.endpoints.tax&&cfg.endpoints.tax.included)?'on':'', onclick:()=>toggleTaxIncluded()},[(cfg.endpoints.tax&&cfg.endpoints.tax.included)?'✓ tax included in price':'tax added on top']),
h('span',{class:'flab'},['Deposit %']), h('input',{class:'sm',type:'number', value:(pay().deposit&&pay().deposit.pct)||'', placeholder:'0', oninput:e=>setDeposit(e.target.value)}),
h('span',{class:'flab'},['Order timer']), h('select',{onchange:e=>setTimer(e.target.value)}, [["off","none"],["aging","prep timer (turns red)"],["due","promise-by / due date"]].map(([v,l])=>h('option',{value:v, selected:(cfg.timer?cfg.timer.mode:'off')===v},[l]))),
h('span',{class:'flab'},['Max in queue']), h('input',{class:'sm',type:'number', value:(cfg.capacity&&cfg.capacity.max)||'', placeholder:'∞', oninput:e=>setCapacity(e.target.value)}) ]),
(cfg.endpoints.tax && ((cfg.stations||[]).some(s=>s.type==='route') || (cfg.endpoints.tax.zones&&cfg.endpoints.tax.zones.length))) ? taxZonesEditor() : null,
cfg.endpoints.tax ? taxClassesEditor() : null
]);
app.appendChild(biz);
// Coupon codes (only when discounts are on) — turns the quick-discount buttons into named codes
if(cfg.endpoints.discounts){
const coupons=couponList();
const cRows=h('div',{}, coupons.map((co,i)=>h('div',{class:'row2'},[
h('input',{class:'nm', value:co.code, oninput:e=>co.code=e.target.value.toUpperCase()}),
h('select',{onchange:e=>{ if(e.target.value==='pct'){ co.pct=co.pct||co.amount||10; delete co.amount; } else { co.amount=co.amount||co.pct||5; delete co.pct; } render(); }},
[['pct','% off'],['amount','$ off']].map(([v,l])=>h('option',{value:v, selected:(co.pct!=null?'pct':'amount')===v},[l]))),
h('input',{class:'sm',type:'number', value:co.pct!=null?co.pct:co.amount, oninput:e=>{ const n=Number(e.target.value)||0; if(co.pct!=null) co.pct=n; else co.amount=n; }}),
h('button',{class:'danger', onclick:()=>removeCoupon(i)},['×'])
])));
app.appendChild(h('div',{class:'panel'},[
h('h2',{},['Coupon codes']),
h('div',{class:'fld'},[ h('span',{class:'flab'},['Codes']), h('span',{class:'hint'},['add codes to replace the quick 10%/$5 buttons with named coupons customers type at checkout'])]),
cRows, h('button',{onclick:addCoupon},['+ Add coupon'])
]));
}
// Staff & time clock
const staff=cfg.staff||[];
const staffRows=h('div',{}, staff.map((s,i)=>h('div',{class:'row2'},[
h('input',{class:'nm', value:s.name, oninput:e=>s.name=e.target.value}),
h('span',{class:'muted'},['PIN']), h('input',{class:'sm', value:s.pin, oninput:e=>s.pin=e.target.value.replace(/\D/g,'').slice(0,8)}),
h('span',{class:'muted'},['$/hr']), h('input',{class:'sm', value:s.wage||'', placeholder:'0', oninput:e=>{ const v=e.target.value.replace(/[^\d.]/g,''); if(v) s.wage=+v; else delete s.wage; }}),
h('button',{class:'danger', onclick:()=>removeStaff(i)},['×'])
])));
const wc=cfg.welcome||{};
const staffPanel=h('div',{class:'panel'},[
h('h2',{},['Staff & time clock']),
h('div',{class:'fld'},[ h('span',{class:'flab'},['People']), h('span',{class:'hint'},['each staffer clocks in with their PIN on a Time Clock station'])]),
staffRows, h('button',{onclick:addStaff},['+ Add person']),
h('div',{class:'fld', style:'margin-top:10px'},[ h('span',{class:'flab'},['Clock-in message']), h('input',{class:'nm', style:'flex:1', value:wc.message||'', placeholder:'A friendly note staff see when they clock in', oninput:e=>setWelcome('message', e.target.value)}) ]),
h('div',{class:'fld'},[ h('span',{class:'flab'},["Today's specials"]), h('span',{class:'hint'},['one per line — shown on the welcome screen'])]),
h('textarea',{class:'nm', style:'width:100%;min-height:52px', placeholder:'Half-price muffins\nFree refills till noon', oninput:e=>setWelcome('specials', e.target.value)}, [ (wc.specials||[]).join('\n') ])
]);
app.appendChild(staffPanel);
// Flow preview
app.appendChild(h('h2',{},['Your flow — click a workstation to configure it']));
app.appendChild(flowPreview(cfg,true));
// Workstations
app.appendChild(h('h2',{},['Workstations']));
const sChips=h('div',{class:'chips'}, cfg.stations.map((s,i)=>h('div',{class:'chip'+(selStation===i?' sel':''), onclick:()=>selectStation(i)},[ s.label, h('span',{class:'t'},[s.type]) ])));
app.appendChild(sChips); app.appendChild(h('button',{onclick:addStation},['+ Add workstation']));
if(selStation>=0 && cfg.stations[selStation]) app.appendChild(stationEditor(selStation));
// Floor designer (only when a floor station exists) — drag tables to lay out the room
if(cfg.stations.some(s=>s.type==='floor')){ app.appendChild(h('h2',{},['Floor plan — drag tables to arrange the room'])); app.appendChild(floorDesigner()); }
// Items
app.appendChild(h('h2',{},['Items & services — click one to set what follows it']));
const iChips=h('div',{class:'chips'}, cfg.catalog.map((it,i)=>h('div',{class:'chip'+(selItem===i?' sel':''), onclick:()=>selectItem(i)},[ it.name, h('span',{class:'t'},['$'+it.price+(it.path&&it.path.length?' · '+it.path.length+' steps':'')]) ])));
app.appendChild(iChips);
app.appendChild(h('button',{onclick:addItem},['+ Add item']));
app.appendChild(h('button',{onclick:()=>{ showImport=!showImport; render(); }, style:'margin-left:8px'},[showImport?'Close import':'⇪ Import items (CSV)']));
if(showImport){
app.appendChild(h('div',{class:'panel', style:'margin-top:10px'},[
h('div',{class:'fld'},[ h('span',{class:'flab'},['Paste CSV']), h('span',{class:'hint'},['one item per line: name, price, category, barcode — a header row is detected and skipped'])]),
h('textarea',{id:'csvBox', class:'nm', style:'width:100%;min-height:96px', placeholder:'Apple, 1.00, produce, 1001\nBanana, 0.50, produce, 1002'}, []),
h('div',{style:'margin-top:8px'},[
h('button',{class:'primary', onclick:()=>{ const n=importItemsCSV(document.getElementById('csvBox').value); flashB(n?('Imported '+n+' item'+(n>1?'s':'')):'Nothing to import — check the format'); showImport=false; render(); }},['Import']),
h('span',{class:'hint', style:'margin-left:10px'},['price defaults to 0, category to "item"; barcode is optional'])
])
]));
}
if(selItem>=0 && cfg.catalog[selItem]) app.appendChild(itemEditor(selItem));
// Build
app.appendChild(h('div',{style:'margin-top:18px'},[
h('button',{class:'primary big', onclick:buildAndShow},['⬇ Build & download my POS']),
h('button',{class:'big', onclick:buildAndShow},['Build it for me (defaults)']),
h('button',{onclick:()=>{ step=1; render(); }},['← different business'])
]));
return;
}
if(step===3){
app.appendChild(h('div',{class:'step'},['Step 3 of 3']));
app.appendChild(h('h2',{},['Your POS is ready']));
const p=h('div',{class:'panel'},[ h('b',{},[cfg.branding.name]), ' — one self-contained file, yours to own.', flowPreview(cfg,false),
h('a',{class:'dl', id:'dlPos'},[h('button',{class:'primary big'},['⬇ Download your POS (one file)'])]),
h('a',{class:'dl', id:'dlMd'},[h('button',{class:'big'},['⬇ Download CLAUDE.md (your Claude Code guide)'])]),
h('h2',{},['Live preview — your actual POS']) ]);
app.appendChild(p);
if(guide.deploy){ const raw=DEPLOY_NOTE[guide.deploy]||DEPLOY_NOTE.one;
const plain=raw.replace(/\*\*(.+?)\*\*/g,'$1').replace(/`([^`]+)`/g,'$1');
app.appendChild(h('div',{class:'panel'},[ h('h2',{},['How to run it']), h('div',{}, [plain]),
h('div',{class:'hint', style:'margin-top:6px'},['This is written into your CLAUDE.md too, so Claude Code can set it up with you.']) ])); }
app.appendChild(h('iframe',{id:'preview'}));
app.appendChild(h('button',{onclick:()=>{ step=2; render(); }},['← keep editing']));
app.appendChild(h('button',{onclick:()=>{ step=1; tradeKey=null; render(); }},['start over']));
if(window.__build){
const dlPos=document.getElementById('dlPos'); dlPos.href=blobUrl(window.__build.html,'text/html'); dlPos.download=(cfg.branding.name.replace(/\W+/g,'-')||'my')+'-pos.html';
const dlMd=document.getElementById('dlMd'); dlMd.href=blobUrl(window.__build.claudeMd,'text/markdown'); dlMd.download='CLAUDE.md';
document.getElementById('preview').srcdoc=window.__build.html;
}