1import{af as Po,ag as pt,ah as Bo,ai as Do,aj as Zt,d as be,e as c,k as b,h as a,v as O,x as Be,I as K,t as P,l as N,ak as Io,j as s,i as oe,D as ut,f as ge,g as ce,q as E,F as L,y as X,al as Qe,Z as to,B as Ce,n as Ve,J as ft,r as j,z as et,w as tt,o as mt,S as Bt,N as _o,am as Lo,a as Ro,Y as No,$ as zo,E as Fe,L as Vo,Q as Mo}from"./5ED1w5_O.js";import{_ as Uo}from"./CUeL5RAi.js";import{_ as Wo}from"./BmOt0Ch0.js";import{_ as Fo}from"./BqL4yBOL.js";import{b as Dt,a as H,C as qe,i as ae,A as oo,c as je,T as Ho,t as Ne,d as Zo,e as Yo,f as It,S as jo,g as Ko,h as qo,j as Go,B as Jo,k as ze,_ as _t,l as Xo,m as Qo,n as en,o as tn}from"./BpCtuHY5.js";import{e as on}from"./BHRTv3No.js";import{_ as Lt}from"./DrdrK4IF.js";import{_ as nn}from"./CNYCY2vU.js";import{_ as no}from"./90EOgzCm.js";import{p as so}from"./ldDt82Ui.js";import{_ as sn}from"./BO_Zj1A9.js";import{o as an}from"./V6axwfKR.js";import{u as ln}from"./R-x7Xyng.js";import{u as rn}from"./CEeLUfXB.js";import"./C663bpaq.js";import"./BLC2ItUy.js";import"./CE29BIQC.js";import"./CtRJsCPV.js";import"./Cop7j5Tf.js";import"./DPBqYF8J.js";import"./D9Wj65Th.js";import"./BbJ8OqaY.js";import"./CzkEBe7P.js";import"./CZVZ6V6i.js";import"./CEVcKk-N.js";import"./CVtBX_OD.js";import"./DTt21mgW.js";import"./CH6ajvbL.js";const Rt={"early-bird":"Early Bird",discount:"Sale","app-exclusive":"App Only",locked:"Locked","sold-out":"Sold Out","max-reached":"Max Reached","instant-wins":"Instant Wins","selling-fast":"Selling Fast","main-prize-boost":"Main Prize Boost","cash-alternative":"Cash Alternative","credit-alternative":"Credit Alternative","auto-draw":"Auto Draw"},dn="rgb(var(--theme-accent-rgb, 139 92 246))",Yt={"early-bird":{background:"linear-gradient(to right, #22c55e, #059669)",gradient:!0},discount:{background:"#7c3aed",gradient:!1},"app-exclusive":{background:"linear-gradient(to right, #4f46e5, #9333ea)",gradient:!0},locked:{background:"linear-gradient(to right, #f59e0b, #f97316)",gradient:!0},"sold-out":{background:"linear-gradient(to right, #dc2626, #b91c1c)",gradient:!0},"max-reached":{background:"#4b5563",gradient:!1},"instant-wins":{background:`linear-gradient(to right, ${dn}, #7c3aed)`,gradient:!0},"selling-fast":{background:"linear-gradient(to right, #f97316, #ea580c)",gradient:!0},"main-prize-boost":{background:"linear-gradient(to right, #fbbf24, #f59e0b)",gradient:!0},"cash-alternative":{background:"#059669",gradient:!1},"credit-alternative":{background:"#7c3aed",gradient:!1},"auto-draw":{background:"var(--theme-card-bg, #1e293b)",gradient:!1}},cn={image:"Image",title:"Title",price:"Price",countdown:"Countdown",progress:"Tickets sold",buttons:"Buttons",status:"Status","tickets-left":"Tickets left","max-per-person":"Max per person","prize-value":"Prize value","draw-date":"Draw date","opens-in":"Opens in","category-tag":"Category tag",summary:"Summary"},un={image:"The prize photo",title:"The competition name",price:"What one entry costs",countdown:"Time left, or when it draws",progress:"How many tickets have gone",buttons:"Quick buy and the main button",status:"Sold Out, Ended, Limit Reached or the winner","tickets-left":'"120 left"',"max-per-person":'"Max 50 per person"',"prize-value":'"Worth £1,000"',"draw-date":'"Draws Fri 3 Oct, 8pm"',"opens-in":"For competitions that have not opened yet","category-tag":"The competition's tag",summary:"The short summary line"},mn={"early-bird":"While early bird pricing is on",discount:"While a discount is on â the wording comes from the discount","app-exclusive":"On app-only competitions",locked:"On competitions that need an access code","sold-out":"When every ticket has gone","max-reached":"When a signed-in customer holds the most they can","instant-wins":"On competitions with instant wins","selling-fast":"When tickets are going quickly, on competitions without instant wins","main-prize-boost":"While a main prize boost is running â named by its branding","cash-alternative":"The cash alternative amount","credit-alternative":"The site credit alternative amount","auto-draw":"On competitions that draw themselves"};function Le(e){const n=typeof e=="string"?e:H(e);if(n.startsWith("badge:")){const t=n.slice(6);return`${Rt[t]??t} badge`}return cn[n]??n}function Nt(e){return e.type==="badge"?mn[e.kind]:un[e.type]}const he={"image-top-left":"Image, top left","image-top-center":"Image, top middle","image-top-right":"Image, top right","image-center":"Image, centre","image-bottom-left":"Image, bottom left","image-bottom-band":"Image, bottom strip","image-bottom-right":"Image, bottom right","image-edge":"Image edge","body-top":"Details, top","body-middle":"Details, middle","body-bottom":"Details, bottom"},ao=e=>qe.filter(n=>je[e].includes(n)),Ye=e=>e.blocks.filter(ae),we=(e,n)=>e.blocks.find(t=>H(t)===n),gt=e=>
1oo.indexOf(H(e));function ot(e,n){return Ye(e).filter(t=>t.enabled&&t.zone===n).sort((t,o)=>t.order-o.order||gt(t)-gt(o))}const Oe=(e,n,t)=>Zo(e,n,t)&&Yo(e,n),lo=(e,n)=>ao(n).filter(t=>Oe(e,t,n)),gn=e=>JSON.parse(JSON.stringify(e));function Ge(e,n,t){return{...e,blocks:e.blocks.map(o=>H(o)===n?t(gn(o)):o)}}function De(e){const n=new Map;for(const t of qe)Ye(e).filter(o=>o.zone===t).sort((o,l)=>o.order-l.order||gt(o)-gt(l)).forEach((o,l)=>n.set(H(o),l));return{...e,blocks:e.blocks.map(t=>{const o=n.get(H(t));return ae(t)&&o!==void 0&&o!==t.order?{...t,order:o}:t})}}function ht(e,n,t){const o=new Map(t.map((l,r)=>[l,r]));return{...e,blocks:e.blocks.map(l=>{const r=o.get(H(l));if(r===void 0||!ae(l))return l;const i={...l,zone:n,order:r,enabled:!0};return i.phoneZone===n&&(i.phoneZone=null),i})}}function bn(e,n){const t=new Set(n);return De({...e,blocks:e.blocks.map(o=>t.has(H(o))&&ae(o)&&o.enabled?{...o,enabled:!1}:o)})}function jt(e,n,t){const o=we(e,n);return!o||o.enabled===t?e:ae(o)?t?De(Ge(e,n,l=>({...l,enabled:!0}))):bn(e,[n]):Ge(e,n,l=>({...l,enabled:t}))}function pn(e,n,t){const o=we(e,n);if(!o||!ae(o)||!Oe(o,t,e.layout))return e;const l=ot(e,t).map(H).filter(r=>r!==n);return De(ht(e,t,[...l,n]))}function fn(e,n,t,o){const l=we(e,n);if(!l||!ae(l)||!Oe(l,t,e.layout))return e;const r=ot(e,t).map(H).filter(i=>i!==n);return r.splice(Math.max(0,Math.min(o,r.length)),0,n),De(ht(e,t,r))}function hn(e,n,t,o,l){const r=ot(e,t).map(H).filter(y=>y!==n),i=l?r.indexOf(l):-1,v=o?r.indexOf(o):-1,m=i!==-1?i:v!==-1?v+1:r.length;return fn(e,n,t,m)}function vn(e,n,t){const o=we(e,n);if(!o||!ae(o))return e;const l=ot(e,o.zone).map(H),r=l.indexOf(n),i=r+t;return r===-1||i<0||i>=l.length?e:(l.splice(r,1),l.splice(i,0,n),ht(e,o.zone,l))}function Kt(e,n,t){const o=we(e,n);return!o||!ae(o)||o.type==="buttons"||t!==null&&(t===o.zone||!Oe(o,t,e.layout))?e:Ge(e,n,l=>({...l,phoneZone:t}))}function yn(e,n){const t=It(e),o=t?jo[t]:void 0,l=n==="overlay"?["image-bottom-band","image-top-left","image-top-right","image-center","image-bottom-left","image-bottom-right","image-top-center"]:["body-top","body-middle","body-bottom","image-bottom-band","image-top-left","image-top-right","image-center","image-bottom-left","image-bottom-right","image-top-center","image-edge"],r=t==="stamp"?["image-center",...o??[]]:[...o??[]];return[...new Set([...r,...l])]}function Tt(e,n){return yn(e,n).find(t=>Oe(e,t,n))??null}function qt(e){return e.type==="badge"?{...e,settings:{...e.settings,shape:"pill"}}:e.type==="status"?{...e,settings:{...e.settings,style:"pill"}}:e}function io(e,n,t){let o=e;const l=je[n];let r=o.zone;if(l.includes(r)||(r=n==="overlay"?"image-bottom-band":"body-top"),It(o)==="tab"&&r!=="image-edge"&&(o=qt(o)),!Oe(o,r,n)){let v=Tt(o,n);v||(o=qt(o),v=Tt(o,n)),r=v??r}let i=o.type==="buttons"?null:o.phoneZone;return i&&(!l.includes(i)||!Oe(o,i,n)||i===r)&&(i=null),{...o,zone:r,phoneZone:i}}function kn(e){let n=!1;const t=e.blocks.map(l=>{if(!ae(l))return l;const r=io(l,e.layout);return JSON.stringify(r)!==JSON.stringify(l)&&(n=!0),r});if(!n)return e;const o=new Set(t.filter((l,r)=>ae(l)&&l.zone!==e.blocks[r].zone).map(H));return De({...e,blocks:t.map(l=>ae(l)&&o.has(H(l))?{...l,order:99}:l)})}function xn(e,n){if(e.layout===n)return e;const t=v=>qe.indexOf(v.zone)*100+v.order,o=new Map(Ye(e).map(v=>[H(v),t(v)])),l=e.blocks.map(v=>ae(v)?io(v,n):v),r={...e,layout:n,blocks:l},i=new Map;for(const v of qe){const m=Ye(r).filter(w=>w.zone===v),y=m.filter(w=>w.enabled).sort((w,A)=>o.get(H(w))-o.get(H(A))),h=m.filter(w=>!w.enabled);y.forEach((w,A)=>i.set(H(w),A)),h.forEach((w,A)=>i.set(H(w),Math.min(99,y.length+A)))}return{...r,blocks:r.blocks.map(v=>ae(v)?{...v,order:i.get(H(v))??v.order}:v)}}const it=e=>e.imageSide??"start";function wn(e,n){const{imageSide:t,...o}=e;return n==="start"?o:{...o,imageSide:n}}const Sn=e=>e.buttonHover??"default";function $n(e,n){const{buttonHover:t,...o}=e;return n==="default"?o:{...o,buttonHover:n}}function Cn(e,n){const t=new Map(Ye(e).map(o=>[H(o),o.zone]));return Ye(n).filter(o=>o.enabled&&t.get(H(o))!==o.zone).length}const ro={all:Ho,corners:["corners","border"],colours:["background","textColor","accent","buttons","surface"],font:["font"]};function On(e,n){const t={...e.style};for(const o of ro[n])t[o]={mode:"site"};return{...e,style:t}}const Tn=(e,n)=>ro[n].every(t=>e.style[t].mode==="site"),An={live:"Live","on-sale":"On sale","early-bird":"Early bird","ending-soon":"Ending soon","almost-sold-out":"Almost sold out","sold-out":"Sold out","limit-reached":"Limit reached",ended:"Ended","awaiting-draw":"Awaiting draw",won:"Won","not-open":"Not open yet"},En={layout:"Layout",colours:"Colours",font:"Font",corners:"Corners",image:"Image",blocks:"Parts",badges:"Badges",motion:"Motion",reactions:"Reactions"},Pn=[...oo].sort((e,n)=>n.length-e.length);function co(e){for(const n of Pn)if(e.startsWith(`Block ${n} `)||e.startsWith(`${n} `)||e.startsWith(`${n}'s `))return n;return e.startsWith("Buttons ")?"buttons":null}function Gt(e){let n=e;const t=co(e);t&&(n=n.replace(`Block ${t} `,`${Le(t)} `).replace(new RegExp(`^${t.replace(/[.*+?^${}()|[\]\\:]/g,"\\$&")}('s)? `),`${Le(t)}$1 `));for(const o of[...qe].sort((l,r)=>r.length-l.length))n=n.split(o).join(`"${he[o]}"`);return n}function _e(e){return Array.isArray(e)?`[${e.map(_e).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[o])=>t<o?-1:t>o?1:0).map(([t,o])=>`${JSON.stringify(t)}:${_e(o)}`).join(",")}}`:JSON.stringify(e)}const lt=(e,n,t)=>{const o=String(e??"").toLowerCase();return n.includes(o)?o:t},wt=(e,n)=>Ne(typeof e=="string"?e:null,n);function Bn(e){const n=e??{}
1,t=wt(n.themeCardBackgroundColor,"#1e293b");return{cardBg:t,accent:wt(n.themeAccentColor,"#8b5cf6"),buttonColor:wt(n.themeButtonBackgroundColor,"#3b82f6"),buttonStyle:lt(n.buttonStyle,Jo,"solid"),corners:lt(n.borderRadius,Go,"rounded"),font:typeof n.themePrimaryFont=="string"&&Bo.includes(n.themePrimaryFont)?n.themePrimaryFont:Po,surface:lt(n.cardStyle,qo,"elevated"),hover:lt(n.cardHoverEffect,Ko,"lift"),text:pt(t)==="white"?"#ffffff":"#111827"}}function Dn(e){const n=e??{},t=o=>typeof n[o]=="boolean"?n[o]:void 0;return{badgeShowTimer:t("badgeShowTimer"),badgeShowEarlyBird:t("badgeShowEarlyBird"),badgeShowDiscount:t("badgeShowDiscount"),badgeShowAppExclusive:t("badgeShowAppExclusive"),badgeShowLocked:t("badgeShowLocked"),badgeShowSoldOut:t("badgeShowSoldOut"),badgeShowInstantWins:t("badgeShowInstantWins"),badgeShowSellingFast:t("badgeShowSellingFast"),badgeShowCashAlternative:t("badgeShowCashAlternative"),badgeShowCreditAlternative:t("badgeShowCreditAlternative"),badgeShowAutoDraw:t("badgeShowAutoDraw"),badgeShowMaxReached:t("badgeShowMaxReached"),cardShowWinner:t("cardShowWinner")}}const Jt=e=>{const n=De(e);return _e({...n,id:"",name:"",blocks:[...n.blocks].sort((t,o)=>H(t)<H(o)?-1:H(t)>H(o)?1:0)})},uo=(e,n)=>Jt(e)===Jt(Dt(n)),zt=e=>e.designs.find(n=>n.id===e.defaultId)??e.designs[0];function At(e,n){const t=zt(e);return{...e,mode:t&&uo(t,n)?"standard":"custom"}}function In(e,n){const t=zt(e);if(e.mode!=="standard"||!t)return At(e,n);const o={...Dt(n),id:t.id,name:t.name};return At({...e,designs:e.designs.map(l=>l.id===t.id?o:l)},n)}function mo(e=Date.now()){return{id:"sample-competition",slug:"sample-competition",title:"Win a Rolex Submariner or £9,000 cash",displayTitle:"Rolex Submariner",summary:"Brand new, boxed with papers â or take the cash.",prizeImageUrl:null,status:"ACTIVE",startDate:new Date(e-3*864e5).toISOString(),endDate:new Date(e+3*864e5).toISOString(),maxTickets:4999,ticketsSold:2100,maxTicketsPerUser:50,pricePerTicket:.99,cashAlternative:9e3,mainPrizeValue:10500,hasInstantWinPrizes:!0,winnerSelectionMode:"AUTO",tags:[{id:"sample-tag",name:"Watches",slug:"watches",color:null}]}}const Je=["phone","desktop-4","desktop-3"],He=2,_n=e=>e.right-e.left>0&&e.bottom-e.top>0;function Ln(e,n,t=null){const o=e.filter(i=>_n(i.rect)),l=[];for(let i=0;i<o.length;i++)for(let v=i+1;v<o.length;v++){const m=o[i],y=o[v];if(m.zone===y.zone)continue;const h=Math.min(m.rect.right,y.rect.right)-Math.max(m.rect.left,y.rect.left),w=Math.min(m.rect.bottom,y.rect.bottom)-Math.max(m.rect.top,y.rect.top);h>He&&w>He&&l.push({kind:"overlap",a:m.key,b:y.key})}const r=(i,v)=>i.top<v.top-He||i.bottom>v.bottom+He||i.left<v.left-He||i.right>v.right+He;for(const i of o){if(i.zone==="image-edge"||i.hangsOffEdge)continue;const v=i.zone.startsWith("image-"),m=v?n:t;m&&r(i.rect,m)&&l.push({kind:"clipped",key:i.key,off:v?"image":"card"})}return l}const Rn={phone:"on phones","desktop-4":"in a 4-across grid","desktop-3":"in a 3-across grid"},St=e=>{const n=Le(e);return`the ${e.startsWith("badge:")?n:n.charAt(0).toLowerCase()+n.slice(1)}`},Et=e=>{const n=Je.filter(o=>e.includes(o)).map(o=>Rn[o]),t=n.length>1?`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`:n[0];return t.charAt(0).toUpperCase()+t.slice(1)};function Nn(e){const n=new Map;for(const t of Je)for(const o of e[t]??[]){const l=o.kind==="overlap"?`overlap:${[o.a,o.b].sort().join("|")}`:`clipped:${o.key}`,r=n.get(l)??{collision:o,widths:[]};r.widths.includes(t)||r.widths.push(t),n.set(l,r)}return[...n.values()].map(({collision:t,widths:o})=>t.kind==="overlap"?{kind:"collision",block:t.a,involves:[t.a,t.b],widths:o,message:`${Et(o)}, ${St(t.a)} runs into ${St(t.b)}.`}:{kind:"collision",block:t.key,involves:[t.key],widths:o,message:`${Et(o)}, ${St(t.key)} doesn't fit on the ${t.off==="card"?"card":"image"} and is cut off.`})}function zn(e,n=3){if(e.length<=n)return e;const t=Je.filter(r=>e.some(i=>i.widths?.includes(r))),o=t.length?Et(t):"",l=t.includes("desktop-3")?" Click Computer above the card to see it three across.":"";return[{kind:"collision",involves:[...new Set(e.flatMap(r=>r.involves??[]))],widths:t,message:`${o?`${o}, p`:"P"}arts run into each other or get cut off in ${e.length} places. Open a part to see what it runs into.${l}`}]}const Vn=[[{zone:"image-top-left"},{zone:"image-top-center"},{zone:"image-top-right"}],[{zone:"image-center",span:!0}
1],[{zone:"image-bottom-left"},{zone:null},{zone:"image-bottom-right"}],[{zone:"image-bottom-band",span:!0}]];function Mn(e,n=!1){const t=je[e],o=["body-top","body-middle","body-bottom"].filter(l=>t.includes(l));return{details:e==="overlay"?"none":e==="side-by-side"&&!n?"beside":"below",imageRows:Vn,edge:t.includes("image-edge"),detailRows:o}}const Un={status:"sold-out","badge:sold-out":"sold-out","badge:discount":"on-sale","badge:early-bird":"early-bird","badge:max-reached":"limit-reached","badge:selling-fast":"almost-sold-out","opens-in":"not-open"},Xe={endingSoon:{title:"Ending soon",hint:"In the last hours before the draw.",state:"ending-soon",related:[{key:"countdown",note:"Its own urgent colour is in its settings"}]},almostSoldOut:{title:"Almost sold out",hint:"When most of the tickets have gone.",state:"almost-sold-out",related:[{key:"progress",note:'Can turn "hot" on its own when selling fast'},{key:"badge:selling-fast",note:"A badge for when tickets are going quickly"}]},soldOut:{title:"Sold out",hint:"Every ticket has gone, before the draw.",state:"sold-out",stampText:"SOLD OUT",related:[{key:"status",note:"The Sold Out wording, and how it looks"},{key:"badge:sold-out",note:"A badge for sold-out cards"}]},ended:{title:"Ended",hint:"After the competition closes, and once it has drawn.",state:"ended",stampText:"ENDED",related:[{key:"status",note:"The Ended wording, and the winner"}]}},Wn=Object.keys(Xe);function Fn(e){switch(e){case"ending-soon":return"endingSoon";case"almost-sold-out":return"almostSoldOut";case"sold-out":return"soldOut";case"ended":case"awaiting-draw":case"won":return"ended";default:return null}}function go(e,n){const t=o=>o.filter(Boolean).join(", ")||"no change";switch(e){case"endingSoon":{const o=n.endingSoon;return o.enabled?`Last ${o.withinHours} ${o.withinHours===1?"hour":"hours"}: ${t([o.glowBorder&&"glowing border",o.pulseCountdown&&"pulsing countdown",o.urgentColour&&"red countdown"])}`:"Off"}case"almostSoldOut":{const o=n.almostSoldOut;return o.enabled?`From ${o.atPercent}% sold: ${t([o.glowBorder&&"glowing border",o.pulseProgress&&"pulsing bar",o.hotProgress&&'"hot" bar'])}`:"Off"}default:{const o=n[e];if(!o.enabled)return"Off";const l=t([o.greyscale&&"black and white",o.dim&&"faded",o.stamp.enabled&&`"${o.stamp.text}" stamp`]);return l.charAt(0).toUpperCase()+l.slice(1)}}}const rt={"image-top-left":"Top left","image-top-center":"Top","image-top-right":"Top right","image-center":"Centre","image-bottom-left":"Bottom left","image-bottom-band":"Bottom strip","image-bottom-right":"Bottom right","image-edge":"Edge tab","body-top":"Top","body-middle":"Middle","body-bottom":"Bottom"};function Hn(e){const n=je[e.layout],t=[],{image:o,body:l,present:r}=e;if(o){const i=o.right-o.left,v=o.bottom-o.top,m=[o.left,o.left+i/3,o.left+2*i/3,o.right],y=[o.top,o.top+v*.28,o.top+v*.72,o.bottom],h=(w,A,I,U)=>t.push({zone:w,left:m[A],right:m[I],top:y[U],bottom:y[U+1]});h("image-top-left",0,1,0),h("image-top-center",1,2,0),h("image-top-right",2,3,0),h("image-center",0,3,1),h("image-bottom-left",0,1,2),h("image-bottom-band",1,2,2),h("image-bottom-right",2,3,2)}if(l&&n.includes("body-top")){const i=(I,U)=>{const q=r[I];return q&&q.bottom>q.top?[q.top,q.bottom]:U},v=i("body-top",[l.top,l.top]),m=i("body-bottom",[l.bottom,l.bottom]),y=(v[1]+m[0])/2,h=i("body-middle",[y,y]);let w=(v[1]+h[0])/2,A=(h[1]+m[0])/2;if(A-w<20){const I=(w+A)/2;w=Math.max(l.top,I-10),A=Math.min(l.bottom,I+10)}t.push({zone:"body-top",left:l.left,right:l.right,top:l.top,bottom:Math.max(l.top,w)}),t.push({zone:"body-middle",left:l.left,right:l.right,top:w,bottom:A}),t.push({zone:"body-bottom",left:l.left,right:l.right,top:Math.min(l.bottom,A),bottom:l.bottom})}if(o&&n.includes("image-edge")){const i=o.right-o.left,v=Math.max(i*.2,40),m=(o.left+o.right)/2;t.push({zone:"image-edge",left:m-v,right:m+v,top:o.bottom-12,bottom:o.bottom+12})}return t.filter(i=>n.includes(i.zone))}function Zn(e,n,t){const o=dt(e,n,t.map(l=>({...l,key:l.zone})));return o?t.find(l=>
1l.zone===o)??null:null}function Yn(e,n,t,o){const l=e==="image-edge";return o.filter(r=>l?(r.left+r.right)/2<n:(r.top+r.bottom)/2<t).length}function dt(e,n,t){let o=null,l=1/0;for(const r of t){if(e<r.left||e>r.right||n<r.top||n>r.bottom)continue;const i=(r.right-r.left)*(r.bottom-r.top);i>0&&i<l&&(o=r,l=i)}return o?.key??null}const bo=Symbol("card-designer");function Ke(){const e=Do(bo);if(!e)throw new Error("Card designer parts must render inside the Competition Cards page");return e}const jn=["classic","ticket-stub","neon-arcade","luxury","minimal","trading-card"],ct={classic:{label:"Default",description:"The card every site starts with, matched to yours."},"ticket-stub":{label:"Ticket Stub",description:"A torn-off raffle ticket with a dashed edge."},"neon-arcade":{label:"Neon Arcade",description:"Dark, sharp and glowing green."},luxury:{label:"Luxury",description:"Black and gold with a serif title."},minimal:{label:"Minimal",description:"Just the essentials, no frame."},"trading-card":{label:"Trading Card",description:"A foil card that tilts on hover."}},Kn=e=>JSON.parse(JSON.stringify(e));function ee(e,n,t,o){for(const l of e.blocks)l.type===n&&t(l)}const Me=(e,n,t,o=e.align,l=!1)=>{e.zone=n,e.order=t,e.align=o,e.phoneZone=null,l&&(e.enabled=!0)},qn=(e,n)=>{for(const t of e.blocks)t.type!=="image"&&t.zone===n&&(t.order=Math.min(99,t.order+1))};function Gn(e,n){const t=e,o=pt(n.cardBg||"#1e293b")==="white";return t.style.frame="ticket-stub",t.style.corners={mode:"custom",value:"soft"},t.style.border={mode:"custom",value:{width:2,style:"dashed",color:o?"#cbd5e1":"#475569"}},t.style.font={mode:"custom",value:"Figtree"},ee(t,"title",l=>{l.settings.caps=!0,l.settings.weight="black"}),ee(t,"price",l=>{l.settings.wording="per-entry"}),ee(t,"countdown",l=>{l.settings.display="boxed",Me(l,"image-bottom-band",0,"center")}),ee(t,"progress",l=>{l.settings.display="segments"}),ee(t,"badge",l=>{l.kind!=="auto-draw"&&(l.settings.shape="tag")}),ee(t,"buttons",l=>{l.settings.mainLabel="Get tickets",l.settings.mainVariant="primary"}),qn(t,"image-top-left"),ee(t,"category-tag",l=>Me(l,"image-top-left",0,"start",!0)),t}function Jn(e){const n=e;n.density="compact",n.style.background={mode:"custom",value:{kind:"solid",color:"#0b0b14"}},n.style.textColor={mode:"custom",value:"#f5f5ff"},n.style.accent={mode:"custom",value:"#39ff14"},n.style.buttons={mode:"custom",value:{color:"#39ff14",style:"outline"}},n.style.corners={mode:"custom",value:"sharp"},n.style.frame="neon",n.style.font={mode:"custom",value:"Syne"},n.style.hover={mode:"custom",value:"glow"},n.style.buttonHover="glow",ee(n,"title",o=>{o.settings.caps=!0,o.settings.size="sm"}),ee(n,"countdown",o=>{o.settings.display="ticking",o.settings.urgentWithinHours=12}),ee(n,"progress",o=>{o.settings.display="bar",o.settings.thickness="thick"}),ee(n,"badge",o=>{o.kind!=="auto-draw"&&(o.settings.shape="tag"),o.settings.color="#39ff14"});const t=ze();return t.endingSoon={enabled:!0,withinHours:24,glowBorder:!0,pulseCountdown:!0,urgentColour:!0},t.almostSoldOut={enabled:!0,atPercent:90,glowBorder:!1,pulseProgress:!0,hotProgress:!0},t.soldOut={...t.soldOut,enabled:!0,stamp:{enabled:!0,text:"SOLD OUT",color:"#ff2d55",rotate:-15}},n.reactions=t,n}function Xn(e){const n=e;n.density="roomy",n.style.background={mode:"custom",value:{kind:"solid",color:"#0e0d0b"}},n.style.textColor={mode:"custom",value:"#f3ead7"},n.style.accent={mode:"custom",value:"#c9a227"},n.style.buttons={mode:"custom",value:{color:"#c9a227",style:"outline"}},n.style.corners={mode:"custom",value:"sharp"},n.style.frame="gold-line",n.style.font={mode:"custom",value:"Playfair Display"},n.style.hover={mode:"custom",value:"lift"},n.style.buttonHover="fill",ee(n,"image",t=>{t.settings.frame="framed",t.settings.fade=30,t.settings.vignette=20,t.settings.hoverZoom=!1}),ee(n,"title",t=>{t.settings.weight="medium",t.settings.caps=!0,t.settings.textAlign="center"}),ee(n,"price",t=>{t.settings.size="lg",t.align="center"}),ee(n,"progress",t=>{t.settings.display="text",t.settings.leftText="none",t.settings.rightText="left"}),ee(n,"badge",t=>{t.kind!=="auto-draw"&&(t.settings.shape="pill"),t.settings.color="#c9a227",t.settings.icon=!1}),ee(n,"countdown",t=>{t.settings.display="draw-date",Me(t,"body-middle",0,"center")});for(const t of n.blocks)t.type!=="image"&&t.type!=="countdown"&&t.zone==="body-middle"&&(t.order=Math.min(99,t.order+1));return ee(n,"prize-value",t=>Me(t,"image-bottom-band",0,"center",!0)),n}function Qn(e){const n=e;return n.density="compact",n.style.background={mode:"custom",value:{kind:"transparent"}},n.style.border={mode:"custom",value:{width:0,style:"solid",color:"#000000"}},n.style.surface={mode:"custom",value:"flat"},n.style.corners={mode:"site"},n.style.font={mode:"custom",value:"Inter"},n.style.hover={mode:"custom",value:"none"},ee(n,"image",t=>{t.settings.fade=0,t.settings.vignette=0,t.settings.hoverZoom=!1}),ee(n,"badge",t=>{t.enabled=t.kind==="sold-out"||t.kind==="discount",t.kind==="sold-out"&&(t.settings.shape="pill")}),ee(n,"title",t=>{t.settings.lines=1,t.settings.size="md",t.settings.weight="semibold",t.order=0}),ee(n,"countdown",t=>{t.settings.display="compact",Me(t,"body-top",1,"start")}),ee(n,"price",t=>{t.settings.size="sm",t.order=2}),ee(n,"progress",t=>{t.settings.thickness="thin",t.settings.leftText="none",t.settings.rightText="none",t.order=3}),ee(n,"buttons",t=>{t.settings.quickBuy=!1,t.settings.mainLabel="Enter",t.settings.mainVariant="primary"}),ee(n,"status",t=>{t.settings.style="pill"}),n}function es(e){const n=e;n.style.corners={mode:"custom",value:"rounded"},n.style.frame="foil",n.style.font={mode:"custom",value:"Outfit"},n.style.hover={mode:"custom",value:"tilt"},n.motion={tilt:!0,sheen:"foil",imageDrift:!1},ee(n,"image",o=>{o.settings.frame="framed",o.settings.shape={mode:"custom",value:"4:5"}}),ee(n,"title",o=>{o.settings.caps=!0,o.settings.weight="black"}),ee(n,"prize-value",o=>{Me(o,"image-bottom-left",0,"start",!0),o.phoneZone="body-top"}),ee(n,"progress",o=>{o.settings.display="ring",Me(o,"image-bottom-right",0,"end"),o.phoneZone="body-middle"}),ee(n,"countdown",o=>{o.phoneZone="image-bottom-right"}),ee(n,"badge",o=>{if(o.kind!=="auto-draw"){if(o.kind==="sold-out"){o.settings.shape="stamp",o.zone="image-top-right",o.order=1,o.align="end",o.phoneZone=null;return}o.settings.shape="pill"}});const t=ze();return t.soldOut={...t.soldOut,enabled:!0,greyscale:!0,stamp:{...t.soldOut.stamp,enabled:!0}},n.reactions=t,n}function Pt(e,n={},t={}){const o=Kn(Dt(n));let l;switch(e){case"classic":return o;case"ticket-stub":l=Gn(o,t);break;case"neon-arcade":l=Jn(o);break;case"luxury":l=Xn(o);break;
1case"minimal":l=Qn(o);break;case"trading-card":l=es(o);break}return De(l)}function ts(e){let n=e>>>0;return()=>{n=n+1831565813>>>0;let t=n;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}const ue=(e,n)=>n[Math.floor(e()*n.length)],Ee=(e,n)=>e()<n;function Ze(e,n){const t=n.reduce((l,[,r])=>l+r,0);let o=e()*t;for(const[l,r]of n)if(o-=r,o<0)return l;return n[n.length-1][0]}const os=[{name:"Midnight",bg:"#0f172a",text:"#f8fafc",accent:"#38bdf8",buttonColor:"#38bdf8",buttonStyle:"solid"},{name:"Ember",bg:"#1c1917",text:"#fafaf9",accent:"#fb923c",buttonColor:"#f97316",buttonStyle:"solid"},{name:"Forest",bg:"#052e16",text:"#ecfdf5",accent:"#4ade80",buttonColor:"#4ade80",buttonStyle:"outline"},{name:"Plum",bg:"#2e1065",text:"#faf5ff",accent:"#e879f9",buttonColor:"#d946ef",buttonStyle:"gradient"},{name:"Paper",bg:"#fafaf9",text:"#1c1917",accent:"#b45309",buttonColor:"#1c1917",buttonStyle:"solid"},{name:"Ocean",bg:"#082f49",text:"#f0f9ff",accent:"#22d3ee",buttonColor:"#22d3ee",buttonStyle:"outline"},{name:"Candy",bg:"#fdf2f8",text:"#500724",accent:"#be185d",buttonColor:"#db2777",buttonStyle:"solid"},{name:"Mint",bg:"#f0fdf4",text:"#14532d",accent:"#15803d",buttonColor:"#15803d",buttonStyle:"solid"},{name:"Gold",bg:"#0e0d0b",text:"#f3ead7",accent:"#c9a227",buttonColor:"#c9a227",buttonStyle:"outline"},{name:"Arcade",bg:"#0b0b14",text:"#f5f5ff",accent:"#39ff14",buttonColor:"#39ff14",buttonStyle:"outline"},{name:"Slate",bg:"#f1f5f9",text:"#0f172a",accent:"#4f46e5",buttonColor:"#4f46e5",buttonStyle:"solid"},{name:"Crimson",bg:"#18181b",text:"#fafafa",accent:"#fb7185",buttonColor:"#f43f5e",buttonStyle:"solid"},{name:"Sunrise",bg:"#fff7ed",text:"#431407",accent:"#c2410c",buttonColor:"#ea580c",buttonStyle:"gradient"}],ns=["Outfit","Syne","Playfair Display","Space Grotesk","Bricolage Grotesque","Fraunces","Unbounded","Chakra Petch","Sora","Figtree"],$t=[{frame:"none",corners:"soft",border:"site",surface:"elevated"},{frame:"none",corners:"rounded",border:{width:1,style:"solid",color:"muted"},surface:"bordered"},{frame:"none",corners:"pill",border:"none",surface:"elevated"},{frame:"none",corners:"site",border:"site",surface:"glass"},{frame:"ticket-stub",corners:"soft",border:{width:2,style:"dashed",color:"muted"},surface:"flat"},{frame:"neon",corners:"sharp",border:"site",surface:"flat"},{frame:"gold-line",corners:"sharp",border:"site",surface:"flat"},{frame:"foil",corners:"rounded",border:"site",surface:"elevated"},{frame:"none",corners:"sharp",border:{width:2,style:"solid",color:"accent"},surface:"flat"},{frame:"none",corners:"soft",border:{width:3,style:"double",color:"accent"},surface:"flat"}],Xt=[{motion:{tilt:!1,sheen:"none",imageDrift:!1},hover:"lift"},{motion:{tilt:!1,sheen:"none",imageDrift:!1},hover:"glow"},{motion:{tilt:!1,sheen:"none",imageDrift:!1},hover:"zoom"},{motion:{tilt:!1,sheen:"none",imageDrift:!1},hover:"site"},{motion:{tilt:!0,sheen:"light",imageDrift:!1},hover:"tilt"},{motion:{tilt:!1,sheen:"none",imageDrift:!0},hover:"lift"},{motion:{tilt:!1,sheen:"light",imageDrift:!1},hover:"glow"},{motion:{tilt:!0,sheen:"foil",imageDrift:!1},hover:"tilt",foilOnly:!0}];function ss(e){const n=ue(e,[-15,0,15]),t=ze(),o=ze();o.endingSoon={enabled:!0,withinHours:24,glowBorder:!0,pulseCountdown:!0,urgentColour:!0},o.almostSoldOut={enabled:!0,atPercent:90,glowBorder:!1,pulseProgress:!0,hotProgress:!0},o.soldOut={enabled:!0,greyscale:!0,dim:!1,stamp:{enabled:!0,text:"SOLD OUT",color:"#ef4444",rotate:n}};const l=ze();l.soldOut={...l.soldOut,enabled:!0,greyscale:!0,dim:!0},l.ended={...l.ended,enabled:!0,greyscale:!0,dim:!0};const r=ze();r.soldOut={enabled:!0,greyscale:!1,dim:!1,stamp:{enabled:!0,text:"SOLD OUT",color:"#ef4444",rotate:n}},r.ended={enabled:!0,greyscale:!0,dim:!1,stamp:{enabled:!0,text:"ENDED",color:"#9ca3af",rotate:n}};const i=ze();return i.endingSoon={enabled:!0,withinHours:12,glowBorder:!0,pulseCountdown:!1,urgentColour:!0},i.almostSoldOut={enabled:!0,atPercent:85,glowBorder:!0,pulseProgress:!1,hotProgress:!0},[t,o,l,r,i]}const as=[["stacked",60],["side-by-side",25],["overlay",15]],ls={stacked:[{badges:"image-top-left",rest:"body-middle",spots:[["countdown",["image-top-right","end","image-bottom-right"]],["category-tag",["body-top","start"]],["title",["body-top","stretch"]],["price",["body-top","start"]],["progress",["body-top","stretch"]],["status",["body-bottom","stretch"]],["buttons",["body-bottom","stretch"]]]},{badges:"image-top-left",rest:"body-middle",spots:[["category-tag",["image-top-right","end"]],["countdown",["image-bottom-band","center"]],["title",["body-top","stretch"]],["prize-value",["body-top","start"]],["price",["body-middle","start"]],["progress",["body-middle","stretch"]],["status",["body-bottom","stretch"]],["buttons",["body-bottom","stretch"]]]},{badges:"image-top-left",rest:"body-middle",spots:[["prize-value",["image-top-right","end"]],["countdown",["image-bottom-band","stretch"]],["title",["body-top","stretch"]],["price",["body-top","center"]],["progress",["body-middle","stretch"]],["status",["body-bottom","stretch"]],["buttons",["body-bottom","stretch"]]]}],"side-by-side":[{badges:"image-top-left",rest:"body-middle",spots:[["countdown",["image-bottom-band","center"]],["category-tag",["body-top","start"]],["title",["body-top","stretch"]],["price",["body-top","start"]],["progress",["body-middle","stretch"]],["status",["body-bottom","stretch"]],["buttons",["body-bottom","stretch"]]]},{badges:"image-top-left",rest:"body-middle",spots:[["category-tag",["image-top-right","end"]],["prize-value",["image-bottom-band","start"]],["countdown",["body-top","start"]],["title",["body-top","stretch"]],["price",["body-middle","start"]],["progress",["body-middle","stretch"]],["status",["body-bottom","stretch"]],["buttons",["body-bottom","stretch"]]]}],overlay:[{badges:"image-top-left",rest:"image-bottom-band",spots:[["countdown",["image-top-right","end","image-top-left"]],["title",["image-bottom-band","stretch"]],["price",["image-bottom-band","start"]],["progress",["image-bottom-band","stretch"]],["status",["image-bottom-band","stretch"]],["buttons",["image-bottom-band","stretch"]]]},{badges:"image-top-left",rest:"image-bottom-band",spots:[["countdown",["image-top-right","end","image-top-left"]],["price",["image-bottom-band","start"]],["title",["image-bottom-band","stretch"]],["progress",["image-bottom-band","stretch"]],["status",["image-bottom-band","stretch"]],["buttons",["image-bottom-band","stretch"]]]}]},is={stacked:[{mode:"site"},{mode:"custom",value:"4:3"},{mode:"custom",value:"1:1"},{mode:"custom",value:"4:5"},{mode:"custom",value:"16:9"}],"side-by-side":[{mode:"custom",value:"1:1"},{mode:"custom",value:"3:4"},{mode:"custom",value:"4:5"}],overlay:[{mode:"custom",value:"3:4"},{mode:"custom",value:"4:5"}]}
1,bt=["tickets-left","max-per-person","prize-value","draw-date","opens-in","category-tag","summary"],rs=["title","price","buttons","status"],ds=e=>JSON.parse(JSON.stringify(e)),Ct=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");function cs(e,n){const t=parseInt(e.slice(1),16),o=n>0?255:0,l=Math.abs(n),r=i=>i+(o-i)*l;return`#${Ct(r(t>>16&255))}${Ct(r(t>>8&255))}${Ct(r(t&255))}`}function po(e){if(e.mode==="site")return[];switch(e.value.kind){case"solid":return[e.value.color];case"gradient":return[e.value.from,e.value.to];case"texture":return[e.value.color];case"transparent":return[]}}function us(e,n){if(n==="accent"&&e.accent.mode==="custom")return e.accent.value;const t=po(e.background)[0];return t?pt(t)==="white"?"#cbd5e1":"#475569":"#94a3b8"}const Qt=e=>H(e);function ms(e,n){return e.blocks.some(t=>!ae(t)||It(t)!=="tab"?!1:t.type==="badge"?n.has("badges"):n.has("blocks"))}function gs(e,n){return n.has("blocks")&&e.blocks.some(t=>t.enabled&&bt.includes(t.type))}function bs(e,n){const t=[e.zone,e.phoneZone].filter(Boolean),o=l=>t.every(r=>Oe(l,r,n));if(o(e))return e;if(e.type==="badge")for(const l of["pill","tag","tab","stamp","ribbon"]){const r={...e,settings:{...e.settings,shape:l}};if(o(r))return r}if(e.type==="status")for(const l of["button","pill","stamp","ribbon"]){const r={...e,settings:{...e.settings,style:l}};if(o(r))return r}if(e.type==="progress"){const l={...e,settings:{...e.settings,display:"ring"}};if(o(l))return l}return e}function ps(e,n){let t=e;if(!Oe(t,t.zone,n)){const o=Tt(t,n);o&&(t={...t,zone:o,order:99})}return t.phoneZone&&(t.phoneZone===t.zone||!Oe(t,t.phoneZone,n))&&(t={...t,phoneZone:null}),t}function fs(e){switch(bt.includes(e.type)&&(e.enabled=!1),e.type){case"title":e.settings={...e.settings,size:e.settings.size==="sm"?"sm":"md",lines:Math.min(e.settings.lines,2)};break;case"price":e.settings={...e.settings,wording:e.settings.wording==="per-entry"?"pounds":e.settings.wording,size:e.settings.size==="lg"?"md":e.settings.size};break;case"countdown":e.settings={...e.settings,display:"compact"};break;case"progress":e.settings={...e.settings,display:e.settings.display==="segments"?"segments":"bar",thickness:e.settings.thickness==="thick"?"regular":e.settings.thickness,leftText:"none",rightText:"none"};break}}function hs(e,n,t){const o=ts(t),l=ds(e),r=l.style,i={layout:Ze(o,as),density:Ze(o,[["regular",50],["compact",30],["roomy",20]]),sideDensity:Ze(o,[["compact",85],["regular",15]]),imageSide:o(),arrangement:o(),palette:ue(o,os),bgKind:Ze(o,[["solid",55],["gradient",25],["texture",20]]),gradientAngle:ue(o,[135,160,180,200]),texture:ue(o,["noise","dots","grid","diagonal","paper"]),font:Ee(o,.15)?null:ue(o,ns),frame:ue(o,$t),frameRoll:o(),image:{shape:o(),framed:Ee(o,.3),zoom:Ee(o,.7),fade:ue(o,[0,30,60]),vignette:ue(o,[0,20,50]),drift:o()},title:{lines:ue(o,[1,2,2,3]),size:ue(o,["md","md","lg"]),weight:ue(o,["semibold","bold","bold","black"]),caps:Ee(o,.35),al
1ign:ue(o,["start","start","center"]),hoverAccent:Ee(o,.6)},price:{wording:ue(o,["pounds","pounds","pence","per-entry"]),size:ue(o,["sm","md","md","lg"])},countdown:{display:ue(o,["compact","compact","ticking","boxed","flip","draw-date"]),urgent:ue(o,[0,12,24])},progress:{display:Ze(o,[["bar",50],["segments",25],["ring",10],["text",15]]),thickness:ue(o,["thin","regular","thick"]),texts:o(),hot:Ee(o,.8)},buttons:{quickBuy:Ee(o,.75),quickBuyIcon:ue(o,["cart","ticket","plus"]),variant:ue(o,["primary","secondary"]),icon:ue(o,["none","none","arrow","ticket"])},statusStyle:ue(o,["button","button","pill"]),extras:bt.map(()=>Ee(o,.22)),badgePack:o(),badgeTint:Ee(o,.3),motion:o(),reactions:ss(o),reactionPick:o(),buttonHover:Ze(o,[["default",25],["shade",20],["fill",15],["lift",15],["glow",10],["grow",10],["none",5]])};if(!n.has("layout")){const m=ms(l,n)||i.layout==="overlay"&&gs(l,n)?"stacked":i.layout,y=ls[m],h=y[Math.floor(i.arrangement*y.length)];l.layout=m,l.density=m==="stacked"?i.density:m==="side-by-side"?i.sideDensity:"compact",m==="stacked"&&i.imageSide<.2||m==="side-by-side"&&i.imageSide<.35?l.imageSide="end":delete l.imageSide;const A=new Map(h.spots.map(([u,S],D)=>[u,{spot:S,i:D}])),I=new Map,U=u=>{const S=I.get(u)??0;return I.set(u,S+1),Math.min(99,S)},q=u=>{const S=A.get(Qt(u));return S?S.i:u.type==="badge"?100+u.order:200},B=l.blocks.filter(ae).sort((u,S)=>q(u)-q(S));for(const u of B){const S=A.get(Qt(u));let D,T=u.align,_=null;S?(D=S.spot[0],T=S.spot[1]??"start",_=S.spot[2]??null):u.type==="badge"?(D=u.kind==="auto-draw"&&m==="stacked"?"image-edge":h.badges,T=u.kind==="auto-draw"&&m==="stacked"?"center":"start"):(D=h.rest,T="start"),je[m].includes(D)||(D=h.rest),u.zone=D,u.align=T,u.phoneZone=u.type==="buttons"?null:_,u.order=U(D)}}const v=l.layout;if(!n.has("colours")){const m=i.palette,y=pt(m.bg)==="white";let h;i.bgKind==="gradient"?h={kind:"gradient",from:m.bg,to:cs(m.bg,y?.12:-.06),angle:i.gradientAngle}:i.bgKind==="texture"?h={kind:"texture",texture:i.texture,color:m.bg}:h={kind:"solid",color:m.bg},r.background={mode:"custom",value:h},r.textColor={mode:"custom",value:m.text},r.accent={mode:"custom",value:m.accent},r.buttons={mode:"custom",value:{color:m.buttonColor,style:m.buttonStyle}}}if(n.has("font")||(r.font=i.font?{mode:"custom",value:i.font}:{mode:"site"}),!n.has("corners")){const m=n.has("motion")&&e.motion.sheen==="foil",y=m?$t.filter(w=>w.frame==="foil"):$t,h=m?y[Math.floor(i.frameRoll*y.length)]:i.frame;r.frame=h.frame,r.corners=h.corners==="site"?{mode:"site"}:{mode:"custom",value:h.corners},r.surface=h.surface==="site"?{mode:"site"}:{mode:"custom",value:h.surface},r.border=h.border==="site"?{mode:"site"}:h.border==="none"?{mode:"custom",value:{width:0,style:"solid",color:"#000000"}}:{mode:"custom",value:{width:h.border.width,style:h.border.style,color:us(r,h.border.color)}}}if(!n.has("motion")){const m=Xt.filter(h=>!h.foilOnly||r.frame==="foil"),y=r.frame==="foil"&&i.motion<.5?Xt.find(h=>h.foilOnly):m[Math.floor(i.motion*m.length)];l.motion={...y.motion},r.hover=y.hover==="site"?{mode:"site"}:{mode:"custom",value:y.hover},i.buttonHover==="default"?delete r.buttonHover:r.buttonHover=i.buttonHover}if(n.has("reactions")||(l.reactions=i.reactions[Math.floor(i.reactionPick*i.reactions.length)]),!n.has("image")){const m=l.blocks.find(y=>y.type==="image");if(m?.type==="image"){const y=is[v],h={shape:y[Math.floor(i.image.shape*y.length)],fit:"cover",frame:v==="overlay"?"edge":i.image.framed?"framed":"edge",hoverZoom:i.image.zoom,fade:v==="overlay"?60:i.image.fade,vignette:i.image.vignette};m.settings=h}}if(!n.has("blocks"))for(const m of l.blocks){if(!ae(m)||m.type==="badge")continue;switch(m.type){case"title":m.settings={...m.settings,lines:i.title.lines,size:i.title.size,weight:i.title.weight,caps:i.title.caps,textAlign:i.title.align,hoverAccent:i.title.hoverAccent};break;case"price":m.settings={...m.settings,wording:i.price.wording,size:i.price.size};break;case"countdown":m.settings={...m.settings,display:i.countdown.display,urgentWithinHours:i.countdown.urgent};break;case"progress":{const h=i.progress.texts,[w,A]=h<.4?["sold-of-max","percent"]:h<.7?["left","percent"]:h<.85?["none","left"]:["percent","none"];m.settings={...m.settings,display:i.progress.display,thickness:i.progress.thickness,leftText:w,rightText:A,hotEnabled:i.progress.hot};break}case"buttons":m.settings={...m.settings,quickBuy:i.buttons.quickBuy,quickBuyIcon:i.buttons.quickBuyIcon,mainVariant:i.buttons.variant,mainIcon:i.buttons.icon};break;case"status":m.settings={...m.settings,style:i.statusStyle};break}rs.includes(m.type)&&(m.enabled=!0);const y=bt.indexOf(m.type);y!==-1&&(m.enabled=i.extras[y]),v==="overlay"&&fs(m)}if(!n.has("badges")){const m=l.reactions.soldOut.enabled&&l.reactions.soldOut.stamp.enabled,y=[{shape:"pill",icon:!0},{shape:"tag",icon:!0},{shape:"pill",icon:!1},{shape:"tag",icon:!1},...m?[]:[{shape:"pill",icon:!0,soldOutStamp:!0}]],h=y[Math.floor(i.badgePack*y.length)],w=i.badgeTint&&r.accent.mode==="custom"?r.accent.value:null;for(const A of l.blocks){if(A.type!=="badge")continue;const U=A.kind==="auto-draw"&&A.zone==="image-edge"?"tab":A.kind==="sold-out"&&h.soldOutStamp?"stamp":h.shape;A.settings={...A.settings,shape:U,icon:A.kind==="auto-draw"?!1:h.icon,color:w}}}if(l.blocks=l.blocks.map(m=>ae(m)?n.has("layout")?bs(m,v):ps(m,v):m),!n.has("colours")){const m=po(r.background),y=r.textColor.mode==="custom"?r.textColor.value:null;y&&m.some(w=>Zt(y,w)<4.5)&&(r.textColor={mode:"site"});const h=r.accent.mode==="custom"?r.accent.value:null;h&&m.some(w=>Zt(h,w)<3)&&(r.accent={mode:"site"})}return n.has("layout")?l:De(l)}const vs=()=>Math.floor(Math.random()*4294967295),ys={class:"space-y-2"},ks={class:"flex items-start gap-3"},xs={class:"min-w-0 flex-1"},ws={class:"text-base font-semibold text-card-text truncate"},Ss={key:0,class:"text-xs text-card-text-muted"},$s=be({__name:"CardDesignerPanelHeader",props:{title:{},hint:{},back:{}},emits:["back"],setup(e,{emit:n}){const t=n;return(o,l)=>{const r=Be;return c(),b("div",ys,[a("button",{type:"button",class:"inline-flex items-center gap-1 -ml-1 px-1 py-0.5 rounded text-xs text-card-text-muted hover:text-card-text hover:bg-card-text/5",onClick:l[0]||(l[0]=i=>t("back"))},[O(r,{name:"heroicons:chevron-left",class:"w-3.5 h-3.5","aria-hidden":"true"}),K(" "+P(e.back),1)]),a("div",ks,[a("div",xs,[a("h2",ws,P(e.title),
11),e.hint?(c(),b("p",Ss,P(e.hint),1)):N("",!0)]),Io(o.$slots,"actions")])])}}}),Vt=Object.assign($s,{__name:"AdminCardDesignerPanelHeader"}),Cs=["aria-checked","aria-label","title"],Os=["aria-pressed"],Ts={class:"flex flex-wrap items-center gap-1.5 min-w-0"},As={class:"block text-xs text-card-text-muted truncate"},Es=be({__name:"CardDesignerPartRow",props:{block:{},where:{},name:{}},setup(e){const n=e,t=Ke(),o=E(()=>H(n.block)),l=E(()=>n.name??Le(n.block)),r=E(()=>t.selectedKey.value===o.value),i=E(()=>t.hoveredKey.value===o.value),v=E(()=>t.warningsFor(o.value)),m=E(()=>t.issuesFor(o.value)),y=()=>{t.hoveredKey.value===o.value&&(t.hoveredKey.value=null)};return(h,w)=>{const A=Be,I=Lt;return c(),b("div",{class:oe(["flex items-center gap-1.5 pl-1.5 pr-2 py-1.5 transition-colors cursor-pointer",s(r)?"admin-selected":s(i)?"bg-card-button-subtle/60":"hover:bg-card-button-subtle/40"]),onMouseenter:w[2]||(w[2]=U=>s(t).hoveredKey.value=s(o)),onMouseleave:y,onClick:w[3]||(w[3]=U=>s(t).select(s(o)))},[a("button",{type:"button",role:"switch","aria-checked":e.block.enabled,"aria-label":e.block.enabled?`Hide ${s(l)}`:`Show ${s(l)}`,title:e.block.enabled?"On the card â click to hide":"Hidden â click to show",class:"shrink-0 p-1.5 rounded-md text-card-text-muted hover:text-card-text hover:bg-card-text/10 transition-colors",onClick:w[0]||(w[0]=ut(U=>s(t).setEnabled(s(o),!e.block.enabled),["stop"]))},[O(A,{name:e.block.enabled?"heroicons:eye":"heroicons:eye-slash",class:"w-[1.1rem] h-[1.1rem]","aria-hidden":"true"},null,8,["name"])],8,Cs),a("button",{type:"button",class:"min-w-0 flex-1 text-left","aria-pressed":s(r),onClick:w[1]||(w[1]=ut(U=>s(t).select(s(o)),["stop"]))},[a("span",Ts,[a("span",{class:oe(["text-sm font-medium truncate",e.block.enabled?"text-card-text":"text-card-text-muted"])},P(s(l)),3),s(m).length?(c(),ge(I,{key:0,tone:"critical",size:"sm"},{default:ce(()=>[...w[4]||(w[4]=[K("Needs attention",-1)])]),_:1})):s(v).length?(c(),ge(I,{key:1,tone:"attention",size:"sm",title:s(v).join(` 2`)},{default:ce(()=>[...w[5]||(w[5]=[K("Worth checking",-1)])]),_:1},8,["title"])):N("",!0)]),a("span",As,P(e.where),1)],8,Os),O(A,{name:"heroicons:chevron-right",class:oe(["w-4 h-4 shrink-0",s(r)?"text-card-text":"text-card-text-muted/60"]),"aria-hidden":"true"},null,8,["class"])],34)}}}),Mt=Object.assign(Es,{__name:"AdminCardDesignerPartRow"}),Ps={class:"space-y-4"},Bs={class:"admin-card overflow-hidden divide-y divide-[var(--admin-border)]"},Ds=be({__name:"CardDesignerBadgesPanel",setup(e){const n=Ke(),t=E(()=>n.design.value.blocks.filter(l=>l.type==="badge")),o=l=>l.enabled?he[l.zone]:Nt(l);return(l,r)=>(c(),b("div",Ps,[O(Vt,{title:"Badges",hint:"Each one shows only on competitions it applies to. Click one to style it or move it.",back:"Your card",onBack:r[0]||(r[0]=i=>s(n).openPanel({kind:"home"}))}),a("div",Bs,[(c(!0),b(L,null,X(s(t),i=>(c(),ge(Mt,{key:s(H)(i),block:i,name:s(Rt)[i.kind],where:o(i)},null,8,["block","name","where"]))),128))])]))}}),Is=Object.assign(Ds,{__name:"AdminCardDesignerBadgesPanel"}),_s={class:"rounded-xl border border-[var(--admin-border)] bg-card px-4 py-3"},Ls={class:"space-y-1"},Rs={class:"flex flex-wrap items-center gap-2 text-sm font-semibold text-card-text"},Ns={href:"mailto:[email protected]?subject=Card%20designer%20feedback",class:"inline-flex items-center gap-1 text-sm font-medium text-admin-accent-text hover:underline"},zs=be({__name:"CardDesignerBetaBanner",setup(e){return(n,t)=>{const o=Lt,l=Be;return c(),b("div",_s,[a("div",Ls,[a("p",Rs,[O(o,{tone:"attention"},{default:ce(()=>[...t[0]||(t[0]=[K("Beta",-1)])]),_:1}),t[1]||(t[1]=K(" We're still building this page ",-1))]),t[3]||(t[3]=a("p",{class:"text-sm text-card-text-secondary"}," There's a lot going on here, and we know it. How this editor works may change a lot, and things may move between visits, while we find the simplest way to design a card. ",-1)),a("a",Ns,[t[2]||(t[2]=K(" Tell us what's confusing, missing or great ",-1)),O(l,{name:"heroicons:arrow-right",class:"w-3.5 h-3.5","aria-hidden":"true"})])])])}}}),Vs=Object.assign(zs,{__name:"AdminCardDesignerBetaBanner"}),Ms=["for"],Us={class:"flex items-center gap-2"},Ws=["value","aria-label"],Fs=["id","value","placeholder"],Hs={class:"flex flex-wrap items-center gap-1.5 mt-2"},Zs=["title","aria-label","aria-pressed"],Ys=["title","aria-label","onClick"],js=be({__name:"CardDesignerColorField",props:{modelValue:{},label:{},fallback:{default:"#8b5cf6"},resetLabel:{default:void 0},platformSwatch:{default:void 0}},emits:["update:modelValue"],setup(e,{emit:n}
2){const t=e,o=n,l=Qe(),r=to(),i=E(()=>{const y=r.settings.value;return[{label:"Your button colour",value:Ne(y?.themeButtonBackgroundColor,"#3b82f6")},{label:"Your accent colour",value:Ne(y?.themeAccentColor,"#8b5cf6")},{label:"Your card colour",value:Ne(y?.themeCardBackgroundColor,"#1e293b")},{label:"Your background colour",value:Ne(y?.themeBackgroundColor,"#0f172a")},{label:"White",value:"#ffffff"},{label:"Black",value:"#000000"}]}),v=y=>{let h=y.trim();if(!h){t.resetLabel&&o("update:modelValue",null);return}h.startsWith("#")||(h=`#${h}`);const w=Ne(h,"");w&&o("update:modelValue",w)},m=async y=>{const h=y.target;v(h.value),await Ve(),h.value=t.modelValue??""};return(y,h)=>{const w=no;return c(),b("div",null,[a("label",{for:s(l),class:"block text-xs font-medium text-card-text-muted mb-1"},P(e.label),9,Ms),a("div",Us,[a("input",{type:"color",value:s(Ne)(e.modelValue,e.fallback),class:"h-9 w-12 shrink-0 rounded-lg border border-[var(--admin-border)] bg-card cursor-pointer","aria-label":`${e.label} colour picker`,onInput:h[0]||(h[0]=A=>v(A.target.value))},null,40,Ws),a("input",{id:s(l),type:"text",value:e.modelValue??"",placeholder:e.resetLabel||"#rrggbb",maxlength:"9",spellcheck:"false",class:"input h-9 py-0 text-sm font-mono flex-1 min-w-0",onChange:m},null,40,Fs),e.resetLabel&&e.modelValue?(c(),ge(w,{key:0,icon:"heroicons:arrow-uturn-left",title:`Back to ${e.resetLabel.toLowerCase()}`,size:"sm",onClick:h[1]||(h[1]=A=>o("update:modelValue",null))},null,8,["title"])):N("",!0)]),a("div",Hs,[e.resetLabel&&e.platformSwatch?(c(),b("button",{key:0,type:"button",title:e.resetLabel,"aria-label":`${e.label}: ${e.resetLabel}`,"aria-pressed":!e.modelValue,class:oe(["h-6 px-2 rounded-md border text-[0.6875rem] font-semibold text-white transition-transform hover:scale-105",e.modelValue?"border-[var(--admin-border)]":"border-transparent ring-2 ring-offset-1 ring-[var(--admin-btn-primary-bg)]"]),style:Ce({background:e.platformSwatch}),onClick:h[2]||(h[2]=A=>o("update:modelValue",null))}," Platform ",14,Zs)):N("",!0),(c(!0),b(L,null,X(s(i),A=>(c(),b("button",{key:A.label,type:"button",title:A.label,"aria-label":`${e.label}: ${A.label}`,class:"w-6 h-6 rounded-md border border-[var(--admin-border)] transition-transform hover:scale-110",style:Ce({backgroundColor:A.value}),onClick:I=>v(A.value)},null,12,Ys))),128))])])}}}),$e=Object.assign(js,{__name:"AdminCardDesignerColorField"}),Ks=["aria-label"],qs=["aria-checked","disabled","title","onClick"],Gs=be({__name:"CardDesignerSegmented",props:{modelValue:{},options:{},label:{}},emits:["update:modelValue"],setup(e,{emit:n}){const t=n;return(o,l)=>(c(),b("div",{class:"admin-segmented flex-wrap max-w-full",role:"radiogroup","aria-label":e.label},[(c(!0),b(L,null,X(e.options,r=>(c(),b("button",{key:String(r.value),type:"button",role:"radio","aria-checked":e.modelValue===r.value,disabled:r.disabled,title:r.title,class:oe(["admin-segment",e.modelValue===r.value&&"admin-segment-active"]),onClick:i=>t("update:modelValue",r.value)},P(r.label),11,qs))),128))],8,Ks))}}),Q=Object.assign(Gs,{__name:"AdminCardDesignerSegmented"}),Js=["aria-label"],Xs=["aria-checked","title","onClick"],Qs={key:0,class:"inline-block w-1.5 h-1.5 ml-1 rounded-full bg-current opacity-60 align-middle","aria-label":"(your site)"},ea=be({__name:"CardDesignerSiteChoice",props:{modelValue:{},options:{},siteValue:{},label:{}},emits:["update:modelValue"],setup(e,{emit:n}){const t=e,o=n,l=E(()=>t.modelValue.mode==="site"?t.siteValue:t.modelValue.value),r=i=>{o("update:modelValue",i===t.siteValue?{mode:"site"}:{mode:"custom",value:i})};return(i,v)=>(c(),b("div",{class:"admin-segmented flex-wrap max-w-full",role:"radiogroup","aria-label":e.label},[(c(!0),b(L,null,X(e.options,m=>(c(),b("button",{key:String(m.value),type:"button",role:"radio","aria-checked":s(l)===m.value,title:m.value===e.siteValue?"Your site's setting":void 0,class:oe(["admin-segment",s(l)===m.value&&"admin-segment-active"]),onClick:y=>r(m.value)},[K(P(m.label)+" ",1),m.value===e.siteValue?(c(),b("span",Qs)):N("",!0)],10,Xs))),128))],8,Js))}}),Ot=Object.assign(ea,{__name:"AdminCardDesignerSiteChoice"}),ta={class:"space-y-4"},oa={class:"admin-card p-4 space-y-4"},na={class:"flex items-start justify-between gap-3"},sa={class:"grid grid-cols-4 gap-1.5",role:"group","aria-label":"Card colours"},aa=["aria-expanded","onClick"],la={class:"text-xs font-medium text-card-text"},ia={class:"text-[0.65rem] leading-none text-card-text-muted"},ra={key:0,class:"rounded-lg border border-[var(--admin-border)] p-3 space-y-3"},da={key:1,class:"grid gap-3 grid-cols-2"},ca={class:"col-span-2"},ua=["for"],ma=["id","value"],ga={key:2,class:"grid gap-3 grid-cols-2"},ba=["for"],pa=["id","value"],fa=["value"],ha={key:3,class:"text-xs text-card-text-muted"},va={key:0,class:"text-xs text-card-text-muted"},ya={class:"text-xs text-card-text-muted mt-1"},ka={class:"mt-1 text-xs text-card-text-muted"},xa={class:"admin-card p-4 space-y-4"},wa={class:"space-y-3"},Sa={key:0,class:"grid gap-3 grid-cols-2 items-start pl-3 border-l-2 border-[var(--admin-border)]"},$a={class:"text-xs text-card-text-muted mt-1"},Ca={class:"admin-card p-4 space-y-4"},Oa={class:"text-xs text-card-text-muted mt-1"},Ta={key:0,class:"mt-1 text-xs text-amber-400"},Aa={class:"flex items-start justify-between gap-4 cursor-pointer"},Ea=["aria-checked"],Pa={class:"flex items-start justify-between gap-4 cursor-pointer"},Ba=["aria-checked"],Da=be({__name:"CardDesignerLook",setup(e){const n=Ke(),t=Qe(),o=E(()=>n.site.value),l=E(()=>n.design.value.style),r=E(()=>n.design.value.motion),i=j(null),v=[{key:"background",label:"Card",siteWord:"Your site",reset:"Use your site's card colour"},{key:"textColor",label:"Text",siteWord:"Automatic",reset:"Back to automatic"},{key:"accent",label:"Accent",siteWord:"Your site",reset:"Use your site's accent colour"},{key:"buttons",label:"Buttons",siteWord:"Your site",reset:"Use your site's buttons"}
2],m=E(()=>l.value.background.mode==="custom"?l.value.background.value:{kind:"solid",color:o.value.cardBg}),y=E(()=>l.value.buttons.mode==="custom"?l.value.buttons.value:{color:o.value.buttonColor,style:o.value.buttonStyle}),h=E(()=>Sn(l.value)),w={textColor:()=>o.value.text,accent:()=>o.value.accent,font:()=>o.value.font},A=k=>{const g=l.value[k];return g.mode==="custom"?g.value:w[k]()},I=k=>{if(k==="background"){const g=m.value;return g.kind==="gradient"?`linear-gradient(${g.angle}deg, ${g.from}, ${g.to})`:g.kind==="transparent"?"repeating-conic-gradient(#8885 0% 25%, transparent 0% 50%) 50% / 10px 10px":g.color}return k==="buttons"?y.value.color:A(k)},U=E(()=>Tn(n.design.value,"all")),q=k=>n.setDesign({...n.design.value,style:k}),B=(k,g)=>q({...l.value,[k]:g}),u=(k,g)=>B(k,{mode:"custom",value:g}),S=k=>B(k,{mode:"site"}),D=k=>k===o.value.font?S("font"):u("font",k),T=k=>q($n(l.value,k)),_=k=>n.setDesign({...n.design.value,motion:{...r.value,...k}}),ne=()=>n.setDesign(On(n.design.value,"all")),ie=k=>{const g=parseInt(k.slice(1),16),R=(g>>16&255)*.299+(g>>8&255)*.587+(g&255)*.114>128?0:255,Y=$=>Math.round($+(R-$)*.15).toString(16).padStart(2,"0");return`#${Y(g>>16&255)}${Y(g>>8&255)}${Y(g&255)}`},G=(k,g)=>{const Z=k.kind==="solid"||k.kind==="texture"?k.color:k.kind==="gradient"?k.from:o.value.cardBg;switch(g){case"solid":return{kind:g,color:Z};case"gradient":return{kind:g,from:Z,to:ie(Z),angle:160};case"texture":return{kind:g,texture:"noise",color:Z};case"transparent":return{kind:g}}},W=E(()=>l.value.border.mode==="site"?"site":String(l.value.border.value.width)),re=k=>{if(k==="site")return S("border");const g=l.value.border.mode==="custom"?l.value.border.value:{width:1,style:"solid",color:o.value.accent};u("border",{...g,width:Number(k)})},M=[{value:"solid",label:"Solid"},{value:"gradient",label:"Gradient"},{value:"texture",label:"Texture"},{value:"transparent",label:"None"}],F=[{value:"noise",label:"Grain"},{value:"dots",label:"Dots"},{value:"grid",label:"Grid"},{value:"diagonal",label:"Stripes"},{value:"paper",label:"Paper"}],se=[{value:"solid",label:"Solid"},{value:"outline",label:"Outline"},{value:"ghost",label:"Ghost"},{value:"gradient",label:"Gradient"}],pe=[{value:"default",label:"Default"},{value:"none",label:"None"},{value:"shade",label:"Shade"},{value:"lift",label:"Lift"},{value:"grow",label:"Grow"},{value:"glow",label:"Glow"},{value:"fill",label:"Fill"}],me={default:"A light fade or tint, set by the button style. Phones don't hover.",none:"The buttons stay as they are under the mouse.",shade:"The button colour shifts a shade: dark buttons lighten, light ones darken.",lift:"The buttons rise a touch, with a shadow. Shade instead for visitors who ask for less motion.",grow:"The buttons grow a little. Shade instead for visitors who ask for less motion.",glow:"A soft glow in the button colour.",fill:"Solid buttons hollow out to an outline; outline, ghost and grey buttons fill in."},z=[{value:"flat",label:"Flat"},{value:"elevated",label:"Elevated"},{value:"bordered",label:"Bordered"},{value:"glass",label:"Glass"}],d=[{value:"sharp",label:"Sharp"},{value:"soft",label:"Soft"},{value:"rounded",label:"Rounded"},{value:"pill",label:"Pill"}],f=[{value:"site",label:"Fine line"},{value:"0",label:"None"},{value:"1",label:"Thin"},{value:"2",label:"Medium"},{value:"3",label:"Thick"}],ve=[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"double",label:"Double"}],ke=[{value:"none",label:"None"},{value:"lift",label:"Lift"},{value:"zoom",label:"Zoom"},{value:"glow",label:"Glow"},{value:"tilt",label:"Tilt"}],fe=[{value:"none",label:"None"},{value:"ticket-stub",label:"Ticket stub"},{value:"neon",label:"Neon"},{value:"gold-line",label:"Gold line"},{value:"foil",label:"Foil"}],Se={none:"No decoration around the card.","ticket-stub":"A torn-off tear line between the image and the details, with notched edges.",neon:"A glowing edge in your accent colour.","gold-line":"A thin gold border with an inner line.",foil:"A rainbow foil edge. Pairs with the foil sheen below."},xe=[{value:"none",label:"None"},{value:"light",label:"Light"},{value:"foil",label:"Foil"}],x={none:"No shine.",light:"A soft light follows the pointer across the card.",foil
2:"A trading-card rainbow band that shifts with the pointer."};return(k,g)=>{const Z=ft,R=Be,Y=nn;return c(),b("div",ta,[a("section",oa,[a("div",na,[g[24]||(g[24]=a("div",{class:"min-w-0"},[a("h3",{class:"admin-section-title"},"Colours and font"),a("p",{class:"text-xs text-card-text-muted mt-0.5"},[K(" Anything marked "),a("span",{class:"font-medium text-card-text-secondary"},"Your site"),K(" or with a dot follows Settings â Appearance, so your cards change with it. ")])],-1)),s(U)?N("",!0):(c(),ge(Z,{key:0,size:"xs",variant:"secondary",class:"shrink-0",title:"Put the colours, font, card style, corners, border and the card's hover back on your site's settings",onClick:ne},{default:ce(()=>[...g[23]||(g[23]=[K(" Match my site ",-1)])]),_:1}))]),a("div",sa,[(c(),b(L,null,X(v,$=>a("button",{key:$.key,type:"button","aria-expanded":s(i)===$.key,class:oe(["flex flex-col items-center gap-1 rounded-lg px-1 py-2 border transition-colors",s(i)===$.key?"border-[var(--admin-btn-primary-bg)] admin-selected":"border-transparent hover:bg-card-button-subtle"]),onClick:de=>i.value=s(i)===$.key?null:$.key},[a("span",{class:"w-9 h-9 rounded-full border border-card-text/20 shadow-inner",style:Ce({background:I($.key)}),"aria-hidden":"true"},null,4),a("span",la,P($.label),1),a("span",ia,P(s(l)[$.key].mode==="site"?$.siteWord:"Your own"),1)],10,aa)),64))]),s(i)?(c(),b("div",ra,[s(i)==="background"?(c(),b(L,{key:0},[O(Q,{"model-value":s(m).kind,options:M,label:"Background type","onUpdate:modelValue":g[0]||(g[0]=$=>$!==s(m).kind&&u("background",G(s(m),$)))},null,8,["model-value"]),s(m).kind==="solid"?(c(),ge($e,{key:0,"model-value":s(m).color,label:"Colour","onUpdate:modelValue":g[1]||(g[1]=$=>$&&u("background",{kind:"solid",color:$}))},null,8,["model-value"])):s(m).kind==="gradient"?(c(),b("div",da,[O($e,{"model-value":s(m).from,label:"From","onUpdate:modelValue":g[2]||(g[2]=$=>$&&u("background",{...s(m),from:$}))},null,8,["model-value"]),O($e,{"model-value":s(m).to,label:"To","onUpdate:modelValue":g[3]||(g[3]=$=>$&&u("background",{...s(m),to:$}))},null,8,["model-value"]),a("div",ca,[a("label",{for:`${s(t)}-angle`,class:"block text-xs font-medium text-card-text-muted mb-1"},"Direction ("+P(s(m).angle)+"°)",9,ua),a("input",{id:`${s(t)}-angle`,type:"range",min:"0",max:"360",step:"5",value:s(m).angle,class:"w-full accent-admin-accent",onInput:g[4]||(g[4]=$=>u("background",{...s(m),angle:Number($.target.value)}))},null,40,ma)])])):s(m).kind==="texture"?(c(),b("div",ga,[a("div",null,[a("label",{for:`${s(t)}-texture`,class:"block text-xs font-medium text-card-text-muted mb-1"},"Texture",8,ba),a("select",{id:`${s(t)}-texture`,class:"input h-9 py-0 text-sm",value:s(m).texture,onChange:g[5]||(g[5]=$=>u("background",{...s(m),texture:$.target.value}))},[(c(),b(L,null,X(F,$=>a("option",{key:$.value,value:$.value},P($.label),9,fa)),64))],40,pa)]),O($e,{"model-value":s(m).color,label:"Colour","onUpdate:modelValue":g[6]||(g[6]=$=>$&&u("background",{...s(m),color:$}))},null,8,["model-value"])])):(c(),b("p",ha," The card sits straight on your page background, and its text takes your page's text colour. ")),g[25]||(g[25]=a("p",{class:"text-xs text-card-text-muted"},"Just for your cards: your header and panels keep Card Color.",-1))],64)):s(i)==="textColor"?(c(),b(L,{key:1},[O($e,{"model-value":A("textColor"),label:"Text colour","onUpdate:modelValue":g[7]||(g[7]=$=>$&&u("textColor",$))},null,8,["model-value"]),s(l).textColor.mode==="site"?(c(),b("p",va,"Automatic: picked so it reads on the background.")):N("",!0)],64)):s(i)==="accent"?(c(),b(L,{key:2},[O($e,{"model-value":A("accent"),label:"Accent colour","onUpdate:modelValue":g[8]||(g[8]=$=>$&&u("accent",$))},null,8,["model-value"]),g[26]||(g[26]=a("p",{class:"text-xs text-card-text-muted"},"Progress bars, highlights and glows.",-1))],64)):s(i)==="buttons"?(c(),b(L,{key:3},[O($e,{"model-value":s(y).color,label:"Button colour","onUpdate:modelValue":g[9]||(g[9]=$=>$&&u("buttons",{...s(y),color:$}))},null,8,["model-value"]),a("div",null,[g[27]||(g[27]=a("p",{class:"block text-xs font-medium text-card-text-muted mb-1"},"Button style",-1)),O(Q,{"model-value":s(y).style,options:se,label:"Button style","onUpdate:modelValue":g[10]||(g[10]=$=>u("buttons",{...s(y),style:$}))},null,8,["model-value"])]),a("div",null,[g[28]||(g[28]=a("p",{class:"block text-xs font-medium text-card-text-muted mb-1"},"Hover",-1)),O(Q,{"model-value":s(h),options:pe,label:"Button hover","onUpdate:modelValue":T},null,8,["model-value"]),a("p",ya,P(me[s(h)]),1)])],64)):N("",!0),s(l)[s(i)].mode==="custom"?(c(),b("button",{key:4,type:"button",class:"inline-flex items-center gap-1 text-xs font-medium text-admin-accent-text hover:underline",onClick:g[11]||(g[11
2]=$=>S(s(i)))},[O(R,{name:"heroicons:arrow-uturn-left",class:"w-3.5 h-3.5","aria-hidden":"true"}),K(" "+P(v.find($=>$.key===s(i))?.reset),1)])):N("",!0)])):N("",!0),a("div",null,[g[29]||(g[29]=a("p",{class:"block text-xs font-medium text-card-text-muted mb-1"},"Font",-1)),O(Y,{"model-value":A("font"),placeholder:"Choose a font","onUpdate:modelValue":g[12]||(g[12]=$=>$&&D($))},null,8,["model-value"]),a("p",ka,[s(l).font.mode==="site"?(c(),b(L,{key:0},[K("Your site font.")],64)):(c(),b("button",{key:1,type:"button",class:"font-medium text-admin-accent-text hover:underline",onClick:g[13]||(g[13]=$=>S("font"))},"Use your site font ("+P(s(o).font)+")",1))])])]),a("section",xa,[g[35]||(g[35]=a("h3",{class:"admin-section-title"},"Shape",-1)),a("div",null,[g[30]||(g[30]=a("p",{class:"field-label"},"Card style",-1)),O(Ot,{"model-value":s(l).surface,options:z,"site-value":s(o).surface,label:"Card style","onUpdate:modelValue":g[14]||(g[14]=$=>B("surface",$))},null,8,["model-value","site-value"])]),a("div",null,[g[31]||(g[31]=a("p",{class:"field-label"},"Corners",-1)),O(Ot,{"model-value":s(l).corners,options:d,"site-value":s(o).corners,label:"Corners","onUpdate:modelValue":g[15]||(g[15]=$=>B("corners",$))},null,8,["model-value","site-value"])]),a("div",wa,[a("div",null,[g[32]||(g[32]=a("p",{class:"field-label"},"Border",-1)),O(Q,{"model-value":s(W),options:f,label:"Border","onUpdate:modelValue":re},null,8,["model-value"])]),s(l).border.mode==="custom"&&s(l).border.value.width>0?(c(),b("div",Sa,[a("div",null,[g[33]||(g[33]=a("p",{class:"field-label"},"Line",-1)),O(Q,{"model-value":s(l).border.value.style,options:ve,label:"Border line","onUpdate:modelValue":g[16]||(g[16]=$=>u("border",{...s(l).border.value,style:$}))},null,8,["model-value"])]),O($e,{"model-value":s(l).border.value.color,label:"Border colour","onUpdate:modelValue":g[17]||(g[17]=$=>$&&u("border",{...s(l).border.value,color:$}))},null,8,["model-value"])])):N("",!0)]),a("div",null,[g[34]||(g[34]=a("p",{class:"field-label"},"Frame",-1)),O(Q,{"model-value":s(l).frame,options:fe,label:"Frame","onUpdate:modelValue":g[18]||(g[18]=$=>q({...s(l),frame:$}))},null,8,["model-value"]),a("p",$a,P(Se[s(l).frame]),1)])]),a("section",Ca,[g[40]||(g[40]=a("div",null,[a("h3",{class:"admin-section-title"},"Hover and motion"),a("p",{class:"text-xs text-card-text-muted mt-0.5"}," What a card does under the mouse; phones don't hover. Sheen, leaning and the drifting image are off for visitors who ask for less motion. ")],-1)),a("div",null,[g[36]||(g[36]=a("p",{class:"field-label"},"Under the mouse",-1)),O(Ot,{"model-value":s(l).hover,options:ke,"site-value":s(o).hover,label:"Hover effect","onUpdate:modelValue":g[19]||(g[19]=$=>B("hover",$))},null,8,["model-value","site-value"])]),a("div",null,[g[37]||(g[37]=a("p",{class:"field-label"},"Sheen",-1)),O(Q,{"model-value":s(r).sheen,options:xe,label:"Sheen","onUpdate:modelValue":g[20]||(g[20]=$=>_({sheen:$}))},null,8,["model-value"]),a("p",Oa,P(x[s(r).sheen]),1),s(r).sheen==="foil"&&s(l).frame!=="foil"?(c(),b("p",Ta,"Foil sheen looks best with the Foil frame, above.")):N("",!0)]),a("label",Aa,[g[38]||(g[38]=a("span",{class:"min-w-0"},[a("span",{class:"block text-sm text-card-text"},"Lean towards the pointer"),a("span",{class:"block text-xs text-card-text-muted"},"The card tilts as the mouse moves over it.")],-1)),a("button",{type:"button",role:"switch","aria-checked":s(r).tilt,"aria-label":"Lean towards the pointer",class:"admin-switch cursor-pointer mt-0.5",onClick:g[21]||(g[21]=$=>_({tilt:!s(r).tilt}))},null,8,Ea)]),a("label",Pa,[g[39]||(g[39]=a("span",{class:"min-w-0"},[a("span",{class:"block text-sm text-card-text"},"Drifting image"),a("span",{class:"block text-xs text-card-text-muted"},"The prize image moves slowly, like a camera pan.")],-1)),a("button",{type:"button",role:"switch","aria-checked":s(r).imageDrift,"aria-label":"Drifting image",class:"admin-switch cursor-pointer mt-0.5",onClick:g[22]||(g[22]=$=>_({imageDrift:!s(r).imageDrift}))},null,8,Ba)])])])}}}),Ia=Object.assign(et(Da,[["__scopeId","data-v-74eee45d"]]),{__name:"AdminCardDesignerLook"}),_a={class:"space-y-4"},La={class:"admin-card p-4 space-y-4"},Ra={class:"grid grid-cols-3 gap-2",role:"radiogroup","aria-label":"Layout"},Na=["aria-checked","title","onClick"],za={class:"text-xs font-medium text-card-text"},Va={class:"flex flex-wrap items-center justify-between gap-2"},Ma={key:0},Ua={class:"flex flex-wrap items-center justify-between gap-2"},Wa={key:0,class:"mt-1 text-xs text-card-text-muted"},Fa={class:"space-y-1.5"},Ha={class:"admin-card overflow-hidden"},Za={class:"px-3 pt-2.5 pb-1 text-[0.7rem] font-semibold uppercase tracking-wide text-card-text-muted"},Ya={class:"divide-y divide-[var(--admin-border)] border-b border-[var(--admin-border)]"},ja={class:"min-w-0 flex-1"},Ka={class:"flex items-center gap-1.5"},qa={class:"block text-xs text-card-text-muted truncate"},Ga={key:0,class:"pt-1.5"},Ja={class:"flex flex-wrap gap-1.5"},Xa=["title","onClick"],Qa={class:"space-y-1.5"},el={class:"admin-card overflow-hidden divide-y divide-[var(--admin-border)]"},tl=["onClick"],ol={class:"min-w-0 flex-1"},nl={class:"block text-sm font-medium text-card-text"},sl={class:"block text-xs text-card-text-muted truncate"},al=be({__name:"CardDesignerHome",setup(e){const n=Ke(),t=E(()=>n.design.value),o=[{value:"stacked",label:"Stacked",description:"Image on top, details below, like the default card."},{value:"side-by-side",label:"Side by side",description:"Image beside the details. Narrow cards stack themselves."},{value:"overlay",label:"Overlay",description:"The image fills the card and everything sits on it."}],l=[{value:"compact",label:"Compact"},{value:"regular",label:"Regular"},{value:"roomy",label:"Roomy"}],r=[{value:"start",label:"On top"},{value:"end",label:"Below"}],i=[{value:"start",label:"Left"},{value:"end",label:"Right"}],v={endingSoon:"is ending soon",almostSoldOut:"is almost sold out",soldOut:"sells out",ended:"has ended"},m=B=>B.phoneZone?`${rt[B.zone]} · on phones: ${rt[B.phoneZone].toLowerCase()}`:rt[B.zone],y=E(()=>{const B=t.value,u=ao(B.layout),S=B.blocks.filter(W=>ae(W)&&W.enabled&&W.type!=="badge").sort((W,re)=>u.indexOf(W.zone)-u.indexOf(re.zone)||W.order-re.order),D=B.blocks.find(W=>W.type==="image"),T=[...D?.enabled?[{block:D,where:"The prize photo"}]:[],...S.filter(W=>W.zone.startsWith("image-")).map(W=>({block:W,where:m(W)}))],_=S.filter(W=>!W.zone.startsWith("image-")).map(W=>({block:W,where:m(W)})),ne=it(B)==="end",ie=B.layout==="side-by-side"?"Beside the image":ne?"Above the image":"Below the image",G=[{title:"On the image",rows:T},{title:ie,rows:_}];return(B.layout==="stacked"&&ne?G.reverse():G).filter(W=>W.rows.length>0)}),h=E(()=>
2t.value.blocks.filter(B=>!B.enabled&&B.type!=="badge")),w=E(()=>t.value.blocks.filter(B=>B.type==="badge")),A=E(()=>w.value.length),I=E(()=>w.value.filter(B=>B.enabled).length),U=E(()=>w.value.some(B=>n.issuesFor(H(B)).length>0)),q=B=>{n.setEnabled(H(B),!0),n.select(H(B))};return(B,u)=>{const S=Be,D=Lt;return c(),b("div",_a,[a("section",La,[u[6]||(u[6]=a("h3",{class:"admin-section-title"},"Layout",-1)),a("div",Ra,[(c(),b(L,null,X(o,T=>a("button",{key:T.value,type:"button",role:"radio","aria-checked":s(t).layout===T.value,title:T.description,class:oe(["flex flex-col items-center gap-1.5 p-2 rounded-lg border transition-colors",s(t).layout===T.value?"border-[var(--admin-btn-primary-bg)] ring-1 ring-[var(--admin-btn-primary-bg)] admin-selected":"border-[var(--admin-border)] hover:bg-card-button-subtle"]),onClick:_=>s(n).setLayout(T.value)},[a("span",{class:oe(["w-9 h-12 rounded-[3px] border border-card-text/40 overflow-hidden flex",T.value==="side-by-side"?"flex-row":"flex-col",T.value==="overlay"?"relative":""]),"aria-hidden":"true"},[a("span",{class:oe(["bg-card-text/35",T.value==="stacked"?"h-[55%]":T.value==="side-by-side"?"w-[45%]":"absolute inset-0"])},null,2),a("span",{class:oe(["flex flex-col gap-0.5 p-1",T.value==="overlay"?"relative mt-auto":"flex-1"])},[...u[3]||(u[3]=[a("span",{class:"h-0.5 w-4/5 rounded bg-card-text/60"},null,-1),a("span",{class:"h-0.5 w-1/2 rounded bg-card-text/60"},null,-1)])],2)],2),a("span",za,P(T.label),1)],10,Na)),64))]),a("div",Va,[u[4]||(u[4]=a("p",{class:"text-xs font-medium text-card-text-muted"},"Spacing",-1)),O(Q,{"model-value":s(t).density,options:l,label:"Spacing","onUpdate:modelValue":u[0]||(u[0]=T=>s(n).setDesign({...s(t),density:T}))},null,8,["model-value"])]),s(t).layout!=="overlay"?(c(),b("div",Ma,[a("div",Ua,[u[5]||(u[5]=a("p",{class:"text-xs font-medium text-card-text-muted"},"Image",-1)),O(Q,{"model-value":s(it)(s(t)),options:s(t).layout==="stacked"?r:i,label:"Where the image sits","onUpdate:modelValue":u[1]||(u[1]=T=>s(n).setDesign(s(wn)(s(t),T)))},null,8,["model-value","options"])]),s(t).layout==="side-by-side"&&s(it)(s(t))==="end"?(c(),b("p",Wa," On a narrow card, where it stacks, the image stays on top. ")):N("",!0)])):N("",!0)]),a("section",Fa,[u[10]||(u[10]=a("h3",{class:"admin-eyebrow"},"On the card",-1)),a("div",Ha,[(c(!0),b(L,null,X(s(y),T=>(c(),b(L,{key:T.title},[a("p",Za,P(T.title),1),a("div",Ya,[(c(!0),b(L,null,X(T.rows,_=>(c(),ge(Mt,{key:s(H)(_.block),block:_.block,where:_.where},null,8,["block","where"]))),128))])],64))),128)),a("button",{type:"button",class:"w-full flex items-center gap-2 pl-3 pr-2 py-2 text-left hover:bg-card-button-subtle/40 transition-colors",onClick:u[2]||(u[2]=T=>s(n).openPanel({kind:"badges"}))},[O(S,{name:"heroicons:tag",class:"w-4 h-4 shrink-0 text-card-text-muted","aria-hidden":"true"}),a("span",ja,[a("span",Ka,[u[8]||(u[8]=a("span",{class:"text-sm font-medium text-card-text"},"Badges",-1)),s(U)?(c(),ge(D,{key:0,tone:"critical",size:"sm"},{default:ce(()=>[...u[7]||(u[7]=[K("Needs attention",-1)])]),_:1})):N("",!0)]),a("span",qa,P(s(I))+" of "+P(s(A))+" on · each shows only when it applies",1)]),O(S,{name:"heroicons:chevron-right",class:"w-4 h-4 shrink-0 text-card-text-muted/60","aria-hidden":"true"})])]),s(h).length?(c(),b("div",Ga,[u[9]||(u[9]=a("p",{class:"text-xs text-card-text-muted mb-1.5"},"Add to the card",-1)),a("div",Ja,[(c(!0),b(L,null,X(s(h),T=>(c(),b("button",{key:s(H)(T),type:"button",class:"inline-flex items-center gap-1 rounded-full border border-dashed border-[var(--admin-border)] px-2.5 py-1 text-xs text-card-text-secondary hover:border-card-text/50 hover:text-card-text",title:s(Nt)(T),onClick:_=>q(T)},[O(S,{name:"heroicons:plus",class:"w-3 h-3","aria-hidden":"true"}),K(" "+P(s(Le)(T)),1)],8,Xa))),128))])])):N("",!0)]),O(Ia),a("section",Qa,[u[11]||(u[11]=a("h3",{class:"admin-eyebrow"},"When a competitionâ¦",-1)),a("div",el,[(c(!0),b(L,null,X(s(Wn),T=>(c(),b("button",{key:T,type:"button",class:"w-full flex items-center gap-2 pl-3 pr-2 py-2 text-left hover:bg-card-button-subtle/40 transition-colors",onClick:_=>
2s(n).openPanel({kind:"state",which:T})},[a("span",{class:oe(["w-2 h-2 rounded-full shrink-0",s(t).reactions[T].enabled?"bg-emerald-400":"bg-card-text/20"]),"aria-hidden":"true"},null,2),a("span",ol,[a("span",nl,P(v[T]),1),a("span",sl,P(s(go)(T,s(t).reactions)),1)]),O(S,{name:"heroicons:chevron-right",class:"w-4 h-4 shrink-0 text-card-text-muted/60","aria-hidden":"true"})],8,tl))),128))])])])}}}),ll=Object.assign(al,{__name:"AdminCardDesignerHome"}),il={class:"grid gap-4"},rl=["for"],dl=["id","value"],cl=["value"],ul={class:"check-row"},ml=["checked"],gl=["for"],bl=["id","value"],pl=["for"],fl=["id","value"],hl={class:"check-row"},vl=["checked"],yl={class:"check-row"},kl=["checked"],xl={class:"check-row"},wl=["checked"],Sl={class:"check-row"},$l=["checked"],Cl=["for"],Ol=["id","value"],Tl={class:"mt-1 text-xs text-card-text-muted"},Al=["for"],El={class:"flex items-center gap-2"},Pl=["id","value"],Bl={class:"check-row"},Dl=["checked"],Il={key:0},_l=["for"],Ll=["id","value"],Rl=["value"],Nl=["for"],zl=["id","value"],Vl=["value"],Ml={class:"check-row"},Ul=["checked"],Wl={key:1},Fl=["for"],Hl={class:"flex items-center gap-2"},Zl=["id","value"],Yl=["for"],jl=["id","value"],Kl={class:"space-y-2"},ql={class:"check-row"},Gl=["checked"],Jl={class:"mt-1 text-xs text-card-text-muted"},Xl={class:"check-row"},Ql=["checked"],ei=["for"],ti=["id","placeholder","value","onInput"],oi={key:0},ni=["for"],si=["id","placeholder","value"],ai={class:"mt-1 text-xs text-card-text-muted"},li={key:1,class:"text-xs text-card-text-muted"},ii={class:"mt-1 text-xs text-card-text-muted"},ri={class:"mt-1 text-xs text-card-text-muted"},di={class:"check-row"},ci=["checked"],ui={key:8},mi={key:9},gi=["for"],bi=["id","value"],pi={key:10},fi=["for"],hi=["id","value"],vi={class:"mt-1 text-xs text-card-text-muted"},yi=["for"],ki=["id","value"],xi={key:12},wi={key:13},Si=be({__name:"CardDesignerBlockSettings",props:{block:{},layout:{}},emits:["update"],setup(e,{emit:n}){const t=e,o=n,l=Qe(),r=z=>`${l}-${z}`,i=z=>{o("update",{...t.block,settings:{...t.block.settings,...z}})},v=z=>z.target.checked,m=z=>Number(z.target.value),y=z=>z.target.value,h=z=>z.target.value,w=(z,d,f)=>{const ve=z.target,ke=Math.round(Number(ve.value)),fe=Number.isFinite(ke)?Math.min(f,Math.max(d,ke)):d;return ve.value=String(fe),fe},A=(z,d)=>{const f=y(z);f.trim()&&i({[d]:f})},I=(z,d,f)=>{const ve=z.target;ve.value.trim()||(ve.value=f,i({[d]:f}))},U=z=>{i({shape:z==="site"?{mode:"site"}:{mode:"custom",value:z}})},q=(z,d)=>{if(t.block.type!=="status")return;const f={...t.block.settings.labels};d.trim()?f[z]=d:delete f[z],i({labels:f})},B=z=>{if(t.block.type!=="badge")return;const d={...t.block.settings};z.trim()?d.label=z:delete d.label,o("update",{...t.block,settings:d})},u=E(()=>t.block.type==="badge"&&t.block.kind!=="discount"&&t.block.kind!=="main-prize-boost"),S=E(()=>t.block.type!=="badge"?"":t.block.kind==="discount"?"Platform colour is each discount's own colour.":Yt[t.block.kind].gradient?"Platform colour is this badge's usual gradient. Picking a colour makes it one solid colour.":"Platform colour is this badge's usual colour."),D=E(()=>t.block.type==="badge"&&(t.block.kind==="cash-alternative"||t.block.kind==="credit-alternative")),T=E(()=>{const z=je[t.layout].includes("image-edge");return[{value:"pill",label:"Pill"},{value:"tag",label:"Tag"},{value:"ribbon",label:"Ribbon"},{value:"stamp",label:"Stamp"},{value:"tab",label:"Tab",disabled:!z,title:z?void 0:"Tabs need the Stacked layout"}]}),_={pill:"A rounded label.",tag:"A label with a squared-off end.",ribbon:"A diagonal ribbon across a top corner of the image. Picking it moves the badge there.",stamp:"A rubber stamp over the image. Picking it moves the badge onto the image.",tab:"A half-pill on the image edge, like today's Auto Draw. Picking it moves the badge there."},ne=[{value:1,label:"1"},{value:2,label:"2"},{value:3,label:"3"}],ie=[{value:"sm",label:"Small"},{value:"md",label:"Medium"},{value:"lg",label:"Large"}],G=[{value:"start",label:"Left"},{value:"center",label:"Centre"},{value:"end",label:"Right"}],W=[{value:"3:4",label:"Portrait (3:4)"},{value:"4:5",label:"Tall (4:5)"},{value:"1:1",label:"Square (1:1)"},{value:"4:3",label:"Landscape (4:3)"},{value:"16:9",label:"Wide (16:9)"}],re=[{value:"compact",label:"3d 4h"},{value:"ticking",label:"With seconds"},{value:"boxed",label:"Boxed digits"},{value:"flip",label:"Flip clock"},{value:"draw-date",label:"Draw date"}],M={compact:'Short and quiet: "3d 4h", "4h 12m".',ticking:"Counts down every second while the card is on screen.",boxed:"Each unit in its own box, ticking every second.",flip:"Flip-clock digits, ticking every second.","draw-date":'When it draws instead of how long is left: "Draws Fri 8pm".'},F=[{value:"sold-of-max",label:"120 / 500 sold"},{value:"percent",label:"24% sold"},{value:"left",label:"380 left"},{value:"none",label:"Nothing"}],se=[{value:"button",label:"Button"},{value:"pill",label:"Pill"},{value:"ribbon",label:"Ribbon"},{value:"stamp",label:"Stamp"}],pe={button:"A greyed-out button where the buttons usually are, as today.",pill:"A small label.",ribbon:"A diagonal ribbon across a top corner of the image. Picking it moves the status there.",stamp:"A rubber stamp over the image. Picking it moves the status onto the image."},me=[{key:"soldOut",label:"Sold out wording",placeholder:"Sold Out"},{key:"ended",label:"Ended wording",placeholder:"Ended"},{key:"limitReached",label:"Limit reached wording",placeholder:"Limit Reached"},{key:"awaitingDraw",label:"Awaiting draw wording",placeholder:"Awaiting draw"}];return(z,d)=>(c(),b("div",il,[e.block.type==="image"?(c(),b(L,{key:0},[a("div",null,[a("label",{for:r("shape"),class:"field-label"},"Shape",8,rl),a("select",{id:r("shape"),class:"input h-9 py-0 text-sm",value:e.block.settings.shape.mode==="site"?"site":e.block.settings.shape.value,onChange:d[0]||(d[0]=f=>U(f.target.value))},[d[49]||(d[49]=a("option",{value:"site"},"Match site (Card Aspect Ratio)",-1)),(c(),b(L,null,X(W,f=>a("option",{key:f.value,value:f.value},P(f.label),9,cl)),64))],40,dl)]),a("div",null,[d[50]||(d[50]=a("p",{class:"field-label"},"Fit",-1)),O(Q,{"model-value":e.block.settings.fit,options:[{value:"cover",label:"Fill the space"},{value:"contain",label:"Show it all"}],label:"Image fit","onUpdate:modelValue":d[1]||(d[1]=f=>i({fit:f}))},null,8,["model-value"])]),a("div",null,[d[51]||(d[51]=a("p",{class:"field-label"},"Edges",-1)),O(Q,{"model-value":e.block.settings.frame,options:[{value:"edge",label:"Edge to edge"},{value:"framed",label:"Framed"}],label:"Image edges","onUpdate:modelValue":d[2]||(d[2]=f=>i({frame:f}))},null,8,["model-value"])]),a("label",ul,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.hoverZoom,onCh
2ange:d[3]||(d[3]=f=>i({hoverZoom:v(f)}))},null,40,ml),d[52]||(d[52]=a("span",null,"Zoom in on hover",-1))]),a("div",null,[a("label",{for:r("fade"),class:"field-label"},"Fade at the bottom ("+P(e.block.settings.fade)+"%)",9,gl),a("input",{id:r("fade"),type:"range",min:"0",max:"100",step:"5",class:"w-full accent-admin-accent",value:e.block.settings.fade,onInput:d[4]||(d[4]=f=>i({fade:m(f)}))},null,40,bl)]),a("div",null,[a("label",{for:r("vignette"),class:"field-label"},"Darkened edges ("+P(e.block.settings.vignette)+"%)",9,pl),a("input",{id:r("vignette"),type:"range",min:"0",max:"100",step:"5",class:"w-full accent-admin-accent",value:e.block.settings.vignette,onInput:d[5]||(d[5]=f=>i({vignette:m(f)}))},null,40,fl)])],64)):e.block.type==="title"?(c(),b(L,{key:1},[a("div",null,[d[53]||(d[53]=a("p",{class:"field-label"},"Lines before it is cut short",-1)),O(Q,{"model-value":e.block.settings.lines,options:ne,label:"Title lines","onUpdate:modelValue":d[6]||(d[6]=f=>i({lines:f}))},null,8,["model-value"])]),a("div",null,[d[54]||(d[54]=a("p",{class:"field-label"},"Size",-1)),O(Q,{"model-value":e.block.settings.size,options:[{value:"sm",label:"Small"},{value:"md",label:"Medium"},{value:"lg",label:"Large"},{value:"xl",label:"Extra large"}],label:"Title size","onUpdate:modelValue":d[7]||(d[7]=f=>i({size:f}))},null,8,["model-value"])]),a("div",null,[d[55]||(d[55]=a("p",{class:"field-label"},"Weight",-1)),O(Q,{"model-value":e.block.settings.weight,options:[{value:"medium",label:"Regular"},{value:"semibold",label:"Semi-bold"},{value:"bold",label:"Bold"},{value:"black",label:"Heavy"}],label:"Title weight","onUpdate:modelValue":d[8]||(d[8]=f=>i({weight:f}))},null,8,["model-value"])]),a("div",null,[d[56]||(d[56]=a("p",{class:"field-label"},"Text alignment",-1)),O(Q,{"model-value":e.block.settings.textAlign,options:G,label:"Title text alignment","onUpdate:modelValue":d[9]||(d[9]=f=>i({textAlign:f}))},null,8,["model-value"])]),a("label",hl,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.caps,onChange:d[10]||(d[10]=f=>i({caps:v(f)}))},null,40,vl),d[57]||(d[57]=a("span",null,"All capitals",-1))]),a("label",yl,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.hoverAccent,onChange:d[11]||(d[11]=f=>i({hoverAccent:v(f)}))},null,40,kl),d[58]||(d[58]=a("span",null,"Accent colour on hover",-1))])],64)):e.block.type==="price"?(c(),b(L,{key:2},[a("div",null,[d[59]||(d[59]=a("p",{class:"field-label"},"Wording",-1)),O(Q,{"model-value":e.block.settings.wording,options:[{value:"pounds",label:"£0.99"},{value:"pence",label:"99p"},{value:"per-entry",label:"£0.99 per entry"}],label:"Price wording","onUpdate:modelValue":d[12]||(d[12]=f=>i({wording:f}))},null,8,["model-value"])]),a("div",null,[d[60]||(d[60]=a("p",{class:"field-label"},"Size",-1)),O(Q,{"model-value":e.block.settings.size,options:ie,label:"Price size","onUpdate:modelValue":d[13]||(d[13]=f=>i({size:f}))},null,8,["model-value"])]),a("label",xl,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.showWasPrice,onChange:d[14]||(d[14]=f=>i({showWasPrice:v(f)}))},null,40,wl),d[61]||(d[61]=a("span",null,"Show the was-price on sale",-1))]),a("label",Sl,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.showSaveChip,onChange:d[15]||(d[15]=f=>i({showSaveChip:v(f)}))},null,40,$l),d[62]||(d[62]=a("span",null,"Show the SAVE chip on sale",-1))]),a("div",null,[a("label",{for:r("free"),class:"field-label"},"Wording for free entry",8,Cl),a("input",{id:r("free"),type:"text",class:"input h-9 py-0 text-sm",maxlength:"12",value:e.block.settings.freeLabel,onInput:d[16]||(d[16]=f=>A(f,"freeLabel")),onChange:d[17]||(d[17]=f=>I(f,"freeLabel","FREE"))},null,40,Ol)])],64)):e.block.type==="countdown"?(c(),b(L,{key:3},[a("div",null,[d[63]||(d[63]=a("p",{class:"field-label"},"Style",-1)),O(Q,{"model-value":e.block.settings.display,options:re,label:"Countdown style","onUpdate:modelValue":d[18]||(d[18]=f=>i({display:f}))},null,8,["model-value"]),a("p",Tl,P(M[e.block.settings.display]),1)]),a("div",null,[a("label",{for:r("urgent"),class:"field-label"},"Turn urgent in the last",8,Al),a("div",El,[a("input",{id:r("urgent"),type:"number",min:"0",max:"168",class:"input h-9 py-0 text-sm w-24",value:e.block.settings.urgentWithinHours,onChange:d[19]||(d[19]=f=>i({urgentWithinHours:w(f,0,168)}))},null,40,Pl),d[64]||(d[64]=a("span",{class:"text-sm text-card-text-muted"},"hours",-1))]),d[65]||(d[65]=a("p",{class:"mt-1 text-xs text-card-text-muted"},"0 never turns urgent.",-1))]),a("label",Bl,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.showEnded,onChange:d[20]||(d[20]=f=>i({showEnded:v(f)}))},null,40,Dl),d[66]||(d[66]=a("span",null,'Show "Ended" once it has ended',-1))])],64)):e.block.type==="progress"?(c(),b(L,{key:4},[a("div",null,[d[67]||(d[67]=a("p",{class:"field-label"},"Style",-1)),O(Q,{"model-value":e.block.settings.display,options:[{value:"bar",label:"Bar"},{value:"segments",label:"Segments"},{value:"ring",label:"Ring"},{value:"text",label:"Words only"}],label:"Progress style","onUpdate:modelValue":d[21]||(d[21]=f=>
2i({display:f}))},null,8,["model-value"]),d[68]||(d[68]=a("p",{class:"mt-1 text-xs text-card-text-muted"},"A ring can also sit in a corner of the image.",-1))]),e.block.settings.display!=="text"?(c(),b("div",Il,[d[69]||(d[69]=a("p",{class:"field-label"},"Thickness",-1)),O(Q,{"model-value":e.block.settings.thickness,options:[{value:"thin",label:"Thin"},{value:"regular",label:"Regular"},{value:"thick",label:"Thick"}],label:"Progress thickness","onUpdate:modelValue":d[22]||(d[22]=f=>i({thickness:f}))},null,8,["model-value"])])):N("",!0),a("div",null,[a("label",{for:r("left"),class:"field-label"},"Left-hand words",8,_l),a("select",{id:r("left"),class:"input h-9 py-0 text-sm",value:e.block.settings.leftText,onChange:d[23]||(d[23]=f=>i({leftText:h(f)}))},[(c(),b(L,null,X(F,f=>a("option",{key:f.value,value:f.value},P(f.label),9,Rl)),64))],40,Ll)]),a("div",null,[a("label",{for:r("right"),class:"field-label"},"Right-hand words",8,Nl),a("select",{id:r("right"),class:"input h-9 py-0 text-sm",value:e.block.settings.rightText,onChange:d[24]||(d[24]=f=>i({rightText:h(f)}))},[(c(),b(L,null,X(F,f=>a("option",{key:f.value,value:f.value},P(f.label),9,Vl)),64))],40,zl)]),a("label",Ml,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.hotEnabled,onChange:d[25]||(d[25]=f=>i({hotEnabled:v(f)}))},null,40,Ul),d[70]||(d[70]=a("span",null,'Turn "hot" when selling fast',-1))]),e.block.settings.hotEnabled?(c(),b("div",Wl,[a("label",{for:r("hot"),class:"field-label"},"Hot above",8,Fl),a("div",Hl,[a("input",{id:r("hot"),type:"number",min:"1",max:"99",class:"input h-9 py-0 text-sm w-24",value:e.block.settings.hotAbovePercent,onChange:d[26]||(d[26]=f=>i({hotAbovePercent:w(f,1,99)}))},null,40,Zl),d[71]||(d[71]=a("span",{class:"text-sm text-card-text-muted"},"% sold",-1))])])):N("",!0)],64)):e.block.type==="buttons"?(c(),b(L,{key:5},[a("div",null,[a("label",{for:r("main"),class:"field-label"},"Main button wording",8,Yl),a("input",{id:r("main"),type:"text",class:"input h-9 py-0 text-sm",maxlength:"24",value:e.block.settings.mainLabel,onInput:d[27]||(d[27]=f=>A(f,"mainLabel")),onChange:d[28]||(d[28]=f=>I(f,"mainLabel","Details"))},null,40,jl)]),a("div",null,[d[72]||(d[72]=a("p",{class:"field-label"},"Main button style",-1)),O(Q,{"model-value":e.block.settings.mainVariant,options:[{value:"secondary",label:"Quiet"},{value:"primary",label:"Bold"}],label:"Main button style","onUpdate:modelValue":d[29]||(d[29]=f=>i({mainVariant:f}))},null,8,["model-value"])]),a("div",null,[d[73]||(d[73]=a("p",{class:"field-label"},"Main button icon",-1)),O(Q,{"model-value":e.block.settings.mainIcon,options:[{value:"none",label:"None"},{value:"arrow",label:"Arrow"},{value:"ticket",label:"Ticket"}],label:"Main button icon","onUpdate:modelValue":d[30]||(d[30]=f=>i({mainIcon:f}))},null,8,["model-value"])]),a("div",Kl,[a("label",ql,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.quickBuy,onChange:d[31]||(d[31]=f=>i({quickBuy:v(f)}))},null,40,Gl),d[74]||(d[74]=a("span",null,"Quick buy button",-1))]),e.block.settings.quickBuy?(c(),ge(Q,{key:0,"model-value":e.block.settings.quickBuyIcon,options:[{value:"cart",label:"Basket"},{value:"ticket",label:"Ticket"},{value:"plus",label:"Plus"}],label:"Quick buy icon","onUpdate:modelValue":d[32]||(d[32]=f=>i({quickBuyIcon:f}))},null,8,["model-value"])):N("",!0),d[75]||(d[75]=a("p",{class:"mt-1 text-xs text-card-text-muted"},"Quick buy never shows on a card that can't be bought (sold out, ended, at the customer's limit, locked, app only or not open yet).",-1))])],64)):e.block.type==="status"?(c(),b(L,{key:6},[a("div",null,[d[76]||(d[76]=a("p",{class:"field-label"},"Style",-1)),O(Q,{"model-value":e.block.settings.style,options:se,label:"Status style","onUpdate:modelValue":d[33]||(d[33]=f=>i({style:f}))},null,8,["model-value"]),a("p",Jl,P(pe[e.block.settings.style]),1)]),a("label",Xl,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.showWinner,onChange:d[34]||(d[34]=f=>i({showWinner:v(f)}))},null,40,Ql),d[77]||(d[77]=a("span",null,'Show the winner on ended cards â "Won by Sarah T. · #1234", or "Awaiting draw" until the draw runs',-1))]),(c(),b(L,null,X(me,f=>a("div",{key:f.key},[a("label",{for:r(f.key),class:"field-label"},P(f.label),9,ei),a("input",{id:r(f.key),type:"text",class:"input h-9 py-0 text-sm",maxlength:"24",placeholder:f.placeholder,value:e.block.settings.labels[f.key]??"",onInput:ve=>q(f.key,y(ve))},null,40,ti)])),64))],64)):e.block.type==="badge"?(c(),b(L,{key:7},[s(u)?(c(),b("div",oi,[a("label",{for:r("label"),class:"field-label"},P(s(D)?"Words before the amount":"Wording"),9,ni),a("input",{id:r("label"),type:"text",class:"input h-9 py-0 text-sm",maxlength:"24",placeholder:s(D)?"e.g. Cash":s(Rt)[e.block.kind],value:e.block.settings.label??"",onInput:d[35]||(d[35]=f=>B(y(f)))},null,40,si),a("p",ai,P(s(D)?"Leave empty to show just the amount.":"Leave empty for the platform wording."),1)])):(c(),b("p",li,P(e.block.kind==="discount"?"The wording comes from each discount.":"The wording comes from the boost's own branding."),1)),a("div",null,[d[78]||(d[78]=a("p",{class:"field-label"},"Shape",-1)),O(Q,{"model-value":e.block.settings.shape,options:s(T),label:"Badge shape","onUpdate:modelValue":d[36]||(d[36]=f=>i({shape:f}))}
2,null,8,["model-value","options"]),a("p",ii,P(_[e.block.settings.shape]),1)]),a("div",null,[O($e,{"model-value":e.block.settings.color??null,label:"Colour","reset-label":"Platform colour","platform-swatch":s(Yt)[e.block.kind].background,"onUpdate:modelValue":d[37]||(d[37]=f=>i({color:f}))},null,8,["model-value","platform-swatch"]),a("p",ri,P(s(S)),1)]),a("label",di,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:e.block.settings.icon,onChange:d[38]||(d[38]=f=>i({icon:v(f)}))},null,40,ci),d[79]||(d[79]=a("span",null,"Show its icon",-1))])],64)):e.block.type==="tickets-left"?(c(),b("div",ui,[d[80]||(d[80]=a("p",{class:"field-label"},"Wording",-1)),O(Q,{"model-value":e.block.settings.wording,options:[{value:"left",label:"120 left"},{value:"remaining",label:"120 remaining"}],label:"Tickets left wording","onUpdate:modelValue":d[39]||(d[39]=f=>i({wording:f}))},null,8,["model-value"])])):e.block.type==="max-per-person"?(c(),b("div",mi,[a("label",{for:r("max"),class:"field-label"},"Wording",8,gi),a("input",{id:r("max"),type:"text",class:"input h-9 py-0 text-sm",maxlength:"24",value:e.block.settings.label,onInput:d[40]||(d[40]=f=>A(f,"label")),onChange:d[41]||(d[41]=f=>I(f,"label","Max {n} per person"))},null,40,bi),d[81]||(d[81]=a("p",{class:"mt-1 text-xs text-card-text-muted"},'{n} becomes the number, e.g. "Max {n} per person".',-1))])):e.block.type==="prize-value"||e.block.type==="opens-in"?(c(),b("div",pi,[a("label",{for:r("prefix"),class:"field-label"},"Words before it",8,fi),a("input",{id:r("prefix"),type:"text",class:"input h-9 py-0 text-sm",maxlength:"12",value:e.block.settings.prefix,onInput:d[42]||(d[42]=f=>A(f,"prefix")),onChange:d[43]||(d[43]=f=>I(f,"prefix",e.block.type==="prize-value"?"Worth":"Opens in"))},null,40,hi),a("p",vi,P(e.block.type==="prize-value"?'e.g. "Worth" â "Worth £1,000".':'e.g. "Opens in" â "Opens in 2d 5h".'),1)])):e.block.type==="draw-date"?(c(),b(L,{key:11},[a("div",null,[d[82]||(d[82]=a("p",{class:"field-label"},"Format",-1)),O(Q,{"model-value":e.block.settings.format,options:[{value:"relative",label:"Fri 8pm"},{value:"date",label:"Fri 3 Oct"},{value:"datetime",label:"Fri 3 Oct, 8pm"}],label:"Draw date format","onUpdate:modelValue":d[44]||(d[44]=f=>i({format:f}))},null,8,["model-value"])]),a("div",null,[a("label",{for:r("prefix"),class:"field-label"},"Words before it",8,yi),a("input",{id:r("prefix"),type:"text",class:"input h-9 py-0 text-sm",maxlength:"12",value:e.block.settings.prefix,onInput:d[45]||(d[45]=f=>A(f,"prefix")),onChange:d[46]||(d[46]=f=>I(f,"prefix","Draws"))},null,40,ki)])],64)):e.block.type==="category-tag"?(c(),b("div",xi,[d[83]||(d[83]=a("p",{class:"field-label"},"Show",-1)),O(Q,{"model-value":e.block.settings.show,options:[{value:"first",label:"The first tag"},{value:"all",label:"Every tag"}],label:"Which tags","onUpdate:modelValue":d[47]||(d[47]=f=>i({show:f}))},null,8,["model-value"])])):e.block.type==="summary"?(c(),b("div",wi,[d[84]||(d[84]=a("p",{class:"field-label"},"Lines before it is cut short",-1)),O(Q,{"model-value":e.block.settings.lines,options:ne,label:"Summary lines","onUpdate:modelValue":d[48]||(d[48]=f=>i({lines:f}))},null,8,["model-value"])])):N("",!0)]))}}),$i=Object.assign(et(Si,[["__scopeId","data-v-3be4c454"]]),{__name:"AdminCardDesignerBlockSettings"}),Ci=["aria-label"],Oi={key:0,"aria-hidden":"true"},Ti=["aria-checked","aria-label","title","disabled","onClick"],Ai={key:0,class:"absolute top-0.5 right-1 text-[0.6rem] leading-none font-semibold opacity-70"},Ei=["aria-checked","aria-label","title","disabled"],Pi=["aria-checked","aria-label","title","disabled","onClick"],Bi={key:0,class:"absolute top-0.5 right-1 text-[0.6rem] leading-none font-semibold opacity-70"},Di=be({__name:"CardDesignerPositionPicker",props:{layout:{},modelValue:{},allowed:{},counts:{},label:{},narrow:{type:Boolean},imageEnd:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:n}){const t=e,o=n,l=E(()=>Mn(t.layout,t.narrow)),r=E(()=>!!t.imageEnd&&l.value.details!=="none"&&(t.layout==="stacked"||l.value.details==="beside")),i={"body-top":"Top","body-middle":"Middle","body-bottom":"Bottom"},v=m=>{const y="relative rounded-[3px] border transition-colors flex items-center justify-center";return t.modelValue===m?`${y} border-transparent bg-[var(--admin-btn-primary-bg)] text-[var(--admin-btn-primary-text)]`:t.allowed.includes(m)?`${y} border-dashed border-card-text/50 bg-card/70 text-card-text-muted hover:border-card-text hover:bg-card cursor-pointer`:`${y}
2 border-transparent bg-card-text/5 opacity-30 cursor-not-allowed text-card-text-muted`};return(m,y)=>(c(),b("div",{role:"radiogroup","aria-label":e.label,class:oe(["flex gap-1 w-full max-w-[13rem] select-none p-1 rounded-lg border border-card-text/20 bg-card",s(l).details==="beside"?s(r)?"flex-row-reverse items-stretch":"flex-row items-stretch":s(r)?"flex-col-reverse":"flex-col"])},[a("div",{class:oe(["grid grid-cols-3 gap-1 p-1 rounded-md bg-linear-to-br from-card-text/30 via-card-text/20 to-card-text/10",s(l).details==="beside"?"w-[56%] min-h-[8.5rem]":s(l).details==="none"?"aspect-[3/4]":"aspect-[4/3]"]),style:{"grid-template-rows":"auto minmax(1.5rem, 1fr) auto auto"}},[(c(!0),b(L,null,X(s(l).imageRows,(h,w)=>(c(),b(L,{key:w},[(c(!0),b(L,null,X(h,(A,I)=>(c(),b(L,{key:`${w}-${I}`},[A.zone?(c(),b("button",{key:1,type:"button",role:"radio","aria-checked":e.modelValue===A.zone,"aria-label":s(he)[A.zone],title:e.allowed.includes(A.zone)?s(he)[A.zone]:`${s(he)[A.zone]} â can't go here`,disabled:!e.allowed.includes(A.zone),class:oe([v(A.zone),A.span?"col-span-3":"","min-h-5"]),onClick:U=>o("update:modelValue",A.zone)},[e.counts?.[A.zone]?(c(),b("span",Ai,P(e.counts[A.zone]),1)):N("",!0)],10,Ti)):(c(),b("span",Oi))],64))),128))],64))),128))],2),s(l).edge?(c(),b("button",{key:0,type:"button",role:"radio","aria-checked":e.modelValue==="image-edge","aria-label":s(he)["image-edge"],title:e.allowed.includes("image-edge")?s(he)["image-edge"]:`${s(he)["image-edge"]} â can't go here`,disabled:!e.allowed.includes("image-edge"),class:oe([v("image-edge"),"self-center w-1/3 h-3.5 z-[1]",s(r)?"-mb-2.5 -mt-1":"-mt-2.5 -mb-1"]),onClick:y[0]||(y[0]=h=>o("update:modelValue","image-edge"))},null,10,Ei)):N("",!0),s(l).details!=="none"?(c(),b("div",{key:1,class:oe(["flex flex-col gap-1",s(l).details==="beside"?"flex-1":""])},[(c(!0),b(L,null,X(s(l).detailRows,h=>(c(),b("button",{key:h,type:"button",role:"radio","aria-checked":e.modelValue===h,"aria-label":s(he)[h],title:e.allowed.includes(h)?s(he)[h]:`${s(he)[h]} â can't go here`,disabled:!e.allowed.includes(h),class:oe([v(h),"h-6 flex-1 text-[0.65rem] font-medium"]),onClick:w=>o("update:modelValue",h)},[K(P(i[h])+" ",1),e.counts?.[h]?(c(),b("span",Bi,P(e.counts[h]),1)):N("",!0)],10,Pi))),128))],2)):N("",!0)],10,Ci))}}),Ii=Object.assign(Di,{__name:"AdminCardDesignerPositionPicker"}),_i=["aria-label"],Li={class:"flex items-center gap-2 shrink-0 cursor-pointer text-xs text-card-text-secondary"},Ri=["aria-checked","aria-label"],Ni={key:0,class:"rounded-lg bg-card-text/5 px-3 py-2 text-xs text-card-text-muted"},zi={key:1,class:"flex items-start gap-1.5 rounded-lg bg-card-text/5 px-3 py-2 text-xs text-card-text-muted"},Vi={key:2,class:"space-y-1"},Mi={class:"admin-card p-4"},Ui={key:3,class:"admin-card p-4 space-y-4"},Wi={class:"flex flex-wrap items-start justify-between gap-2"},Fi={class:"admin-section-title"},Hi={class:"text-xs text-card-text-muted mt-0.5"},Zi={class:"flex flex-wrap items-start gap-4"},Yi={class:"w-[13rem] max-w-full"},ji={class:"mt-1.5 text-xs text-card-text"},Ki={class:"min-w-0 flex-1 space-y-3"},qi={key:0,class:"text-xs text-card-text-muted"},Gi={key:1},Ji={key:0},Xi={class:"rounded-lg border border-[var(--admin-border)] divide-y divide-[var(--admin-border)] overflow-hidden"},Qi=["onClick"],er=be({__name:"CardDesignerPartPanel",props:{visible:{type:Boolean}},setup(e){const n=Ke(),t=E(()=>n.selectedKey.value??""),o=E(()=>t.value?we(n.design.value,t.value):void 0),l=E(()=>o.value&&ae(o.value)?o.value:null),r=E(()=>n.design.value.layout),i=E(()=>o.value?Le(o.value):""),v=E(()=>o.value?Nt(o.value):""),m=E(()=>v.value.charAt(0).toLowerCase()+v.value.slice(1)),y=E(()=>n.warningsFor(t.value)),h=E(()=>n.issuesFor(t.value)),w=E(()=>n.placeFor.value==="phone"&&l.value?.type!=="buttons"),A=E(()=>l.value?w.value?l.value.phoneZone??l.value.zone:l.value.zone:"body-top"),I=E(()=>l.value?lo(l.value,r.value):[]),U=E(()=>l.value?ot(n.design.value,l.value.zone):[]),q=E(()=>{const T={};for(const _ of n.design.value.blocks)!ae(_)||!_.enabled||H(_)===t.value||(T[_.zone]=(T[_.zone]??0)+1);return T}),B=T=>{l.value?.enabled&&A.value===T||n.setZone(t.value,T)},u=E(()=>{const T=n.panel.value;return T.kind==="badges"?"Badges":T.kind==="state"?Xe[T.which].title:"Your card"}),S=[{value:"computer",label:"Computer"},{value:"phone",label:"Phone"}],D=[{value:"start",label:"Left"},{value:"center",label:"Centre"},{value:"end",label:"Right"},{value:"stretch",label:"Full width"}];return(T,_)=>{const ne=Be,ie=no;return s(o)?(c(),b("div",{key:0,class:"space-y-4","aria-label":`${s(i)} settings`},[O(Vt,{title:s(i),hint:s(v),back:s(u),onBack:_[1]||(_[1]=G=>s(n).select(null))},{actions:ce(()=>[a("label",Li,[K(P(s(o).enabled?"On the card":"Hidden")+" ",1),a("button",{type:"button",role:"switch","aria-checked":s(o).enabled,"aria-label":s(o).enabled?`Hide ${s(i)}`:`Show ${s(i)}`,class:"admin-switch cursor-pointer",onClick:_[0]||(_[0]=G=>s(n).setEnabled(s(t),!s(o).enabled))},null,8,Ri)])]),_:1},8,["title","hint","back"]),s(o).enabled?e.visible?N("",!0):(c(),b("p",zi,[O(ne,{name:"heroicons:information-circle",class:"w-4 h-4 shrink-0","aria-hidden":"true"}),a("span",null,"Not on the card right now: it shows "+P(s(m))+". Pick a competition or a state above the card that has it.",1)])):(c(),b("p",Ni," Hidden, and its settings are kept. Turn it on, or pick a spot for it below. ")),s(h).length||s(y).length?(c(),b("ul",Vi,[(c(!0),b(L,null,X(s(h),(G,W)=>(c(),b("li",{key:`i${W}`,class:"text-xs text-red-400"},P(G),1))),128)),(c(!0),b(L,null,X(s(y),(G,W)=>(c(),b("li",{key:`w${W}`,class:"flex items-start gap-1 text-xs text-amber-400"},[O(ne,{name:"heroicons:exclamation-triangle",class:"w-3.5 h-3.5 shrink-0 mt-px","aria-hidden":"true"}),K(P(G),1)]))),128))])):N("",!0),a("section",Mi,[O($i,{block:s(o),layout:s(r),onUpdate:s(n).updateBlock},null,8,["block","layout","onUpdate"])]),s(l)?(c(),b("section",Ui,[a("div",Wi,[a("div",null,[a("h3",Fi,P(s(w)?"Where it sits on phones":"Where it sits"),1),a("p",Hi,[s(l).type==="buttons"?(c(),b(L,{key:0},[K("Buttons sit in the same place on phones and computers.")],64)):s(w)?(c(),b(L,{key:1},[K("Moves it on phones only. Computers keep their spot.")],64)):(c(),b(L,{key:2},[K("Drag it on the card, or pick a spot here.")],64))])]),s(l).type!=="buttons"?(c(),ge(Q,{key:0,"model-value":s(n).placeFor.value,options:S,label:`Choose where ${s(i)} sits on`,"onUpdate:modelValue":_[2]||(_[2]=G=>s(n).placeFor.value=G)},null,8,["model-value","label"])):N("",!0)]),a("div",Zi,[a("div",Yi,[O(Ii,{layout:s(r),narrow:s(w),"image-end":s(it)(s(n).design.value)==="end","model-value":s(l).enabled?s(A):null,allowed:s(I),c
2ounts:s(w)?void 0:s(q),label:s(w)?`Where ${s(i)} sits on phones`:`Where ${s(i)} sits`,"onUpdate:modelValue":B},null,8,["layout","narrow","image-end","model-value","allowed","counts","label"]),a("p",ji,P(s(l).enabled?s(he)[s(A)]:"Hidden"),1)]),a("div",Ki,[s(l).phoneZone?(c(),b("p",qi,[s(w)?(c(),b(L,{key:0},[K("On computers: "+P(s(he)[s(l).zone])+".",1)],64)):(c(),b(L,{key:1},[K("On phones: "+P(s(he)[s(l).phoneZone])+".",1)],64)),a("button",{type:"button",class:"ml-1 font-medium text-admin-accent-text hover:underline",onClick:_[3]||(_[3]=G=>s(n).setPhoneZone(s(t),null))}," Same on both ")])):N("",!0),s(l).enabled&&s(l).zone!=="image-edge"?(c(),b("div",Gi,[_[5]||(_[5]=a("p",{class:"text-xs font-medium text-card-text-muted mb-1.5"},"Line up",-1)),O(Q,{"model-value":s(l).align,options:D,label:`How ${s(i)} lines up`,"onUpdate:modelValue":_[4]||(_[4]=G=>s(n).setAlign(s(t),G))},null,8,["model-value","label"])])):N("",!0)])]),s(l).enabled&&s(U).length>1?(c(),b("div",Ji,[_[6]||(_[6]=a("p",{class:"text-xs font-medium text-card-text-muted mb-1.5"},"In this spot, top to bottom",-1)),a("div",Xi,[(c(!0),b(L,null,X(s(U),(G,W)=>(c(),b("div",{key:s(H)(G),class:oe(["flex items-center gap-1 pl-3 pr-1.5 py-1 text-sm",s(H)(G)===s(t)?"admin-selected":""])},[a("button",{type:"button",class:"min-w-0 flex-1 text-left truncate text-card-text",onClick:re=>s(n).select(s(H)(G))},P(s(Le)(G)),9,Qi),O(ie,{icon:"heroicons:chevron-up",title:"Move up",size:"sm",disabled:W===0,onClick:re=>s(n).move(s(H)(G),-1)},null,8,["disabled","onClick"]),O(ie,{icon:"heroicons:chevron-down",title:"Move down",size:"sm",disabled:W===s(U).length-1,onClick:re=>s(n).move(s(H)(G),1)},null,8,["disabled","onClick"])],2))),128))])])):N("",!0)])):N("",!0)],8,_i)):N("",!0)}}}),tr=Object.assign(er,{__name:"AdminCardDesignerPartPanel"}),Pe=e=>{const n=e.getBoundingClientRect();return{left:n.left,top:n.top,right:n.right,bottom:n.bottom}};function fo(e){const n=Pe(e);return e.querySelectorAll("*").forEach(t=>{const o=t.getBoundingClientRect();o.width<=0||o.height<=0||(n.left=Math.min(n.left,o.left),n.top=Math.min(n.top,o.top),n.right=Math.max(n.right,o.right),n.bottom=Math.max(n.bottom,o.bottom))}),n}const or=(e,n)=>({left:Math.max(e.left,n.left),top:Math.max(e.top,n.top),right:Math.min(e.right,n.right),bottom:Math.min(e.bottom,n.bottom)}),nr=["data-probe-width"],eo='[data-comps="card-title"], .cd-chip-text',sr=be({__name:"CardDesignerOverlapProbe",props:{design:{},competition:{},forceLimitReached:{type:Boolean},neighbour:{}},emits:["measured"],setup(e,{expose:n,emit:t}){const o=e,l=t,r={phone:166,"desktop-4":280,"desktop-3":380},i=j(null),v=_o(null),m=E(()=>v.value??o.design),y=S=>S.getBoundingClientRect().width>0&&(S.scrollHeight>S.clientHeight+1||S.scrollWidth>S.clientWidth+1),h=()=>{const S=i.value;if(!S)return{warnings:[],cutShort:0};const D={};let T=0;
2for(const _ of Je){const ne=S.querySelector(`[data-probe-width="${_}"]`);if(!ne)continue;const ie=[];ne.querySelectorAll("[data-card-zone]").forEach(re=>{re.querySelectorAll(":scope > [data-card-block]").forEach(M=>{const F=M.getBoundingClientRect();F.width<=0||F.height<=0||ie.push({key:M.dataset.cardBlock,zone:re.dataset.cardZone,rect:fo(M),hangsOffEdge:!!M.querySelector(".cd-chip-ribbon")})})});const G=ne.querySelector('[data-comps="card-image"]'),W=ne.querySelector(".cd-surface");D[_]=Ln(ie,G?Pe(G):null,W?Pe(W):null),ne.querySelectorAll(eo).forEach(re=>{y(re)&&T++})}return S.querySelector("[data-probe-neighbour]")?.querySelectorAll(eo).forEach(_=>{y(_)&&T++}),{warnings:Nn(D),cutShort:T}},w=()=>{if(v.value)return;const{warnings:S}=h(),D=JSON.stringify(S);D!==A&&(A=D,l("measured",S))};let A="",I=null;const U=()=>{I&&clearTimeout(I),I=setTimeout(async()=>{I=null,await Ve(),await document.fonts?.ready,requestAnimationFrame(w)},200)};tt(()=>[o.design,o.competition,o.forceLimitReached,o.neighbour],U,{deep:!0});const q=()=>new Promise(S=>requestAnimationFrame(()=>S()));let B=Promise.resolve();return n({check:S=>{const D=B.then(async()=>{v.value=S;try{return await Ve(),await document.fonts?.ready,await q(),await document.fonts?.ready,await q(),h()}finally{v.value=null,U()}});return B=D.catch(()=>{}),D}}),mt(()=>{U(),document.fonts?.addEventListener?.("loadingdone",U)}),Bt(()=>{I&&clearTimeout(I),document.fonts?.removeEventListener?.("loadingdone",U)}),(S,D)=>{const T=_t;return c(),b("div",{ref_key:"host",ref:i,class:"public-theme-scope admin-type-reset fixed top-0 -left-[9999px] invisible pointer-events-none","aria-hidden":"true",inert:""},[(c(!0),b(L,null,X(s(Je),_=>(c(),b("div",{key:_,"data-probe-width":_,class:"grid",style:Ce({width:`${r[_]}px`})},[O(T,{competition:e.competition,design:s(m),preview:"","force-limit-reached":e.forceLimitReached},null,8,["competition","design","force-limit-reached"])],12,nr))),128)),e.neighbour?(c(),b("div",{key:0,"data-probe-neighbour":"",class:"grid",style:Ce({width:`${r.phone}px`})},[O(T,{competition:e.neighbour.competition,design:s(m),preview:"","force-limit-reached":e.neighbour.forceLimitReached},null,8,["competition","design","force-limit-reached"])],4)):N("",!0)],512)}}}),ar=Object.assign(sr,{__name:"AdminCardDesignerOverlapProbe"}),lr={class:"admin-card p-3 space-y-3"},ir={class:"px-1"},rr={class:"admin-section-title flex items-center gap-1.5"},dr={class:"rounded-lg bg-card-text/5 p-2 space-y-2"},cr={class:"flex flex-wrap items-center gap-2"},ur=["value","disabled"],mr={key:0,value:""},gr=["value"],br={class:"flex flex-wrap items-center gap-1",role:"radiogroup","aria-label":"Preview the card as"},pr=["aria-checked","onClick"],fr={key:0,class:"flex flex-col items-center gap-2 max-w-full"},hr={"data-preview-screen":"phone",class:"public-theme-scope admin-type-reset rounded-[1.75rem] border border-[var(--admin-border)] shadow-sm overflow-hidden max-w-full"},vr={key:1,class:"flex flex-col items-center gap-2 max-w-full"},yr={"data-preview-screen":"computer",class:"public-theme-scope admin-type-reset rounded-lg border border-[var(--admin-border)] shadow-sm overflow-hidden max-w-full"},kr={class:"flex gap-1 px-3 pt-2.5","aria-hidden":"true"},xr={class:"flex flex-wrap items-start justify-center gap-3 p-3 pt-2"},wr={key:0,class:"text-xs opacity-60"},Sr={class:"text-xs text-card-text-muted"},$r={key:2,class:"absolute inset-0 pointer-events-none z-10","aria-hidden":"true"},Cr={key:0,class:"absolute -top-2.5 left-1 px-1.5 rounded bg-[var(--admin-btn-primary-bg)] text-[var(--admin-btn-primary-text,#fff)] text-[0.65rem] font-semibold leading-4 whitespace-nowrap"},Or={class:"px-1 text-xs text-card-text-muted"},Tr={key:1,class:"flex items-start gap-2 rounded-lg bg-card-text/5 px-3 py-2 text-xs text-card-text-secondary"},Ar={class:"flex-1"},Er={key:2,class:"px-1"},Pr={class:"space-y-1"},Br=360,Dr=be({__name:"CardDesignerStage",props:{design:{},competitions:{},loading:{type:Boolean},competitionId:{},state:{},view:{},warnings:{},selectedKey:{},hoveredKey:{},stateNote:{}},emits:["update:competitionId","update:state","update:view","measured","select","deselect","hover","visible","place","open-state"],setup(e,{expose:n,emit:t}){const o=e,l=t,r=[{value:"both",label:"Phone and computer"},{value:"phone",label:"Phone"},{value:"computer",label:"Computer"}],i=E(()=>o.view==="computer"?[{px:280,label:"Four across"},{px:380,label:"Three across"}]:[{px:280,label:"Four across"}]),v=mo(),m=E(()=>o.competitions.find(x=>x.id===o.competitionId)??o.competitions[0]??v),y=E(()=>{const x=o.competitions;if(x.length<2)return m.value;
2const k=x.findIndex(g=>g.id===m.value.id);return x[(k+1)%x.length]}),h=x=>{const k=so(x,o.state,Date.now());return{competition:k.competition,forceLimitReached:k.forceLimitReached}},w=E(()=>h(m.value)),A=E(()=>[w.value,y.value===m.value?w.value:h(y.value)]),I=j(null),U=()=>{const x=I.value;if(!x)return[];const k=[...x.querySelectorAll("[data-card-block]")].map(Z=>{const R=Z.closest('[data-comps="card-image"]'),Y=fo(Z);return{key:Z.dataset.cardBlock,...R?or(Y,Pe(R)):Y}}),g=[...x.querySelectorAll('[data-comps="card-image"]')].map(Z=>({key:"image",...Pe(Z)}));return[...k,...g]},q=(x,k)=>{const g=[...I.value?.querySelectorAll("[data-preview-screen]")??[]];return(x&&g.find(R=>{const Y=R.getBoundingClientRect();return x.x>=Y.left&&x.x<=Y.right&&x.y>=Y.top&&x.y<=Y.bottom})||(k instanceof Element?k.closest("[data-preview-screen]"):null))?.dataset.previewScreen==="phone"?"phone":"computer"},B=x=>{const k=x.detail>0?dt(x.clientX,x.clientY,U()):null;if(k)return k;const g=x.target instanceof Element?x.target:null,Z=g?.closest("[data-card-block]");return Z?Z.dataset.cardBlock:g?.closest('[data-comps="card-image"]')?"image":null};let u=!1;const S=x=>{if(u){u=!1,x.preventDefault(),x.stopPropagation();return}const k=B(x);if(!k){(x.target instanceof Element?x.target:null)?.closest('[data-comps="competition-card"]')||l("deselect");return}x.preventDefault(),x.stopPropagation(),l("select",k,q(x.detail>0?{x:x.clientX,y:x.clientY}:null,x.target))},D=j(null);let T=null;const _=x=>{const k=I.value?.getBoundingClientRect();return k?{left:`${x.left-k.left}px`,top:`${x.top-k.top}px`,width:`${x.right-x.left}px`,height:`${x.bottom-x.top}px`}:{}},ne=x=>{if(u=!1,x.button!==0)return;const k=dt(x.clientX,x.clientY,U());if(!k||k==="image")return;const g=we(o.design,k);if(!g||!ae(g))return;const R=[...I.value?.querySelectorAll(`[data-card-block="${k}"]`)??[]].find(Y=>{const $=Y.getBoundingClientRect();return $.width>0&&x.clientX>=$.left-8&&x.clientX<=$.right+8&&x.clientY>=$.top-8&&x.clientY<=$.bottom+8})?.closest('[data-comps="competition-card"]');R&&(T={key:k,x:x.clientX,y:x.clientY,pointerId:x.pointerId,card:R,screen:q({x:x.clientX,y:x.clientY},R)})},ie=(x,k)=>{const g=we(o.design,k);if(!g||!ae(g))return[];const Z=x.querySelector('[data-comps="card-image"]'),R=x.querySelector(".cd-body"),Y={};x.querySelectorAll("[data-card-zone]").forEach(de=>{const Te=de.getBoundingClientRect();Te.width>0&&Te.height>0&&(Y[de.dataset.cardZone]=Pe(de))});const $=lo(g,o.design.layout);return Hn({layout:o.design.layout,image:Z?Pe(Z):null,body:R?Pe(R):null,present:Y}).map(de=>({...de,allowed:$.includes(de.zone)}))},G=()=>{if(!T)return;const{key:x,card:k,pointerId:g,screen:Z}=T;I.value?.setPointerCapture(g),D.value={key:x,label:Le(x),screen:Z,x:T.x,y:T.y,card:k,targets:ie(k,x),over:null,after:null,before:null,line:null},l("hover",null),l("select",x,Z)},W=(x,k)=>{const g=D.value;if(!g)return;g.x=x,g.y=k;const Z=Zn(x,k,g.targets.filter(le=>le.allowed));if(g.over=Z,g.line=null,g.after=null,g.before=null,!Z||g.screen==="phone")return;const Y=[...g.card.querySelector(`[data-card-zone="${Z.zone}"]`)?.children??[]].filter(le=>le instanceof HTMLElement&&le.dataset.cardBlock!==void 0&&le.dataset.cardBlock!==g.key).map(le=>({key:le.dataset.cardBlock,rect:Pe(le)})).filter(({rect:le})=>le.right>le.left&&le.bottom>le.top),$=Y.map(le=>le.rect),de=Yn(Z.zone,x,k,$);if(g.after=Y[de-1]?.key??null,g.before=Y[de]?.key??null,$.length===0)return;if(Z.zone==="image-edge"){const le=de===0?$[0].left-4:de===$.length?$[$.length-1].right+4:($[de-1].right+$[de].left)/2;g.line={left:le-1.5,right:le+1.5,top:Z.top,bottom:Z.bottom};return}const Te=de===0?$[0].top-4:de===$.length?$[$.length-1].bottom+4:($[de-1].bottom+$[de].top)/2,nt=Math.min(...$.map(le=>le.left)),Ue=Math.max(...$.map(le=>le.right));g.line={left:nt,right:Ue,top:Te-1.5,bottom:Te+1.5}},re=()=>{const x=D.value;D.value=null,T=null,x&&(u=!0,x.over&&l("place",x.key,x.over.zone,x.after,x.before,x.screen))},M=()=>{const x=T?.pointerId;D.value=null,T=null,x!==void 0&&I.value?.hasPointerCapture(x)&&I.value.releasePointerCapture(x)},F=j(null);n({checkDesign:async x=>F.value?F.value.check(x):{warnings:[],cutShort:0}});const pe=x=>{x.key==="Escape"&&D.value&&M()},me=()=>M();mt(()=>{window.addEventListener("keydown",pe),window.addEventListener("blur",me)});let z=0,d={x:0,y:0};const f=x=>{if(d={x:x.clientX,y:x.clientY},T&&(x.pointerId!==T.pointerId||!(x.buttons&1))&&!D.value&&(T=null),T&&!D.value&&Math.hypot(x.clientX-T.x,x.clientY-T.y)>6&&G(),D.value){W(x.clientX,x.clientY);return}z||(z=requestAnimationFrame(()=>{z=0;const k=dt(d.x,d.y,U());k!==(o.hoveredKey??null)&&l("hover",k)}))},ve=()=>{D.value&&re(),T=null},ke=()=>{D.value||(T=null,z&&cancelAnimationFrame(z),z=0,l("hover",null))};let fe="";const Se=()=>{const x=I.value;if(!x)return;x.querySelectorAll("[data-editor-mark]").forEach(Y=>Y.removeAttribute("data-editor-mark"));const k=(Y,$)=>{if(!Y)return;const de=Y==="image"?'[data-comps="card-image"]':`[data-card-block="${Y}"]`;x.querySelectorAll(de).forEach(Te=>Te.setAttribute("data-editor-mark",$))};o.hoveredKey!==o.selectedKey&&k(o.hoveredKey,"hover"),k(o.selectedKey,"selected");const g=new Set;x.querySelectorAll("[data-card-block]").forEach(Y=>{const $=Y.getBoundingClientRect();$.width>0&&$.height>0&&g.add(Y.dataset.cardBlock)}),x.querySelector('[data-comps="card-image"]')&&g.add("image");const Z=[...g].sort(),R=Z.join("|");R!==fe&&(fe=R,l("visible",Z))},xe=()=>Ve(()=>requestAnimationFrame(Se));return tt(()=>[o.selectedKey,o.hoveredKey,o.design,o.view,w.value],xe),mt(xe),Bt(()=>{z&&cancelAnimationFrame(z),window.removeEventListener("keydown",pe),window.removeEventListener("blur",me)}),(x,k)=>{const g=Be,Z=_t;return c(),b("div",lr,[a("div",ir,[a("h2",rr,[O(g,{name:"heroicons:eye",class:"w-4 h-4 text-card-text-muted","aria-hidden":"true"}),k[5]||(k[5]=K(" Preview ",-1))]),k[6]||(k[6]=a("p",{class:"text-xs text-card-text-muted mt-0.5"}," The buttons here only change what you're looking at. Nothing on your card changes until you edit it. ",-1))]),a("div",dr,[a("div",cr,[O(Q,{"model-value":e.view,options:r,label:"Screens to preview","onUpdate:modelValue":k[0]||(k[0]=R=>l("update:view",R))},null,8,["model-value"]),a("select",{class:"input h-8 py-0 text-xs flex-1 min-w-[10rem]","aria-label":"Competition to preview",value:e.competitionId,disabled:e.competitions.length===0,onChange:k[1]||(k[1]=R=>l("update:competitionId",R.target.value))},[e.competitions.length===0?(c(),b("option",mr,P(e.loading?"Loading competitionsâ¦":"A sample competition"),1)):N("",!0),(c(!0),b(L,null,X(e.competitions,R=>(c(),b("option",{key:R.id,value:R.id},P(R.displayTitle||R.title),9,gr))),128))],40,ur)]),a("div",br,[k[7]||(k[7]=a("span",{class:"px-1 text-xs text-card-text-muted"},"Preview as",-1)),(c(!0),b(L,null,X(s(Xo),R=>(c(),b("button",{key:R,type:"button",role:"radio","aria-checked":e.state===R,class:oe(["px-2 py-0.5 rounded-md text-xs transition-colors",e.state===R?"bg-card text-card-text font-medium shadow-sm ring-1 ring-[var(--admin-border)]":"text-card-text-secondary hover:text-card-text hover:bg-card-button-subtle"]),onClick:Y=>l("update:state",R)},P(s(An)[R]),11,pr))),128))])]),a("div",{ref_key:"cardsEl",ref:I,class:oe(["cd-editor-cards relative select-none flex flex-wrap items-start justify-center gap-x-4 gap-y-4 py-1 overflow-x-auto",s(D)?"cursor-grabbing":e.hoveredKey&&e.hoveredKey!=="image"?"cursor-grab":e.hoveredKey?"cursor-pointer":""]),onClickCapture:S,onPointerdown:ne,onPointermove:f,onPointerup:ve,onPointercancel:M,onLostpointercapture:M,onPointerleave:ke,onDragstart:k[2]||(k[2]=ut(()=>{},["prevent"]))},[e.view!=="computer"?(c(),b("figure",fr,[a("div",hr,[k[8]||(k[8]=a("div",{class:"flex justify-center pt-2","aria-hidden":"true"},[a("span",{class:"h-1 w-12 rounded-full bg-current opacity-20"})],-1)),a("div",{class:"grid grid-cols-2 gap-3 px-2 pt-2 pb-4",style:Ce({width:`${Br}px`,maxWidth:"100%"})},[(c(!0),b(L,null,X(s(A),(R,Y)=>(c(),b("div",{key:`${Y}-${R.competition.id}`,class:"grid"},[O(Z,{competition:R.competition,design:e.design,preview:"","force-limit-reached":R.forceLimitReached},null,8,["competition","design","force-limit-reached"])]))),128))],4)]),k[9]||(k[9]=a("figcaption",{class:"text-xs text-card-text-muted"},"Phone, two across",-1))])):N("",!0),e.view!=="phone"?(c(),b("figure",vr,[a("div",yr,[a("div",kr,[(c(),b(L,null,X(3,R=>a("span",{key:R,class:"w-1.5 h-1.5 rounded-full bg-current opacity-20"})),64))]),a("div",xr,[(c(!0),b(L,null,X(s(i),R=>(c(),b("div",{key:R.px,class:"flex flex-col items-center gap-2 max-w-full"},[a("div",{class:"grid max-w-full",style:Ce({width:`${R.px}px`})},[O(Z,{competition:s(w).competition,design:e.design,preview:"","force-limit-reached":s(w).forceLimitReached},null,8,["competition","design","force-limit-reached"])],4),e.view==="computer"?(c(),b("span",wr,P(R.label),1)):N("",!0)]))),128))])]),a("figcaption",Sr,P(e.view==="computer"?"Computer":"Computer, four across"),1)])):N("",!0),s(D)?(c(),b("div",$r,[(c(!0),b(L,null,X(s(D).targets,R=>(c(),b("div",{key:R.zone,class:oe(["absolute rounded-md border transition-colors",R.allowed?s(D).over?.zone===R.zone?"border-2 border-[var(--admin-btn-primary-bg)] bg-[var(--admin-btn-primary-bg)]/20":"border-dashed border-white/70 bg-black/10":"border-transparent"]),style:Ce(_(R))},[s(D).over?.zone===R.zone?(c(),b("span",Cr,P(s(rt)[R.zone]),1)):N("",!0)],6))),128)),s(D).line?(c(),b("div",{key:0,class:"absolute rounded-full bg-[var(--admin-btn-primary-bg)]",style:Ce(_(s(D).line))},null,4)):N("",!0)])):N("",!0)],34),s(D)?(c(),b("div",{key:0,class:"fixed z-[80] pointer-events-none px-2 py-1 rounded-md bg-[var(--admin-btn-primary-bg)] text-[var(--admin-btn-primary-text,#fff)] text-xs font-semibold shadow-lg",style:Ce({left:`${s(D).x+12}px`,top:`${s(D).y+12}px`}),"aria-hidden":"true"},P(s(D).label),5)):N("",!0),a("p",Or,[k[10]||(k[10]=K(" Click a part to change it, or drag it somewhere else. ",-1)),e.view!=="computer"?(c(),b(L,{key:0},[K("Moving a part on the phone moves it on phones only.")],64)):N("",!0),k[11]||(k[11]=K(" Click beside the card to go back. ",-1))]),e.stateNote?(c(),b("div",Tr,[O(g,{name:"heroicons:sparkles",class:"w-4 h-4 shrink-0 text-card-text-muted","aria-hidden":"true"}),a("span",Ar,P(e.stateNote.text),1),a("button",{type:"button",class:"shrink-0 font-medium text-admin-accent-text hover:underline",onClick:k[3]||(k[3]=R=>l("open-state",e.stateNote.which))},"Change")])):N("",!0),O(ar,{ref_key:"probe",ref:F,design:e.design,competition:s(w).competition,"force-limit-reached":s(w).forceLimitReached,neighbour:s(y)===s(m)?
2null:s(A)[1],onMeasured:k[4]||(k[4]=R=>l("measured",R))},null,8,["design","competition","force-limit-reached","neighbour"]),e.warnings.length?(c(),b("div",Er,[k[12]||(k[12]=a("h3",{class:"text-xs font-semibold text-card-text mb-1"},"Worth checking",-1)),a("ul",Pr,[(c(!0),b(L,null,X(e.warnings,(R,Y)=>(c(),b("li",{key:Y,class:"flex items-start gap-1.5 text-xs text-amber-400"},[O(g,{name:"heroicons:exclamation-triangle",class:"w-3.5 h-3.5 shrink-0 mt-px"}),a("span",null,P(R.message),1)]))),128))]),k[13]||(k[13]=a("p",{class:"mt-1 text-xs text-card-text-muted"},"These never stop you saving â nothing on a card is required.",-1))])):N("",!0)])}}}),Ir=Object.assign(et(Dr,[["__scopeId","data-v-ea84a19c"]]),{__name:"AdminCardDesignerStage"}),_r={class:"space-y-4"},Lr={class:"grid gap-3 grid-cols-2 sm:grid-cols-3 lg:grid-cols-6"},Rr=["onClick"],Nr={class:"public-theme-scope admin-type-reset relative h-[19rem] overflow-hidden rounded-lg pointer-events-none","aria-hidden":"true",inert:""},zr={class:"absolute top-3 left-1/2 -translate-x-1/2 w-[260px] grid origin-top scale-[0.6]"},Vr={class:"px-0.5 min-w-0"},Mr={class:"text-sm font-medium text-card-text"},Ur={class:"text-xs text-card-text-muted"},Wr=be({__name:"CardDesignerStartingPoints",props:{competition:{},legacy:{},site:{}},emits:["apply"],setup(e,{emit:n}){const t=e,o=n,l=E(()=>jn.map(i=>({kind:i,design:{...Pt(i,t.legacy,t.site),id:`sp-${i}`}}))),r=E(()=>so(t.competition,"live",Date.now()).competition);return(i,v)=>{const m=_t,y=ft;return c(),b("div",_r,[v[0]||(v[0]=a("p",{class:"text-sm text-card-text-muted max-w-xl"}," Pick one to start from and make it your own. It replaces the card you're editing as unsaved changes, so nothing changes on your site until you save. ",-1)),a("div",Lr,[(c(!0),b(L,null,X(s(l),h=>(c(),b("div",{key:h.kind,class:"admin-card p-2.5 flex flex-col gap-2.5 cursor-pointer hover:bg-card-button-subtle/40 transition-colors",onClick:w=>o("apply",h.kind)},[a("div",Nr,[a("div",zr,[O(m,{competition:s(r),design:h.design,preview:""},null,8,["competition","design"])])]),a("div",Vr,[a("p",Mr,P(s(ct)[h.kind].label),1),a("p",Ur,P(s(ct)[h.kind].description),1)]),O(y,{size:"xs",variant:"secondary",class:"mt-auto self-start",onClick:ut(w=>o("apply",h.kind),["stop"])},{default:ce(()=>[K(" Use "+P(s(ct)[h.kind].label),1)]),_:2},1032,["onClick"])],8,Rr))),128))])])}}}),Fr=Object.assign(Wr,{__name:"AdminCardDesignerStartingPoints"}),Hr={class:"space-y-4"},Zr={class:"flex items-center gap-2 shrink-0 cursor-pointer text-xs text-card-text-secondary"},Yr=["aria-checked","aria-label"],jr={class:"admin-card p-4 space-y-3"},Kr={key:0,class:"text-xs text-card-text-muted"},qr=["for"],Gr={class:"flex items-center gap-2"},Jr=["id","value"],Xr={class:"check-row"},Qr=["checked"],ed={class:"check-row"},td=["checked"],od={class:"check-row"},nd=["checked"],sd=["for"],ad={class:"flex items-center gap-2"},ld=["id","value"],id={class:"check-row"},rd=["checked"],dd={class:"check-row"},cd=["checked"],ud={class:"check-row"},md=["checked"],gd={class:"check-row"},bd=["checked"],pd={class:"check-row"},fd=["checked"],hd={class:"check-row"},vd=["checked"],yd={key:0,class:"grid gap-3 sm:grid-cols-2 items-start pl-6"},kd={class:"space-y-3"},xd=["for"],wd=["id","value"],Sd={key:0,class:"space-y-1.5"},$d={class:"admin-card overflow-hidden divide-y divide-[var(--admin-border)]"},Cd=be({__name:"CardDesignerStatePanel",props:{which:{}},setup(e){const n=e,t=Ke(),o=Qe(),l=E(()=>t.design.value.reactions),r=E(()=>l.value[n.which]),i=E(()=>Xe[n.which]),v=E(()=>n.which==="soldOut"||n.which==="ended"?l.value[n.which]:null),m=B=>{const u=t.design.value,S={...u.reactions,[n.which]:{...u.reactions[n.which],...B}};t.setDesign({...u,reactions:S})},y=B=>{v.value&&m({stamp:{...v.value.stamp,...B}})},h=B=>{const u=B.target.value;u.trim()&&y({text:u})},w=B=>{const u=B.target;u.value.trim()||(u.value=i.value.stampText??"",y({text:u.value}))},A=E(()=>i.value.related.map(({key:B,note:u})=>({block:we(t.design.value,B),note:u})).filter(B=>!!B.block));tt(()=>n.which,B=>{t.previewState.value=Xe[B].state},{immediate:!0});const I=B=>B.target.checked,U=(B,u,S)=>{const D=B.target,T=Math.round(Number(D.value)),_=Number.isFinite(T)?Math.min(S,Math.max(u,T)):u;return D.value=String(_),_},q=[{value:-30,label:"-30°"},{value:-15,label:"-15°"},{value:0,label:"Level"},{value:15,label:"15°"},{value:30,label:"30°"}];return(B,u)=>(c(),b("div",Hr,[O(Vt,{title:s(i).title,hint:s(i).hint,back:"Your card",onBack:u[1]||(u[1]=S=>
2s(t).openPanel({kind:"home"}))},{actions:ce(()=>[a("label",Zr,[K(P(s(r).enabled?"On":"Off")+" ",1),a("button",{type:"button",role:"switch","aria-checked":s(r).enabled,"aria-label":`${s(i).title}: change how the card looks`,class:"admin-switch cursor-pointer",onClick:u[0]||(u[0]=S=>m({enabled:!s(r).enabled}))},null,8,Yr)])]),_:1},8,["title","hint"]),a("section",jr,[s(r).enabled?e.which==="endingSoon"?(c(),b(L,{key:1},[a("div",null,[a("label",{for:`${s(o)}-hours`,class:"field-label"},"Starts in the last",8,qr),a("div",Gr,[a("input",{id:`${s(o)}-hours`,type:"number",min:"1",max:"168",class:"input h-9 py-0 text-sm w-24",value:s(l).endingSoon.withinHours,onChange:u[2]||(u[2]=S=>m({withinHours:U(S,1,168)}))},null,40,Jr),u[17]||(u[17]=a("span",{class:"text-sm text-card-text-muted"},"hours",-1))])]),a("label",Xr,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(l).endingSoon.glowBorder,onChange:u[3]||(u[3]=S=>m({glowBorder:I(S)}))},null,40,Qr),u[18]||(u[18]=a("span",null,"Glowing border",-1))]),a("label",ed,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(l).endingSoon.pulseCountdown,onChange:u[4]||(u[4]=S=>m({pulseCountdown:I(S)}))},null,40,td),u[19]||(u[19]=a("span",null,"Pulse the countdown",-1))]),a("label",od,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(l).endingSoon.urgentColour,onChange:u[5]||(u[5]=S=>m({urgentColour:I(S)}))},null,40,nd),u[20]||(u[20]=a("span",null,"Countdown turns red",-1))])],64)):e.which==="almostSoldOut"?(c(),b(L,{key:2},[a("div",null,[a("label",{for:`${s(o)}-pct`,class:"field-label"},"From",8,sd),a("div",ad,[a("input",{id:`${s(o)}-pct`,type:"number",min:"50",max:"99",class:"input h-9 py-0 text-sm w-24",value:s(l).almostSoldOut.atPercent,onChange:u[6]||(u[6]=S=>m({atPercent:U(S,50,99)}))},null,40,ld),u[21]||(u[21]=a("span",{class:"text-sm text-card-text-muted"},"% sold",-1))])]),a("label",id,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(l).almostSoldOut.glowBorder,onChange:u[7]||(u[7]=S=>m({glowBorder:I(S)}))},null,40,rd),u[22]||(u[22]=a("span",null,"Glowing border",-1))]),a("label",dd,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(l).almostSoldOut.pulseProgress,onChange:u[8]||(u[8]=S=>m({pulseProgress:I(S)}))},null,40,cd),u[23]||(u[23]=a("span",null,"Pulse the tickets sold bar",-1))]),a("label",ud,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(l).almostSoldOut.hotProgress,onChange:u[9]||(u[9]=S=>m({hotProgress:I(S)}))},null,40,md),u[24]||(u[24]=a("span",null,'Show the bar as "hot"',-1))])],64)):s(v)?(c(),b(L,{key:3},[a("label",gd,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(v).greyscale,onChange:u[10]||(u[10]=S=>m({greyscale:I(S)}))},null,40,bd),u[25]||(u[25]=a("span",null,"Black and white",-1))]),a("label",pd,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(v).dim,onChange:u[11]||(u[11]=S=>m({dim:I(S)}))},null,40,fd),u[26]||(u[26]=a("span",null,"Fade the card",-1))]),a("label",hd,[a("input",{type:"checkbox",class:"designer-check accent-admin-accent",checked:s(v).stamp.enabled,onChange:u[12]||(u[12]=S=>y({enabled:I(S)}))},null,40,vd),u[27]||(u[27]=a("span",null,"Stamp across the image",-1))]),s(v).stamp.enabled?(c(),b("div",yd,[a("div",kd,[a("div",null,[a("label",{for:`${s(o)}-stamp`,class:"field-label"},"Stamp wording",8,xd),a("input",{id:`${s(o)}-stamp`,type:"text",maxlength:"16",class:"input h-9 py-0 text-sm",value:s(v).stamp.text,onInput:u[13]||(u[13]=S=>h(S)),onChange:u[14]||(u[14]=S=>w(S))},null,40,wd)]),a("div",null,[u[28]||(u[28]=a("p",{class:"field-label"},"Angle",-1)),O(Q,{"model-value":s(v).stamp.rotate,options:q,label:`${s(i).title} stamp angle`,"onUpdate:modelValue":u[15]||(u[15]=S=>y({rotate:S}))},null,8,["model-value","label"])])]),O($e,{"model-value":s(v).stamp.color,label:"Stamp colour","onUpdate:modelValue":u[16]||(u[16]=S=>S&&y({color:S}))},null,8,["model-value"])])):N("",!0)],64)):N("",!0):(c(),b("p",Kr," Off: the card looks the same as any other. Turn it on to change it in this state. "))]),s(A).length?(c(),b("section",Sd,[u[29]||(u[29]=a("h3",{class:"admin-eyebrow"},"Also in this state",-1)),a("div",$d,[(c(!0),b(L,null,X(s(A),S=>(c(),ge(Mt,{key:s(H)(S.block),block:S.block,where:S.note},null,8,["block","where"]))),128))])])):N("",!0)]))}}),Od=Object.assign(et(Cd,[["__scopeId","data-v-a3ce50c9"]]),{__name:"AdminCardDesignerStatePanel"}),Td={class:"surprise__face"},Ad={class:"surprise__label"},Ed=["id"],Pd=["aria-checked","onClick"],Bd=["aria-disabled"],Dd={class:"sr-only",role:"status"},Id=600,_d=2400,Ld=be({__name:"CardDesignerSurpriseButton",props:{pins:{},canUndo:{type:Boolean},disabled:{type:Boolean},busy:{type:Boolean}},emits:["shuffle","undo","update:pins"],setup(e,{emit:n}
2){const t=e,o=n,l=Qe(),r=j(null),i=j(null),v=j(null),m=j(!1),y=j(!1),h=j(!1),w=j("");let A,I;const U=E(()=>y.value?"thinking":h.value?"wave":"idle"),q=()=>{y.value||t.disabled||(ie(!1),clearTimeout(I),h.value=!1,y.value=!0,w.value="Compy is shuffling your card",A=setTimeout(()=>{B=!0,o("shuffle"),Ve(()=>{t.busy||u()})},Id))};let B=!1;const u=()=>{B&&(B=!1,y.value=!1,h.value=!0,w.value="New design in the preview. Save to keep it, or undo the shuffle.",I=setTimeout(()=>{h.value=!1},_d))};tt(()=>t.busy,M=>{M||u()});const S=M=>{const F=new Set(t.pins);F.has(M)?F.delete(M):F.add(M),o("update:pins",F)},D=()=>{t.canUndo&&(ie(!0),o("undo"),w.value="Shuffle undone")},T=()=>Array.from(v.value?.querySelectorAll?.('[role^="menuitem"]')??[]),_=M=>{const F=T();F.length&&F[(M+F.length)%F.length]?.focus()},ne=async M=>{m.value=!0,await Ve();const F=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;v.value?.scrollIntoView?.({block:"nearest",behavior:F?"auto":"smooth"}),M!==null&&_(M)},ie=M=>{m.value&&(m.value=!1,M&&i.value?.$el?.focus?.())},G=M=>{m.value?ie(!1):ne(M.detail===0?0:null)},W=M=>{const F=T().indexOf(document.activeElement);switch(M.key){case"ArrowDown":M.preventDefault(),_(F+1);break;case"ArrowUp":M.preventDefault(),_(F<0?-1:F-1);break;case"Home":M.preventDefault(),_(0);break;case"End":M.preventDefault(),_(-1);break}},re=M=>{const F=M.relatedTarget;F&&!r.value?.contains(F)&&ie(!1)};return an(r,()=>ie(!1)),Bt(()=>{clearTimeout(A),clearTimeout(I)}),(M,F)=>{const se=sn,pe=ft,me=Be;return c(),b("div",{ref_key:"rootRef",ref:r,class:"relative inline-flex w-fit",onKeydown:F[0]||(F[0]=Lo(z=>ie(!0),["esc"])),onFocusout:re},[O(pe,{type:"button",size:"sm",variant:"secondary",class:oe(["surprise__main",{surprise__busy:s(y)}]),disabled:e.disabled,"aria-busy":s(y),title:"A random design that still reads well. Nothing is saved until you save.",onClick:q},{default:ce(()=>[a("span",Td,[O(se,{state:s(U),tone:"solid",size:26},null,8,["state"])]),a("span",Ad,[a("span",{class:oe({invisible:s(y)})},"Surprise me",2),a("span",{class:oe({invisible:!s(y)})},"Shufflingâ¦",2)])]),_:1},8,["class","disabled","aria-busy"]),O(pe,{ref_key:"caretRef",ref:i,type:"button",size:"sm",variant:"secondary",class:"surprise__caret",disabled:e.disabled,"aria-haspopup":"menu","aria-expanded":s(m),"aria-controls":s(l),"aria-label":"Surprise me options",onClick:G},{default:ce(()=>[O(me,{name:"heroicons:chevron-down",class:"w-3.5 h-3.5"})]),_:1},8,["disabled","aria-expanded","aria-controls"]),s(m)?(c(),b("div",{key:0,id:s(l),ref_key:"menuRef",ref:v,role:"menu","aria-label":"Surprise me options",class:"absolute left-0 sm:left-auto sm:right-0 top-full z-30 mt-1 w-60 rounded-xl border border-[var(--admin-border)] bg-card p-1.5 shadow-xl",onKeydown:W},[F[2]||(F[2]=a("p",{class:"px-3 pt-1.5 pb-1 text-xs text-card-text-muted"},"Keep these when shuffling",-1)),(c(!0),b(L,null,X(s(Qo),z=>(c(),b("button",{key:z,type:"button",role:"menuitemcheckbox","aria-checked":e.pins.has(z),class:"flex w-full items-center gap-2.5 rounded-lg px-3 py-1.5 text-left text-sm text-card-text hover:bg-card-button-subtle focus:outline-hidden focus-visible:bg-card-button-subtle",onClick:d=>S(z)},[a("span",{class:oe(["flex h-4 w-4 shrink-0 items-center justify-center rounded border",e.pins.has(z)?"border-transparent bg-[var(--admin-btn-primary-bg)] text-[var(--admin-btn-primary-text,#fff)]":"border-[var(--admin-border)]"]),"aria-hidden":"true"},[e.pins.has(z)?(c(),ge(me,{key:0,name:"heroicons:check",class:"w-3 h-3"})):N("",!0)],2),K(" "+P(s(En)[z]),1)],8,Pd))),128)),F[3]||(F[3]=a("div",{class:"my-1 border-t border-[var(--admin-border)]",role:"separator"},null,-1)),a("button",{type:"button",role:"menuitem","aria-disabled":!e.canUndo,class:oe(["flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm hover:bg-card-button-subtle focus:outline-hidden focus-visible:bg-card-button-subtle",e.canUndo?"text-card-text":"text-card-text-muted cursor-not-allowed"]),onClick:D},[O(me,{name:"heroicons:arrow-uturn-left",class:"w-4 h-4 shrink-0"}),F[1]||(F[1]=K(" Undo shuffle ",-1))],10,Bd)],40,Ed)):N("",!0),a("span",Dd,P(s(w)),1)],544)}}}),Rd=Object.assign(et(Ld,[["__scopeId","data-v-aea0daca"]]),{__name:"AdminCardDesignerSurpriseButton"}),Nd=()=>{const e=Ro();return{getCardDesigns:async()=>await $fetch("/admin/settings/card-designs",{method:"GET",baseURL:e.public.apiBase,credentials:"include"}),updateCardDesigns:async(o,l)=>await $fetch("/admin/settings/card-designs",{method:"PUT",baseURL:e.public.apiBase,credentials:"include",body:{cardDesigns:o,...l!==void 0?{expectedUpdatedAt:l}:{}}})}},zd={key:0,class:"space-y-6"},Vd={key:0,class:"flex items-start gap-2 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm text-amber-300"},Md={key:1,id:"card-designer-issues",class:"bg-red-500/10 border border-red-500/30 rounded-xl p-4"},Ud={class:"space-y-1"},Wd={key:2,class:"bg-red-500/10 border border-red-500/30 rounded-xl p-4"},Fd={class:"space-y-1"},Hd={class:"font-medium"},Zd={class:"grid grid-cols-1 gap-6 xl:grid-cols-[24rem_minmax(0,1fr)] 2xl:gr
2id-cols-[26rem_minmax(0,1fr)] items-start"},Yd={class:"order-first min-w-0 xl:order-last xl:sticky xl:top-4 xl:max-h-[calc(100dvh-9rem)] xl:overflow-y-auto admin-scroll"},jd={class:"flex flex-wrap items-center justify-between gap-3"},Kd={class:"flex items-center gap-2 text-sm min-w-0"},qd={key:2,class:"text-card-text-muted"},Gd={class:"flex items-center gap-3"},Jd={class:"flex flex-col sm:flex-row gap-3 pt-2"},Xd=8,Qd=3,Ac=be({__name:"cards",setup(e){No({title:"Competition Cards",minimal:!0});const{getCardDesigns:n,updateCardDesigns:t}=Nd(),o=Vo(),{confirm:l}=ln(),r=to(),i={stacked:"stacked","side-by-side":"side by side",overlay:"overlay"},v=j(!0),m=j(!1),y=j(!1),h=j([]),w=j(null),A=j(""),I=j(null),U=j(null),q=j(!1),B=E({get:()=>q.value,set:C=>{C||(q.value=!1)}}),u=j(null),S=j({kind:"home"}),D=j(null),T=j([]),_=j(null),ne=j(!1),ie=C=>JSON.parse(JSON.stringify(C));let G=0;const W=async()=>{const C=++G;v.value=!0,m.value=!1;try{const[p,V]=await Promise.all([n(),r.fetchSettings()]);if(C!==G)return!1;if(!V)throw new Error("Site settings did not load");return w.value=In(ie(p.data.cardDesigns),fe.value),A.value=_e(w.value),U.value=p.data.updatedAt,I.value=p.data.rejected??null,u.value=null,S.value={kind:"home"},h.value=[],Ae.value=[],!0}catch{return C!==G||(m.value=!0),!1}finally{C===G&&(v.value=!1)}};mt(()=>{W(),yo()});const re=E(()=>w.value?At(w.value,fe.value):null),M=E(()=>!!re.value&&_e(re.value)!==A.value);rn(()=>M.value&&!y.value);const F=E(()=>{const C=I.value;return C?C.wholesale&&C.reason==="unreadable-version"?"Your card design was saved by a newer version of the platform, so it can't be shown here. Saving will be refused until that version is back â try again shortly.":C.wholesale?"Your saved card design couldn't be read, so the editor has started again from the default card. Saving replaces the unreadable one.":"Part of your saved card design couldn't be read and has been left out. Saving keeps what you see here.":""}),se=E(()=>w.value?zt(w.value)??null:null),pe=C=>{const p=w.value;p&&(p.designs=p.designs.map(V=>V.id===C.id?C:V))},me=C=>{se.value&&pe(C(se.value))},z=C=>{const p=se.value;if(!p||p.layout===C)return;const V=xn(p,C);pe(V);const J=Cn(p,V);J>0&&o.info(`${J} ${J===1?"part":"parts"} moved to fit the ${i[C]} layout.`)},d=(C,p)=>me(V=>{const J=jt(V,C,!0),ye=we(J,C);return!ye||!ae(ye)||(ye.phoneZone??ye.zone)===p?J:Kt(J,C,p===ye.zone?null:p)}),f=C=>{const p=se.value?we(se.value,C):void 0;return k.value==="phone"&&!!p&&ae(p)&&p.type!=="buttons"},ve=(C,p,V,J,ye)=>{if(k.value=ye,f(C))return d(C,p);me(Ie=>hn(Ie,C,p,V,J))},ke=E(()=>Bn(r.settings.value)),fe=E(()=>Dn(r.settings.value)),Se=E(()=>w.value?en(w.value):[]),xe=j("live"),x=j("both"),k=j("computer");tt(x,C=>{C!=="both"&&(k.value=C)});const g=j([]),Z=E(()=>{if(!se.value)return[];const C=tn(se.value,xe.value,{cardBg:ke.value.cardBg,accent:ke.value.accent}),p=g.value.some(V=>V.involves?.includes("countdown"));return C.filter(V=>!(p&&V.kind==="corner-crowding"))}),R=E(()=>[...Z.value,...zn(g.value)]),Y=C=>Se.value.filter(p=>co(p)===C).map(Gt),$=C=>[...Z.value,...g.value].filter(p=>p.block===C||p.kind==="collision"&&p.involves?.includes(C)).map(p=>p.message),de=E(()=>{const C=Fn(xe.value);if(!C||!se.value)return null;const p=go(C,se.value.reactions);return{which:C,text:`${Xe[C].title}: ${p==="Off"?"the card looks the same as any other":p.charAt(0).toLowerCase()+p.slice(1)}.`}}),Te={design:E(()=>se.value),site:ke,selectedKey:u,panel:S,hoveredKey:D,previewState:xe,placeFor:k,select:C=>vt(C),openPanel:C=>Ut(C),warningsFor:$,issuesFor:Y,setDesign:pe,setLayout:z,setEnabled:(C,p)=>me(V=>jt(V,C,p)),setAlign:(C,p)=>me(V=>Ge(V,C,J=>ae(J)?{...J,align:p}:J)),setZone:(C,p)=>{if(f(C))return d(C,p);me(V=>pn(V,C,p))},setPhoneZone:(C,p)=>me(V=>Kt(V,C,p)),move:(C,p)=>me(V=>vn(V,C,p)),updateBlock:C=>me(p=>kn(Ge(p,H(C),()=>C))),dropInZone:(C,p)=>me(V=>De(ht(V,C,p)))};Mo(bo,Te);const nt=()=>!u.value&&S.value.kind==="home";let Ue=null;const le=C=>{const p=_.value?.closest("main")??null;nt()&&p&&(Ue=p.scrollTop),C(),Ve(()=>{if(nt()){p&&Ue!==null&&(p.scrollTop=Ue),Ue=null;return}const V=_.value;if(!V)return;const J=V.getBoundingClientRect().top;(J<0||J>window.innerHeight-96)&&V.scrollIntoView({block:"start"})})};
2function vt(C){if(le(()=>{u.value=C}),!C)return;const p=Un[C],V=se.value?we(se.value,C):void 0;p&&V?.enabled&&!T.value.includes(C)&&(xe.value=p)}function ho(C,p){k.value=p,vt(C)}function Ut(C){le(()=>{u.value=null,S.value=C})}const Re=j([]),yt=j(!1),We=j(""),vo=mo(),yo=async()=>{yt.value=!0;try{const p=((await $fetch("/api/competitions",{params:{page:1,limit:12}}))?.data??[]).filter(V=>!!V.id);Re.value=[...p].sort((V,J)=>+!!J.prizeImageUrl-+!!V.prizeImageUrl),Re.value.some(V=>V.id===We.value)||(We.value=Re.value[0]?.id??"")}catch{Re.value=[]}finally{yt.value=!1}},ko=E(()=>Re.value.find(C=>C.id===We.value)??Re.value[0]??vo),Wt=C=>{const p=se.value;p&&(pe({...C,id:p.id,name:p.name}),u.value=null,S.value={kind:"home"})},xo=async C=>{const p=ct[C].label;M.value&&!await l({title:`Use ${p}?`,message:`This replaces the design you're editing with ${p}. Your unsaved changes to it will be lost.`,confirmText:`Use ${p}`,variant:"destructive"})||(Wt(Pt(C,fe.value,{cardBg:ke.value.cardBg})),ne.value=!1,o.success(`${p} is on the card. Save to keep it.`))},kt=E(()=>!!se.value&&uo(se.value,fe.value)),wo=async()=>{await l({title:"Reset to the default card?",message:"This puts back the card every site starts with, matched to your site. Nothing changes on your site until you save.",confirmText:"Reset to default",variant:"destructive"})&&(Wt(Pt("classic",fe.value)),o.success("The default card is back. Save to put it back on your site."))},st=j(new Set),Ae=j([]),Ft=j(null),at=j(!1),So=async()=>{const C=se.value;if(!(!C||at.value)){at.value=!0;try{let p=null;for(let V=0;V<Xd;V++){const J=hs(C,st.value,vs()),ye=await Ft.value?.checkDesign(J),Ie=ye?ye.warnings.length*Qd+ye.cutShort:0;if((!p||Ie<p.score)&&(p={design:J,score:Ie}),Ie===0)break}if(!p||se.value!==C)return;Ae.value=[...Ae.value,JSON.stringify(C)].slice(-10),pe(p.design)}finally{at.value=!1}}},$o=()=>{const C=Ae.value[Ae.value.length-1];C&&(Ae.value=Ae.value.slice(0,-1),pe(JSON.parse(C)))},Co=()=>{A.value&&(w.value=JSON.parse(A.value),u.value=null,S.value={kind:"home"},h.value=[],Ae.value=[])},Ht=async(C={})=>{if(!(!re.value||Se.value.length>0)){y.value=!0,h.value=[];try{const p=_e(w.value),V=await t(ie(re.value),C.force?void 0:U.value),J=ie(V.data.cardDesigns);A.value=_e(J),_e(w.value)===p&&(w.value=J),U.value=V.data.updatedAt,I.value=null,q.value=!1,r.updateSettings({cardDesigns:J.mode==="custom"?J:null}),o.success(J.mode==="custom"?"Saved. Your cards are updated.":"Saved. Your site is on the default card.")}catch(p){Oo(p)}finally{y.value=!1}}},Oo=C=>{const p=C?.data;if(p?.code==="CARD_DESIGNS_VERSION_CONFLICT"){q.value=!0;return}if(p?.code==="CARD_DESIGNS_VERSION_UNSUPPORTED"){o.error("Your card design was saved by a newer version of the platform. Nothing was saved â try again shortly.");return}if(p?.code==="CARD_DESIGNS_VERSION_UNVERIFIABLE"){o.error("Could not check for other changes just now. Nothing was saved â try again.");return}if(h.value=on(C),h.value.length){o.error("Couldn't save your card design â see the errors above");return}o.error(p?.message||"Failed to save your card design")},To=async()=>{if(q.value=!1,await W()){o.success("Loaded the latest version of your card design");return}q.value=!0,o.error("Couldn't load the latest version â try again")},Ao=async()=>{q.value=!1,await Ht({force:!0})};return(C,p)=>{const V=Be,J=ft,ye=Uo,Ie=Wo,Eo=Fo;return c(),ge(Eo,{title:"Competition Cards",description:"Design the cards your competitions show in grids, Related competitions and after checkout."},zo({default:ce(()=>[O(Vs,{class:"mb-6"}),O(ye,{loading:s(v),error:s(m)?"We could not load your card design.":null,"is-empty":!1,onRetry:W},{default:ce(()=>[s(w)&&s(se)?(c(),b("div",zd,[s(F)?(c(),b("div",Vd,[O(V,{name:"heroicons:exclamation-triangle",class:"w-5 h-5 shrink-0"}),a("p",null,P(s(F)),1)])):N("",!0),s(Se).length>0?(c(),b("div",Md,[p[15]||(p[15]=a("h2",{class:"text-sm font-semibold text-red-300 mb-2"},"Fix these before saving",-1)),a("ul",Ud,[(c(!0),b(L,null,X(s(Se),(te,xt)=>(c(),b("li",{key:xt,class:"text-sm text-red-200"},P(s(Gt)(te)),1))),128))])])):N("",!0),s(h).length>0?(c(),b("div",Wd,[p[16]||(p[16]=a("h2",{class:"text-sm font-semibold text-red-300 mb-2"},"The save was rejected",-1)),a("ul",Fd,[(c(!0),b(L,null,X(s(h),(te,xt)=>(c(),b("li",{key:xt,class:"text-sm text-red-200"},[a("span",Hd,P(te.label),1),K(" â "+P(te.message),1)]))),128))])])):N("",!0),a("div",Zd,[a("div",Yd,[O(Ir,{ref_key:"stageRef",ref:Ft,"competition-id":s(We),"onUpdate:competitionId":p[2]||(p[2]=te=>Fe(We)?We.value=te:null),state:s(xe),"onUpdate:state":p[3]||(p[3]=te=>Fe(xe)?xe.value=te:null),view:s(x),"onUpdate:view":p[4]||(p[4]=te=>Fe(x)?x.value=te:null),design:s(se),competitions:s(Re),loading:s(yt),warnings:s(R),"selected-key":s(u),"hovered-key":s(D),"state-note":s(de),onMeasured:p[5]||(p[5]=te=>g.value=te),onSelect:ho,onDeselect:p[6]||(p[6]=te=>s(u)&&vt(null)),onHover:p[7]||(p[7]=te=>D.value=te),onVisible:p[8]||(p[8]=te=>T.value=te),onPlace:ve,onOpenState:p[9]||(p[9]=te=>Ut({kind:"state",which:te}))},null,8,["competition-id","state","view","design","competitions","loading","warnings","selected-key","hovered-key","state-note"])]),a("div",{ref_key:"panelEl",ref:_,class:"min-w-0 scroll-mt-4"},[s(u)?(c(),ge(tr,{key:0,visible:s(T).includes(s(u))},null,8,["visible"])):s(S).kind==="badges"?(c(),ge(Is,{key:1})):s(S).kind==="state"?(c(),ge(Od,{key:2,which:s(S).which},null,8,["which"])):(c(),ge(ll,{key:3}))],512)])])):N("",!0)]),_:1},8,["loading","error"]),O(Ie,{modelValue:s(ne),"onUpdate:modelValue":p[11]||(p[11]=te=>Fe(ne)?ne.value=te:null),title:"Start from a look",size:"xl"},{default:ce(()=>[O(Fr,{competition:s(ko),legacy:s(fe),site:{cardBg:s(ke).cardBg},onApply:xo},null,8,["competition","legacy","site"])]),_:1},8,["modelValue"]),O(Ie,{modelValue:s(B),"onUpdate:modelValue":p[12]||(p[12]=te=>Fe(B)?B.value=te:null),title:"Someone else saved the card design",size:"sm"},{default:ce(()=>[p[25]||(p[25]=a("p",{class:"text-sm text-card-text-secondary"}," Another admin saved changes to your competition cards while you were editing. ",-1)),p[26]||(p[26]=a("p",{class:"text-sm text-card-text-muted"}," Load their version to discard your unsaved changes, or overwrite to replace theirs with yours. ",-1)),a("div",Jd,[O(J,{variant:"secondary",width:"flex",disabled:s(y),onClick:To},{default:ce(()=>[...p[23]||(p[23]=[K(" Load their version ",-1)])]),_:1},8,["disabled"]),O(J,{variant:"danger",width:"flex",disabled:s(y),loading:s(y),onClick:Ao},{default:ce(()=>[...p[24]||(p[24]=[K(" Overwrite their version ",-1)])]),_:1},8,["disabled","loading"])])]),_:1},8,["modelValue"])]),_:2},[!s(v)&&!s(m)&&s(w)?{name:"actions",fn:ce(()=>
2[O(J,{size:"sm",variant:"secondary",onClick:p[0]||(p[0]=te=>ne.value=!0)},{default:ce(()=>[O(V,{name:"heroicons:swatch",class:"w-4 h-4","aria-hidden":"true"}),p[13]||(p[13]=K(" Looks ",-1))]),_:1}),O(Rd,{pins:s(st),"onUpdate:pins":p[1]||(p[1]=te=>Fe(st)?st.value=te:null),"can-undo":s(Ae).length>0,busy:s(at),onShuffle:So,onUndo:$o},null,8,["pins","can-undo","busy"]),O(J,{size:"sm",variant:"secondary",disabled:s(kt),title:s(kt)?"This is the default card":"Put back the card every site starts with",onClick:wo},{default:ce(()=>[O(V,{name:"heroicons:arrow-uturn-left",class:"w-4 h-4","aria-hidden":"true"}),p[14]||(p[14]=K(" Reset to default ",-1))]),_:1},8,["disabled","title"])]),key:"0"}:void 0,!s(v)&&!s(m)&&s(w)?{name:"saveBar",fn:ce(()=>[a("div",jd,[a("div",Kd,[s(Se).length>0?(c(),b(L,{key:0},[p[17]||(p[17]=a("span",{class:"w-2 h-2 rounded-full bg-red-400 shrink-0"},null,-1)),p[18]||(p[18]=a("a",{href:"#card-designer-issues",class:"text-red-300 underline"},"Fix the issues above to save",-1))],64)):s(M)?(c(),b(L,{key:1},[p[19]||(p[19]=a("span",{class:"w-2 h-2 rounded-full bg-amber-400 shrink-0"},null,-1)),p[20]||(p[20]=a("span",{class:"text-amber-400"},"Unsaved changes",-1))],64)):(c(),b("span",qd," All changes saved"+P(s(kt)?" · this is the default card":""),1))]),a("div",Gd,[s(M)?(c(),ge(J,{key:0,variant:"secondary",disabled:s(y),onClick:Co},{default:ce(()=>[...p[21]||(p[21]=[K(" Undo my changes ",-1)])]),_:1},8,["disabled"])):N("",!0),O(J,{variant:"primary",loading:s(y),disabled:s(y)||!s(M)||s(Se).length>0,onClick:p[10]||(p[10]=te=>Ht())},{default:ce(()=>[...p[22]||(p[22]=[K(" Save ",-1)])]),_:1},8,["loading","disabled"])])])]),key:"1"}:void 0]),1024)}}});export{Ac as default};
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.