proto-sudoku-wc 0.1.22 → 0.1.23

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.
@@ -273,74 +273,6 @@ class TimeoutError extends Error {
273
273
  }
274
274
  }
275
275
 
276
- // eslint-disable-next-line @typescript-eslint/ban-types
277
- const isObject = (value) => value !== null && typeof value === 'object';
278
-
279
- const validateAndMerge = (...sources) => {
280
- for (const source of sources) {
281
- if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {
282
- throw new TypeError('The `options` argument must be an object');
283
- }
284
- }
285
- return deepMerge({}, ...sources);
286
- };
287
- const mergeHeaders = (source1 = {}, source2 = {}) => {
288
- const result = new globalThis.Headers(source1);
289
- const isHeadersInstance = source2 instanceof globalThis.Headers;
290
- const source = new globalThis.Headers(source2);
291
- for (const [key, value] of source.entries()) {
292
- if ((isHeadersInstance && value === 'undefined') || value === undefined) {
293
- result.delete(key);
294
- }
295
- else {
296
- result.set(key, value);
297
- }
298
- }
299
- return result;
300
- };
301
- function newHookValue(original, incoming, property) {
302
- return (Object.hasOwn(incoming, property) && incoming[property] === undefined)
303
- ? []
304
- : deepMerge(original[property] ?? [], incoming[property] ?? []);
305
- }
306
- const mergeHooks = (original = {}, incoming = {}) => ({
307
- beforeRequest: newHookValue(original, incoming, 'beforeRequest'),
308
- beforeRetry: newHookValue(original, incoming, 'beforeRetry'),
309
- afterResponse: newHookValue(original, incoming, 'afterResponse'),
310
- beforeError: newHookValue(original, incoming, 'beforeError'),
311
- });
312
- // TODO: Make this strongly-typed (no `any`).
313
- const deepMerge = (...sources) => {
314
- let returnValue = {};
315
- let headers = {};
316
- let hooks = {};
317
- for (const source of sources) {
318
- if (Array.isArray(source)) {
319
- if (!Array.isArray(returnValue)) {
320
- returnValue = [];
321
- }
322
- returnValue = [...returnValue, ...source];
323
- }
324
- else if (isObject(source)) {
325
- for (let [key, value] of Object.entries(source)) {
326
- if (isObject(value) && key in returnValue) {
327
- value = deepMerge(returnValue[key], value);
328
- }
329
- returnValue = { ...returnValue, [key]: value };
330
- }
331
- if (isObject(source.hooks)) {
332
- hooks = mergeHooks(hooks, source.hooks);
333
- returnValue.hooks = hooks;
334
- }
335
- if (isObject(source.headers)) {
336
- headers = mergeHeaders(headers, source.headers);
337
- returnValue.headers = headers;
338
- }
339
- }
340
- }
341
- return returnValue;
342
- };
343
-
344
276
  const supportsRequestStreams = (() => {
345
277
  let duplexAccessed = false;
346
278
  let hasContentType = false;
@@ -381,6 +313,8 @@ const responseTypes = {
381
313
  };
382
314
  // The maximum value of a 32bit int (see issue #117)
383
315
  const maxSafeTimeout = 2_147_483_647;
316
+ // Size in bytes of a typical form boundary, used to help estimate upload size
317
+ const usualFormBoundarySize = new TextEncoder().encode('------WebKitFormBoundaryaxpyiPgbbPti10Rw').length;
384
318
  const stop = Symbol('stop');
385
319
  const kyOptionKeys = {
386
320
  json: true,
@@ -393,6 +327,7 @@ const kyOptionKeys = {
393
327
  hooks: true,
394
328
  throwHttpErrors: true,
395
329
  onDownloadProgress: true,
330
+ onUploadProgress: true,
396
331
  fetch: true,
397
332
  };
398
333
  const requestOptionsRegistry = {
@@ -414,6 +349,194 @@ const requestOptionsRegistry = {
414
349
  priority: true,
415
350
  };
416
351
 
352
+ // eslint-disable-next-line @typescript-eslint/ban-types
353
+ const getBodySize = (body) => {
354
+ if (!body) {
355
+ return 0;
356
+ }
357
+ if (body instanceof FormData) {
358
+ // This is an approximation, as FormData size calculation is not straightforward
359
+ let size = 0;
360
+ for (const [key, value] of body) {
361
+ size += usualFormBoundarySize;
362
+ size += new TextEncoder().encode(`Content-Disposition: form-data; name="${key}"`).length;
363
+ size += typeof value === 'string'
364
+ ? new TextEncoder().encode(value).length
365
+ : value.size;
366
+ }
367
+ return size;
368
+ }
369
+ if (body instanceof Blob) {
370
+ return body.size;
371
+ }
372
+ if (body instanceof ArrayBuffer) {
373
+ return body.byteLength;
374
+ }
375
+ if (typeof body === 'string') {
376
+ return new TextEncoder().encode(body).length;
377
+ }
378
+ if (body instanceof URLSearchParams) {
379
+ return new TextEncoder().encode(body.toString()).length;
380
+ }
381
+ if ('byteLength' in body) {
382
+ return (body).byteLength;
383
+ }
384
+ if (typeof body === 'object' && body !== null) {
385
+ try {
386
+ const jsonString = JSON.stringify(body);
387
+ return new TextEncoder().encode(jsonString).length;
388
+ }
389
+ catch {
390
+ return 0;
391
+ }
392
+ }
393
+ return 0; // Default case, unable to determine size
394
+ };
395
+ const streamResponse = (response, onDownloadProgress) => {
396
+ const totalBytes = Number(response.headers.get('content-length')) || 0;
397
+ let transferredBytes = 0;
398
+ if (response.status === 204) {
399
+ if (onDownloadProgress) {
400
+ onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());
401
+ }
402
+ return new Response(null, {
403
+ status: response.status,
404
+ statusText: response.statusText,
405
+ headers: response.headers,
406
+ });
407
+ }
408
+ return new Response(new ReadableStream({
409
+ async start(controller) {
410
+ const reader = response.body.getReader();
411
+ if (onDownloadProgress) {
412
+ onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());
413
+ }
414
+ async function read() {
415
+ const { done, value } = await reader.read();
416
+ if (done) {
417
+ controller.close();
418
+ return;
419
+ }
420
+ if (onDownloadProgress) {
421
+ transferredBytes += value.byteLength;
422
+ const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
423
+ onDownloadProgress({ percent, transferredBytes, totalBytes }, value);
424
+ }
425
+ controller.enqueue(value);
426
+ await read();
427
+ }
428
+ await read();
429
+ },
430
+ }), {
431
+ status: response.status,
432
+ statusText: response.statusText,
433
+ headers: response.headers,
434
+ });
435
+ };
436
+ const streamRequest = (request, onUploadProgress) => {
437
+ const totalBytes = getBodySize(request.body);
438
+ let transferredBytes = 0;
439
+ return new Request(request, {
440
+ // @ts-expect-error - Types are outdated.
441
+ duplex: 'half',
442
+ body: new ReadableStream({
443
+ async start(controller) {
444
+ const reader = request.body instanceof ReadableStream ? request.body.getReader() : new Response('').body.getReader();
445
+ async function read() {
446
+ const { done, value } = await reader.read();
447
+ if (done) {
448
+ // Ensure 100% progress is reported when the upload is complete
449
+ if (onUploadProgress) {
450
+ onUploadProgress({ percent: 1, transferredBytes, totalBytes: Math.max(totalBytes, transferredBytes) }, new Uint8Array());
451
+ }
452
+ controller.close();
453
+ return;
454
+ }
455
+ transferredBytes += value.byteLength;
456
+ let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
457
+ if (totalBytes < transferredBytes || percent === 1) {
458
+ percent = 0.99;
459
+ }
460
+ if (onUploadProgress) {
461
+ onUploadProgress({ percent: Number(percent.toFixed(2)), transferredBytes, totalBytes }, value);
462
+ }
463
+ controller.enqueue(value);
464
+ await read();
465
+ }
466
+ await read();
467
+ },
468
+ }),
469
+ });
470
+ };
471
+
472
+ // eslint-disable-next-line @typescript-eslint/ban-types
473
+ const isObject = (value) => value !== null && typeof value === 'object';
474
+
475
+ const validateAndMerge = (...sources) => {
476
+ for (const source of sources) {
477
+ if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {
478
+ throw new TypeError('The `options` argument must be an object');
479
+ }
480
+ }
481
+ return deepMerge({}, ...sources);
482
+ };
483
+ const mergeHeaders = (source1 = {}, source2 = {}) => {
484
+ const result = new globalThis.Headers(source1);
485
+ const isHeadersInstance = source2 instanceof globalThis.Headers;
486
+ const source = new globalThis.Headers(source2);
487
+ for (const [key, value] of source.entries()) {
488
+ if ((isHeadersInstance && value === 'undefined') || value === undefined) {
489
+ result.delete(key);
490
+ }
491
+ else {
492
+ result.set(key, value);
493
+ }
494
+ }
495
+ return result;
496
+ };
497
+ function newHookValue(original, incoming, property) {
498
+ return (Object.hasOwn(incoming, property) && incoming[property] === undefined)
499
+ ? []
500
+ : deepMerge(original[property] ?? [], incoming[property] ?? []);
501
+ }
502
+ const mergeHooks = (original = {}, incoming = {}) => ({
503
+ beforeRequest: newHookValue(original, incoming, 'beforeRequest'),
504
+ beforeRetry: newHookValue(original, incoming, 'beforeRetry'),
505
+ afterResponse: newHookValue(original, incoming, 'afterResponse'),
506
+ beforeError: newHookValue(original, incoming, 'beforeError'),
507
+ });
508
+ // TODO: Make this strongly-typed (no `any`).
509
+ const deepMerge = (...sources) => {
510
+ let returnValue = {};
511
+ let headers = {};
512
+ let hooks = {};
513
+ for (const source of sources) {
514
+ if (Array.isArray(source)) {
515
+ if (!Array.isArray(returnValue)) {
516
+ returnValue = [];
517
+ }
518
+ returnValue = [...returnValue, ...source];
519
+ }
520
+ else if (isObject(source)) {
521
+ for (let [key, value] of Object.entries(source)) {
522
+ if (isObject(value) && key in returnValue) {
523
+ value = deepMerge(returnValue[key], value);
524
+ }
525
+ returnValue = { ...returnValue, [key]: value };
526
+ }
527
+ if (isObject(source.hooks)) {
528
+ hooks = mergeHooks(hooks, source.hooks);
529
+ returnValue.hooks = hooks;
530
+ }
531
+ if (isObject(source.headers)) {
532
+ headers = mergeHeaders(headers, source.headers);
533
+ returnValue.headers = headers;
534
+ }
535
+ }
536
+ }
537
+ return returnValue;
538
+ };
539
+
417
540
  const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
418
541
  const retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];
419
542
  const retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
@@ -502,6 +625,8 @@ class Ky {
502
625
  }
503
626
  // Delay the fetch so that body method shortcuts can set the Accept header
504
627
  await Promise.resolve();
628
+ // Before using ky.request, _fetch clones it and saves the clone for future retries to use.
629
+ // If retry is not needed, close the cloned request's ReadableStream for memory safety.
505
630
  let response = await ky._fetch();
506
631
  for (const hook of ky._options.hooks.afterResponse) {
507
632
  // eslint-disable-next-line no-await-in-loop
@@ -519,8 +644,11 @@ class Ky {
519
644
  }
520
645
  throw error;
521
646
  }
647
+ // Now that we know a retry is not needed, close the ReadableStream of the cloned request.
648
+ if (!ky.request.bodyUsed) {
649
+ await ky.request.body?.cancel();
650
+ }
522
651
  // If `onDownloadProgress` is passed, it uses the stream API internally
523
- /* istanbul ignore next */
524
652
  if (ky._options.onDownloadProgress) {
525
653
  if (typeof ky._options.onDownloadProgress !== 'function') {
526
654
  throw new TypeError('The `onDownloadProgress` option must be a function');
@@ -528,7 +656,7 @@ class Ky {
528
656
  if (!supportsResponseStreams) {
529
657
  throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');
530
658
  }
531
- return ky._stream(response.clone(), ky._options.onDownloadProgress);
659
+ return streamResponse(response.clone(), ky._options.onDownloadProgress);
532
660
  }
533
661
  return response;
534
662
  };
@@ -595,15 +723,9 @@ class Ky {
595
723
  this._input = this._options.prefixUrl + this._input;
596
724
  }
597
725
  if (supportsAbortController) {
598
- this.abortController = new globalThis.AbortController();
599
726
  const originalSignal = this._options.signal ?? this._input.signal;
600
- if (originalSignal?.aborted) {
601
- this.abortController.abort(originalSignal?.reason);
602
- }
603
- originalSignal?.addEventListener('abort', () => {
604
- this.abortController.abort(originalSignal.reason);
605
- });
606
- this._options.signal = this.abortController.signal;
727
+ this.abortController = new globalThis.AbortController();
728
+ this._options.signal = originalSignal ? AbortSignal.any([originalSignal, this.abortController.signal]) : this.abortController.signal;
607
729
  }
608
730
  if (supportsRequestStreams) {
609
731
  // @ts-expect-error - Types are outdated.
@@ -630,6 +752,19 @@ class Ky {
630
752
  // The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.
631
753
  this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);
632
754
  }
755
+ // If `onUploadProgress` is passed, it uses the stream API internally
756
+ if (this._options.onUploadProgress) {
757
+ if (typeof this._options.onUploadProgress !== 'function') {
758
+ throw new TypeError('The `onUploadProgress` option must be a function');
759
+ }
760
+ if (!supportsRequestStreams) {
761
+ throw new Error('Request streams are not supported in your environment. The `duplex` option for `Request` is not available.');
762
+ }
763
+ const originalBody = this.request.body;
764
+ if (originalBody) {
765
+ this.request = streamRequest(this.request, this._options.onUploadProgress);
766
+ }
767
+ }
633
768
  }
634
769
  _calculateRetryDelay(error) {
635
770
  this._retryCount++;
@@ -716,48 +851,6 @@ class Ky {
716
851
  }
717
852
  return timeout(mainRequest, nonRequestOptions, this.abortController, this._options);
718
853
  }
719
- /* istanbul ignore next */
720
- _stream(response, onDownloadProgress) {
721
- const totalBytes = Number(response.headers.get('content-length')) || 0;
722
- let transferredBytes = 0;
723
- if (response.status === 204) {
724
- if (onDownloadProgress) {
725
- onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());
726
- }
727
- return new globalThis.Response(null, {
728
- status: response.status,
729
- statusText: response.statusText,
730
- headers: response.headers,
731
- });
732
- }
733
- return new globalThis.Response(new globalThis.ReadableStream({
734
- async start(controller) {
735
- const reader = response.body.getReader();
736
- if (onDownloadProgress) {
737
- onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());
738
- }
739
- async function read() {
740
- const { done, value } = await reader.read();
741
- if (done) {
742
- controller.close();
743
- return;
744
- }
745
- if (onDownloadProgress) {
746
- transferredBytes += value.byteLength;
747
- const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
748
- onDownloadProgress({ percent, transferredBytes, totalBytes }, value);
749
- }
750
- controller.enqueue(value);
751
- await read();
752
- }
753
- await read();
754
- },
755
- }), {
756
- status: response.status,
757
- statusText: response.statusText,
758
- headers: response.headers,
759
- });
760
- }
761
854
  }
