/**
 * `<qr-code-ui>` — Inline QR code generator — renders a scannable code as inline SVG.
Two modes:

**A. Auto-encode (default).** Set `[value]` to a string (URL, plain
text, share link, 2FA secret). The component encodes the data with
the built-in zero-deps QR encoder (byte mode, ECC level configurable,
versions 1–10 up to ~150 byte chars) and renders an SVG.

**B. Bring-your-own matrix.** Set `[matrix]` to a JSON string of a
2-D 0/1 array (`[[1,0,1,...],[...],...]`). The component renders the
supplied matrix directly without invoking its own encoder. Use this
when you need versions 11–40, kanji/alphanumeric mode, or any
encoder feature beyond the built-in. When both `[value]` and
`[matrix]` are set, the matrix wins (BYO override).

Output is a single `<svg>` with `viewBox="0 0 N N"`. Crisp-edges
rendering preserves the scannable cell boundaries at any size.
Sizing is controlled by the `[size]` prop (host CSS-pixel dimension);
internal cell size is computed from `size / (matrix-size + 2 ·
margin)`. ARIA: `role="img"` with `aria-label` (default "QR code"
or the `[label]` prop).

 *
 * @see https://ui-kit.exe.xyz/site/components/qr-code
 *
 * Type declarations generated by scripts/build/dts-codegen.mjs from
 * the component's `.a2ui.json` sidecar(s). Edit the source `.yaml`,
 * run `npm run build:components`, then `npm run codegen:dts` to
 * regenerate; or hand-author this file fully if rich event types are
 * needed beyond what the yaml `events:` block can express.
 */

import { UIElement } from '../../core/element.js';

export class UIQRCode extends UIElement {
  /** Background (light-cell) color. **Empty defaults to `#ffffff` —
hardcoded white** alongside the black foreground, for guaranteed
scanability. Override only when paired with an explicit
[color] (the contrast pair must scan).
 */
  background: string;
  /** Foreground (dark-cell) color. Any CSS color string (hex, rgb,
token reference). **Empty defaults to `#000000` — hardcoded black
for guaranteed scanability** (theme-aware `currentColor` would
produce light-on-dark in dark mode, which most phone scanners
refuse to decode). Override for branded QRs only when you've
verified the chosen color/background pair scans on the target
devices.
 */
  color: string;
  /** Error-correction level (auto-encode mode only). `L` (7% recovery),
`M` (15%, default), `Q` (25%), `H` (30%). Higher levels recover
from more damage at the cost of QR-version size growth.
 */
  errorCorrection: 'L' | 'M' | 'Q' | 'H';
  /** `aria-label` for the SVG. Defaults to "QR code". Customize for
better AT context (e.g. "Share link QR code", "2FA setup QR").
 */
  label: string;
  /** Quiet zone in cells around the QR pattern. QR spec requires a
minimum 4-cell margin for reliable scanning; smaller values may
not scan on some devices. Default `4`.
 */
  margin: number;
  /** BYO precomputed bit matrix as JSON — a 2-D array of 0/1
(`[[1,0,...],[0,1,...],...]`). When set, the built-in encoder is
bypassed and this matrix renders directly. Useful for QR variants
the built-in doesn't support (versions 11–40, alphanumeric mode,
kanji, etc.) — bring your own encoder, pass the matrix here.
 */
  matrix: string;
  /** Host display size in CSS pixels (width and height; the SVG is
always square). Default 200. Internal cell size is computed from
this divided by `matrix-size + 2·margin`.
 */
  size: number;
  /** The string to encode (URL / text / share link / 2FA seed). When
[matrix] is also set, the matrix wins. Empty value + empty matrix
renders nothing.
 */
  value: string;
}
