// Printable half-sheet handouts with the member's QR + invite link.
// The ref token (username, share code or member #) comes from ?ref=, then
// localStorage (set by Promo tools), then the signed-in account.
(function () {
'use strict';
var $ = function (id) { return document.getElementById(id); };
var ORIGIN = location.origin;
var DESIGNS = [
{ angle: 'instant', tag: 'Polygon · same-transaction payouts', h: 'Advertise & earn.
Paid on-chain, instantly.',
lead: 'Every ad package splits to real wallets the second it sells. No pending. No withdraw button.',
bullets: ['Free to join with just an email', 'Ad packages from $5, seven ad formats', 'Every payout public on the blockchain'] },
{ angle: 'adspend', tag: 'For marketers who buy traffic', h: 'You were buying ads anyway.',
lead: 'Here the ad spend in your line pays you, in the same transaction, on a public ledger.',
bullets: ['Banners, text, login, solo, video, featured, visits', 'Dwell-timed views: real people, not scripts', '50 / 20 / 10 sponsor split, written in code'] },
{ angle: 'free', tag: 'Costs nothing to try', h: 'Watch first.
Spend never.',
lead: 'Join free, view a few ads, earn credits, and run your first campaign for zero dollars.',
bullets: ['Email sign-in, no password, no wallet needed', 'Earn credits for your attention every day', 'Upgrade only if you want more reach'] }
];
function getRef() {
var q = new URLSearchParams(location.search).get('ref');
if (q && /^[A-Za-z0-9_]{1,20}$/.test(q)) return q;
try { var s = localStorage.getItem('iap.ref'); if (s && /^[A-Za-z0-9_]{1,20}$/.test(s)) return s; } catch (e) {}
return '';
}
function qrSvg(url) {
try { var q = qrcode(0, 'M'); q.addData(url); q.make(); return q.createSvgTag({ cellSize: 4, margin: 2, scalable: true }); } catch (e) { return ''; }
}
function el(tag, cls, html) { var d = document.createElement(tag); if (cls) d.className = cls; if (html != null) d.innerHTML = html; return d; }
function card(d, url, shortUrl) {
var hs = el('div', 'hs');
hs.appendChild(el('div', 'lines'));
var inner = el('div', 'in');
var logo = el('img', 'logo'); logo.src = '/logo.png'; logo.alt = 'InstantAdPay'; inner.appendChild(logo);
inner.appendChild(el('span', 'tag', d.tag));
inner.appendChild(el('h2', null, d.h));
inner.appendChild(el('p', 'lead', d.lead));
var ul = el('ul'); d.bullets.forEach(function (b) { ul.appendChild(el('li', null, b)); }); inner.appendChild(ul);
inner.appendChild(el('div', 'foot', 'Scan the code or visit ' + shortUrl + ''));
hs.appendChild(inner);
var ov = el('div', 'hs-qrov');
ov.appendChild(el('div', 'q', url ? qrSvg(url) : '