@papernote/ui 1.10.11 → 1.10.12

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/dist/index.js CHANGED
@@ -2940,6 +2940,1092 @@ function Separator({ orientation = 'horizontal', className = '', spacing = 'md',
2940
2940
  `, role: "separator", "aria-orientation": orientation }));
2941
2941
  }
2942
2942
 
2943
+ // canvas-confetti v1.9.4 built on 2025-10-25T05:14:56.640Z
2944
+ var module$1 = {};
2945
+
2946
+ // source content
2947
+ /* globals Map */
2948
+
2949
+ (function main(global, module, isWorker, workerSize) {
2950
+ var canUseWorker = !!(
2951
+ global.Worker &&
2952
+ global.Blob &&
2953
+ global.Promise &&
2954
+ global.OffscreenCanvas &&
2955
+ global.OffscreenCanvasRenderingContext2D &&
2956
+ global.HTMLCanvasElement &&
2957
+ global.HTMLCanvasElement.prototype.transferControlToOffscreen &&
2958
+ global.URL &&
2959
+ global.URL.createObjectURL);
2960
+
2961
+ var canUsePaths = typeof Path2D === 'function' && typeof DOMMatrix === 'function';
2962
+ var canDrawBitmap = (function () {
2963
+ // this mostly supports ssr
2964
+ if (!global.OffscreenCanvas) {
2965
+ return false;
2966
+ }
2967
+
2968
+ try {
2969
+ var canvas = new OffscreenCanvas(1, 1);
2970
+ var ctx = canvas.getContext('2d');
2971
+ ctx.fillRect(0, 0, 1, 1);
2972
+ var bitmap = canvas.transferToImageBitmap();
2973
+ ctx.createPattern(bitmap, 'no-repeat');
2974
+ } catch (e) {
2975
+ return false;
2976
+ }
2977
+
2978
+ return true;
2979
+ })();
2980
+
2981
+ function noop() {}
2982
+
2983
+ // create a promise if it exists, otherwise, just
2984
+ // call the function directly
2985
+ function promise(func) {
2986
+ var ModulePromise = module.exports.Promise;
2987
+ var Prom = ModulePromise !== void 0 ? ModulePromise : global.Promise;
2988
+
2989
+ if (typeof Prom === 'function') {
2990
+ return new Prom(func);
2991
+ }
2992
+
2993
+ func(noop, noop);
2994
+
2995
+ return null;
2996
+ }
2997
+
2998
+ var bitmapMapper = (function (skipTransform, map) {
2999
+ // see https://github.com/catdad/canvas-confetti/issues/209
3000
+ // creating canvases is actually pretty expensive, so we should create a
3001
+ // 1:1 map for bitmap:canvas, so that we can animate the confetti in
3002
+ // a performant manner, but also not store them forever so that we don't
3003
+ // have a memory leak
3004
+ return {
3005
+ transform: function(bitmap) {
3006
+ if (skipTransform) {
3007
+ return bitmap;
3008
+ }
3009
+
3010
+ if (map.has(bitmap)) {
3011
+ return map.get(bitmap);
3012
+ }
3013
+
3014
+ var canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
3015
+ var ctx = canvas.getContext('2d');
3016
+ ctx.drawImage(bitmap, 0, 0);
3017
+
3018
+ map.set(bitmap, canvas);
3019
+
3020
+ return canvas;
3021
+ },
3022
+ clear: function () {
3023
+ map.clear();
3024
+ }
3025
+ };
3026
+ })(canDrawBitmap, new Map());
3027
+
3028
+ var raf = (function () {
3029
+ var TIME = Math.floor(1000 / 60);
3030
+ var frame, cancel;
3031
+ var frames = {};
3032
+ var lastFrameTime = 0;
3033
+
3034
+ if (typeof requestAnimationFrame === 'function' && typeof cancelAnimationFrame === 'function') {
3035
+ frame = function (cb) {
3036
+ var id = Math.random();
3037
+
3038
+ frames[id] = requestAnimationFrame(function onFrame(time) {
3039
+ if (lastFrameTime === time || lastFrameTime + TIME - 1 < time) {
3040
+ lastFrameTime = time;
3041
+ delete frames[id];
3042
+
3043
+ cb();
3044
+ } else {
3045
+ frames[id] = requestAnimationFrame(onFrame);
3046
+ }
3047
+ });
3048
+
3049
+ return id;
3050
+ };
3051
+ cancel = function (id) {
3052
+ if (frames[id]) {
3053
+ cancelAnimationFrame(frames[id]);
3054
+ }
3055
+ };
3056
+ } else {
3057
+ frame = function (cb) {
3058
+ return setTimeout(cb, TIME);
3059
+ };
3060
+ cancel = function (timer) {
3061
+ return clearTimeout(timer);
3062
+ };
3063
+ }
3064
+
3065
+ return { frame: frame, cancel: cancel };
3066
+ }());
3067
+
3068
+ var getWorker = (function () {
3069
+ var worker;
3070
+ var prom;
3071
+ var resolves = {};
3072
+
3073
+ function decorate(worker) {
3074
+ function execute(options, callback) {
3075
+ worker.postMessage({ options: options || {}, callback: callback });
3076
+ }
3077
+ worker.init = function initWorker(canvas) {
3078
+ var offscreen = canvas.transferControlToOffscreen();
3079
+ worker.postMessage({ canvas: offscreen }, [offscreen]);
3080
+ };
3081
+
3082
+ worker.fire = function fireWorker(options, size, done) {
3083
+ if (prom) {
3084
+ execute(options, null);
3085
+ return prom;
3086
+ }
3087
+
3088
+ var id = Math.random().toString(36).slice(2);
3089
+
3090
+ prom = promise(function (resolve) {
3091
+ function workerDone(msg) {
3092
+ if (msg.data.callback !== id) {
3093
+ return;
3094
+ }
3095
+
3096
+ delete resolves[id];
3097
+ worker.removeEventListener('message', workerDone);
3098
+
3099
+ prom = null;
3100
+
3101
+ bitmapMapper.clear();
3102
+
3103
+ done();
3104
+ resolve();
3105
+ }
3106
+
3107
+ worker.addEventListener('message', workerDone);
3108
+ execute(options, id);
3109
+
3110
+ resolves[id] = workerDone.bind(null, { data: { callback: id }});
3111
+ });
3112
+
3113
+ return prom;
3114
+ };
3115
+
3116
+ worker.reset = function resetWorker() {
3117
+ worker.postMessage({ reset: true });
3118
+
3119
+ for (var id in resolves) {
3120
+ resolves[id]();
3121
+ delete resolves[id];
3122
+ }
3123
+ };
3124
+ }
3125
+
3126
+ return function () {
3127
+ if (worker) {
3128
+ return worker;
3129
+ }
3130
+
3131
+ if (!isWorker && canUseWorker) {
3132
+ var code = [
3133
+ 'var CONFETTI, SIZE = {}, module = {};',
3134
+ '(' + main.toString() + ')(this, module, true, SIZE);',
3135
+ 'onmessage = function(msg) {',
3136
+ ' if (msg.data.options) {',
3137
+ ' CONFETTI(msg.data.options).then(function () {',
3138
+ ' if (msg.data.callback) {',
3139
+ ' postMessage({ callback: msg.data.callback });',
3140
+ ' }',
3141
+ ' });',
3142
+ ' } else if (msg.data.reset) {',
3143
+ ' CONFETTI && CONFETTI.reset();',
3144
+ ' } else if (msg.data.resize) {',
3145
+ ' SIZE.width = msg.data.resize.width;',
3146
+ ' SIZE.height = msg.data.resize.height;',
3147
+ ' } else if (msg.data.canvas) {',
3148
+ ' SIZE.width = msg.data.canvas.width;',
3149
+ ' SIZE.height = msg.data.canvas.height;',
3150
+ ' CONFETTI = module.exports.create(msg.data.canvas);',
3151
+ ' }',
3152
+ '}',
3153
+ ].join('\n');
3154
+ try {
3155
+ worker = new Worker(URL.createObjectURL(new Blob([code])));
3156
+ } catch (e) {
3157
+ // eslint-disable-next-line no-console
3158
+ typeof console !== 'undefined' && typeof console.warn === 'function' ? console.warn('🎊 Could not load worker', e) : null;
3159
+
3160
+ return null;
3161
+ }
3162
+
3163
+ decorate(worker);
3164
+ }
3165
+
3166
+ return worker;
3167
+ };
3168
+ })();
3169
+
3170
+ var defaults = {
3171
+ particleCount: 50,
3172
+ angle: 90,
3173
+ spread: 45,
3174
+ startVelocity: 45,
3175
+ decay: 0.9,
3176
+ gravity: 1,
3177
+ drift: 0,
3178
+ ticks: 200,
3179
+ x: 0.5,
3180
+ y: 0.5,
3181
+ shapes: ['square', 'circle'],
3182
+ zIndex: 100,
3183
+ colors: [
3184
+ '#26ccff',
3185
+ '#a25afd',
3186
+ '#ff5e7e',
3187
+ '#88ff5a',
3188
+ '#fcff42',
3189
+ '#ffa62d',
3190
+ '#ff36ff'
3191
+ ],
3192
+ // probably should be true, but back-compat
3193
+ disableForReducedMotion: false,
3194
+ scalar: 1
3195
+ };
3196
+
3197
+ function convert(val, transform) {
3198
+ return transform ? transform(val) : val;
3199
+ }
3200
+
3201
+ function isOk(val) {
3202
+ return !(val === null || val === undefined);
3203
+ }
3204
+
3205
+ function prop(options, name, transform) {
3206
+ return convert(
3207
+ options && isOk(options[name]) ? options[name] : defaults[name],
3208
+ transform
3209
+ );
3210
+ }
3211
+
3212
+ function onlyPositiveInt(number){
3213
+ return number < 0 ? 0 : Math.floor(number);
3214
+ }
3215
+
3216
+ function randomInt(min, max) {
3217
+ // [min, max)
3218
+ return Math.floor(Math.random() * (max - min)) + min;
3219
+ }
3220
+
3221
+ function toDecimal(str) {
3222
+ return parseInt(str, 16);
3223
+ }
3224
+
3225
+ function colorsToRgb(colors) {
3226
+ return colors.map(hexToRgb);
3227
+ }
3228
+
3229
+ function hexToRgb(str) {
3230
+ var val = String(str).replace(/[^0-9a-f]/gi, '');
3231
+
3232
+ if (val.length < 6) {
3233
+ val = val[0]+val[0]+val[1]+val[1]+val[2]+val[2];
3234
+ }
3235
+
3236
+ return {
3237
+ r: toDecimal(val.substring(0,2)),
3238
+ g: toDecimal(val.substring(2,4)),
3239
+ b: toDecimal(val.substring(4,6))
3240
+ };
3241
+ }
3242
+
3243
+ function getOrigin(options) {
3244
+ var origin = prop(options, 'origin', Object);
3245
+ origin.x = prop(origin, 'x', Number);
3246
+ origin.y = prop(origin, 'y', Number);
3247
+
3248
+ return origin;
3249
+ }
3250
+
3251
+ function setCanvasWindowSize(canvas) {
3252
+ canvas.width = document.documentElement.clientWidth;
3253
+ canvas.height = document.documentElement.clientHeight;
3254
+ }
3255
+
3256
+ function setCanvasRectSize(canvas) {
3257
+ var rect = canvas.getBoundingClientRect();
3258
+ canvas.width = rect.width;
3259
+ canvas.height = rect.height;
3260
+ }
3261
+
3262
+ function getCanvas(zIndex) {
3263
+ var canvas = document.createElement('canvas');
3264
+
3265
+ canvas.style.position = 'fixed';
3266
+ canvas.style.top = '0px';
3267
+ canvas.style.left = '0px';
3268
+ canvas.style.pointerEvents = 'none';
3269
+ canvas.style.zIndex = zIndex;
3270
+
3271
+ return canvas;
3272
+ }
3273
+
3274
+ function ellipse(context, x, y, radiusX, radiusY, rotation, startAngle, endAngle, antiClockwise) {
3275
+ context.save();
3276
+ context.translate(x, y);
3277
+ context.rotate(rotation);
3278
+ context.scale(radiusX, radiusY);
3279
+ context.arc(0, 0, 1, startAngle, endAngle, antiClockwise);
3280
+ context.restore();
3281
+ }
3282
+
3283
+ function randomPhysics(opts) {
3284
+ var radAngle = opts.angle * (Math.PI / 180);
3285
+ var radSpread = opts.spread * (Math.PI / 180);
3286
+
3287
+ return {
3288
+ x: opts.x,
3289
+ y: opts.y,
3290
+ wobble: Math.random() * 10,
3291
+ wobbleSpeed: Math.min(0.11, Math.random() * 0.1 + 0.05),
3292
+ velocity: (opts.startVelocity * 0.5) + (Math.random() * opts.startVelocity),
3293
+ angle2D: -radAngle + ((0.5 * radSpread) - (Math.random() * radSpread)),
3294
+ tiltAngle: (Math.random() * (0.75 - 0.25) + 0.25) * Math.PI,
3295
+ color: opts.color,
3296
+ shape: opts.shape,
3297
+ tick: 0,
3298
+ totalTicks: opts.ticks,
3299
+ decay: opts.decay,
3300
+ drift: opts.drift,
3301
+ random: Math.random() + 2,
3302
+ tiltSin: 0,
3303
+ tiltCos: 0,
3304
+ wobbleX: 0,
3305
+ wobbleY: 0,
3306
+ gravity: opts.gravity * 3,
3307
+ ovalScalar: 0.6,
3308
+ scalar: opts.scalar,
3309
+ flat: opts.flat
3310
+ };
3311
+ }
3312
+
3313
+ function updateFetti(context, fetti) {
3314
+ fetti.x += Math.cos(fetti.angle2D) * fetti.velocity + fetti.drift;
3315
+ fetti.y += Math.sin(fetti.angle2D) * fetti.velocity + fetti.gravity;
3316
+ fetti.velocity *= fetti.decay;
3317
+
3318
+ if (fetti.flat) {
3319
+ fetti.wobble = 0;
3320
+ fetti.wobbleX = fetti.x + (10 * fetti.scalar);
3321
+ fetti.wobbleY = fetti.y + (10 * fetti.scalar);
3322
+
3323
+ fetti.tiltSin = 0;
3324
+ fetti.tiltCos = 0;
3325
+ fetti.random = 1;
3326
+ } else {
3327
+ fetti.wobble += fetti.wobbleSpeed;
3328
+ fetti.wobbleX = fetti.x + ((10 * fetti.scalar) * Math.cos(fetti.wobble));
3329
+ fetti.wobbleY = fetti.y + ((10 * fetti.scalar) * Math.sin(fetti.wobble));
3330
+
3331
+ fetti.tiltAngle += 0.1;
3332
+ fetti.tiltSin = Math.sin(fetti.tiltAngle);
3333
+ fetti.tiltCos = Math.cos(fetti.tiltAngle);
3334
+ fetti.random = Math.random() + 2;
3335
+ }
3336
+
3337
+ var progress = (fetti.tick++) / fetti.totalTicks;
3338
+
3339
+ var x1 = fetti.x + (fetti.random * fetti.tiltCos);
3340
+ var y1 = fetti.y + (fetti.random * fetti.tiltSin);
3341
+ var x2 = fetti.wobbleX + (fetti.random * fetti.tiltCos);
3342
+ var y2 = fetti.wobbleY + (fetti.random * fetti.tiltSin);
3343
+
3344
+ context.fillStyle = 'rgba(' + fetti.color.r + ', ' + fetti.color.g + ', ' + fetti.color.b + ', ' + (1 - progress) + ')';
3345
+
3346
+ context.beginPath();
3347
+
3348
+ if (canUsePaths && fetti.shape.type === 'path' && typeof fetti.shape.path === 'string' && Array.isArray(fetti.shape.matrix)) {
3349
+ context.fill(transformPath2D(
3350
+ fetti.shape.path,
3351
+ fetti.shape.matrix,
3352
+ fetti.x,
3353
+ fetti.y,
3354
+ Math.abs(x2 - x1) * 0.1,
3355
+ Math.abs(y2 - y1) * 0.1,
3356
+ Math.PI / 10 * fetti.wobble
3357
+ ));
3358
+ } else if (fetti.shape.type === 'bitmap') {
3359
+ var rotation = Math.PI / 10 * fetti.wobble;
3360
+ var scaleX = Math.abs(x2 - x1) * 0.1;
3361
+ var scaleY = Math.abs(y2 - y1) * 0.1;
3362
+ var width = fetti.shape.bitmap.width * fetti.scalar;
3363
+ var height = fetti.shape.bitmap.height * fetti.scalar;
3364
+
3365
+ var matrix = new DOMMatrix([
3366
+ Math.cos(rotation) * scaleX,
3367
+ Math.sin(rotation) * scaleX,
3368
+ -Math.sin(rotation) * scaleY,
3369
+ Math.cos(rotation) * scaleY,
3370
+ fetti.x,
3371
+ fetti.y
3372
+ ]);
3373
+
3374
+ // apply the transform matrix from the confetti shape
3375
+ matrix.multiplySelf(new DOMMatrix(fetti.shape.matrix));
3376
+
3377
+ var pattern = context.createPattern(bitmapMapper.transform(fetti.shape.bitmap), 'no-repeat');
3378
+ pattern.setTransform(matrix);
3379
+
3380
+ context.globalAlpha = (1 - progress);
3381
+ context.fillStyle = pattern;
3382
+ context.fillRect(
3383
+ fetti.x - (width / 2),
3384
+ fetti.y - (height / 2),
3385
+ width,
3386
+ height
3387
+ );
3388
+ context.globalAlpha = 1;
3389
+ } else if (fetti.shape === 'circle') {
3390
+ context.ellipse ?
3391
+ 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) :
3392
+ 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);
3393
+ } else if (fetti.shape === 'star') {
3394
+ var rot = Math.PI / 2 * 3;
3395
+ var innerRadius = 4 * fetti.scalar;
3396
+ var outerRadius = 8 * fetti.scalar;
3397
+ var x = fetti.x;
3398
+ var y = fetti.y;
3399
+ var spikes = 5;
3400
+ var step = Math.PI / spikes;
3401
+
3402
+ while (spikes--) {
3403
+ x = fetti.x + Math.cos(rot) * outerRadius;
3404
+ y = fetti.y + Math.sin(rot) * outerRadius;
3405
+ context.lineTo(x, y);
3406
+ rot += step;
3407
+
3408
+ x = fetti.x + Math.cos(rot) * innerRadius;
3409
+ y = fetti.y + Math.sin(rot) * innerRadius;
3410
+ context.lineTo(x, y);
3411
+ rot += step;
3412
+ }
3413
+ } else {
3414
+ context.moveTo(Math.floor(fetti.x), Math.floor(fetti.y));
3415
+ context.lineTo(Math.floor(fetti.wobbleX), Math.floor(y1));
3416
+ context.lineTo(Math.floor(x2), Math.floor(y2));
3417
+ context.lineTo(Math.floor(x1), Math.floor(fetti.wobbleY));
3418
+ }
3419
+
3420
+ context.closePath();
3421
+ context.fill();
3422
+
3423
+ return fetti.tick < fetti.totalTicks;
3424
+ }
3425
+
3426
+ function animate(canvas, fettis, resizer, size, done) {
3427
+ var animatingFettis = fettis.slice();
3428
+ var context = canvas.getContext('2d');
3429
+ var animationFrame;
3430
+ var destroy;
3431
+
3432
+ var prom = promise(function (resolve) {
3433
+ function onDone() {
3434
+ animationFrame = destroy = null;
3435
+
3436
+ context.clearRect(0, 0, size.width, size.height);
3437
+ bitmapMapper.clear();
3438
+
3439
+ done();
3440
+ resolve();
3441
+ }
3442
+
3443
+ function update() {
3444
+ if (isWorker && !(size.width === workerSize.width && size.height === workerSize.height)) {
3445
+ size.width = canvas.width = workerSize.width;
3446
+ size.height = canvas.height = workerSize.height;
3447
+ }
3448
+
3449
+ if (!size.width && !size.height) {
3450
+ resizer(canvas);
3451
+ size.width = canvas.width;
3452
+ size.height = canvas.height;
3453
+ }
3454
+
3455
+ context.clearRect(0, 0, size.width, size.height);
3456
+
3457
+ animatingFettis = animatingFettis.filter(function (fetti) {
3458
+ return updateFetti(context, fetti);
3459
+ });
3460
+
3461
+ if (animatingFettis.length) {
3462
+ animationFrame = raf.frame(update);
3463
+ } else {
3464
+ onDone();
3465
+ }
3466
+ }
3467
+
3468
+ animationFrame = raf.frame(update);
3469
+ destroy = onDone;
3470
+ });
3471
+
3472
+ return {
3473
+ addFettis: function (fettis) {
3474
+ animatingFettis = animatingFettis.concat(fettis);
3475
+
3476
+ return prom;
3477
+ },
3478
+ canvas: canvas,
3479
+ promise: prom,
3480
+ reset: function () {
3481
+ if (animationFrame) {
3482
+ raf.cancel(animationFrame);
3483
+ }
3484
+
3485
+ if (destroy) {
3486
+ destroy();
3487
+ }
3488
+ }
3489
+ };
3490
+ }
3491
+
3492
+ function confettiCannon(canvas, globalOpts) {
3493
+ var isLibCanvas = !canvas;
3494
+ var allowResize = !!prop(globalOpts || {}, 'resize');
3495
+ var hasResizeEventRegistered = false;
3496
+ var globalDisableForReducedMotion = prop(globalOpts, 'disableForReducedMotion', Boolean);
3497
+ var shouldUseWorker = canUseWorker && !!prop(globalOpts || {}, 'useWorker');
3498
+ var worker = shouldUseWorker ? getWorker() : null;
3499
+ var resizer = isLibCanvas ? setCanvasWindowSize : setCanvasRectSize;
3500
+ var initialized = (canvas && worker) ? !!canvas.__confetti_initialized : false;
3501
+ var preferLessMotion = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion)').matches;
3502
+ var animationObj;
3503
+
3504
+ function fireLocal(options, size, done) {
3505
+ var particleCount = prop(options, 'particleCount', onlyPositiveInt);
3506
+ var angle = prop(options, 'angle', Number);
3507
+ var spread = prop(options, 'spread', Number);
3508
+ var startVelocity = prop(options, 'startVelocity', Number);
3509
+ var decay = prop(options, 'decay', Number);
3510
+ var gravity = prop(options, 'gravity', Number);
3511
+ var drift = prop(options, 'drift', Number);
3512
+ var colors = prop(options, 'colors', colorsToRgb);
3513
+ var ticks = prop(options, 'ticks', Number);
3514
+ var shapes = prop(options, 'shapes');
3515
+ var scalar = prop(options, 'scalar');
3516
+ var flat = !!prop(options, 'flat');
3517
+ var origin = getOrigin(options);
3518
+
3519
+ var temp = particleCount;
3520
+ var fettis = [];
3521
+
3522
+ var startX = canvas.width * origin.x;
3523
+ var startY = canvas.height * origin.y;
3524
+
3525
+ while (temp--) {
3526
+ fettis.push(
3527
+ randomPhysics({
3528
+ x: startX,
3529
+ y: startY,
3530
+ angle: angle,
3531
+ spread: spread,
3532
+ startVelocity: startVelocity,
3533
+ color: colors[temp % colors.length],
3534
+ shape: shapes[randomInt(0, shapes.length)],
3535
+ ticks: ticks,
3536
+ decay: decay,
3537
+ gravity: gravity,
3538
+ drift: drift,
3539
+ scalar: scalar,
3540
+ flat: flat
3541
+ })
3542
+ );
3543
+ }
3544
+
3545
+ // if we have a previous canvas already animating,
3546
+ // add to it
3547
+ if (animationObj) {
3548
+ return animationObj.addFettis(fettis);
3549
+ }
3550
+
3551
+ animationObj = animate(canvas, fettis, resizer, size , done);
3552
+
3553
+ return animationObj.promise;
3554
+ }
3555
+
3556
+ function fire(options) {
3557
+ var disableForReducedMotion = globalDisableForReducedMotion || prop(options, 'disableForReducedMotion', Boolean);
3558
+ var zIndex = prop(options, 'zIndex', Number);
3559
+
3560
+ if (disableForReducedMotion && preferLessMotion) {
3561
+ return promise(function (resolve) {
3562
+ resolve();
3563
+ });
3564
+ }
3565
+
3566
+ if (isLibCanvas && animationObj) {
3567
+ // use existing canvas from in-progress animation
3568
+ canvas = animationObj.canvas;
3569
+ } else if (isLibCanvas && !canvas) {
3570
+ // create and initialize a new canvas
3571
+ canvas = getCanvas(zIndex);
3572
+ document.body.appendChild(canvas);
3573
+ }
3574
+
3575
+ if (allowResize && !initialized) {
3576
+ // initialize the size of a user-supplied canvas
3577
+ resizer(canvas);
3578
+ }
3579
+
3580
+ var size = {
3581
+ width: canvas.width,
3582
+ height: canvas.height
3583
+ };
3584
+
3585
+ if (worker && !initialized) {
3586
+ worker.init(canvas);
3587
+ }
3588
+
3589
+ initialized = true;
3590
+
3591
+ if (worker) {
3592
+ canvas.__confetti_initialized = true;
3593
+ }
3594
+
3595
+ function onResize() {
3596
+ if (worker) {
3597
+ // TODO this really shouldn't be immediate, because it is expensive
3598
+ var obj = {
3599
+ getBoundingClientRect: function () {
3600
+ if (!isLibCanvas) {
3601
+ return canvas.getBoundingClientRect();
3602
+ }
3603
+ }
3604
+ };
3605
+
3606
+ resizer(obj);
3607
+
3608
+ worker.postMessage({
3609
+ resize: {
3610
+ width: obj.width,
3611
+ height: obj.height
3612
+ }
3613
+ });
3614
+ return;
3615
+ }
3616
+
3617
+ // don't actually query the size here, since this
3618
+ // can execute frequently and rapidly
3619
+ size.width = size.height = null;
3620
+ }
3621
+
3622
+ function done() {
3623
+ animationObj = null;
3624
+
3625
+ if (allowResize) {
3626
+ hasResizeEventRegistered = false;
3627
+ global.removeEventListener('resize', onResize);
3628
+ }
3629
+
3630
+ if (isLibCanvas && canvas) {
3631
+ if (document.body.contains(canvas)) {
3632
+ document.body.removeChild(canvas);
3633
+ }
3634
+ canvas = null;
3635
+ initialized = false;
3636
+ }
3637
+ }
3638
+
3639
+ if (allowResize && !hasResizeEventRegistered) {
3640
+ hasResizeEventRegistered = true;
3641
+ global.addEventListener('resize', onResize, false);
3642
+ }
3643
+
3644
+ if (worker) {
3645
+ return worker.fire(options, size, done);
3646
+ }
3647
+
3648
+ return fireLocal(options, size, done);
3649
+ }
3650
+
3651
+ fire.reset = function () {
3652
+ if (worker) {
3653
+ worker.reset();
3654
+ }
3655
+
3656
+ if (animationObj) {
3657
+ animationObj.reset();
3658
+ }
3659
+ };
3660
+
3661
+ return fire;
3662
+ }
3663
+
3664
+ // Make default export lazy to defer worker creation until called.
3665
+ var defaultFire;
3666
+ function getDefaultFire() {
3667
+ if (!defaultFire) {
3668
+ defaultFire = confettiCannon(null, { useWorker: true, resize: true });
3669
+ }
3670
+ return defaultFire;
3671
+ }
3672
+
3673
+ function transformPath2D(pathString, pathMatrix, x, y, scaleX, scaleY, rotation) {
3674
+ var path2d = new Path2D(pathString);
3675
+
3676
+ var t1 = new Path2D();
3677
+ t1.addPath(path2d, new DOMMatrix(pathMatrix));
3678
+
3679
+ var t2 = new Path2D();
3680
+ // see https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix/DOMMatrix
3681
+ t2.addPath(t1, new DOMMatrix([
3682
+ Math.cos(rotation) * scaleX,
3683
+ Math.sin(rotation) * scaleX,
3684
+ -Math.sin(rotation) * scaleY,
3685
+ Math.cos(rotation) * scaleY,
3686
+ x,
3687
+ y
3688
+ ]));
3689
+
3690
+ return t2;
3691
+ }
3692
+
3693
+ function shapeFromPath(pathData) {
3694
+ if (!canUsePaths) {
3695
+ throw new Error('path confetti are not supported in this browser');
3696
+ }
3697
+
3698
+ var path, matrix;
3699
+
3700
+ if (typeof pathData === 'string') {
3701
+ path = pathData;
3702
+ } else {
3703
+ path = pathData.path;
3704
+ matrix = pathData.matrix;
3705
+ }
3706
+
3707
+ var path2d = new Path2D(path);
3708
+ var tempCanvas = document.createElement('canvas');
3709
+ var tempCtx = tempCanvas.getContext('2d');
3710
+
3711
+ if (!matrix) {
3712
+ // attempt to figure out the width of the path, up to 1000x1000
3713
+ var maxSize = 1000;
3714
+ var minX = maxSize;
3715
+ var minY = maxSize;
3716
+ var maxX = 0;
3717
+ var maxY = 0;
3718
+ var width, height;
3719
+
3720
+ // do some line skipping... this is faster than checking
3721
+ // every pixel and will be mostly still correct
3722
+ for (var x = 0; x < maxSize; x += 2) {
3723
+ for (var y = 0; y < maxSize; y += 2) {
3724
+ if (tempCtx.isPointInPath(path2d, x, y, 'nonzero')) {
3725
+ minX = Math.min(minX, x);
3726
+ minY = Math.min(minY, y);
3727
+ maxX = Math.max(maxX, x);
3728
+ maxY = Math.max(maxY, y);
3729
+ }
3730
+ }
3731
+ }
3732
+
3733
+ width = maxX - minX;
3734
+ height = maxY - minY;
3735
+
3736
+ var maxDesiredSize = 10;
3737
+ var scale = Math.min(maxDesiredSize/width, maxDesiredSize/height);
3738
+
3739
+ matrix = [
3740
+ scale, 0, 0, scale,
3741
+ -Math.round((width/2) + minX) * scale,
3742
+ -Math.round((height/2) + minY) * scale
3743
+ ];
3744
+ }
3745
+
3746
+ return {
3747
+ type: 'path',
3748
+ path: path,
3749
+ matrix: matrix
3750
+ };
3751
+ }
3752
+
3753
+ function shapeFromText(textData) {
3754
+ var text,
3755
+ scalar = 1,
3756
+ color = '#000000',
3757
+ // see https://nolanlawson.com/2022/04/08/the-struggle-of-using-native-emoji-on-the-web/
3758
+ fontFamily = '"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';
3759
+
3760
+ if (typeof textData === 'string') {
3761
+ text = textData;
3762
+ } else {
3763
+ text = textData.text;
3764
+ scalar = 'scalar' in textData ? textData.scalar : scalar;
3765
+ fontFamily = 'fontFamily' in textData ? textData.fontFamily : fontFamily;
3766
+ color = 'color' in textData ? textData.color : color;
3767
+ }
3768
+
3769
+ // all other confetti are 10 pixels,
3770
+ // so this pixel size is the de-facto 100% scale confetti
3771
+ var fontSize = 10 * scalar;
3772
+ var font = '' + fontSize + 'px ' + fontFamily;
3773
+
3774
+ var canvas = new OffscreenCanvas(fontSize, fontSize);
3775
+ var ctx = canvas.getContext('2d');
3776
+
3777
+ ctx.font = font;
3778
+ var size = ctx.measureText(text);
3779
+ var width = Math.ceil(size.actualBoundingBoxRight + size.actualBoundingBoxLeft);
3780
+ var height = Math.ceil(size.actualBoundingBoxAscent + size.actualBoundingBoxDescent);
3781
+
3782
+ var padding = 2;
3783
+ var x = size.actualBoundingBoxLeft + padding;
3784
+ var y = size.actualBoundingBoxAscent + padding;
3785
+ width += padding + padding;
3786
+ height += padding + padding;
3787
+
3788
+ canvas = new OffscreenCanvas(width, height);
3789
+ ctx = canvas.getContext('2d');
3790
+ ctx.font = font;
3791
+ ctx.fillStyle = color;
3792
+
3793
+ ctx.fillText(text, x, y);
3794
+
3795
+ var scale = 1 / scalar;
3796
+
3797
+ return {
3798
+ type: 'bitmap',
3799
+ // TODO these probably need to be transfered for workers
3800
+ bitmap: canvas.transferToImageBitmap(),
3801
+ matrix: [scale, 0, 0, scale, -width * scale / 2, -height * scale / 2]
3802
+ };
3803
+ }
3804
+
3805
+ module.exports = function() {
3806
+ return getDefaultFire().apply(this, arguments);
3807
+ };
3808
+ module.exports.reset = function() {
3809
+ getDefaultFire().reset();
3810
+ };
3811
+ module.exports.create = confettiCannon;
3812
+ module.exports.shapeFromPath = shapeFromPath;
3813
+ module.exports.shapeFromText = shapeFromText;
3814
+ }((function () {
3815
+ if (typeof window !== 'undefined') {
3816
+ return window;
3817
+ }
3818
+
3819
+ if (typeof self !== 'undefined') {
3820
+ return self;
3821
+ }
3822
+
3823
+ return this || {};
3824
+ })(), module$1, false));
3825
+
3826
+ // end source content
3827
+
3828
+ var confetti = module$1.exports;
3829
+ module$1.exports.create;
3830
+
3831
+ const defaultColors = ['#22c55e', '#3b82f6', '#a855f7', '#f59e0b', '#ef4444', '#ec4899'];
3832
+ /**
3833
+ * Celebration component for triggering confetti and other celebration animations.
3834
+ *
3835
+ * @example
3836
+ * // Basic confetti on goal completion
3837
+ * <Celebration trigger={goalCompleted} onComplete={() => setGoalCompleted(false)} />
3838
+ *
3839
+ * @example
3840
+ * // Fireworks for major achievements
3841
+ * <Celebration trigger={achieved} type="fireworks" duration={3000} />
3842
+ *
3843
+ * @example
3844
+ * // Stars with custom colors
3845
+ * <Celebration trigger={true} type="stars" colors={['#ffd700', '#ffed4a']} />
3846
+ */
3847
+ function Celebration({ trigger = false, type = 'confetti', duration = 2000, particleCount = 100, spread = 70, origin = { x: 0.5, y: 0.6 }, colors = defaultColors, onComplete, enabled = true, }) {
3848
+ const animationRef = React.useRef(null);
3849
+ const endTimeRef = React.useRef(0);
3850
+ const fireConfetti = React.useCallback(() => {
3851
+ confetti({
3852
+ particleCount: Math.floor(particleCount / 3),
3853
+ spread,
3854
+ origin,
3855
+ colors,
3856
+ disableForReducedMotion: true,
3857
+ });
3858
+ }, [particleCount, spread, origin, colors]);
3859
+ const fireFireworks = React.useCallback(() => {
3860
+ const end = Date.now() + duration;
3861
+ endTimeRef.current = end;
3862
+ const frame = () => {
3863
+ confetti({
3864
+ particleCount: 3,
3865
+ angle: 60,
3866
+ spread: 55,
3867
+ origin: { x: 0 },
3868
+ colors,
3869
+ disableForReducedMotion: true,
3870
+ });
3871
+ confetti({
3872
+ particleCount: 3,
3873
+ angle: 120,
3874
+ spread: 55,
3875
+ origin: { x: 1 },
3876
+ colors,
3877
+ disableForReducedMotion: true,
3878
+ });
3879
+ if (Date.now() < endTimeRef.current) {
3880
+ animationRef.current = requestAnimationFrame(frame);
3881
+ }
3882
+ };
3883
+ frame();
3884
+ }, [duration, colors]);
3885
+ const fireStars = React.useCallback(() => {
3886
+ const defaults = {
3887
+ spread: 360,
3888
+ ticks: 50,
3889
+ gravity: 0,
3890
+ decay: 0.94,
3891
+ startVelocity: 30,
3892
+ colors,
3893
+ shapes: ['star'],
3894
+ disableForReducedMotion: true,
3895
+ };
3896
+ const shoot = () => {
3897
+ confetti({
3898
+ ...defaults,
3899
+ particleCount: 10,
3900
+ scalar: 1.2,
3901
+ origin: { x: Math.random(), y: Math.random() * 0.5 },
3902
+ });
3903
+ confetti({
3904
+ ...defaults,
3905
+ particleCount: 5,
3906
+ scalar: 0.75,
3907
+ origin: { x: Math.random(), y: Math.random() * 0.5 },
3908
+ });
3909
+ };
3910
+ shoot();
3911
+ setTimeout(shoot, 200);
3912
+ setTimeout(shoot, 400);
3913
+ }, [colors]);
3914
+ React.useEffect(() => {
3915
+ if (!trigger || !enabled)
3916
+ return;
3917
+ switch (type) {
3918
+ case 'fireworks':
3919
+ fireFireworks();
3920
+ break;
3921
+ case 'stars':
3922
+ fireStars();
3923
+ break;
3924
+ case 'confetti':
3925
+ default:
3926
+ // Fire multiple bursts for confetti
3927
+ fireConfetti();
3928
+ setTimeout(fireConfetti, 150);
3929
+ setTimeout(fireConfetti, 300);
3930
+ break;
3931
+ }
3932
+ const timeout = setTimeout(() => {
3933
+ onComplete?.();
3934
+ }, duration);
3935
+ return () => {
3936
+ clearTimeout(timeout);
3937
+ if (animationRef.current) {
3938
+ cancelAnimationFrame(animationRef.current);
3939
+ }
3940
+ };
3941
+ }, [trigger, type, enabled, duration, fireConfetti, fireFireworks, fireStars, onComplete]);
3942
+ // This component doesn't render anything visible
3943
+ return null;
3944
+ }
3945
+ /**
3946
+ * Hook for programmatically triggering celebrations
3947
+ */
3948
+ function useCelebration() {
3949
+ const celebrate = React.useCallback((options) => {
3950
+ const { type = 'confetti', particleCount = 100, spread = 70, origin = { x: 0.5, y: 0.6 }, colors = defaultColors, duration = 2000, } = options || {};
3951
+ switch (type) {
3952
+ case 'fireworks': {
3953
+ const end = Date.now() + duration;
3954
+ const frame = () => {
3955
+ confetti({
3956
+ particleCount: 3,
3957
+ angle: 60,
3958
+ spread: 55,
3959
+ origin: { x: 0 },
3960
+ colors,
3961
+ disableForReducedMotion: true,
3962
+ });
3963
+ confetti({
3964
+ particleCount: 3,
3965
+ angle: 120,
3966
+ spread: 55,
3967
+ origin: { x: 1 },
3968
+ colors,
3969
+ disableForReducedMotion: true,
3970
+ });
3971
+ if (Date.now() < end) {
3972
+ requestAnimationFrame(frame);
3973
+ }
3974
+ };
3975
+ frame();
3976
+ break;
3977
+ }
3978
+ case 'stars': {
3979
+ const defaults = {
3980
+ spread: 360,
3981
+ ticks: 50,
3982
+ gravity: 0,
3983
+ decay: 0.94,
3984
+ startVelocity: 30,
3985
+ colors,
3986
+ shapes: ['star'],
3987
+ disableForReducedMotion: true,
3988
+ };
3989
+ const shoot = () => {
3990
+ confetti({
3991
+ ...defaults,
3992
+ particleCount: 10,
3993
+ scalar: 1.2,
3994
+ origin: { x: Math.random(), y: Math.random() * 0.5 },
3995
+ });
3996
+ confetti({
3997
+ ...defaults,
3998
+ particleCount: 5,
3999
+ scalar: 0.75,
4000
+ origin: { x: Math.random(), y: Math.random() * 0.5 },
4001
+ });
4002
+ };
4003
+ shoot();
4004
+ setTimeout(shoot, 200);
4005
+ setTimeout(shoot, 400);
4006
+ break;
4007
+ }
4008
+ case 'confetti':
4009
+ default: {
4010
+ const fire = () => {
4011
+ confetti({
4012
+ particleCount: Math.floor(particleCount / 3),
4013
+ spread,
4014
+ origin,
4015
+ colors,
4016
+ disableForReducedMotion: true,
4017
+ });
4018
+ };
4019
+ fire();
4020
+ setTimeout(fire, 150);
4021
+ setTimeout(fire, 300);
4022
+ break;
4023
+ }
4024
+ }
4025
+ }, []);
4026
+ return { celebrate };
4027
+ }
4028
+
2943
4029
  /**
2944
4030
  * Stack component for arranging children vertically or horizontally with consistent spacing.
2945
4031
  *
@@ -59060,6 +60146,7 @@ exports.CardHeader = CardHeader;
59060
60146
  exports.CardTitle = CardTitle;
59061
60147
  exports.CardView = CardView;
59062
60148
  exports.Carousel = Carousel;
60149
+ exports.Celebration = Celebration;
59063
60150
  exports.Checkbox = Checkbox;
59064
60151
  exports.CheckboxList = CheckboxList;
59065
60152
  exports.Chip = Chip;
@@ -59228,6 +60315,7 @@ exports.statusManager = statusManager;
59228
60315
  exports.useBreadcrumbReset = useBreadcrumbReset;
59229
60316
  exports.useBreakpoint = useBreakpoint;
59230
60317
  exports.useBreakpointValue = useBreakpointValue;
60318
+ exports.useCelebration = useCelebration;
59231
60319
  exports.useColumnReorder = useColumnReorder;
59232
60320
  exports.useColumnResize = useColumnResize;
59233
60321
  exports.useCommandPalette = useCommandPalette;