762
855
 
763
856
  /*! MIT License © Sindre Sorhus */
@@ -271,74 +271,6 @@ class TimeoutError extends Error {
271
271
  }
272
272
  }
273
273
 
274
- // eslint-disable-next-line @typescript-eslint/ban-types
275
- const isObject = (value) => value !== null && typeof value === 'object';
276
-
277
- const validateAndMerge = (...sources) => {
278
- for (const source of sources) {
279
- if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {
280
- throw new TypeError('The `options` argument must be an object');
281
- }
282
- }
283
- return deepMerge({}, ...sources);
284
- };
285
- const mergeHeaders = (source1 = {}, source2 = {}) => {
286
- const result = new globalThis.Headers(source1);
287
- const isHeadersInstance = source2 instanceof globalThis.Headers;
288
- const source = new globalThis.Headers(source2);
289
- for (const [key, value] of source.entries()) {
290
- if ((isHeadersInstance && value === 'undefined') || value === undefined) {
291
- result.delete(key);
292
- }
293
- else {
294
- result.set(key, value);
295
- }
296
- }
297
- return result;
298
- };
299
- function newHookValue(original, incoming, property) {
300
- return (Object.hasOwn(incoming, property) && incoming[property] === undefined)
301
- ? []
302
- : deepMerge(original[property] ?? [], incoming[property] ?? []);
303
- }
304
- const mergeHooks = (original = {}, incoming = {}) => ({
305
- beforeRequest: newHookValue(original, incoming, 'beforeRequest'),
306
- beforeRetry: newHookValue(original, incoming, 'beforeRetry'),
307
- afterResponse: newHookValue(original, incoming, 'afterResponse'),
308
- beforeError: newHookValue(original, incoming, 'beforeError'),
309
- });
310
- // TODO: Make this strongly-typed (no `any`).
311
- const deepMerge = (...sources) => {
312
- let returnValue = {};
313
- let headers = {};
314
- let hooks = {};
315
- for (const source of sources) {
316
- if (Array.isArray(source)) {
317
- if (!Array.isArray(returnValue)) {
318
- returnValue = [];
319
- }
320
- returnValue = [...returnValue, ...source];
321
- }
322
- else if (isObject(source)) {
323
- for (let [key, value] of Object.entries(source)) {
324
- if (isObject(value) && key in returnValue) {
325
- value = deepMerge(returnValue[key], value);
326
- }
327
- returnValue = { ...returnValue, [key]: value };
328
- }
329
- if (isObject(source.hooks)) {
330
- hooks = mergeHooks(hooks, source.hooks);
331
- returnValue.hooks = hooks;
332
- }
333
- if (isObject(source.headers)) {
334
- headers = mergeHeaders(headers, source.headers);
335
- returnValue.headers = headers;
336
- }
337
- }
338
- }
339
- return returnValue;
340
- };
341
-
342
274
  const supportsRequestStreams = (() => {
343
275
  let duplexAccessed = false;
344
276
  let hasContentType = false;
@@ -379,6 +311,8 @@ const responseTypes = {
379
311
  };
380
312
  // The maximum value of a 32bit int (see issue #117)
381
313
  const maxSafeTimeout = 2_147_483_647;
314
+ // Size in bytes of a typical form boundary, used to help estimate upload size
315
+ const usualFormBoundarySize = new TextEncoder().encode('------WebKitFormBoundaryaxpyiPgbbPti10Rw').length;
382
316
  const stop = Symbol('stop');
383
317
  const kyOptionKeys = {
384
318
  json: true,
@@ -391,6 +325,7 @@ const kyOptionKeys = {
391
325
  hooks: true,
392
326
  throwHttpErrors: true,
393
327
  onDownloadProgress: true,
328
+ onUploadProgress: true,
394
329
  fetch: true,
395
330
  };
396
331
  const requestOptionsRegistry = {
@@ -412,6 +347,194 @@ const requestOptionsRegistry = {
412
347
  priority: true,
413
348
  };
414
349
 
350
+ // eslint-disable-next-line @typescript-eslint/ban-types
351
+ const getBodySize = (body) => {
352
+ if (!body) {
353
+ return 0;
354
+ }
355
+ if (body instanceof FormData) {
356
+ // This is an approximation, as FormData size calculation is not straightforward
357
+ let size = 0;
358
+ for (const [key, value] of body) {
359
+ size += usualFormBoundarySize;
360
+ size += new TextEncoder().encode(`Content-Disposition: form-data; name="${key}"`).length;
361
+ size += typeof value === 'string'
362
+ ? new TextEncoder().encode(value).length
363
+ : value.size;
364
+ }
365
+ return size;
366
+ }
367
+ if (body instanceof Blob) {
368
+ return body.size;
369
+ }
370
+ if (body instanceof ArrayBuffer) {
371
+ return body.byteLength;
372
+ }
373
+ if (typeof body === 'string') {
374
+ return new TextEncoder().encode(body).length;
375
+ }
376
+ if (body instanceof URLSearchParams) {
377
+ return new TextEncoder().encode(body.toString()).length;
378
+ }
379
+ if ('byteLength' in body) {
380
+ return (body).byteLength;
381
+ }
382
+ if (typeof body === 'object' && body !== null) {
383
+ try {
384
+ const jsonString = JSON.stringify(body);
385
+ return new TextEncoder().encode(jsonString).length;
386
+ }
387
+ catch {
388
+ return 0;
389
+ }
390
+ }
391
+ return 0; // Default case, unable to determine size
392
+ };
393
+ const streamResponse = (response, onDownloadProgress) => {
394
+ const totalBytes = Number(response.headers.get('content-length')) || 0;
395
+ let transferredBytes = 0;
396
+ if (response.status === 204) {
397
+ if (onDownloadProgress) {
398
+ onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());
399
+ }
400
+ return new Response(null, {
401
+ status: response.status,
402
+ statusText: response.statusText,
403
+ headers: response.headers,
404
+ });
405
+ }
406
+ return new Response(new ReadableStream({
407
+ async start(controller) {
408
+ const reader = response.body.getReader();
409
+ if (onDownloadProgress) {
410
+ onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());
411
+ }
412
+ async function read() {
413
+ const { done, value } = await reader.read();
414
+ if (done) {
415
+ controller.close();
416
+ return;
417
+ }
418
+ if (onDownloadProgress) {
419
+ transferredBytes += value.byteLength;
420
+ const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
421
+ onDownloadProgress({ percent, transferredBytes, totalBytes }, value);
422
+ }
423
+ controller.enqueue(value);
424
+ await read();
425
+ }
426
+ await read();
427
+ },
428
+ }), {
429
+ status: response.status,
430
+ statusText: response.statusText,
431
+ headers: response.headers,
432
+ });
433
+ };
434
+ const streamRequest = (request, onUploadProgress) => {
435
+ const totalBytes = getBodySize(request.body);
436
+ let transferredBytes = 0;
437
+ return new Request(request, {
438
+ // @ts-expect-error - Types are outdated.
439
+ duplex: 'half',
440
+ body: new ReadableStream({
441
+ async start(controller) {
442
+ const reader = request.body instanceof ReadableStream ? request.body.getReader() : new Response('').body.getReader();
443
+ async function read() {
444
+ const { done, value } = await reader.read();
445
+ if (done) {
446
+ // Ensure 100% progress is reported when the upload is complete
447
+ if (onUploadProgress) {
448
+ onUploadProgress({ percent: 1, transferredBytes, totalBytes: Math.max(totalBytes, transferredBytes) }, new Uint8Array());
449
+ }
450
+ controller.close();
451
+ return;
452
+ }
453
+ transferredBytes += value.byteLength;
454
+ let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
455
+ if (totalBytes < transferredBytes || percent === 1) {
456
+ percent = 0.99;
457
+ }
458
+ if (onUploadProgress) {
459
+ onUploadProgress({ percent: Number(percent.toFixed(2)), transferredBytes, totalBytes }, value);
460
+ }
461
+ controller.enqueue(value);
462
+ await read();
463
+ }
464
+ await read();
465
+ },
466
+ }),
467
+ });
468
+ };
469
+
470
+ // eslint-disable-next-line @typescript-eslint/ban-types
471
+ const isObject = (value) => value !== null && typeof value === 'object';
472
+
473
+ const validateAndMerge = (...sources) => {
474
+ for (const source of sources) {
475
+ if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {
476
+ throw new TypeError('The `options` argument must be an object');
477
+ }
478
+ }
479
+ return deepMerge({}, ...sources);
480
+ };
481
+ const mergeHeaders = (source1 = {}, source2 = {}) => {
482
+ const result = new globalThis.Headers(source1);
483
+ const isHeadersInstance = source2 instanceof globalThis.Headers;
484
+ const source = new globalThis.Headers(source2);
485
+ for (const [key, value] of source.entries()) {
486
+ if ((isHeadersInstance && value === 'undefined') || value === undefined) {
487
+ result.delete(key);
488
+ }
489
+ else {
490
+ result.set(key, value);
491
+ }
492
+ }
493
+ return result;
494
+ };
495
+ function newHookValue(original, incoming, property) {
496
+ return (Object.hasOwn(incoming, property) && incoming[property] === undefined)
497
+ ? []
498
+ : deepMerge(original[property] ?? [], incoming[property] ?? []);
499
+ }
500
+ const mergeHooks = (original = {}, incoming = {}) => ({
501
+ beforeRequest: newHookValue(original, incoming, 'beforeRequest'),
502
+ beforeRetry: newHookValue(original, incoming, 'beforeRetry'),
503
+ afterResponse: newHookValue(original, incoming, 'afterResponse'),
504
+ beforeError: newHookValue(original, incoming, 'beforeError'),
505
+ });
506
+ // TODO: Make this strongly-typed (no `any`).
507
+ const deepMerge = (...sources) => {
508
+ let returnValue = {};
509
+ let headers = {};
510
+ let hooks = {};
511
+ for (const source of sources) {
512
+ if (Array.isArray(source)) {
513
+ if (!Array.isArray(returnValue)) {
514
+ returnValue = [];
515
+ }
516
+ returnValue = [...returnValue, ...source];
517
+ }
518
+ else if (isObject(source)) {
519
+ for (let [key, value] of Object.entries(source)) {
520
+ if (isObject(value) && key in returnValue) {
521
+ value = deepMerge(returnValue[key], value);
522
+ }
523
+ returnValue = { ...returnValue, [key]: value };
524
+ }
525
+ if (isObject(source.hooks)) {
526
+ hooks = mergeHooks(hooks, source.hooks);
527
+ returnValue.hooks = hooks;
528
+ }
529
+ if (isObject(source.headers)) {
530
+ headers = mergeHeaders(headers, source.headers);
531
+ returnValue.headers = headers;
532
+ }
533
+ }
534
+ }
535
+ return returnValue;
536
+ };
537
+
415
538
  const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
416
539
  const retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];
417
540
  const retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
@@ -500,6 +623,8 @@ class Ky {
500
623
  }
501
624
  // Delay the fetch so that body method shortcuts can set the Accept header
502
625
  await Promise.resolve();
626
+ // Before using ky.request, _fetch clones it and saves the clone for future retries to use.
627
+ // If retry is not needed, close the cloned request's ReadableStream for memory safety.
503
628
  let response = await ky._fetch();
504
629
  for (const hook of ky._options.hooks.afterResponse) {
505
630
  // eslint-disable-next-line no-await-in-loop
@@ -517,8 +642,11 @@ class Ky {
517
642
  }
518
643
  throw error;
519
644
  }
645
+ // Now that we know a retry is not needed, close the ReadableStream of the cloned request.
646
+ if (!ky.request.bodyUsed) {
647
+ await ky.request.body?.cancel();
648
+ }
520
649
  // If `onDownloadProgress` is passed, it uses the stream API internally
521
- /* istanbul ignore next */
522
650
  if (ky._options.onDownloadProgress) {
523
651
  if (typeof ky._options.onDownloadProgress !== 'function') {
524
652
  throw new TypeError('The `onDownloadProgress` option must be a function');
@@ -526,7 +654,7 @@ class Ky {
526
654
  if (!supportsResponseStreams) {
527
655
  throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');
528
656
  }
529
- return ky._stream(response.clone(), ky._options.onDownloadProgress);
657
+ return streamResponse(response.clone(), ky._options.onDownloadProgress);
530
658
  }
531
659
  return response;
532
660
  };
@@ -593,15 +721,9 @@ class Ky {
593
721
  this._input = this._options.prefixUrl + this._input;
594
722
  }
595
723
  if (supportsAbortController) {
596
- this.abortController = new globalThis.AbortController();
597
724
  const originalSignal = this._options.signal ?? this._input.signal;
598
- if (originalSignal?.aborted) {
599
- this.abortController.abort(originalSignal?.reason);
600
- }
601
- originalSignal?.addEventListener('abort', () => {
602
- this.abortController.abort(originalSignal.reason);
603
- });
604
- this._options.signal = this.abortController.signal;
725
+ this.abortController = new globalThis.AbortController();
726
+ this._options.signal = originalSignal ? AbortSignal.any([originalSignal, this.abortController.signal]) : this.abortController.signal;
605
727
  }
606
728
  if (supportsRequestStreams) {
607
729
  // @ts-expect-error - Types are outdated.
@@ -628,6 +750,19 @@ class Ky {
628
750
  // The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.
629
751
  this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);
630
752
  }
753
+ // If `onUploadProgress` is passed, it uses the stream API internally
754
+ if (this._options.onUploadProgress) {
755
+ if (typeof this._options.onUploadProgress !== 'function') {
756
+ throw new TypeError('The `onUploadProgress` option must be a function');
757
+ }
758
+ if (!supportsRequestStreams) {
759
+ throw new Error('Request streams are not supported in your environment. The `duplex` option for `Request` is not available.');
760
+ }
761
+ const originalBody = this.request.body;
762
+ if (originalBody) {
763
+ this.request = streamRequest(this.request, this._options.onUploadProgress);
764
+ }
765
+ }
631
766
  }
632
767
  _calculateRetryDelay(error) {
633
768
  this._retryCount++;
@@ -714,48 +849,6 @@ class Ky {
714
849
  }
715
850
  return timeout(mainRequest, nonRequestOptions, this.abortController, this._options);
716
851
  }
717
- /* istanbul ignore next */
718
- _stream(response, onDownloadProgress) {
719
- const totalBytes = Number(response.headers.get('content-length')) || 0;
720
- let transferredBytes = 0;
721
- if (response.status === 204) {
722
- if (onDownloadProgress) {
723
- onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());
724
- }
725
- return new globalThis.Response(null, {
726
- status: response.status,
727
- statusText: response.statusText,
728
- headers: response.headers,
729
- });
730
- }
731
- return new globalThis.Response(new globalThis.ReadableStream({
732
- async start(controller) {
733
- const reader = response.body.getReader();
734
- if (onDownloadProgress) {
735
- onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());
736
- }
737
- async function read() {
738
- const { done, value } = await reader.read();
739
- if (done) {
740
- controller.close();
741
- return;
742
- }
743
- if (onDownloadProgress) {
744
- transferredBytes += value.byteLength;
745
- const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
746
- onDownloadProgress({ percent, transferredBytes, totalBytes }, value);
747
- }
748
- controller.enqueue(value);
749
- await read();
750
- }
751
- await read();
752
- },
753
- }), {
754
- status: response.status,
755
- statusText: response.statusText,
756
- headers: response.headers,
757
- });
758
- }
759
852
  }
