#set page(width: auto, height: auto)
#let typst_qr = plugin("target/wasm32-unknown-unknown/release/typst_qr.wasm")

#let qr(data, dark_color: black, light_color: white, has_quiet_zone: true, width: auto) = image.decode(
    str(typst_qr.qr(
        cbor.encode((
            data,
            dark_color.hex(),
            light_color.hex(),
            has_quiet_zone,
        ))
    )),
    format: "svg",
    width: width
)

#figure(
    qr("This QR code was generated dynamically by a typst plugin!", width: 200pt),
    caption: [
        A qr code generated by a typst wasm plugin!!
    ],
)

#figure(
    qr(
        "This QR code was generated dynamically by a typst plugin!",
        dark_color: green,
        light_color: blue,
        has_quiet_zone: false,
        width: 200pt
    ),
    caption: [
        A qr code with custom colors!
    ],
)