@tapple.io/qr-code-generator 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -10
- package/dist/browser.mjs +24 -24
- package/dist/index.d.ts +5 -5
- package/dist/node.cjs +22 -22
- package/dist/node.mjs +22 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@ A lightweight QR code generator with full TypeScript support. Generate QR codes
|
|
|
5
5
|
[](https://www.npmjs.com/package/@tapple.io/qr-code-generator)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
+
**[🎨 Try the Interactive Demo →](https://tappleinc.github.io/qr-code-generator/demo/)**
|
|
9
|
+
|
|
8
10
|
## Features
|
|
9
11
|
|
|
10
12
|
- 🚀 **Platform-optimized architecture** - Zero browser dependencies (native Canvas API) + one Node.js dependency (`@resvg/resvg-js`)
|
|
@@ -153,23 +155,23 @@ import { genQrImage, EyeFrameShape, DotShape, BorderShape } from '@tapple.io/qr-
|
|
|
153
155
|
const options = {
|
|
154
156
|
size: 300, // QR matrix size in pixels
|
|
155
157
|
margin: 24, // Margin in pixels
|
|
156
|
-
backgroundColor: '
|
|
158
|
+
backgroundColor: 'white', // CSS color: hex, rgb, rgba, hsl, hsla, or named
|
|
157
159
|
|
|
158
160
|
// Eye (position marker) styling
|
|
159
161
|
eyes: {
|
|
160
162
|
shape: EyeFrameShape.SQUIRCLE, // 'square' | 'squircle'
|
|
161
|
-
color: '#0066ff'
|
|
163
|
+
color: '#0066ff' // Supports all CSS color formats
|
|
162
164
|
},
|
|
163
165
|
|
|
164
166
|
// Pupil (center of eyes) styling
|
|
165
167
|
pupils: {
|
|
166
|
-
color: '
|
|
168
|
+
color: 'rgb(0, 0, 0)' // Can mix color formats
|
|
167
169
|
},
|
|
168
170
|
|
|
169
171
|
// Data dot styling
|
|
170
172
|
dots: {
|
|
171
173
|
shape: DotShape.DOTS, // 'classic' | 'dots' | 'square'
|
|
172
|
-
color: '
|
|
174
|
+
color: 'hsl(0, 0%, 0%)', // HSL format supported
|
|
173
175
|
scale: 1.0 // 0.75 to 1.25
|
|
174
176
|
},
|
|
175
177
|
|
|
@@ -183,7 +185,7 @@ const options = {
|
|
|
183
185
|
border: {
|
|
184
186
|
shape: BorderShape.SQUIRCLE, // 'none' | 'square' | 'squircle' | 'circle'
|
|
185
187
|
width: 10, // Border width in pixels
|
|
186
|
-
color: '
|
|
188
|
+
color: 'rgba(0, 0, 0, 0.8)', // RGBA with transparency supported
|
|
187
189
|
style: 'solid' // 'solid' | 'dashed'
|
|
188
190
|
},
|
|
189
191
|
|
|
@@ -205,15 +207,15 @@ Complete reference for PNG and SVG rendering options:
|
|
|
205
207
|
|--------|------|---------|-------------|-------------|
|
|
206
208
|
| `size` | number | `300` | >= 21 | QR matrix size in pixels |
|
|
207
209
|
| `margin` | number | `24` | >= 0 | Spacing around QR code in pixels |
|
|
208
|
-
| `backgroundColor` | string | `'#ffffff'` |
|
|
210
|
+
| `backgroundColor` | string | `'#ffffff'` | CSS color | Background color (supports hex, rgb/rgba, hsl/hsla, named colors) |
|
|
209
211
|
| **Eyes (Position Markers)** |
|
|
210
212
|
| `eyes.shape` | enum | `'square'` | `'square'` \| `'squircle'` | Outer frame shape of position markers |
|
|
211
|
-
| `eyes.color` | string | `'#000000'` |
|
|
213
|
+
| `eyes.color` | string | `'#000000'` | CSS color | Color of eye frames (supports hex, rgb/rgba, hsl/hsla, named colors) |
|
|
212
214
|
| **Pupils (Eye Centers)** |
|
|
213
|
-
| `pupils.color` | string | `'#000000'` |
|
|
215
|
+
| `pupils.color` | string | `'#000000'` | CSS color | Color of pupil (inner square of eyes) |
|
|
214
216
|
| **Dots (Data Modules)** |
|
|
215
217
|
| `dots.shape` | enum | `'classic'` | `'classic'` \| `'dots'` \| `'square'` | Shape of data modules |
|
|
216
|
-
| `dots.color` | string | `'#000000'` |
|
|
218
|
+
| `dots.color` | string | `'#000000'` | CSS color | Color of data modules |
|
|
217
219
|
| `dots.scale` | number | `1.0` | 0.75 - 1.25 | Visual size multiplier |
|
|
218
220
|
| **Logo** |
|
|
219
221
|
| `logo.src` | string | - | Data URL or SVG string | Image source |
|
|
@@ -221,7 +223,7 @@ Complete reference for PNG and SVG rendering options:
|
|
|
221
223
|
| **Border** |
|
|
222
224
|
| `border.shape` | enum | `'none'` | `'none'` \| `'square'` \| `'squircle'` \| `'circle'` | Border shape wrapping the QR code |
|
|
223
225
|
| `border.width` | number | `10` | >=0 | Border thickness in pixels |
|
|
224
|
-
| `border.color` | string | `'#000000'` |
|
|
226
|
+
| `border.color` | string | `'#000000'` | CSS color | Border color (supports hex, rgb/rgba, hsl/hsla, named colors) |
|
|
225
227
|
| `border.style` | enum | `'solid'` | `'solid'` \| `'dashed'` | Border line style |
|
|
226
228
|
| **Output** |
|
|
227
229
|
| `output.format` | enum | `'png'` | `'png'` \| `'svg'` | Output image format |
|
|
@@ -229,6 +231,52 @@ Complete reference for PNG and SVG rendering options:
|
|
|
229
231
|
|
|
230
232
|
> **Note:** Error correction level is automatically selected based on input length and logo presence (not user-configurable).
|
|
231
233
|
|
|
234
|
+
### Color Format Support
|
|
235
|
+
|
|
236
|
+
All color properties (`backgroundColor`, `eyes.color`, `pupils.color`, `dots.color`, `border.color`) support multiple CSS color formats:
|
|
237
|
+
|
|
238
|
+
#### Supported Formats
|
|
239
|
+
|
|
240
|
+
**Hexadecimal (3 or 6 digits)**
|
|
241
|
+
```typescript
|
|
242
|
+
backgroundColor: '#fff' // 3-digit shorthand
|
|
243
|
+
backgroundColor: '#ffffff' // 6-digit full
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**RGB / RGBA**
|
|
247
|
+
```typescript
|
|
248
|
+
dots: { color: 'rgb(0, 0, 0)' }
|
|
249
|
+
dots: { color: 'rgba(0, 0, 0, 0.8)' } // With transparency
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**HSL / HSLA**
|
|
253
|
+
```typescript
|
|
254
|
+
eyes: { color: 'hsl(240, 100%, 50%)' }
|
|
255
|
+
eyes: { color: 'hsla(240, 100%, 50%, 0.9)' } // With transparency
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Named Colors**
|
|
259
|
+
```typescript
|
|
260
|
+
backgroundColor: 'white'
|
|
261
|
+
dots: { color: 'black' }
|
|
262
|
+
border: { color: 'red' }
|
|
263
|
+
// Supports all 147 CSS3 named colors + 'transparent'
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**Mixed Formats**
|
|
267
|
+
```typescript
|
|
268
|
+
// You can mix different formats in the same QR code
|
|
269
|
+
const qr = await genQrImage('Hello', {
|
|
270
|
+
backgroundColor: 'white',
|
|
271
|
+
eyes: { color: '#0066ff' },
|
|
272
|
+
pupils: { color: 'rgb(0, 0, 0)' },
|
|
273
|
+
dots: { color: 'hsl(0, 0%, 20%)' },
|
|
274
|
+
border: { shape: BorderShape.CIRCLE, color: 'rgba(0, 0, 0, 0.5)' }
|
|
275
|
+
});
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
> **Note on Transparency:** When using alpha channels (RGBA/HSLA), ensure sufficient contrast for QR code scannability. Alpha values below 0.8 may reduce scan reliability.
|
|
279
|
+
|
|
232
280
|
### TextOptions Reference
|
|
233
281
|
|
|
234
282
|
Options for ASCII text rendering:
|
package/dist/browser.mjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
var X={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},
|
|
1
|
+
var X={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},I={L:[19,34,55,80,108,136,156,194,232,274],M:[16,28,44,64,86,108,124,154,182,216],Q:[13,22,34,48,62,76,88,110,132,154],H:[9,16,26,36,46,60,66,86,100,122]},Z={L:[[1,19,0,0],[1,34,0,0],[1,55,0,0],[1,80,0,0],[1,108,0,0],[2,68,0,0],[2,78,0,0],[2,97,0,0],[2,116,0,0],[2,68,2,69]],M:[[1,16,0,0],[1,28,0,0],[1,44,0,0],[2,32,0,0],[2,43,0,0],[4,27,0,0],[4,31,0,0],[2,38,2,39],[3,36,2,37],[4,43,1,44]],Q:[[1,13,0,0],[1,22,0,0],[2,17,0,0],[2,24,0,0],[2,15,2,16],[4,19,0,0],[2,14,4,15],[4,18,2,19],[4,16,4,17],[6,19,2,20]],H:[[1,9,0,0],[1,16,0,0],[2,13,0,0],[4,9,0,0],[2,11,2,12],[4,15,0,0],[4,13,1,14],[4,14,2,15],[4,12,4,13],[6,15,2,16]]},R="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ve={1:[10,12,14],2:[9,11,13],4:[8,16,16]},B={L:1,M:0,Q:3,H:2},O=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],K=[31892,34236,39577,42195],J=[0,7,7,7,7,7,0,0,0,0];function M(t){return t*4+17}function P(t,e){let r=e<10?0:e<27?1:2;return Ve[t][r]}var ee=(r=>(r.SQUARE="square",r.SQUIRCLE="squircle",r))(ee||{}),te=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(te||{}),re=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(re||{}),ne=(r=>(r.SOLID="solid",r.DASHED="dashed",r))(ne||{});function $(t,e){let r=e/2;return t<=-r?0:t>=r?255:Math.round((t+r)/e*255)}function N(t,e,r=.01){return $(e-t,r)}function Ne(t,e,r,o){let n=Math.abs(t)-r+o,s=Math.abs(e)-r+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function qe(t,e){let n=e*3,s=e*2,a=n+s,i=Math.max(1,Math.round(t/a)),l=t/i,c=l*(3/5),u=l*(2/5),f=u/2;return{dashArray:`${c} ${u}`,offset:f}}function q(t,e){let r=e*3,o=e*2,n=r+o,s=Math.round(t/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=t/s,i=a*.6,l=a*.4,c=i/2;return{dashArray:`${i} ${l}`,offset:c}}function V(t,e,r,o,n){return n==="circle"?ze(t,e,r,o):n==="squircle"?Fe(t,e,r,o):Ue(t,e,r,o)}function ze(t,e,r,o){let s=(Math.atan2(e,t)+Math.PI)/(2*Math.PI),a=r/2-o/2,i=2*Math.PI*a,l=o*3,c=o*2,u=Math.floor(i/(l+c)),f=u%2===0?u:u-1,d=Math.max(4,f);return s*d%1<.6}function Fe(t,e,r,o){let s=r/2-o/2,a=r*z,i=Math.max(0,a-o/2),l=s-i,c=2*l,u=.5*Math.PI*i,f=4*c+4*u,d=Qe(t,e,l,i,c,u,f),{dashArray:m}=q(f,o),[g,h]=m.split(" ").map(Number),p=g+h;return(d+g/2)%p<g}function Qe(t,e,r,o,n,s,a){if(e<-r)if(t>r){let i=Math.atan2(e- -r,t-r)+Math.PI/2;return r+i*o}else if(t<-r){let i=Math.atan2(e- -r,t- -r)+Math.PI;return r+3*s+3*n+i*o}else return t>=0?t:a+t;else if(e>r)if(t>r){let i=Math.atan2(e-r,t-r);return r+s+n+i*o}else if(t<-r){let i=Math.atan2(e-r,t- -r)-Math.PI/2;return r+2*s+2*n+i*o}else return r+2*s+n+(r-t);else return t>r?r+s+(e- -r):t<-r?r+3*s+2*n+(r-e):t>=0?t:a+t}function Ue(t,e,r,o){let n=r/2,s=Math.abs(t),i=Math.abs(e)>=s?n+t:n+e,l=r-o,c=3,u=2,f=o*(c+u),d=Math.max(1,Math.round(l/f)),m=l/d,g=m*(c/(c+u)),p=(m-g)/2;return(i+p)%m<g}var z=.09,_e={EYE_FRAME:.90909},S={square:{renderSVG(t,e,r,o){return`<rect x="${t}" y="${e}" width="${r}" height="${r}" fill="${o}"/>`},renderPixel(t,e,r,o){let n=r/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(t),n-Math.abs(e));return $(a,s)}},squircle:{renderSVG(t,e,r,o){let n=r/2,s=n*_e.EYE_FRAME,a=t+n,i=e+n;return`<path d="${`M${a},${i-n}
|
|
2
2
|
C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
|
|
3
3
|
S${a+s},${i+n} ${a},${i+n}
|
|
4
4
|
S${a-n},${i+s} ${a-n},${i}
|
|
5
|
-
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,
|
|
6
|
-
H${
|
|
7
|
-
A${
|
|
8
|
-
V${
|
|
9
|
-
A${
|
|
10
|
-
H${
|
|
11
|
-
A${
|
|
12
|
-
V${
|
|
13
|
-
A${
|
|
14
|
-
Z`;if(a==="dashed"){let
|
|
15
|
-
A${
|
|
16
|
-
A${
|
|
17
|
-
A${
|
|
18
|
-
A${
|
|
5
|
+
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(t,e,r,o){let n=r/2,s=o?.pixelSize??.01,a=4,i=Math.abs(t),l=Math.abs(e),c=i/n,u=l/n;if(i<.001&&l<.001)return 255;let f=Math.pow(c,a)+Math.pow(u,a),d=a/n*Math.sqrt(Math.pow(c,2*a-2)+Math.pow(u,2*a-2)),m=(1-f)/d;return $(m,s)}}},w={classic:{renderSVG(){return""},renderPixel(t,e,r,o){let n=r/2,s=o?.pixelSize??.01;if(r>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:l,col:c}=o,u=o.qrSize||i.length,f=c>0&&i[l][c-1],d=c<u-1&&i[l][c+1],m=l>0&&i[l-1][c],g=l<u-1&&i[l+1][c],h=f?1/0:n+t,p=d?1/0:n-t,y=m?1/0:n+e,x=g?1/0:n-e,T=Math.min(Math.min(h,p),Math.min(y,x));return $(T,s)}let a=Math.min(n-Math.abs(t),n-Math.abs(e));return $(a,s)}},dots:{renderSVG(t,e,r,o){let n=t+r/2,s=e+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(t,e,r,o){let n=r*.35,s=o?.pixelSize??.01,a=Math.sqrt(t*t+e*e);return N(a,n,s)}},square:{renderSVG(t,e,r,o){let n=r*.7,s=(r-n)/2,a=t+s,i=e+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(t,e,r,o){let s=r*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(t),s-Math.abs(e));return $(i,a)}}},L={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(t,e,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,m=r-s,{dashArray:g,offset:h}=qe(m,s);return`<rect x="${t+d}" y="${e+d}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${-h}"/>`}let i=`M${t},${e}h${r}v${r}h${-r}z`,l=t+s,c=e+s,u=r-s*2,f=`M${l},${c}h${u}v${u}h${-u}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(t,e,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=r/2,l=i-n,c=i-Math.abs(t),u=i-Math.abs(e),f=l-Math.abs(t),d=l-Math.abs(e),m=Math.min(c,u),g=Math.min(f,d);if(m>=0&&g<=0){if(s==="dashed"&&!V(t,e,r,n,"square"))return 0;let h=$(m,a),p=255-$(g,a);return Math.min(h,p)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(t,e,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=t+i,c=e+i,u=i-s/2,f=r*z,d=Math.max(0,f-s/2),m=u-d,g=`M${l},${c-u}
|
|
6
|
+
H${l+m}
|
|
7
|
+
A${d},${d} 0 0 1 ${l+u},${c-m}
|
|
8
|
+
V${c+m}
|
|
9
|
+
A${d},${d} 0 0 1 ${l+m},${c+u}
|
|
10
|
+
H${l-m}
|
|
11
|
+
A${d},${d} 0 0 1 ${l-u},${c+m}
|
|
12
|
+
V${c-m}
|
|
13
|
+
A${d},${d} 0 0 1 ${l-m},${c-u}
|
|
14
|
+
Z`;if(a==="dashed"){let h=2*m,p=.5*Math.PI*d,y=4*h+4*p,{dashArray:x,offset:T}=q(y,s);return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${x}" stroke-dashoffset="${T}"/>`}return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(t,e,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,l=r/2-n/2,c=r*z,u=Math.max(0,c-n/2),f=Math.abs(Ne(t,e,l,u)),d=n/2-f;return d>-a?s==="dashed"&&!V(t,e,r,n,"squircle")?0:$(d,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(t,e,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=t+r/2,l=e+r/2,c=r/2;if(a==="dashed"){let m=c-s/2,g=2*Math.PI*m,{dashArray:h,offset:p}=q(g,s);return`<circle cx="${i}" cy="${l}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${p}"/>`}let u=c-s,f=`M${i},${l-c}
|
|
15
|
+
A${c},${c} 0 1,1 ${i},${l+c}
|
|
16
|
+
A${c},${c} 0 1,1 ${i},${l-c}Z`,d=`M${i},${l-u}
|
|
17
|
+
A${u},${u} 0 1,0 ${i},${l+u}
|
|
18
|
+
A${u},${u} 0 1,0 ${i},${l-u}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(t,e,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=r/2,l=i-n,c=Math.sqrt(t*t+e*e);if(c<=i&&c>=l){if(s==="dashed"&&!V(t,e,r,n,"circle"))return 0;let u=N(c,i,a),f=255-N(c,l,a);return Math.min(u,f)}return 0}}};var C=class extends Error{constructor(e){let r=e.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
19
|
`);super(`QR Code validation failed:
|
|
20
|
-
${t}`),this.name="QRValidationError",this.errors=r}};function M(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function w(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function q(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function We(e,r){let t=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!t.test(e)&&!o)return{field:r,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2)return{field:r,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!Ge(s))return{field:r,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:r,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function Ge(e){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(e)&&e.length%4===0}catch{return!1}}function se(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function U(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function ae(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function ie(e){let r=[];if(e.size!==void 0){let t=M(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=M(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=w(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=q(e.eyes.shape,"eyes.shape",S);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=w(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=w(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=q(e.dots.shape,"dots.shape",E);t&&r.push(t)}if(e.dots?.color!==void 0){let t=w(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=M(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=q(e.border.shape,"border.shape",L);t&&r.push(t)}if(e.border?.width!==void 0){let t=M(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=w(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo){if(!e.logo.src||typeof e.logo.src!="string")r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"});else{let t=We(e.logo.src,"logo.src");t&&r.push(t)}if(e.logo.scale!==void 0){let t=M(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}}if(r.length>0)throw new C(r)}function ce(e){let r=[];if(e.margin!==void 0){let t=M(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new C(r)}function z(e){let r=[];if(typeof e=="string"){if(e||r.push({field:"input",value:e,message:"string input cannot be empty"}),r.length>0)throw new C(r);return}if(!e||typeof e!="object"||!("type"in e))throw r.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new C(r);let t=e;switch(t.type){case"wifi":{je(e.data,r);break}case"vcard":{He(e.data,r);break}case"calendar":{Ye(e.data,r);break}case"email":{Xe(e,r);break}case"sms":{Ze(e,r);break}case"phone":{Ke(e,r);break}case"url":{Je(e,r);break}default:r.push({field:"input.type",value:t.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(r.length>0)throw new C(r)}function je(e,r){if(!e||typeof e!="object"){r.push({field:"wifi.data",value:e,message:"must be an object"});return}let t=e;if((!t.ssid||typeof t.ssid!="string"||!t.ssid.trim())&&r.push({field:"wifi.ssid",value:t.ssid,message:"is required and must be non-empty"}),(!t.password||typeof t.password!="string")&&r.push({field:"wifi.password",value:t.password,message:"is required and must be a string"}),t.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(t.encryption)||r.push({field:"wifi.encryption",value:t.encryption,message:`must be one of: ${o.join(", ")}`})}t.hidden!==void 0&&typeof t.hidden!="boolean"&&r.push({field:"wifi.hidden",value:t.hidden,message:"must be a boolean"})}function He(e,r){if(!e||typeof e!="object"){r.push({field:"vcard.data",value:e,message:"must be an object"});return}let t=e;(!t.name||typeof t.name!="string"||!t.name.trim())&&r.push({field:"vcard.name",value:t.name,message:"is required and must be non-empty"}),t.email!==void 0&&(typeof t.email!="string"||!se(t.email))&&r.push({field:"vcard.email",value:t.email,message:"must be a valid email address"}),t.phone!==void 0&&(typeof t.phone!="string"||!U(t.phone))&&r.push({field:"vcard.phone",value:t.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),t.url!==void 0&&(typeof t.url!="string"||!ae(t.url))&&r.push({field:"vcard.url",value:t.url,message:"must be a valid URL"}),t.address!==void 0&&typeof t.address!="object"&&r.push({field:"vcard.address",value:t.address,message:"must be an object"})}function Ye(e,r){if(!e||typeof e!="object"){r.push({field:"calendar.data",value:e,message:"must be an object"});return}let t=e;(!t.title||typeof t.title!="string"||!t.title.trim())&&r.push({field:"calendar.title",value:t.title,message:"is required and must be non-empty"});let o=oe(t.startDate);if(o||r.push({field:"calendar.startDate",value:t.startDate,message:"is required and must be a valid Date object or ISO string"}),t.endDate!==void 0){let n=oe(t.endDate);n?o&&n<o&&r.push({field:"calendar.endDate",value:t.endDate,message:"must be after startDate"}):r.push({field:"calendar.endDate",value:t.endDate,message:"must be a valid Date object or ISO string"})}}function Xe(e,r){let t=e;(!t.email||typeof t.email!="string"||!se(t.email))&&r.push({field:"email.email",value:t.email,message:"is required and must be a valid email address"}),t.subject!==void 0&&typeof t.subject!="string"&&r.push({field:"email.subject",value:t.subject,message:"must be a string"}),t.body!==void 0&&typeof t.body!="string"&&r.push({field:"email.body",value:t.body,message:"must be a string"})}function Ze(e,r){let t=e;(!t.phone||typeof t.phone!="string"||!U(t.phone))&&r.push({field:"sms.phone",value:t.phone,message:"is required and must be a valid phone number"}),t.message!==void 0&&typeof t.message!="string"&&r.push({field:"sms.message",value:t.message,message:"must be a string"})}function Ke(e,r){let t=e;(!t.phone||typeof t.phone!="string"||!U(t.phone))&&r.push({field:"phone.phone",value:t.phone,message:"is required and must be a valid phone number"})}function Je(e,r){let t=e;(!t.url||typeof t.url!="string"||!ae(t.url))&&r.push({field:"url.url",value:t.url,message:"is required and must be a valid URL"})}function oe(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let r=new Date(e);return isNaN(r.getTime())?null:r}return null}var b={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},A={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function ue(e){if(!e){let{logo:t,...o}=b;return o}return ie(e),{size:e.size??b.size,margin:e.margin??b.margin,backgroundColor:e.backgroundColor??b.backgroundColor,eyes:{shape:e.eyes?.shape??b.eyes.shape,color:e.eyes?.color??b.eyes.color},pupils:{color:e.pupils?.color??b.pupils.color},dots:{shape:e.dots?.shape??b.dots.shape,color:e.dots?.color??b.dots.color,scale:e.dots?.scale??b.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??b.logo.scale}:void 0,border:{shape:e.border?.shape??b.border.shape,width:e.border?.width??b.border.width,color:e.border?.color??b.border.color,style:e.border?.style??b.border.style},output:e.output??b.output}}function le(e){return e?(ce(e),{margin:e.margin??A.margin,darkChar:e.darkChar??A.darkChar,lightChar:e.lightChar??A.lightChar}):{...A}}function fe(e){return/^\d+$/.test(e)?1:[...e].every(r=>I.includes(r))?2:4}function et(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)r.push(n>>a&1)}return r}function tt(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=I.indexOf(e[t])*45+I.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=I.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function rt(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function nt(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=D(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function ot(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function st(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function de(e,r,t){let o=fe(e),n,s;o===1?(n=et(e),s=e.length):o===2?(n=tt(e),s=e.length):(n=rt(e),s=new TextEncoder().encode(e).length);let a=nt(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=ot(a);return st(c,t)}function k(e,r){let t=fe(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=D(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+u+l;if(Math.ceil(d/8)<=r[c-1])return c}let n=D(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function me(e,r){if(r)try{if(k(e,R.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let t=["H","Q","M","L"];for(let o of t)try{if(k(e,R[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var O=new Array(256),_=new Array(256);function at(){let e=1;for(let r=0;r<255;r++)O[r]=e,_[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)O[r]=O[r-255]}at();function ge(e,r){return e===0||r===0?0:O[_[e]+_[r]]}function it(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=ge(r[s],O[t]);r=n}return r}function he(e,r){let t=it(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=ge(t[a],s)}return o.slice(e.length)}function pe(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let d=e.slice(u,u+a);o.push(d);let f=he(d,r);n.push(f),u+=a}for(let l=0;l<i;l++){let d=e.slice(u,u+c);o.push(d);let f=he(d,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function be(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function ye(e){let r=v(e);return Array.from({length:r},()=>Array(r).fill(!1))}function $e(e){let r=v(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=P[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function W(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function ct(e,r,t){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[r+o][t+n]=s||a}}function xe(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function Ce(e){W(e,0,0),W(e,0,e.length-7),W(e,e.length-7,0)}function Re(e,r){let t=e.length,o=P[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||ct(e,n,s)}function Me(e,r){e[4*r+9][8]=!0}function Ie(e,r,t){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function G(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function ut(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let d=1;d<r;d++)e[a][d]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][d],u=1),e[d][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[d][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function ve(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);G(i,r,a),o(i,t,a);let c=ut(i);c<s&&(s=c,n=a)}return n}function j(e,r,t){let o=e.length,n=B[r]<<3|t,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function Se(e,r){if(r<7)return;let t=e.length,o=K[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function Ee(e,r){return B[e]<<3|r}function we(e,r,t,o,n){let s=ye(e),a=$e(e);Ce(s),xe(s),Re(s,e),Me(s,e),Ie(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??ve(s,a,r,j);return G(s,a,c),j(s,r,c),Se(s,e),{matrix:s,mask:c,formatInfo:n?Ee(r,c):void 0,unmaskedMatrix:i}}function H(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function Oe(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Pe(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function lt(e,r,t,o,n,s,a){let i=S[t]||S.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function ft(e,r,t,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let h=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(h);else if(typeof Buffer<"u")i=Buffer.from(h,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(h)}catch{return""}}}let c=i.match(/viewBox=["']([^"']+)["']/),u=c?c[1]:"0 0 100 100",l=i.match(/<svg([\s\S]*?)>/i),d="";if(l){let m=l[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(d=" "+m.join(" "))}let f=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
|
|
21
|
-
<svg width="${o}" height="${o}" viewBox="${
|
|
22
|
-
${
|
|
20
|
+
${r}`),this.name="QRValidationError",this.errors=e}};function Ge(t){let e={...t};return e.backgroundColor===""&&(e.backgroundColor=void 0),e.eyes&&(e.eyes={...e.eyes},e.eyes.shape===""&&(e.eyes.shape=void 0),e.eyes.color===""&&(e.eyes.color=void 0)),e.pupils&&(e.pupils={...e.pupils},e.pupils.color===""&&(e.pupils.color=void 0)),e.dots&&(e.dots={...e.dots},e.dots.shape===""&&(e.dots.shape=void 0),e.dots.color===""&&(e.dots.color=void 0)),e.border&&(e.border={...e.border},e.border.shape===""&&(e.border.shape=void 0),e.border.color===""&&(e.border.color=void 0),e.border.style===""&&(e.border.style=void 0)),e}function We(t){let e={...t};return e.darkChar===""&&(e.darkChar=void 0),e.lightChar===""&&(e.lightChar=void 0),e}function v(t,e,r,o,n=!1){return typeof t!="number"||!isFinite(t)?{field:e,value:t,message:"must be a finite number"}:n&&!Number.isInteger(t)?{field:e,value:t,message:"must be an integer"}:t<r?{field:e,value:t,message:`must be at least ${r}`}:o!==null&&t>o?{field:e,value:t,message:`must be at most ${o}`}:null}function E(t,e){if(typeof t!="string")return{field:e,value:t,message:"must be a string"};let r=t.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/,s=r.match(n);if(s){let[,c,u,f,d]=s,m=parseInt(c,10),g=parseInt(u,10),h=parseInt(f,10);if(m<0||m>255||g<0||g>255||h<0||h>255)return{field:e,value:t,message:"RGB values must be between 0-255"};if(d!==void 0){let p=parseFloat(d);if(isNaN(p)||p<0||p>1)return{field:e,value:t,message:"RGBA alpha value must be between 0-1"}}return null}let a=/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/,i=r.match(a);if(i){let[,c,u,f,d]=i,m=parseInt(c,10),g=parseInt(u,10),h=parseInt(f,10);if(m<0||m>360)return{field:e,value:t,message:"HSL hue must be between 0-360"};if(g<0||g>100||h<0||h>100)return{field:e,value:t,message:"HSL saturation and lightness must be between 0-100%"};if(d!==void 0){let p=parseFloat(d);if(isNaN(p)||p<0||p>1)return{field:e,value:t,message:"HSLA alpha value must be between 0-1"}}return null}return["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","transparent"].includes(r.toLowerCase())?null:{field:e,value:t,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function F(t,e,r){if(typeof t!="string")return{field:e,value:t,message:"must be a string"};if(!(t in r)){let o=Object.keys(r).join(", ");return{field:e,value:t,message:`must be one of: ${o}`}}return null}function je(t,e){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=t.trim().startsWith("<svg");if(!r.test(t)&&!o)return{field:e,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(t.startsWith("data:")){let n=t.split(",");if(n.length!==2)return{field:e,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!He(s))return{field:e,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!t.includes("</svg>")?{field:e,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function He(t){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(t)&&t.length%4===0}catch{return!1}}function se(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Q(t){return/^[\d\s\-+()]+$/.test(t)&&t.replace(/\D/g,"").length>=7}function ae(t){try{return new URL(t.startsWith("http")?t:`https://${t}`),!0}catch{return!1}}function ie(t){let e=Ge(t),r=[];if(e.size!==void 0){let o=v(e.size,"size",21,null,!0);o&&r.push(o)}if(e.margin!==void 0){let o=v(e.margin,"margin",0,null,!0);o&&r.push(o)}if(e.backgroundColor!==void 0){let o=E(e.backgroundColor,"backgroundColor");o&&r.push(o)}if(e.eyes?.shape!==void 0){let o=F(e.eyes.shape,"eyes.shape",S);o&&r.push(o)}if(e.eyes?.color!==void 0){let o=E(e.eyes.color,"eyes.color");o&&r.push(o)}if(e.pupils?.color!==void 0){let o=E(e.pupils.color,"pupils.color");o&&r.push(o)}if(e.dots?.shape!==void 0){let o=F(e.dots.shape,"dots.shape",w);o&&r.push(o)}if(e.dots?.color!==void 0){let o=E(e.dots.color,"dots.color");o&&r.push(o)}if(e.dots?.scale!==void 0){let o=v(e.dots.scale,"dots.scale",.75,1.25,!1);o&&r.push(o)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let o=F(e.border.shape,"border.shape",L);o&&r.push(o)}if(e.border?.width!==void 0){let o=v(e.border.width,"border.width",0,null,!0);o&&r.push(o)}if(e.border?.color!==void 0){let o=E(e.border.color,"border.color");o&&r.push(o)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo){if(!e.logo.src||typeof e.logo.src!="string")r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"});else{let o=je(e.logo.src,"logo.src");o&&r.push(o)}if(e.logo.scale!==void 0){let o=v(e.logo.scale,"logo.scale",.1,.3,!1);o&&r.push(o)}}if(r.length>0)throw new C(r);return e}function le(t){let e=We(t),r=[];if(e.margin!==void 0){let o=v(e.margin,"margin",0,null,!0);o&&r.push(o)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new C(r);return e}function U(t){let e=[];if(typeof t=="string"){if(t||e.push({field:"input",value:t,message:"string input cannot be empty"}),e.length>0)throw new C(e);return}if(!t||typeof t!="object"||!("type"in t))throw e.push({field:"input",value:t,message:"must be a string or structured content object with a type property"}),new C(e);let r=t;switch(r.type){case"wifi":{Ye(t.data,e);break}case"vcard":{Xe(t.data,e);break}case"calendar":{Ze(t.data,e);break}case"email":{Ke(t,e);break}case"sms":{Je(t,e);break}case"phone":{et(t,e);break}case"url":{tt(t,e);break}default:e.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(e.length>0)throw new C(e)}function Ye(t,e){if(!t||typeof t!="object"){e.push({field:"wifi.data",value:t,message:"must be an object"});return}let r=t;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&e.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&e.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||e.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&e.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function Xe(t,e){if(!t||typeof t!="object"){e.push({field:"vcard.data",value:t,message:"must be an object"});return}let r=t;(!r.name||typeof r.name!="string"||!r.name.trim())&&e.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!se(r.email))&&e.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!Q(r.phone))&&e.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!ae(r.url))&&e.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&e.push({field:"vcard.address",value:r.address,message:"must be an object"})}function Ze(t,e){if(!t||typeof t!="object"){e.push({field:"calendar.data",value:t,message:"must be an object"});return}let r=t;(!r.title||typeof r.title!="string"||!r.title.trim())&&e.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=oe(r.startDate);if(o||e.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=oe(r.endDate);n?o&&n<o&&e.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):e.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function Ke(t,e){let r=t;(!r.email||typeof r.email!="string"||!se(r.email))&&e.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&e.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&e.push({field:"email.body",value:r.body,message:"must be a string"})}function Je(t,e){let r=t;(!r.phone||typeof r.phone!="string"||!Q(r.phone))&&e.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&e.push({field:"sms.message",value:r.message,message:"must be a string"})}function et(t,e){let r=t;(!r.phone||typeof r.phone!="string"||!Q(r.phone))&&e.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function tt(t,e){let r=t;(!r.url||typeof r.url!="string"||!ae(r.url))&&e.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}function oe(t){if(t instanceof Date)return isNaN(t.getTime())?null:t;if(typeof t=="string"){let e=new Date(t);return isNaN(e.getTime())?null:e}return null}var b={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},A={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function ce(t){if(!t){let{logo:o,...n}=b;return n}let e=ie(t);return{size:e.size??b.size,margin:e.margin??b.margin,backgroundColor:e.backgroundColor??b.backgroundColor,eyes:{shape:e.eyes?.shape??b.eyes.shape,color:e.eyes?.color??b.eyes.color},pupils:{color:e.pupils?.color??b.pupils.color},dots:{shape:e.dots?.shape??b.dots.shape,color:e.dots?.color??b.dots.color,scale:e.dots?.scale??b.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??b.logo.scale}:void 0,border:{shape:e.border?.shape??b.border.shape,width:e.border?.width??b.border.width,color:e.border?.color??b.border.color,style:e.border?.style??b.border.style},output:e.output??b.output}}function ue(t){if(!t)return{...A};let e=le(t);return{margin:e.margin??A.margin,darkChar:e.darkChar??A.darkChar,lightChar:e.lightChar??A.lightChar}}function de(t){return/^\d+$/.test(t)?1:[...t].every(e=>R.includes(e))?2:4}function rt(t){let e=[];for(let r=0;r<t.length;r+=3){let o=t.substring(r,Math.min(r+3,t.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)e.push(n>>a&1)}return e}function nt(t){let e=[];for(let r=0;r<t.length;r+=2)if(r+1<t.length){let o=R.indexOf(t[r])*45+R.indexOf(t[r+1]);for(let n=10;n>=0;n--)e.push(o>>n&1)}else{let o=R.indexOf(t[r]);for(let n=5;n>=0;n--)e.push(o>>n&1)}return e}function ot(t){let e=[],r=new TextEncoder().encode(t);for(let o of r)for(let n=7;n>=0;n--)e.push(o>>n&1);return e}function st(t,e,r,o){let n=[];for(let a=3;a>=0;a--)n.push(e>>a&1);let s=P(e,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...t]}function at(t){let e=[];for(let r=0;r<t.length;r+=8){let o=0;for(let n=0;n<8&&r+n<t.length;n++)o=o<<1|t[r+n];r+8>t.length&&(o<<=8-t.length%8),e.push(o)}return e}function it(t,e){let r=[...t],o=[236,17],n=0;for(;r.length<e;)r.push(o[n]),n=1-n;return r}function fe(t,e,r){let o=de(t),n,s;o===1?(n=rt(t),s=t.length):o===2?(n=nt(t),s=t.length):(n=ot(t),s=new TextEncoder().encode(t).length);let a=st(n,o,s,e),i=Math.min(4,r*8-a.length);for(let c=0;c<i;c++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=at(a);return it(l,r)}function D(t,e){let r=de(t),o=r===4?new TextEncoder().encode(t).length:t.length;for(let l=1;l<=10;l++){let c=P(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+c+u;if(Math.ceil(f/8)<=e[l-1])return l}let n=P(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${e[9]} bytes. Current data length: ${t.length} characters (${o} bytes encoded).`)}function me(t,e){if(e)try{if(D(t,I.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${t.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(D(t,I[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${t.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var k=new Array(256),_=new Array(256);function lt(){let t=1;for(let e=0;e<255;e++)k[e]=t,_[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)k[e]=k[e-255]}lt();function he(t,e){return t===0||e===0?0:k[_[t]+_[e]]}function ct(t){let e=[1];for(let r=0;r<t;r++){let o=e.length+1,n=new Array(o).fill(0);for(let s=0;s<e.length;s++)n[s]^=e[s],n[s+1]^=he(e[s],k[r]);e=n}return e}function ge(t,e){let r=ct(e),o=[...t,...new Array(e).fill(0)];for(let n=0;n<t.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=he(r[a],s)}return o.slice(t.length)}function pe(t,e,r){let o=[],n=[],[s,a,i,l]=r,c=0;for(let u=0;u<s;u++){let f=t.slice(c,c+a);o.push(f);let d=ge(f,e);n.push(d),c+=a}for(let u=0;u<i;u++){let f=t.slice(c,c+l);o.push(f);let d=ge(f,e);n.push(d),c+=l}return{dataBlocks:o,ecBlocks:n}}function be(t,e){let r=[],o=Math.max(...t.map(s=>s.length));for(let s=0;s<o;s++)for(let a of t)s<a.length&&r.push(a[s]);let n=Math.max(...e.map(s=>s.length));for(let s=0;s<n;s++)for(let a of e)s<a.length&&r.push(a[s]);return r}function ye(t){let e=M(t);return Array.from({length:e},()=>Array(e).fill(!1))}function xe(t){let e=M(t),r=Array.from({length:e},()=>Array(e).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][e-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[e-8+n][s]=!0;for(let n=8;n<e-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*t+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=e-8;n<e;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=e-8;n<e;n++)r[8][n]=!0;let o=O[t-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>e-9||n>e-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(t>=7){for(let n=0;n<6;n++)for(let s=e-11;s<e-8;s++)r[n][s]=!0;for(let n=e-11;n<e-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function G(t,e,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=e+o,a=r+n;if(s<0||s>=t.length||a<0||a>=t.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;t[s][a]=i||l}}function ut(t,e,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;t[e+o][r+n]=s||a}}function $e(t){let e=t.length;for(let r=8;r<e-8;r++)t[6][r]=r%2===0,t[r][6]=r%2===0}function Ce(t){G(t,0,0),G(t,0,t.length-7),G(t,t.length-7,0)}function Ie(t,e){let r=t.length,o=O[e-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||ut(t,n,s)}function ve(t,e){t[4*e+9][8]=!0}function Re(t,e,r){let o=t.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!e[a][i-l]){let c=n<r.length?r[n]:!1;t[a][i-l]=c,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function W(t,e,r){let o=t.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(e[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(t[n][s]=!t[n][s])}}function dt(t){let e=t.length,r=0;for(let a=0;a<e;a++){let i=t[a][0],l=t[0][a],c=1,u=1;for(let f=1;f<e;f++)t[a][f]===i?c++:(c>=5&&(r+=3+(c-5)),i=t[a][f],c=1),t[f][a]===l?u++:(u>=5&&(r+=3+(u-5)),l=t[f][a],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let a=0;a<e-1;a++)for(let i=0;i<e-1;i++){let l=t[a][i];t[a][i+1]===l&&t[a+1][i]===l&&t[a+1][i+1]===l&&(r+=3)}for(let a=0;a<e;a++){let i=0,l=0;for(let c=0;c<e;c++)i=i<<1&2047|(t[a][c]?1:0),c>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(t[c][a]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=e*e;for(let a=0;a<e;a++)for(let i=0;i<e;i++)t[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Me(t,e,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=t.map(c=>[...c]);W(i,e,a),o(i,r,a);let l=dt(i);l<s&&(s=l,n=a)}return n}function j(t,e,r){let o=t.length,n=B[e]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?t[8][i]=l:i===6?t[8][7]=l:i===7?t[8][8]=l:i===8?t[7][8]=l:t[5-(i-9)][8]=l,i<=6?t[o-1-i][8]=l:t[8][o-8+(i-7)]=l}}function Se(t,e){if(e<7)return;let r=t.length,o=K[e-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;t[a][i]=s;let l=r-11+n%3,c=Math.floor(n/3);t[l][c]=s}}function we(t,e){return B[t]<<3|e}function Ee(t,e,r,o,n){let s=ye(t),a=xe(t);Ce(s),$e(s),Ie(s,t),ve(s,t),Re(s,a,r);let i=n?s.map(c=>[...c]):void 0,l=o??Me(s,a,e,j);return W(s,a,l),j(s,e,l),Se(s,t),{matrix:s,mask:l,formatInfo:n?we(e,l):void 0,unmaskedMatrix:i}}function H(t,e,r){return t<7&&e<7||t<7&&e>=r-7||t>=r-7&&e<7}function ke(t){return[{x:0,y:0},{x:t-7,y:0},{x:0,y:t-7}]}function Oe(t,e){let o=Math.max(.1,Math.min(.3,e));return t*o}function ft(t,e,r,o,n,s,a){let i=S[r]||S.square,l=i.renderSVG(t,e,7*a,o),c=i.renderSVG(t+a,e+a,5*a,s),u=i.renderSVG(t+2*a,e+2*a,3*a,n);return l+c+u}function mt(t,e,r,o){let n=o/2,s=t.trim();if(t.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=t;if(t.includes("data:image/svg")){let m=t.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(t.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=i.match(/<svg([\s\S]*?)>/i),f="";if(u){let m=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${e-n}, ${r-n})">
|
|
21
|
+
<svg width="${o}" height="${o}" viewBox="${c}"${f}>
|
|
22
|
+
${d}
|
|
23
23
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${
|
|
25
|
-
`;for(let i=0;i<
|
|
26
|
-
`}for(let i=0;i<
|
|
27
|
-
`;return s}async function Ae(e
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
24
|
+
</g>`}else return`<image x="${e-n}" y="${r-n}" width="${o}" height="${o}" href="${t}" preserveAspectRatio="xMidYMid meet"/>`}function gt(t,e,r,o,n){let s=t.matrixSize,a="",i=w[r]||w.classic;if(r==="classic"){a=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(t.modules[l][c]&&!H(l,c,s)){let u=c*e,f=l*e,d=n*e,m=(1-n)*e/2,g=u+m,h=f+m;a+=`M${g},${h}h${d}v${d}h${-d}z`}return a+='"/>',a}for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(t.modules[l][c]&&!H(l,c,s)){let u=c*e,f=l*e,d=n*e,m=(1-n)*e/2,g=u+m,h=f+m,p={qrcode:t.modules,qrSize:s,row:l,col:c};a+=i.renderSVG(g,h,d,o,p)}return a}function Pe(t,e){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=e,l=r/t.matrixSize,c=e.border.shape==="none"?0:e.border.width,u=r+2*o+2*c,f=o+c,d=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${u}" width="${u}" height="${u}">`;if(d+=`<rect width="${u}" height="${u}" fill="${n}"/>`,e.border.shape!=="none"&&c>0){let y=L[e.border.shape];if(y){let x={borderWidth:c,borderStyle:e.border.style};d+=y.renderSVG(0,0,u,e.border.color,x)}}e.border.shape!=="none"&&c>0&&(d+=`<rect x="${f}" y="${f}" width="${r}" height="${r}" fill="${n}"/>`),d+=`<g transform="translate(${f}, ${f})">`;let m=ke(t.matrixSize),g="";for(let y of m)g+=ft(y.x*l,y.y*l,s.shape,s.color,a.color,n,l);let h=gt(t,l,i.shape,i.color,i.scale);d+=g+h+"</g>";let p="";if(e.logo){let y=Oe(t.matrixSize,e.logo.scale)*l,x=u/2;p=mt(e.logo.src,x,x,y)}return d+=p+"</svg>",d}function Le(t,e){let{margin:r,lightChar:o,darkChar:n}=e,s="",a=t.matrixSize+r*2;for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
25
|
+
`;for(let i=0;i<t.matrixSize;i++){s+=o.repeat(r);for(let l=0;l<t.matrixSize;l++)s+=t.modules[i][l]?n:o;s+=o.repeat(r)+`
|
|
26
|
+
`}for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
27
|
+
`;return s}async function Ae(t,e){let{output:r,size:o,margin:n,border:s}=e,a=s.shape==="none"?0:s.width,i=o+2*n+2*a;return new Promise((l,c)=>{let u=document.createElement("canvas");u.width=i,u.height=i;let f=u.getContext("2d");if(!f){c(new Error("Failed to get canvas context"));return}let d=new Image,m=null;try{let g=new Blob([t],{type:"image/svg+xml;charset=utf-8"});m=URL.createObjectURL(g)}catch{c(new Error("Failed to create SVG blob for rasterization"));return}d.onload=()=>{if(m&&URL.revokeObjectURL(m),f.drawImage(d,0,0,i,i),r.type==="dataURL"){let g=u.toDataURL("image/png");l(g)}else u.toBlob(g=>{if(!g){c(new Error("Failed to convert PNG to blob"));return}g.arrayBuffer().then(h=>{l(new Uint8Array(h))})},"image/png")},d.onerror=()=>{m&&URL.revokeObjectURL(m),c(new Error("Failed to load SVG for rasterization"))},d.src=m})}async function De(t,e){let{format:r,type:o}=e.output;return r==="svg"?o==="string"?t:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:await Ae(t,e)}function Y(t){if(typeof t=="string")return t;switch(t.type){case"url":return ht(t.url);case"vcard":return pt(t.data);case"wifi":return bt(t.data);case"calendar":return yt(t.data);case"email":return xt(t.email,t.subject,t.body);case"sms":return $t(t.phone,t.message);case"phone":return Ct(t.phone)}}function ht(t){return!t.startsWith("http://")&&!t.startsWith("https://")?`https://${t}`:t}function pt(t){let e=["BEGIN:VCARD","VERSION:3.0",`FN:${t.name}`];if(t.phone&&e.push(`TEL:${t.phone}`),t.email&&e.push(`EMAIL:${t.email}`),t.organization&&e.push(`ORG:${t.organization}`),t.url&&e.push(`URL:${t.url}`),t.title&&e.push(`TITLE:${t.title}`),t.note&&e.push(`NOTE:${t.note}`),t.address){let{street:r,city:o,state:n,zip:s,country:a}=t.address,i=["","",r||"",o||"",n||"",s||"",a||""];e.push(`ADR:${i.join(";")}`)}return e.push("END:VCARD"),e.join(`
|
|
28
|
+
`)}function bt(t){let e=t.encryption||"WPA",r=t.hidden?"H:true;":"",o=Te(t.ssid),n=Te(t.password);return`WIFI:T:${e};S:${o};P:${n};${r};`}function Te(t){return t.replace(/([\\;,":])/g,"\\$1")}function yt(t){let e=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${t.title}`,`DTSTART:${e(t.startDate)}`,`DTEND:${e(t.endDate)}`];return t.location&&r.push(`LOCATION:${t.location}`),t.description&&r.push(`DESCRIPTION:${t.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
29
|
+
`)}function xt(t,e,r){let o=`mailto:${t}`,n=[];return e&&n.push(`subject=${encodeURIComponent(e)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function $t(t,e){return e?`sms:${t}:${e}`:`sms:${t}`}function Ct(t){return`tel:${t}`}function It(t,e){let r=[];for(let n of t)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=J[e-1];for(let n=0;n<o;n++)r.push(!1);return r}function Be(t,e){if(!t)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=me(t,e),o=I[r],n=D(t,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${t.length} characters. Maximum capacity at EC level ${r}: ~${I[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=fe(t,n,o[n-1]),a=X[r][n-1],i=Z[r][n-1],{dataBlocks:l,ecBlocks:c}=pe(s,a,i),u=be(l,c),f=It(u,n),{matrix:d,mask:m}=Ee(n,r,f);return{version:n,matrixSize:M(n),modules:d,mask:m,errorCorrectionLevel:r}}async function vt(t,e){U(t);let r=Y(t),o=ce(e),n=Be(r,!!o.logo),s=Pe(n,o);return await De(s,o)}function Rt(t,e){U(t);let r=Y(t),o=ue(e),n=Be(r,!1);return Le(n,o)}export{re as BorderShape,ne as BorderStyle,te as DotShape,ee as EyeFrameShape,C as QRValidationError,vt as genQrImage,Rt as genQrText};
|
package/dist/index.d.ts
CHANGED
|
@@ -140,25 +140,25 @@ export interface ImageOptions {
|
|
|
140
140
|
size?: number;
|
|
141
141
|
/** Margin around QR code in pixels (default: 24) */
|
|
142
142
|
margin?: number;
|
|
143
|
-
/** Background color
|
|
143
|
+
/** Background color - supports hex (#fff, #ffffff), rgb/rgba, hsl/hsla, or named colors (default: '#ffffff') */
|
|
144
144
|
backgroundColor?: string;
|
|
145
145
|
/** Eye (outer frame) styling */
|
|
146
146
|
eyes?: {
|
|
147
147
|
/** Eye frame shape (default: 'square') */
|
|
148
148
|
shape?: EyeFrameShape;
|
|
149
|
-
/** Eye frame color
|
|
149
|
+
/** Eye frame color - supports hex (#fff, #ffffff), rgb/rgba, hsl/hsla, or named colors (default: '#000000') */
|
|
150
150
|
color?: string;
|
|
151
151
|
};
|
|
152
152
|
/** Pupil (inner core) styling */
|
|
153
153
|
pupils?: {
|
|
154
|
-
/** Pupil color
|
|
154
|
+
/** Pupil color - supports hex (#fff, #ffffff), rgb/rgba, hsl/hsla, or named colors (default: '#000000') */
|
|
155
155
|
color?: string;
|
|
156
156
|
};
|
|
157
157
|
/** Data dot (module) styling */
|
|
158
158
|
dots?: {
|
|
159
159
|
/** Data dot shape (default: 'classic') */
|
|
160
160
|
shape?: DotShape;
|
|
161
|
-
/** Data dot color
|
|
161
|
+
/** Data dot color - supports hex (#fff, #ffffff), rgb/rgba, hsl/hsla, or named colors (default: '#000000') */
|
|
162
162
|
color?: string;
|
|
163
163
|
/** Data dot scale (0.75 to 1.25, default: 1.0) - adjusts visual size of dots while keeping overall dimensions fixed */
|
|
164
164
|
scale?: number;
|
|
@@ -179,7 +179,7 @@ export interface ImageOptions {
|
|
|
179
179
|
* Total output size = size + 2×margin + 2×width
|
|
180
180
|
*/
|
|
181
181
|
width?: number;
|
|
182
|
-
/** Border color
|
|
182
|
+
/** Border color - supports hex (#fff, #ffffff), rgb/rgba, hsl/hsla, or named colors (default: '#000000') */
|
|
183
183
|
color?: string;
|
|
184
184
|
/** Border style - solid or dashed pattern (default: 'solid') */
|
|
185
185
|
style?: BorderStyle;
|
package/dist/node.cjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";var je=Object.create;var
|
|
1
|
+
"use strict";var je=Object.create;var O=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Ge=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var He=(e,t)=>{for(var r in t)O(e,r,{get:t[r],enumerable:!0})},re=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ue(t))!We.call(e,n)&&n!==r&&O(e,n,{get:()=>t[n],enumerable:!(o=_e(t,n))||o.enumerable});return e};var Ye=(e,t,r)=>(r=e!=null?je(Ge(e)):{},re(t||!e||!e.__esModule?O(r,"default",{value:e,enumerable:!0}):r,e)),Xe=e=>re(O({},"__esModule",{value:!0}),e);var Vt={};He(Vt,{BorderShape:()=>Q,BorderStyle:()=>F,DotShape:()=>z,EyeFrameShape:()=>q,QRValidationError:()=>x,genQrImage:()=>Qe,genQrText:()=>Fe});module.exports=Xe(Vt);var ne={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},C={L:[19,34,55,80,108,136,156,194,232,274],M:[16,28,44,64,86,108,124,154,182,216],Q:[13,22,34,48,62,76,88,110,132,154],H:[9,16,26,36,46,60,66,86,100,122]},oe={L:[[1,19,0,0],[1,34,0,0],[1,55,0,0],[1,80,0,0],[1,108,0,0],[2,68,0,0],[2,78,0,0],[2,97,0,0],[2,116,0,0],[2,68,2,69]],M:[[1,16,0,0],[1,28,0,0],[1,44,0,0],[2,32,0,0],[2,43,0,0],[4,27,0,0],[4,31,0,0],[2,38,2,39],[3,36,2,37],[4,43,1,44]],Q:[[1,13,0,0],[1,22,0,0],[2,17,0,0],[2,24,0,0],[2,15,2,16],[4,19,0,0],[2,14,4,15],[4,18,2,19],[4,16,4,17],[6,19,2,20]],H:[[1,9,0,0],[1,16,0,0],[2,13,0,0],[4,9,0,0],[2,11,2,12],[4,15,0,0],[4,13,1,14],[4,14,2,15],[4,12,4,13],[6,15,2,16]]},R="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ze={1:[10,12,14],2:[9,11,13],4:[8,16,16]},V={L:1,M:0,Q:3,H:2},P=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],se=[31892,34236,39577,42195],ae=[0,7,7,7,7,7,0,0,0,0];function M(e){return e*4+17}function A(e,t){let r=t<10?0:t<27?1:2;return Ze[e][r]}var q=(r=>(r.SQUARE="square",r.SQUIRCLE="squircle",r))(q||{}),z=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(z||{}),Q=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(Q||{}),F=(r=>(r.SOLID="solid",r.DASHED="dashed",r))(F||{});function v(e,t){let r=t/2;return e<=-r?0:e>=r?255:Math.round((e+r)/t*255)}function _(e,t,r=.01){return v(t-e,r)}function Ke(e,t,r,o){let n=Math.abs(e)-r+o,s=Math.abs(t)-r+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function Je(e,t){let n=t*3,s=t*2,a=n+s,i=Math.max(1,Math.round(e/a)),l=e/i,u=l*(3/5),c=l*(2/5),f=c/2;return{dashArray:`${u} ${c}`,offset:f}}function U(e,t){let r=t*3,o=t*2,n=r+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,l=a*.4,u=i/2;return{dashArray:`${i} ${l}`,offset:u}}function j(e,t,r,o,n){return n==="circle"?et(e,t,r,o):n==="squircle"?tt(e,t,r,o):nt(e,t,r,o)}function et(e,t,r,o){let s=(Math.atan2(t,e)+Math.PI)/(2*Math.PI),a=r/2-o/2,i=2*Math.PI*a,l=o*3,u=o*2,c=Math.floor(i/(l+u)),f=c%2===0?c:c-1,d=Math.max(4,f);return s*d%1<.6}function tt(e,t,r,o){let s=r/2-o/2,a=r*G,i=Math.max(0,a-o/2),l=s-i,u=2*l,c=.5*Math.PI*i,f=4*u+4*c,d=rt(e,t,l,i,u,c,f),{dashArray:m}=U(f,o),[g,p]=m.split(" ").map(Number),h=g+p;return(d+g/2)%h<g}function rt(e,t,r,o,n,s,a){if(t<-r)if(e>r){let i=Math.atan2(t- -r,e-r)+Math.PI/2;return r+i*o}else if(e<-r){let i=Math.atan2(t- -r,e- -r)+Math.PI;return r+3*s+3*n+i*o}else return e>=0?e:a+e;else if(t>r)if(e>r){let i=Math.atan2(t-r,e-r);return r+s+n+i*o}else if(e<-r){let i=Math.atan2(t-r,e- -r)-Math.PI/2;return r+2*s+2*n+i*o}else return r+2*s+n+(r-e);else return e>r?r+s+(t- -r):e<-r?r+3*s+2*n+(r-t):e>=0?e:a+e}function nt(e,t,r,o){let n=r/2,s=Math.abs(e),i=Math.abs(t)>=s?n+e:n+t,l=r-o,u=3,c=2,f=o*(u+c),d=Math.max(1,Math.round(l/f)),m=l/d,g=m*(u/(u+c)),h=(m-g)/2;return(i+h)%m<g}var G=.09,ot={EYE_FRAME:.90909},S={square:{renderSVG(e,t,r,o){return`<rect x="${e}" y="${t}" width="${r}" height="${r}" fill="${o}"/>`},renderPixel(e,t,r,o){let n=r/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(e),n-Math.abs(t));return v(a,s)}},squircle:{renderSVG(e,t,r,o){let n=r/2,s=n*ot.EYE_FRAME,a=e+n,i=t+n;return`<path d="${`M${a},${i-n}
|
|
2
2
|
C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
|
|
3
3
|
S${a+s},${i+n} ${a},${i+n}
|
|
4
4
|
S${a-n},${i+s} ${a-n},${i}
|
|
5
|
-
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,
|
|
6
|
-
H${
|
|
7
|
-
A${
|
|
5
|
+
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,t,r,o){let n=r/2,s=o?.pixelSize??.01,a=4,i=Math.abs(e),l=Math.abs(t),u=i/n,c=l/n;if(i<.001&&l<.001)return 255;let f=Math.pow(u,a)+Math.pow(c,a),d=a/n*Math.sqrt(Math.pow(u,2*a-2)+Math.pow(c,2*a-2)),m=(1-f)/d;return v(m,s)}}},w={classic:{renderSVG(){return""},renderPixel(e,t,r,o){let n=r/2,s=o?.pixelSize??.01;if(r>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:l,col:u}=o,c=o.qrSize||i.length,f=u>0&&i[l][u-1],d=u<c-1&&i[l][u+1],m=l>0&&i[l-1][u],g=l<c-1&&i[l+1][u],p=f?1/0:n+e,h=d?1/0:n-e,y=m?1/0:n+t,$=g?1/0:n-t,N=Math.min(Math.min(p,h),Math.min(y,$));return v(N,s)}let a=Math.min(n-Math.abs(e),n-Math.abs(t));return v(a,s)}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(e,t,r,o){let n=r*.35,s=o?.pixelSize??.01,a=Math.sqrt(e*e+t*t);return _(a,n,s)}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,a=e+s,i=t+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(e,t,r,o){let s=r*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(e),s-Math.abs(t));return v(i,a)}}},D={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,m=r-s,{dashArray:g,offset:p}=Je(m,s);return`<rect x="${e+d}" y="${t+d}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${-p}"/>`}let i=`M${e},${t}h${r}v${r}h${-r}z`,l=e+s,u=t+s,c=r-s*2,f=`M${l},${u}h${c}v${c}h${-c}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,t,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=r/2,l=i-n,u=i-Math.abs(e),c=i-Math.abs(t),f=l-Math.abs(e),d=l-Math.abs(t),m=Math.min(u,c),g=Math.min(f,d);if(m>=0&&g<=0){if(s==="dashed"&&!j(e,t,r,n,"square"))return 0;let p=v(m,a),h=255-v(g,a);return Math.min(p,h)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=e+i,u=t+i,c=i-s/2,f=r*G,d=Math.max(0,f-s/2),m=c-d,g=`M${l},${u-c}
|
|
6
|
+
H${l+m}
|
|
7
|
+
A${d},${d} 0 0 1 ${l+c},${u-m}
|
|
8
8
|
V${u+m}
|
|
9
|
-
A${
|
|
10
|
-
H${
|
|
11
|
-
A${
|
|
9
|
+
A${d},${d} 0 0 1 ${l+m},${u+c}
|
|
10
|
+
H${l-m}
|
|
11
|
+
A${d},${d} 0 0 1 ${l-c},${u+m}
|
|
12
12
|
V${u-m}
|
|
13
|
-
A${
|
|
14
|
-
Z`;if(a==="dashed"){let
|
|
15
|
-
A${u},${u} 0 1,1 ${i},${
|
|
16
|
-
A${u},${u} 0 1,1 ${i},${
|
|
17
|
-
A${
|
|
18
|
-
A${
|
|
13
|
+
A${d},${d} 0 0 1 ${l-m},${u-c}
|
|
14
|
+
Z`;if(a==="dashed"){let p=2*m,h=.5*Math.PI*d,y=4*p+4*h,{dashArray:$,offset:N}=U(y,s);return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${$}" stroke-dashoffset="${N}"/>`}return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(e,t,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,l=r/2-n/2,u=r*G,c=Math.max(0,u-n/2),f=Math.abs(Ke(e,t,l,c)),d=n/2-f;return d>-a?s==="dashed"&&!j(e,t,r,n,"squircle")?0:v(d,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+r/2,l=t+r/2,u=r/2;if(a==="dashed"){let m=u-s/2,g=2*Math.PI*m,{dashArray:p,offset:h}=U(g,s);return`<circle cx="${i}" cy="${l}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${p}" stroke-dashoffset="${h}"/>`}let c=u-s,f=`M${i},${l-u}
|
|
15
|
+
A${u},${u} 0 1,1 ${i},${l+u}
|
|
16
|
+
A${u},${u} 0 1,1 ${i},${l-u}Z`,d=`M${i},${l-c}
|
|
17
|
+
A${c},${c} 0 1,0 ${i},${l+c}
|
|
18
|
+
A${c},${c} 0 1,0 ${i},${l-c}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,t,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=r/2,l=i-n,u=Math.sqrt(e*e+t*t);if(u<=i&&u>=l){if(s==="dashed"&&!j(e,t,r,n,"circle"))return 0;let c=_(u,i,a),f=255-_(u,l,a);return Math.min(c,f)}return 0}}};var x=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
19
|
`);super(`QR Code validation failed:
|
|
20
|
-
${t}`),this.name="QRValidationError",this.errors=r}};function R(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function w(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function G(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function st(e,r){let t=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!t.test(e)&&!o)return{field:r,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2)return{field:r,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!at(s))return{field:r,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:r,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function at(e){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(e)&&e.length%4===0}catch{return!1}}function ce(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function H(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function ue(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function le(e){let r=[];if(e.size!==void 0){let t=R(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=R(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=w(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=G(e.eyes.shape,"eyes.shape",S);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=w(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=w(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=G(e.dots.shape,"dots.shape",E);t&&r.push(t)}if(e.dots?.color!==void 0){let t=w(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=R(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=G(e.border.shape,"border.shape",L);t&&r.push(t)}if(e.border?.width!==void 0){let t=R(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=w(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo){if(!e.logo.src||typeof e.logo.src!="string")r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"});else{let t=st(e.logo.src,"logo.src");t&&r.push(t)}if(e.logo.scale!==void 0){let t=R(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}}if(r.length>0)throw new v(r)}function fe(e){let r=[];if(e.margin!==void 0){let t=R(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new v(r)}function Y(e){let r=[];if(typeof e=="string"){if(e||r.push({field:"input",value:e,message:"string input cannot be empty"}),r.length>0)throw new v(r);return}if(!e||typeof e!="object"||!("type"in e))throw r.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new v(r);let t=e;switch(t.type){case"wifi":{it(e.data,r);break}case"vcard":{ct(e.data,r);break}case"calendar":{ut(e.data,r);break}case"email":{lt(e,r);break}case"sms":{ft(e,r);break}case"phone":{dt(e,r);break}case"url":{mt(e,r);break}default:r.push({field:"input.type",value:t.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(r.length>0)throw new v(r)}function it(e,r){if(!e||typeof e!="object"){r.push({field:"wifi.data",value:e,message:"must be an object"});return}let t=e;if((!t.ssid||typeof t.ssid!="string"||!t.ssid.trim())&&r.push({field:"wifi.ssid",value:t.ssid,message:"is required and must be non-empty"}),(!t.password||typeof t.password!="string")&&r.push({field:"wifi.password",value:t.password,message:"is required and must be a string"}),t.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(t.encryption)||r.push({field:"wifi.encryption",value:t.encryption,message:`must be one of: ${o.join(", ")}`})}t.hidden!==void 0&&typeof t.hidden!="boolean"&&r.push({field:"wifi.hidden",value:t.hidden,message:"must be a boolean"})}function ct(e,r){if(!e||typeof e!="object"){r.push({field:"vcard.data",value:e,message:"must be an object"});return}let t=e;(!t.name||typeof t.name!="string"||!t.name.trim())&&r.push({field:"vcard.name",value:t.name,message:"is required and must be non-empty"}),t.email!==void 0&&(typeof t.email!="string"||!ce(t.email))&&r.push({field:"vcard.email",value:t.email,message:"must be a valid email address"}),t.phone!==void 0&&(typeof t.phone!="string"||!H(t.phone))&&r.push({field:"vcard.phone",value:t.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),t.url!==void 0&&(typeof t.url!="string"||!ue(t.url))&&r.push({field:"vcard.url",value:t.url,message:"must be a valid URL"}),t.address!==void 0&&typeof t.address!="object"&&r.push({field:"vcard.address",value:t.address,message:"must be an object"})}function ut(e,r){if(!e||typeof e!="object"){r.push({field:"calendar.data",value:e,message:"must be an object"});return}let t=e;(!t.title||typeof t.title!="string"||!t.title.trim())&&r.push({field:"calendar.title",value:t.title,message:"is required and must be non-empty"});let o=ie(t.startDate);if(o||r.push({field:"calendar.startDate",value:t.startDate,message:"is required and must be a valid Date object or ISO string"}),t.endDate!==void 0){let n=ie(t.endDate);n?o&&n<o&&r.push({field:"calendar.endDate",value:t.endDate,message:"must be after startDate"}):r.push({field:"calendar.endDate",value:t.endDate,message:"must be a valid Date object or ISO string"})}}function lt(e,r){let t=e;(!t.email||typeof t.email!="string"||!ce(t.email))&&r.push({field:"email.email",value:t.email,message:"is required and must be a valid email address"}),t.subject!==void 0&&typeof t.subject!="string"&&r.push({field:"email.subject",value:t.subject,message:"must be a string"}),t.body!==void 0&&typeof t.body!="string"&&r.push({field:"email.body",value:t.body,message:"must be a string"})}function ft(e,r){let t=e;(!t.phone||typeof t.phone!="string"||!H(t.phone))&&r.push({field:"sms.phone",value:t.phone,message:"is required and must be a valid phone number"}),t.message!==void 0&&typeof t.message!="string"&&r.push({field:"sms.message",value:t.message,message:"must be a string"})}function dt(e,r){let t=e;(!t.phone||typeof t.phone!="string"||!H(t.phone))&&r.push({field:"phone.phone",value:t.phone,message:"is required and must be a valid phone number"})}function mt(e,r){let t=e;(!t.url||typeof t.url!="string"||!ue(t.url))&&r.push({field:"url.url",value:t.url,message:"is required and must be a valid URL"})}function ie(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let r=new Date(e);return isNaN(r.getTime())?null:r}return null}var b={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},k={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function de(e){if(!e){let{logo:t,...o}=b;return o}return le(e),{size:e.size??b.size,margin:e.margin??b.margin,backgroundColor:e.backgroundColor??b.backgroundColor,eyes:{shape:e.eyes?.shape??b.eyes.shape,color:e.eyes?.color??b.eyes.color},pupils:{color:e.pupils?.color??b.pupils.color},dots:{shape:e.dots?.shape??b.dots.shape,color:e.dots?.color??b.dots.color,scale:e.dots?.scale??b.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??b.logo.scale}:void 0,border:{shape:e.border?.shape??b.border.shape,width:e.border?.width??b.border.width,color:e.border?.color??b.border.color,style:e.border?.style??b.border.style},output:e.output??b.output}}function me(e){return e?(fe(e),{margin:e.margin??k.margin,darkChar:e.darkChar??k.darkChar,lightChar:e.lightChar??k.lightChar}):{...k}}function ge(e){return/^\d+$/.test(e)?1:[...e].every(r=>M.includes(r))?2:4}function gt(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)r.push(n>>a&1)}return r}function ht(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=M.indexOf(e[t])*45+M.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=M.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function pt(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function bt(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=A(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function yt(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function $t(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function he(e,r,t){let o=ge(e),n,s;o===1?(n=gt(e),s=e.length):o===2?(n=ht(e),s=e.length):(n=pt(e),s=new TextEncoder().encode(e).length);let a=bt(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=yt(a);return $t(c,t)}function T(e,r){let t=ge(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=A(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+u+l;if(Math.ceil(d/8)<=r[c-1])return c}let n=A(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function pe(e,r){if(r)try{if(T(e,C.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let t=["H","Q","M","L"];for(let o of t)try{if(T(e,C[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var O=new Array(256),X=new Array(256);function xt(){let e=1;for(let r=0;r<255;r++)O[r]=e,X[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)O[r]=O[r-255]}xt();function ye(e,r){return e===0||r===0?0:O[X[e]+X[r]]}function vt(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=ye(r[s],O[t]);r=n}return r}function be(e,r){let t=vt(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=ye(t[a],s)}return o.slice(e.length)}function $e(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let d=e.slice(u,u+a);o.push(d);let f=be(d,r);n.push(f),u+=a}for(let l=0;l<i;l++){let d=e.slice(u,u+c);o.push(d);let f=be(d,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function xe(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function ve(e){let r=I(e);return Array.from({length:r},()=>Array(r).fill(!1))}function Ce(e){let r=I(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=D[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function Z(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function Ct(e,r,t){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[r+o][t+n]=s||a}}function Re(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function Me(e){Z(e,0,0),Z(e,0,e.length-7),Z(e,e.length-7,0)}function Ie(e,r){let t=e.length,o=D[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||Ct(e,n,s)}function Se(e,r){e[4*r+9][8]=!0}function Ee(e,r,t){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function K(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function Rt(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let d=1;d<r;d++)e[a][d]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][d],u=1),e[d][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[d][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function we(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);K(i,r,a),o(i,t,a);let c=Rt(i);c<s&&(s=c,n=a)}return n}function J(e,r,t){let o=e.length,n=N[r]<<3|t,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function Oe(e,r){if(r<7)return;let t=e.length,o=se[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function Pe(e,r){return N[e]<<3|r}function De(e,r,t,o,n){let s=ve(e),a=Ce(e);Me(s),Re(s),Ie(s,e),Se(s,e),Ee(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??we(s,a,r,J);return K(s,a,c),J(s,r,c),Oe(s,e),{matrix:s,mask:c,formatInfo:n?Pe(r,c):void 0,unmaskedMatrix:i}}function ee(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function Ae(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Le(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function Mt(e,r,t,o,n,s,a){let i=S[t]||S.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function It(e,r,t,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let c=i.match(/viewBox=["']([^"']+)["']/),u=c?c[1]:"0 0 100 100",l=i.match(/<svg([\s\S]*?)>/i),d="";if(l){let m=l[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(d=" "+m.join(" "))}let f=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
|
|
21
|
-
<svg width="${o}" height="${o}" viewBox="${u}"${
|
|
22
|
-
${
|
|
20
|
+
${r}`),this.name="QRValidationError",this.errors=t}};function st(e){let t={...e};return t.backgroundColor===""&&(t.backgroundColor=void 0),t.eyes&&(t.eyes={...t.eyes},t.eyes.shape===""&&(t.eyes.shape=void 0),t.eyes.color===""&&(t.eyes.color=void 0)),t.pupils&&(t.pupils={...t.pupils},t.pupils.color===""&&(t.pupils.color=void 0)),t.dots&&(t.dots={...t.dots},t.dots.shape===""&&(t.dots.shape=void 0),t.dots.color===""&&(t.dots.color=void 0)),t.border&&(t.border={...t.border},t.border.shape===""&&(t.border.shape=void 0),t.border.color===""&&(t.border.color=void 0),t.border.style===""&&(t.border.style=void 0)),t}function at(e){let t={...e};return t.darkChar===""&&(t.darkChar=void 0),t.lightChar===""&&(t.lightChar=void 0),t}function I(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function E(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/,s=r.match(n);if(s){let[,u,c,f,d]=s,m=parseInt(u,10),g=parseInt(c,10),p=parseInt(f,10);if(m<0||m>255||g<0||g>255||p<0||p>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(d!==void 0){let h=parseFloat(d);if(isNaN(h)||h<0||h>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let a=/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/,i=r.match(a);if(i){let[,u,c,f,d]=i,m=parseInt(u,10),g=parseInt(c,10),p=parseInt(f,10);if(m<0||m>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(g<0||g>100||p<0||p>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(d!==void 0){let h=parseFloat(d);if(isNaN(h)||h<0||h>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}return["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","transparent"].includes(r.toLowerCase())?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function W(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function it(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2)return{field:t,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!lt(s))return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function lt(e){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(e)&&e.length%4===0}catch{return!1}}function le(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function H(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function ue(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function ce(e){let t=st(e),r=[];if(t.size!==void 0){let o=I(t.size,"size",21,null,!0);o&&r.push(o)}if(t.margin!==void 0){let o=I(t.margin,"margin",0,null,!0);o&&r.push(o)}if(t.backgroundColor!==void 0){let o=E(t.backgroundColor,"backgroundColor");o&&r.push(o)}if(t.eyes?.shape!==void 0){let o=W(t.eyes.shape,"eyes.shape",S);o&&r.push(o)}if(t.eyes?.color!==void 0){let o=E(t.eyes.color,"eyes.color");o&&r.push(o)}if(t.pupils?.color!==void 0){let o=E(t.pupils.color,"pupils.color");o&&r.push(o)}if(t.dots?.shape!==void 0){let o=W(t.dots.shape,"dots.shape",w);o&&r.push(o)}if(t.dots?.color!==void 0){let o=E(t.dots.color,"dots.color");o&&r.push(o)}if(t.dots?.scale!==void 0){let o=I(t.dots.scale,"dots.scale",.75,1.25,!1);o&&r.push(o)}if(t.border?.shape!==void 0&&t.border.shape!=="none"){let o=W(t.border.shape,"border.shape",D);o&&r.push(o)}if(t.border?.width!==void 0){let o=I(t.border.width,"border.width",0,null,!0);o&&r.push(o)}if(t.border?.color!==void 0){let o=E(t.border.color,"border.color");o&&r.push(o)}if(t.border?.style!==void 0&&(typeof t.border.style!="string"||t.border.style!=="solid"&&t.border.style!=="dashed")&&r.push({field:"border.style",value:t.border.style,message:'must be either "solid" or "dashed"'}),t.logo){if(!t.logo.src||typeof t.logo.src!="string")r.push({field:"logo.src",value:t.logo.src,message:"must be a non-empty string"});else{let o=it(t.logo.src,"logo.src");o&&r.push(o)}if(t.logo.scale!==void 0){let o=I(t.logo.scale,"logo.scale",.1,.3,!1);o&&r.push(o)}}if(r.length>0)throw new x(r);return t}function de(e){let t=at(e),r=[];if(t.margin!==void 0){let o=I(t.margin,"margin",0,null,!0);o&&r.push(o)}if(t.darkChar!==void 0&&typeof t.darkChar!="string"&&r.push({field:"darkChar",value:t.darkChar,message:"must be a string"}),t.lightChar!==void 0&&typeof t.lightChar!="string"&&r.push({field:"lightChar",value:t.lightChar,message:"must be a string"}),r.length>0)throw new x(r);return t}function Y(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new x(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new x(t);let r=e;switch(r.type){case"wifi":{ut(e.data,t);break}case"vcard":{ct(e.data,t);break}case"calendar":{dt(e.data,t);break}case"email":{ft(e,t);break}case"sms":{mt(e,t);break}case"phone":{gt(e,t);break}case"url":{pt(e,t);break}default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new x(t)}function ut(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function ct(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!le(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!H(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!ue(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function dt(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=ie(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=ie(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function ft(e,t){let r=e;(!r.email||typeof r.email!="string"||!le(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function mt(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!H(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function gt(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!H(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function pt(e,t){let r=e;(!r.url||typeof r.url!="string"||!ue(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}function ie(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}var b={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},L={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function fe(e){if(!e){let{logo:o,...n}=b;return n}let t=ce(e);return{size:t.size??b.size,margin:t.margin??b.margin,backgroundColor:t.backgroundColor??b.backgroundColor,eyes:{shape:t.eyes?.shape??b.eyes.shape,color:t.eyes?.color??b.eyes.color},pupils:{color:t.pupils?.color??b.pupils.color},dots:{shape:t.dots?.shape??b.dots.shape,color:t.dots?.color??b.dots.color,scale:t.dots?.scale??b.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??b.logo.scale}:void 0,border:{shape:t.border?.shape??b.border.shape,width:t.border?.width??b.border.width,color:t.border?.color??b.border.color,style:t.border?.style??b.border.style},output:t.output??b.output}}function me(e){if(!e)return{...L};let t=de(e);return{margin:t.margin??L.margin,darkChar:t.darkChar??L.darkChar,lightChar:t.lightChar??L.lightChar}}function ge(e){return/^\d+$/.test(e)?1:[...e].every(t=>R.includes(t))?2:4}function ht(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)t.push(n>>a&1)}return t}function bt(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=R.indexOf(e[r])*45+R.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=R.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function yt(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function $t(e,t,r,o){let n=[];for(let a=3;a>=0;a--)n.push(t>>a&1);let s=A(t,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...e]}function vt(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function xt(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function pe(e,t,r){let o=ge(e),n,s;o===1?(n=ht(e),s=e.length):o===2?(n=bt(e),s=e.length):(n=yt(e),s=new TextEncoder().encode(e).length);let a=$t(n,o,s,t),i=Math.min(4,r*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=vt(a);return xt(l,r)}function T(e,t){let r=ge(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let u=A(r,l),c=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+u+c;if(Math.ceil(f/8)<=t[l-1])return l}let n=A(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function he(e,t){if(t)try{if(T(e,C.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(T(e,C[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var k=new Array(256),X=new Array(256);function Ct(){let e=1;for(let t=0;t<255;t++)k[t]=e,X[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)k[t]=k[t-255]}Ct();function ye(e,t){return e===0||t===0?0:k[X[e]+X[t]]}function It(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=ye(t[s],k[r]);t=n}return t}function be(e,t){let r=It(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=ye(r[a],s)}return o.slice(e.length)}function $e(e,t,r){let o=[],n=[],[s,a,i,l]=r,u=0;for(let c=0;c<s;c++){let f=e.slice(u,u+a);o.push(f);let d=be(f,t);n.push(d),u+=a}for(let c=0;c<i;c++){let f=e.slice(u,u+l);o.push(f);let d=be(f,t);n.push(d),u+=l}return{dataBlocks:o,ecBlocks:n}}function ve(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&r.push(a[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let a of t)s<a.length&&r.push(a[s]);return r}function xe(e){let t=M(e);return Array.from({length:t},()=>Array(t).fill(!1))}function Ce(e){let t=M(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=P[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function Z(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,a=r+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||l}}function Rt(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[t+o][r+n]=s||a}}function Ie(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function Re(e){Z(e,0,0),Z(e,0,e.length-7),Z(e,e.length-7,0)}function Me(e,t){let r=e.length,o=P[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||Rt(e,n,s)}function Se(e,t){e[4*t+9][8]=!0}function we(e,t,r){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!t[a][i-l]){let u=n<r.length?r[n]:!1;e[a][i-l]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function K(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function Mt(e){let t=e.length,r=0;for(let a=0;a<t;a++){let i=e[a][0],l=e[0][a],u=1,c=1;for(let f=1;f<t;f++)e[a][f]===i?u++:(u>=5&&(r+=3+(u-5)),i=e[a][f],u=1),e[f][a]===l?c++:(c>=5&&(r+=3+(c-5)),l=e[f][a],c=1);u>=5&&(r+=3+(u-5)),c>=5&&(r+=3+(c-5))}for(let a=0;a<t-1;a++)for(let i=0;i<t-1;i++){let l=e[a][i];e[a][i+1]===l&&e[a+1][i]===l&&e[a+1][i+1]===l&&(r+=3)}for(let a=0;a<t;a++){let i=0,l=0;for(let u=0;u<t;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(e[u][a]?1:0),u>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let a=0;a<t;a++)for(let i=0;i<t;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Ee(e,t,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);K(i,t,a),o(i,r,a);let l=Mt(i);l<s&&(s=l,n=a)}return n}function J(e,t,r){let o=e.length,n=V[t]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?e[8][i]=l:i===6?e[8][7]=l:i===7?e[8][8]=l:i===8?e[7][8]=l:e[5-(i-9)][8]=l,i<=6?e[o-1-i][8]=l:e[8][o-8+(i-7)]=l}}function ke(e,t){if(t<7)return;let r=e.length,o=se[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;e[a][i]=s;let l=r-11+n%3,u=Math.floor(n/3);e[l][u]=s}}function Oe(e,t){return V[e]<<3|t}function Pe(e,t,r,o,n){let s=xe(e),a=Ce(e);Re(s),Ie(s),Me(s,e),Se(s,e),we(s,a,r);let i=n?s.map(u=>[...u]):void 0,l=o??Ee(s,a,t,J);return K(s,a,l),J(s,t,l),ke(s,e),{matrix:s,mask:l,formatInfo:n?Oe(t,l):void 0,unmaskedMatrix:i}}function ee(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function Ae(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function De(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function St(e,t,r,o,n,s,a){let i=S[r]||S.square,l=i.renderSVG(e,t,7*a,o),u=i.renderSVG(e+a,t+a,5*a,s),c=i.renderSVG(e+2*a,t+2*a,3*a,n);return l+u+c}function wt(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),u=l?l[1]:"0 0 100 100",c=i.match(/<svg([\s\S]*?)>/i),f="";if(c){let m=c[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
21
|
+
<svg width="${o}" height="${o}" viewBox="${u}"${f}>
|
|
22
|
+
${d}
|
|
23
23
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${
|
|
25
|
-
`;for(let i=0;i<e.matrixSize;i++){s+=o.repeat(
|
|
26
|
-
`}for(let i=0;i<
|
|
27
|
-
`;return s}var B=null,Be=!1;async function
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
24
|
+
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function Et(e,t,r,o,n){let s=e.matrixSize,a="",i=w[r]||w.classic;if(r==="classic"){a=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let u=0;u<s;u++)if(e.modules[l][u]&&!ee(l,u,s)){let c=u*t,f=l*t,d=n*t,m=(1-n)*t/2,g=c+m,p=f+m;a+=`M${g},${p}h${d}v${d}h${-d}z`}return a+='"/>',a}for(let l=0;l<s;l++)for(let u=0;u<s;u++)if(e.modules[l][u]&&!ee(l,u,s)){let c=u*t,f=l*t,d=n*t,m=(1-n)*t/2,g=c+m,p=f+m,h={qrcode:e.modules,qrSize:s,row:l,col:u};a+=i.renderSVG(g,p,d,o,h)}return a}function Le(e,t){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=t,l=r/e.matrixSize,u=t.border.shape==="none"?0:t.border.width,c=r+2*o+2*u,f=o+u,d=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}">`;if(d+=`<rect width="${c}" height="${c}" fill="${n}"/>`,t.border.shape!=="none"&&u>0){let y=D[t.border.shape];if(y){let $={borderWidth:u,borderStyle:t.border.style};d+=y.renderSVG(0,0,c,t.border.color,$)}}t.border.shape!=="none"&&u>0&&(d+=`<rect x="${f}" y="${f}" width="${r}" height="${r}" fill="${n}"/>`),d+=`<g transform="translate(${f}, ${f})">`;let m=Ae(e.matrixSize),g="";for(let y of m)g+=St(y.x*l,y.y*l,s.shape,s.color,a.color,n,l);let p=Et(e,l,i.shape,i.color,i.scale);d+=g+p+"</g>";let h="";if(t.logo){let y=De(e.matrixSize,t.logo.scale)*l,$=c/2;h=wt(t.logo.src,$,$,y)}return d+=h+"</svg>",d}function Te(e,t){let{margin:r,lightChar:o,darkChar:n}=t,s="",a=e.matrixSize+r*2;for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
25
|
+
`;for(let i=0;i<e.matrixSize;i++){s+=o.repeat(r);for(let l=0;l<e.matrixSize;l++)s+=e.modules[i][l]?n:o;s+=o.repeat(r)+`
|
|
26
|
+
`}for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
27
|
+
`;return s}var B=null,Be=!1;async function kt(){if(B)return B;if(Be)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");Be=!0;try{return B=(await import("@resvg/resvg-js")).Resvg,B}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Ne(e,t){let{output:r,size:o,margin:n,border:s}=t,a=s.shape==="none"?0:s.width,i=o+2*n+2*a,l=await kt(),f=new l(e,{fitTo:{mode:"width",value:i}}).render().asPng(),d=Buffer.from(f);return r.type==="dataURL"?`data:image/png;base64,${d.toString("base64")}`:d}async function Ve(e,t){let{format:r,type:o}=t.output;return r==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Ne(e,t)}function te(e){if(typeof e=="string")return e;switch(e.type){case"url":return Ot(e.url);case"vcard":return Pt(e.data);case"wifi":return At(e.data);case"calendar":return Dt(e.data);case"email":return Lt(e.email,e.subject,e.body);case"sms":return Tt(e.phone,e.message);case"phone":return Bt(e.phone)}}function Ot(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function Pt(e){let t=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&t.push(`TEL:${e.phone}`),e.email&&t.push(`EMAIL:${e.email}`),e.organization&&t.push(`ORG:${e.organization}`),e.url&&t.push(`URL:${e.url}`),e.title&&t.push(`TITLE:${e.title}`),e.note&&t.push(`NOTE:${e.note}`),e.address){let{street:r,city:o,state:n,zip:s,country:a}=e.address,i=["","",r||"",o||"",n||"",s||"",a||""];t.push(`ADR:${i.join(";")}`)}return t.push("END:VCARD"),t.join(`
|
|
28
|
+
`)}function At(e){let t=e.encryption||"WPA",r=e.hidden?"H:true;":"",o=qe(e.ssid),n=qe(e.password);return`WIFI:T:${t};S:${o};P:${n};${r};`}function qe(e){return e.replace(/([\\;,":])/g,"\\$1")}function Dt(e){let t=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${t(e.startDate)}`,`DTEND:${t(e.endDate)}`];return e.location&&r.push(`LOCATION:${e.location}`),e.description&&r.push(`DESCRIPTION:${e.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
29
|
+
`)}function Lt(e,t,r){let o=`mailto:${e}`,n=[];return t&&n.push(`subject=${encodeURIComponent(t)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function Tt(e,t){return t?`sms:${e}:${t}`:`sms:${e}`}function Bt(e){return`tel:${e}`}function Nt(e,t){let r=[];for(let n of e)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=ae[t-1];for(let n=0;n<o;n++)r.push(!1);return r}function ze(e,t){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=he(e,t),o=C[r],n=T(e,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${e.length} characters. Maximum capacity at EC level ${r}: ~${C[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=pe(e,n,o[n-1]),a=ne[r][n-1],i=oe[r][n-1],{dataBlocks:l,ecBlocks:u}=$e(s,a,i),c=ve(l,u),f=Nt(c,n),{matrix:d,mask:m}=Pe(n,r,f);return{version:n,matrixSize:M(n),modules:d,mask:m,errorCorrectionLevel:r}}async function Qe(e,t){Y(e);let r=te(e),o=fe(t),n=ze(r,!!o.logo),s=Le(n,o);return await Ve(s,o)}function Fe(e,t){Y(e);let r=te(e),o=me(t),n=ze(r,!1);return Te(n,o)}0&&(module.exports={BorderShape,BorderStyle,DotShape,EyeFrameShape,QRValidationError,genQrImage,genQrText});
|
package/dist/node.mjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
var Z={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},C={L:[19,34,55,80,108,136,156,194,232,274],M:[16,28,44,64,86,108,124,154,182,216],Q:[13,22,34,48,62,76,88,110,132,154],H:[9,16,26,36,46,60,66,86,100,122]},K={L:[[1,19,0,0],[1,34,0,0],[1,55,0,0],[1,80,0,0],[1,108,0,0],[2,68,0,0],[2,78,0,0],[2,97,0,0],[2,116,0,0],[2,68,2,69]],M:[[1,16,0,0],[1,28,0,0],[1,44,0,0],[2,32,0,0],[2,43,0,0],[4,27,0,0],[4,31,0,0],[2,38,2,39],[3,36,2,37],[4,43,1,44]],Q:[[1,13,0,0],[1,22,0,0],[2,17,0,0],[2,24,0,0],[2,15,2,16],[4,19,0,0],[2,14,4,15],[4,18,2,19],[4,16,4,17],[6,19,2,20]],H:[[1,9,0,0],[1,16,0,0],[2,13,0,0],[4,9,0,0],[2,11,2,12],[4,15,0,0],[4,13,1,14],[4,14,2,15],[4,12,4,13],[6,15,2,16]]},
|
|
1
|
+
var Z={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},C={L:[19,34,55,80,108,136,156,194,232,274],M:[16,28,44,64,86,108,124,154,182,216],Q:[13,22,34,48,62,76,88,110,132,154],H:[9,16,26,36,46,60,66,86,100,122]},K={L:[[1,19,0,0],[1,34,0,0],[1,55,0,0],[1,80,0,0],[1,108,0,0],[2,68,0,0],[2,78,0,0],[2,97,0,0],[2,116,0,0],[2,68,2,69]],M:[[1,16,0,0],[1,28,0,0],[1,44,0,0],[2,32,0,0],[2,43,0,0],[4,27,0,0],[4,31,0,0],[2,38,2,39],[3,36,2,37],[4,43,1,44]],Q:[[1,13,0,0],[1,22,0,0],[2,17,0,0],[2,24,0,0],[2,15,2,16],[4,19,0,0],[2,14,4,15],[4,18,2,19],[4,16,4,17],[6,19,2,20]],H:[[1,9,0,0],[1,16,0,0],[2,13,0,0],[4,9,0,0],[2,11,2,12],[4,15,0,0],[4,13,1,14],[4,14,2,15],[4,12,4,13],[6,15,2,16]]},R="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",qe={1:[10,12,14],2:[9,11,13],4:[8,16,16]},N={L:1,M:0,Q:3,H:2},O=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],J=[31892,34236,39577,42195],ee=[0,7,7,7,7,7,0,0,0,0];function M(t){return t*4+17}function P(t,e){let r=e<10?0:e<27?1:2;return qe[t][r]}var te=(r=>(r.SQUARE="square",r.SQUIRCLE="squircle",r))(te||{}),re=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(re||{}),ne=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(ne||{}),oe=(r=>(r.SOLID="solid",r.DASHED="dashed",r))(oe||{});function v(t,e){let r=e/2;return t<=-r?0:t>=r?255:Math.round((t+r)/e*255)}function q(t,e,r=.01){return v(e-t,r)}function ze(t,e,r,o){let n=Math.abs(t)-r+o,s=Math.abs(e)-r+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function Qe(t,e){let n=e*3,s=e*2,a=n+s,i=Math.max(1,Math.round(t/a)),l=t/i,u=l*(3/5),c=l*(2/5),f=c/2;return{dashArray:`${u} ${c}`,offset:f}}function z(t,e){let r=e*3,o=e*2,n=r+o,s=Math.round(t/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=t/s,i=a*.6,l=a*.4,u=i/2;return{dashArray:`${i} ${l}`,offset:u}}function V(t,e,r,o,n){return n==="circle"?Fe(t,e,r,o):n==="squircle"?je(t,e,r,o):Ue(t,e,r,o)}function Fe(t,e,r,o){let s=(Math.atan2(e,t)+Math.PI)/(2*Math.PI),a=r/2-o/2,i=2*Math.PI*a,l=o*3,u=o*2,c=Math.floor(i/(l+u)),f=c%2===0?c:c-1,d=Math.max(4,f);return s*d%1<.6}function je(t,e,r,o){let s=r/2-o/2,a=r*Q,i=Math.max(0,a-o/2),l=s-i,u=2*l,c=.5*Math.PI*i,f=4*u+4*c,d=_e(t,e,l,i,u,c,f),{dashArray:m}=z(f,o),[g,p]=m.split(" ").map(Number),h=g+p;return(d+g/2)%h<g}function _e(t,e,r,o,n,s,a){if(e<-r)if(t>r){let i=Math.atan2(e- -r,t-r)+Math.PI/2;return r+i*o}else if(t<-r){let i=Math.atan2(e- -r,t- -r)+Math.PI;return r+3*s+3*n+i*o}else return t>=0?t:a+t;else if(e>r)if(t>r){let i=Math.atan2(e-r,t-r);return r+s+n+i*o}else if(t<-r){let i=Math.atan2(e-r,t- -r)-Math.PI/2;return r+2*s+2*n+i*o}else return r+2*s+n+(r-t);else return t>r?r+s+(e- -r):t<-r?r+3*s+2*n+(r-e):t>=0?t:a+t}function Ue(t,e,r,o){let n=r/2,s=Math.abs(t),i=Math.abs(e)>=s?n+t:n+e,l=r-o,u=3,c=2,f=o*(u+c),d=Math.max(1,Math.round(l/f)),m=l/d,g=m*(u/(u+c)),h=(m-g)/2;return(i+h)%m<g}var Q=.09,Ge={EYE_FRAME:.90909},S={square:{renderSVG(t,e,r,o){return`<rect x="${t}" y="${e}" width="${r}" height="${r}" fill="${o}"/>`},renderPixel(t,e,r,o){let n=r/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(t),n-Math.abs(e));return v(a,s)}},squircle:{renderSVG(t,e,r,o){let n=r/2,s=n*Ge.EYE_FRAME,a=t+n,i=e+n;return`<path d="${`M${a},${i-n}
|
|
2
2
|
C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
|
|
3
3
|
S${a+s},${i+n} ${a},${i+n}
|
|
4
4
|
S${a-n},${i+s} ${a-n},${i}
|
|
5
|
-
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,
|
|
6
|
-
H${
|
|
7
|
-
A${
|
|
5
|
+
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(t,e,r,o){let n=r/2,s=o?.pixelSize??.01,a=4,i=Math.abs(t),l=Math.abs(e),u=i/n,c=l/n;if(i<.001&&l<.001)return 255;let f=Math.pow(u,a)+Math.pow(c,a),d=a/n*Math.sqrt(Math.pow(u,2*a-2)+Math.pow(c,2*a-2)),m=(1-f)/d;return v(m,s)}}},w={classic:{renderSVG(){return""},renderPixel(t,e,r,o){let n=r/2,s=o?.pixelSize??.01;if(r>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:l,col:u}=o,c=o.qrSize||i.length,f=u>0&&i[l][u-1],d=u<c-1&&i[l][u+1],m=l>0&&i[l-1][u],g=l<c-1&&i[l+1][u],p=f?1/0:n+t,h=d?1/0:n-t,y=m?1/0:n+e,$=g?1/0:n-e,B=Math.min(Math.min(p,h),Math.min(y,$));return v(B,s)}let a=Math.min(n-Math.abs(t),n-Math.abs(e));return v(a,s)}},dots:{renderSVG(t,e,r,o){let n=t+r/2,s=e+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(t,e,r,o){let n=r*.35,s=o?.pixelSize??.01,a=Math.sqrt(t*t+e*e);return q(a,n,s)}},square:{renderSVG(t,e,r,o){let n=r*.7,s=(r-n)/2,a=t+s,i=e+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(t,e,r,o){let s=r*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(t),s-Math.abs(e));return v(i,a)}}},A={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(t,e,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,m=r-s,{dashArray:g,offset:p}=Qe(m,s);return`<rect x="${t+d}" y="${e+d}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${-p}"/>`}let i=`M${t},${e}h${r}v${r}h${-r}z`,l=t+s,u=e+s,c=r-s*2,f=`M${l},${u}h${c}v${c}h${-c}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(t,e,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=r/2,l=i-n,u=i-Math.abs(t),c=i-Math.abs(e),f=l-Math.abs(t),d=l-Math.abs(e),m=Math.min(u,c),g=Math.min(f,d);if(m>=0&&g<=0){if(s==="dashed"&&!V(t,e,r,n,"square"))return 0;let p=v(m,a),h=255-v(g,a);return Math.min(p,h)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(t,e,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=t+i,u=e+i,c=i-s/2,f=r*Q,d=Math.max(0,f-s/2),m=c-d,g=`M${l},${u-c}
|
|
6
|
+
H${l+m}
|
|
7
|
+
A${d},${d} 0 0 1 ${l+c},${u-m}
|
|
8
8
|
V${u+m}
|
|
9
|
-
A${
|
|
10
|
-
H${
|
|
11
|
-
A${
|
|
9
|
+
A${d},${d} 0 0 1 ${l+m},${u+c}
|
|
10
|
+
H${l-m}
|
|
11
|
+
A${d},${d} 0 0 1 ${l-c},${u+m}
|
|
12
12
|
V${u-m}
|
|
13
|
-
A${
|
|
14
|
-
Z`;if(a==="dashed"){let
|
|
15
|
-
A${u},${u} 0 1,1 ${i},${
|
|
16
|
-
A${u},${u} 0 1,1 ${i},${
|
|
17
|
-
A${
|
|
18
|
-
A${
|
|
13
|
+
A${d},${d} 0 0 1 ${l-m},${u-c}
|
|
14
|
+
Z`;if(a==="dashed"){let p=2*m,h=.5*Math.PI*d,y=4*p+4*h,{dashArray:$,offset:B}=z(y,s);return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${$}" stroke-dashoffset="${B}"/>`}return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(t,e,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,l=r/2-n/2,u=r*Q,c=Math.max(0,u-n/2),f=Math.abs(ze(t,e,l,c)),d=n/2-f;return d>-a?s==="dashed"&&!V(t,e,r,n,"squircle")?0:v(d,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(t,e,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=t+r/2,l=e+r/2,u=r/2;if(a==="dashed"){let m=u-s/2,g=2*Math.PI*m,{dashArray:p,offset:h}=z(g,s);return`<circle cx="${i}" cy="${l}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${p}" stroke-dashoffset="${h}"/>`}let c=u-s,f=`M${i},${l-u}
|
|
15
|
+
A${u},${u} 0 1,1 ${i},${l+u}
|
|
16
|
+
A${u},${u} 0 1,1 ${i},${l-u}Z`,d=`M${i},${l-c}
|
|
17
|
+
A${c},${c} 0 1,0 ${i},${l+c}
|
|
18
|
+
A${c},${c} 0 1,0 ${i},${l-c}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(t,e,r,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=r/2,l=i-n,u=Math.sqrt(t*t+e*e);if(u<=i&&u>=l){if(s==="dashed"&&!V(t,e,r,n,"circle"))return 0;let c=q(u,i,a),f=255-q(u,l,a);return Math.min(c,f)}return 0}}};var x=class extends Error{constructor(e){let r=e.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
19
|
`);super(`QR Code validation failed:
|
|
20
|
-
${t}`),this.name="QRValidationError",this.errors=r}};function R(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function w(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function z(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function Ge(e,r){let t=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!t.test(e)&&!o)return{field:r,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2)return{field:r,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!He(s))return{field:r,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:r,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function He(e){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(e)&&e.length%4===0}catch{return!1}}function ae(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function j(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function ie(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function ce(e){let r=[];if(e.size!==void 0){let t=R(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=R(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=w(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=z(e.eyes.shape,"eyes.shape",S);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=w(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=w(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=z(e.dots.shape,"dots.shape",E);t&&r.push(t)}if(e.dots?.color!==void 0){let t=w(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=R(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=z(e.border.shape,"border.shape",A);t&&r.push(t)}if(e.border?.width!==void 0){let t=R(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=w(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo){if(!e.logo.src||typeof e.logo.src!="string")r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"});else{let t=Ge(e.logo.src,"logo.src");t&&r.push(t)}if(e.logo.scale!==void 0){let t=R(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}}if(r.length>0)throw new v(r)}function ue(e){let r=[];if(e.margin!==void 0){let t=R(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new v(r)}function _(e){let r=[];if(typeof e=="string"){if(e||r.push({field:"input",value:e,message:"string input cannot be empty"}),r.length>0)throw new v(r);return}if(!e||typeof e!="object"||!("type"in e))throw r.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new v(r);let t=e;switch(t.type){case"wifi":{Ye(e.data,r);break}case"vcard":{Xe(e.data,r);break}case"calendar":{Ze(e.data,r);break}case"email":{Ke(e,r);break}case"sms":{Je(e,r);break}case"phone":{et(e,r);break}case"url":{tt(e,r);break}default:r.push({field:"input.type",value:t.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(r.length>0)throw new v(r)}function Ye(e,r){if(!e||typeof e!="object"){r.push({field:"wifi.data",value:e,message:"must be an object"});return}let t=e;if((!t.ssid||typeof t.ssid!="string"||!t.ssid.trim())&&r.push({field:"wifi.ssid",value:t.ssid,message:"is required and must be non-empty"}),(!t.password||typeof t.password!="string")&&r.push({field:"wifi.password",value:t.password,message:"is required and must be a string"}),t.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(t.encryption)||r.push({field:"wifi.encryption",value:t.encryption,message:`must be one of: ${o.join(", ")}`})}t.hidden!==void 0&&typeof t.hidden!="boolean"&&r.push({field:"wifi.hidden",value:t.hidden,message:"must be a boolean"})}function Xe(e,r){if(!e||typeof e!="object"){r.push({field:"vcard.data",value:e,message:"must be an object"});return}let t=e;(!t.name||typeof t.name!="string"||!t.name.trim())&&r.push({field:"vcard.name",value:t.name,message:"is required and must be non-empty"}),t.email!==void 0&&(typeof t.email!="string"||!ae(t.email))&&r.push({field:"vcard.email",value:t.email,message:"must be a valid email address"}),t.phone!==void 0&&(typeof t.phone!="string"||!j(t.phone))&&r.push({field:"vcard.phone",value:t.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),t.url!==void 0&&(typeof t.url!="string"||!ie(t.url))&&r.push({field:"vcard.url",value:t.url,message:"must be a valid URL"}),t.address!==void 0&&typeof t.address!="object"&&r.push({field:"vcard.address",value:t.address,message:"must be an object"})}function Ze(e,r){if(!e||typeof e!="object"){r.push({field:"calendar.data",value:e,message:"must be an object"});return}let t=e;(!t.title||typeof t.title!="string"||!t.title.trim())&&r.push({field:"calendar.title",value:t.title,message:"is required and must be non-empty"});let o=se(t.startDate);if(o||r.push({field:"calendar.startDate",value:t.startDate,message:"is required and must be a valid Date object or ISO string"}),t.endDate!==void 0){let n=se(t.endDate);n?o&&n<o&&r.push({field:"calendar.endDate",value:t.endDate,message:"must be after startDate"}):r.push({field:"calendar.endDate",value:t.endDate,message:"must be a valid Date object or ISO string"})}}function Ke(e,r){let t=e;(!t.email||typeof t.email!="string"||!ae(t.email))&&r.push({field:"email.email",value:t.email,message:"is required and must be a valid email address"}),t.subject!==void 0&&typeof t.subject!="string"&&r.push({field:"email.subject",value:t.subject,message:"must be a string"}),t.body!==void 0&&typeof t.body!="string"&&r.push({field:"email.body",value:t.body,message:"must be a string"})}function Je(e,r){let t=e;(!t.phone||typeof t.phone!="string"||!j(t.phone))&&r.push({field:"sms.phone",value:t.phone,message:"is required and must be a valid phone number"}),t.message!==void 0&&typeof t.message!="string"&&r.push({field:"sms.message",value:t.message,message:"must be a string"})}function et(e,r){let t=e;(!t.phone||typeof t.phone!="string"||!j(t.phone))&&r.push({field:"phone.phone",value:t.phone,message:"is required and must be a valid phone number"})}function tt(e,r){let t=e;(!t.url||typeof t.url!="string"||!ie(t.url))&&r.push({field:"url.url",value:t.url,message:"is required and must be a valid URL"})}function se(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let r=new Date(e);return isNaN(r.getTime())?null:r}return null}var b={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},L={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function le(e){if(!e){let{logo:t,...o}=b;return o}return ce(e),{size:e.size??b.size,margin:e.margin??b.margin,backgroundColor:e.backgroundColor??b.backgroundColor,eyes:{shape:e.eyes?.shape??b.eyes.shape,color:e.eyes?.color??b.eyes.color},pupils:{color:e.pupils?.color??b.pupils.color},dots:{shape:e.dots?.shape??b.dots.shape,color:e.dots?.color??b.dots.color,scale:e.dots?.scale??b.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??b.logo.scale}:void 0,border:{shape:e.border?.shape??b.border.shape,width:e.border?.width??b.border.width,color:e.border?.color??b.border.color,style:e.border?.style??b.border.style},output:e.output??b.output}}function fe(e){return e?(ue(e),{margin:e.margin??L.margin,darkChar:e.darkChar??L.darkChar,lightChar:e.lightChar??L.lightChar}):{...L}}function de(e){return/^\d+$/.test(e)?1:[...e].every(r=>M.includes(r))?2:4}function rt(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)r.push(n>>a&1)}return r}function nt(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=M.indexOf(e[t])*45+M.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=M.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function ot(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function st(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=D(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function at(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function it(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function me(e,r,t){let o=de(e),n,s;o===1?(n=rt(e),s=e.length):o===2?(n=nt(e),s=e.length):(n=ot(e),s=new TextEncoder().encode(e).length);let a=st(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=at(a);return it(c,t)}function k(e,r){let t=de(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=D(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+u+l;if(Math.ceil(d/8)<=r[c-1])return c}let n=D(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ge(e,r){if(r)try{if(k(e,C.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let t=["H","Q","M","L"];for(let o of t)try{if(k(e,C[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var O=new Array(256),U=new Array(256);function ct(){let e=1;for(let r=0;r<255;r++)O[r]=e,U[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)O[r]=O[r-255]}ct();function pe(e,r){return e===0||r===0?0:O[U[e]+U[r]]}function ut(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=pe(r[s],O[t]);r=n}return r}function he(e,r){let t=ut(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=pe(t[a],s)}return o.slice(e.length)}function be(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let d=e.slice(u,u+a);o.push(d);let f=he(d,r);n.push(f),u+=a}for(let l=0;l<i;l++){let d=e.slice(u,u+c);o.push(d);let f=he(d,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function ye(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function $e(e){let r=I(e);return Array.from({length:r},()=>Array(r).fill(!1))}function xe(e){let r=I(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=P[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function W(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function lt(e,r,t){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[r+o][t+n]=s||a}}function ve(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function Ce(e){W(e,0,0),W(e,0,e.length-7),W(e,e.length-7,0)}function Re(e,r){let t=e.length,o=P[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||lt(e,n,s)}function Me(e,r){e[4*r+9][8]=!0}function Ie(e,r,t){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function G(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function ft(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let d=1;d<r;d++)e[a][d]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][d],u=1),e[d][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[d][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function Se(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);G(i,r,a),o(i,t,a);let c=ft(i);c<s&&(s=c,n=a)}return n}function H(e,r,t){let o=e.length,n=V[r]<<3|t,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function Ee(e,r){if(r<7)return;let t=e.length,o=J[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function we(e,r){return V[e]<<3|r}function Oe(e,r,t,o,n){let s=$e(e),a=xe(e);Ce(s),ve(s),Re(s,e),Me(s,e),Ie(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??Se(s,a,r,H);return G(s,a,c),H(s,r,c),Ee(s,e),{matrix:s,mask:c,formatInfo:n?we(r,c):void 0,unmaskedMatrix:i}}function Y(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function Pe(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function De(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function dt(e,r,t,o,n,s,a){let i=S[t]||S.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function mt(e,r,t,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let c=i.match(/viewBox=["']([^"']+)["']/),u=c?c[1]:"0 0 100 100",l=i.match(/<svg([\s\S]*?)>/i),d="";if(l){let m=l[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(d=" "+m.join(" "))}let f=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
|
|
21
|
-
<svg width="${o}" height="${o}" viewBox="${u}"${
|
|
22
|
-
${
|
|
20
|
+
${r}`),this.name="QRValidationError",this.errors=e}};function We(t){let e={...t};return e.backgroundColor===""&&(e.backgroundColor=void 0),e.eyes&&(e.eyes={...e.eyes},e.eyes.shape===""&&(e.eyes.shape=void 0),e.eyes.color===""&&(e.eyes.color=void 0)),e.pupils&&(e.pupils={...e.pupils},e.pupils.color===""&&(e.pupils.color=void 0)),e.dots&&(e.dots={...e.dots},e.dots.shape===""&&(e.dots.shape=void 0),e.dots.color===""&&(e.dots.color=void 0)),e.border&&(e.border={...e.border},e.border.shape===""&&(e.border.shape=void 0),e.border.color===""&&(e.border.color=void 0),e.border.style===""&&(e.border.style=void 0)),e}function He(t){let e={...t};return e.darkChar===""&&(e.darkChar=void 0),e.lightChar===""&&(e.lightChar=void 0),e}function I(t,e,r,o,n=!1){return typeof t!="number"||!isFinite(t)?{field:e,value:t,message:"must be a finite number"}:n&&!Number.isInteger(t)?{field:e,value:t,message:"must be an integer"}:t<r?{field:e,value:t,message:`must be at least ${r}`}:o!==null&&t>o?{field:e,value:t,message:`must be at most ${o}`}:null}function E(t,e){if(typeof t!="string")return{field:e,value:t,message:"must be a string"};let r=t.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/,s=r.match(n);if(s){let[,u,c,f,d]=s,m=parseInt(u,10),g=parseInt(c,10),p=parseInt(f,10);if(m<0||m>255||g<0||g>255||p<0||p>255)return{field:e,value:t,message:"RGB values must be between 0-255"};if(d!==void 0){let h=parseFloat(d);if(isNaN(h)||h<0||h>1)return{field:e,value:t,message:"RGBA alpha value must be between 0-1"}}return null}let a=/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/,i=r.match(a);if(i){let[,u,c,f,d]=i,m=parseInt(u,10),g=parseInt(c,10),p=parseInt(f,10);if(m<0||m>360)return{field:e,value:t,message:"HSL hue must be between 0-360"};if(g<0||g>100||p<0||p>100)return{field:e,value:t,message:"HSL saturation and lightness must be between 0-100%"};if(d!==void 0){let h=parseFloat(d);if(isNaN(h)||h<0||h>1)return{field:e,value:t,message:"HSLA alpha value must be between 0-1"}}return null}return["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","transparent"].includes(r.toLowerCase())?null:{field:e,value:t,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function F(t,e,r){if(typeof t!="string")return{field:e,value:t,message:"must be a string"};if(!(t in r)){let o=Object.keys(r).join(", ");return{field:e,value:t,message:`must be one of: ${o}`}}return null}function Ye(t,e){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=t.trim().startsWith("<svg");if(!r.test(t)&&!o)return{field:e,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(t.startsWith("data:")){let n=t.split(",");if(n.length!==2)return{field:e,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!Xe(s))return{field:e,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!t.includes("</svg>")?{field:e,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function Xe(t){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(t)&&t.length%4===0}catch{return!1}}function ae(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function j(t){return/^[\d\s\-+()]+$/.test(t)&&t.replace(/\D/g,"").length>=7}function ie(t){try{return new URL(t.startsWith("http")?t:`https://${t}`),!0}catch{return!1}}function le(t){let e=We(t),r=[];if(e.size!==void 0){let o=I(e.size,"size",21,null,!0);o&&r.push(o)}if(e.margin!==void 0){let o=I(e.margin,"margin",0,null,!0);o&&r.push(o)}if(e.backgroundColor!==void 0){let o=E(e.backgroundColor,"backgroundColor");o&&r.push(o)}if(e.eyes?.shape!==void 0){let o=F(e.eyes.shape,"eyes.shape",S);o&&r.push(o)}if(e.eyes?.color!==void 0){let o=E(e.eyes.color,"eyes.color");o&&r.push(o)}if(e.pupils?.color!==void 0){let o=E(e.pupils.color,"pupils.color");o&&r.push(o)}if(e.dots?.shape!==void 0){let o=F(e.dots.shape,"dots.shape",w);o&&r.push(o)}if(e.dots?.color!==void 0){let o=E(e.dots.color,"dots.color");o&&r.push(o)}if(e.dots?.scale!==void 0){let o=I(e.dots.scale,"dots.scale",.75,1.25,!1);o&&r.push(o)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let o=F(e.border.shape,"border.shape",A);o&&r.push(o)}if(e.border?.width!==void 0){let o=I(e.border.width,"border.width",0,null,!0);o&&r.push(o)}if(e.border?.color!==void 0){let o=E(e.border.color,"border.color");o&&r.push(o)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo){if(!e.logo.src||typeof e.logo.src!="string")r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"});else{let o=Ye(e.logo.src,"logo.src");o&&r.push(o)}if(e.logo.scale!==void 0){let o=I(e.logo.scale,"logo.scale",.1,.3,!1);o&&r.push(o)}}if(r.length>0)throw new x(r);return e}function ue(t){let e=He(t),r=[];if(e.margin!==void 0){let o=I(e.margin,"margin",0,null,!0);o&&r.push(o)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new x(r);return e}function _(t){let e=[];if(typeof t=="string"){if(t||e.push({field:"input",value:t,message:"string input cannot be empty"}),e.length>0)throw new x(e);return}if(!t||typeof t!="object"||!("type"in t))throw e.push({field:"input",value:t,message:"must be a string or structured content object with a type property"}),new x(e);let r=t;switch(r.type){case"wifi":{Ze(t.data,e);break}case"vcard":{Ke(t.data,e);break}case"calendar":{Je(t.data,e);break}case"email":{et(t,e);break}case"sms":{tt(t,e);break}case"phone":{rt(t,e);break}case"url":{nt(t,e);break}default:e.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(e.length>0)throw new x(e)}function Ze(t,e){if(!t||typeof t!="object"){e.push({field:"wifi.data",value:t,message:"must be an object"});return}let r=t;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&e.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&e.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||e.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&e.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function Ke(t,e){if(!t||typeof t!="object"){e.push({field:"vcard.data",value:t,message:"must be an object"});return}let r=t;(!r.name||typeof r.name!="string"||!r.name.trim())&&e.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!ae(r.email))&&e.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!j(r.phone))&&e.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!ie(r.url))&&e.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&e.push({field:"vcard.address",value:r.address,message:"must be an object"})}function Je(t,e){if(!t||typeof t!="object"){e.push({field:"calendar.data",value:t,message:"must be an object"});return}let r=t;(!r.title||typeof r.title!="string"||!r.title.trim())&&e.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=se(r.startDate);if(o||e.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=se(r.endDate);n?o&&n<o&&e.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):e.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function et(t,e){let r=t;(!r.email||typeof r.email!="string"||!ae(r.email))&&e.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&e.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&e.push({field:"email.body",value:r.body,message:"must be a string"})}function tt(t,e){let r=t;(!r.phone||typeof r.phone!="string"||!j(r.phone))&&e.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&e.push({field:"sms.message",value:r.message,message:"must be a string"})}function rt(t,e){let r=t;(!r.phone||typeof r.phone!="string"||!j(r.phone))&&e.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function nt(t,e){let r=t;(!r.url||typeof r.url!="string"||!ie(r.url))&&e.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}function se(t){if(t instanceof Date)return isNaN(t.getTime())?null:t;if(typeof t=="string"){let e=new Date(t);return isNaN(e.getTime())?null:e}return null}var b={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},D={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function ce(t){if(!t){let{logo:o,...n}=b;return n}let e=le(t);return{size:e.size??b.size,margin:e.margin??b.margin,backgroundColor:e.backgroundColor??b.backgroundColor,eyes:{shape:e.eyes?.shape??b.eyes.shape,color:e.eyes?.color??b.eyes.color},pupils:{color:e.pupils?.color??b.pupils.color},dots:{shape:e.dots?.shape??b.dots.shape,color:e.dots?.color??b.dots.color,scale:e.dots?.scale??b.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??b.logo.scale}:void 0,border:{shape:e.border?.shape??b.border.shape,width:e.border?.width??b.border.width,color:e.border?.color??b.border.color,style:e.border?.style??b.border.style},output:e.output??b.output}}function de(t){if(!t)return{...D};let e=ue(t);return{margin:e.margin??D.margin,darkChar:e.darkChar??D.darkChar,lightChar:e.lightChar??D.lightChar}}function fe(t){return/^\d+$/.test(t)?1:[...t].every(e=>R.includes(e))?2:4}function ot(t){let e=[];for(let r=0;r<t.length;r+=3){let o=t.substring(r,Math.min(r+3,t.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)e.push(n>>a&1)}return e}function st(t){let e=[];for(let r=0;r<t.length;r+=2)if(r+1<t.length){let o=R.indexOf(t[r])*45+R.indexOf(t[r+1]);for(let n=10;n>=0;n--)e.push(o>>n&1)}else{let o=R.indexOf(t[r]);for(let n=5;n>=0;n--)e.push(o>>n&1)}return e}function at(t){let e=[],r=new TextEncoder().encode(t);for(let o of r)for(let n=7;n>=0;n--)e.push(o>>n&1);return e}function it(t,e,r,o){let n=[];for(let a=3;a>=0;a--)n.push(e>>a&1);let s=P(e,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...t]}function lt(t){let e=[];for(let r=0;r<t.length;r+=8){let o=0;for(let n=0;n<8&&r+n<t.length;n++)o=o<<1|t[r+n];r+8>t.length&&(o<<=8-t.length%8),e.push(o)}return e}function ut(t,e){let r=[...t],o=[236,17],n=0;for(;r.length<e;)r.push(o[n]),n=1-n;return r}function me(t,e,r){let o=fe(t),n,s;o===1?(n=ot(t),s=t.length):o===2?(n=st(t),s=t.length):(n=at(t),s=new TextEncoder().encode(t).length);let a=it(n,o,s,e),i=Math.min(4,r*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=lt(a);return ut(l,r)}function L(t,e){let r=fe(t),o=r===4?new TextEncoder().encode(t).length:t.length;for(let l=1;l<=10;l++){let u=P(r,l),c=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+u+c;if(Math.ceil(f/8)<=e[l-1])return l}let n=P(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${e[9]} bytes. Current data length: ${t.length} characters (${o} bytes encoded).`)}function ge(t,e){if(e)try{if(L(t,C.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${t.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(L(t,C[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${t.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var k=new Array(256),U=new Array(256);function ct(){let t=1;for(let e=0;e<255;e++)k[e]=t,U[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)k[e]=k[e-255]}ct();function he(t,e){return t===0||e===0?0:k[U[t]+U[e]]}function dt(t){let e=[1];for(let r=0;r<t;r++){let o=e.length+1,n=new Array(o).fill(0);for(let s=0;s<e.length;s++)n[s]^=e[s],n[s+1]^=he(e[s],k[r]);e=n}return e}function pe(t,e){let r=dt(e),o=[...t,...new Array(e).fill(0)];for(let n=0;n<t.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=he(r[a],s)}return o.slice(t.length)}function be(t,e,r){let o=[],n=[],[s,a,i,l]=r,u=0;for(let c=0;c<s;c++){let f=t.slice(u,u+a);o.push(f);let d=pe(f,e);n.push(d),u+=a}for(let c=0;c<i;c++){let f=t.slice(u,u+l);o.push(f);let d=pe(f,e);n.push(d),u+=l}return{dataBlocks:o,ecBlocks:n}}function ye(t,e){let r=[],o=Math.max(...t.map(s=>s.length));for(let s=0;s<o;s++)for(let a of t)s<a.length&&r.push(a[s]);let n=Math.max(...e.map(s=>s.length));for(let s=0;s<n;s++)for(let a of e)s<a.length&&r.push(a[s]);return r}function $e(t){let e=M(t);return Array.from({length:e},()=>Array(e).fill(!1))}function ve(t){let e=M(t),r=Array.from({length:e},()=>Array(e).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][e-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[e-8+n][s]=!0;for(let n=8;n<e-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*t+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=e-8;n<e;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=e-8;n<e;n++)r[8][n]=!0;let o=O[t-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>e-9||n>e-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(t>=7){for(let n=0;n<6;n++)for(let s=e-11;s<e-8;s++)r[n][s]=!0;for(let n=e-11;n<e-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function G(t,e,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=e+o,a=r+n;if(s<0||s>=t.length||a<0||a>=t.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;t[s][a]=i||l}}function ft(t,e,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;t[e+o][r+n]=s||a}}function xe(t){let e=t.length;for(let r=8;r<e-8;r++)t[6][r]=r%2===0,t[r][6]=r%2===0}function Ce(t){G(t,0,0),G(t,0,t.length-7),G(t,t.length-7,0)}function Ie(t,e){let r=t.length,o=O[e-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||ft(t,n,s)}function Re(t,e){t[4*e+9][8]=!0}function Me(t,e,r){let o=t.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!e[a][i-l]){let u=n<r.length?r[n]:!1;t[a][i-l]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function W(t,e,r){let o=t.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(e[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(t[n][s]=!t[n][s])}}function mt(t){let e=t.length,r=0;for(let a=0;a<e;a++){let i=t[a][0],l=t[0][a],u=1,c=1;for(let f=1;f<e;f++)t[a][f]===i?u++:(u>=5&&(r+=3+(u-5)),i=t[a][f],u=1),t[f][a]===l?c++:(c>=5&&(r+=3+(c-5)),l=t[f][a],c=1);u>=5&&(r+=3+(u-5)),c>=5&&(r+=3+(c-5))}for(let a=0;a<e-1;a++)for(let i=0;i<e-1;i++){let l=t[a][i];t[a][i+1]===l&&t[a+1][i]===l&&t[a+1][i+1]===l&&(r+=3)}for(let a=0;a<e;a++){let i=0,l=0;for(let u=0;u<e;u++)i=i<<1&2047|(t[a][u]?1:0),u>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(t[u][a]?1:0),u>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=e*e;for(let a=0;a<e;a++)for(let i=0;i<e;i++)t[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Se(t,e,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=t.map(u=>[...u]);W(i,e,a),o(i,r,a);let l=mt(i);l<s&&(s=l,n=a)}return n}function H(t,e,r){let o=t.length,n=N[e]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?t[8][i]=l:i===6?t[8][7]=l:i===7?t[8][8]=l:i===8?t[7][8]=l:t[5-(i-9)][8]=l,i<=6?t[o-1-i][8]=l:t[8][o-8+(i-7)]=l}}function we(t,e){if(e<7)return;let r=t.length,o=J[e-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;t[a][i]=s;let l=r-11+n%3,u=Math.floor(n/3);t[l][u]=s}}function Ee(t,e){return N[t]<<3|e}function ke(t,e,r,o,n){let s=$e(t),a=ve(t);Ce(s),xe(s),Ie(s,t),Re(s,t),Me(s,a,r);let i=n?s.map(u=>[...u]):void 0,l=o??Se(s,a,e,H);return W(s,a,l),H(s,e,l),we(s,t),{matrix:s,mask:l,formatInfo:n?Ee(e,l):void 0,unmaskedMatrix:i}}function Y(t,e,r){return t<7&&e<7||t<7&&e>=r-7||t>=r-7&&e<7}function Oe(t){return[{x:0,y:0},{x:t-7,y:0},{x:0,y:t-7}]}function Pe(t,e){let o=Math.max(.1,Math.min(.3,e));return t*o}function gt(t,e,r,o,n,s,a){let i=S[r]||S.square,l=i.renderSVG(t,e,7*a,o),u=i.renderSVG(t+a,e+a,5*a,s),c=i.renderSVG(t+2*a,e+2*a,3*a,n);return l+u+c}function pt(t,e,r,o){let n=o/2,s=t.trim();if(t.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=t;if(t.includes("data:image/svg")){let m=t.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(t.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),u=l?l[1]:"0 0 100 100",c=i.match(/<svg([\s\S]*?)>/i),f="";if(c){let m=c[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${e-n}, ${r-n})">
|
|
21
|
+
<svg width="${o}" height="${o}" viewBox="${u}"${f}>
|
|
22
|
+
${d}
|
|
23
23
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${
|
|
25
|
-
`;for(let i=0;i<
|
|
26
|
-
`}for(let i=0;i<
|
|
27
|
-
`;return s}var T=null,
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
24
|
+
</g>`}else return`<image x="${e-n}" y="${r-n}" width="${o}" height="${o}" href="${t}" preserveAspectRatio="xMidYMid meet"/>`}function ht(t,e,r,o,n){let s=t.matrixSize,a="",i=w[r]||w.classic;if(r==="classic"){a=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let u=0;u<s;u++)if(t.modules[l][u]&&!Y(l,u,s)){let c=u*e,f=l*e,d=n*e,m=(1-n)*e/2,g=c+m,p=f+m;a+=`M${g},${p}h${d}v${d}h${-d}z`}return a+='"/>',a}for(let l=0;l<s;l++)for(let u=0;u<s;u++)if(t.modules[l][u]&&!Y(l,u,s)){let c=u*e,f=l*e,d=n*e,m=(1-n)*e/2,g=c+m,p=f+m,h={qrcode:t.modules,qrSize:s,row:l,col:u};a+=i.renderSVG(g,p,d,o,h)}return a}function Ae(t,e){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=e,l=r/t.matrixSize,u=e.border.shape==="none"?0:e.border.width,c=r+2*o+2*u,f=o+u,d=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}">`;if(d+=`<rect width="${c}" height="${c}" fill="${n}"/>`,e.border.shape!=="none"&&u>0){let y=A[e.border.shape];if(y){let $={borderWidth:u,borderStyle:e.border.style};d+=y.renderSVG(0,0,c,e.border.color,$)}}e.border.shape!=="none"&&u>0&&(d+=`<rect x="${f}" y="${f}" width="${r}" height="${r}" fill="${n}"/>`),d+=`<g transform="translate(${f}, ${f})">`;let m=Oe(t.matrixSize),g="";for(let y of m)g+=gt(y.x*l,y.y*l,s.shape,s.color,a.color,n,l);let p=ht(t,l,i.shape,i.color,i.scale);d+=g+p+"</g>";let h="";if(e.logo){let y=Pe(t.matrixSize,e.logo.scale)*l,$=c/2;h=pt(e.logo.src,$,$,y)}return d+=h+"</svg>",d}function De(t,e){let{margin:r,lightChar:o,darkChar:n}=e,s="",a=t.matrixSize+r*2;for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
25
|
+
`;for(let i=0;i<t.matrixSize;i++){s+=o.repeat(r);for(let l=0;l<t.matrixSize;l++)s+=t.modules[i][l]?n:o;s+=o.repeat(r)+`
|
|
26
|
+
`}for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
27
|
+
`;return s}var T=null,Le=!1;async function bt(){if(T)return T;if(Le)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");Le=!0;try{return T=(await import("@resvg/resvg-js")).Resvg,T}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Te(t,e){let{output:r,size:o,margin:n,border:s}=e,a=s.shape==="none"?0:s.width,i=o+2*n+2*a,l=await bt(),f=new l(t,{fitTo:{mode:"width",value:i}}).render().asPng(),d=Buffer.from(f);return r.type==="dataURL"?`data:image/png;base64,${d.toString("base64")}`:d}async function Be(t,e){let{format:r,type:o}=e.output;return r==="svg"?o==="string"?t:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:await Te(t,e)}function X(t){if(typeof t=="string")return t;switch(t.type){case"url":return yt(t.url);case"vcard":return $t(t.data);case"wifi":return vt(t.data);case"calendar":return xt(t.data);case"email":return Ct(t.email,t.subject,t.body);case"sms":return It(t.phone,t.message);case"phone":return Rt(t.phone)}}function yt(t){return!t.startsWith("http://")&&!t.startsWith("https://")?`https://${t}`:t}function $t(t){let e=["BEGIN:VCARD","VERSION:3.0",`FN:${t.name}`];if(t.phone&&e.push(`TEL:${t.phone}`),t.email&&e.push(`EMAIL:${t.email}`),t.organization&&e.push(`ORG:${t.organization}`),t.url&&e.push(`URL:${t.url}`),t.title&&e.push(`TITLE:${t.title}`),t.note&&e.push(`NOTE:${t.note}`),t.address){let{street:r,city:o,state:n,zip:s,country:a}=t.address,i=["","",r||"",o||"",n||"",s||"",a||""];e.push(`ADR:${i.join(";")}`)}return e.push("END:VCARD"),e.join(`
|
|
28
|
+
`)}function vt(t){let e=t.encryption||"WPA",r=t.hidden?"H:true;":"",o=Ne(t.ssid),n=Ne(t.password);return`WIFI:T:${e};S:${o};P:${n};${r};`}function Ne(t){return t.replace(/([\\;,":])/g,"\\$1")}function xt(t){let e=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${t.title}`,`DTSTART:${e(t.startDate)}`,`DTEND:${e(t.endDate)}`];return t.location&&r.push(`LOCATION:${t.location}`),t.description&&r.push(`DESCRIPTION:${t.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
29
|
+
`)}function Ct(t,e,r){let o=`mailto:${t}`,n=[];return e&&n.push(`subject=${encodeURIComponent(e)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function It(t,e){return e?`sms:${t}:${e}`:`sms:${t}`}function Rt(t){return`tel:${t}`}function Mt(t,e){let r=[];for(let n of t)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=ee[e-1];for(let n=0;n<o;n++)r.push(!1);return r}function Ve(t,e){if(!t)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=ge(t,e),o=C[r],n=L(t,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${t.length} characters. Maximum capacity at EC level ${r}: ~${C[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=me(t,n,o[n-1]),a=Z[r][n-1],i=K[r][n-1],{dataBlocks:l,ecBlocks:u}=be(s,a,i),c=ye(l,u),f=Mt(c,n),{matrix:d,mask:m}=ke(n,r,f);return{version:n,matrixSize:M(n),modules:d,mask:m,errorCorrectionLevel:r}}async function St(t,e){_(t);let r=X(t),o=ce(e),n=Ve(r,!!o.logo),s=Ae(n,o);return await Be(s,o)}function wt(t,e){_(t);let r=X(t),o=de(e),n=Ve(r,!1);return De(n,o)}export{ne as BorderShape,oe as BorderStyle,re as DotShape,te as EyeFrameShape,x as QRValidationError,St as genQrImage,wt as genQrText};
|