@copio/sdk 0.1.5 → 0.1.7
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/THIRD_PARTY_NOTICES.md +34 -0
- package/dist/adapters/edge/index.js +2 -0
- package/dist/adapters/edge/index.js.map +7 -0
- package/dist/adapters/edge/null-edge-detector-adapter.js +2 -0
- package/dist/adapters/edge/null-edge-detector-adapter.js.map +7 -0
- package/dist/adapters/edge/scanic-wasm-adapter.js +2 -0
- package/dist/adapters/edge/scanic-wasm-adapter.js.map +7 -0
- package/dist/adapters/image/canvas2d-adapter.js +1 -1
- package/dist/adapters/image/index.js +1 -1
- package/dist/adapters/image/null-image-processor-adapter.js +1 -1
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/indexeddb-adapter.js +1 -1
- package/dist/adapters/memory-adapter.js +1 -1
- package/dist/adapters/ocr/index.js +1 -1
- package/dist/adapters/ocr/null-ocr-adapter.js +1 -1
- package/dist/adapters/ocr/tesseract-wasm-adapter.js +1 -1
- package/dist/adapters/pdf/index.js +1 -1
- package/dist/adapters/pdf/null-pdf-adapter.js +1 -1
- package/dist/adapters/pdf/pdfkit-adapter.js +1 -1
- package/dist/adapters/storage/index.js +1 -1
- package/dist/adapters/storage/indexeddb-adapter.js +1 -1
- package/dist/adapters/storage/memory-adapter.js +1 -1
- package/dist/adapters/sync/index.js +1 -1
- package/dist/adapters/sync/null-sync-adapter.js +1 -1
- package/dist/adapters/sync/peerjs-adapter.js +1 -1
- package/dist/canvas-GKLGWNAJ.js +2 -0
- package/dist/cdn.js +189 -1409
- package/dist/chunk-25WAHT3G.js +2 -0
- package/dist/chunk-2VH2NPXW.js +175 -0
- package/dist/{chunk-DIU5BGU5.js → chunk-4D6GC55I.js} +2 -2
- package/dist/chunk-6QK7337A.js +2 -0
- package/dist/chunk-GLY5CGCY.js +2 -0
- package/dist/chunk-GU6OQMYK.js +4 -0
- package/dist/chunk-HCCNUPKB.js +2 -0
- package/dist/chunk-JIPKWRBK.js +2 -0
- package/dist/{chunk-GGERQ3CJ.js → chunk-NM4YYZYB.js} +3 -3
- package/dist/chunk-NNSM2I5L.js +2 -0
- package/dist/chunk-PBF7V4Z6.js +2 -0
- package/dist/chunk-PSGIWIRH.js +2 -0
- package/dist/chunk-Q7SOUI6D.js +2 -0
- package/dist/chunk-R6Q4OXDG.js +2 -0
- package/dist/chunk-SZHKZARU.js +2 -0
- package/dist/{chunk-J7HWZNIP.js → chunk-T5CPA7B2.js} +2 -2
- package/dist/chunk-V2D55DVU.js +1 -0
- package/dist/chunk-VPSUKD6F.js +2 -0
- package/dist/chunk-WZZ7FNDX.js +2 -0
- package/dist/chunk-ZILTJGT2.js +2 -0
- package/dist/core.js +1 -1
- package/dist/custom-elements.json +2358 -177
- package/dist/export.js +1 -1
- package/dist/fs-Y7NMZRBK.js +2 -0
- package/dist/handoff-transport-7YFK4RYL.js +2 -0
- package/dist/handoff.js +2 -0
- package/dist/http-CYZIMVXQ.js +2 -0
- package/dist/https-OLG7KUSR.js +2 -0
- package/dist/index.js +11 -11
- package/dist/ocr.js +1 -1
- package/dist/path2d-HD3LU76S.js +2 -0
- package/dist/scanic-mlDetector-BCSVQYFV.js +2 -0
- package/dist/scanic-ort.wasm.min-MU4NYSP2.js +2 -0
- package/dist/scanner.js +3 -1396
- package/dist/sync.js +1 -1
- package/dist/types/js/adapters/edge/edge-detector-port.d.ts +183 -0
- package/dist/types/js/adapters/edge/index.d.ts +3 -0
- package/dist/types/js/adapters/edge/null-edge-detector-adapter.d.ts +35 -0
- package/dist/types/js/adapters/edge/scanic-wasm-adapter.d.ts +54 -0
- package/dist/types/js/adapters/storage/indexeddb-adapter.d.ts +11 -0
- package/dist/types/js/adapters/storage/memory-adapter.d.ts +11 -0
- package/dist/types/js/adapters/storage/opfs-adapter.d.ts +11 -0
- package/dist/types/js/adapters/storage/storage-port.d.ts +27 -0
- package/dist/types/js/services/doc-repository.d.ts +6 -1
- package/dist/types/js/services/handoff-crypto.d.ts +84 -0
- package/dist/types/js/services/handoff-session.d.ts +257 -0
- package/dist/types/js/services/handoff-transport.d.ts +51 -0
- package/dist/types/js/services/ice-servers.d.ts +33 -1
- package/dist/types/js/services/migration-runner.d.ts +100 -0
- package/dist/types/js/utils/perspective.d.ts +70 -0
- package/dist/types/js/utils/utils.d.ts +19 -1
- package/dist/types/sdk/core.d.ts +52 -6
- package/dist/types/sdk/elements.d.ts +2 -0
- package/dist/types/sdk/events.d.ts +42 -0
- package/dist/types/sdk/handoff-session.d.ts +4 -0
- package/dist/types/sdk/handoff-styles.d.ts +9 -0
- package/dist/types/sdk/handoff.d.ts +108 -0
- package/dist/types/sdk/index.d.ts +5 -1
- package/dist/types/sdk/models.d.ts +248 -1
- package/dist/types/sdk/scanner.d.ts +94 -1
- package/dist/types/sdk/styles.d.ts +1 -1
- package/dist/types/sdk/version.d.ts +1 -1
- package/dist/url-NYR4TEJV.js +2 -0
- package/package.json +10 -3
- package/sdk/core.js +226 -13
- package/sdk/events.js +14 -0
- package/sdk/handoff-session.js +26 -0
- package/sdk/handoff-styles.js +531 -0
- package/sdk/handoff.js +1079 -0
- package/sdk/index.js +38 -1
- package/sdk/models.js +116 -4
- package/sdk/scanner.js +1517 -151
- package/sdk/styles.js +305 -22
- package/sdk/version.js +1 -1
- package/dist/canvas-FAXPLPXN.js +0 -2
- package/dist/chunk-4C666HHU.js +0 -2
- package/dist/chunk-FQRADJY6.js +0 -2
- package/dist/chunk-G5EUMLYT.js +0 -4
- package/dist/chunk-K4NR6OAC.js +0 -2
- package/dist/chunk-L4OVZN23.js +0 -2
- package/dist/chunk-MEE2NNYB.js +0 -2
- package/dist/chunk-O7IV7A6O.js +0 -2
- package/dist/chunk-Q7XPZMZA.js +0 -1395
- package/dist/chunk-WETG2JD7.js +0 -2
- package/dist/fs-HJ6WWW73.js +0 -2
- package/dist/http-FKJJMT2N.js +0 -2
- package/dist/https-MUBFLDZM.js +0 -2
- package/dist/path2d-QWN6DFCC.js +0 -2
- package/dist/url-ABJ6S2Y6.js +0 -2
package/sdk/styles.js
CHANGED
|
@@ -57,19 +57,6 @@ export const scannerCss = `
|
|
|
57
57
|
--copio-shadow-elevated: 0 12px 32px -4px rgba(0, 0, 0, 0.55);
|
|
58
58
|
--copio-transition-fast: 150ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
59
59
|
--copio-transition-normal: 240ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
60
|
-
--sl-font-sans: var(--copio-font-family);
|
|
61
|
-
--sl-font-mono: var(--copio-font-mono);
|
|
62
|
-
--sl-color-primary-50: #f0f9ff;
|
|
63
|
-
--sl-color-primary-100: #e0f2fe;
|
|
64
|
-
--sl-color-primary-200: #bae6fd;
|
|
65
|
-
--sl-color-primary-300: #7dd3fc;
|
|
66
|
-
--sl-color-primary-400: #38bdf8;
|
|
67
|
-
--sl-color-primary-500: #0ea5e9;
|
|
68
|
-
--sl-color-primary-600: var(--copio-color-primary);
|
|
69
|
-
--sl-color-primary-700: #0369a1;
|
|
70
|
-
--sl-color-primary-800: #075985;
|
|
71
|
-
--sl-color-primary-900: #0c4a6e;
|
|
72
|
-
--sl-color-primary-950: #082f49;
|
|
73
60
|
font-family: var(--copio-font-family);
|
|
74
61
|
font-size: 14px;
|
|
75
62
|
line-height: 1.5;
|
|
@@ -383,6 +370,22 @@ export const scannerCss = `
|
|
|
383
370
|
background: radial-gradient(circle at 50% 45%, #1e293b 0%, #090d14 75%);
|
|
384
371
|
}
|
|
385
372
|
|
|
373
|
+
.copio-camera-feed.is-shutter-flash::after {
|
|
374
|
+
content: '';
|
|
375
|
+
position: absolute;
|
|
376
|
+
inset: 0;
|
|
377
|
+
background: #ffffff;
|
|
378
|
+
opacity: 0.75;
|
|
379
|
+
pointer-events: none;
|
|
380
|
+
z-index: 5;
|
|
381
|
+
animation: copio-shutter-flash 150ms ease-out forwards;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
@keyframes copio-shutter-flash {
|
|
385
|
+
0% { opacity: 0.75; }
|
|
386
|
+
100% { opacity: 0; }
|
|
387
|
+
}
|
|
388
|
+
|
|
386
389
|
/* Framing Guide Overlay (receipt | card | a4 | auto) */
|
|
387
390
|
.copio-framing-guide {
|
|
388
391
|
position: relative;
|
|
@@ -445,6 +448,44 @@ export const scannerCss = `
|
|
|
445
448
|
z-index: 1;
|
|
446
449
|
}
|
|
447
450
|
|
|
451
|
+
/* Live Viewfinder SVG Quad Overlay (CPO-076) */
|
|
452
|
+
.copio-live-quad-overlay {
|
|
453
|
+
position: absolute;
|
|
454
|
+
inset: 0;
|
|
455
|
+
width: 100%;
|
|
456
|
+
height: 100%;
|
|
457
|
+
pointer-events: none;
|
|
458
|
+
z-index: 10;
|
|
459
|
+
overflow: visible;
|
|
460
|
+
}
|
|
461
|
+
.copio-live-quad-polygon {
|
|
462
|
+
fill: rgba(56, 189, 248, 0.18);
|
|
463
|
+
stroke: var(--copio-color-primary, #38bdf8);
|
|
464
|
+
stroke-width: 3;
|
|
465
|
+
vector-effect: non-scaling-stroke;
|
|
466
|
+
stroke-linecap: round;
|
|
467
|
+
stroke-linejoin: round;
|
|
468
|
+
filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.45));
|
|
469
|
+
}
|
|
470
|
+
.copio-live-quad-corner {
|
|
471
|
+
fill: #ffffff;
|
|
472
|
+
stroke: var(--copio-color-primary, #38bdf8);
|
|
473
|
+
stroke-width: 2.5;
|
|
474
|
+
filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.4));
|
|
475
|
+
}
|
|
476
|
+
.copio-camera-feed.is-detected .copio-live-quad-polygon {
|
|
477
|
+
fill: rgba(34, 197, 94, 0.22);
|
|
478
|
+
stroke: #22c55e;
|
|
479
|
+
filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.6));
|
|
480
|
+
}
|
|
481
|
+
.copio-camera-feed.is-detected .copio-live-quad-corner {
|
|
482
|
+
stroke: #22c55e;
|
|
483
|
+
}
|
|
484
|
+
.copio-camera-feed.is-tracking .copio-edge-quad {
|
|
485
|
+
opacity: 0.1;
|
|
486
|
+
transition: opacity var(--copio-transition-fast);
|
|
487
|
+
}
|
|
488
|
+
|
|
448
489
|
.copio-camera-placeholder {
|
|
449
490
|
position: relative;
|
|
450
491
|
z-index: 2;
|
|
@@ -458,6 +499,13 @@ export const scannerCss = `
|
|
|
458
499
|
color: var(--copio-color-text-muted);
|
|
459
500
|
font-size: 12px;
|
|
460
501
|
font-weight: 500;
|
|
502
|
+
cursor: pointer;
|
|
503
|
+
user-select: none;
|
|
504
|
+
transition: color var(--copio-transition-fast), transform var(--copio-transition-fast);
|
|
505
|
+
}
|
|
506
|
+
.copio-camera-placeholder:hover {
|
|
507
|
+
color: var(--copio-color-text);
|
|
508
|
+
transform: scale(1.02);
|
|
461
509
|
}
|
|
462
510
|
|
|
463
511
|
.copio-status-dot {
|
|
@@ -516,7 +564,7 @@ export const scannerCss = `
|
|
|
516
564
|
align-items: center;
|
|
517
565
|
justify-content: space-between;
|
|
518
566
|
gap: 12px;
|
|
519
|
-
padding: 12px 16px;
|
|
567
|
+
padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) 16px;
|
|
520
568
|
background: var(--copio-color-surface);
|
|
521
569
|
border-top: 1px solid var(--copio-color-border);
|
|
522
570
|
min-height: 84px;
|
|
@@ -636,12 +684,12 @@ export const scannerCss = `
|
|
|
636
684
|
min-height: 180px;
|
|
637
685
|
}
|
|
638
686
|
|
|
639
|
-
.copio-canvas-viewport.
|
|
640
|
-
padding
|
|
687
|
+
.copio-canvas-viewport.is-cropping {
|
|
688
|
+
padding: 24px;
|
|
641
689
|
}
|
|
642
690
|
|
|
643
|
-
.copio-canvas-viewport.
|
|
644
|
-
padding:
|
|
691
|
+
.copio-canvas-viewport.has-card-switcher {
|
|
692
|
+
padding-top: 66px;
|
|
645
693
|
}
|
|
646
694
|
|
|
647
695
|
/* Card Side Switcher */
|
|
@@ -712,7 +760,7 @@ export const scannerCss = `
|
|
|
712
760
|
inset: 0;
|
|
713
761
|
width: 100%;
|
|
714
762
|
height: 100%;
|
|
715
|
-
overflow:
|
|
763
|
+
overflow: visible;
|
|
716
764
|
z-index: 8;
|
|
717
765
|
touch-action: none;
|
|
718
766
|
}
|
|
@@ -779,6 +827,59 @@ export const scannerCss = `
|
|
|
779
827
|
.copio-crop-handle.w, .copio-crop-handle.edge-w { left: -24px; top: calc(50% - 24px); cursor: ew-resize; }
|
|
780
828
|
.copio-crop-handle.e, .copio-crop-handle.edge-e { right: -24px; top: calc(50% - 24px); cursor: ew-resize; }
|
|
781
829
|
|
|
830
|
+
/* 4-Corner Perspective Quad Crop (CPO-075) */
|
|
831
|
+
.copio-crop-quad-svg {
|
|
832
|
+
position: absolute;
|
|
833
|
+
inset: 0;
|
|
834
|
+
width: 100%;
|
|
835
|
+
height: 100%;
|
|
836
|
+
pointer-events: none;
|
|
837
|
+
overflow: visible;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.copio-crop-mask {
|
|
841
|
+
fill: rgba(5, 8, 14, 0.68);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
.copio-crop-quad-outline {
|
|
845
|
+
fill: rgba(56, 189, 248, 0.06);
|
|
846
|
+
stroke: var(--copio-color-primary);
|
|
847
|
+
stroke-width: 2;
|
|
848
|
+
vector-effect: non-scaling-stroke;
|
|
849
|
+
pointer-events: auto;
|
|
850
|
+
cursor: move;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
.copio-crop-quad-grid {
|
|
854
|
+
stroke: rgba(56, 189, 248, 0.35);
|
|
855
|
+
stroke-width: 1;
|
|
856
|
+
vector-effect: non-scaling-stroke;
|
|
857
|
+
pointer-events: none;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
.copio-quad-handle {
|
|
861
|
+
transform: translate(-50%, -50%);
|
|
862
|
+
cursor: grab;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
.copio-quad-handle:active {
|
|
866
|
+
cursor: grabbing;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
.copio-crop-magnifier {
|
|
870
|
+
position: absolute;
|
|
871
|
+
width: 96px;
|
|
872
|
+
height: 96px;
|
|
873
|
+
border-radius: 50%;
|
|
874
|
+
border: 2.5px solid var(--copio-color-primary);
|
|
875
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
|
|
876
|
+
pointer-events: none;
|
|
877
|
+
z-index: 20;
|
|
878
|
+
display: none;
|
|
879
|
+
background: #0b0f17;
|
|
880
|
+
transform: translate(-50%, -125%);
|
|
881
|
+
}
|
|
882
|
+
|
|
782
883
|
/* Filmstrip & Reorder Tray */
|
|
783
884
|
.copio-filmstrip,
|
|
784
885
|
.copio-filmstrip-bar {
|
|
@@ -881,7 +982,7 @@ export const scannerCss = `
|
|
|
881
982
|
display: flex;
|
|
882
983
|
flex-direction: column;
|
|
883
984
|
gap: 8px;
|
|
884
|
-
padding: 10px 12px;
|
|
985
|
+
padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)) 12px;
|
|
885
986
|
background: var(--copio-color-surface);
|
|
886
987
|
border-top: 1px solid var(--copio-color-border);
|
|
887
988
|
min-height: 56px;
|
|
@@ -894,12 +995,13 @@ export const scannerCss = `
|
|
|
894
995
|
display: flex;
|
|
895
996
|
flex-wrap: wrap;
|
|
896
997
|
align-items: center;
|
|
897
|
-
gap:
|
|
998
|
+
gap: 4px;
|
|
898
999
|
width: 100%;
|
|
899
1000
|
}
|
|
900
1001
|
|
|
901
1002
|
.copio-toolbar-tools .copio-tool-btn {
|
|
902
|
-
flex: 1 1
|
|
1003
|
+
flex: 1 1 0;
|
|
1004
|
+
min-width: 0;
|
|
903
1005
|
}
|
|
904
1006
|
|
|
905
1007
|
.copio-toolbar-actions {
|
|
@@ -907,6 +1009,7 @@ export const scannerCss = `
|
|
|
907
1009
|
align-items: center;
|
|
908
1010
|
gap: 8px;
|
|
909
1011
|
width: 100%;
|
|
1012
|
+
flex-shrink: 0;
|
|
910
1013
|
}
|
|
911
1014
|
|
|
912
1015
|
.copio-toolbar-actions .copio-btn-primary {
|
|
@@ -982,6 +1085,23 @@ export const scannerCss = `
|
|
|
982
1085
|
font-weight: 500;
|
|
983
1086
|
position: relative;
|
|
984
1087
|
overflow: hidden;
|
|
1088
|
+
transition: opacity 200ms ease-out;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
.copio-toast-warning {
|
|
1092
|
+
border-color: #f59e0b;
|
|
1093
|
+
background: #1c1917;
|
|
1094
|
+
color: #fef3c7;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
.copio-toast-info {
|
|
1098
|
+
border-color: var(--copio-color-primary);
|
|
1099
|
+
background: #0f172a;
|
|
1100
|
+
color: #f8fafc;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.copio-toast-fade-out {
|
|
1104
|
+
opacity: 0;
|
|
985
1105
|
}
|
|
986
1106
|
|
|
987
1107
|
.copio-toast-progress {
|
|
@@ -1117,10 +1237,24 @@ export const scannerCss = `
|
|
|
1117
1237
|
.copio-subtitle {
|
|
1118
1238
|
display: none;
|
|
1119
1239
|
}
|
|
1240
|
+
.copio-stage-canvas,
|
|
1241
|
+
.copio-canvas-viewport {
|
|
1242
|
+
min-height: 120px;
|
|
1243
|
+
padding: 12px;
|
|
1244
|
+
}
|
|
1245
|
+
.copio-canvas-viewport.is-cropping {
|
|
1246
|
+
padding: 20px;
|
|
1247
|
+
}
|
|
1120
1248
|
.copio-filmstrip,
|
|
1121
1249
|
.copio-filmstrip-bar {
|
|
1122
1250
|
gap: 6px;
|
|
1123
1251
|
padding: 6px 8px;
|
|
1252
|
+
min-height: 64px;
|
|
1253
|
+
}
|
|
1254
|
+
.copio-toolbar,
|
|
1255
|
+
.copio-controls-dock {
|
|
1256
|
+
gap: 6px;
|
|
1257
|
+
padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)) 10px;
|
|
1124
1258
|
}
|
|
1125
1259
|
.copio-tool-btn {
|
|
1126
1260
|
font-size: 10px;
|
|
@@ -1179,12 +1313,161 @@ export const scannerCss = `
|
|
|
1179
1313
|
.copio-toolbar-tools {
|
|
1180
1314
|
width: auto;
|
|
1181
1315
|
flex: 1;
|
|
1316
|
+
gap: 6px;
|
|
1317
|
+
}
|
|
1318
|
+
.copio-toolbar-tools .copio-tool-btn {
|
|
1319
|
+
flex: 1 1 56px;
|
|
1320
|
+
min-width: var(--copio-touch-target-min);
|
|
1182
1321
|
}
|
|
1183
1322
|
.copio-toolbar-actions {
|
|
1184
1323
|
width: auto;
|
|
1185
1324
|
min-width: 200px;
|
|
1186
1325
|
}
|
|
1187
1326
|
}
|
|
1327
|
+
|
|
1328
|
+
/* Mobile Handoff Sender Mode (CPO-094) */
|
|
1329
|
+
.copio-handoff-pill {
|
|
1330
|
+
display: inline-flex;
|
|
1331
|
+
align-items: center;
|
|
1332
|
+
gap: 6px;
|
|
1333
|
+
padding: 4px 10px;
|
|
1334
|
+
background: rgba(2, 132, 199, 0.16);
|
|
1335
|
+
border: 1px solid rgba(56, 189, 248, 0.35);
|
|
1336
|
+
border-radius: var(--copio-radius-pill);
|
|
1337
|
+
font-size: 11px;
|
|
1338
|
+
font-weight: 600;
|
|
1339
|
+
color: var(--copio-color-text);
|
|
1340
|
+
backdrop-filter: blur(8px);
|
|
1341
|
+
}
|
|
1342
|
+
.copio-handoff-dot {
|
|
1343
|
+
width: 8px;
|
|
1344
|
+
height: 8px;
|
|
1345
|
+
border-radius: 50%;
|
|
1346
|
+
background: var(--copio-color-warning);
|
|
1347
|
+
display: inline-block;
|
|
1348
|
+
flex-shrink: 0;
|
|
1349
|
+
}
|
|
1350
|
+
.copio-handoff-dot.connected {
|
|
1351
|
+
background: var(--copio-color-success);
|
|
1352
|
+
box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
|
|
1353
|
+
}
|
|
1354
|
+
.copio-handoff-dot.connecting,
|
|
1355
|
+
.copio-handoff-dot.reconnecting {
|
|
1356
|
+
background: var(--copio-color-warning);
|
|
1357
|
+
animation: copio-pulse 1.4s ease-in-out infinite;
|
|
1358
|
+
}
|
|
1359
|
+
.copio-handoff-dot.disconnected,
|
|
1360
|
+
.copio-handoff-dot.error {
|
|
1361
|
+
background: var(--copio-color-danger);
|
|
1362
|
+
}
|
|
1363
|
+
.copio-handoff-retry-btn {
|
|
1364
|
+
appearance: none;
|
|
1365
|
+
border: none;
|
|
1366
|
+
background: var(--copio-color-surface-elevated);
|
|
1367
|
+
color: var(--copio-color-text);
|
|
1368
|
+
font-size: 10px;
|
|
1369
|
+
font-weight: 600;
|
|
1370
|
+
padding: 2px 6px;
|
|
1371
|
+
border-radius: var(--copio-radius-sm);
|
|
1372
|
+
cursor: pointer;
|
|
1373
|
+
}
|
|
1374
|
+
.copio-handoff-progress-view,
|
|
1375
|
+
.copio-handoff-confirm {
|
|
1376
|
+
position: absolute;
|
|
1377
|
+
inset: 0;
|
|
1378
|
+
display: flex;
|
|
1379
|
+
align-items: center;
|
|
1380
|
+
justify-content: center;
|
|
1381
|
+
padding: var(--copio-spacing-xl);
|
|
1382
|
+
}
|
|
1383
|
+
.copio-handoff-progress-view {
|
|
1384
|
+
z-index: 50;
|
|
1385
|
+
background: var(--copio-color-surface-overlay, rgba(15, 22, 32, 0.92));
|
|
1386
|
+
backdrop-filter: blur(12px);
|
|
1387
|
+
}
|
|
1388
|
+
.copio-handoff-confirm {
|
|
1389
|
+
z-index: 60;
|
|
1390
|
+
background: var(--copio-color-bg);
|
|
1391
|
+
}
|
|
1392
|
+
.copio-handoff-progress-card,
|
|
1393
|
+
.copio-handoff-confirm-card {
|
|
1394
|
+
width: 100%;
|
|
1395
|
+
max-width: 340px;
|
|
1396
|
+
background: var(--copio-color-surface);
|
|
1397
|
+
border: 1px solid var(--copio-color-border-strong);
|
|
1398
|
+
border-radius: var(--copio-radius-lg);
|
|
1399
|
+
padding: var(--copio-spacing-xl);
|
|
1400
|
+
display: flex;
|
|
1401
|
+
flex-direction: column;
|
|
1402
|
+
align-items: center;
|
|
1403
|
+
text-align: center;
|
|
1404
|
+
gap: var(--copio-spacing-md);
|
|
1405
|
+
box-shadow: var(--copio-shadow-elevated);
|
|
1406
|
+
}
|
|
1407
|
+
.copio-handoff-spinner {
|
|
1408
|
+
width: 32px;
|
|
1409
|
+
height: 32px;
|
|
1410
|
+
border: 3px solid rgba(148, 163, 184, 0.2);
|
|
1411
|
+
border-top-color: var(--copio-color-primary);
|
|
1412
|
+
border-radius: 50%;
|
|
1413
|
+
animation: copio-spin 0.8s linear infinite;
|
|
1414
|
+
}
|
|
1415
|
+
.copio-handoff-progress-title,
|
|
1416
|
+
.copio-handoff-confirm-title {
|
|
1417
|
+
font-size: 16px;
|
|
1418
|
+
font-weight: 700;
|
|
1419
|
+
color: var(--copio-color-text);
|
|
1420
|
+
margin: 0;
|
|
1421
|
+
}
|
|
1422
|
+
.copio-handoff-progress-track {
|
|
1423
|
+
width: 100%;
|
|
1424
|
+
height: 8px;
|
|
1425
|
+
background: var(--copio-color-surface-elevated);
|
|
1426
|
+
border-radius: var(--copio-radius-pill);
|
|
1427
|
+
overflow: hidden;
|
|
1428
|
+
border: 1px solid var(--copio-color-border);
|
|
1429
|
+
}
|
|
1430
|
+
.copio-handoff-progress-bar {
|
|
1431
|
+
height: 100%;
|
|
1432
|
+
background: linear-gradient(90deg, var(--copio-color-primary), #0284c7);
|
|
1433
|
+
border-radius: var(--copio-radius-pill);
|
|
1434
|
+
transition: width var(--copio-transition-fast);
|
|
1435
|
+
}
|
|
1436
|
+
.copio-handoff-progress-desc,
|
|
1437
|
+
.copio-handoff-confirm-subtitle {
|
|
1438
|
+
font-size: 12px;
|
|
1439
|
+
color: var(--copio-color-text-muted);
|
|
1440
|
+
margin: 0;
|
|
1441
|
+
}
|
|
1442
|
+
.copio-handoff-confirm-icon {
|
|
1443
|
+
width: 56px;
|
|
1444
|
+
height: 56px;
|
|
1445
|
+
border-radius: 50%;
|
|
1446
|
+
background: rgba(34, 197, 94, 0.15);
|
|
1447
|
+
color: var(--copio-color-success);
|
|
1448
|
+
border: 1px solid rgba(34, 197, 94, 0.35);
|
|
1449
|
+
display: flex;
|
|
1450
|
+
align-items: center;
|
|
1451
|
+
justify-content: center;
|
|
1452
|
+
}
|
|
1453
|
+
.copio-handoff-confirm-badge {
|
|
1454
|
+
display: inline-flex;
|
|
1455
|
+
align-items: center;
|
|
1456
|
+
padding: 4px 12px;
|
|
1457
|
+
background: var(--copio-color-surface-elevated);
|
|
1458
|
+
border: 1px solid var(--copio-color-border);
|
|
1459
|
+
border-radius: var(--copio-radius-pill);
|
|
1460
|
+
font-size: 12px;
|
|
1461
|
+
font-weight: 600;
|
|
1462
|
+
color: var(--copio-color-primary);
|
|
1463
|
+
}
|
|
1464
|
+
.copio-handoff-confirm-actions {
|
|
1465
|
+
width: 100%;
|
|
1466
|
+
display: flex;
|
|
1467
|
+
flex-direction: column;
|
|
1468
|
+
gap: 8px;
|
|
1469
|
+
margin-top: 8px;
|
|
1470
|
+
}
|
|
1188
1471
|
`;
|
|
1189
1472
|
|
|
1190
1473
|
let cachedScannerSheet = null;
|
package/sdk/version.js
CHANGED
package/dist/canvas-FAXPLPXN.js
DELETED
package/dist/chunk-4C666HHU.js
DELETED
package/dist/chunk-FQRADJY6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as c}from"./chunk-DIU5BGU5.js";var a=class extends c{#e=new Map;#s=new Map;#n=new Set;constructor(){super()}async init(){return{kind:"memory",persistent:!1}}listDocsSync(){return Array.from(this.#e.values()).map(e=>({id:e.id,name:e.name,pages:Array.isArray(e.pages)?[...e.pages]:[]}))}async listDocs(){return this.listDocsSync()}getDocSync(e){let s=this.#e.get(e);return s?{id:s.id,name:s.name,pages:Array.isArray(s.pages)?[...s.pages]:[]}:null}async getDoc(e){return this.getDocSync(e)}async saveDoc(e,s){if(!e)throw new Error("Cannot save document without an ID");let t=[];if(Array.isArray(s.pages))t=[...s.pages];else if(typeof s.pages=="string")try{t=JSON.parse(s.pages)}catch{t=[]}this.#e.set(e,{id:e,name:s.name||"",pages:t}),this.#t()}async deleteDoc(e){this.#e.delete(e);let s=`${e}/`;for(let t of this.#s.keys())t.startsWith(s)&&this.#s.delete(t);this.#t()}async renameDoc(e,s){let t=this.#e.get(e);if(!t)throw new Error(`Document "${e}" not found`);t.name=s,this.#t()}async savePage(e,s,t){this.#s.set(`${e}/${s}`,t);let n=this.#e.get(e);if(n){let r=n.pages.findIndex(i=>i.id===s);if(r>=0)typeof t=="object"&&t!==null&&!(t instanceof Blob)?n.pages[r]={...n.pages[r],...t}:n.pages[r]={...n.pages[r],src:t};else{let i=typeof t=="object"&&t!==null&&!(t instanceof Blob)?{id:s,...t}:{id:s,src:t};n.pages.push(i)}}this.#t()}async getPage(e,s){if(this.#s.has(`${e}/${s}`))return this.#s.get(`${e}/${s}`);let t=this.#e.get(e);if(t){let n=t.pages.find(r=>r.id===s);if(n)return n.src??n}return null}async deletePage(e,s){this.#s.delete(`${e}/${s}`);let t=this.#e.get(e);t&&(t.pages=t.pages.filter(n=>n.id!==s)),this.#t()}subscribe(e){return this.#n.add(e),()=>{this.#n.delete(e)}}clear(){this.#e.clear(),this.#s.clear(),this.#t()}#t(){for(let e of this.#n)try{e()}catch(s){console.error("Error in MemoryStorageAdapter subscriber:",s)}}};export{a};
|
|
2
|
-
//# sourceMappingURL=chunk-FQRADJY6.js.map
|
package/dist/chunk-G5EUMLYT.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as Et}from"./chunk-ULTSZWZO.js";function c(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}var At=typeof self<"u"?self:global,q=typeof navigator<"u",me=q&&typeof HTMLImageElement>"u",Nt=!(typeof global>"u"||typeof process>"u"||!process.versions||!process.versions.node),It=At.Buffer,tt=At.BigInt,Ut=!!It,et=s=>Yt(s)?void 0:s,ye=s=>s!==void 0;function Yt(s){return s===void 0||(s instanceof Map?s.size===0:Object.values(s).filter(ye).length===0)}function m(s){let t=new Error(s);throw delete t.stack,t}function qt(s){return(s=(function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t})(s).trim())===""?void 0:s}function zt(s){let t=(function(e){let i=0;return e.ifd0.enabled&&(i+=1024),e.exif.enabled&&(i+=2048),e.makerNote&&(i+=2048),e.userComment&&(i+=1024),e.gps.enabled&&(i+=512),e.interop.enabled&&(i+=100),e.ifd1.enabled&&(i+=1024),i+2048})(s);return s.jfif.enabled&&(t+=50),s.xmp.enabled&&(t+=2e4),s.iptc.enabled&&(t+=14e3),s.icc.enabled&&(t+=6e3),t}var yt=s=>String.fromCharCode.apply(null,s),Vt=typeof TextDecoder<"u"?new TextDecoder("utf-8"):void 0;function Zt(s){return Vt?Vt.decode(s):Ut?Buffer.from(s).toString("utf8"):decodeURIComponent(escape(yt(s)))}var O=class s{static from(t,e){return t instanceof this&&t.le===e?t:new s(t,void 0,void 0,e)}constructor(t,e=0,i,n){if(typeof n=="boolean"&&(this.le=n),Array.isArray(t)&&(t=new Uint8Array(t)),t===0)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){i===void 0&&(i=t.byteLength-e);let r=new DataView(t,e,i);this._swapDataView(r)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof s){i===void 0&&(i=t.byteLength-e),(e+=t.byteOffset)+i>t.byteOffset+t.byteLength&&m("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else if(typeof t=="number"){let r=new DataView(new ArrayBuffer(t));this._swapDataView(r)}else m("Invalid input argument for BufferView: "+t)}_swapArrayBuffer(t){this._swapDataView(new DataView(t))}_swapBuffer(t){this._swapDataView(new DataView(t.buffer,t.byteOffset,t.byteLength))}_swapDataView(t){this.dataView=t,this.buffer=t.buffer,this.byteOffset=t.byteOffset,this.byteLength=t.byteLength}_lengthToEnd(t){return this.byteLength-t}set(t,e,i=s){return t instanceof DataView||t instanceof s?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),t instanceof Uint8Array||m("BufferView.set(): Invalid data argument."),this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new s(this,t,e)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(t,e){return new Uint8Array(this.buffer,this.byteOffset+t,e)}getString(t=0,e=this.byteLength){return Zt(this.getUint8Array(t,e))}getLatin1String(t=0,e=this.byteLength){let i=this.getUint8Array(t,e);return yt(i)}getUnicodeString(t=0,e=this.byteLength){let i=[];for(let n=0;n<e&&t+n<this.byteLength;n+=2)i.push(this.getUint16(t+n));return yt(i)}getInt8(t){return this.dataView.getInt8(t)}getUint8(t){return this.dataView.getUint8(t)}getInt16(t,e=this.le){return this.dataView.getInt16(t,e)}getInt32(t,e=this.le){return this.dataView.getInt32(t,e)}getUint16(t,e=this.le){return this.dataView.getUint16(t,e)}getUint32(t,e=this.le){return this.dataView.getUint32(t,e)}getFloat32(t,e=this.le){return this.dataView.getFloat32(t,e)}getFloat64(t,e=this.le){return this.dataView.getFloat64(t,e)}getFloat(t,e=this.le){return this.dataView.getFloat32(t,e)}getDouble(t,e=this.le){return this.dataView.getFloat64(t,e)}getUintBytes(t,e,i){switch(e){case 1:return this.getUint8(t,i);case 2:return this.getUint16(t,i);case 4:return this.getUint32(t,i);case 8:return this.getUint64&&this.getUint64(t,i)}}getUint(t,e,i){switch(e){case 8:return this.getUint8(t,i);case 16:return this.getUint16(t,i);case 32:return this.getUint32(t,i);case 64:return this.getUint64&&this.getUint64(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}};function bt(s,t){m(`${s} '${t}' was not loaded, try using full build of exifr.`)}var Z=class extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||bt(this.kind,t),e&&(t in e||(function(i,n){m(`Unknown ${i} '${n}'.`)})(this.kind,t),e[t].enabled||bt(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}},z=new Z("file parser"),b=new Z("segment parser"),V=new Z("file reader"),Jt=At.fetch;function Rt(s,t){return(e=s).startsWith("data:")||e.length>1e4?St(s,t,"base64"):Nt&&s.includes("://")?wt(s,t,"url",G):Nt?St(s,t,"fs"):q?wt(s,t,"url",G):void m("Invalid input argument");var e}async function wt(s,t,e,i){return V.has(e)?St(s,t,e):i?(async function(n,r){let a=await r(n);return new O(a)})(s,i):void m(`Parser ${e} is not loaded`)}async function St(s,t,e){let i=new(V.get(e))(s,t);return await i.read(),i}var G=s=>Jt(s).then((t=>t.arrayBuffer())),H=s=>new Promise(((t,e)=>{let i=new FileReader;i.onloadend=()=>t(i.result||new ArrayBuffer),i.onerror=e,i.readAsArrayBuffer(s)})),kt=class extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}};function k(s,t,e){let i=new kt;for(let[n,r]of e)i.set(n,r);if(Array.isArray(t))for(let n of t)s.set(n,i);else s.set(t,i);return i}function Bt(s,t,e){let i,n=s.get(t);for(i of e)n.set(i[0],i[1])}var C=new Map,$=new Map,N=new Map,D=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],J=["jfif","xmp","icc","iptc","ihdr"],W=["tiff",...J],p=["ifd0","ifd1","exif","gps","interop"],F=[...W,...p],T=["makerNote","userComment"],Q=["translateKeys","translateValues","reviveValues","multiSegment"],E=[...Q,"sanitize","mergeOutput","silentErrors"],it=class{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}},L=class extends it{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,n){if(super(),c(this,"enabled",!1),c(this,"skip",new Set),c(this,"pick",new Set),c(this,"deps",new Set),c(this,"translateKeys",!1),c(this,"translateValues",!1),c(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=p.includes(t),this.canBeFiltered&&(this.dict=C.get(t)),i!==void 0)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if(typeof i=="object"){if(this.enabled=!0,this.parse=i.parse!==!1,this.canBeFiltered){let{pick:r,skip:a}=i;r&&r.length>0&&this.translateTagSet(r,this.pick),a&&a.length>0&&this.translateTagSet(a,this.skip)}this.applyInheritables(i)}else i===!0||i===!1?this.parse=this.enabled=i:m(`Invalid options argument: ${i}`)}applyInheritables(t){let e,i;for(e of Q)i=t[e],i!==void 0&&(this[e]=i)}translateTagSet(t,e){if(this.dict){let i,n,{tagKeys:r,tagValues:a}=this.dict;for(i of t)typeof i=="string"?(n=a.indexOf(i),n===-1&&(n=r.indexOf(Number(i))),n!==-1&&e.add(Number(r[n]))):e.add(i)}else for(let i of t)e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,st(this.pick,this.deps)):this.enabled&&this.pick.size>0&&st(this.pick,this.deps)}},y={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,ihdr:void 0,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},jt=new Map,I=class extends it{static useCached(t){let e=jt.get(t);return e!==void 0||(e=new this(t),jt.set(t,e)),e}constructor(t){super(),t===!0?this.setupFromTrue():t===void 0?this.setupFromUndefined():Array.isArray(t)?this.setupFromArray(t):typeof t=="object"?this.setupFromObject(t):m(`Invalid options argument ${t}`),this.firstChunkSize===void 0&&(this.firstChunkSize=q?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of D)this[t]=y[t];for(t of E)this[t]=y[t];for(t of T)this[t]=y[t];for(t of F)this[t]=new L(t,y[t],void 0,this)}setupFromTrue(){let t;for(t of D)this[t]=y[t];for(t of E)this[t]=y[t];for(t of T)this[t]=!0;for(t of F)this[t]=new L(t,!0,void 0,this)}setupFromArray(t){let e;for(e of D)this[e]=y[e];for(e of E)this[e]=y[e];for(e of T)this[e]=y[e];for(e of F)this[e]=new L(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,p)}setupFromObject(t){let e;for(e of(p.ifd0=p.ifd0||p.image,p.ifd1=p.ifd1||p.thumbnail,Object.assign(this,t),D))this[e]=gt(t[e],y[e]);for(e of E)this[e]=gt(t[e],y[e]);for(e of T)this[e]=gt(t[e],y[e]);for(e of W)this[e]=new L(e,y[e],t[e],this);for(e of p)this[e]=new L(e,y[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,p,F),t.tiff===!0?this.batchEnableWithBool(p,!0):t.tiff===!1?this.batchEnableWithUserValue(p,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,p):typeof t.tiff=="object"&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,p)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let n=e[i];this[i].enabled=n!==!1&&n!==void 0}}setupGlobalFilters(t,e,i,n=i){if(t&&t.length){for(let a of n)this[a].enabled=!1;let r=Gt(t,i);for(let[a,o]of r)st(this[a].pick,o),this[a].enabled=!0}else if(e&&e.length){let r=Gt(e,i);for(let[a,o]of r)st(this[a].skip,o)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:n,icc:r}=this;this.makerNote?e.deps.add(37500):e.skip.add(37500),this.userComment?e.deps.add(37510):e.skip.add(37510),i.enabled||t.skip.add(700),n.enabled||t.skip.add(33723),r.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:n}=this;n.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=p.some((r=>this[r].enabled===!0))||this.makerNote||this.userComment;for(let r of p)this[r].finalizeFilters()}get onlyTiff(){return!J.map((t=>this[t].enabled)).some((t=>t===!0))&&this.tiff.enabled}checkLoadedPlugins(){for(let t of W)this[t].enabled&&!b.has(t)&&bt("segment parser",t)}};function Gt(s,t){let e,i,n,r,a=[];for(n of t){for(r of(e=C.get(n),i=[],e))(s.includes(r[0])||s.includes(r[1]))&&i.push(r[0]);i.length&&a.push([n,i])}return a}function gt(s,t){return s!==void 0?s:t!==void 0?t:void 0}function st(s,t){for(let e of t)s.add(e)}c(I,"default",y);var P=class{constructor(t){c(this,"parsers",{}),c(this,"output",{}),c(this,"errors",[]),c(this,"pushToErrors",(e=>this.errors.push(e))),this.options=I.useCached(t)}async read(t){this.file=await(function(e,i){return typeof e=="string"?Rt(e,i):q&&!me&&e instanceof HTMLImageElement?Rt(e.src,i):e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView?new O(e):q&&e instanceof Blob?wt(e,i,"blob",H):void m("Invalid input argument")})(t,this.options)}setup(){if(this.fileParser)return;let{file:t}=this,e=t.getUint16(0);for(let[i,n]of z)if(n.canHandle(t,e))return this.fileParser=new n(this.options,this.file,this.parsers),t[i]=!0;this.file.close&&this.file.close(),m("Unknown file format")}async parse(){let{output:t,errors:e}=this;return this.setup(),this.options.silentErrors?(await this.executeParsers().catch(this.pushToErrors),e.push(...this.fileParser.errors)):await this.executeParsers(),this.file.close&&this.file.close(),this.options.silentErrors&&e.length>0&&(t.errors=e),et(t)}async executeParsers(){let{output:t}=this;await this.fileParser.parse();let e=Object.values(this.parsers).map((async i=>{let n=await i.parse();i.assignToOutput(t,n)}));this.options.silentErrors&&(e=e.map((i=>i.catch(this.pushToErrors)))),await Promise.all(e)}async extractThumbnail(){this.setup();let{options:t,file:e}=this,i=b.get("tiff",t);var n;if(e.tiff?n={start:0,type:"tiff"}:e.jpeg&&(n=await this.fileParser.getOrFindSegment("tiff")),n===void 0)return;let r=await this.fileParser.ensureSegmentChunk(n),a=this.parsers.tiff=new i(r,t,e),o=await a.extractThumbnail();return e.close&&e.close(),o}};async function Mt(s,t){let e=new P(t);return await e.read(s),e.parse()}var be=Object.freeze({__proto__:null,parse:Mt,Exifr:P,fileParsers:z,segmentParsers:b,fileReaders:V,tagKeys:C,tagValues:$,tagRevivers:N,createDictionary:k,extendDictionary:Bt,fetchUrlAsArrayBuffer:G,readBlobAsArrayBuffer:H,chunkedProps:D,otherSegments:J,segments:W,tiffBlocks:p,segmentsAndBlocks:F,tiffExtractables:T,inheritables:Q,allFormatters:E,Options:I}),nt=class{constructor(t,e,i){c(this,"errors",[]),c(this,"ensureSegmentChunk",(async n=>{let r=n.start,a=n.size||65536;if(this.file.chunked)if(this.file.available(r,a))n.chunk=this.file.subarray(r,a);else try{n.chunk=await this.file.readChunk(r,a)}catch(o){m(`Couldn't read segment: ${JSON.stringify(n)}. ${o.message}`)}else this.file.byteLength>r+a?n.chunk=this.file.subarray(r,a):n.size===void 0?n.chunk=this.file.subarray(r):m("Segment unreachable: "+JSON.stringify(n));return n.chunk})),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}injectSegment(t,e){this.options[t].enabled&&this.createParser(t,e)}createParser(t,e){let i=new(b.get(t))(e,this.options,this.file);return this.parsers[t]=i}createParsers(t){for(let e of t){let{type:i,chunk:n}=e,r=this.options[i];if(r&&r.enabled){let a=this.parsers[i];a&&a.append||a||this.createParser(i,n)}}}async readSegments(t){let e=t.map(this.ensureSegmentChunk);await Promise.all(e)}},v=class{static findPosition(t,e){let i=t.getUint16(e+2)+2,n=typeof this.headerLength=="function"?this.headerLength(t,e,i):this.headerLength,r=e+n,a=i-n;return{offset:e,length:i,headerLength:n,start:r,size:a,end:r+a}}static parse(t,e={}){return new this(t,new I({[this.type]:e}),t).parse()}normalizeInput(t){return t instanceof O?t:new O(t)}constructor(t,e={},i){c(this,"errors",[]),c(this,"raw",new Map),c(this,"handleError",(n=>{if(!this.options.silentErrors)throw n;this.errors.push(n.message)})),this.chunk=this.normalizeInput(t),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=e,this.localOptions=e[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(t,e){let i=N.get(e),n=$.get(e),r=C.get(e),a=this.options[e],o=a.reviveValues&&!!i,h=a.translateValues&&!!n,l=a.translateKeys&&!!r,u={};for(let[d,f]of t)o&&i.has(d)?f=i.get(d)(f):h&&n.has(d)&&(f=this.translateValue(f,n.get(d))),l&&r.has(d)&&(d=r.get(d)||d),u[d]=f;return u}translateValue(t,e){return e[t]||e.DEFAULT||t}assignToOutput(t,e){this.assignObjectToOutput(t,this.constructor.type,e)}assignObjectToOutput(t,e,i){if(this.globalOptions.mergeOutput)return Object.assign(t,i);t[e]?Object.assign(t[e],i):t[e]=i}};c(v,"headerLength",4),c(v,"type",void 0),c(v,"multiSegment",!1),c(v,"canHandle",(()=>!1));function we(s){return s===192||s===194||s===196||s===219||s===221||s===218||s===254}function Se(s){return s>=224&&s<=239}function ke(s,t,e){for(let[i,n]of b)if(n.canHandle(s,t,e))return i}var rt=class extends nt{constructor(...t){super(...t),c(this,"appSegments",[]),c(this,"jpegSegments",[]),c(this,"unknownSegments",[])}static canHandle(t,e){return e===65496}async parse(){await this.findAppSegments(),await this.readSegments(this.appSegments),this.mergeMultiSegments(),this.createParsers(this.mergedAppSegments||this.appSegments)}setupSegmentFinderArgs(t){t===!0?(this.findAll=!0,this.wanted=new Set(b.keyList())):(t=t===void 0?b.keyList().filter((e=>this.options[e].enabled)):t.filter((e=>this.options[e].enabled&&b.has(e))),this.findAll=!1,this.remaining=new Set(t),this.wanted=new Set(t)),this.unfinishedMultiSegment=!1}async findAppSegments(t=0,e){this.setupSegmentFinderArgs(e);let{file:i,findAll:n,wanted:r,remaining:a}=this;if(!n&&this.file.chunked&&(n=Array.from(r).some((o=>{let h=b.get(o),l=this.options[o];return h.multiSegment&&l.multiSegment})),n&&await this.file.readWhole()),t=this.findAppSegmentsInRange(t,i.byteLength),!this.options.onlyTiff&&i.chunked){let o=!1;for(;a.size>0&&!o&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:h}=i,l=this.appSegments.some((u=>!this.file.available(u.offset||u.start,u.length||u.size)));if(o=t>h&&!l?!await i.readNextChunk(t):!await i.readNextChunk(h),(t=this.findAppSegmentsInRange(t,i.byteLength))===void 0)return}}}findAppSegmentsInRange(t,e){e-=2;let i,n,r,a,o,h,{file:l,findAll:u,wanted:d,remaining:f,options:g}=this;for(;t<e;t++)if(l.getUint8(t)===255){if(i=l.getUint8(t+1),Se(i)){if(n=l.getUint16(t+2),r=ke(l,t,n),r&&d.has(r)&&(a=b.get(r),o=a.findPosition(l,t),h=g[r],o.type=r,this.appSegments.push(o),!u&&(a.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=o.chunkNumber<o.chunkCount,this.unfinishedMultiSegment||f.delete(r)):f.delete(r),f.size===0)))break;g.recordUnknownSegments&&(o=v.findPosition(l,t),o.marker=i,this.unknownSegments.push(o)),t+=n+1}else if(we(i)){if(n=l.getUint16(t+2),i===218&&g.stopAfterSos!==!1)return;g.recordJpegSegments&&this.jpegSegments.push({offset:t,length:n,marker:i}),t+=n+1}}return t}mergeMultiSegments(){if(!this.appSegments.some((e=>e.multiSegment)))return;let t=(function(e,i){let n,r,a,o=new Map;for(let h=0;h<e.length;h++)n=e[h],r=n[i],o.has(r)?a=o.get(r):o.set(r,a=[]),a.push(n);return Array.from(o)})(this.appSegments,"type");this.mergedAppSegments=t.map((([e,i])=>{let n=b.get(e,this.options);return n.handleMultiSegments?{type:e,chunk:n.handleMultiSegments(i)}:i[0]}))}getSegment(t){return this.appSegments.find((e=>e.type===t))}async getOrFindSegment(t){let e=this.getSegment(t);return e===void 0&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}};c(rt,"type","jpeg"),z.set("jpeg",rt);var xe=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4],xt=class extends v{parseHeader(){var t=this.chunk.getUint16();t===18761?this.le=!0:t===19789&&(this.le=!1),this.chunk.le=this.le,this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:n,skip:r}=this.options[e];n=new Set(n);let a=n.size>0,o=r.size===0,h=this.chunk.getUint16(t);t+=2;for(let l=0;l<h;l++){let u=this.chunk.getUint16(t);if(a){if(n.has(u)&&(i.set(u,this.parseTag(t,u,e)),n.delete(u),n.size===0))break}else!o&&r.has(u)||i.set(u,this.parseTag(t,u,e));t+=12}return i}parseTag(t,e,i){let{chunk:n}=this,r=n.getUint16(t+2),a=n.getUint32(t+4),o=xe[r];if(o*a<=4?t+=8:t=n.getUint32(t+8),(r<1||r>13)&&m(`Invalid TIFF value type. block: ${i.toUpperCase()}, tag: ${e.toString(16)}, type: ${r}, offset ${t}`),t>n.byteLength&&m(`Invalid TIFF value offset. block: ${i.toUpperCase()}, tag: ${e.toString(16)}, type: ${r}, offset ${t} is outside of chunk size ${n.byteLength}`),r===1)return n.getUint8Array(t,a);if(r===2)return qt(n.getString(t,a));if(r===7)return n.getUint8Array(t,a);if(a===1)return this.parseTagValue(r,t);{let h=new((function(u){switch(u){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}})(r))(a),l=o;for(let u=0;u<a;u++)h[u]=this.parseTagValue(r,t),t+=l;return h}}parseTagValue(t,e){let{chunk:i}=this;switch(t){case 1:return i.getUint8(e);case 3:return i.getUint16(e);case 4:return i.getUint32(e);case 5:return i.getUint32(e)/i.getUint32(e+4);case 6:return i.getInt8(e);case 8:return i.getInt16(e);case 9:return i.getInt32(e);case 10:return i.getInt32(e)/i.getInt32(e+4);case 11:return i.getFloat(e);case 12:return i.getDouble(e);case 13:return i.getUint32(e);default:m(`Invalid tiff type ${t}`)}}},X=class extends xt{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1165519206&&t.getUint16(e+8)===0}async parse(){this.parseHeader();let{options:t}=this;return t.ifd0.enabled&&await this.parseIfd0Block(),t.exif.enabled&&await this.safeParse("parseExifBlock"),t.gps.enabled&&await this.safeParse("parseGpsBlock"),t.interop.enabled&&await this.safeParse("parseInteropBlock"),t.ifd1.enabled&&await this.safeParse("parseThumbnailBlock"),this.createOutput()}safeParse(t){let e=this[t]();return e.catch!==void 0&&(e=e.catch(this.handleError)),e}findIfd0Offset(){this.ifd0Offset===void 0&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(this.ifd1Offset===void 0){this.findIfd0Offset();let t=this.chunk.getUint16(this.ifd0Offset),e=this.ifd0Offset+2+12*t;this.ifd1Offset=this.chunk.getUint32(e)}}parseBlock(t,e){let i=new Map;return this[e]=i,this.parseTags(t,e,i),i}async parseIfd0Block(){if(this.ifd0)return;let{file:t}=this;this.findIfd0Offset(),this.ifd0Offset<8&&m("Malformed EXIF data"),!t.chunked&&this.ifd0Offset>t.byteLength&&m(`IFD0 offset points to outside of file.
|
|
2
|
-
this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${t.byteLength}`),t.tiff&&await t.ensureChunk(this.ifd0Offset,zt(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return e.size!==0?(this.exifOffset=e.get(34665),this.interopOffset=e.get(40965),this.gpsOffset=e.get(34853),this.xmp=e.get(700),this.iptc=e.get(33723),this.icc=e.get(34675),this.options.sanitize&&(e.delete(34665),e.delete(40965),e.delete(34853),e.delete(700),e.delete(33723),e.delete(34675)),e):void 0}async parseExifBlock(){if(this.exif||(this.ifd0||await this.parseIfd0Block(),this.exifOffset===void 0))return;this.file.tiff&&await this.file.ensureChunk(this.exifOffset,zt(this.options));let t=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),t}unpack(t,e){let i=t.get(e);i&&i.length===1&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps||(this.ifd0||await this.parseIfd0Block(),this.gpsOffset===void 0))return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",Ht(...t.get(2),t.get(1))),t.set("longitude",Ht(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),this.interopOffset!==void 0||this.exif||await this.parseExifBlock(),this.interopOffset!==void 0))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(t=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||t))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),this.ifd1===void 0)return;let t=this.ifd1.get(513),e=this.ifd1.get(514);return this.chunk.getUint8Array(t,e)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let t,e,i,n={};for(e of p)if(t=this[e],!Yt(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if(e==="ifd1")continue;Object.assign(n,i)}else n[e]=i;return this.makerNote&&(n.makerNote=this.makerNote),this.userComment&&(n.userComment=this.userComment),n}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,n]of Object.entries(e))this.assignObjectToOutput(t,i,n)}};function Ht(s,t,e,i){var n=s+t/60+e/3600;return i!=="S"&&i!=="W"||(n*=-1),n}c(X,"type","tiff"),c(X,"headerLength",10),b.set("tiff",X);var ve=Object.freeze({__proto__:null,default:be,Exifr:P,fileParsers:z,segmentParsers:b,fileReaders:V,tagKeys:C,tagValues:$,tagRevivers:N,createDictionary:k,extendDictionary:Bt,fetchUrlAsArrayBuffer:G,readBlobAsArrayBuffer:H,chunkedProps:D,otherSegments:J,segments:W,tiffBlocks:p,segmentsAndBlocks:F,tiffExtractables:T,inheritables:Q,allFormatters:E,Options:I,parse:Mt}),Lt={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Qt=Object.assign({},Lt,{firstChunkSize:4e4,gps:[1,2,3,4]});async function Ce(s){let t=new P(Qt);await t.read(s);let e=await t.parse();if(e&&e.gps){let{latitude:i,longitude:n}=e.gps;return{latitude:i,longitude:n}}}var te=Object.assign({},Lt,{tiff:!1,ifd1:!0,mergeOutput:!1});async function Oe(s){let t=new P(te);await t.read(s);let e=await t.extractThumbnail();return e&&Ut?It.from(e):e}async function Pe(s){let t=await this.thumbnail(s);if(t!==void 0){let e=new Blob([t]);return URL.createObjectURL(e)}}var ee=Object.assign({},Lt,{firstChunkSize:4e4,ifd0:[274]});async function ie(s){let t=new P(ee);await t.read(s);let e=await t.parse();if(e&&e.ifd0)return e.ifd0[274]}var se=Object.freeze({1:{dimensionSwapped:!1,scaleX:1,scaleY:1,deg:0,rad:0},2:{dimensionSwapped:!1,scaleX:-1,scaleY:1,deg:0,rad:0},3:{dimensionSwapped:!1,scaleX:1,scaleY:1,deg:180,rad:180*Math.PI/180},4:{dimensionSwapped:!1,scaleX:-1,scaleY:1,deg:180,rad:180*Math.PI/180},5:{dimensionSwapped:!0,scaleX:1,scaleY:-1,deg:90,rad:90*Math.PI/180},6:{dimensionSwapped:!0,scaleX:1,scaleY:1,deg:90,rad:90*Math.PI/180},7:{dimensionSwapped:!0,scaleX:1,scaleY:-1,deg:270,rad:270*Math.PI/180},8:{dimensionSwapped:!0,scaleX:1,scaleY:1,deg:270,rad:270*Math.PI/180}}),R=!0,j=!0;if(typeof navigator=="object"){let s=navigator.userAgent;if(s.includes("iPad")||s.includes("iPhone")){let t=s.match(/OS (\d+)_(\d+)/);if(t){let[,e,i]=t;R=Number(e)+.1*Number(i)<13.4,j=!1}}else if(s.includes("OS X 10")){let[,t]=s.match(/OS X 10[_.](\d+)/);R=j=Number(t)<15}if(s.includes("Chrome/")){let[,t]=s.match(/Chrome\/(\d+)/);R=j=Number(t)<81}else if(s.includes("Firefox/")){let[,t]=s.match(/Firefox\/(\d+)/);R=j=Number(t)<77}}async function Ae(s){let t=await ie(s);return Object.assign({canvas:R,css:j},se[t])}var vt=class extends O{constructor(...t){super(...t),c(this,"ranges",new Ct),this.byteLength!==0&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(t===0&&this.byteLength===0&&i){let n=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(n)}else{let n=t+e;if(n>this.byteLength){let{dataView:r}=this._extend(n);this._swapDataView(r)}}}_extend(t){let e;e=Ut?It.allocUnsafe(t):new Uint8Array(t);let i=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:e,dataView:i}}subarray(t,e,i=!1){return e=e||this._lengthToEnd(t),i&&this._tryExtend(t,e),this.ranges.add(t,e),super.subarray(t,e)}set(t,e,i=!1){i&&this._tryExtend(e,t.byteLength,t);let n=super.set(t,e);return this.ranges.add(e,n.byteLength),n}async ensureChunk(t,e){this.chunked&&(this.ranges.available(t,e)||await this.readChunk(t,e))}available(t,e){return this.ranges.available(t,e)}},Ct=class{constructor(){c(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let n=t+e,r=this.list.filter((a=>Wt(t,a.offset,n)||Wt(t,a.end,n)));if(r.length>0){t=Math.min(t,...r.map((o=>o.offset))),n=Math.max(n,...r.map((o=>o.end))),e=n-t;let a=r.shift();a.offset=t,a.length=e,a.end=n,this.list=this.list.filter((o=>!r.includes(o)))}else this.list.push({offset:t,length:e,end:n})}available(t,e){let i=t+e;return this.list.some((n=>n.offset<=t&&i<=n.end))}};function Wt(s,t,e){return s<=t&&t<=e}var at=class extends vt{constructor(t,e){super(0),c(this,"chunksRead",0),this.input=t,this.options=e}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(t=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let e=this.options.chunkSize,i=await this.readChunk(t,e);return!!i&&i.byteLength===e}async readChunk(t,e){if(this.chunksRead++,(e=this.safeWrapAddress(t,e))!==0)return this._readChunk(t,e)}safeWrapAddress(t,e){return this.size!==void 0&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(this.ranges.list.length!==0)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return this.size!==void 0&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}};V.set("blob",class extends at{async readWhole(){this.chunked=!1;let s=await H(this.input);this._swapArrayBuffer(s)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(s,t){let e=t?s+t:void 0,i=this.input.slice(s,e),n=await H(i);return this.set(n,s,!0)}});var Ie=Object.freeze({__proto__:null,default:ve,Exifr:P,fileParsers:z,segmentParsers:b,fileReaders:V,tagKeys:C,tagValues:$,tagRevivers:N,createDictionary:k,extendDictionary:Bt,fetchUrlAsArrayBuffer:G,readBlobAsArrayBuffer:H,chunkedProps:D,otherSegments:J,segments:W,tiffBlocks:p,segmentsAndBlocks:F,tiffExtractables:T,inheritables:Q,allFormatters:E,Options:I,parse:Mt,gpsOnlyOptions:Qt,gps:Ce,thumbnailOnlyOptions:te,thumbnail:Oe,thumbnailUrl:Pe,orientationOnlyOptions:ee,orientation:ie,rotations:se,get rotateCanvas(){return R},get rotateCss(){return j},rotation:Ae});V.set("url",class extends at{async readWhole(){this.chunked=!1;let s=await G(this.input);s instanceof ArrayBuffer?this._swapArrayBuffer(s):s instanceof Uint8Array&&this._swapBuffer(s)}async _readChunk(s,t){let e=t?s+t-1:void 0,i=this.options.httpHeaders||{};(s||e)&&(i.range=`bytes=${[s,e].join("-")}`);let n=await Jt(this.input,{headers:i}),r=await n.arrayBuffer(),a=r.byteLength;if(n.status!==416)return a!==t&&(this.size=s+a),this.set(r,s,!0)}});O.prototype.getUint64=function(s){let t=this.getUint32(s),e=this.getUint32(s+4);return t<1048575?t<<32|e:typeof tt!==void 0?(console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),tt(t)<<tt(32)|tt(e)):void m("Trying to read 64b value but JS can only handle 53b numbers.")};var Ot=class extends nt{parseBoxes(t=0){let e=[];for(;t<this.file.byteLength-4;){let i=this.parseBoxHead(t);if(e.push(i),i.length===0)break;t+=i.length}return e}parseSubBoxes(t){t.boxes=this.parseBoxes(t.start)}findBox(t,e){return t.boxes===void 0&&this.parseSubBoxes(t),t.boxes.find((i=>i.kind===e))}parseBoxHead(t){let e=this.file.getUint32(t),i=this.file.getString(t+4,4),n=t+8;return e===1&&(e=this.file.getUint64(t+8),n+=8),{offset:t,length:e,kind:i,start:n}}parseBoxFullHead(t){if(t.version!==void 0)return;let e=this.file.getUint32(t.start);t.version=e>>24,t.start+=4}},ot=class extends Ot{static canHandle(t,e){if(e!==0)return!1;let i=t.getUint16(2);if(i>50)return!1;let n=16,r=[];for(;n<i;)r.push(t.getString(n,4)),n+=4;return r.includes(this.type)}async parse(){let t=this.file.getUint32(0),e=this.parseBoxHead(t);for(;e.kind!=="meta";)t+=e.length,await this.file.ensureChunk(t,16),e=this.parseBoxHead(t);await this.file.ensureChunk(e.offset,e.length),this.parseBoxFullHead(e),this.parseSubBoxes(e),this.options.icc.enabled&&await this.findIcc(e),this.options.tiff.enabled&&await this.findExif(e)}async registerSegment(t,e,i){await this.file.ensureChunk(e,i);let n=this.file.subarray(e,i);this.createParser(t,n)}async findIcc(t){let e=this.findBox(t,"iprp");if(e===void 0)return;let i=this.findBox(e,"ipco");if(i===void 0)return;let n=this.findBox(i,"colr");n!==void 0&&await this.registerSegment("icc",n.offset+12,n.length)}async findExif(t){let e=this.findBox(t,"iinf");if(e===void 0)return;let i=this.findBox(t,"iloc");if(i===void 0)return;let n=this.findExifLocIdInIinf(e),r=this.findExtentInIloc(i,n);if(r===void 0)return;let[a,o]=r;await this.file.ensureChunk(a,o);let h=4+this.file.getUint32(a);a+=h,o-=h,await this.registerSegment("tiff",a,o)}findExifLocIdInIinf(t){this.parseBoxFullHead(t);let e,i,n,r,a=t.start,o=this.file.getUint16(a);for(a+=2;o--;){if(e=this.parseBoxHead(a),this.parseBoxFullHead(e),i=e.start,e.version>=2&&(n=e.version===3?4:2,r=this.file.getString(i+n+2,4),r==="Exif"))return this.file.getUintBytes(i,n);a+=e.length}}get8bits(t){let e=this.file.getUint8(t);return[e>>4,15&e]}findExtentInIloc(t,e){this.parseBoxFullHead(t);let i=t.start,[n,r]=this.get8bits(i++),[a,o]=this.get8bits(i++),h=t.version===2?4:2,l=t.version===1||t.version===2?2:0,u=o+n+r,d=t.version===2?4:2,f=this.file.getUintBytes(i,d);for(i+=d;f--;){let g=this.file.getUintBytes(i,h);i+=h+l+2+a;let S=this.file.getUint16(i);if(i+=2,g===e)return S>1&&console.warn(`ILOC box has more than one extent but we're only processing one
|
|
3
|
-
Please create an issue at https://github.com/MikeKovarik/exifr with this file`),[this.file.getUintBytes(i+o,n),this.file.getUintBytes(i+o+n,r)];i+=S*u}}},ht=class extends ot{};c(ht,"type","heic");var lt=class extends ot{};c(lt,"type","avif"),z.set("heic",ht),z.set("avif",lt),k(C,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),k(C,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),k(C,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),k($,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);var K=k($,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]),$t={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};K.set(37392,$t),K.set(41488,$t);var pt={0:"Normal",1:"Low",2:"High"};function _t(s){return typeof s=="object"&&s.length!==void 0?s[0]:s}function Xt(s){let t=Array.from(s).slice(1);return t[1]>15&&(t=t.map((e=>String.fromCharCode(e)))),t[2]!=="0"&&t[2]!==0||t.pop(),t.join(".")}function mt(s){if(typeof s=="string"){var[t,e,i,n,r,a]=s.trim().split(/[-: ]/g).map(Number),o=new Date(t,e-1,i);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(o.setHours(n),o.setMinutes(r),o.setSeconds(a)),Number.isNaN(+o)?s:o}}function _(s){if(typeof s=="string")return s;let t=[];if(s[1]===0&&s[s.length-1]===0)for(let e=0;e<s.length;e+=2)t.push(Kt(s[e+1],s[e]));else for(let e=0;e<s.length;e+=2)t.push(Kt(s[e],s[e+1]));return qt(String.fromCodePoint(...t))}function Kt(s,t){return s<<8|t}K.set(41992,pt),K.set(41993,pt),K.set(41994,pt),k(N,["ifd0","ifd1"],[[50827,function(s){return typeof s!="string"?Zt(s):s}],[306,mt],[40091,_],[40092,_],[40093,_],[40094,_],[40095,_]]),k(N,"exif",[[40960,Xt],[36864,Xt],[36867,mt],[36868,mt],[40962,_t],[40963,_t]]),k(N,"gps",[[0,s=>Array.from(s).join(".")],[7,s=>Array.from(s).join(":")]]);var Y=class extends v{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1752462448&&t.getString(e+4,20)==="http://ns.adobe.com/"}static headerLength(t,e){return t.getString(e+4,34)==="http://ns.adobe.com/xmp/extension/"?79:33}static findPosition(t,e){let i=super.findPosition(t,e);return i.multiSegment=i.extended=i.headerLength===79,i.multiSegment?(i.chunkCount=t.getUint8(e+72),i.chunkNumber=t.getUint8(e+76),t.getUint8(e+77)!==0&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(t){return t.map((e=>e.chunk.getString())).join("")}normalizeInput(t){return typeof t=="string"?t:O.from(t).getString()}parse(t=this.chunk){if(!this.localOptions.parse)return t;t=(function(r){let a={},o={};for(let h of oe)a[h]=[],o[h]=0;return r.replace(Le,((h,l,u)=>{if(l==="<"){let d=++o[u];return a[u].push(d),`${h}#${d}`}return`${h}#${a[u].pop()}`}))})(t);let e=ft.findAll(t,"rdf","Description");e.length===0&&e.push(new ft("rdf","Description",void 0,t));let i,n={};for(let r of e)for(let a of r.properties)i=Me(a.ns,n),ne(a,i);return(function(r){let a;for(let o in r)a=r[o]=et(r[o]),a===void 0&&delete r[o];return et(r)})(n)}assignToOutput(t,e){if(this.localOptions.parse)for(let[i,n]of Object.entries(e))switch(i){case"tiff":this.assignObjectToOutput(t,"ifd0",n);break;case"exif":this.assignObjectToOutput(t,"exif",n);break;case"xmlns":break;default:this.assignObjectToOutput(t,i,n)}else t.xmp=e}};c(Y,"type","xmp"),c(Y,"multiSegment",!0),b.set("xmp",Y);var Pt=class s{static findAll(t){return re(t,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[3].slice(1,-1);return n=ae(n),new s(e,i,n)}constructor(t,e,i){this.ns=t,this.name=e,this.value=i}serialize(){return this.value}},ft=class s{static findAll(t,e,i){if(e!==void 0||i!==void 0){e=e||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var n=new RegExp(`<(${e}):(${i})(#\\d+)?((\\s+?[\\w\\d-:]+=("[^"]*"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)`,"gm")}else n=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return re(t,n).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[4],r=t[8];return new s(e,i,n,r)}constructor(t,e,i,n){this.ns=t,this.name=e,this.attrString=i,this.innerXml=n,this.attrs=Pt.findAll(i),this.children=s.findAll(n),this.value=this.children.length===0?ae(n):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return this.value!==void 0&&this.attrs.length===0&&this.children.length===0}get isListContainer(){return this.children.length===1&&this.children[0].isList}get isList(){let{ns:t,name:e}=this;return t==="rdf"&&(e==="Seq"||e==="Bag"||e==="Alt")}get isListItem(){return this.ns==="rdf"&&this.name==="li"}serialize(){if(this.properties.length===0&&this.value===void 0)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return Be(this.children.map(Ue));if(this.isListItem&&this.children.length===1&&this.attrs.length===0)return this.children[0].serialize();let t={};for(let e of this.properties)ne(e,t);return this.value!==void 0&&(t.value=this.value),et(t)}};function ne(s,t){let e=s.serialize();e!==void 0&&(t[s.name]=e)}var Ue=s=>s.serialize(),Be=s=>s.length===1?s[0]:s,Me=(s,t)=>t[s]?t[s]:t[s]={};function re(s,t){let e,i=[];if(!s)return i;for(;(e=t.exec(s))!==null;)i.push(e);return i}function ae(s){if((function(i){return i==null||i==="null"||i==="undefined"||i===""||i.trim()===""})(s))return;let t=Number(s);if(!Number.isNaN(t))return t;let e=s.toLowerCase();return e==="true"||e!=="false"&&s.trim()}var oe=["rdf:li","rdf:Seq","rdf:Bag","rdf:Alt","rdf:Description"],Le=new RegExp(`(<|\\/)(${oe.join("|")})`,"g"),he=Ie;async function Ve(s){try{return await he.parse(s)||null}catch{return null}}function Re(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,"0")).join("")}async function je(s){if(typeof createImageBitmap>"u"||typeof document>"u"){if(s&&typeof s.arrayBuffer=="function"){let o=await s.arrayBuffer(),h=globalThis.Buffer,l=typeof h<"u"?h.from(o).toString("base64"):btoa(String.fromCharCode(...new Uint8Array(o)));return`data:${s.type||"image/png"};base64,${l}`}if(typeof s=="string")return s}let t=await createImageBitmap(s),n=Math.min(1,1654/t.width,2339/t.height);if(n===1&&(s.type==="image/jpeg"||s.type==="image/jpg"||s.type==="image/png"||s.type==="image/webp"))return t.close(),new Promise((o,h)=>{let l=new FileReader;l.onload=()=>o(l.result),l.onerror=h,l.readAsDataURL(s)});let r=document.createElement("canvas");r.width=Math.round(t.width*n),r.height=Math.round(t.height*n),r.getContext("2d").drawImage(t,0,0,r.width,r.height),t.close();let a=s.type==="image/png"?"image/png":"image/jpeg";return r.toDataURL(a,a==="image/png"?void 0:.82)}function le(s,t=21,e=.2,i=128){let{data:n,width:r,height:a}=s,o=r+1,h=new Float64Array((r+1)*(a+1)),l=new Float64Array((r+1)*(a+1)),u=new Uint8Array(r*a);for(let f=0;f<a;f++){let g=0,S=0,U=f*r,B=(f+1)*o,A=f*o;for(let w=0;w<r;w++){let x=(U+w)*4,M=n[x]*77+n[x+1]*150+n[x+2]*29>>8;u[U+w]=M,g+=M,S+=M*M,h[B+w+1]=h[A+w+1]+g,l[B+w+1]=l[A+w+1]+S}}let d=Math.floor(t/2);for(let f=0;f<a;f++){let g=Math.max(0,f-d),S=Math.min(a-1,f+d),U=g*o,B=(S+1)*o;for(let A=0;A<r;A++){let w=Math.max(0,A-d),x=Math.min(r-1,A+d),M=(x-w+1)*(S-g+1),ue=h[B+x+1]-h[U+x+1]-h[B+w]+h[U+w],de=l[B+x+1]-l[U+x+1]-l[B+w]+l[U+w],ut=ue/M,ce=Math.max(0,de/M-ut*ut),ge=Math.sqrt(ce),pe=ut*(1+e*(ge/i-1)),Tt=f*r+A,dt=u[Tt]<pe?0:255,ct=Tt*4;n[ct]=dt,n[ct+1]=dt,n[ct+2]=dt}}return s}function Ge(s,t=21,e=.2,i=128){return new Promise(n=>{let r=new Image;r.onload=()=>{let a=document.createElement("canvas");a.width=r.width,a.height=r.height;let o=a.getContext("2d");o.drawImage(r,0,0);let h=o.getImageData(0,0,a.width,a.height);le(h,t,e,i),o.putImageData(h,0,0);let l=s.startsWith("data:image/png"),u=l?"image/png":"image/jpeg";n(a.toDataURL(u,l?void 0:.82))},r.src=s})}function He(s){return new Promise(t=>{let e=new Image;e.onload=()=>{let i=document.createElement("canvas");i.width=e.height,i.height=e.width;let n=i.getContext("2d");n.translate(i.width/2,i.height/2),n.rotate(Math.PI/2),n.drawImage(e,-e.width/2,-e.height/2);let r=s.startsWith("data:image/png"),a=r?"image/png":"image/jpeg";t(i.toDataURL(a,r?void 0:.82))},e.src=s})}function We(s,t=""){if(!s)return"";let e=s.getCroppedCanvas(),i=t.startsWith("data:image/png"),n=i?"image/png":"image/jpeg";return e.toDataURL(n,i?void 0:.82)}function Dt(s){if(!s||typeof s!="object")return{crop:null,rotation:0,filter:"none"};let t=null;s.crop&&typeof s.crop=="object"&&(s.crop.width>0&&s.crop.height>0?t={x:Math.round(s.crop.x||0),y:Math.round(s.crop.y||0),width:Math.round(s.crop.width),height:Math.round(s.crop.height)}:s.crop.w>0&&s.crop.h>0&&(t={x:Number(s.crop.x)||0,y:Number(s.crop.y)||0,w:Number(s.crop.w)||1,h:Number(s.crop.h)||1}));let e=s.rotation!==void 0?s.rotation:s.rotate,i=(Math.round(Number(e)||0)%360+360)%360,n=s.filter==="bw"?"bw":"none";return{crop:t,rotation:i,filter:n}}function De(s){if(!s)return!1;let t=Dt(s);return!!(t.crop||t.rotation!==0||t.filter!=="none")}function Ft(s,t){let e=Dt(t),i=s.naturalWidth||s.width||0,n=s.naturalHeight||s.height||0,r=document.createElement("canvas"),a=i,o=n,h=0,l=0;if(e.crop){let f=e.crop;"w"in f&&!("width"in f)?(h=Math.max(0,Math.min(Math.round(f.x*i),i)),l=Math.max(0,Math.min(Math.round(f.y*n),n)),a=Math.max(1,Math.min(Math.round(f.w*i),i-h)),o=Math.max(1,Math.min(Math.round(f.h*n),n-l))):(h=Math.max(0,Math.min(f.x,i)),l=Math.max(0,Math.min(f.y,n)),a=Math.max(1,Math.min(f.width,i-h)),o=Math.max(1,Math.min(f.height,n-l)))}r.width=a,r.height=o,r.getContext("2d").drawImage(s,h,l,a,o,0,0,a,o);let d=r;if(e.rotation!==0){let f=e.rotation,g=document.createElement("canvas");f===90||f===270?(g.width=d.height,g.height=d.width):(g.width=d.width,g.height=d.height);let S=g.getContext("2d");S.translate(g.width/2,g.height/2),S.rotate(f*Math.PI/180),S.drawImage(d,-d.width/2,-d.height/2),d=g}if(e.filter==="bw"){let f=d.getContext("2d"),g=f.getImageData(0,0,d.width,d.height);le(g),f.putImageData(g,0,0)}return d}function $e(s,t){if(!s)return Promise.resolve("");let e=Dt(t);return De(e)?new Promise((i,n)=>{let r=new Image;r.onload=()=>{try{let a=s.startsWith("data:image/png"),o=a?"image/png":"image/jpeg",h=Ft(r,e);i(h.toDataURL(o,a?void 0:.82))}catch(a){n(a)}},r.onerror=n,r.src=s}):Promise.resolve(s)}function Fe(s){return new Promise((t,e)=>{let i=new Image;i.onload=()=>t(i),i.onerror=e,i.src=s})}var fe=class extends Et{async renderEdits(t,e={}){if(!t)return"";if(typeof document>"u")return t;try{let i=await Fe(t),n={...e};return e?.crop&&"w"in e.crop&&(n.crop={x:Math.round((e.crop.x||0)*i.naturalWidth),y:Math.round((e.crop.y||0)*i.naturalHeight),width:Math.round((e.crop.w||1)*i.naturalWidth),height:Math.round((e.crop.h||1)*i.naturalHeight)}),e?.rotate!==void 0&&(n.rotation=e.rotate),Ft(i,n).toDataURL("image/jpeg",.92)}catch{return t}}async crop(t,e){return this.renderEdits(t,{crop:e})}async rotate(t,e){return this.renderEdits(t,{rotate:e})}async applyFilter(t,e){return this.renderEdits(t,{filter:e})}};export{Ve as a,Re as b,je as c,le as d,Ge as e,He as f,We as g,Dt as h,Ft as i,$e as j,fe as k};
|
|
4
|
-
//# sourceMappingURL=chunk-G5EUMLYT.js.map
|
package/dist/chunk-K4NR6OAC.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as L,b as S,d as m}from"./chunk-L4OVZN23.js";import{a as U}from"./chunk-FQRADJY6.js";import{a as D}from"./chunk-DIU5BGU5.js";async function $(){if(typeof location<"u"&&location.search&&(new URLSearchParams(location.search).has("no-opfs")||new URLSearchParams(location.search).get("storage")==="indexeddb")||typeof navigator>"u"||!navigator.storage||typeof navigator.storage.getDirectory!="function")return!1;try{let l=await navigator.storage.getDirectory();if(!l)return!1;let t=`.copio-probe-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`,r=await l.getFileHandle(t,{create:!0}),i=await r.createWritable();if(await i.write(new Uint8Array([1,2,3,4])),await i.close(),(await r.getFile()).size!==4)throw new Error("OPFS probe size mismatch");return await l.removeEntry(t),!0}catch{return!1}}function j(l,t,r="store.json"){let i=0,s=null,n=Promise.resolve(),a=0,o=()=>typeof t=="function"?t():t,e=async()=>{await n;let f=o();if(f){i=1;try{let u=await(await(await f.getFileHandle(r)).getFile()).text();u&&u.trim().length>0&&l.setJson(u)}catch{}finally{i=0}}},c=()=>{let f=o();return f?(a++,i=2,n=n.catch(()=>{}).then(async()=>{try{let w=l.getJson(),u=await(await f.getFileHandle(r,{create:!0})).createWritable();await u.write(w),await u.close()}catch(w){console.warn("[OpfsPersister] Failed to save store.json:",w)}finally{a--,a<=0&&(a=0,i=0)}}),n):Promise.resolve()};return{load:e,save:c,startAutoSave:()=>{s||(s=l.addDidFinishTransactionListener(()=>{c()}))},stopAutoSave:()=>{s&&(l.delListener(s),s=null)},getStatus:()=>i,getStore:()=>l}}async function O(l){let t=[];try{if(typeof l.entries=="function")for await(let r of l.entries())t.push(r);else if(typeof l.values=="function")for await(let r of l.values())t.push([r.name,r])}catch(r){console.warn("[OpfsAdapter] Error reading directory entries:",r)}return t}var v=class extends D{#p;#d="copio";#b=null;#g=null;#r=null;#i=null;#u=null;#t=!1;#e=null;#c=new Set;#l=new Map;#s=new Map;#a=new Map;#n=new Map;#w=null;constructor(t={}){super(),this.#p=t,this.#d=t.dirName||"copio",t.store?this.#i=t.store:(this.#i=L(),this.#i.setTable("docs",{})),this.#u=t.persister||j(this.#i,()=>this.#g,"store.json")}get store(){return this.#t?this.#e?.store:this.#i}get persister(){return this.#t?this.#e?.persister:this.#u}get isFallback(){return this.#t}get fallbackAdapter(){return this.#e}async#o(){if(this.#t)return!1;if(this.#r&&this.#g)return!0;if(typeof navigator<"u"&&navigator.storage&&typeof navigator.storage.getDirectory=="function")try{return this.#b=await navigator.storage.getDirectory(),this.#g=await this.#b.getDirectoryHandle(this.#d,{create:!0}),this.#r=await this.#g.getDirectoryHandle("docs",{create:!0}),!0}catch(t){return console.warn("[OpfsAdapter] OPFS directory access failed, switching to fallback:",t),await this.#h(),!1}else return await this.#h(),!1}#y(t,r){return typeof r=="string"&&r.startsWith("blob:")&&(this.#c.add(r),this.#l.has(t)||this.#l.set(t,[]),this.#l.get(t).push(r)),r}revokeDocUrls(t){if(this.#t){this.#e?.revokeDocUrls(t);return}let r=this.#l.get(t);if(r){for(let i of r){try{URL.revokeObjectURL(i)}catch{}this.#c.delete(i)}this.#l.delete(t)}for(let[i,s]of this.#s.entries())if(i.startsWith(`${t}:`)){try{URL.revokeObjectURL(s)}catch{}this.#s.delete(i)}for(let[i,s]of this.#a.entries())if(i.startsWith(`${t}:`)){try{URL.revokeObjectURL(s)}catch{}this.#a.delete(i)}this.#n.delete(t)}revokeAllUrls(){if(this.#t){this.#e?.revokeAllUrls();return}for(let t of this.#c)try{URL.revokeObjectURL(t)}catch{}this.#c.clear(),this.#l.clear(),this.#s.clear(),this.#a.clear(),this.#n.clear()}async init(){return this.#w?this.#w:(this.#w=(async()=>{if(this.#p.forceFallback)return this.#h();if(!await $())return this.#h();try{await this.#o(),await this.#u.load(),this.#u.startAutoSave(),await this.sweepOrphans();let r=!1;if(typeof navigator<"u"&&navigator.storage&&navigator.storage.persisted)try{r=await navigator.storage.persisted()}catch{}return{kind:"opfs",persistent:r}}catch(r){return console.warn("[OpfsAdapter] OPFS initialization failed, switching to IndexedDB fallback:",r),this.#h()}})(),this.#w)}async#h(){return this.#t=!0,this.#e=new m(this.#p),{kind:"indexeddb",persistent:(await this.#e.init()).persistent}}async sweepOrphans(){if(this.#t)return this.#e?.sweepOrphans();if(await this.#o(),!this.#r)return 0;let t=0,r=this.#i.getTable("docs")||{},i=new Set(Object.keys(r)),s=new Map;for(let[a,o]of Object.entries(r)){let e=this.#f(o.pages);s.set(a,new Set(e.map(c=>c.id)))}let n=await O(this.#r);for(let[a,o]of n)if(o.kind==="directory")if(i.has(a)){let e=s.get(a)||new Set,c=o,g=await O(c);for(let[y]of g){let f=y.replace(/-original\.bin$/,"").replace(/\.bin$/,"");if(!e.has(f))try{await c.removeEntry(y),t++}catch{}}}else try{await this.#r.removeEntry(a,{recursive:!0}),t++}catch{}return t}listDocsSync(){if(this.#t)return this.#e?.listDocsSync();let t=this.#i.getTable("docs");return Object.entries(t||{}).map(([r,i])=>({id:r,name:i.name||"",pages:this.#f(i.pages)}))}async listDocs(){return this.#t?this.#e?.listDocs():this.listDocsSync()}getDocSync(t){if(this.#t)return this.#e?.getDocSync(t);if(this.#n.has(t))return this.#n.get(t);if(!this.#i.hasRow("docs",t))return null;let r=this.#i.getRow("docs",t);return{id:t,name:r.name||"",pages:this.#f(r.pages)}}async getDoc(t){if(this.#t)return this.#e?.getDoc(t);if(await this.#o(),!this.#i.hasRow("docs",t))return null;let r=this.#i.getRow("docs",t),i=this.#f(r.pages),s=null;if(this.#r)try{s=await this.#r.getDirectoryHandle(t)}catch{}let n=await Promise.all(i.map(async o=>{if(!o||!s)return o;let e={...o},c=`${t}:${o.id}`;try{let f=await(await s.getFileHandle(`${o.id}.bin`)).getFile();e.blob=f,this.#s.has(c)?e.src=this.#s.get(c):(e.src=this.#y(t,URL.createObjectURL(f)),this.#s.set(c,e.src))}catch{}let g=`${t}:${o.id}:orig`;try{let f=await(await s.getFileHandle(`${o.id}-original.bin`)).getFile();e.originalBlob=f,this.#a.has(g)?e.originalSrc=this.#a.get(g):(e.originalSrc=this.#y(t,URL.createObjectURL(f)),this.#a.set(g,e.originalSrc))}catch{e.blob&&(e.originalBlob=e.blob,e.originalSrc=e.src)}return e})),a={id:t,name:r.name||"",pages:n};return this.#n.set(t,a),a}async saveDoc(t,r){if(this.#t)return this.#e?.saveDoc(t,r);if(!t)throw new Error("Cannot save document without an ID");let i=Array.isArray(r.pages)?r.pages:this.#f(r.pages),s=[],n=[],a=[];for(let e of i){if(!e)continue;let c=S(e.src)||(e.src instanceof Blob?e.src:null)||(e.blob instanceof Blob?e.blob:null),g=c?.type||"image/jpeg",y={id:e.id,name:e.name||"",type:e.type||"image",hasBlob:!0,mimeType:g,edits:e.edits,exif:e.exif,content:e.content,ocrText:e.ocrText??null,ocrConfidence:e.ocrConfidence??null,ocrWords:Array.isArray(e.ocrWords)?e.ocrWords:null,ocrWidth:e.ocrWidth??null,ocrHeight:e.ocrHeight??null};s.push(y);let f=`${t}:${e.id}`,w=`${t}:${e.id}:orig`,h={...e},u=this.#s.get(f),k=typeof e.src=="string"&&e.src.startsWith("data:")||e.src instanceof Blob||e.src&&u&&e.src!==u;if(c)if(h.blob=c,k||!u){if(u){try{URL.revokeObjectURL(u)}catch{}this.#c.delete(u)}let b=this.#y(t,URL.createObjectURL(c));this.#s.set(f,b),h.src=b}else h.src=u;let d=S(e.originalSrc)||(e.originalSrc instanceof Blob?e.originalSrc:null)||(e.originalBlob instanceof Blob?e.originalBlob:null),p=this.#a.get(w),R=!p&&!d&&(!e.originalSrc||e.originalSrc===e.src);R&&c&&(d=c);let H=typeof e.originalSrc=="string"&&e.originalSrc.startsWith("data:")||e.originalSrc instanceof Blob||R&&!!d;if(d)if(h.originalBlob=d,H||!p){if(p&&H){try{URL.revokeObjectURL(p)}catch{}this.#c.delete(p)}let b=this.#y(t,URL.createObjectURL(d));this.#a.set(w,b),h.originalSrc=b}else h.originalSrc=p;else p?h.originalSrc=p:e.originalSrc?h.originalSrc=e.originalSrc:(h.originalSrc=h.src,h.blob&&(h.originalBlob=h.blob));n.push(h),a.push({pageId:e.id,page:e,srcBlob:c,origBlob:d})}if(this.#i.setRow("docs",t,{name:r.name||"",pages:JSON.stringify(s)}),this.#n.set(t,{id:t,name:r.name||"",pages:n}),await this.#o(),this.#t)return this.#e?.saveDoc(t,r);let o=null;if(this.#r)try{o=await this.#r.getDirectoryHandle(t,{create:!0})}catch(e){console.warn(`[OpfsAdapter] Failed to get doc directory "${t}":`,e)}if(o)for(let e of a){let{pageId:c,page:g,srcBlob:y,origBlob:f}=e;if(!y&&typeof g.src=="string"&&g.src.startsWith("blob:"))try{y=await(await fetch(g.src)).blob()}catch{}if(y)try{let h=await(await o.getFileHandle(`${c}.bin`,{create:!0})).createWritable();await h.write(y),await h.close()}catch(w){console.warn(`[OpfsAdapter] Failed writing page file "${c}.bin":`,w)}if(!f&&typeof g.originalSrc=="string"&&g.originalSrc.startsWith("blob:"))try{f=await(await fetch(g.originalSrc)).blob()}catch{}if(f)try{let h=await(await o.getFileHandle(`${c}-original.bin`,{create:!0})).createWritable();await h.write(f),await h.close()}catch{}}}async deleteDoc(t){if(this.#t)return this.#e?.deleteDoc(t);if(this.#i.delRow("docs",t),this.#n.delete(t),this.revokeDocUrls(t),await this.#o(),this.#r)try{await this.#r.removeEntry(t,{recursive:!0})}catch{}}async renameDoc(t,r){if(this.#t)return this.#e?.renameDoc(t,r);if(!this.#i.hasRow("docs",t))throw new Error(`Document "${t}" not found`);this.#i.setCell("docs",t,"name",r),this.#n.has(t)&&(this.#n.get(t).name=r)}async savePage(t,r,i){if(this.#t)return this.#e?.savePage(t,r,i);await this.#o();let s=await this.getDoc(t);if(!s)throw new Error(`Document ${t} not found`);let n=s.pages.findIndex(e=>e.id===r),a;if(n>=0)typeof i=="object"&&i!==null&&!(i instanceof Blob)?s.pages[n]={...s.pages[n],...i}:s.pages[n]={...s.pages[n],src:i,blob:i instanceof Blob?i:void 0},a=s.pages[n];else{let e=typeof i=="object"&&i!==null&&!(i instanceof Blob)?{id:r,...i}:{id:r,src:i,blob:i instanceof Blob?i:void 0};s.pages.push(e),a=e}let o=S(a.src)||(a.src instanceof Blob?a.src:null)||(a.blob instanceof Blob?a.blob:null);if(!o&&typeof a.src=="string"&&a.src.startsWith("blob:"))try{o=await(await fetch(a.src)).blob()}catch{}if(o&&this.#r)try{let g=await(await(await this.#r.getDirectoryHandle(t,{create:!0})).getFileHandle(`${r}.bin`,{create:!0})).createWritable();await g.write(o),await g.close()}catch(e){console.warn(`[OpfsAdapter] Failed writing page file "${r}.bin":`,e)}await this.saveDoc(t,s)}async getPage(t,r){if(this.#t)return this.#e?.getPage(t,r);if(await this.#o(),this.#r)try{return await(await(await this.#r.getDirectoryHandle(t)).getFileHandle(`${r}.bin`)).getFile()}catch{}let i=this.getDocSync(t);if(!i)return null;let s=i.pages.find(n=>n.id===r);return s?s.content??s.src??s:null}async deletePage(t,r){if(this.#t)return this.#e?.deletePage(t,r);await this.#o();let i=this.getDocSync(t);if(!i)return;if(i.pages=i.pages.filter(a=>a.id!==r),this.#i.setRow("docs",t,{name:i.name||"",pages:JSON.stringify(i.pages)}),this.#r){try{await(await this.#r.getDirectoryHandle(t)).removeEntry(`${r}.bin`)}catch{}try{await(await this.#r.getDirectoryHandle(t)).removeEntry(`${r}-original.bin`)}catch{}}let s=`${t}:${r}`;if(this.#s.has(s)){try{URL.revokeObjectURL(this.#s.get(s))}catch{}this.#s.delete(s)}let n=`${t}:${r}:orig`;if(this.#a.has(n)){try{URL.revokeObjectURL(this.#a.get(n))}catch{}this.#a.delete(n)}this.#n.delete(t)}subscribe(t){if(this.#t)return this.#e?.subscribe(t);let r=this.#i.addTableListener("docs",t);return()=>{this.#i.delListener(r)}}#f(t){if(Array.isArray(t))return t;if(typeof t=="string")try{return JSON.parse(t)}catch{return[]}return[]}};function M(l={}){return l.forceMemory?new U:l.forceIndexedDb?new m(l):l.forceOpfs?new v(l):typeof navigator<"u"&&navigator.storage&&typeof navigator.storage.getDirectory=="function"?new v(l):typeof indexedDB<"u"?new m(l):new U}export{$ as a,v as b,M as c};
|
|
2
|
-
//# sourceMappingURL=chunk-K4NR6OAC.js.map
|