760
853
 
761
854
  /*! MIT License © Sindre Sorhus */
@@ -0,0 +1,3 @@
1
+ import{h as t,g as e,f as n,r}from"./p-XZFwktKX.js";const o=e=>{const n=e.hex||"currentColor",r=e.size||24;return t("svg",{class:e.class,width:r,height:r,viewBox:"0 0 24 24",role:"img","aria-label":"title"},t("title",null,e.label||"alien"),t("g",{fill:n},t("path",{d:"M10.31 10.93C11.33 12.57 11.18 14.5 9.96 15.28C8.74 16.04 6.92 15.33\n 5.89 13.69C4.87 12.05 5.03 10.1 6.25 9.34C7.47 8.58 9.29 9.29 10.31\n 10.93M12 17.75C14 17.75 14.5 17 14.5 17C14.5 17 14 19 12 19C10 19 9.5\n 17.03 9.5 17C9.5 17 10 17.75 12 17.75M17.75 9.34C18.97 10.1 19.13 12.05\n 18.11 13.69C17.08 15.33 15.26 16.04 14.04 15.28C12.82 14.5 12.67 12.57\n 13.69 10.93C14.71 9.29 16.53 8.58 17.75 9.34M12 20C14.5 20 20 14.86 20\n 11C20 7.14 16.41 4 12 4C7.59 4 4 7.14 4 11C4 14.86 9.5 20 12 20M12 2C17.5\n 2 22 6.04 22 11C22 15.08 16.32 22 12 22C7.68 22 2 15.08 2 11C2 6.04 6.5 2\n 12 2Z"})),t("path",{d:"M0 0h24v24H0z",fill:"none"}))},s="proto-sudoku",a=`${s}::data`,i=`${s}::inputs`,l=`${s}::pick`,c=t=>{const e=localStorage.getItem(t);return e?JSON.parse(e):void 0},d=(t,e)=>{const n=JSON.stringify(e);localStorage.setItem(t,n)},f=()=>[...c(i)],h=t=>{d(i,t.join(""))},u=()=>{const t=c(l);return null!==t?t:void 0},p=t=>{d(l,t>=0&&t<81?t:null)},b="Check ?",g="New Puzzle",y=t=>!("isConnected"in t)||t.isConnected,w=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys())t.set(e,t.get(e).filter(y))})(...e)}),2e3)}})(),m=t=>"function"==typeof t?t():t;class v extends Error{response;request;options;constructor(t,e,n){const r=`${t.status||0===t.status?t.status:""} ${t.statusText||""}`.trim();super(`Request failed with ${r?`status code ${r}`:"an unknown error"}: ${e.method} ${e.url}`),this.name="HTTPError",this.response=t,this.request=e,this.options=n}}class x extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}const C=(()=>{let t=!1,e=!1;const n="function"==typeof globalThis.ReadableStream,r="function"==typeof globalThis.Request;if(n&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(t){if(t instanceof Error&&"unsupported BodyInit type"===t.message)return!1;throw t}return t&&!e})(),k="function"==typeof globalThis.AbortController,T="function"==typeof globalThis.ReadableStream,R="function"==typeof globalThis.FormData,E=["get","post","put","patch","head","delete"],M={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},S=2147483647,j=(new TextEncoder).encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,z=Symbol("stop"),A={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},P={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},B=t=>null!==t&&"object"==typeof t,U=(...t)=>{for(const e of t)if((!B(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return O({},...t)},q=(t={},e={})=>{const n=new globalThis.Headers(t),r=e instanceof globalThis.Headers,o=new globalThis.Headers(e);for(const[t,e]of o.entries())r&&"undefined"===e||void 0===e?n.delete(t):n.set(t,e);return n};function $(t,e,n){return Object.hasOwn(e,n)&&void 0===e[n]?[]:O(t[n]??[],e[n]??[])}const L=(t={},e={})=>({beforeRequest:$(t,e,"beforeRequest"),beforeRetry:$(t,e,"beforeRetry"),afterResponse:$(t,e,"afterResponse"),beforeError:$(t,e,"beforeError")}),O=(...t)=>{let e={},n={},r={};for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(B(o)){for(let[t,n]of Object.entries(o))B(n)&&t in e&&(n=O(e[t],n)),e={...e,[t]:n};B(o.hooks)&&(r=L(r,o.hooks),e.hooks=r),B(o.headers)&&(n=q(n,o.headers),e.headers=n)}return e},D=t=>E.includes(t)?t.toUpperCase():t,N={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3},H=(t={})=>{if("number"==typeof t)return{...N,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...N,...t}};class _{static create(t,e){const n=new _(t,e),r=async()=>{if("number"==typeof n._options.timeout&&n._options.timeout>S)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let t=await n._fetch();for(const e of n._options.hooks.afterResponse){const r=await e(n.request,n._options,n._decorateResponse(t.clone()));r instanceof globalThis.Response&&(t=r)}if(n._decorateResponse(t),!t.ok&&n._options.throwHttpErrors){let e=new v(t,n.request,n._options);for(const t of n._options.hooks.beforeError)e=await t(e);throw e}if(n.request.bodyUsed||await(n.request.body?.cancel()),n._options.onDownloadProgress){if("function"!=typeof n._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!T)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return((t,e)=>{const n=Number(t.headers.get("content-length"))||0;let r=0;return 204===t.status?(e&&e({percent:1,totalBytes:n,transferredBytes:r},new Uint8Array),new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new Response(new ReadableStream({async start(o){const s=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array),await async function t(){const{done:a,value:i}=await s.read();a?o.close():(e&&(r+=i.byteLength,e({percent:0===n?0:r/n,transferredBytes:r,totalBytes:n},i)),o.enqueue(i),await t())}()}}),{status:t.status,statusText:t.statusText,headers:t.headers})})(t.clone(),n._options.onDownloadProgress)}return t},o=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(r):r();for(const[t,r]of Object.entries(M))o[t]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||r);const s=await o;if("json"===t){if(204===s.status)return"";if(0===(await s.clone().arrayBuffer()).byteLength)return"";if(e.parseJson)return e.parseJson(await s.text())}return s[t]()};return o}request;abortController;_retryCount=0;_input;_options;constructor(t,e={}){if(this._input=t,this._options={...e,headers:q(this._input.headers,e.headers),hooks:L({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:D(e.method??this._input.method??"GET"),prefixUrl:String(e.prefixUrl||""),retry:H(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(k){const t=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=t?AbortSignal.any([t,this.abortController.signal]):this.abortController.signal}if(C&&(this._options.duplex="half"),void 0!==this._options.json&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const t="string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString(),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,"?"+t);!(R&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options)}if(this._options.onUploadProgress){if("function"!=typeof this._options.onUploadProgress)throw new TypeError("The `onUploadProgress` option must be a function");if(!C)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=((t,e)=>{const n=(t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,r]of t)e+=j,e+=(new TextEncoder).encode(`Content-Disposition: form-data; name="${n}"`).length,e+="string"==typeof r?(new TextEncoder).encode(r).length:r.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if("string"==typeof t)return(new TextEncoder).encode(t).length;if(t instanceof URLSearchParams)return(new TextEncoder).encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if("object"==typeof t&&null!==t)try{const e=JSON.stringify(t);return(new TextEncoder).encode(e).length}catch{return 0}return 0})(t.body);let r=0;return new Request(t,{duplex:"half",body:new ReadableStream({async start(o){const s=t.body instanceof ReadableStream?t.body.getReader():new Response("").body.getReader();await async function t(){const{done:a,value:i}=await s.read();if(a)return e&&e({percent:1,transferredBytes:r,totalBytes:Math.max(n,r)},new Uint8Array),void o.close();r+=i.byteLength;let l=0===n?0:r/n;(n<r||1===l)&&(l=.99),e&&e({percent:Number(l.toFixed(2)),transferredBytes:r,totalBytes:n},i),o.enqueue(i),await t()}()}})})})(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof x)throw t;if(t instanceof v){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const e=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(e&&this._options.retry.afterStatusCodes.includes(t.response.status)){let t=1e3*Number(e);Number.isNaN(t)?t=Date.parse(e)-Date.now():t>=Date.parse("2024-01-01")&&(t-=Date.now());const n=this._options.retry.maxRetryAfter??t;return t<n?t:n}if(413===t.response.status)throw t}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const n=Math.min(this._calculateRetryDelay(e),S);if(this._retryCount<1)throw e;await async function(t,{signal:e}){return new Promise(((n,r)=>{function o(){clearTimeout(s),r(e.reason)}e&&(e.throwIfAborted(),e.addEventListener("abort",o,{once:!0}));const s=setTimeout((()=>{e?.removeEventListener("abort",o),n()}),t)}))}(n,{signal:this._options.signal});for(const t of this._options.hooks.beforeRetry)if(await t({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===z)return;return this._retry(t)}}async _fetch(){for(const t of this._options.hooks.beforeRequest){const e=await t(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const t=((t,e)=>{const n={};for(const r in e)r in P||r in A||r in t||(n[r]=e[r]);return n})(this.request,this._options),e=this.request;return this.request=e.clone(),!1===this._options.timeout?this._options.fetch(e,t):async function(t,e,n,r){return new Promise(((o,s)=>{const a=setTimeout((()=>{n&&n.abort(),s(new x(t))}),r.timeout);r.fetch(t,e).then(o).catch(s).then((()=>{clearTimeout(a)}))}))}(e,t,this.abortController,this._options)}}
2
+ /*! MIT License © Sindre Sorhus */const J=t=>{const e=(e,n)=>_.create(e,U(t,n));for(const n of E)e[n]=(e,r)=>_.create(e,U(t,r,{method:n}));return e.create=t=>J(U(t)),e.extend=e=>("function"==typeof e&&(e=e(t??{})),J(U(t,e))),e.stop=z,e},X=J(),I={list:[],keys:[],locs:[],loading:!1,solved:!1,error:void 0,pick:void 0,data:void 0},{state:F}=(()=>{const t=((t,e=(t,e)=>t!==e)=>{const n=m(t);let r=new Map(Object.entries(n??{}));const o={dispose:[],get:[],set:[],reset:[]},s=()=>{r=new Map(Object.entries(m(t)??{})),o.reset.forEach((t=>t()))},a=t=>(o.get.forEach((e=>e(t))),r.get(t)),i=(t,n)=>{const s=r.get(t);e(n,s,t)&&(r.set(t,n),o.set.forEach((e=>e(t,n,s))))},l="undefined"==typeof Proxy?{}:new Proxy(n,{get:(t,e)=>a(e),ownKeys:()=>Array.from(r.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>r.has(e),set:(t,e,n)=>(i(e,n),!0)}),c=(t,e)=>(o[t].push(e),()=>{((t,e)=>{const n=t.indexOf(e);n>=0&&(t[n]=t[t.length-1],t.length--)})(o[t],e)});return{state:l,get:a,set:i,on:c,onChange:(e,n)=>{const r=c("set",((t,r)=>{t===e&&n(r)})),o=c("reset",(()=>n(m(t)[e])));return()=>{r(),o()}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(c("set",e.set)),e.get&&t.push(c("get",e.get)),e.reset&&t.push(c("reset",e.reset)),e.dispose&&t.push(c("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{o.dispose.forEach((t=>t())),s()},reset:s,forceUpdate:t=>{const e=r.get(t);o.set.forEach((n=>n(t,e,e)))}}})(I,void 0);return t.use((()=>{if("function"!=typeof e)return{};const t=new Map;return{dispose:()=>t.clear(),get:n=>{const r=e();r&&((t,e,n)=>{const r=t.get(e);r?r.includes(n)||r.push(n):t.set(e,[n])})(t,n,r)},set:e=>{const r=t.get(e);r&&t.set(e,r.filter(n)),w(t)},reset:()=>{t.forEach((t=>t.forEach(n))),w(t)}}})()),t})(),K=new Map([["row",new Map],["column",new Map],["box",new Map]]),W=["1","2","3","4","5","6","7","8","9"],Z=t=>{if(void 0!==t&&t.indx!=F.pick){const{isClue:e,indx:n,row:r,column:o,box:s}=t,a=((t,e,n,r)=>{const o=new Map([["row",e],["column",n],["box",r]]),s=new Set;return o.forEach(((e,n)=>{K.get(n).get(e).forEach((e=>{e!==t&&s.add(e)}))})),Array.from(s)})(n,r,o,s),i=e?[]:(t=>{const{list:e}=F,n=new Set;return t.map((t=>{const{key:r}=e[t];"."!=r&&n.add(r)})),W.filter((t=>!n.has(t)))})(a);F.pick=n,F.keys=i,F.locs=a}else F.pick=void 0,F.keys=[],F.locs=[];Q(F.pick)};let G;const V={local:"http://localhost:8080/api",netlify:"/.netlify/functions",vercel:"https://sudoku-rust-api.vercel.app/api"},Y=t=>{h(t)},Q=t=>{p(t)},tt=(t=!1)=>{F.list=[],F.keys=[],F.locs=[],F.loading=t,F.solved=!1,F.error=void 0,F.pick=void 0,F.data=void 0},et=(t,e=!0)=>{const{puzzle:n,ref:r}=t;e&&(h([]),d(a,t)),(t=>{if(t){const{puzzle:e,ref:n}=t,r=e?[...e]:[],o=n?atob(n):void 0,s=o?[...o]:[],a=r.map(((t,e)=>{const n=s[e],r=t===n,o=Math.floor(e/9),a=e%9,i=((t,e)=>e<3?t<3?0:t<6?3:6:e<6?t<3?1:t<6?4:7:t<3?2:t<6?5:8)(o,a);return((t,e,n,r)=>{new Map([["row",e],["column",n],["box",r]]).forEach(((e,n)=>{const r=K.get(n);r.has(e)?r.get(e).add(t):r.set(e,new Set([t]))}))})(e,o,a,i),{key:t,isClue:r,value:n,indx:e,row:o,column:a,box:i}}));(t=>{f().forEach(((e,n)=>{const r=t[n],{isClue:o}=r;o||(r.key=e)}))})(a),F.data=t,F.list=a}else F.data=void 0,F.list=[]})({puzzle:n,ref:r})},nt=t=>{F.list=[...t],t.length=0},rt={initApp:t=>{(t=>{const e=(t=>{const e=Object.keys(V).includes(t)?t:"vercel";return V[e]})(t);G=X.extend({hooks:{beforeRequest:[t=>{t.headers.set("X-Requested-With","ky"),t.headers.set("X-Custom-Header","foobar")}]},prefixUrl:e,timeout:1e4})})(t),tt();const e=c(a),n=u();if(e&&(et(e,!1),n>=0)){const{list:t}=F;Z(t[n])}},refresh:async()=>{tt(!0),Y([]),Q(F.pick);try{const t=await G.get("puzzle").json();et(t)}catch(t){const{message:e}=t;console.log("-- ",e),console.log(t),F.error=e}finally{F.loading=!1}},select:t=>{Z(t)},check:()=>{const{list:t}=F,e=[];let n=0,r=0,o=0;t.forEach((t=>{const{key:s,value:a,isClue:i}=t;i?o+=1:"."!==s&&(s!==a?(n+=1,t.key="."):r+=1),e.push(t.key)}));const s=o+r;Y(r?e:[]),n>0?nt(t):81===s&&(F.solved=!0)},input:t=>{const{pick:e,list:n}=F;n[e].key=t,nt(n)}},ot=(...t)=>t.filter(Boolean).join(" "),st=e=>{const n=e.hex||"currentColor",r=e.label||"loading...",o=e.size||24;return t("svg",{class:ot(e.class||"","animate-spin"),width:o,height:o,fill:"none",viewBox:"0 0 24 24",role:"img","aria-label":"title"},t("title",null,r),t("g",null,t("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:n,"stroke-width":"4"}),t("path",{class:"opacity-75",fill:n,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})),t("path",{d:"M0 0h24v24H0z",fill:"none"}))},at=e=>{const{message:n,salute:r,spinner:s=!1}=e;return t("div",{class:"mt-5 flex h-24px flex-row items-center"},t(s?st:o,{class:"mr-2"}),r?t("label",{class:"mr-1 font-bold"},r,":"):"",t("label",{class:"italic"},n))},it=()=>{const{solved:e,loading:n,error:r}=F;return t("div",{class:"flex flex-col"},n||r||e?"":t(at,{message:"Welcome, are you ready to play?..."}),n?t(at,{message:"Loading...",spinner:!0}):"",r?t(at,{message:r,salute:"ERROR"}):"",e?t(at,{message:"You solved the puzzle!!"}):"")},lt=e=>{const n=e.hex||"currentColor",r=e.size||24;return t("svg",{class:e.class,width:r,height:r,viewBox:"0 0 24 24",role:"img","aria-label":"title"},t("title",null,e.label||"fingerprint"),t("g",{fill:n},t("path",{d:"M17.81,4.47C17.73,4.47 17.65,4.45 17.58,4.41C15.66,3.42 14,3\n 12,3C10.03,3 8.15,3.47 6.44,4.41C6.2,4.54 5.9,4.45 5.76,4.21C5.63,3.97\n 5.72,3.66 5.96,3.53C7.82,2.5 9.86,2 12,2C14.14,2 16,2.47\n 18.04,3.5C18.29,3.65 18.38,3.95 18.25,4.19C18.16,4.37 18,4.47\n 17.81,4.47M3.5,9.72C3.4,9.72 3.3,9.69 3.21,9.63C3,9.47 2.93,9.16\n 3.09,8.93C4.08,7.53 5.34,6.43 6.84,5.66C10,4.04 14,4.03\n 17.15,5.65C18.65,6.42 19.91,7.5 20.9,8.9C21.06,9.12 21,9.44\n 20.78,9.6C20.55,9.76 20.24,9.71 20.08,9.5C19.18,8.22 18.04,7.23\n 16.69,6.54C13.82,5.07 10.15,5.07 7.29,6.55C5.93,7.25 4.79,8.25\n 3.89,9.5C3.81,9.65 3.66,9.72 3.5,9.72M9.75,21.79C9.62,21.79 9.5,21.74\n 9.4,21.64C8.53,20.77 8.06,20.21 7.39,19C6.7,17.77 6.34,16.27\n 6.34,14.66C6.34,11.69 8.88,9.27 12,9.27C15.12,9.27 17.66,11.69\n 17.66,14.66A0.5,0.5 0 0,1 17.16,15.16A0.5,0.5 0 0,1\n 16.66,14.66C16.66,12.24 14.57,10.27 12,10.27C9.43,10.27 7.34,12.24\n 7.34,14.66C7.34,16.1 7.66,17.43 8.27,18.5C8.91,19.66 9.35,20.15\n 10.12,20.93C10.31,21.13 10.31,21.44 10.12,21.64C10,21.74 9.88,21.79\n 9.75,21.79M16.92,19.94C15.73,19.94 14.68,19.64 13.82,19.05C12.33,18.04\n 11.44,16.4 11.44,14.66A0.5,0.5 0 0,1 11.94,14.16A0.5,0.5 0 0,1\n 12.44,14.66C12.44,16.07 13.16,17.4 14.38,18.22C15.09,18.7 15.92,18.93\n 16.92,18.93C17.16,18.93 17.56,18.9 17.96,18.83C18.23,18.78 18.5,18.96\n 18.54,19.24C18.59,19.5 18.41,19.77 18.13,19.82C17.56,19.93 17.06,19.94\n 16.92,19.94M14.91,22C14.87,22 14.82,22 14.78,22C13.19,21.54 12.15,20.95\n 11.06,19.88C9.66,18.5 8.89,16.64 8.89,14.66C8.89,13.04 10.27,11.72\n 11.97,11.72C13.67,11.72 15.05,13.04 15.05,14.66C15.05,15.73 16,16.6\n 17.13,16.6C18.28,16.6 19.21,15.73 19.21,14.66C19.21,10.89 15.96,7.83\n 11.96,7.83C9.12,7.83 6.5,9.41 5.35,11.86C4.96,12.67 4.76,13.62\n 4.76,14.66C4.76,15.44 4.83,16.67 5.43,18.27C5.53,18.53 5.4,18.82\n 5.14,18.91C4.88,19 4.59,18.87 4.5,18.62C4,17.31 3.77,16\n 3.77,14.66C3.77,13.46 4,12.37 4.45,11.42C5.78,8.63 8.73,6.82\n 11.96,6.82C16.5,6.82 20.21,10.33 20.21,14.65C20.21,16.27 18.83,17.59\n 17.13,17.59C15.43,17.59 14.05,16.27 14.05,14.65C14.05,13.58 13.12,12.71\n 11.97,12.71C10.82,12.71 9.89,13.58 9.89,14.65C9.89,16.36 10.55,17.96\n 11.76,19.16C12.71,20.1 13.62,20.62 15.03,21C15.3,21.08 15.45,21.36\n 15.38,21.62C15.33,21.85 15.12,22 14.91,22Z"})),t("path",{d:"M0 0h24v24H0z",fill:"none"}))},ct="eswat2",dt=()=>t("a",{class:"absolute right-0 top-0 text-clrs-gray hover:text-clrs-navy",href:"https://eswat2.dev","aria-label":ct,target:"blank",title:ct},t(lt,{label:ct})),ft=(e,n)=>t("h1",{class:ot("text-center uppercase text-clrs-red","mb-11 ml-0 mr-0 mt-11","text-6xl font-thin")},n),ht=e=>{const{label:n,callback:r,matched:o=!1}=e;return t("button",{class:ot("rounded-md border border-solid border-clrs-slate4 font-bold",n===b?"mr-2 bg-clrs-yellow px-3 py-2 text-clrs-navy":n===g?"mr-2 bg-clrs-navy px-3 py-2 text-white":"x"===n?"mr-1 bg-clrs-red px-2 py-1 text-white":o?"mr-1 bg-clrs-slate4 px-2 py-1 text-white":"mr-1 bg-gray-50 px-2 py-1 text-clrs-navy"),onClick:r},n)},ut=()=>{const{keys:e,list:n,pick:r,solved:o}=F,s=t=>()=>{rt.input(t)},a=o?[]:e,i=null!=r?n[r]:void 0;return t("div",{class:"mt-2 flex flex-row justify-end"},o||!i||i.isClue||"."==i.key?"":t(ht,{label:"x",callback:s(".")}),a.map((e=>t(ht,{label:e,callback:s(e),matched:i.key===e}))))},pt=[2,5,11,14,20,23,29,32,38,41,47,50,56,59,65,68,74,77],bt=pt.map((t=>t+1)),gt=[18,19,20,21,22,23,24,25,26,45,46,47,48,49,50,51,52,53],yt=gt.map((t=>t+9)),wt=e=>{const{cell:n,focus:r,selected:o,solved:s}=e,{key:a,isClue:i,indx:l}=n,c="."!=a?a:"";return t("label",{class:ot(`cell-${l}`,pt.includes(l)?"border-xbr-clrs-navy":"",bt.includes(l)?"border-xbl-clrs-navy":"",gt.includes(l)?"border-xbb-clrs-navy":"",yt.includes(l)?"border-xbt-clrs-navy":"","h-8 w-8 border border-solid text-center leading-8",o?"border-clrs-red bg-clrs-red-a50 text-clrs-red":r?"border-clrs-gray bg-clrs-green-a50 font-bold":i?"border-clrs-gray bg-clrs-silver":""!==c?"border-clrs-gray text-clrs-red":"border-clrs-gray"),onClick:((t,e)=>()=>{e||rt.select(t)})(n,s)},c)},mt=()=>{const{list:e,pick:n,locs:r,solved:o}=F;return t("div",{class:ot("flex flex-row flex-wrap","border border-solid border-clrs-navy","h-76p5 w-76p5 text-lg")},e.map(((e,s)=>{const a=!o&&s===n,i=!o&&r.includes(s);return t(wt,{cell:e,focus:i,selected:a,solved:o})})))},vt=()=>t("label",{class:"ml-auto align-top text-xs italic text-clrs-slate4"},"Tailwind ","4.0.17"),xt=t=>()=>{t.refresh()},Ct=t=>()=>{t.check()},kt=()=>{const{list:e,solved:n}=F;return t("div",{class:"flex flex-row"},t(ht,{label:g,callback:xt(rt)}),81!==e.length||n?"":t(ht,{label:b,callback:Ct(rt)}),t(vt,null))},Tt=class{constructor(t){r(this,t),this.tag="proto-sudoku",this.platform="vercel"}componentDidLoad(){rt.initApp(this.platform)}render(){return t("div",{key:"9f50eec975c4da5f4984b80380067d5155dda0d1",id:"app",class:"ds1-main relative max-w-min p-0.5"},t(dt,{key:"e7bab7e257022a9920f8b43785d9dc33ab7fed65"}),t(ft,{key:"d8c32e6b9c20b9fe6c8ff2e9fc7a9900057a2679"},"Sudoku"),t(mt,{key:"8a028015ae4380aaa54a406ccf5cc908816ca6a4"}),t(ut,{key:"951b6d20ca7a99ced4c60aa39fe040af6e96dd46"}),t("hr",{key:"35ba2812a3b068b21b5252c5f07d0b5dc2f18527",class:"ml-0 mr-0"}),t(kt,{key:"114e7edd4bf3da82ae344f56cb7e856ce17a6da8"}),t(it,{key:"2c15eb0ba714d1e0c378882c62ce575c428adc2a"}))}};Tt.style="/*! tailwindcss v4.0.17 | MIT License | https://tailwindcss.com */\n@layer theme, base, components, utilities;\n@layer theme {\n :root,\n :host {\n --font-sans:\n ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji',\n 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n --color-gray-50: oklch(0.985 0.002 247.839);\n --color-white: #fff;\n --spacing: 0.25rem;\n --text-xs: 0.75rem;\n --text-xs--line-height: calc(1 / 0.75);\n --text-lg: 1.125rem;\n --text-lg--line-height: calc(1.75 / 1.125);\n --text-6xl: 3.75rem;\n --text-6xl--line-height: 1;\n --font-weight-thin: 100;\n --font-weight-bold: 700;\n --radius-md: 0.375rem;\n --animate-spin: spin 1s linear infinite;\n }\n}\n@layer utilities {\n .absolute {\n position: absolute;\n }\n .relative {\n position: relative;\n }\n .top-0 {\n top: calc(var(--spacing) * 0);\n }\n .right-0 {\n right: calc(var(--spacing) * 0);\n }\n .m-6 {\n margin: calc(var(--spacing) * 6);\n }\n .mt-2 {\n margin-top: calc(var(--spacing) * 2);\n }\n .mt-5 {\n margin-top: calc(var(--spacing) * 5);\n }\n .mt-11 {\n margin-top: calc(var(--spacing) * 11);\n }\n .mr-0 {\n margin-right: calc(var(--spacing) * 0);\n }\n .mr-1 {\n margin-right: calc(var(--spacing) * 1);\n }\n .mr-2 {\n margin-right: calc(var(--spacing) * 2);\n }\n .mb-11 {\n margin-bottom: calc(var(--spacing) * 11);\n }\n .ml-0 {\n margin-left: calc(var(--spacing) * 0);\n }\n .ml-auto {\n margin-left: auto;\n }\n .flex {\n display: flex;\n }\n .h-8 {\n height: calc(var(--spacing) * 8);\n }\n .h-24px {\n height: 24px;\n }\n .h-76p5 {\n height: 19.125rem;\n }\n .w-8 {\n width: calc(var(--spacing) * 8);\n }\n .w-76p5 {\n width: 19.125rem;\n }\n .max-w-min {\n max-width: min-content;\n }\n .animate-spin {\n animation: var(--animate-spin);\n }\n .flex-col {\n flex-direction: column;\n }\n .flex-row {\n flex-direction: row;\n }\n .flex-wrap {\n flex-wrap: wrap;\n }\n .items-center {\n align-items: center;\n }\n .justify-end {\n justify-content: flex-end;\n }\n .rounded-md {\n border-radius: var(--radius-md);\n }\n .border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n .border-solid {\n --tw-border-style: solid;\n border-style: solid;\n }\n .border-clrs-gray {\n border-color: var(--clrs-gray, #aaaaaa);\n }\n .border-clrs-navy {\n border-color: var(--clrs-navy, #001f3f);\n }\n .border-clrs-red {\n border-color: var(--clrs-red, #ff4136);\n }\n .border-clrs-slate4 {\n border-color: var(--clrs-slate4, #4e5964);\n }\n .bg-clrs-green-a50 {\n background-color: var(--clrs-green-a50, #2ecc4050);\n }\n .bg-clrs-navy {\n background-color: var(--clrs-navy, #001f3f);\n }\n .bg-clrs-red {\n background-color: var(--clrs-red, #ff4136);\n }\n .bg-clrs-red-a50 {\n background-color: var(--clrs-red-a50, #ff413650);\n }\n .bg-clrs-silver {\n background-color: var(--clrs-silver, #dddddd);\n }\n .bg-clrs-slate4 {\n background-color: var(--clrs-slate4, #4e5964);\n }\n .bg-clrs-yellow {\n background-color: var(--clrs-yellow, #ffdc00);\n }\n .bg-gray-50 {\n background-color: var(--color-gray-50);\n }\n .p-0\\.5 {\n padding: calc(var(--spacing) * 0.5);\n }\n .px-2 {\n padding-inline: calc(var(--spacing) * 2);\n }\n .px-3 {\n padding-inline: calc(var(--spacing) * 3);\n }\n .py-1 {\n padding-block: calc(var(--spacing) * 1);\n }\n .py-2 {\n padding-block: calc(var(--spacing) * 2);\n }\n .text-center {\n text-align: center;\n }\n .align-top {\n vertical-align: top;\n }\n .font-sans {\n font-family: var(--font-sans);\n }\n .text-6xl {\n font-size: var(--text-6xl);\n line-height: var(--tw-leading, var(--text-6xl--line-height));\n }\n .text-lg {\n font-size: var(--text-lg);\n line-height: var(--tw-leading, var(--text-lg--line-height));\n }\n .text-xs {\n font-size: var(--text-xs);\n line-height: var(--tw-leading, var(--text-xs--line-height));\n }\n .leading-8 {\n --tw-leading: calc(var(--spacing) * 8);\n line-height: calc(var(--spacing) * 8);\n }\n .font-bold {\n --tw-font-weight: var(--font-weight-bold);\n font-weight: var(--font-weight-bold);\n }\n .font-thin {\n --tw-font-weight: var(--font-weight-thin);\n font-weight: var(--font-weight-thin);\n }\n .text-clrs-gray {\n color: var(--clrs-gray, #aaaaaa);\n }\n .text-clrs-navy {\n color: var(--clrs-navy, #001f3f);\n }\n .text-clrs-red {\n color: var(--clrs-red, #ff4136);\n }\n .text-clrs-slate4 {\n color: var(--clrs-slate4, #4e5964);\n }\n .text-white {\n color: var(--color-white);\n }\n .uppercase {\n text-transform: uppercase;\n }\n .italic {\n font-style: italic;\n }\n .opacity-25 {\n opacity: 25%;\n }\n .opacity-75 {\n opacity: 75%;\n }\n .shadow {\n --tw-shadow:\n 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)),\n 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));\n box-shadow:\n var(--tw-inset-shadow), var(--tw-inset-ring-shadow),\n var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n .border-xbb-clrs-navy {\n border-bottom: 1px solid var(--clrs-navy, #001f3f) !important;\n }\n .border-xbl-clrs-navy {\n border-left: 1px solid var(--clrs-navy, #001f3f) !important;\n }\n .border-xbr-clrs-navy {\n border-right: 1px solid var(--clrs-navy, #001f3f) !important;\n }\n .border-xbt-clrs-navy {\n border-top: 1px solid var(--clrs-navy, #001f3f) !important;\n }\n .hover\\:text-clrs-navy {\n &:hover {\n @media (hover: hover) {\n color: var(--clrs-navy, #001f3f);\n }\n }\n }\n}\n@layer components {\n .ds1-main {\n margin: calc(var(--spacing) * 6);\n display: flex;\n flex-direction: column;\n font-family: var(--font-sans);\n color: var(--clrs-navy, #001f3f);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n}\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n";export{Tt as proto_sudoku}
3
+ //# sourceMappingURL=p-d46d67c8.entry.js.map
@@ -1,2 +1,2 @@
1
- import{p as t,b as o}from"./p-XZFwktKX.js";export{s as setNonce}from"./p-XZFwktKX.js";import{g as p}from"./p-DQuL1Twl.js";(()=>{const o=import.meta.url,s={};return""!==o&&(s.resourcesUrl=new URL(".",o).href),t(s)})().then((async t=>(await p(),o([["p-2277b011",[[1,"proto-sudoku",{tag:[1],platform:[1]}]]]],t))));
1
+ import{p as t,b as o}from"./p-XZFwktKX.js";export{s as setNonce}from"./p-XZFwktKX.js";import{g as p}from"./p-DQuL1Twl.js";(()=>{const o=import.meta.url,s={};return""!==o&&(s.resourcesUrl=new URL(".",o).href),t(s)})().then((async t=>(await p(),o([["p-d46d67c8",[[1,"proto-sudoku",{tag:[1],platform:[1]}]]]],t))));
2
2
  //# sourceMappingURL=proto-sudoku-wc.esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proto-sudoku-wc",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "prototype - a simple Sudoku app rendered in Stencil and Tailwind",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@stencil/core": "4.28.2",
31
31
  "@stencil/store": "2.1.2",
32
- "ky": "1.7.5"
32
+ "ky": "1.8.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "autoprefixer": "10.4.21",
@@ -1,3 +0,0 @@
1
- import{h as t,g as e,f as n,r}from"./p-XZFwktKX.js";const o=e=>{const n=e.hex||"currentColor",r=e.size||24;return t("svg",{class:e.class,width:r,height:r,viewBox:"0 0 24 24",role:"img","aria-label":"title"},t("title",null,e.label||"alien"),t("g",{fill:n},t("path",{d:"M10.31 10.93C11.33 12.57 11.18 14.5 9.96 15.28C8.74 16.04 6.92 15.33\n 5.89 13.69C4.87 12.05 5.03 10.1 6.25 9.34C7.47 8.58 9.29 9.29 10.31\n 10.93M12 17.75C14 17.75 14.5 17 14.5 17C14.5 17 14 19 12 19C10 19 9.5\n 17.03 9.5 17C9.5 17 10 17.75 12 17.75M17.75 9.34C18.97 10.1 19.13 12.05\n 18.11 13.69C17.08 15.33 15.26 16.04 14.04 15.28C12.82 14.5 12.67 12.57\n 13.69 10.93C14.71 9.29 16.53 8.58 17.75 9.34M12 20C14.5 20 20 14.86 20\n 11C20 7.14 16.41 4 12 4C7.59 4 4 7.14 4 11C4 14.86 9.5 20 12 20M12 2C17.5\n 2 22 6.04 22 11C22 15.08 16.32 22 12 22C7.68 22 2 15.08 2 11C2 6.04 6.5 2\n 12 2Z"})),t("path",{d:"M0 0h24v24H0z",fill:"none"}))},s="proto-sudoku",a=`${s}::data`,i=`${s}::inputs`,l=`${s}::pick`,c=t=>{const e=localStorage.getItem(t);return e?JSON.parse(e):void 0},h=(t,e)=>{const n=JSON.stringify(e);localStorage.setItem(t,n)},d=()=>[...c(i)],f=t=>{h(i,t.join(""))},p=()=>{const t=c(l);return null!==t?t:void 0},u=t=>{h(l,t>=0&&t<81?t:null)},g="Check ?",b="New Puzzle",y=t=>!("isConnected"in t)||t.isConnected,m=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys())t.set(e,t.get(e).filter(y))})(...e)}),2e3)}})(),w=t=>"function"==typeof t?t():t;class v extends Error{response;request;options;constructor(t,e,n){const r=`${t.status||0===t.status?t.status:""} ${t.statusText||""}`.trim();super(`Request failed with ${r?`status code ${r}`:"an unknown error"}: ${e.method} ${e.url}`),this.name="HTTPError",this.response=t,this.request=e,this.options=n}}class x extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}const C=t=>null!==t&&"object"==typeof t,k=(...t)=>{for(const e of t)if((!C(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return E({},...t)},T=(t={},e={})=>{const n=new globalThis.Headers(t),r=e instanceof globalThis.Headers,o=new globalThis.Headers(e);for(const[t,e]of o.entries())r&&"undefined"===e||void 0===e?n.delete(t):n.set(t,e);return n};function R(t,e,n){return Object.hasOwn(e,n)&&void 0===e[n]?[]:E(t[n]??[],e[n]??[])}const M=(t={},e={})=>({beforeRequest:R(t,e,"beforeRequest"),beforeRetry:R(t,e,"beforeRetry"),afterResponse:R(t,e,"afterResponse"),beforeError:R(t,e,"beforeError")}),E=(...t)=>{let e={},n={},r={};for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(C(o)){for(let[t,n]of Object.entries(o))C(n)&&t in e&&(n=E(e[t],n)),e={...e,[t]:n};C(o.hooks)&&(r=M(r,o.hooks),e.hooks=r),C(o.headers)&&(n=T(n,o.headers),e.headers=n)}return e},z=(()=>{let t=!1,e=!1;const n="function"==typeof globalThis.ReadableStream,r="function"==typeof globalThis.Request;if(n&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(t){if(t instanceof Error&&"unsupported BodyInit type"===t.message)return!1;throw t}return t&&!e})(),j="function"==typeof globalThis.AbortController,S="function"==typeof globalThis.ReadableStream,A="function"==typeof globalThis.FormData,P=["get","post","put","patch","head","delete"],q={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},U=2147483647,$=Symbol("stop"),B={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},O={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},L=t=>P.includes(t)?t.toUpperCase():t,D={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3},N=(t={})=>{if("number"==typeof t)return{...D,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...D,...t}};class _{static create(t,e){const n=new _(t,e),r=async()=>{if("number"==typeof n._options.timeout&&n._options.timeout>U)throw new RangeError("The `timeout` option cannot be greater than 2147483647");await Promise.resolve();let t=await n._fetch();for(const e of n._options.hooks.afterResponse){const r=await e(n.request,n._options,n._decorateResponse(t.clone()));r instanceof globalThis.Response&&(t=r)}if(n._decorateResponse(t),!t.ok&&n._options.throwHttpErrors){let e=new v(t,n.request,n._options);for(const t of n._options.hooks.beforeError)e=await t(e);throw e}if(n._options.onDownloadProgress){if("function"!=typeof n._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!S)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(t.clone(),n._options.onDownloadProgress)}return t},o=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(r):r();for(const[t,r]of Object.entries(q))o[t]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||r);const s=await o;if("json"===t){if(204===s.status)return"";if(0===(await s.clone().arrayBuffer()).byteLength)return"";if(e.parseJson)return e.parseJson(await s.text())}return s[t]()};return o}request;abortController;_retryCount=0;_input;_options;constructor(t,e={}){if(this._input=t,this._options={...e,headers:T(this._input.headers,e.headers),hooks:M({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:L(e.method??this._input.method??"GET"),prefixUrl:String(e.prefixUrl||""),retry:N(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(j){this.abortController=new globalThis.AbortController;const t=this._options.signal??this._input.signal;t?.aborted&&this.abortController.abort(t?.reason),t?.addEventListener("abort",(()=>{this.abortController.abort(t.reason)})),this._options.signal=this.abortController.signal}if(z&&(this._options.duplex="half"),void 0!==this._options.json&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const t="string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString(),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,"?"+t);!(A&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof x)throw t;if(t instanceof v){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const e=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(e&&this._options.retry.afterStatusCodes.includes(t.response.status)){let t=1e3*Number(e);Number.isNaN(t)?t=Date.parse(e)-Date.now():t>=Date.parse("2024-01-01")&&(t-=Date.now());const n=this._options.retry.maxRetryAfter??t;return t<n?t:n}if(413===t.response.status)throw t}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const n=Math.min(this._calculateRetryDelay(e),U);if(this._retryCount<1)throw e;await async function(t,{signal:e}){return new Promise(((n,r)=>{function o(){clearTimeout(s),r(e.reason)}e&&(e.throwIfAborted(),e.addEventListener("abort",o,{once:!0}));const s=setTimeout((()=>{e?.removeEventListener("abort",o),n()}),t)}))}(n,{signal:this._options.signal});for(const t of this._options.hooks.beforeRetry)if(await t({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===$)return;return this._retry(t)}}async _fetch(){for(const t of this._options.hooks.beforeRequest){const e=await t(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const t=((t,e)=>{const n={};for(const r in e)r in O||r in B||r in t||(n[r]=e[r]);return n})(this.request,this._options),e=this.request;return this.request=e.clone(),!1===this._options.timeout?this._options.fetch(e,t):async function(t,e,n,r){return new Promise(((o,s)=>{const a=setTimeout((()=>{n&&n.abort(),s(new x(t))}),r.timeout);r.fetch(t,e).then(o).catch(s).then((()=>{clearTimeout(a)}))}))}(e,t,this.abortController,this._options)}_stream(t,e){const n=Number(t.headers.get("content-length"))||0;let r=0;return 204===t.status?(e&&e({percent:1,totalBytes:n,transferredBytes:r},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(o){const s=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array),await async function t(){const{done:a,value:i}=await s.read();a?o.close():(e&&(r+=i.byteLength,e({percent:0===n?0:r/n,transferredBytes:r,totalBytes:n},i)),o.enqueue(i),await t())}()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}}
2
- /*! MIT License © Sindre Sorhus */const H=t=>{const e=(e,n)=>_.create(e,k(t,n));for(const n of P)e[n]=(e,r)=>_.create(e,k(t,r,{method:n}));return e.create=t=>H(k(t)),e.extend=e=>("function"==typeof e&&(e=e(t??{})),H(k(t,e))),e.stop=$,e},X=H(),J={list:[],keys:[],locs:[],loading:!1,solved:!1,error:void 0,pick:void 0,data:void 0},{state:I}=(()=>{const t=((t,e=(t,e)=>t!==e)=>{const n=w(t);let r=new Map(Object.entries(n??{}));const o={dispose:[],get:[],set:[],reset:[]},s=()=>{r=new Map(Object.entries(w(t)??{})),o.reset.forEach((t=>t()))},a=t=>(o.get.forEach((e=>e(t))),r.get(t)),i=(t,n)=>{const s=r.get(t);e(n,s,t)&&(r.set(t,n),o.set.forEach((e=>e(t,n,s))))},l="undefined"==typeof Proxy?{}:new Proxy(n,{get:(t,e)=>a(e),ownKeys:()=>Array.from(r.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>r.has(e),set:(t,e,n)=>(i(e,n),!0)}),c=(t,e)=>(o[t].push(e),()=>{((t,e)=>{const n=t.indexOf(e);n>=0&&(t[n]=t[t.length-1],t.length--)})(o[t],e)});return{state:l,get:a,set:i,on:c,onChange:(e,n)=>{const r=c("set",((t,r)=>{t===e&&n(r)})),o=c("reset",(()=>n(w(t)[e])));return()=>{r(),o()}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(c("set",e.set)),e.get&&t.push(c("get",e.get)),e.reset&&t.push(c("reset",e.reset)),e.dispose&&t.push(c("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{o.dispose.forEach((t=>t())),s()},reset:s,forceUpdate:t=>{const e=r.get(t);o.set.forEach((n=>n(t,e,e)))}}})(J,void 0);return t.use((()=>{if("function"!=typeof e)return{};const t=new Map;return{dispose:()=>t.clear(),get:n=>{const r=e();r&&((t,e,n)=>{const r=t.get(e);r?r.includes(n)||r.push(n):t.set(e,[n])})(t,n,r)},set:e=>{const r=t.get(e);r&&t.set(e,r.filter(n)),m(t)},reset:()=>{t.forEach((t=>t.forEach(n))),m(t)}}})()),t})(),Z=new Map([["row",new Map],["column",new Map],["box",new Map]]),K=["1","2","3","4","5","6","7","8","9"],W=t=>{if(void 0!==t&&t.indx!=I.pick){const{isClue:e,indx:n,row:r,column:o,box:s}=t,a=((t,e,n,r)=>{const o=new Map([["row",e],["column",n],["box",r]]),s=new Set;return o.forEach(((e,n)=>{Z.get(n).get(e).forEach((e=>{e!==t&&s.add(e)}))})),Array.from(s)})(n,r,o,s),i=e?[]:(t=>{const{list:e}=I,n=new Set;return t.map((t=>{const{key:r}=e[t];"."!=r&&n.add(r)})),K.filter((t=>!n.has(t)))})(a);I.pick=n,I.keys=i,I.locs=a}else I.pick=void 0,I.keys=[],I.locs=[];Y(I.pick)};let F;const G={local:"http://localhost:8080/api",netlify:"/.netlify/functions",vercel:"https://sudoku-rust-api.vercel.app/api"},V=t=>{f(t)},Y=t=>{u(t)},Q=(t=!1)=>{I.list=[],I.keys=[],I.locs=[],I.loading=t,I.solved=!1,I.error=void 0,I.pick=void 0,I.data=void 0},tt=(t,e=!0)=>{const{puzzle:n,ref:r}=t;e&&(f([]),h(a,t)),(t=>{if(t){const{puzzle:e,ref:n}=t,r=e?[...e]:[],o=n?atob(n):void 0,s=o?[...o]:[],a=r.map(((t,e)=>{const n=s[e],r=t===n,o=Math.floor(e/9),a=e%9,i=((t,e)=>e<3?t<3?0:t<6?3:6:e<6?t<3?1:t<6?4:7:t<3?2:t<6?5:8)(o,a);return((t,e,n,r)=>{new Map([["row",e],["column",n],["box",r]]).forEach(((e,n)=>{const r=Z.get(n);r.has(e)?r.get(e).add(t):r.set(e,new Set([t]))}))})(e,o,a,i),{key:t,isClue:r,value:n,indx:e,row:o,column:a,box:i}}));(t=>{d().forEach(((e,n)=>{const r=t[n],{isClue:o}=r;o||(r.key=e)}))})(a),I.data=t,I.list=a}else I.data=void 0,I.list=[]})({puzzle:n,ref:r})},et=t=>{I.list=[...t],t.length=0},nt={initApp:t=>{(t=>{const e=(t=>{const e=Object.keys(G).includes(t)?t:"vercel";return G[e]})(t);F=X.extend({hooks:{beforeRequest:[t=>{t.headers.set("X-Requested-With","ky"),t.headers.set("X-Custom-Header","foobar")}]},prefixUrl:e,timeout:1e4})})(t),Q();const e=c(a),n=p();if(e&&(tt(e,!1),n>=0)){const{list:t}=I;W(t[n])}},refresh:async()=>{Q(!0),V([]),Y(I.pick);try{const t=await F.get("puzzle").json();tt(t)}catch(t){const{message:e}=t;console.log("-- ",e),console.log(t),I.error=e}finally{I.loading=!1}},select:t=>{W(t)},check:()=>{const{list:t}=I,e=[];let n=0,r=0,o=0;t.forEach((t=>{const{key:s,value:a,isClue:i}=t;i?o+=1:"."!==s&&(s!==a?(n+=1,t.key="."):r+=1),e.push(t.key)}));const s=o+r;V(r?e:[]),n>0?et(t):81===s&&(I.solved=!0)},input:t=>{const{pick:e,list:n}=I;n[e].key=t,et(n)}},rt=(...t)=>t.filter(Boolean).join(" "),ot=e=>{const n=e.hex||"currentColor",r=e.label||"loading...",o=e.size||24;return t("svg",{class:rt(e.class||"","animate-spin"),width:o,height:o,fill:"none",viewBox:"0 0 24 24",role:"img","aria-label":"title"},t("title",null,r),t("g",null,t("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:n,"stroke-width":"4"}),t("path",{class:"opacity-75",fill:n,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})),t("path",{d:"M0 0h24v24H0z",fill:"none"}))},st=e=>{const{message:n,salute:r,spinner:s=!1}=e;return t("div",{class:"mt-5 flex h-24px flex-row items-center"},t(s?ot:o,{class:"mr-2"}),r?t("label",{class:"mr-1 font-bold"},r,":"):"",t("label",{class:"italic"},n))},at=()=>{const{solved:e,loading:n,error:r}=I;return t("div",{class:"flex flex-col"},n||r||e?"":t(st,{message:"Welcome, are you ready to play?..."}),n?t(st,{message:"Loading...",spinner:!0}):"",r?t(st,{message:r,salute:"ERROR"}):"",e?t(st,{message:"You solved the puzzle!!"}):"")},it=e=>{const n=e.hex||"currentColor",r=e.size||24;return t("svg",{class:e.class,width:r,height:r,viewBox:"0 0 24 24",role:"img","aria-label":"title"},t("title",null,e.label||"fingerprint"),t("g",{fill:n},t("path",{d:"M17.81,4.47C17.73,4.47 17.65,4.45 17.58,4.41C15.66,3.42 14,3\n 12,3C10.03,3 8.15,3.47 6.44,4.41C6.2,4.54 5.9,4.45 5.76,4.21C5.63,3.97\n 5.72,3.66 5.96,3.53C7.82,2.5 9.86,2 12,2C14.14,2 16,2.47\n 18.04,3.5C18.29,3.65 18.38,3.95 18.25,4.19C18.16,4.37 18,4.47\n 17.81,4.47M3.5,9.72C3.4,9.72 3.3,9.69 3.21,9.63C3,9.47 2.93,9.16\n 3.09,8.93C4.08,7.53 5.34,6.43 6.84,5.66C10,4.04 14,4.03\n 17.15,5.65C18.65,6.42 19.91,7.5 20.9,8.9C21.06,9.12 21,9.44\n 20.78,9.6C20.55,9.76 20.24,9.71 20.08,9.5C19.18,8.22 18.04,7.23\n 16.69,6.54C13.82,5.07 10.15,5.07 7.29,6.55C5.93,7.25 4.79,8.25\n 3.89,9.5C3.81,9.65 3.66,9.72 3.5,9.72M9.75,21.79C9.62,21.79 9.5,21.74\n 9.4,21.64C8.53,20.77 8.06,20.21 7.39,19C6.7,17.77 6.34,16.27\n 6.34,14.66C6.34,11.69 8.88,9.27 12,9.27C15.12,9.27 17.66,11.69\n 17.66,14.66A0.5,0.5 0 0,1 17.16,15.16A0.5,0.5 0 0,1\n 16.66,14.66C16.66,12.24 14.57,10.27 12,10.27C9.43,10.27 7.34,12.24\n 7.34,14.66C7.34,16.1 7.66,17.43 8.27,18.5C8.91,19.66 9.35,20.15\n 10.12,20.93C10.31,21.13 10.31,21.44 10.12,21.64C10,21.74 9.88,21.79\n 9.75,21.79M16.92,19.94C15.73,19.94 14.68,19.64 13.82,19.05C12.33,18.04\n 11.44,16.4 11.44,14.66A0.5,0.5 0 0,1 11.94,14.16A0.5,0.5 0 0,1\n 12.44,14.66C12.44,16.07 13.16,17.4 14.38,18.22C15.09,18.7 15.92,18.93\n 16.92,18.93C17.16,18.93 17.56,18.9 17.96,18.83C18.23,18.78 18.5,18.96\n 18.54,19.24C18.59,19.5 18.41,19.77 18.13,19.82C17.56,19.93 17.06,19.94\n 16.92,19.94M14.91,22C14.87,22 14.82,22 14.78,22C13.19,21.54 12.15,20.95\n 11.06,19.88C9.66,18.5 8.89,16.64 8.89,14.66C8.89,13.04 10.27,11.72\n 11.97,11.72C13.67,11.72 15.05,13.04 15.05,14.66C15.05,15.73 16,16.6\n 17.13,16.6C18.28,16.6 19.21,15.73 19.21,14.66C19.21,10.89 15.96,7.83\n 11.96,7.83C9.12,7.83 6.5,9.41 5.35,11.86C4.96,12.67 4.76,13.62\n 4.76,14.66C4.76,15.44 4.83,16.67 5.43,18.27C5.53,18.53 5.4,18.82\n 5.14,18.91C4.88,19 4.59,18.87 4.5,18.62C4,17.31 3.77,16\n 3.77,14.66C3.77,13.46 4,12.37 4.45,11.42C5.78,8.63 8.73,6.82\n 11.96,6.82C16.5,6.82 20.21,10.33 20.21,14.65C20.21,16.27 18.83,17.59\n 17.13,17.59C15.43,17.59 14.05,16.27 14.05,14.65C14.05,13.58 13.12,12.71\n 11.97,12.71C10.82,12.71 9.89,13.58 9.89,14.65C9.89,16.36 10.55,17.96\n 11.76,19.16C12.71,20.1 13.62,20.62 15.03,21C15.3,21.08 15.45,21.36\n 15.38,21.62C15.33,21.85 15.12,22 14.91,22Z"})),t("path",{d:"M0 0h24v24H0z",fill:"none"}))},lt="eswat2",ct=()=>t("a",{class:"absolute right-0 top-0 text-clrs-gray hover:text-clrs-navy",href:"https://eswat2.dev","aria-label":lt,target:"blank",title:lt},t(it,{label:lt})),ht=(e,n)=>t("h1",{class:rt("text-center uppercase text-clrs-red","mb-11 ml-0 mr-0 mt-11","text-6xl font-thin")},n),dt=e=>{const{label:n,callback:r,matched:o=!1}=e;return t("button",{class:rt("rounded-md border border-solid border-clrs-slate4 font-bold",n===g?"mr-2 bg-clrs-yellow px-3 py-2 text-clrs-navy":n===b?"mr-2 bg-clrs-navy px-3 py-2 text-white":"x"===n?"mr-1 bg-clrs-red px-2 py-1 text-white":o?"mr-1 bg-clrs-slate4 px-2 py-1 text-white":"mr-1 bg-gray-50 px-2 py-1 text-clrs-navy"),onClick:r},n)},ft=()=>{const{keys:e,list:n,pick:r,solved:o}=I,s=t=>()=>{nt.input(t)},a=o?[]:e,i=null!=r?n[r]:void 0;return t("div",{class:"mt-2 flex flex-row justify-end"},o||!i||i.isClue||"."==i.key?"":t(dt,{label:"x",callback:s(".")}),a.map((e=>t(dt,{label:e,callback:s(e),matched:i.key===e}))))},pt=[2,5,11,14,20,23,29,32,38,41,47,50,56,59,65,68,74,77],ut=pt.map((t=>t+1)),gt=[18,19,20,21,22,23,24,25,26,45,46,47,48,49,50,51,52,53],bt=gt.map((t=>t+9)),yt=e=>{const{cell:n,focus:r,selected:o,solved:s}=e,{key:a,isClue:i,indx:l}=n,c="."!=a?a:"";return t("label",{class:rt(`cell-${l}`,pt.includes(l)?"border-xbr-clrs-navy":"",ut.includes(l)?"border-xbl-clrs-navy":"",gt.includes(l)?"border-xbb-clrs-navy":"",bt.includes(l)?"border-xbt-clrs-navy":"","h-8 w-8 border border-solid text-center leading-8",o?"border-clrs-red bg-clrs-red-a50 text-clrs-red":r?"border-clrs-gray bg-clrs-green-a50 font-bold":i?"border-clrs-gray bg-clrs-silver":""!==c?"border-clrs-gray text-clrs-red":"border-clrs-gray"),onClick:((t,e)=>()=>{e||nt.select(t)})(n,s)},c)},mt=()=>{const{list:e,pick:n,locs:r,solved:o}=I;return t("div",{class:rt("flex flex-row flex-wrap","border border-solid border-clrs-navy","h-76p5 w-76p5 text-lg")},e.map(((e,s)=>{const a=!o&&s===n,i=!o&&r.includes(s);return t(yt,{cell:e,focus:i,selected:a,solved:o})})))},wt=()=>t("label",{class:"ml-auto align-top text-xs italic text-clrs-slate4"},"Tailwind ","4.0.17"),vt=t=>()=>{t.refresh()},xt=t=>()=>{t.check()},Ct=()=>{const{list:e,solved:n}=I;return t("div",{class:"flex flex-row"},t(dt,{label:b,callback:vt(nt)}),81!==e.length||n?"":t(dt,{label:g,callback:xt(nt)}),t(wt,null))},kt=class{constructor(t){r(this,t),this.tag="proto-sudoku",this.platform="vercel"}componentDidLoad(){nt.initApp(this.platform)}render(){return t("div",{key:"9f50eec975c4da5f4984b80380067d5155dda0d1",id:"app",class:"ds1-main relative max-w-min p-0.5"},t(ct,{key:"e7bab7e257022a9920f8b43785d9dc33ab7fed65"}),t(ht,{key:"d8c32e6b9c20b9fe6c8ff2e9fc7a9900057a2679"},"Sudoku"),t(mt,{key:"8a028015ae4380aaa54a406ccf5cc908816ca6a4"}),t(ft,{key:"951b6d20ca7a99ced4c60aa39fe040af6e96dd46"}),t("hr",{key:"35ba2812a3b068b21b5252c5f07d0b5dc2f18527",class:"ml-0 mr-0"}),t(Ct,{key:"114e7edd4bf3da82ae344f56cb7e856ce17a6da8"}),t(at,{key:"2c15eb0ba714d1e0c378882c62ce575c428adc2a"}))}};kt.style="/*! tailwindcss v4.0.17 | MIT License | https://tailwindcss.com */\n@layer theme, base, components, utilities;\n@layer theme {\n :root,\n :host {\n --font-sans:\n ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji',\n 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n --color-gray-50: oklch(0.985 0.002 247.839);\n --color-white: #fff;\n --spacing: 0.25rem;\n --text-xs: 0.75rem;\n --text-xs--line-height: calc(1 / 0.75);\n --text-lg: 1.125rem;\n --text-lg--line-height: calc(1.75 / 1.125);\n --text-6xl: 3.75rem;\n --text-6xl--line-height: 1;\n --font-weight-thin: 100;\n --font-weight-bold: 700;\n --radius-md: 0.375rem;\n --animate-spin: spin 1s linear infinite;\n }\n}\n@layer utilities {\n .absolute {\n position: absolute;\n }\n .relative {\n position: relative;\n }\n .top-0 {\n top: calc(var(--spacing) * 0);\n }\n .right-0 {\n right: calc(var(--spacing) * 0);\n }\n .m-6 {\n margin: calc(var(--spacing) * 6);\n }\n .mt-2 {\n margin-top: calc(var(--spacing) * 2);\n }\n .mt-5 {\n margin-top: calc(var(--spacing) * 5);\n }\n .mt-11 {\n margin-top: calc(var(--spacing) * 11);\n }\n .mr-0 {\n margin-right: calc(var(--spacing) * 0);\n }\n .mr-1 {\n margin-right: calc(var(--spacing) * 1);\n }\n .mr-2 {\n margin-right: calc(var(--spacing) * 2);\n }\n .mb-11 {\n margin-bottom: calc(var(--spacing) * 11);\n }\n .ml-0 {\n margin-left: calc(var(--spacing) * 0);\n }\n .ml-auto {\n margin-left: auto;\n }\n .flex {\n display: flex;\n }\n .h-8 {\n height: calc(var(--spacing) * 8);\n }\n .h-24px {\n height: 24px;\n }\n .h-76p5 {\n height: 19.125rem;\n }\n .w-8 {\n width: calc(var(--spacing) * 8);\n }\n .w-76p5 {\n width: 19.125rem;\n }\n .max-w-min {\n max-width: min-content;\n }\n .animate-spin {\n animation: var(--animate-spin);\n }\n .flex-col {\n flex-direction: column;\n }\n .flex-row {\n flex-direction: row;\n }\n .flex-wrap {\n flex-wrap: wrap;\n }\n .items-center {\n align-items: center;\n }\n .justify-end {\n justify-content: flex-end;\n }\n .rounded-md {\n border-radius: var(--radius-md);\n }\n .border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n .border-solid {\n --tw-border-style: solid;\n border-style: solid;\n }\n .border-clrs-gray {\n border-color: var(--clrs-gray, #aaaaaa);\n }\n .border-clrs-navy {\n border-color: var(--clrs-navy, #001f3f);\n }\n .border-clrs-red {\n border-color: var(--clrs-red, #ff4136);\n }\n .border-clrs-slate4 {\n border-color: var(--clrs-slate4, #4e5964);\n }\n .bg-clrs-green-a50 {\n background-color: var(--clrs-green-a50, #2ecc4050);\n }\n .bg-clrs-navy {\n background-color: var(--clrs-navy, #001f3f);\n }\n .bg-clrs-red {\n background-color: var(--clrs-red, #ff4136);\n }\n .bg-clrs-red-a50 {\n background-color: var(--clrs-red-a50, #ff413650);\n }\n .bg-clrs-silver {\n background-color: var(--clrs-silver, #dddddd);\n }\n .bg-clrs-slate4 {\n background-color: var(--clrs-slate4, #4e5964);\n }\n .bg-clrs-yellow {\n background-color: var(--clrs-yellow, #ffdc00);\n }\n .bg-gray-50 {\n background-color: var(--color-gray-50);\n }\n .p-0\\.5 {\n padding: calc(var(--spacing) * 0.5);\n }\n .px-2 {\n padding-inline: calc(var(--spacing) * 2);\n }\n .px-3 {\n padding-inline: calc(var(--spacing) * 3);\n }\n .py-1 {\n padding-block: calc(var(--spacing) * 1);\n }\n .py-2 {\n padding-block: calc(var(--spacing) * 2);\n }\n .text-center {\n text-align: center;\n }\n .align-top {\n vertical-align: top;\n }\n .font-sans {\n font-family: var(--font-sans);\n }\n .text-6xl {\n font-size: var(--text-6xl);\n line-height: var(--tw-leading, var(--text-6xl--line-height));\n }\n .text-lg {\n font-size: var(--text-lg);\n line-height: var(--tw-leading, var(--text-lg--line-height));\n }\n .text-xs {\n font-size: var(--text-xs);\n line-height: var(--tw-leading, var(--text-xs--line-height));\n }\n .leading-8 {\n --tw-leading: calc(var(--spacing) * 8);\n line-height: calc(var(--spacing) * 8);\n }\n .font-bold {\n --tw-font-weight: var(--font-weight-bold);\n font-weight: var(--font-weight-bold);\n }\n .font-thin {\n --tw-font-weight: var(--font-weight-thin);\n font-weight: var(--font-weight-thin);\n }\n .text-clrs-gray {\n color: var(--clrs-gray, #aaaaaa);\n }\n .text-clrs-navy {\n color: var(--clrs-navy, #001f3f);\n }\n .text-clrs-red {\n color: var(--clrs-red, #ff4136);\n }\n .text-clrs-slate4 {\n color: var(--clrs-slate4, #4e5964);\n }\n .text-white {\n color: var(--color-white);\n }\n .uppercase {\n text-transform: uppercase;\n }\n .italic {\n font-style: italic;\n }\n .opacity-25 {\n opacity: 25%;\n }\n .opacity-75 {\n opacity: 75%;\n }\n .shadow {\n --tw-shadow:\n 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)),\n 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));\n box-shadow:\n var(--tw-inset-shadow), var(--tw-inset-ring-shadow),\n var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n .border-xbb-clrs-navy {\n border-bottom: 1px solid var(--clrs-navy, #001f3f) !important;\n }\n .border-xbl-clrs-navy {\n border-left: 1px solid var(--clrs-navy, #001f3f) !important;\n }\n .border-xbr-clrs-navy {\n border-right: 1px solid var(--clrs-navy, #001f3f) !important;\n }\n .border-xbt-clrs-navy {\n border-top: 1px solid var(--clrs-navy, #001f3f) !important;\n }\n .hover\\:text-clrs-navy {\n &:hover {\n @media (hover: hover) {\n color: var(--clrs-navy, #001f3f);\n }\n }\n }\n}\n@layer components {\n .ds1-main {\n margin: calc(var(--spacing) * 6);\n display: flex;\n flex-direction: column;\n font-family: var(--font-sans);\n color: var(--clrs-navy, #001f3f);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n}\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n";export{kt as proto_sudoku}
3
- //# sourceMappingURL=p-2277b011.entry.js.map