/* Source-derived physical ticket artwork; rows are resolved by the scoped API. */
(function () {
const {useState,useEffect}=React;
const MM=96/25.4,PREVIEW=.5,MARGIN=6,GUTTER=4;
const FORMATS={shelf:{id:"shelf",label:"Shelf ticket",w:70,h:50,description:"Slots into the standard rail. One per facing."},barker:{id:"barker",label:"Bay barker",w:95,h:70,description:"Projects from the shelf edge for offers seen from the aisle."},a5:{id:"a5",label:"A5 poster",w:148,h:210,description:"One-up on A4, with a trim edge for an end-of-bay or window."}};
const THEMES={red:{label:"Classic red",flag:"#d81f2a",fg:"#fff",ink:"#b3141d",tint:"#fdecec"},amber:{label:"Clearance",flag:"#f4a300",fg:"#241a00",ink:"#a06a00",tint:"#fff6e3"},teal:{label:"Brand teal",flag:"#0d7b6c",fg:"#fff",ink:"#0a6156",tint:"#e6f4f1"},magenta:{label:"Beauty pink",flag:"#c2185b",fg:"#fff",ink:"#a01449",tint:"#fdeaf1"},green:{label:"Wellness",flag:"#2e7d32",fg:"#fff",ink:"#256428",tint:"#eaf4ea"},violet:{label:"Premium",flag:"#5b3fa8",fg:"#fff",ink:"#4a3389",tint:"#efeafa"},navy:{label:"Navy",flag:"#0f2436",fg:"#fff",ink:"#0f2436",tint:"#e9eef3"}};
const money=c=>c==null?"—":"$"+(c/100).toFixed(2);
const date=d=>d?String(d).slice(0,10).split('-').reverse().join('/'):"—";
const layout=f=>{const cols=Math.floor((210-2*MARGIN+GUTTER)/(f.w+GUTTER)),rows=Math.floor((297-2*MARGIN+GUTTER)/(f.h+GUTTER));return {cols,rows,per:cols*rows,gridW:cols*f.w+(cols-1)*GUTTER,gridH:rows*f.h+(rows-1)*GUTTER};};
function Ticket({row,format,promotion,theme}) {
const f=FORMATS[format],t=THEMES[theme||row.theme]||THEMES.red,scale=format==='shelf'?1:format==='barker'?1.42:2.1;
const price=row.kind==='price'&&row.effectiveCents!=null;
const member=promotion?.mechanic==='member',clearance=promotion?.origin==='clearance';
const parts=price?(row.effectiveCents/100).toFixed(2).split('.'):[];
const saving=price&&row.beforeCents!=null?row.beforeCents-row.effectiveCents:0;
return