confsmith 0.1.0

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.
@@ -0,0 +1,981 @@
1
+ // node_modules/canvas-confetti/dist/confetti.module.mjs
2
+ var module = {};
3
+ (function main(global, module2, isWorker, workerSize) {
4
+ var canUseWorker = !!(global.Worker && global.Blob && global.Promise && global.OffscreenCanvas && global.OffscreenCanvasRenderingContext2D && global.HTMLCanvasElement && global.HTMLCanvasElement.prototype.transferControlToOffscreen && global.URL && global.URL.createObjectURL);
5
+ var canUsePaths = typeof Path2D === "function" && typeof DOMMatrix === "function";
6
+ var canDrawBitmap = function() {
7
+ if (!global.OffscreenCanvas) {
8
+ return false;
9
+ }
10
+ var canvas = new OffscreenCanvas(1, 1);
11
+ var ctx = canvas.getContext("2d");
12
+ ctx.fillRect(0, 0, 1, 1);
13
+ var bitmap = canvas.transferToImageBitmap();
14
+ try {
15
+ ctx.createPattern(bitmap, "no-repeat");
16
+ } catch (e2) {
17
+ return false;
18
+ }
19
+ return true;
20
+ }();
21
+ function noop() {
22
+ }
23
+ function promise(func) {
24
+ var ModulePromise = module2.exports.Promise;
25
+ var Prom = ModulePromise !== void 0 ? ModulePromise : global.Promise;
26
+ if (typeof Prom === "function") {
27
+ return new Prom(func);
28
+ }
29
+ func(noop, noop);
30
+ return null;
31
+ }
32
+ var bitmapMapper = /* @__PURE__ */ function(skipTransform, map) {
33
+ return {
34
+ transform: function(bitmap) {
35
+ if (skipTransform) {
36
+ return bitmap;
37
+ }
38
+ if (map.has(bitmap)) {
39
+ return map.get(bitmap);
40
+ }
41
+ var canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
42
+ var ctx = canvas.getContext("2d");
43
+ ctx.drawImage(bitmap, 0, 0);
44
+ map.set(bitmap, canvas);
45
+ return canvas;
46
+ },
47
+ clear: function() {
48
+ map.clear();
49
+ }
50
+ };
51
+ }(canDrawBitmap, /* @__PURE__ */ new Map());
52
+ var raf = function() {
53
+ var TIME = Math.floor(1e3 / 60);
54
+ var frame, cancel;
55
+ var frames = {};
56
+ var lastFrameTime = 0;
57
+ if (typeof requestAnimationFrame === "function" && typeof cancelAnimationFrame === "function") {
58
+ frame = function(cb) {
59
+ var id = Math.random();
60
+ frames[id] = requestAnimationFrame(function onFrame(time) {
61
+ if (lastFrameTime === time || lastFrameTime + TIME - 1 < time) {
62
+ lastFrameTime = time;
63
+ delete frames[id];
64
+ cb();
65
+ } else {
66
+ frames[id] = requestAnimationFrame(onFrame);
67
+ }
68
+ });
69
+ return id;
70
+ };
71
+ cancel = function(id) {
72
+ if (frames[id]) {
73
+ cancelAnimationFrame(frames[id]);
74
+ }
75
+ };
76
+ } else {
77
+ frame = function(cb) {
78
+ return setTimeout(cb, TIME);
79
+ };
80
+ cancel = function(timer) {
81
+ return clearTimeout(timer);
82
+ };
83
+ }
84
+ return { frame, cancel };
85
+ }();
86
+ var getWorker = /* @__PURE__ */ function() {
87
+ var worker;
88
+ var prom;
89
+ var resolves = {};
90
+ function decorate(worker2) {
91
+ function execute(options, callback) {
92
+ worker2.postMessage({ options: options || {}, callback });
93
+ }
94
+ worker2.init = function initWorker(canvas) {
95
+ var offscreen = canvas.transferControlToOffscreen();
96
+ worker2.postMessage({ canvas: offscreen }, [offscreen]);
97
+ };
98
+ worker2.fire = function fireWorker(options, size, done) {
99
+ if (prom) {
100
+ execute(options, null);
101
+ return prom;
102
+ }
103
+ var id = Math.random().toString(36).slice(2);
104
+ prom = promise(function(resolve) {
105
+ function workerDone(msg) {
106
+ if (msg.data.callback !== id) {
107
+ return;
108
+ }
109
+ delete resolves[id];
110
+ worker2.removeEventListener("message", workerDone);
111
+ prom = null;
112
+ bitmapMapper.clear();
113
+ done();
114
+ resolve();
115
+ }
116
+ worker2.addEventListener("message", workerDone);
117
+ execute(options, id);
118
+ resolves[id] = workerDone.bind(null, { data: { callback: id } });
119
+ });
120
+ return prom;
121
+ };
122
+ worker2.reset = function resetWorker() {
123
+ worker2.postMessage({ reset: true });
124
+ for (var id in resolves) {
125
+ resolves[id]();
126
+ delete resolves[id];
127
+ }
128
+ };
129
+ }
130
+ return function() {
131
+ if (worker) {
132
+ return worker;
133
+ }
134
+ if (!isWorker && canUseWorker) {
135
+ var code = [
136
+ "var CONFETTI, SIZE = {}, module = {};",
137
+ "(" + main.toString() + ")(this, module, true, SIZE);",
138
+ "onmessage = function(msg) {",
139
+ " if (msg.data.options) {",
140
+ " CONFETTI(msg.data.options).then(function () {",
141
+ " if (msg.data.callback) {",
142
+ " postMessage({ callback: msg.data.callback });",
143
+ " }",
144
+ " });",
145
+ " } else if (msg.data.reset) {",
146
+ " CONFETTI && CONFETTI.reset();",
147
+ " } else if (msg.data.resize) {",
148
+ " SIZE.width = msg.data.resize.width;",
149
+ " SIZE.height = msg.data.resize.height;",
150
+ " } else if (msg.data.canvas) {",
151
+ " SIZE.width = msg.data.canvas.width;",
152
+ " SIZE.height = msg.data.canvas.height;",
153
+ " CONFETTI = module.exports.create(msg.data.canvas);",
154
+ " }",
155
+ "}"
156
+ ].join("\n");
157
+ try {
158
+ worker = new Worker(URL.createObjectURL(new Blob([code])));
159
+ } catch (e2) {
160
+ typeof console !== void 0 && typeof console.warn === "function" ? console.warn("\u{1F38A} Could not load worker", e2) : null;
161
+ return null;
162
+ }
163
+ decorate(worker);
164
+ }
165
+ return worker;
166
+ };
167
+ }();
168
+ var defaults = {
169
+ particleCount: 50,
170
+ angle: 90,
171
+ spread: 45,
172
+ startVelocity: 45,
173
+ decay: 0.9,
174
+ gravity: 1,
175
+ drift: 0,
176
+ ticks: 200,
177
+ x: 0.5,
178
+ y: 0.5,
179
+ shapes: ["square", "circle"],
180
+ zIndex: 100,
181
+ colors: [
182
+ "#26ccff",
183
+ "#a25afd",
184
+ "#ff5e7e",
185
+ "#88ff5a",
186
+ "#fcff42",
187
+ "#ffa62d",
188
+ "#ff36ff"
189
+ ],
190
+ // probably should be true, but back-compat
191
+ disableForReducedMotion: false,
192
+ scalar: 1
193
+ };
194
+ function convert(val, transform) {
195
+ return transform ? transform(val) : val;
196
+ }
197
+ function isOk(val) {
198
+ return !(val === null || val === void 0);
199
+ }
200
+ function prop(options, name, transform) {
201
+ return convert(
202
+ options && isOk(options[name]) ? options[name] : defaults[name],
203
+ transform
204
+ );
205
+ }
206
+ function onlyPositiveInt(number) {
207
+ return number < 0 ? 0 : Math.floor(number);
208
+ }
209
+ function randomInt(min, max) {
210
+ return Math.floor(Math.random() * (max - min)) + min;
211
+ }
212
+ function toDecimal(str) {
213
+ return parseInt(str, 16);
214
+ }
215
+ function colorsToRgb(colors) {
216
+ return colors.map(hexToRgb);
217
+ }
218
+ function hexToRgb(str) {
219
+ var val = String(str).replace(/[^0-9a-f]/gi, "");
220
+ if (val.length < 6) {
221
+ val = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
222
+ }
223
+ return {
224
+ r: toDecimal(val.substring(0, 2)),
225
+ g: toDecimal(val.substring(2, 4)),
226
+ b: toDecimal(val.substring(4, 6))
227
+ };
228
+ }
229
+ function getOrigin(options) {
230
+ var origin = prop(options, "origin", Object);
231
+ origin.x = prop(origin, "x", Number);
232
+ origin.y = prop(origin, "y", Number);
233
+ return origin;
234
+ }
235
+ function setCanvasWindowSize(canvas) {
236
+ canvas.width = document.documentElement.clientWidth;
237
+ canvas.height = document.documentElement.clientHeight;
238
+ }
239
+ function setCanvasRectSize(canvas) {
240
+ var rect = canvas.getBoundingClientRect();
241
+ canvas.width = rect.width;
242
+ canvas.height = rect.height;
243
+ }
244
+ function getCanvas(zIndex) {
245
+ var canvas = document.createElement("canvas");
246
+ canvas.style.position = "fixed";
247
+ canvas.style.top = "0px";
248
+ canvas.style.left = "0px";
249
+ canvas.style.pointerEvents = "none";
250
+ canvas.style.zIndex = zIndex;
251
+ return canvas;
252
+ }
253
+ function ellipse(context, x, y, radiusX, radiusY, rotation, startAngle, endAngle, antiClockwise) {
254
+ context.save();
255
+ context.translate(x, y);
256
+ context.rotate(rotation);
257
+ context.scale(radiusX, radiusY);
258
+ context.arc(0, 0, 1, startAngle, endAngle, antiClockwise);
259
+ context.restore();
260
+ }
261
+ function randomPhysics(opts) {
262
+ var radAngle = opts.angle * (Math.PI / 180);
263
+ var radSpread = opts.spread * (Math.PI / 180);
264
+ return {
265
+ x: opts.x,
266
+ y: opts.y,
267
+ wobble: Math.random() * 10,
268
+ wobbleSpeed: Math.min(0.11, Math.random() * 0.1 + 0.05),
269
+ velocity: opts.startVelocity * 0.5 + Math.random() * opts.startVelocity,
270
+ angle2D: -radAngle + (0.5 * radSpread - Math.random() * radSpread),
271
+ tiltAngle: (Math.random() * (0.75 - 0.25) + 0.25) * Math.PI,
272
+ color: opts.color,
273
+ shape: opts.shape,
274
+ tick: 0,
275
+ totalTicks: opts.ticks,
276
+ decay: opts.decay,
277
+ drift: opts.drift,
278
+ random: Math.random() + 2,
279
+ tiltSin: 0,
280
+ tiltCos: 0,
281
+ wobbleX: 0,
282
+ wobbleY: 0,
283
+ gravity: opts.gravity * 3,
284
+ ovalScalar: 0.6,
285
+ scalar: opts.scalar,
286
+ flat: opts.flat
287
+ };
288
+ }
289
+ function updateFetti(context, fetti) {
290
+ fetti.x += Math.cos(fetti.angle2D) * fetti.velocity + fetti.drift;
291
+ fetti.y += Math.sin(fetti.angle2D) * fetti.velocity + fetti.gravity;
292
+ fetti.velocity *= fetti.decay;
293
+ if (fetti.flat) {
294
+ fetti.wobble = 0;
295
+ fetti.wobbleX = fetti.x + 10 * fetti.scalar;
296
+ fetti.wobbleY = fetti.y + 10 * fetti.scalar;
297
+ fetti.tiltSin = 0;
298
+ fetti.tiltCos = 0;
299
+ fetti.random = 1;
300
+ } else {
301
+ fetti.wobble += fetti.wobbleSpeed;
302
+ fetti.wobbleX = fetti.x + 10 * fetti.scalar * Math.cos(fetti.wobble);
303
+ fetti.wobbleY = fetti.y + 10 * fetti.scalar * Math.sin(fetti.wobble);
304
+ fetti.tiltAngle += 0.1;
305
+ fetti.tiltSin = Math.sin(fetti.tiltAngle);
306
+ fetti.tiltCos = Math.cos(fetti.tiltAngle);
307
+ fetti.random = Math.random() + 2;
308
+ }
309
+ var progress = fetti.tick++ / fetti.totalTicks;
310
+ var x1 = fetti.x + fetti.random * fetti.tiltCos;
311
+ var y1 = fetti.y + fetti.random * fetti.tiltSin;
312
+ var x2 = fetti.wobbleX + fetti.random * fetti.tiltCos;
313
+ var y2 = fetti.wobbleY + fetti.random * fetti.tiltSin;
314
+ context.fillStyle = "rgba(" + fetti.color.r + ", " + fetti.color.g + ", " + fetti.color.b + ", " + (1 - progress) + ")";
315
+ context.beginPath();
316
+ if (canUsePaths && fetti.shape.type === "path" && typeof fetti.shape.path === "string" && Array.isArray(fetti.shape.matrix)) {
317
+ context.fill(transformPath2D(
318
+ fetti.shape.path,
319
+ fetti.shape.matrix,
320
+ fetti.x,
321
+ fetti.y,
322
+ Math.abs(x2 - x1) * 0.1,
323
+ Math.abs(y2 - y1) * 0.1,
324
+ Math.PI / 10 * fetti.wobble
325
+ ));
326
+ } else if (fetti.shape.type === "bitmap") {
327
+ var rotation = Math.PI / 10 * fetti.wobble;
328
+ var scaleX = Math.abs(x2 - x1) * 0.1;
329
+ var scaleY = Math.abs(y2 - y1) * 0.1;
330
+ var width = fetti.shape.bitmap.width * fetti.scalar;
331
+ var height = fetti.shape.bitmap.height * fetti.scalar;
332
+ var matrix = new DOMMatrix([
333
+ Math.cos(rotation) * scaleX,
334
+ Math.sin(rotation) * scaleX,
335
+ -Math.sin(rotation) * scaleY,
336
+ Math.cos(rotation) * scaleY,
337
+ fetti.x,
338
+ fetti.y
339
+ ]);
340
+ matrix.multiplySelf(new DOMMatrix(fetti.shape.matrix));
341
+ var pattern = context.createPattern(bitmapMapper.transform(fetti.shape.bitmap), "no-repeat");
342
+ pattern.setTransform(matrix);
343
+ context.globalAlpha = 1 - progress;
344
+ context.fillStyle = pattern;
345
+ context.fillRect(
346
+ fetti.x - width / 2,
347
+ fetti.y - height / 2,
348
+ width,
349
+ height
350
+ );
351
+ context.globalAlpha = 1;
352
+ } else if (fetti.shape === "circle") {
353
+ context.ellipse ? context.ellipse(fetti.x, fetti.y, Math.abs(x2 - x1) * fetti.ovalScalar, Math.abs(y2 - y1) * fetti.ovalScalar, Math.PI / 10 * fetti.wobble, 0, 2 * Math.PI) : ellipse(context, fetti.x, fetti.y, Math.abs(x2 - x1) * fetti.ovalScalar, Math.abs(y2 - y1) * fetti.ovalScalar, Math.PI / 10 * fetti.wobble, 0, 2 * Math.PI);
354
+ } else if (fetti.shape === "star") {
355
+ var rot = Math.PI / 2 * 3;
356
+ var innerRadius = 4 * fetti.scalar;
357
+ var outerRadius = 8 * fetti.scalar;
358
+ var x = fetti.x;
359
+ var y = fetti.y;
360
+ var spikes = 5;
361
+ var step = Math.PI / spikes;
362
+ while (spikes--) {
363
+ x = fetti.x + Math.cos(rot) * outerRadius;
364
+ y = fetti.y + Math.sin(rot) * outerRadius;
365
+ context.lineTo(x, y);
366
+ rot += step;
367
+ x = fetti.x + Math.cos(rot) * innerRadius;
368
+ y = fetti.y + Math.sin(rot) * innerRadius;
369
+ context.lineTo(x, y);
370
+ rot += step;
371
+ }
372
+ } else {
373
+ context.moveTo(Math.floor(fetti.x), Math.floor(fetti.y));
374
+ context.lineTo(Math.floor(fetti.wobbleX), Math.floor(y1));
375
+ context.lineTo(Math.floor(x2), Math.floor(y2));
376
+ context.lineTo(Math.floor(x1), Math.floor(fetti.wobbleY));
377
+ }
378
+ context.closePath();
379
+ context.fill();
380
+ return fetti.tick < fetti.totalTicks;
381
+ }
382
+ function animate(canvas, fettis, resizer, size, done) {
383
+ var animatingFettis = fettis.slice();
384
+ var context = canvas.getContext("2d");
385
+ var animationFrame;
386
+ var destroy;
387
+ var prom = promise(function(resolve) {
388
+ function onDone() {
389
+ animationFrame = destroy = null;
390
+ context.clearRect(0, 0, size.width, size.height);
391
+ bitmapMapper.clear();
392
+ done();
393
+ resolve();
394
+ }
395
+ function update() {
396
+ if (isWorker && !(size.width === workerSize.width && size.height === workerSize.height)) {
397
+ size.width = canvas.width = workerSize.width;
398
+ size.height = canvas.height = workerSize.height;
399
+ }
400
+ if (!size.width && !size.height) {
401
+ resizer(canvas);
402
+ size.width = canvas.width;
403
+ size.height = canvas.height;
404
+ }
405
+ context.clearRect(0, 0, size.width, size.height);
406
+ animatingFettis = animatingFettis.filter(function(fetti) {
407
+ return updateFetti(context, fetti);
408
+ });
409
+ if (animatingFettis.length) {
410
+ animationFrame = raf.frame(update);
411
+ } else {
412
+ onDone();
413
+ }
414
+ }
415
+ animationFrame = raf.frame(update);
416
+ destroy = onDone;
417
+ });
418
+ return {
419
+ addFettis: function(fettis2) {
420
+ animatingFettis = animatingFettis.concat(fettis2);
421
+ return prom;
422
+ },
423
+ canvas,
424
+ promise: prom,
425
+ reset: function() {
426
+ if (animationFrame) {
427
+ raf.cancel(animationFrame);
428
+ }
429
+ if (destroy) {
430
+ destroy();
431
+ }
432
+ }
433
+ };
434
+ }
435
+ function confettiCannon(canvas, globalOpts) {
436
+ var isLibCanvas = !canvas;
437
+ var allowResize = !!prop(globalOpts || {}, "resize");
438
+ var hasResizeEventRegistered = false;
439
+ var globalDisableForReducedMotion = prop(globalOpts, "disableForReducedMotion", Boolean);
440
+ var shouldUseWorker = canUseWorker && !!prop(globalOpts || {}, "useWorker");
441
+ var worker = shouldUseWorker ? getWorker() : null;
442
+ var resizer = isLibCanvas ? setCanvasWindowSize : setCanvasRectSize;
443
+ var initialized = canvas && worker ? !!canvas.__confetti_initialized : false;
444
+ var preferLessMotion = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion)").matches;
445
+ var animationObj;
446
+ function fireLocal(options, size, done) {
447
+ var particleCount = prop(options, "particleCount", onlyPositiveInt);
448
+ var angle = prop(options, "angle", Number);
449
+ var spread = prop(options, "spread", Number);
450
+ var startVelocity = prop(options, "startVelocity", Number);
451
+ var decay = prop(options, "decay", Number);
452
+ var gravity = prop(options, "gravity", Number);
453
+ var drift = prop(options, "drift", Number);
454
+ var colors = prop(options, "colors", colorsToRgb);
455
+ var ticks = prop(options, "ticks", Number);
456
+ var shapes = prop(options, "shapes");
457
+ var scalar = prop(options, "scalar");
458
+ var flat = !!prop(options, "flat");
459
+ var origin = getOrigin(options);
460
+ var temp = particleCount;
461
+ var fettis = [];
462
+ var startX = canvas.width * origin.x;
463
+ var startY = canvas.height * origin.y;
464
+ while (temp--) {
465
+ fettis.push(
466
+ randomPhysics({
467
+ x: startX,
468
+ y: startY,
469
+ angle,
470
+ spread,
471
+ startVelocity,
472
+ color: colors[temp % colors.length],
473
+ shape: shapes[randomInt(0, shapes.length)],
474
+ ticks,
475
+ decay,
476
+ gravity,
477
+ drift,
478
+ scalar,
479
+ flat
480
+ })
481
+ );
482
+ }
483
+ if (animationObj) {
484
+ return animationObj.addFettis(fettis);
485
+ }
486
+ animationObj = animate(canvas, fettis, resizer, size, done);
487
+ return animationObj.promise;
488
+ }
489
+ function fire(options) {
490
+ var disableForReducedMotion = globalDisableForReducedMotion || prop(options, "disableForReducedMotion", Boolean);
491
+ var zIndex = prop(options, "zIndex", Number);
492
+ if (disableForReducedMotion && preferLessMotion) {
493
+ return promise(function(resolve) {
494
+ resolve();
495
+ });
496
+ }
497
+ if (isLibCanvas && animationObj) {
498
+ canvas = animationObj.canvas;
499
+ } else if (isLibCanvas && !canvas) {
500
+ canvas = getCanvas(zIndex);
501
+ document.body.appendChild(canvas);
502
+ }
503
+ if (allowResize && !initialized) {
504
+ resizer(canvas);
505
+ }
506
+ var size = {
507
+ width: canvas.width,
508
+ height: canvas.height
509
+ };
510
+ if (worker && !initialized) {
511
+ worker.init(canvas);
512
+ }
513
+ initialized = true;
514
+ if (worker) {
515
+ canvas.__confetti_initialized = true;
516
+ }
517
+ function onResize() {
518
+ if (worker) {
519
+ var obj = {
520
+ getBoundingClientRect: function() {
521
+ if (!isLibCanvas) {
522
+ return canvas.getBoundingClientRect();
523
+ }
524
+ }
525
+ };
526
+ resizer(obj);
527
+ worker.postMessage({
528
+ resize: {
529
+ width: obj.width,
530
+ height: obj.height
531
+ }
532
+ });
533
+ return;
534
+ }
535
+ size.width = size.height = null;
536
+ }
537
+ function done() {
538
+ animationObj = null;
539
+ if (allowResize) {
540
+ hasResizeEventRegistered = false;
541
+ global.removeEventListener("resize", onResize);
542
+ }
543
+ if (isLibCanvas && canvas) {
544
+ if (document.body.contains(canvas)) {
545
+ document.body.removeChild(canvas);
546
+ }
547
+ canvas = null;
548
+ initialized = false;
549
+ }
550
+ }
551
+ if (allowResize && !hasResizeEventRegistered) {
552
+ hasResizeEventRegistered = true;
553
+ global.addEventListener("resize", onResize, false);
554
+ }
555
+ if (worker) {
556
+ return worker.fire(options, size, done);
557
+ }
558
+ return fireLocal(options, size, done);
559
+ }
560
+ fire.reset = function() {
561
+ if (worker) {
562
+ worker.reset();
563
+ }
564
+ if (animationObj) {
565
+ animationObj.reset();
566
+ }
567
+ };
568
+ return fire;
569
+ }
570
+ var defaultFire;
571
+ function getDefaultFire() {
572
+ if (!defaultFire) {
573
+ defaultFire = confettiCannon(null, { useWorker: true, resize: true });
574
+ }
575
+ return defaultFire;
576
+ }
577
+ function transformPath2D(pathString, pathMatrix, x, y, scaleX, scaleY, rotation) {
578
+ var path2d = new Path2D(pathString);
579
+ var t1 = new Path2D();
580
+ t1.addPath(path2d, new DOMMatrix(pathMatrix));
581
+ var t2 = new Path2D();
582
+ t2.addPath(t1, new DOMMatrix([
583
+ Math.cos(rotation) * scaleX,
584
+ Math.sin(rotation) * scaleX,
585
+ -Math.sin(rotation) * scaleY,
586
+ Math.cos(rotation) * scaleY,
587
+ x,
588
+ y
589
+ ]));
590
+ return t2;
591
+ }
592
+ function shapeFromPath(pathData) {
593
+ if (!canUsePaths) {
594
+ throw new Error("path confetti are not supported in this browser");
595
+ }
596
+ var path, matrix;
597
+ if (typeof pathData === "string") {
598
+ path = pathData;
599
+ } else {
600
+ path = pathData.path;
601
+ matrix = pathData.matrix;
602
+ }
603
+ var path2d = new Path2D(path);
604
+ var tempCanvas = document.createElement("canvas");
605
+ var tempCtx = tempCanvas.getContext("2d");
606
+ if (!matrix) {
607
+ var maxSize = 1e3;
608
+ var minX = maxSize;
609
+ var minY = maxSize;
610
+ var maxX = 0;
611
+ var maxY = 0;
612
+ var width, height;
613
+ for (var x = 0; x < maxSize; x += 2) {
614
+ for (var y = 0; y < maxSize; y += 2) {
615
+ if (tempCtx.isPointInPath(path2d, x, y, "nonzero")) {
616
+ minX = Math.min(minX, x);
617
+ minY = Math.min(minY, y);
618
+ maxX = Math.max(maxX, x);
619
+ maxY = Math.max(maxY, y);
620
+ }
621
+ }
622
+ }
623
+ width = maxX - minX;
624
+ height = maxY - minY;
625
+ var maxDesiredSize = 10;
626
+ var scale = Math.min(maxDesiredSize / width, maxDesiredSize / height);
627
+ matrix = [
628
+ scale,
629
+ 0,
630
+ 0,
631
+ scale,
632
+ -Math.round(width / 2 + minX) * scale,
633
+ -Math.round(height / 2 + minY) * scale
634
+ ];
635
+ }
636
+ return {
637
+ type: "path",
638
+ path,
639
+ matrix
640
+ };
641
+ }
642
+ function shapeFromText(textData) {
643
+ var text, scalar = 1, color = "#000000", fontFamily = '"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';
644
+ if (typeof textData === "string") {
645
+ text = textData;
646
+ } else {
647
+ text = textData.text;
648
+ scalar = "scalar" in textData ? textData.scalar : scalar;
649
+ fontFamily = "fontFamily" in textData ? textData.fontFamily : fontFamily;
650
+ color = "color" in textData ? textData.color : color;
651
+ }
652
+ var fontSize = 10 * scalar;
653
+ var font = "" + fontSize + "px " + fontFamily;
654
+ var canvas = new OffscreenCanvas(fontSize, fontSize);
655
+ var ctx = canvas.getContext("2d");
656
+ ctx.font = font;
657
+ var size = ctx.measureText(text);
658
+ var width = Math.ceil(size.actualBoundingBoxRight + size.actualBoundingBoxLeft);
659
+ var height = Math.ceil(size.actualBoundingBoxAscent + size.actualBoundingBoxDescent);
660
+ var padding = 2;
661
+ var x = size.actualBoundingBoxLeft + padding;
662
+ var y = size.actualBoundingBoxAscent + padding;
663
+ width += padding + padding;
664
+ height += padding + padding;
665
+ canvas = new OffscreenCanvas(width, height);
666
+ ctx = canvas.getContext("2d");
667
+ ctx.font = font;
668
+ ctx.fillStyle = color;
669
+ ctx.fillText(text, x, y);
670
+ var scale = 1 / scalar;
671
+ return {
672
+ type: "bitmap",
673
+ // TODO these probably need to be transfered for workers
674
+ bitmap: canvas.transferToImageBitmap(),
675
+ matrix: [scale, 0, 0, scale, -width * scale / 2, -height * scale / 2]
676
+ };
677
+ }
678
+ module2.exports = function() {
679
+ return getDefaultFire().apply(this, arguments);
680
+ };
681
+ module2.exports.reset = function() {
682
+ getDefaultFire().reset();
683
+ };
684
+ module2.exports.create = confettiCannon;
685
+ module2.exports.shapeFromPath = shapeFromPath;
686
+ module2.exports.shapeFromText = shapeFromText;
687
+ })(function() {
688
+ if (typeof window !== "undefined") {
689
+ return window;
690
+ }
691
+ if (typeof self !== "undefined") {
692
+ return self;
693
+ }
694
+ return this || {};
695
+ }(), module, false);
696
+ var confetti_module_default = module.exports;
697
+ var create = module.exports.create;
698
+
699
+ // node_modules/stimulus-confetti/dist/stimulus_confetti.modern.js
700
+ function e() {
701
+ return e = Object.assign ? Object.assign.bind() : function(t2) {
702
+ for (var e2 = 1; e2 < arguments.length; e2++) {
703
+ var r2 = arguments[e2];
704
+ for (var n2 in r2) Object.prototype.hasOwnProperty.call(r2, n2) && (t2[n2] = r2[n2]);
705
+ }
706
+ return t2;
707
+ }, e.apply(this, arguments);
708
+ }
709
+ function r(t2) {
710
+ return t2.replace(/(?:[_-])([a-z0-9])/g, (t3, e2) => e2.toUpperCase());
711
+ }
712
+ function n(t2) {
713
+ return t2.charAt(0).toUpperCase() + t2.slice(1);
714
+ }
715
+ function s(t2, e2) {
716
+ const r2 = i(t2);
717
+ return Array.from(r2.reduce((t3, r3) => (function(t4, e3) {
718
+ const r4 = t4[e3];
719
+ return Array.isArray(r4) ? r4 : [];
720
+ }(r3, e2).forEach((e3) => t3.add(e3)), t3), /* @__PURE__ */ new Set()));
721
+ }
722
+ function i(t2) {
723
+ const e2 = [];
724
+ for (; t2; ) e2.push(t2), t2 = Object.getPrototypeOf(t2);
725
+ return e2.reverse();
726
+ }
727
+ function o([t2, e2], n2) {
728
+ return function(t3) {
729
+ const e3 = `${s2 = t3.token, s2.replace(/([A-Z])/g, (t4, e4) => `-${e4.toLowerCase()}`)}-value`, n3 = function(t4) {
730
+ const e4 = function(t5) {
731
+ const e5 = a(t5.typeObject.type);
732
+ if (!e5) return;
733
+ const r3 = c(t5.typeObject.default);
734
+ if (e5 !== r3) throw new Error(`The specified default value for the Stimulus Value "${t5.controller ? `${t5.controller}.${t5.token}` : t5.token}" must match the defined type "${e5}". The provided default value of "${t5.typeObject.default}" is of type "${r3}".`);
735
+ return e5;
736
+ }({ controller: t4.controller, token: t4.token, typeObject: t4.typeDefinition }), r2 = c(t4.typeDefinition), n4 = a(t4.typeDefinition), s3 = e4 || r2 || n4;
737
+ if (s3) return s3;
738
+ throw new Error(`Unknown value type "${t4.controller ? `${t4.controller}.${t4.typeDefinition}` : t4.token}" for "${t4.token}" value`);
739
+ }(t3);
740
+ var s2;
741
+ return { type: n3, key: e3, name: r(e3), get defaultValue() {
742
+ return function(t4) {
743
+ const e4 = a(t4);
744
+ if (e4) return u[e4];
745
+ const r2 = t4.default;
746
+ return void 0 !== r2 ? r2 : t4;
747
+ }(t3.typeDefinition);
748
+ }, get hasCustomDefaultValue() {
749
+ return void 0 !== c(t3.typeDefinition);
750
+ }, reader: l[n3], writer: h[n3] || h.default };
751
+ }({ controller: n2, token: t2, typeDefinition: e2 });
752
+ }
753
+ function a(t2) {
754
+ switch (t2) {
755
+ case Array:
756
+ return "array";
757
+ case Boolean:
758
+ return "boolean";
759
+ case Number:
760
+ return "number";
761
+ case Object:
762
+ return "object";
763
+ case String:
764
+ return "string";
765
+ }
766
+ }
767
+ function c(t2) {
768
+ switch (typeof t2) {
769
+ case "boolean":
770
+ return "boolean";
771
+ case "number":
772
+ return "number";
773
+ case "string":
774
+ return "string";
775
+ }
776
+ return Array.isArray(t2) ? "array" : "[object Object]" === Object.prototype.toString.call(t2) ? "object" : void 0;
777
+ }
778
+ (() => {
779
+ try {
780
+ !function() {
781
+ const t2 = function(t3) {
782
+ function e2() {
783
+ return Reflect.construct(t3, arguments, new.target);
784
+ }
785
+ return e2.prototype = Object.create(t3.prototype, { constructor: { value: e2 } }), Reflect.setPrototypeOf(e2, t3), e2;
786
+ }(function() {
787
+ this.a.call(this);
788
+ });
789
+ t2.prototype.a = function() {
790
+ }, new t2();
791
+ }();
792
+ } catch (t2) {
793
+ return (t3) => class extends t3 {
794
+ };
795
+ }
796
+ })();
797
+ var u = { get array() {
798
+ return [];
799
+ }, boolean: false, number: 0, get object() {
800
+ return {};
801
+ }, string: "" };
802
+ var l = { array(t2) {
803
+ const e2 = JSON.parse(t2);
804
+ if (!Array.isArray(e2)) throw new TypeError(`expected value of type "array" but instead got value "${t2}" of type "${c(e2)}"`);
805
+ return e2;
806
+ }, boolean: (t2) => !("0" == t2 || "false" == String(t2).toLowerCase()), number: (t2) => Number(t2), object(t2) {
807
+ const e2 = JSON.parse(t2);
808
+ if (null === e2 || "object" != typeof e2 || Array.isArray(e2)) throw new TypeError(`expected value of type "object" but instead got value "${t2}" of type "${c(e2)}"`);
809
+ return e2;
810
+ }, string: (t2) => t2 };
811
+ var h = { default: function(t2) {
812
+ return `${t2}`;
813
+ }, array: d, object: d };
814
+ function d(t2) {
815
+ return JSON.stringify(t2);
816
+ }
817
+ var p = class {
818
+ constructor(t2) {
819
+ this.context = t2;
820
+ }
821
+ static get shouldLoad() {
822
+ return true;
823
+ }
824
+ get application() {
825
+ return this.context.application;
826
+ }
827
+ get scope() {
828
+ return this.context.scope;
829
+ }
830
+ get element() {
831
+ return this.scope.element;
832
+ }
833
+ get identifier() {
834
+ return this.scope.identifier;
835
+ }
836
+ get targets() {
837
+ return this.scope.targets;
838
+ }
839
+ get classes() {
840
+ return this.scope.classes;
841
+ }
842
+ get data() {
843
+ return this.scope.data;
844
+ }
845
+ initialize() {
846
+ }
847
+ connect() {
848
+ }
849
+ disconnect() {
850
+ }
851
+ dispatch(t2, { target: e2 = this.element, detail: r2 = {}, prefix: n2 = this.identifier, bubbles: s2 = true, cancelable: i2 = true } = {}) {
852
+ const o2 = new CustomEvent(n2 ? `${n2}:${t2}` : t2, { detail: r2, bubbles: s2, cancelable: i2 });
853
+ return e2.dispatchEvent(o2), o2;
854
+ }
855
+ };
856
+ p.blessings = [function(t2) {
857
+ return s(t2, "classes").reduce((t3, e2) => {
858
+ return Object.assign(t3, { [`${r2 = e2}Class`]: { get() {
859
+ const { classes: t4 } = this;
860
+ if (t4.has(r2)) return t4.get(r2);
861
+ {
862
+ const e3 = t4.getAttributeName(r2);
863
+ throw new Error(`Missing attribute "${e3}"`);
864
+ }
865
+ } }, [`${r2}Classes`]: { get() {
866
+ return this.classes.getAll(r2);
867
+ } }, [`has${n(r2)}Class`]: { get() {
868
+ return this.classes.has(r2);
869
+ } } });
870
+ var r2;
871
+ }, {});
872
+ }, function(t2) {
873
+ return s(t2, "targets").reduce((t3, e2) => {
874
+ return Object.assign(t3, { [`${r2 = e2}Target`]: { get() {
875
+ const t4 = this.targets.find(r2);
876
+ if (t4) return t4;
877
+ throw new Error(`Missing target element "${r2}" for "${this.identifier}" controller`);
878
+ } }, [`${r2}Targets`]: { get() {
879
+ return this.targets.findAll(r2);
880
+ } }, [`has${n(r2)}Target`]: { get() {
881
+ return this.targets.has(r2);
882
+ } } });
883
+ var r2;
884
+ }, {});
885
+ }, function(t2) {
886
+ const e2 = function(t3, e3) {
887
+ return i(t3).reduce((t4, e4) => (t4.push(...function(t5, e5) {
888
+ const r3 = t5.values;
889
+ return r3 ? Object.keys(r3).map((t6) => [t6, r3[t6]]) : [];
890
+ }(e4)), t4), []);
891
+ }(t2), r2 = { valueDescriptorMap: { get() {
892
+ return e2.reduce((t3, e3) => {
893
+ const r3 = o(e3, this.identifier), n2 = this.data.getAttributeNameForKey(r3.key);
894
+ return Object.assign(t3, { [n2]: r3 });
895
+ }, {});
896
+ } } };
897
+ return e2.reduce((t3, e3) => Object.assign(t3, function(t4, e4) {
898
+ const r3 = o(t4, void 0), { key: s2, name: i2, reader: a2, writer: c2 } = r3;
899
+ return { [i2]: { get() {
900
+ const t5 = this.data.get(s2);
901
+ return null !== t5 ? a2(t5) : r3.defaultValue;
902
+ }, set(t5) {
903
+ void 0 === t5 ? this.data.delete(s2) : this.data.set(s2, c2(t5));
904
+ } }, [`has${n(i2)}`]: { get() {
905
+ return this.data.has(s2) || r3.hasCustomDefaultValue;
906
+ } } };
907
+ }(e3)), r2);
908
+ }], p.targets = [], p.values = {};
909
+ var f = (t2 = {}) => Object.keys(t2).map((e2) => `${e2}:${t2[e2]}`).join(";");
910
+ var g = class extends p {
911
+ constructor(...t2) {
912
+ super(...t2), this.clicked = false, this.canvasElement = null;
913
+ }
914
+ get canvas() {
915
+ if (this.canvasElement) return this.canvasElement;
916
+ const t2 = document.createElement("canvas");
917
+ return t2.style.cssText = f({ position: "fixed", top: 0, right: 0, bottom: 0, left: 0, width: "100%", height: "100%", "pointer-events": "none", "z-index": "9999" }), document.body.appendChild(t2), this.canvasElement = t2, this.canvasElement;
918
+ }
919
+ get instance() {
920
+ return confetti_module_default.create(this.canvas, { resize: true, useWorker: true });
921
+ }
922
+ spray(t2) {
923
+ t2.preventDefault(), this.log("Spraying"), this.getStyle(t2).then(() => {
924
+ this.log("Finished animation"), this.followValue && (false === this.clicked && this.followLink(), this.clicked = true);
925
+ });
926
+ }
927
+ getStyle(t2) {
928
+ switch (this.animationValue) {
929
+ case "basic":
930
+ default:
931
+ return this.basic(t2);
932
+ case "school-pride":
933
+ return this.schoolPride(t2);
934
+ case "stars":
935
+ return this.stars(t2);
936
+ }
937
+ }
938
+ basic(t2) {
939
+ return this.log("Basic started"), this.instance({ particleCount: this.particleCountValue, startVelocity: this.startVelocityValue, spread: this.spreadValue, ticks: this.ticksValue, origin: { x: t2.clientX / window.innerWidth, y: t2.clientY / window.innerHeight } });
940
+ }
941
+ stars(t2) {
942
+ this.log("Stars started");
943
+ var r2 = { spread: this.spreadValue, ticks: 50, gravity: 0, decay: 0.94, startVelocity: this.startVelocityValue, shapes: ["star"], colors: ["FFE400", "FFBD00", "E89400", "FFCA6C", "FDFFB8"], origin: { x: t2.clientX / window.innerWidth, y: t2.clientY / window.innerHeight } };
944
+ return new Promise((t3) => {
945
+ setTimeout(() => {
946
+ this.instance(e({}, r2, { particleCount: this.particleCountValue, shapes: ["star"] }));
947
+ }, 70), this.instance(e({}, r2, { particleCount: this.particleCountValue, shapes: ["star"] })).then(() => {
948
+ this.log("Stars ended"), t3();
949
+ });
950
+ });
951
+ }
952
+ schoolPride(t2) {
953
+ return this.log("School pride started"), new Promise((t3) => {
954
+ var e2 = Date.now() + 1e3 * this.durationValue, r2 = [this.firstColorValue, this.secondColorValue];
955
+ const n2 = this;
956
+ !function s2() {
957
+ n2.instance({ particleCount: 2, angle: 60, spread: 55, origin: { x: 0 }, colors: r2 }), n2.instance({ particleCount: 2, angle: 120, spread: 55, origin: { x: 1 }, colors: r2 }), Date.now() < e2 ? requestAnimationFrame(s2) : (n2.log("School pride ended"), t3());
958
+ }();
959
+ });
960
+ }
961
+ followLink() {
962
+ this.log("Following link");
963
+ const t2 = document.createElement("a");
964
+ t2.style.cssText = f({ opacity: 0, display: "hidden" }), t2.href = this.context.element.href, t2.target = this.context.element.target, document.body.appendChild(t2), t2.click(), this.log("Followed link"), setTimeout(() => {
965
+ this.log("Reset state"), this.clicked = false;
966
+ }, 1);
967
+ }
968
+ log(t2) {
969
+ this.debugValue && console.log(`[Stimulus confetti] ${t2}`);
970
+ }
971
+ };
972
+ g.targets = ["element"], g.values = { follow: { type: Boolean, default: true }, animation: { type: String, default: "basic" }, duration: { type: Number, default: 5 }, firstColor: { type: String, default: "#0886DE" }, secondColor: { type: String, default: "#FF6154" }, particleCount: { type: Number, default: 100 }, startVelocity: { type: Number, default: 20 }, spread: { type: Number, default: 360 }, ticks: { type: Number, default: 90 }, debug: { type: Boolean, default: false } };
973
+
974
+ // app/javascript/confsmith.js
975
+ console.log("hi from confsmith");
976
+ console.log(g);
977
+ var t = async function() {
978
+ console.log("t");
979
+ };
980
+ await t();
981
+ //# sourceMappingURL=/assets/confsmith.js.map