1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3068],{9916:(e,t,n)=>{n.d(t,{U:()=>l});var r=n(64269);function s(){return"true"===(0,r.Kq)("cms_editor_session")}async function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:15e3;if(s())return!0;let t=Date.now()+e;for(;Date.now()<t&&function(){if(!0===window.__btEditorSignInInFlight)return!0;let e=new URLSearchParams(window.location.search);return e.has("edit_handoff")||e.has("edit_signin")}();)if(await new Promise(e=>setTimeout(e,100)),s())return!0;return s()}async function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=arguments.length>2?arguments[2]:void 0;if(!l&&!((0,r.Kq)("nostr_nsec")||"true"===(0,r.Kq)("nostr_extension")&&window.nostr)){if(!s()&&!await a())throw Error("No Nostr private key available");return fetch(e,{credentials:"same-origin",...t})}return(await Promise.all([n.e(5195),n.e(1356),n.e(11),n.e(9267),n.e(4565),n.e(124)]).then(n.bind(n,60124))).authenticatedFetch(e,t,l)}},25623:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(95155),s=n(71289);function a(e){let{opacity:t=.1}=e;return(0,r.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"url(".concat(s.XF,")"),backgroundSize:"cover",backgroundPosition:"center",opacity:t}})}},47101:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(95155),s=n(19880);let a="inset 0px 0px 0px 1px rgba(10,13,18,0.18), inset 0px -2px 0px 0px rgba(10,13,18,0.05)",l=["".concat(a,", 0 0 0px 0px rgba(255,255,255,0)"),"".concat(a,", 0 0 0px 12px rgba(255,255,255,0.28)"),"".concat(a,", 0 0 0px 0px rgba(255,255,255,0)")];function o(e){let{children:t,variant:n="primary",size:o="md",onClick:c,pulse:i=!1,fullWidth:d=!0,className:u="",disabled:x=!1,type:p="button"}=e,h="primary"===n;return(0,r.jsx)(s.P.button,{onClick:c,type:p,disabled:x,className:"\n ".concat("sm"===o?"h-10 text-sm":"h-12 text-base"," flex items-center justify-center rounded-lg font-archivo font-medium tracking-wider\n ").concat(d?"w-full":"","\n ").concat(h?"bg-burgundy text-white border-2 border-white/10":"bg-white text-charcoal border border-[#D5D7DA]","\n ").concat(x?"opacity-60 cursor-not-allowed":"","\n ").concat(u,"\n "),style:{boxShadow:h?a:"0px 1px 2px 0px rgba(10,13,18,0.05)"},animate:i&&h&&!x?{boxShadow:l}:void 0,transition:i?{duration:2,repeat:1/0,ease:"easeInOut",delay:.7}:void 0,whileTap:x?void 0:{scale:.97},children:t})}},60125:(e,t,n)=>{n.d(t,{Cw:()=>a,cI:()=>d,h4:()=>c,in:()=>o,mD:()=>l,n4:()=>i});var r=n(94508),s=n(65937);let{adminGet:a,adminPost:l,adminPatch:o,adminPut:c,adminDelete:i,adminUploadImage:d}=(0,r.Z)({reportError:s.L,appLabel:"randalls-rewards"})},80884:(e,t,n)=>{n.d(t,{K:()=>u,h:()=>d});
1var r=n(95155),s=n(12115),a=n(20179),l=n(60125);let o=null,c=null;async function i(){return o||c||(c=(0,l.Cw)("/api/admin/loyalty/tier-config").then(e=>{var t;let n=(null!=(t=e.tiers)?t:[]).filter(e=>!1!==e.active).sort((e,t)=>e.tier_order-t.tier_order);return o=n,n}).finally(()=>{c=null}))}function d(){o=null}function u(e){let{value:t,onSave:n,onStarsThreshold:l}=e,[c,d]=(0,s.useState)(o);if((0,s.useEffect)(()=>{let e=!1;return o||i().then(t=>{e||d(t)}).catch(()=>{e||d([])}),()=>{e=!0}},[]),!c)return(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("span",{className:"text-stone-400 text-xs font-archivo tracking-[1.2px] block mb-1",children:"AVAILABLE TO"}),(0,r.jsx)("div",{className:"text-stone-400 text-xs",children:"Loading tiersâ¦"})]});if(0===c.length)return(0,r.jsx)(a.B,{label:"Available to (tier order)",type:"number",value:null!=t?t:1,onSave:async e=>n(Number(null!=e?e:1)),min:1,max:20,hint:"No tiers found. Default 1 = available to everyone."});let u=c[0],x=c.map((e,t)=>({value:String(e.tier_order),label:0===t?"All members (".concat(e.display_name," and above \xb7 ").concat(e.stars_threshold.toLocaleString()," stars)"):"".concat(e.display_name," and above \xb7 ").concat(e.stars_threshold.toLocaleString()," stars")}));return(0,r.jsx)(a.B,{label:"Available to",type:"select",options:x,value:String(null!=t?t:u.tier_order),onSave:async e=>{let t=Number(null!=e?e:u.tier_order);if(await n(t),l){var r;l((null!=(r=c.find(e=>e.tier_order===t))?r:u).stars_threshold)}},hint:"All members see this. Only those at or above this tier can claim it."})}},94159:(e,t,n)=>{n.d(t,{z:()=>o});var r=n(95155),s=n(12115),a=n(60125),l=n(9916);function o(e){let{value:t,onChange:n,label:o="QUALIFYING PRODUCTS",description:c=(0,r.jsxs)(r.Fragment,{children:["A stamp is awarded when the member buys any product listed here. Type a keyword (e.g."," ",(0,r.jsx)("span",{className:"font-mono text-stone-400",children:"burger"}),") to filter, then add SKUs individually or all at once. Leave empty to award on ",(0,r.jsx)("em",{children:"any"})," purchase."]})}
1=e,[i,d]=(0,s.useState)(""),[u,x]=(0,s.useState)([]),[p,h]=(0,s.useState)(!1),[m,f]=(0,s.useState)(!1),[b,g]=(0,s.useState)(-1),[v,y]=(0,s.useState)(new Map),w=(0,s.useRef)(null),j=(0,s.useRef)(null),N=(0,s.useRef)(null),k=(0,s.useRef)(null),[_,S]=(0,s.useState)(!1),[D,C]=(0,s.useState)(null),[T,A]=(0,s.useState)(!1),E=(0,s.useCallback)(e=>{y(t=>{let n=new Map(t);return e.forEach(e=>n.set(e.product_code,e.product_name)),n})},[]);(0,s.useEffect)(()=>{let e=t.filter(e=>!v.get(e));0!==e.length&&(0,a.Cw)("/api/admin/loyalty/products/search?codes=".concat(e.join(","))).then(e=>E(e.products)).catch(()=>{})},[t.join(",")]);let L=(0,s.useCallback)(async e=>{S(!0),C(null);try{var r;let s=new FormData;s.append("file",e);let a=await (0,l.U)("/api/admin/loyalty/products/import",{method:"POST",body:s});if(!a.ok)throw Error("HTTP ".concat(a.status));let o=await a.json(),c=(null!=(r=o.codes)?r:[]).filter(e=>!t.includes(e));c.length>0&&n([...t,...c]);let i=o.task_id?" Task created to import unknowns.":"";C("Added ".concat(c.length," new code").concat(1===c.length?"":"s"," from ").concat(o.count," found.").concat(i)),setTimeout(()=>C(null),5e3)}catch(e){C("Import failed â check file format."),setTimeout(()=>C(null),3e3)}finally{S(!1)}},[t,n]),I=(0,s.useCallback)(async e=>{f(!0);try{let n=await (0,a.Cw)("/api/admin/loyalty/products/search?q=".concat(encodeURIComponent(e))),r=n.products.filter(e=>!t.includes(e.product_code));E(n.products),x(r),g(-1),h(!0)}catch(e){x([])}finally{f(!1)}},[t,E]),U=(0,s.useCallback)(e=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>void I(e),200)},[I]),P=e=>{var r;n([...t,e.product_code]),E([e]),x(t=>t.filter(t=>t.product_code!==e.product_code)),null==(r=j.current)||r.focus()};(0,s.useEffect)(()=>{if(b<0||!N.current)return;let e=N.current.children[b+1];null==e||e.scrollIntoView({block:"nearest"})},[b]);let K=p&&(m||u.length>0||i.length>0);return(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-stone-400 text-xs font-archivo tracking-[1.2px] block mb-2",children:o}),(0,r.jsx)("p",{className:"text-stone-400 text-xs mb-3",children:c}),(0,r.jsxs)("div",{className:"relative mb-3 border border-dashed rounded px-3 py-2.5 text-center cursor-pointer transition-colors ".concat(T?"border-amber-400 bg-amber-400/5":"border-stone-600 hover:border-stone-400"),onClick:()=>{var e;return null==(e=k.current)?void 0:e.click()},onDragOver:e=>{e.preventDefault(),A(!0)},onDragLeave:()=>A(!1),onDrop:e=>{e.preventDefault(),A(!1);let t=e.dataTransfer.files[0];t&&L(t)},children:[(0,r.jsx)("input",{ref:k,type:"file",accept:".csv,.tsv,.txt,.xlsx,.xls",className:"sr-only",onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];n&&L(n),e.target.value=""}}),_?(0,r.jsx)("span",{className:"text-xs text-stone-400 animate-pulse",children:"Importingâ¦"}):D?(0,r.jsx)("span",{className:"text-xs text-amber-400",children:D}):(0,r.jsxs)("span",{className:"text-xs text-stone-400",children:["Drop a ",(0,r.jsx)("span",{className:"text-stone-400",children:"CSV / XLSX / TXT"})," to bulk-import SKUs, or click to browse"]})]}),t.length>0&&(0,r.jsxs)("div",{className:"mb-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,r.jsxs)("span",{className:"text-stone-400 text-xs",children:[t.length," SKU",1===t.length?"":"s"," selected"]}),(0,r.jsx)("button",{onClick:()=>n([]),className:"text-xs text-stone-400 hover:text-stone-300 transition-colors",children:"Clear all"})]}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-1.5",children:t.map(e=>(0,r.jsxs)("span",{className:"flex items-center gap-1 pl-2 pr-1 py-1 rounded bg-stone-700 border border-stone-600 text-stone-200 text-xs min-w-0",children:[(0,r.jsx)("span",{className:"font-mono text-stone-400 text-xs shrink-0",children:e}),v.get(e)&&(0,r.jsx)("span",{className:"truncate flex-1 text-stone-300 text-xs",children:v.get(e)}),(0,r.jsx)("button",{onClick:()=>n(t.filter(t=>t!==e)),className:"w-4 h-4 flex items-center justify-center rounded-full text-stone-400 hover:text-white hover:bg-stone-500 transition-colors ml-auto shrink-0","aria-label":"Remove ".concat(e),children:"\xd7"})]},e))})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("div",{className:"relative flex items-center",children:[(0,r.jsx)("input",{ref:j,type:"text",value:i,placeholder:"Type a PLU code or product name to searchâ¦",onChange:e=>{d(e.target.value),U(e.target.value)},onFocus:()=>{p||I(i)},onBlur:()=>setTimeout(()=>h(!1),150),onKeyDown:e=>{if(p)if("ArrowDown"===e.key)e.preventDefault(),g(e=>Math.min(e+1,u.length-1));else if("ArrowUp"===e.key)e.preventDefault(),g(e=>Math.max(e-1,-1));else if("Enter"===e.key&&b>=0){e.preventDefault();let t=u[b];t&&P(t)}else"Escape"===e.key&&(h(!1),g(-1))},className:"w-full bg-stone-800 border border-stone-600 rounded px-3 py-2 text-sm text-stone-200 placeholder:text-stone-400 focus:outline-none focus:border-stone-400 pr-8","aria-autocomplete":"list","aria-expanded":p}),m&&(0,r.jsx)("span",{className:"absolute right-2.5 text-stone-400 text-xs animate-pulse pointer-events-none",children:"\xb7\xb7\xb7"})]}),K&&(0,r.jsxs)("ul",{ref:N,className:"absolute z-50 mt-1 w-full bg-stone-900 border border-stone-600 rounded-lg shadow-2xl max-h-64 overflow-y-auto",role:"listbox",children:[u.length>0&&i.length>0&&(0,r.jsx)("li",{className:"sticky top-0 z-10 border-b border-stone-700 bg-stone-900",children:(0,r.jsxs)("button",{onMouseDown:e=>{var r;e.preventDefault();let s=u.filter(e=>!t.includes(e.product_code));s.length&&n([...t,...s.map(e=>
1e.product_code)]),d(""),x([]),h(!1),null==(r=j.current)||r.focus()},className:"w-full text-left px-3 py-2.5 text-xs font-semibold text-amber-400 hover:bg-stone-800 transition-colors flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-amber-500",children:"+"}),"Add all ",u.length," match",1===u.length?"":"es",(0,r.jsxs)("span",{className:"text-stone-400 font-normal ml-1",children:['for "',i,'"']})]})}),u.length>0&&0===i.length&&(0,r.jsxs)("li",{className:"sticky top-0 z-10 border-b border-stone-700 bg-stone-900 px-3 py-2 text-xs text-stone-400",children:["Top ",u.length," products by frequency â type to search all"]}),!m&&0===u.length&&i.length>0&&(0,r.jsxs)("li",{className:"px-3 py-3 text-xs text-stone-400 text-center",children:['No products found for "',i,'"']}),u.map((e,t)=>(0,r.jsx)("li",{role:"option","aria-selected":t===b,children:(0,r.jsxs)("button",{onMouseDown:t=>{t.preventDefault(),P(e)},className:"w-full text-left px-3 py-2.5 flex items-center gap-3 transition-colors ".concat(t===b?"bg-stone-700":"hover:bg-stone-800"),children:[(0,r.jsx)("span",{className:"font-mono text-xs text-stone-400 shrink-0 w-14 text-right",children:e.product_code}),(0,r.jsx)("span",{className:"text-sm text-stone-200 truncate flex-1 text-left",children:e.product_name}),e.sales_group_name&&(0,r.jsx)("span",{className:"text-xs text-stone-400 shrink-0 max-w-[100px] truncate",children:e.sales_group_name})]})},e.product_code))]})]})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.