Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exifr

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exifr - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

12

CHANGELOG.md

@@ -5,2 +5,11 @@ # Changelog

## [4.1.0]
### Added
- Support for IE10
### Breaking changes (for IE / `legacy` bundle)
- No need to use these polyfills anymore: `TextDecoder`, `Object.assign`, `Object.keys`, `Object.values`, `Object.fromEntries`, `Array.from`, `Array.prototype.includes`, `fetch`, `Map`, `Set`.
- `Promise` polyfill is needed now instead of `regeneratorRuntime`
## [4.0.0]

@@ -131,3 +140,4 @@

[Unreleased]: https://github.com/MikeKovarik/exifr/compare/v4.0.0...HEAD
[Unreleased]: https://github.com/MikeKovarik/exifr/compare/v4.1.0...HEAD
[4.0.0]: https://github.com/MikeKovarik/exifr/compare/v4.0.0...v4.1.0
[4.0.0]: https://github.com/MikeKovarik/exifr/compare/v3.0.1...v4.0.0

@@ -134,0 +144,0 @@ [3.0.1]: https://github.com/MikeKovarik/exifr/compare/v3.0.0...v3.0.1

2

dist/core.esm.js

@@ -1,1 +0,1 @@

var e="undefined"!=typeof Buffer,t="undefined"!=typeof navigator,i=t&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(e){return function(e){if(void 0===e)return!0;return e instanceof Map?0===e.size:0===Object.values(e).filter(a).length}(e)?void 0:e}const a=e=>void 0!==e;function f(e){let t=new Error(e);return delete t.stack,t}let o=s?global.BigInt:self.BigInt;const h=new TextDecoder("utf-8");class l{static from(e,t){return e instanceof this&&e.le===t?e:new l(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof l){let{byteOffset:s,byteLength:r}=e;if(void 0===i&&(i=r-t),(t+=s)+i>s+r)throw f("Creating view outside of available memory in ArrayBuffer");let n=new DataView(e.buffer,t,i);this._swapDataView(n)}else{if("number"!=typeof e)throw f("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=l){if(e instanceof DataView||e instanceof l?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw f("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new l(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return s=i,h.decode(s);var s}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(t)<<o(32)|o(i);throw f("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function u(e,t){throw f("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class d extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||u(this.kind,e),t&&(e in t||function(e,t){throw f("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||u(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var c=new d("file parser"),p=new d("segment parser"),g=new d("file reader");function w(e,i){if((r=e).startsWith("data:")||r.length>1e4)return y(e,i,"base64");if(t)return b(e,i,"url",m);if(s)return y(e,i,"fs");throw f("Invalid input argument");var r}async function b(e,t,i,s){if(g.has(i))return y(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw f("Parser ".concat(i," is not loaded"))}async function y(e,t,i){let s=new(g.get(i))(e,t);return await s.read(),s}async function m(e){return fetch(e).then(e=>e.arrayBuffer())}async function k(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}const v=Symbol("keys"),U=Symbol("values");class V extends Map{get tagKeys(){return this[v]||(this[v]=Array.from(this.keys())),this[v]}get tagValues(){return this[U]||(this[U]=Array.from(this.values())),this[U]}}function S(e,t,i){let s=new V(i);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function A(e,t,i){let s,r=e.get(t);for(s of i)r.set(s[0],s[1])}const B=new Map,F=new Map,O=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],z=["jfif","xmp","icc","iptc"],C=["tiff",...z],L=["ifd0","ifd1","exif","gps","interop"],x=[...C,...L],I=["makerNote","userComment"],D=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...D,"sanitize","mergeOutput"];class E{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class N extends E{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=L.includes(e),this.canBeFiltered&&(this.dict=B.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw f("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of D)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:r,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(s=n.indexOf(i),-1===s&&(s=r.indexOf(Number(i))),-1!==s&&t.add(Number(r[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,W(this.pick,this.deps)):this.enabled&&this.pick.size>0&&W(this.pick,this.deps)}}var P={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},_=new Map;class M extends E{static useCached(e){let t=_.get(e);return void 0!==t?t:(t=new this(e),_.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw f("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=t?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of T)this[e]=P[e];for(e of j)this[e]=P[e];for(e of I)this[e]=P[e];for(e of x)this[e]=new N(e,P[e],void 0,this)}setupFromTrue(){let e;for(e of T)this[e]=P[e];for(e of j)this[e]=P[e];for(e of I)this[e]=!0;for(e of x)this[e]=new N(e,!0,void 0,this)}setupFromArray(e){let t;for(t of T)this[t]=P[t];for(t of j)this[t]=P[t];for(t of I)this[t]=P[t];for(t of x)this[t]=new N(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,L)}setupFromObject(e){let t;for(t of(L.ifd0=L.ifd0||L.image,L.ifd1=L.ifd1||L.thumbnail,Object.assign(this,e),T))this[t]=G(e[t],P[t]);for(t of j)this[t]=G(e[t],P[t]);for(t of I)this[t]=G(e[t],P[t]);for(t of C)this[t]=new N(t,P[t],e[t],this);for(t of L)this[t]=new N(t,P[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,L,x),!0===e.tiff?this.batchEnableWithBool(L,!0):!1===e.tiff?this.batchEnableWithUserValue(L,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,L):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,L)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=K(e,i);for(let[e,i]of t)W(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=K(t,i);for(let[t,i]of e)W(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:r}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),r.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=L.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of L)this[e].finalizeFilters()}get onlyTiff(){return!z.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of C)this[e].enabled&&!p.has(e)&&u("segment parser",e)}}function K(e,t){let i,s,r,n,a=[];for(r of t){for(n of(i=B.get(r),s=[],i))(e.includes(n[0])||e.includes(n[1]))&&s.push(n[0]);s.length&&a.push([r,s])}return a}function G(e,t){return void 0!==e?e:void 0!==t?t:void 0}function W(e,t){for(let i of t)e.add(i)}r(M,"default",P);const J={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},H=Object.assign({},J,{firstChunkSize:4e4,gps:[1,2,3,4]}),R=Object.assign({},J,{firstChunkSize:4e4,ifd0:[274]});class q{constructor(e){r(this,"parsers",{}),this.options=M.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=c.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=c.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw f("Unknown file format");this.file.isHeic=!0,e=c.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,s){if("string"==typeof e)return w(e,s);if(t&&!i&&e instanceof HTMLImageElement)return w(e.src,s);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new l(e);if(t&&e instanceof Blob)return b(e,s,"blob",k);throw f("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=n(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=p.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),r=await s.extractThumbnail();return this.file.close&&this.file.close(),r}}async function Q(e,t){let i=new q(t);return await i.read(e),i.parse()}async function X(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new q(i);await s.read(t);let r=await s.extractThumbnail();return r&&e?Buffer.from(r):r}async function Y(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function Z(e){let t=new q(H);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}}async function $(e){let t=new q(R);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}export{q as Exifr,M as Options,j as allFormatters,T as chunkedProps,S as createDictionary,J as disableAllOptions,A as extendDictionary,m as fetchUrlAsArrayBuffer,c as fileParsers,g as fileReaders,Z as gps,H as gpsOnlyOptions,D as inheritables,$ as orientation,R as orientationOnlyOptions,z as otherSegments,Q as parse,k as readBlobAsArrayBuffer,p as segmentParsers,C as segments,x as segmentsAndBlocks,B as tagKeys,O as tagRevivers,F as tagValues,X as thumbnail,Y as thumbnailUrl,L as tiffBlocks,I as tiffExtractables};
var e="undefined"!=typeof Buffer,t="undefined"!=typeof navigator,i=t&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(e){return function(e){if(void 0===e)return!0;return e instanceof Map?0===e.size:0===Object.values(e).filter(a).length}(e)?void 0:e}const a=e=>void 0!==e;function f(e){let t=new Error(e);return delete t.stack,t}let o=s?global.BigInt:self.BigInt;const h=new TextDecoder("utf-8");class l{static from(e,t){return e instanceof this&&e.le===t?e:new l(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof l){let{byteOffset:s,byteLength:r}=e;if(void 0===i&&(i=r-t),(t+=s)+i>s+r)throw f("Creating view outside of available memory in ArrayBuffer");let n=new DataView(e.buffer,t,i);this._swapDataView(n)}else{if("number"!=typeof e)throw f("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=l){if(e instanceof DataView||e instanceof l?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw f("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new l(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return s=i,h.decode(s);var s}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(t)<<o(32)|o(i);throw f("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function u(e,t){throw f("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class d extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||u(this.kind,e),t&&(e in t||function(e,t){throw f("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||u(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var c=new d("file parser"),p=new d("segment parser"),g=new d("file reader");function w(e,i){if((r=e).startsWith("data:")||r.length>1e4)return b(e,i,"base64");if(t)return y(e,i,"url",m);if(s)return b(e,i,"fs");throw f("Invalid input argument");var r}async function y(e,t,i,s){if(g.has(i))return b(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw f("Parser ".concat(i," is not loaded"))}async function b(e,t,i){let s=new(g.get(i))(e,t);return await s.read(),s}async function m(e){return fetch(e).then(e=>e.arrayBuffer())}async function k(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}class v 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 V(e,t,i){let s=new v;for(let[e,t]of i)s.set(e,t);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function U(e,t,i){let s,r=e.get(t);for(s of i)r.set(s[0],s[1])}const S=new Map,A=new Map,B=new Map,F=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],O=["jfif","xmp","icc","iptc"],T=["tiff",...O],z=["ifd0","ifd1","exif","gps","interop"],C=[...T,...z],L=["makerNote","userComment"],x=["translateKeys","translateValues","reviveValues","multiSegment"],I=[...x,"sanitize","mergeOutput"];class D{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class j extends D{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=z.includes(e),this.canBeFiltered&&(this.dict=S.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw f("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of x)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:r,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(s=n.indexOf(i),-1===s&&(s=r.indexOf(Number(i))),-1!==s&&t.add(Number(r[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,M(this.pick,this.deps)):this.enabled&&this.pick.size>0&&M(this.pick,this.deps)}}var E={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},N=new Map;class P extends D{static useCached(e){let t=N.get(e);return void 0!==t?t:(t=new this(e),N.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw f("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=t?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of F)this[e]=E[e];for(e of I)this[e]=E[e];for(e of L)this[e]=E[e];for(e of C)this[e]=new j(e,E[e],void 0,this)}setupFromTrue(){let e;for(e of F)this[e]=E[e];for(e of I)this[e]=E[e];for(e of L)this[e]=!0;for(e of C)this[e]=new j(e,!0,void 0,this)}setupFromArray(e){let t;for(t of F)this[t]=E[t];for(t of I)this[t]=E[t];for(t of L)this[t]=E[t];for(t of C)this[t]=new j(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,z)}setupFromObject(e){let t;for(t of(z.ifd0=z.ifd0||z.image,z.ifd1=z.ifd1||z.thumbnail,Object.assign(this,e),F))this[t]=_(e[t],E[t]);for(t of I)this[t]=_(e[t],E[t]);for(t of L)this[t]=_(e[t],E[t]);for(t of T)this[t]=new j(t,E[t],e[t],this);for(t of z)this[t]=new j(t,E[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,z,C),!0===e.tiff?this.batchEnableWithBool(z,!0):!1===e.tiff?this.batchEnableWithUserValue(z,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,z):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,z)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=K(e,i);for(let[e,i]of t)M(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=K(t,i);for(let[t,i]of e)M(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:r}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),r.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=z.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of z)this[e].finalizeFilters()}get onlyTiff(){return!O.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of T)this[e].enabled&&!p.has(e)&&u("segment parser",e)}}function K(e,t){let i,s,r,n,a=[];for(r of t){for(n of(i=S.get(r),s=[],i))(e.includes(n[0])||e.includes(n[1]))&&s.push(n[0]);s.length&&a.push([r,s])}return a}function _(e,t){return void 0!==e?e:void 0!==t?t:void 0}function M(e,t){for(let i of t)e.add(i)}r(P,"default",E);const G={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},W=Object.assign({},G,{firstChunkSize:4e4,gps:[1,2,3,4]}),J=Object.assign({},G,{firstChunkSize:4e4,ifd0:[274]});class H{constructor(e){r(this,"parsers",{}),this.options=P.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=c.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=c.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw f("Unknown file format");this.file.isHeic=!0,e=c.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,s){if("string"==typeof e)return w(e,s);if(t&&!i&&e instanceof HTMLImageElement)return w(e.src,s);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new l(e);if(t&&e instanceof Blob)return y(e,s,"blob",k);throw f("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=n(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=p.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),r=await s.extractThumbnail();return this.file.close&&this.file.close(),r}}async function R(e,t){let i=new H(t);return await i.read(e),i.parse()}async function q(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new H(i);await s.read(t);let r=await s.extractThumbnail();return r&&e?Buffer.from(r):r}async function Q(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function X(e){let t=new H(W);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}}async function Y(e){let t=new H(J);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}export{H as Exifr,P as Options,I as allFormatters,F as chunkedProps,V as createDictionary,G as disableAllOptions,U as extendDictionary,m as fetchUrlAsArrayBuffer,c as fileParsers,g as fileReaders,X as gps,W as gpsOnlyOptions,x as inheritables,Y as orientation,J as orientationOnlyOptions,O as otherSegments,R as parse,k as readBlobAsArrayBuffer,p as segmentParsers,T as segments,C as segmentsAndBlocks,S as tagKeys,B as tagRevivers,A as tagValues,q as thumbnail,Q as thumbnailUrl,z as tiffBlocks,L as tiffExtractables};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";var t="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,r=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){return function(e){if(void 0===e)return!0;return e instanceof Map?0===e.size:0===Object.values(e).filter(f).length}(e)?void 0:e}const f=e=>void 0!==e;function o(e){let t=new Error(e);return delete t.stack,t}let h=r?global.BigInt:self.BigInt;const l=new TextDecoder("utf-8");class u{static from(e,t){return e instanceof this&&e.le===t?e:new u(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof u){let{byteOffset:s,byteLength:r}=e;if(void 0===i&&(i=r-t),(t+=s)+i>s+r)throw o("Creating view outside of available memory in ArrayBuffer");let n=new DataView(e.buffer,t,i);this._swapDataView(n)}else{if("number"!=typeof e)throw o("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=u){if(e instanceof DataView||e instanceof u?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw o("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new u(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return s=i,l.decode(s);var s}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof h)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),h(t)<<h(32)|h(i);throw o("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function d(e,t){throw o("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class c extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||d(this.kind,e),t&&(e in t||function(e,t){throw o("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||d(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var p=new c("file parser"),g=new c("segment parser"),w=new c("file reader");function y(e,t){if((s=e).startsWith("data:")||s.length>1e4)return m(e,t,"base64");if(i)return b(e,t,"url",k);if(r)return m(e,t,"fs");throw o("Invalid input argument");var s}async function b(e,t,i,s){if(w.has(i))return m(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw o("Parser ".concat(i," is not loaded"))}async function m(e,t,i){let s=new(w.get(i))(e,t);return await s.read(),s}async function k(e){return fetch(e).then(e=>e.arrayBuffer())}async function v(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}const U=Symbol("keys"),V=Symbol("values");class A extends Map{get tagKeys(){return this[U]||(this[U]=Array.from(this.keys())),this[U]}get tagValues(){return this[V]||(this[V]=Array.from(this.values())),this[V]}}const S=new Map,B=new Map,O=new Map,F=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],x=["jfif","xmp","icc","iptc"],T=["tiff",...x],z=["ifd0","ifd1","exif","gps","interop"],C=[...T,...z],D=["makerNote","userComment"],L=["translateKeys","translateValues","reviveValues","multiSegment"],I=[...L,"sanitize","mergeOutput"];class j{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class P extends j{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=z.includes(e),this.canBeFiltered&&(this.dict=S.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw o("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of L)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:r,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(s=n.indexOf(i),-1===s&&(s=r.indexOf(Number(i))),-1!==s&&t.add(Number(r[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,G(this.pick,this.deps)):this.enabled&&this.pick.size>0&&G(this.pick,this.deps)}}var E={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},_=new Map;class N extends j{static useCached(e){let t=_.get(e);return void 0!==t?t:(t=new this(e),_.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw o("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of F)this[e]=E[e];for(e of I)this[e]=E[e];for(e of D)this[e]=E[e];for(e of C)this[e]=new P(e,E[e],void 0,this)}setupFromTrue(){let e;for(e of F)this[e]=E[e];for(e of I)this[e]=E[e];for(e of D)this[e]=!0;for(e of C)this[e]=new P(e,!0,void 0,this)}setupFromArray(e){let t;for(t of F)this[t]=E[t];for(t of I)this[t]=E[t];for(t of D)this[t]=E[t];for(t of C)this[t]=new P(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,z)}setupFromObject(e){let t;for(t of(z.ifd0=z.ifd0||z.image,z.ifd1=z.ifd1||z.thumbnail,Object.assign(this,e),F))this[t]=K(e[t],E[t]);for(t of I)this[t]=K(e[t],E[t]);for(t of D)this[t]=K(e[t],E[t]);for(t of T)this[t]=new P(t,E[t],e[t],this);for(t of z)this[t]=new P(t,E[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,z,C),!0===e.tiff?this.batchEnableWithBool(z,!0):!1===e.tiff?this.batchEnableWithUserValue(z,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,z):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,z)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=M(e,i);for(let[e,i]of t)G(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=M(t,i);for(let[t,i]of e)G(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:r}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),r.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=z.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of z)this[e].finalizeFilters()}get onlyTiff(){return!x.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of T)this[e].enabled&&!g.has(e)&&d("segment parser",e)}}function M(e,t){let i,s,r,n,a=[];for(r of t){for(n of(i=S.get(r),s=[],i))(e.includes(n[0])||e.includes(n[1]))&&s.push(n[0]);s.length&&a.push([r,s])}return a}function K(e,t){return void 0!==e?e:void 0!==t?t:void 0}function G(e,t){for(let i of t)e.add(i)}n(N,"default",E);const R={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},W=Object.assign({},R,{firstChunkSize:4e4,gps:[1,2,3,4]}),J=Object.assign({},R,{firstChunkSize:4e4,ifd0:[274]});class H{constructor(e){n(this,"parsers",{}),this.options=N.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=p.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=p.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw o("Unknown file format");this.file.isHeic=!0,e=p.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,t){if("string"==typeof e)return y(e,t);if(i&&!s&&e instanceof HTMLImageElement)return y(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new u(e);if(i&&e instanceof Blob)return b(e,t,"blob",v);throw o("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=a(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=g.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),r=await s.extractThumbnail();return this.file.close&&this.file.close(),r}}e.Exifr=H,e.Options=N,e.allFormatters=I,e.chunkedProps=F,e.createDictionary=function(e,t,i){let s=new A(i);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s},e.disableAllOptions=R,e.extendDictionary=function(e,t,i){let s,r=e.get(t);for(s of i)r.set(s[0],s[1])},e.fetchUrlAsArrayBuffer=k,e.fileParsers=p,e.fileReaders=w,e.gps=async function(e){let t=new H(W);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}},e.gpsOnlyOptions=W,e.inheritables=L,e.orientation=async function(e){let t=new H(J);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]},e.orientationOnlyOptions=J,e.otherSegments=x,e.parse=async function(e,t){let i=new H(t);return await i.read(e),i.parse()},e.readBlobAsArrayBuffer=v,e.segmentParsers=g,e.segments=T,e.segmentsAndBlocks=C,e.tagKeys=S,e.tagRevivers=O,e.tagValues=B,e.thumbnail=async function(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new H(i);await s.read(e);let r=await s.extractThumbnail();return r&&t?Buffer.from(r):r},e.thumbnailUrl=async function(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}},e.tiffBlocks=z,e.tiffExtractables=D,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";var t="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,r=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){return function(e){if(void 0===e)return!0;return e instanceof Map?0===e.size:0===Object.values(e).filter(f).length}(e)?void 0:e}const f=e=>void 0!==e;function o(e){let t=new Error(e);return delete t.stack,t}let l=r?global.BigInt:self.BigInt;const h=new TextDecoder("utf-8");class u{static from(e,t){return e instanceof this&&e.le===t?e:new u(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof u){let{byteOffset:s,byteLength:r}=e;if(void 0===i&&(i=r-t),(t+=s)+i>s+r)throw o("Creating view outside of available memory in ArrayBuffer");let n=new DataView(e.buffer,t,i);this._swapDataView(n)}else{if("number"!=typeof e)throw o("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=u){if(e instanceof DataView||e instanceof u?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw o("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new u(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return s=i,h.decode(s);var s}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof l)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),l(t)<<l(32)|l(i);throw o("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function d(e,t){throw o("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class c extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||d(this.kind,e),t&&(e in t||function(e,t){throw o("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||d(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var p=new c("file parser"),g=new c("segment parser"),w=new c("file reader");function y(e,t){if((s=e).startsWith("data:")||s.length>1e4)return m(e,t,"base64");if(i)return b(e,t,"url",k);if(r)return m(e,t,"fs");throw o("Invalid input argument");var s}async function b(e,t,i,s){if(w.has(i))return m(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw o("Parser ".concat(i," is not loaded"))}async function m(e,t,i){let s=new(w.get(i))(e,t);return await s.read(),s}async function k(e){return fetch(e).then(e=>e.arrayBuffer())}async function v(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}class U 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}}const V=new Map,A=new Map,S=new Map,B=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],O=["jfif","xmp","icc","iptc"],F=["tiff",...O],x=["ifd0","ifd1","exif","gps","interop"],T=[...F,...x],z=["makerNote","userComment"],C=["translateKeys","translateValues","reviveValues","multiSegment"],D=[...C,"sanitize","mergeOutput"];class L{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class I extends L{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=x.includes(e),this.canBeFiltered&&(this.dict=V.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw o("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of C)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:r,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(s=n.indexOf(i),-1===s&&(s=r.indexOf(Number(i))),-1!==s&&t.add(Number(r[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,N(this.pick,this.deps)):this.enabled&&this.pick.size>0&&N(this.pick,this.deps)}}var j={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},P=new Map;class E extends L{static useCached(e){let t=P.get(e);return void 0!==t?t:(t=new this(e),P.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw o("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of B)this[e]=j[e];for(e of D)this[e]=j[e];for(e of z)this[e]=j[e];for(e of T)this[e]=new I(e,j[e],void 0,this)}setupFromTrue(){let e;for(e of B)this[e]=j[e];for(e of D)this[e]=j[e];for(e of z)this[e]=!0;for(e of T)this[e]=new I(e,!0,void 0,this)}setupFromArray(e){let t;for(t of B)this[t]=j[t];for(t of D)this[t]=j[t];for(t of z)this[t]=j[t];for(t of T)this[t]=new I(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,x)}setupFromObject(e){let t;for(t of(x.ifd0=x.ifd0||x.image,x.ifd1=x.ifd1||x.thumbnail,Object.assign(this,e),B))this[t]=K(e[t],j[t]);for(t of D)this[t]=K(e[t],j[t]);for(t of z)this[t]=K(e[t],j[t]);for(t of F)this[t]=new I(t,j[t],e[t],this);for(t of x)this[t]=new I(t,j[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,x,T),!0===e.tiff?this.batchEnableWithBool(x,!0):!1===e.tiff?this.batchEnableWithUserValue(x,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,x):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,x)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=_(e,i);for(let[e,i]of t)N(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=_(t,i);for(let[t,i]of e)N(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:r}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),r.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=x.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of x)this[e].finalizeFilters()}get onlyTiff(){return!O.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of F)this[e].enabled&&!g.has(e)&&d("segment parser",e)}}function _(e,t){let i,s,r,n,a=[];for(r of t){for(n of(i=V.get(r),s=[],i))(e.includes(n[0])||e.includes(n[1]))&&s.push(n[0]);s.length&&a.push([r,s])}return a}function K(e,t){return void 0!==e?e:void 0!==t?t:void 0}function N(e,t){for(let i of t)e.add(i)}n(E,"default",j);const M={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},G=Object.assign({},M,{firstChunkSize:4e4,gps:[1,2,3,4]}),R=Object.assign({},M,{firstChunkSize:4e4,ifd0:[274]});class W{constructor(e){n(this,"parsers",{}),this.options=E.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=p.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=p.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw o("Unknown file format");this.file.isHeic=!0,e=p.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,t){if("string"==typeof e)return y(e,t);if(i&&!s&&e instanceof HTMLImageElement)return y(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new u(e);if(i&&e instanceof Blob)return b(e,t,"blob",v);throw o("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=a(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=g.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),r=await s.extractThumbnail();return this.file.close&&this.file.close(),r}}e.Exifr=W,e.Options=E,e.allFormatters=D,e.chunkedProps=B,e.createDictionary=function(e,t,i){let s=new U;for(let[e,t]of i)s.set(e,t);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s},e.disableAllOptions=M,e.extendDictionary=function(e,t,i){let s,r=e.get(t);for(s of i)r.set(s[0],s[1])},e.fetchUrlAsArrayBuffer=k,e.fileParsers=p,e.fileReaders=w,e.gps=async function(e){let t=new W(G);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}},e.gpsOnlyOptions=G,e.inheritables=C,e.orientation=async function(e){let t=new W(R);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]},e.orientationOnlyOptions=R,e.otherSegments=O,e.parse=async function(e,t){let i=new W(t);return await i.read(e),i.parse()},e.readBlobAsArrayBuffer=v,e.segmentParsers=g,e.segments=F,e.segmentsAndBlocks=T,e.tagKeys=V,e.tagRevivers=S,e.tagValues=A,e.thumbnail=async function(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new W(i);await s.read(e);let r=await s.extractThumbnail();return r&&t?Buffer.from(r):r},e.thumbnailUrl=async function(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}},e.tiffBlocks=x,e.tiffExtractables=z,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,1 +0,1 @@

var e="undefined"!=typeof Buffer,t="undefined"!=typeof navigator,i=t&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function r(e){return h(e)?void 0:e}const a=e=>void 0!==e;function h(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(a).length)}function o(e){let t=new Error(e);return delete t.stack,t}function l(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function f(e){let t=function(e){let t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}let u=s?global.BigInt:self.BigInt;const d=new TextDecoder("utf-8");function c(e){return d.decode(e)}class g{static from(e,t){return e instanceof this&&e.le===t?e:new g(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof g){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw o("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else{if("number"!=typeof e)throw o("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=g){if(e instanceof DataView||e instanceof g?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw o("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new g(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){return c(this.getUint8Array(e,t))}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof u)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),u(t)<<u(32)|u(i);throw o("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function p(e,t){throw o("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class m extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||p(this.kind,e),t&&(e in t||function(e,t){throw o("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||p(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var y=new m("file parser"),b=new m("segment parser"),w=new m("file reader");function k(e,i){if((n=e).startsWith("data:")||n.length>1e4)return v(e,i,"base64");if(t)return S(e,i,"url",x);if(s)return v(e,i,"fs");throw o("Invalid input argument");var n}async function S(e,t,i,s){if(w.has(i))return v(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw o("Parser ".concat(i," is not loaded"))}async function v(e,t,i){let s=new(w.get(i))(e,t);return await s.read(),s}async function x(e){return fetch(e).then(e=>e.arrayBuffer())}async function O(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}const C=Symbol("keys"),I=Symbol("values");class A extends Map{get tagKeys(){return this[C]||(this[C]=Array.from(this.keys())),this[C]}get tagValues(){return this[I]||(this[I]=Array.from(this.values())),this[I]}}function U(e,t,i){let s=new A(i);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function P(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])}const B=new Map,F=new Map,L=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],D=["jfif","xmp","icc","iptc"],z=["tiff",...D],N=["ifd0","ifd1","exif","gps","interop"],V=[...z,...N],M=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...E,"sanitize","mergeOutput"];class G{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class R extends G{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=N.includes(e),this.canBeFiltered&&(this.dict=B.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw o("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of E)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of e)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&t.add(Number(n[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,J(this.pick,this.deps)):this.enabled&&this.pick.size>0&&J(this.pick,this.deps)}}var H={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},W=new Map;class _ extends G{static useCached(e){let t=W.get(e);return void 0!==t?t:(t=new this(e),W.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw o("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=t?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of T)this[e]=H[e];for(e of j)this[e]=H[e];for(e of M)this[e]=H[e];for(e of V)this[e]=new R(e,H[e],void 0,this)}setupFromTrue(){let e;for(e of T)this[e]=H[e];for(e of j)this[e]=H[e];for(e of M)this[e]=!0;for(e of V)this[e]=new R(e,!0,void 0,this)}setupFromArray(e){let t;for(t of T)this[t]=H[t];for(t of j)this[t]=H[t];for(t of M)this[t]=H[t];for(t of V)this[t]=new R(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,N)}setupFromObject(e){let t;for(t of(N.ifd0=N.ifd0||N.image,N.ifd1=N.ifd1||N.thumbnail,Object.assign(this,e),T))this[t]=X(e[t],H[t]);for(t of j)this[t]=X(e[t],H[t]);for(t of M)this[t]=X(e[t],H[t]);for(t of z)this[t]=new R(t,H[t],e[t],this);for(t of N)this[t]=new R(t,H[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,N,V),!0===e.tiff?this.batchEnableWithBool(N,!0):!1===e.tiff?this.batchEnableWithUserValue(N,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,N):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,N)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=K(e,i);for(let[e,i]of t)J(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=K(t,i);for(let[t,i]of e)J(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:n}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),n.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=N.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of N)this[e].finalizeFilters()}get onlyTiff(){return!D.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of z)this[e].enabled&&!b.has(e)&&p("segment parser",e)}}function K(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=B.get(n),s=[],i))(e.includes(r[0])||e.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function X(e,t){return void 0!==e?e:void 0!==t?t:void 0}function J(e,t){for(let i of t)e.add(i)}n(_,"default",H);const q={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Y=Object.assign({},q,{firstChunkSize:4e4,gps:[1,2,3,4]}),Z=Object.assign({},q,{firstChunkSize:4e4,ifd0:[274]});class Q{constructor(e){n(this,"parsers",{}),this.options=_.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=y.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=y.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw o("Unknown file format");this.file.isHeic=!0,e=y.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,s){if("string"==typeof e)return k(e,s);if(t&&!i&&e instanceof HTMLImageElement)return k(e.src,s);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new g(e);if(t&&e instanceof Blob)return S(e,s,"blob",O);throw o("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=r(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=b.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}async function $(e,t){let i=new Q(t);return await i.read(e),i.parse()}async function ee(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new Q(i);await s.read(t);let n=await s.extractThumbnail();return n&&e?Buffer.from(n):n}async function te(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function ie(e){let t=new Q(Y);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}}async function se(e){let t=new Q(Z);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}class ne extends g{constructor(...e){super(...e),n(this,"ranges",new re),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(e,t,i){if(0===e&&0===this.byteLength&&i){let e=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(e)}else{let i=e+t;if(i>this.byteLength){let{dataView:e}=this._extend(i);this._swapDataView(e)}}}_extend(t){let i;i=e?Buffer.allocUnsafe(t):new Uint8Array(t);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(e,t,i=!1){return t=t||this._lengthToEnd(e),i&&this._tryExtend(e,t),this.ranges.add(e,t),super.subarray(e,t)}set(e,t,i=!1){i&&this._tryExtend(t,e.byteLength,e);let s=super.set(e,t);return this.ranges.add(t,s.byteLength),s}async ensureChunk(e,t){this.chunked&&(this.ranges.available(e,t)||await this.readChunk(e,t))}available(e,t){return this.ranges.available(e,t)}}class re{constructor(e){n(this,"list",[]),void 0!==e&&Array.isArray(e)&&this.addMultiple(e)}get length(){return this.list.length}addMultiple(e){if(Array.isArray(e[0]))for(let[t,i]of e)this.add(t,i);else for(let{offset:t,length:i}of e)this.add(t,i)}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>ae(e,t.offset,s)||ae(e,t.end,s));if(n.length>0){e=Math.min(e,...n.map(e=>e.offset)),s=Math.max(s,...n.map(e=>e.end)),t=s-e;let i=n.shift();i.offset=e,i.length=t,i.end=s,this.list=this.list.filter(e=>!n.includes(e))}else this.list.push({offset:e,length:t,end:s})}available(e,t){let i=e+t;return this.list.some(t=>t.offset<=e&&i<=t.end)}}function ae(e,t,i){return e<=t&&t<=i}class he extends ne{constructor(e,t){super(0),n(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}w.set("blob",class extends he{async readWhole(){this.chunked=!1;let e=await O(this.input);this._swapArrayBuffer(e)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(e,t){let i=t?e+t:void 0,s=this.input.slice(e,i),n=await O(s);return this.set(n,e,!0)}});class oe{constructor(e,t,i){n(this,"ensureSegmentChunk",async e=>{let t=e.start,i=e.size||65536;if(this.file.chunked)if(this.file.available(t,i))e.chunk=this.file.subarray(t,i);else try{e.chunk=await this.file.readChunk(t,i)}catch(t){throw o("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}else if(this.file.byteLength>t+i)e.chunk=this.file.subarray(t,i);else{if(void 0!==e.size)throw o("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}createParser(e,t){let i=new(b.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class le{static findPosition(e,t){let i=e.getUint16(t+2)+2,s="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,n=t+s,r=i-s;return{offset:t,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(e,t={}){return new this(e,new _({[this.type]:t})).parse()}normalizeInput(e){return e instanceof g?e:new g(e)}constructor(e,t={},i){n(this,"errors",[]),n(this,"raw",new Map),n(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(e),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=t,this.localOptions=t[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(e,t){let i=L.get(t),s=F.get(t),n=B.get(t),r=this.options[t],a=r.reviveValues&&i,h=r.translateValues&&s,o=r.translateKeys&&n,l={};for(let[t,r]of e)a&&i.has(t)?r=i.get(t)(r):h&&s.has(t)&&(r=this.translateValue(r,s.get(t))),o&&n.has(t)&&(t=n.get(t)||t),l[t]=r;return l}translateValue(e,t){return t[e]||e}assignToOutput(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}assignObjectToOutput(e,t,i){if(this.globalOptions.mergeOutput)return Object.assign(e,i);e[t]?Object.assign(e[t],i):e[t]=i}}n(le,"headerLength",4),n(le,"type",void 0),n(le,"multiSegment",!1),n(le,"canHandle",()=>!1);function fe(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ue(e){return e>=224&&e<=239}function de(e,t){for(let[i,s]of b)if(s.canHandle(e,t))return i}y.set("jpeg",class extends oe{constructor(...e){super(...e),n(this,"appSegments",[]),n(this,"jpegSegments",[]),n(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let e=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(e)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(b.keyList())):(e=void 0===e?b.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&b.has(e)),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}async findAppSegments(e=0,t){this.setupSegmentFinderArgs(t);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let e of n){let t=b.get(e),i=this.options[e];if(t.multiSegment&&i.multiSegment){s=!0,this.file.chunked&&await this.file.readWhole();break}}if(e=this._findAppSegments(e,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let t=!1;for(;r.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(e=>!this.file.available(e.offset||e.start,e.length||e.size));if(t=e>s&&!n?!await i.readNextChunk(e):!await i.readNextChunk(s),void 0===(e=this._findAppSegments(e,i.byteLength)))return}}}_findAppSegments(e,t){let i,s,n,r,a,h,{file:o,findAll:l,wanted:f,remaining:u,options:d}=this;for(;e<t;e++)if(255===o.getUint8(e))if(i=o.getUint8(e+1),ue(i)){if(s=o.getUint16(e+2),n=de(o,e),n&&f.has(n)&&(r=b.get(n),a=r.findPosition(o,e),h=d[n],a.type=n,this.appSegments.push(a),!l&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=le.findPosition(o,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(fe(i)){if(s=o.getUint16(e+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:e,length:s,marker:i}),e+=s+1}return e}mergeMultiSegments(){if(!this.appSegments.some(e=>e.multiSegment))return;let e=function(e,t){let i,s,n,r=new Map;for(let a=0;a<e.length;a++)i=e[a],s=i[t],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r.entries())}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=b.get(e,this.options);if(i.handleMultiSegments){return{type:e,chunk:i.handleMultiSegments(t)}}return t[0]})}async createParsers(){let e=this.mergedAppSegments||this.appSegments;for(let t of e){let{type:e,chunk:i}=t;if(!this.options[e].enabled)continue;let s=this.parsers[e];if(s&&s.append);else if(!s){let t=new(b.get(e,this.options))(i,this.options,this.file);this.parsers[e]=t}}}getSegment(e){return this.appSegments.find(t=>t.type===e)}async getOrFindSegment(e){let t=this.getSegment(e);return void 0===t&&(await this.findAppSegments(0,[e]),t=this.getSegment(e)),t}});const ce=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ge extends le{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw o("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw o("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:s,skip:n}=this.options[t];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(e);e+=2;for(let o=0;o<h;o++){let h=this.chunk.getUint16(e);if(r){if(s.has(h)&&(i.set(h,this.parseTag(e,h,t)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(e,h,t));e+=12}return i}parseTag(e,t,i){let s=this.chunk.getUint16(e+2),n=this.chunk.getUint32(e+4),r=ce[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw o("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e));if(e>this.chunk.byteLength)throw o("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(e,n);if(2===s)return l(this.chunk.getString(e,n));if(7===s)return this.chunk.getUint8Array(e,n);if(1===n)return this.parseTagValue(s,e);{let t=new(function(e){switch(e){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}}(s))(n),i=r;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw o("Invalid tiff type ".concat(e))}}}class pe extends ge{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}parseBlock(e,t){let i=new Map;return this[t]=i,this.parseTags(e,t,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw o("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw o("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,f(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==e.size?(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 ensureBlockChunk(e,t){this.file.isTiff&&await this.file.ensureChunk(e,t),e>this.chunk.byteLength&&(this.chunk=g.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,f(this.options));let e=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=e.get(40965)),this.makerNote=e.get(37500),this.userComment=e.get(37510),this.options.sanitize&&(e.delete(40965),e.delete(37500),e.delete(37510)),this.unpack(e,41728),this.unpack(e,41729),e}unpack(e,t){let i=e.get(t);i&&1===i.length&&e.set(t,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let e=this.parseBlock(this.gpsOffset,"gps");return e&&e.has(2)&&e.has(4)&&(e.set("latitude",me(...e.get(2),e.get(1))),e.set("longitude",me(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(e=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||e))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),void 0===this.ifd1)return;let e=this.ifd1.get(513),t=this.ifd1.get(514);return this.chunk.getUint8Array(e,t)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let e,t,i,s={};for(t of N)if(e=this[t],!h(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(s,i)}else s[t]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(let[i,s]of Object.entries(t))this.assignObjectToOutput(e,i,s)}}function me(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}n(pe,"type","tiff"),n(pe,"headerLength",10),b.set("tiff",pe);w.set("url",class extends he{async readWhole(){this.chunked=!1;let e=await x(this.input);this._swapArrayBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,s={};(e||i)&&(s.range="bytes=".concat([e,i].join("-")));let n=await fetch(this.input,{headers:s}),r=await n.arrayBuffer(),a=r.byteLength;if(416!==n.status)return a!==t&&(this.size=e+a),this.set(r,e,!0)}});class ye extends oe{parseBoxes(e=0){let t=[];for(;e<this.file.byteLength-4;){let i=this.parseBoxHead(e);if(t.push(i),0===i.length)break;e+=i.length}return t}parseSubBoxes(e){e.boxes=this.parseBoxes(e.start)}findBox(e,t){return void 0===e.boxes&&this.parseSubBoxes(e),e.boxes.find(e=>e.kind===t)}parseBoxHead(e){let t=this.file.getUint32(e),i=this.file.getString(e+4,4),s=e+8;return 1===t&&(t=this.file.getUint64(e+8),s+=8),{offset:e,length:t,kind:i,start:s}}parseBoxFullHead(e){let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}y.set("heic",class extends ye{async parse(){var e=this.file.getUint32(0);let t=this.parseBoxHead(e);await this.file.ensureChunk(t.offset,t.length),this.parseBoxFullHead(t),this.parseSubBoxes(t),this.options.icc.enabled&&await this.findIcc(t),this.options.tiff.enabled&&await this.findExif(t)}async registerSegment(e,t,i){await this.file.ensureChunk(t,i);let s=this.file.subarray(t,i);this.createParser(e,s)}async findIcc(e){let t=this.findBox(e,"iprp");if(void 0===t)return;let i=this.findBox(t,"ipco");if(void 0===i)return;let s=this.findBox(i,"colr");void 0!==s&&await this.registerSegment("icc",s.offset+12,s.length)}async findExif(e){let t=this.findBox(e,"iinf");if(void 0===t)return;let i=this.findBox(e,"iloc");if(void 0===i)return;let s=this.findExifLocIdInIinf(t),n=this.findExtentInIloc(i,s);if(void 0===n)return;let[r,a]=n;await this.file.ensureChunk(r,a);let h=4+this.file.getUint32(r);r+=h,a-=h,await this.registerSegment("tiff",r,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,s,n,r=e.start,a=this.file.getUint16(r);for(r+=2;a--;){if(t=this.parseBoxHead(r),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(s=3===t.version?4:2,n=this.file.getString(i+s+2,4),"Exif"===n))return this.file.getUintBytes(i,s);r+=t.length}}get8bits(e){let t=this.file.getUint8(e);return[t>>4,15&t]}findExtentInIloc(e,t){this.parseBoxFullHead(e);let i=e.start,[s,n]=this.get8bits(i++),[r,a]=this.get8bits(i++),h=2===e.version?4:2,o=1===e.version||2===e.version?2:0,l=a+s+n,f=2===e.version?4:2,u=this.file.getUintBytes(i,f);for(i+=f;u--;){let e=this.file.getUintBytes(i,h);i+=h+o+2+r;let f=this.file.getUint16(i);if(i+=2,e===t)return f>1&&console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"),[this.file.getUintBytes(i+a,s),this.file.getUintBytes(i+a+s,n)];i+=f*l}}}),U(B,["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"]]),U(B,"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"]]),U(B,"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"]]),U(F,["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"}]]);let be=U(F,"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"}]]);const we={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};be.set(37392,we),be.set(41488,we);const ke={0:"Normal",1:"Low",2:"High"};function Se(e){let t=Array.from(e).slice(1);return t[1]>15&&(t=t.map(e=>String.fromCharCode(e))),"0"!==t[2]&&0!==t[2]||t.pop(),t.join(".")}function ve(e){if("string"==typeof e){var[t,i,s,n,r,a]=e.trim().split(/[-: ]/g).map(Number),h=new Date(t,i-1,s);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(h.setHours(n),h.setMinutes(r),h.setSeconds(a)),Number.isNaN(+h)?e:h}}function xe(e){if("string"==typeof e)return e;let t=[];if(0===e[1]&&0===e[e.length-1])for(let i=0;i<e.length;i+=2)t.push(Oe(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(Oe(e[i],e[i+1]));return l(String.fromCodePoint(...t))}function Oe(e,t){return e<<8|t}be.set(41992,ke),be.set(41993,ke),be.set(41994,ke),U(L,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?c(e):e}],[306,ve],[40091,xe],[40092,xe],[40093,xe],[40094,xe],[40095,xe]]),U(L,"exif",[[40960,Se],[36864,Se],[36867,ve],[36868,ve]]),U(L,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class Ce extends le{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)&&"http://ns.adobe.com/"===e.getString(t+4,"http://ns.adobe.com/".length)}static headerLength(e,t){return"http://ns.adobe.com/xmp/extension/"===e.getString(t+4,"http://ns.adobe.com/xmp/extension/".length)?79:4+"http://ns.adobe.com/xap/1.0/".length+1}static findPosition(e,t){let i=super.findPosition(e,t);return i.multiSegment=i.extended=79===i.headerLength,i.multiSegment?(i.chunkCount=e.getUint8(t+72),i.chunkNumber=e.getUint8(t+76),0!==e.getUint8(t+77)&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(e){return e.map(e=>e.chunk.getString()).join("")}normalizeInput(e){return"string"==typeof e?e:e.getString&&e.getString()}parse(e=this.chunk){if(!this.localOptions.parse)return e;e=function(e){let t={"rdf:li":1,"rdf:Seq":1,"rdf:Bag":1,"rdf:Alt":1};return e.replace(De,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=Ae.findAll(e,"rdf","Description");0===t.length&&t.push(new Ae("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=Fe(t.ns,s),Ue(t,i);return function(e){let t;for(let i of Object.keys(e))t=e[i]=r(e[i]),void 0===t&&delete e[i];return r(e)}(s)}assignToOutput(e,t){if(this.localOptions.parse)for(let[i,s]of Object.entries(t))switch(i){case"tiff":this.assignObjectToOutput(e,"ifd0",s);break;case"exif":this.assignObjectToOutput(e,"exif",s);break;case"xmlns":break;default:this.assignObjectToOutput(e,i,s)}else e.xmp=t}}n(Ce,"type","xmp"),n(Ce,"multiSegment",!0),b.set("xmp",Ce);class Ie{static findAll(e){return Le(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(Ie.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[3].slice(1,-1);return s=Te(s),new Ie(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class Ae{static findAll(e,t,i){if(void 0!==t||void 0!==i){t=t||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var s=new RegExp("<(".concat(t,"):(").concat(i,")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"),"gm")}else s=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return Le(e,s).map(Ae.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new Ae(t,i,s,n)}constructor(e,t,i,s){this.ns=e,this.name=t,this.attrString=i,this.innerXml=s,this.attrs=Ie.findAll(i),this.children=Ae.findAll(s),this.value=0===this.children.length?Te(s):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return void 0!==this.value&&0===this.attrs.length&&0===this.children.length}get isListContainer(){return 1===this.children.length&&this.children[0].isList}get isList(){let{ns:e,name:t}=this;return"rdf"===e&&("Seq"===t||"Bag"===t||"Alt"===t)}get isListItem(){return"rdf"===this.ns&&"li"===this.name}serialize(){if(0===this.properties.length&&void 0===this.value)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return Be(this.children.map(Pe));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Ue(t,e);return void 0!==this.value&&(e.value=this.value),r(e)}}function Ue(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var Pe=e=>e.serialize(),Be=e=>1===e.length?e[0]:e,Fe=(e,t)=>t[e]?t[e]:t[e]={};function Le(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Te(e){if(function(e){return null==e||"null"===e||"undefined"===e||""===e||""===e.trim()}(e))return;let t=Number(e);if(!Number.isNaN(t))return t;let i=e.toLowerCase();return"true"===i||"false"!==i&&e.trim()}const De=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;export{Q as Exifr,_ as Options,j as allFormatters,T as chunkedProps,U as createDictionary,q as disableAllOptions,P as extendDictionary,x as fetchUrlAsArrayBuffer,y as fileParsers,w as fileReaders,ie as gps,Y as gpsOnlyOptions,E as inheritables,se as orientation,Z as orientationOnlyOptions,D as otherSegments,$ as parse,O as readBlobAsArrayBuffer,b as segmentParsers,z as segments,V as segmentsAndBlocks,B as tagKeys,L as tagRevivers,F as tagValues,ee as thumbnail,te as thumbnailUrl,N as tiffBlocks,M as tiffExtractables};
var e="undefined"!=typeof Buffer,t="undefined"!=typeof navigator,i=t&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function r(e){return h(e)?void 0:e}const a=e=>void 0!==e;function h(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(a).length)}function o(e){let t=new Error(e);return delete t.stack,t}function l(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function f(e){let t=function(e){let t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}let u=s?global.BigInt:self.BigInt;const d=new TextDecoder("utf-8");function c(e){return d.decode(e)}class g{static from(e,t){return e instanceof this&&e.le===t?e:new g(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof g){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw o("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else{if("number"!=typeof e)throw o("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=g){if(e instanceof DataView||e instanceof g?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw o("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new g(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){return c(this.getUint8Array(e,t))}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof u)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),u(t)<<u(32)|u(i);throw o("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function p(e,t){throw o("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class m extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||p(this.kind,e),t&&(e in t||function(e,t){throw o("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||p(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var y=new m("file parser"),b=new m("segment parser"),w=new m("file reader");function k(e,i){if((n=e).startsWith("data:")||n.length>1e4)return v(e,i,"base64");if(t)return S(e,i,"url",x);if(s)return v(e,i,"fs");throw o("Invalid input argument");var n}async function S(e,t,i,s){if(w.has(i))return v(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw o("Parser ".concat(i," is not loaded"))}async function v(e,t,i){let s=new(w.get(i))(e,t);return await s.read(),s}async function x(e){return fetch(e).then(e=>e.arrayBuffer())}async function C(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}class O 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 I(e,t,i){let s=new O;for(let[e,t]of i)s.set(e,t);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function U(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])}const A=new Map,P=new Map,B=new Map,F=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],L=["jfif","xmp","icc","iptc"],T=["tiff",...L],D=["ifd0","ifd1","exif","gps","interop"],V=[...T,...D],z=["makerNote","userComment"],N=["translateKeys","translateValues","reviveValues","multiSegment"],M=[...N,"sanitize","mergeOutput"];class E{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class G extends E{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=D.includes(e),this.canBeFiltered&&(this.dict=A.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw o("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of N)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of e)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&t.add(Number(n[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,K(this.pick,this.deps)):this.enabled&&this.pick.size>0&&K(this.pick,this.deps)}}var R={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},j=new Map;class H extends E{static useCached(e){let t=j.get(e);return void 0!==t?t:(t=new this(e),j.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw o("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=t?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of F)this[e]=R[e];for(e of M)this[e]=R[e];for(e of z)this[e]=R[e];for(e of V)this[e]=new G(e,R[e],void 0,this)}setupFromTrue(){let e;for(e of F)this[e]=R[e];for(e of M)this[e]=R[e];for(e of z)this[e]=!0;for(e of V)this[e]=new G(e,!0,void 0,this)}setupFromArray(e){let t;for(t of F)this[t]=R[t];for(t of M)this[t]=R[t];for(t of z)this[t]=R[t];for(t of V)this[t]=new G(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,D)}setupFromObject(e){let t;for(t of(D.ifd0=D.ifd0||D.image,D.ifd1=D.ifd1||D.thumbnail,Object.assign(this,e),F))this[t]=_(e[t],R[t]);for(t of M)this[t]=_(e[t],R[t]);for(t of z)this[t]=_(e[t],R[t]);for(t of T)this[t]=new G(t,R[t],e[t],this);for(t of D)this[t]=new G(t,R[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,D,V),!0===e.tiff?this.batchEnableWithBool(D,!0):!1===e.tiff?this.batchEnableWithUserValue(D,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,D):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,D)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=W(e,i);for(let[e,i]of t)K(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=W(t,i);for(let[t,i]of e)K(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:n}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),n.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=D.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of D)this[e].finalizeFilters()}get onlyTiff(){return!L.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of T)this[e].enabled&&!b.has(e)&&p("segment parser",e)}}function W(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=A.get(n),s=[],i))(e.includes(r[0])||e.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function _(e,t){return void 0!==e?e:void 0!==t?t:void 0}function K(e,t){for(let i of t)e.add(i)}n(H,"default",R);const X={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},J=Object.assign({},X,{firstChunkSize:4e4,gps:[1,2,3,4]}),q=Object.assign({},X,{firstChunkSize:4e4,ifd0:[274]});class Y{constructor(e){n(this,"parsers",{}),this.options=H.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=y.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=y.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw o("Unknown file format");this.file.isHeic=!0,e=y.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,s){if("string"==typeof e)return k(e,s);if(t&&!i&&e instanceof HTMLImageElement)return k(e.src,s);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new g(e);if(t&&e instanceof Blob)return S(e,s,"blob",C);throw o("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=r(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=b.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}async function Z(e,t){let i=new Y(t);return await i.read(e),i.parse()}async function Q(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new Y(i);await s.read(t);let n=await s.extractThumbnail();return n&&e?Buffer.from(n):n}async function $(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function ee(e){let t=new Y(J);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}}async function te(e){let t=new Y(q);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}class ie extends g{constructor(...e){super(...e),n(this,"ranges",new se),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(e,t,i){if(0===e&&0===this.byteLength&&i){let e=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(e)}else{let i=e+t;if(i>this.byteLength){let{dataView:e}=this._extend(i);this._swapDataView(e)}}}_extend(t){let i;i=e?Buffer.allocUnsafe(t):new Uint8Array(t);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(e,t,i=!1){return t=t||this._lengthToEnd(e),i&&this._tryExtend(e,t),this.ranges.add(e,t),super.subarray(e,t)}set(e,t,i=!1){i&&this._tryExtend(t,e.byteLength,e);let s=super.set(e,t);return this.ranges.add(t,s.byteLength),s}async ensureChunk(e,t){this.chunked&&(this.ranges.available(e,t)||await this.readChunk(e,t))}available(e,t){return this.ranges.available(e,t)}}class se{constructor(){n(this,"list",[])}get length(){return this.list.length}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>ne(e,t.offset,s)||ne(e,t.end,s));if(n.length>0){e=Math.min(e,...n.map(e=>e.offset)),s=Math.max(s,...n.map(e=>e.end)),t=s-e;let i=n.shift();i.offset=e,i.length=t,i.end=s,this.list=this.list.filter(e=>!n.includes(e))}else this.list.push({offset:e,length:t,end:s})}available(e,t){let i=e+t;return this.list.some(t=>t.offset<=e&&i<=t.end)}}function ne(e,t,i){return e<=t&&t<=i}class re extends ie{constructor(e,t){super(0),n(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}w.set("blob",class extends re{async readWhole(){this.chunked=!1;let e=await C(this.input);this._swapArrayBuffer(e)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(e,t){let i=t?e+t:void 0,s=this.input.slice(e,i),n=await C(s);return this.set(n,e,!0)}});class ae{constructor(e,t,i){n(this,"ensureSegmentChunk",async e=>{let t=e.start,i=e.size||65536;if(this.file.chunked)if(this.file.available(t,i))e.chunk=this.file.subarray(t,i);else try{e.chunk=await this.file.readChunk(t,i)}catch(t){throw o("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}else if(this.file.byteLength>t+i)e.chunk=this.file.subarray(t,i);else{if(void 0!==e.size)throw o("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}createParser(e,t){let i=new(b.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class he{static findPosition(e,t){let i=e.getUint16(t+2)+2,s="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,n=t+s,r=i-s;return{offset:t,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(e,t={}){return new this(e,new H({[this.type]:t})).parse()}normalizeInput(e){return e instanceof g?e:new g(e)}constructor(e,t={},i){n(this,"errors",[]),n(this,"raw",new Map),n(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(e),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=t,this.localOptions=t[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(e,t){let i=B.get(t),s=P.get(t),n=A.get(t),r=this.options[t],a=r.reviveValues&&!!i,h=r.translateValues&&!!s,o=r.translateKeys&&!!n,l={};for(let[t,r]of e)a&&i.has(t)?r=i.get(t)(r):h&&s.has(t)&&(r=this.translateValue(r,s.get(t))),o&&n.has(t)&&(t=n.get(t)||t),l[t]=r;return l}translateValue(e,t){return t[e]||e}assignToOutput(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}assignObjectToOutput(e,t,i){if(this.globalOptions.mergeOutput)return Object.assign(e,i);e[t]?Object.assign(e[t],i):e[t]=i}}n(he,"headerLength",4),n(he,"type",void 0),n(he,"multiSegment",!1),n(he,"canHandle",()=>!1);function oe(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function le(e){return e>=224&&e<=239}function fe(e,t){for(let[i,s]of b)if(s.canHandle(e,t))return i}y.set("jpeg",class extends ae{constructor(...e){super(...e),n(this,"appSegments",[]),n(this,"jpegSegments",[]),n(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let e=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(e)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(b.keyList())):(e=void 0===e?b.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&b.has(e)),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}async findAppSegments(e=0,t){this.setupSegmentFinderArgs(t);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s&&this.file.chunked&&(s=Array.from(n).some(e=>{let t=b.get(e),i=this.options[e];return t.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),e=this._findAppSegments(e,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let t=!1;for(;r.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(e=>!this.file.available(e.offset||e.start,e.length||e.size));if(t=e>s&&!n?!await i.readNextChunk(e):!await i.readNextChunk(s),void 0===(e=this._findAppSegments(e,i.byteLength)))return}}}_findAppSegments(e,t){let i,s,n,r,a,h,{file:o,findAll:l,wanted:f,remaining:u,options:d}=this;for(;e<t;e++)if(255===o.getUint8(e))if(i=o.getUint8(e+1),le(i)){if(s=o.getUint16(e+2),n=fe(o,e),n&&f.has(n)&&(r=b.get(n),a=r.findPosition(o,e),h=d[n],a.type=n,this.appSegments.push(a),!l&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=he.findPosition(o,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(oe(i)){if(s=o.getUint16(e+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:e,length:s,marker:i}),e+=s+1}return e}mergeMultiSegments(){if(!this.appSegments.some(e=>e.multiSegment))return;let e=function(e,t){let i,s,n,r=new Map;for(let a=0;a<e.length;a++)i=e[a],s=i[t],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r)}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=b.get(e,this.options);if(i.handleMultiSegments){return{type:e,chunk:i.handleMultiSegments(t)}}return t[0]})}async createParsers(){let e=this.mergedAppSegments||this.appSegments;for(let t of e){let{type:e,chunk:i}=t;if(!this.options[e].enabled)continue;let s=this.parsers[e];if(s&&s.append);else if(!s){let t=new(b.get(e,this.options))(i,this.options,this.file);this.parsers[e]=t}}}getSegment(e){return this.appSegments.find(t=>t.type===e)}async getOrFindSegment(e){let t=this.getSegment(e);return void 0===t&&(await this.findAppSegments(0,[e]),t=this.getSegment(e)),t}});const ue=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class de extends he{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw o("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw o("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:s,skip:n}=this.options[t];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(e);e+=2;for(let o=0;o<h;o++){let h=this.chunk.getUint16(e);if(r){if(s.has(h)&&(i.set(h,this.parseTag(e,h,t)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(e,h,t));e+=12}return i}parseTag(e,t,i){let s=this.chunk.getUint16(e+2),n=this.chunk.getUint32(e+4),r=ue[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw o("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e));if(e>this.chunk.byteLength)throw o("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(e,n);if(2===s)return l(this.chunk.getString(e,n));if(7===s)return this.chunk.getUint8Array(e,n);if(1===n)return this.parseTagValue(s,e);{let t=new(function(e){switch(e){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}}(s))(n),i=r;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw o("Invalid tiff type ".concat(e))}}}class ce extends de{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(e){try{return await this[e]()}catch(e){this.handleError(e)}}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}parseBlock(e,t){let i=new Map;return this[t]=i,this.parseTags(e,t,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw o("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw o("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,f(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==e.size?(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 ensureBlockChunk(e,t){this.file.isTiff&&await this.file.ensureChunk(e,t),e>this.chunk.byteLength&&(this.chunk=g.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,f(this.options));let e=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=e.get(40965)),this.makerNote=e.get(37500),this.userComment=e.get(37510),this.options.sanitize&&(e.delete(40965),e.delete(37500),e.delete(37510)),this.unpack(e,41728),this.unpack(e,41729),e}unpack(e,t){let i=e.get(t);i&&1===i.length&&e.set(t,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let e=this.parseBlock(this.gpsOffset,"gps");return e&&e.has(2)&&e.has(4)&&(e.set("latitude",ge(...e.get(2),e.get(1))),e.set("longitude",ge(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(e=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||e))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),void 0===this.ifd1)return;let e=this.ifd1.get(513),t=this.ifd1.get(514);return this.chunk.getUint8Array(e,t)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let e,t,i,s={};for(t of D)if(e=this[t],!h(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(s,i)}else s[t]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(let[i,s]of Object.entries(t))this.assignObjectToOutput(e,i,s)}}function ge(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}n(ce,"type","tiff"),n(ce,"headerLength",10),b.set("tiff",ce);w.set("url",class extends re{async readWhole(){this.chunked=!1;let e=await x(this.input);this._swapArrayBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,s={};(e||i)&&(s.range="bytes=".concat([e,i].join("-")));let n=await fetch(this.input,{headers:s}),r=await n.arrayBuffer(),a=r.byteLength;if(416!==n.status)return a!==t&&(this.size=e+a),this.set(r,e,!0)}});class pe extends ae{parseBoxes(e=0){let t=[];for(;e<this.file.byteLength-4;){let i=this.parseBoxHead(e);if(t.push(i),0===i.length)break;e+=i.length}return t}parseSubBoxes(e){e.boxes=this.parseBoxes(e.start)}findBox(e,t){return void 0===e.boxes&&this.parseSubBoxes(e),e.boxes.find(e=>e.kind===t)}parseBoxHead(e){let t=this.file.getUint32(e),i=this.file.getString(e+4,4),s=e+8;return 1===t&&(t=this.file.getUint64(e+8),s+=8),{offset:e,length:t,kind:i,start:s}}parseBoxFullHead(e){let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}y.set("heic",class extends pe{async parse(){var e=this.file.getUint32(0);let t=this.parseBoxHead(e);await this.file.ensureChunk(t.offset,t.length),this.parseBoxFullHead(t),this.parseSubBoxes(t),this.options.icc.enabled&&await this.findIcc(t),this.options.tiff.enabled&&await this.findExif(t)}async registerSegment(e,t,i){await this.file.ensureChunk(t,i);let s=this.file.subarray(t,i);this.createParser(e,s)}async findIcc(e){let t=this.findBox(e,"iprp");if(void 0===t)return;let i=this.findBox(t,"ipco");if(void 0===i)return;let s=this.findBox(i,"colr");void 0!==s&&await this.registerSegment("icc",s.offset+12,s.length)}async findExif(e){let t=this.findBox(e,"iinf");if(void 0===t)return;let i=this.findBox(e,"iloc");if(void 0===i)return;let s=this.findExifLocIdInIinf(t),n=this.findExtentInIloc(i,s);if(void 0===n)return;let[r,a]=n;await this.file.ensureChunk(r,a);let h=4+this.file.getUint32(r);r+=h,a-=h,await this.registerSegment("tiff",r,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,s,n,r=e.start,a=this.file.getUint16(r);for(r+=2;a--;){if(t=this.parseBoxHead(r),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(s=3===t.version?4:2,n=this.file.getString(i+s+2,4),"Exif"===n))return this.file.getUintBytes(i,s);r+=t.length}}get8bits(e){let t=this.file.getUint8(e);return[t>>4,15&t]}findExtentInIloc(e,t){this.parseBoxFullHead(e);let i=e.start,[s,n]=this.get8bits(i++),[r,a]=this.get8bits(i++),h=2===e.version?4:2,o=1===e.version||2===e.version?2:0,l=a+s+n,f=2===e.version?4:2,u=this.file.getUintBytes(i,f);for(i+=f;u--;){let e=this.file.getUintBytes(i,h);i+=h+o+2+r;let f=this.file.getUint16(i);if(i+=2,e===t)return f>1&&console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"),[this.file.getUintBytes(i+a,s),this.file.getUintBytes(i+a+s,n)];i+=f*l}}}),I(A,["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"]]),I(A,"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"]]),I(A,"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"]]),I(P,["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"}]]);let me=I(P,"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"}]]);const ye={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};me.set(37392,ye),me.set(41488,ye);const be={0:"Normal",1:"Low",2:"High"};function we(e){let t=Array.from(e).slice(1);return t[1]>15&&(t=t.map(e=>String.fromCharCode(e))),"0"!==t[2]&&0!==t[2]||t.pop(),t.join(".")}function ke(e){if("string"==typeof e){var[t,i,s,n,r,a]=e.trim().split(/[-: ]/g).map(Number),h=new Date(t,i-1,s);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(h.setHours(n),h.setMinutes(r),h.setSeconds(a)),Number.isNaN(+h)?e:h}}function Se(e){if("string"==typeof e)return e;let t=[];if(0===e[1]&&0===e[e.length-1])for(let i=0;i<e.length;i+=2)t.push(ve(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(ve(e[i],e[i+1]));return l(String.fromCodePoint(...t))}function ve(e,t){return e<<8|t}me.set(41992,be),me.set(41993,be),me.set(41994,be),I(B,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?c(e):e}],[306,ke],[40091,Se],[40092,Se],[40093,Se],[40094,Se],[40095,Se]]),I(B,"exif",[[40960,we],[36864,we],[36867,ke],[36868,ke]]),I(B,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class xe extends he{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)&&"http://ns.adobe.com/"===e.getString(t+4,"http://ns.adobe.com/".length)}static headerLength(e,t){return"http://ns.adobe.com/xmp/extension/"===e.getString(t+4,"http://ns.adobe.com/xmp/extension/".length)?79:4+"http://ns.adobe.com/xap/1.0/".length+1}static findPosition(e,t){let i=super.findPosition(e,t);return i.multiSegment=i.extended=79===i.headerLength,i.multiSegment?(i.chunkCount=e.getUint8(t+72),i.chunkNumber=e.getUint8(t+76),0!==e.getUint8(t+77)&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(e){return e.map(e=>e.chunk.getString()).join("")}normalizeInput(e){return"string"==typeof e?e:e.getString&&e.getString()}parse(e=this.chunk){if(!this.localOptions.parse)return e;e=function(e){let t={"rdf:li":1,"rdf:Seq":1,"rdf:Bag":1,"rdf:Alt":1};return e.replace(Le,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=Oe.findAll(e,"rdf","Description");0===t.length&&t.push(new Oe("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=Pe(t.ns,s),Ie(t,i);return function(e){let t;for(let i in e)t=e[i]=r(e[i]),void 0===t&&delete e[i];return r(e)}(s)}assignToOutput(e,t){if(this.localOptions.parse)for(let[i,s]of Object.entries(t))switch(i){case"tiff":this.assignObjectToOutput(e,"ifd0",s);break;case"exif":this.assignObjectToOutput(e,"exif",s);break;case"xmlns":break;default:this.assignObjectToOutput(e,i,s)}else e.xmp=t}}n(xe,"type","xmp"),n(xe,"multiSegment",!0),b.set("xmp",xe);class Ce{static findAll(e){return Be(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(Ce.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[3].slice(1,-1);return s=Fe(s),new Ce(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class Oe{static findAll(e,t,i){if(void 0!==t||void 0!==i){t=t||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var s=new RegExp("<(".concat(t,"):(").concat(i,")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"),"gm")}else s=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return Be(e,s).map(Oe.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new Oe(t,i,s,n)}constructor(e,t,i,s){this.ns=e,this.name=t,this.attrString=i,this.innerXml=s,this.attrs=Ce.findAll(i),this.children=Oe.findAll(s),this.value=0===this.children.length?Fe(s):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return void 0!==this.value&&0===this.attrs.length&&0===this.children.length}get isListContainer(){return 1===this.children.length&&this.children[0].isList}get isList(){let{ns:e,name:t}=this;return"rdf"===e&&("Seq"===t||"Bag"===t||"Alt"===t)}get isListItem(){return"rdf"===this.ns&&"li"===this.name}serialize(){if(0===this.properties.length&&void 0===this.value)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return Ae(this.children.map(Ue));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Ie(t,e);return void 0!==this.value&&(e.value=this.value),r(e)}}function Ie(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var Ue=e=>e.serialize(),Ae=e=>1===e.length?e[0]:e,Pe=(e,t)=>t[e]?t[e]:t[e]={};function Be(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Fe(e){if(function(e){return null==e||"null"===e||"undefined"===e||""===e||""===e.trim()}(e))return;let t=Number(e);if(!Number.isNaN(t))return t;let i=e.toLowerCase();return"true"===i||"false"!==i&&e.trim()}const Le=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;export{Y as Exifr,H as Options,M as allFormatters,F as chunkedProps,I as createDictionary,X as disableAllOptions,U as extendDictionary,x as fetchUrlAsArrayBuffer,y as fileParsers,w as fileReaders,ee as gps,J as gpsOnlyOptions,N as inheritables,te as orientation,q as orientationOnlyOptions,L as otherSegments,Z as parse,C as readBlobAsArrayBuffer,b as segmentParsers,T as segments,V as segmentsAndBlocks,A as tagKeys,B as tagRevivers,P as tagValues,Q as thumbnail,$ as thumbnailUrl,D as tiffBlocks,z as tiffExtractables};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";var t="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){return h(e)?void 0:e}const o=e=>void 0!==e;function h(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(o).length)}function l(e){let t=new Error(e);return delete t.stack,t}function f(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function u(e){let t=function(e){let t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}let d=n?global.BigInt:self.BigInt;const c=new TextDecoder("utf-8");function g(e){return c.decode(e)}class p{static from(e,t){return e instanceof this&&e.le===t?e:new p(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof p){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw l("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else{if("number"!=typeof e)throw l("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=p){if(e instanceof DataView||e instanceof p?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw l("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new p(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){return g(this.getUint8Array(e,t))}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof d)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),d(t)<<d(32)|d(i);throw l("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function m(e,t){throw l("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class y extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||m(this.kind,e),t&&(e in t||function(e,t){throw l("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||m(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var b=new y("file parser"),w=new y("segment parser"),k=new y("file reader");function S(e,t){if((s=e).startsWith("data:")||s.length>1e4)return x(e,t,"base64");if(i)return v(e,t,"url",O);if(n)return x(e,t,"fs");throw l("Invalid input argument");var s}async function v(e,t,i,s){if(k.has(i))return x(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw l("Parser ".concat(i," is not loaded"))}async function x(e,t,i){let s=new(k.get(i))(e,t);return await s.read(),s}async function O(e){return fetch(e).then(e=>e.arrayBuffer())}async function C(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}const A=Symbol("keys"),I=Symbol("values");class U extends Map{get tagKeys(){return this[A]||(this[A]=Array.from(this.keys())),this[A]}get tagValues(){return this[I]||(this[I]=Array.from(this.values())),this[I]}}function B(e,t,i){let s=new U(i);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}const P=new Map,F=new Map,L=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],D=["jfif","xmp","icc","iptc"],z=["tiff",...D],N=["ifd0","ifd1","exif","gps","interop"],V=[...z,...N],M=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...E,"sanitize","mergeOutput"];class R{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class G extends R{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=N.includes(e),this.canBeFiltered&&(this.dict=P.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw l("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of E)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of e)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&t.add(Number(n[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,J(this.pick,this.deps)):this.enabled&&this.pick.size>0&&J(this.pick,this.deps)}}var H={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},W=new Map;class _ extends R{static useCached(e){let t=W.get(e);return void 0!==t?t:(t=new this(e),W.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw l("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of T)this[e]=H[e];for(e of j)this[e]=H[e];for(e of M)this[e]=H[e];for(e of V)this[e]=new G(e,H[e],void 0,this)}setupFromTrue(){let e;for(e of T)this[e]=H[e];for(e of j)this[e]=H[e];for(e of M)this[e]=!0;for(e of V)this[e]=new G(e,!0,void 0,this)}setupFromArray(e){let t;for(t of T)this[t]=H[t];for(t of j)this[t]=H[t];for(t of M)this[t]=H[t];for(t of V)this[t]=new G(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,N)}setupFromObject(e){let t;for(t of(N.ifd0=N.ifd0||N.image,N.ifd1=N.ifd1||N.thumbnail,Object.assign(this,e),T))this[t]=X(e[t],H[t]);for(t of j)this[t]=X(e[t],H[t]);for(t of M)this[t]=X(e[t],H[t]);for(t of z)this[t]=new G(t,H[t],e[t],this);for(t of N)this[t]=new G(t,H[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,N,V),!0===e.tiff?this.batchEnableWithBool(N,!0):!1===e.tiff?this.batchEnableWithUserValue(N,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,N):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,N)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=K(e,i);for(let[e,i]of t)J(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=K(t,i);for(let[t,i]of e)J(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:n}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),n.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=N.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of N)this[e].finalizeFilters()}get onlyTiff(){return!D.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of z)this[e].enabled&&!w.has(e)&&m("segment parser",e)}}function K(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=P.get(n),s=[],i))(e.includes(r[0])||e.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function X(e,t){return void 0!==e?e:void 0!==t?t:void 0}function J(e,t){for(let i of t)e.add(i)}r(_,"default",H);const q={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Y=Object.assign({},q,{firstChunkSize:4e4,gps:[1,2,3,4]}),Z=Object.assign({},q,{firstChunkSize:4e4,ifd0:[274]});class Q{constructor(e){r(this,"parsers",{}),this.options=_.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=b.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=b.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw l("Unknown file format");this.file.isHeic=!0,e=b.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,t){if("string"==typeof e)return S(e,t);if(i&&!s&&e instanceof HTMLImageElement)return S(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new p(e);if(i&&e instanceof Blob)return v(e,t,"blob",C);throw l("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=a(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=w.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}class $ extends p{constructor(...e){super(...e),r(this,"ranges",new ee),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(e,t,i){if(0===e&&0===this.byteLength&&i){let e=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(e)}else{let i=e+t;if(i>this.byteLength){let{dataView:e}=this._extend(i);this._swapDataView(e)}}}_extend(e){let i;i=t?Buffer.allocUnsafe(e):new Uint8Array(e);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(e,t,i=!1){return t=t||this._lengthToEnd(e),i&&this._tryExtend(e,t),this.ranges.add(e,t),super.subarray(e,t)}set(e,t,i=!1){i&&this._tryExtend(t,e.byteLength,e);let s=super.set(e,t);return this.ranges.add(t,s.byteLength),s}async ensureChunk(e,t){this.chunked&&(this.ranges.available(e,t)||await this.readChunk(e,t))}available(e,t){return this.ranges.available(e,t)}}class ee{constructor(e){r(this,"list",[]),void 0!==e&&Array.isArray(e)&&this.addMultiple(e)}get length(){return this.list.length}addMultiple(e){if(Array.isArray(e[0]))for(let[t,i]of e)this.add(t,i);else for(let{offset:t,length:i}of e)this.add(t,i)}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>te(e,t.offset,s)||te(e,t.end,s));if(n.length>0){e=Math.min(e,...n.map(e=>e.offset)),s=Math.max(s,...n.map(e=>e.end)),t=s-e;let i=n.shift();i.offset=e,i.length=t,i.end=s,this.list=this.list.filter(e=>!n.includes(e))}else this.list.push({offset:e,length:t,end:s})}available(e,t){let i=e+t;return this.list.some(t=>t.offset<=e&&i<=t.end)}}function te(e,t,i){return e<=t&&t<=i}class ie extends ${constructor(e,t){super(0),r(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}k.set("blob",class extends ie{async readWhole(){this.chunked=!1;let e=await C(this.input);this._swapArrayBuffer(e)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(e,t){let i=t?e+t:void 0,s=this.input.slice(e,i),n=await C(s);return this.set(n,e,!0)}});class se{constructor(e,t,i){r(this,"ensureSegmentChunk",async e=>{let t=e.start,i=e.size||65536;if(this.file.chunked)if(this.file.available(t,i))e.chunk=this.file.subarray(t,i);else try{e.chunk=await this.file.readChunk(t,i)}catch(t){throw l("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}else if(this.file.byteLength>t+i)e.chunk=this.file.subarray(t,i);else{if(void 0!==e.size)throw l("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}createParser(e,t){let i=new(w.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class ne{static findPosition(e,t){let i=e.getUint16(t+2)+2,s="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,n=t+s,r=i-s;return{offset:t,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(e,t={}){return new this(e,new _({[this.type]:t})).parse()}normalizeInput(e){return e instanceof p?e:new p(e)}constructor(e,t={},i){r(this,"errors",[]),r(this,"raw",new Map),r(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(e),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=t,this.localOptions=t[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(e,t){let i=L.get(t),s=F.get(t),n=P.get(t),r=this.options[t],a=r.reviveValues&&i,o=r.translateValues&&s,h=r.translateKeys&&n,l={};for(let[t,r]of e)a&&i.has(t)?r=i.get(t)(r):o&&s.has(t)&&(r=this.translateValue(r,s.get(t))),h&&n.has(t)&&(t=n.get(t)||t),l[t]=r;return l}translateValue(e,t){return t[e]||e}assignToOutput(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}assignObjectToOutput(e,t,i){if(this.globalOptions.mergeOutput)return Object.assign(e,i);e[t]?Object.assign(e[t],i):e[t]=i}}r(ne,"headerLength",4),r(ne,"type",void 0),r(ne,"multiSegment",!1),r(ne,"canHandle",()=>!1);function re(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ae(e){return e>=224&&e<=239}function oe(e,t){for(let[i,s]of w)if(s.canHandle(e,t))return i}b.set("jpeg",class extends se{constructor(...e){super(...e),r(this,"appSegments",[]),r(this,"jpegSegments",[]),r(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let e=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(e)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(w.keyList())):(e=void 0===e?w.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&w.has(e)),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}async findAppSegments(e=0,t){this.setupSegmentFinderArgs(t);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let e of n){let t=w.get(e),i=this.options[e];if(t.multiSegment&&i.multiSegment){s=!0,this.file.chunked&&await this.file.readWhole();break}}if(e=this._findAppSegments(e,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let t=!1;for(;r.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(e=>!this.file.available(e.offset||e.start,e.length||e.size));if(t=e>s&&!n?!await i.readNextChunk(e):!await i.readNextChunk(s),void 0===(e=this._findAppSegments(e,i.byteLength)))return}}}_findAppSegments(e,t){let i,s,n,r,a,o,{file:h,findAll:l,wanted:f,remaining:u,options:d}=this;for(;e<t;e++)if(255===h.getUint8(e))if(i=h.getUint8(e+1),ae(i)){if(s=h.getUint16(e+2),n=oe(h,e),n&&f.has(n)&&(r=w.get(n),a=r.findPosition(h,e),o=d[n],a.type=n,this.appSegments.push(a),!l&&(r.multiSegment&&o.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=ne.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(re(i)){if(s=h.getUint16(e+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:e,length:s,marker:i}),e+=s+1}return e}mergeMultiSegments(){if(!this.appSegments.some(e=>e.multiSegment))return;let e=function(e,t){let i,s,n,r=new Map;for(let a=0;a<e.length;a++)i=e[a],s=i[t],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r.entries())}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=w.get(e,this.options);if(i.handleMultiSegments){return{type:e,chunk:i.handleMultiSegments(t)}}return t[0]})}async createParsers(){let e=this.mergedAppSegments||this.appSegments;for(let t of e){let{type:e,chunk:i}=t;if(!this.options[e].enabled)continue;let s=this.parsers[e];if(s&&s.append);else if(!s){let t=new(w.get(e,this.options))(i,this.options,this.file);this.parsers[e]=t}}}getSegment(e){return this.appSegments.find(t=>t.type===e)}async getOrFindSegment(e){let t=this.getSegment(e);return void 0===t&&(await this.findAppSegments(0,[e]),t=this.getSegment(e)),t}});const he=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class le extends ne{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw l("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw l("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:s,skip:n}=this.options[t];s=new Set(s);let r=s.size>0,a=0===n.size,o=this.chunk.getUint16(e);e+=2;for(let h=0;h<o;h++){let o=this.chunk.getUint16(e);if(r){if(s.has(o)&&(i.set(o,this.parseTag(e,o,t)),s.delete(o),0===s.size))break}else!a&&n.has(o)||i.set(o,this.parseTag(e,o,t));e+=12}return i}parseTag(e,t,i){let s=this.chunk.getUint16(e+2),n=this.chunk.getUint32(e+4),r=he[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw l("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e));if(e>this.chunk.byteLength)throw l("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(e,n);if(2===s)return f(this.chunk.getString(e,n));if(7===s)return this.chunk.getUint8Array(e,n);if(1===n)return this.parseTagValue(s,e);{let t=new(function(e){switch(e){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}}(s))(n),i=r;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw l("Invalid tiff type ".concat(e))}}}class fe extends le{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}parseBlock(e,t){let i=new Map;return this[t]=i,this.parseTags(e,t,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw l("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw l("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,u(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==e.size?(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 ensureBlockChunk(e,t){this.file.isTiff&&await this.file.ensureChunk(e,t),e>this.chunk.byteLength&&(this.chunk=p.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,u(this.options));let e=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=e.get(40965)),this.makerNote=e.get(37500),this.userComment=e.get(37510),this.options.sanitize&&(e.delete(40965),e.delete(37500),e.delete(37510)),this.unpack(e,41728),this.unpack(e,41729),e}unpack(e,t){let i=e.get(t);i&&1===i.length&&e.set(t,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let e=this.parseBlock(this.gpsOffset,"gps");return e&&e.has(2)&&e.has(4)&&(e.set("latitude",ue(...e.get(2),e.get(1))),e.set("longitude",ue(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(e=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||e))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),void 0===this.ifd1)return;let e=this.ifd1.get(513),t=this.ifd1.get(514);return this.chunk.getUint8Array(e,t)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let e,t,i,s={};for(t of N)if(e=this[t],!h(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(s,i)}else s[t]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(let[i,s]of Object.entries(t))this.assignObjectToOutput(e,i,s)}}function ue(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}r(fe,"type","tiff"),r(fe,"headerLength",10),w.set("tiff",fe);k.set("url",class extends ie{async readWhole(){this.chunked=!1;let e=await O(this.input);this._swapArrayBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,s={};(e||i)&&(s.range="bytes=".concat([e,i].join("-")));let n=await fetch(this.input,{headers:s}),r=await n.arrayBuffer(),a=r.byteLength;if(416!==n.status)return a!==t&&(this.size=e+a),this.set(r,e,!0)}});class de extends se{parseBoxes(e=0){let t=[];for(;e<this.file.byteLength-4;){let i=this.parseBoxHead(e);if(t.push(i),0===i.length)break;e+=i.length}return t}parseSubBoxes(e){e.boxes=this.parseBoxes(e.start)}findBox(e,t){return void 0===e.boxes&&this.parseSubBoxes(e),e.boxes.find(e=>e.kind===t)}parseBoxHead(e){let t=this.file.getUint32(e),i=this.file.getString(e+4,4),s=e+8;return 1===t&&(t=this.file.getUint64(e+8),s+=8),{offset:e,length:t,kind:i,start:s}}parseBoxFullHead(e){let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}b.set("heic",class extends de{async parse(){var e=this.file.getUint32(0);let t=this.parseBoxHead(e);await this.file.ensureChunk(t.offset,t.length),this.parseBoxFullHead(t),this.parseSubBoxes(t),this.options.icc.enabled&&await this.findIcc(t),this.options.tiff.enabled&&await this.findExif(t)}async registerSegment(e,t,i){await this.file.ensureChunk(t,i);let s=this.file.subarray(t,i);this.createParser(e,s)}async findIcc(e){let t=this.findBox(e,"iprp");if(void 0===t)return;let i=this.findBox(t,"ipco");if(void 0===i)return;let s=this.findBox(i,"colr");void 0!==s&&await this.registerSegment("icc",s.offset+12,s.length)}async findExif(e){let t=this.findBox(e,"iinf");if(void 0===t)return;let i=this.findBox(e,"iloc");if(void 0===i)return;let s=this.findExifLocIdInIinf(t),n=this.findExtentInIloc(i,s);if(void 0===n)return;let[r,a]=n;await this.file.ensureChunk(r,a);let o=4+this.file.getUint32(r);r+=o,a-=o,await this.registerSegment("tiff",r,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,s,n,r=e.start,a=this.file.getUint16(r);for(r+=2;a--;){if(t=this.parseBoxHead(r),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(s=3===t.version?4:2,n=this.file.getString(i+s+2,4),"Exif"===n))return this.file.getUintBytes(i,s);r+=t.length}}get8bits(e){let t=this.file.getUint8(e);return[t>>4,15&t]}findExtentInIloc(e,t){this.parseBoxFullHead(e);let i=e.start,[s,n]=this.get8bits(i++),[r,a]=this.get8bits(i++),o=2===e.version?4:2,h=1===e.version||2===e.version?2:0,l=a+s+n,f=2===e.version?4:2,u=this.file.getUintBytes(i,f);for(i+=f;u--;){let e=this.file.getUintBytes(i,o);i+=o+h+2+r;let f=this.file.getUint16(i);if(i+=2,e===t)return f>1&&console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"),[this.file.getUintBytes(i+a,s),this.file.getUintBytes(i+a+s,n)];i+=f*l}}}),B(P,["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"]]),B(P,"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"]]),B(P,"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"]]),B(F,["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"}]]);let ce=B(F,"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"}]]);const ge={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};ce.set(37392,ge),ce.set(41488,ge);const pe={0:"Normal",1:"Low",2:"High"};function me(e){let t=Array.from(e).slice(1);return t[1]>15&&(t=t.map(e=>String.fromCharCode(e))),"0"!==t[2]&&0!==t[2]||t.pop(),t.join(".")}function ye(e){if("string"==typeof e){var[t,i,s,n,r,a]=e.trim().split(/[-: ]/g).map(Number),o=new Date(t,i-1,s);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(o.setHours(n),o.setMinutes(r),o.setSeconds(a)),Number.isNaN(+o)?e:o}}function be(e){if("string"==typeof e)return e;let t=[];if(0===e[1]&&0===e[e.length-1])for(let i=0;i<e.length;i+=2)t.push(we(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(we(e[i],e[i+1]));return f(String.fromCodePoint(...t))}function we(e,t){return e<<8|t}ce.set(41992,pe),ce.set(41993,pe),ce.set(41994,pe),B(L,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?g(e):e}],[306,ye],[40091,be],[40092,be],[40093,be],[40094,be],[40095,be]]),B(L,"exif",[[40960,me],[36864,me],[36867,ye],[36868,ye]]),B(L,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class ke extends ne{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)&&"http://ns.adobe.com/"===e.getString(t+4,"http://ns.adobe.com/".length)}static headerLength(e,t){return"http://ns.adobe.com/xmp/extension/"===e.getString(t+4,"http://ns.adobe.com/xmp/extension/".length)?79:4+"http://ns.adobe.com/xap/1.0/".length+1}static findPosition(e,t){let i=super.findPosition(e,t);return i.multiSegment=i.extended=79===i.headerLength,i.multiSegment?(i.chunkCount=e.getUint8(t+72),i.chunkNumber=e.getUint8(t+76),0!==e.getUint8(t+77)&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(e){return e.map(e=>e.chunk.getString()).join("")}normalizeInput(e){return"string"==typeof e?e:e.getString&&e.getString()}parse(e=this.chunk){if(!this.localOptions.parse)return e;e=function(e){let t={"rdf:li":1,"rdf:Seq":1,"rdf:Bag":1,"rdf:Alt":1};return e.replace(Be,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=ve.findAll(e,"rdf","Description");0===t.length&&t.push(new ve("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=Ae(t.ns,s),xe(t,i);return function(e){let t;for(let i of Object.keys(e))t=e[i]=a(e[i]),void 0===t&&delete e[i];return a(e)}(s)}assignToOutput(e,t){if(this.localOptions.parse)for(let[i,s]of Object.entries(t))switch(i){case"tiff":this.assignObjectToOutput(e,"ifd0",s);break;case"exif":this.assignObjectToOutput(e,"exif",s);break;case"xmlns":break;default:this.assignObjectToOutput(e,i,s)}else e.xmp=t}}r(ke,"type","xmp"),r(ke,"multiSegment",!0),w.set("xmp",ke);class Se{static findAll(e){return Ie(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(Se.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[3].slice(1,-1);return s=Ue(s),new Se(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class ve{static findAll(e,t,i){if(void 0!==t||void 0!==i){t=t||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var s=new RegExp("<(".concat(t,"):(").concat(i,")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"),"gm")}else s=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return Ie(e,s).map(ve.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new ve(t,i,s,n)}constructor(e,t,i,s){this.ns=e,this.name=t,this.attrString=i,this.innerXml=s,this.attrs=Se.findAll(i),this.children=ve.findAll(s),this.value=0===this.children.length?Ue(s):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return void 0!==this.value&&0===this.attrs.length&&0===this.children.length}get isListContainer(){return 1===this.children.length&&this.children[0].isList}get isList(){let{ns:e,name:t}=this;return"rdf"===e&&("Seq"===t||"Bag"===t||"Alt"===t)}get isListItem(){return"rdf"===this.ns&&"li"===this.name}serialize(){if(0===this.properties.length&&void 0===this.value)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return Ce(this.children.map(Oe));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)xe(t,e);return void 0!==this.value&&(e.value=this.value),a(e)}}function xe(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var Oe=e=>e.serialize(),Ce=e=>1===e.length?e[0]:e,Ae=(e,t)=>t[e]?t[e]:t[e]={};function Ie(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Ue(e){if(function(e){return null==e||"null"===e||"undefined"===e||""===e||""===e.trim()}(e))return;let t=Number(e);if(!Number.isNaN(t))return t;let i=e.toLowerCase();return"true"===i||"false"!==i&&e.trim()}const Be=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;e.Exifr=Q,e.Options=_,e.allFormatters=j,e.chunkedProps=T,e.createDictionary=B,e.disableAllOptions=q,e.extendDictionary=function(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])},e.fetchUrlAsArrayBuffer=O,e.fileParsers=b,e.fileReaders=k,e.gps=async function(e){let t=new Q(Y);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}},e.gpsOnlyOptions=Y,e.inheritables=E,e.orientation=async function(e){let t=new Q(Z);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]},e.orientationOnlyOptions=Z,e.otherSegments=D,e.parse=async function(e,t){let i=new Q(t);return await i.read(e),i.parse()},e.readBlobAsArrayBuffer=C,e.segmentParsers=w,e.segments=z,e.segmentsAndBlocks=V,e.tagKeys=P,e.tagRevivers=L,e.tagValues=F,e.thumbnail=async function(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new Q(i);await s.read(e);let n=await s.extractThumbnail();return n&&t?Buffer.from(n):n},e.thumbnailUrl=async function(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}},e.tiffBlocks=N,e.tiffExtractables=M,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";var t="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){return h(e)?void 0:e}const o=e=>void 0!==e;function h(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(o).length)}function l(e){let t=new Error(e);return delete t.stack,t}function f(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function u(e){let t=function(e){let t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}let d=n?global.BigInt:self.BigInt;const c=new TextDecoder("utf-8");function g(e){return c.decode(e)}class p{static from(e,t){return e instanceof this&&e.le===t?e:new p(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof p){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw l("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else{if("number"!=typeof e)throw l("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=p){if(e instanceof DataView||e instanceof p?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw l("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new p(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){return g(this.getUint8Array(e,t))}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof d)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),d(t)<<d(32)|d(i);throw l("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function m(e,t){throw l("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class y extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||m(this.kind,e),t&&(e in t||function(e,t){throw l("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||m(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var b=new y("file parser"),w=new y("segment parser"),k=new y("file reader");function S(e,t){if((s=e).startsWith("data:")||s.length>1e4)return x(e,t,"base64");if(i)return v(e,t,"url",O);if(n)return x(e,t,"fs");throw l("Invalid input argument");var s}async function v(e,t,i,s){if(k.has(i))return x(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw l("Parser ".concat(i," is not loaded"))}async function x(e,t,i){let s=new(k.get(i))(e,t);return await s.read(),s}async function O(e){return fetch(e).then(e=>e.arrayBuffer())}async function C(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}class A 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 I(e,t,i){let s=new A;for(let[e,t]of i)s.set(e,t);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}const U=new Map,B=new Map,P=new Map,F=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],L=["jfif","xmp","icc","iptc"],T=["tiff",...L],D=["ifd0","ifd1","exif","gps","interop"],V=[...T,...D],z=["makerNote","userComment"],N=["translateKeys","translateValues","reviveValues","multiSegment"],M=[...N,"sanitize","mergeOutput"];class E{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class R extends E{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=D.includes(e),this.canBeFiltered&&(this.dict=U.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw l("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of N)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of e)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&t.add(Number(n[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,K(this.pick,this.deps)):this.enabled&&this.pick.size>0&&K(this.pick,this.deps)}}var j={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},G=new Map;class H extends E{static useCached(e){let t=G.get(e);return void 0!==t?t:(t=new this(e),G.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw l("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of F)this[e]=j[e];for(e of M)this[e]=j[e];for(e of z)this[e]=j[e];for(e of V)this[e]=new R(e,j[e],void 0,this)}setupFromTrue(){let e;for(e of F)this[e]=j[e];for(e of M)this[e]=j[e];for(e of z)this[e]=!0;for(e of V)this[e]=new R(e,!0,void 0,this)}setupFromArray(e){let t;for(t of F)this[t]=j[t];for(t of M)this[t]=j[t];for(t of z)this[t]=j[t];for(t of V)this[t]=new R(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,D)}setupFromObject(e){let t;for(t of(D.ifd0=D.ifd0||D.image,D.ifd1=D.ifd1||D.thumbnail,Object.assign(this,e),F))this[t]=_(e[t],j[t]);for(t of M)this[t]=_(e[t],j[t]);for(t of z)this[t]=_(e[t],j[t]);for(t of T)this[t]=new R(t,j[t],e[t],this);for(t of D)this[t]=new R(t,j[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,D,V),!0===e.tiff?this.batchEnableWithBool(D,!0):!1===e.tiff?this.batchEnableWithUserValue(D,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,D):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,D)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=W(e,i);for(let[e,i]of t)K(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=W(t,i);for(let[t,i]of e)K(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:n}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),n.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=D.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of D)this[e].finalizeFilters()}get onlyTiff(){return!L.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of T)this[e].enabled&&!w.has(e)&&m("segment parser",e)}}function W(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=U.get(n),s=[],i))(e.includes(r[0])||e.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function _(e,t){return void 0!==e?e:void 0!==t?t:void 0}function K(e,t){for(let i of t)e.add(i)}r(H,"default",j);const X={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},J=Object.assign({},X,{firstChunkSize:4e4,gps:[1,2,3,4]}),q=Object.assign({},X,{firstChunkSize:4e4,ifd0:[274]});class Y{constructor(e){r(this,"parsers",{}),this.options=H.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=b.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=b.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw l("Unknown file format");this.file.isHeic=!0,e=b.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,t){if("string"==typeof e)return S(e,t);if(i&&!s&&e instanceof HTMLImageElement)return S(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new p(e);if(i&&e instanceof Blob)return v(e,t,"blob",C);throw l("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=a(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=w.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}class Z extends p{constructor(...e){super(...e),r(this,"ranges",new Q),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(e,t,i){if(0===e&&0===this.byteLength&&i){let e=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(e)}else{let i=e+t;if(i>this.byteLength){let{dataView:e}=this._extend(i);this._swapDataView(e)}}}_extend(e){let i;i=t?Buffer.allocUnsafe(e):new Uint8Array(e);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(e,t,i=!1){return t=t||this._lengthToEnd(e),i&&this._tryExtend(e,t),this.ranges.add(e,t),super.subarray(e,t)}set(e,t,i=!1){i&&this._tryExtend(t,e.byteLength,e);let s=super.set(e,t);return this.ranges.add(t,s.byteLength),s}async ensureChunk(e,t){this.chunked&&(this.ranges.available(e,t)||await this.readChunk(e,t))}available(e,t){return this.ranges.available(e,t)}}class Q{constructor(){r(this,"list",[])}get length(){return this.list.length}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>$(e,t.offset,s)||$(e,t.end,s));if(n.length>0){e=Math.min(e,...n.map(e=>e.offset)),s=Math.max(s,...n.map(e=>e.end)),t=s-e;let i=n.shift();i.offset=e,i.length=t,i.end=s,this.list=this.list.filter(e=>!n.includes(e))}else this.list.push({offset:e,length:t,end:s})}available(e,t){let i=e+t;return this.list.some(t=>t.offset<=e&&i<=t.end)}}function $(e,t,i){return e<=t&&t<=i}class ee extends Z{constructor(e,t){super(0),r(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}k.set("blob",class extends ee{async readWhole(){this.chunked=!1;let e=await C(this.input);this._swapArrayBuffer(e)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(e,t){let i=t?e+t:void 0,s=this.input.slice(e,i),n=await C(s);return this.set(n,e,!0)}});class te{constructor(e,t,i){r(this,"ensureSegmentChunk",async e=>{let t=e.start,i=e.size||65536;if(this.file.chunked)if(this.file.available(t,i))e.chunk=this.file.subarray(t,i);else try{e.chunk=await this.file.readChunk(t,i)}catch(t){throw l("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}else if(this.file.byteLength>t+i)e.chunk=this.file.subarray(t,i);else{if(void 0!==e.size)throw l("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}createParser(e,t){let i=new(w.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class ie{static findPosition(e,t){let i=e.getUint16(t+2)+2,s="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,n=t+s,r=i-s;return{offset:t,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(e,t={}){return new this(e,new H({[this.type]:t})).parse()}normalizeInput(e){return e instanceof p?e:new p(e)}constructor(e,t={},i){r(this,"errors",[]),r(this,"raw",new Map),r(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(e),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=t,this.localOptions=t[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(e,t){let i=P.get(t),s=B.get(t),n=U.get(t),r=this.options[t],a=r.reviveValues&&!!i,o=r.translateValues&&!!s,h=r.translateKeys&&!!n,l={};for(let[t,r]of e)a&&i.has(t)?r=i.get(t)(r):o&&s.has(t)&&(r=this.translateValue(r,s.get(t))),h&&n.has(t)&&(t=n.get(t)||t),l[t]=r;return l}translateValue(e,t){return t[e]||e}assignToOutput(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}assignObjectToOutput(e,t,i){if(this.globalOptions.mergeOutput)return Object.assign(e,i);e[t]?Object.assign(e[t],i):e[t]=i}}r(ie,"headerLength",4),r(ie,"type",void 0),r(ie,"multiSegment",!1),r(ie,"canHandle",()=>!1);function se(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ne(e){return e>=224&&e<=239}function re(e,t){for(let[i,s]of w)if(s.canHandle(e,t))return i}b.set("jpeg",class extends te{constructor(...e){super(...e),r(this,"appSegments",[]),r(this,"jpegSegments",[]),r(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let e=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(e)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(w.keyList())):(e=void 0===e?w.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&w.has(e)),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}async findAppSegments(e=0,t){this.setupSegmentFinderArgs(t);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s&&this.file.chunked&&(s=Array.from(n).some(e=>{let t=w.get(e),i=this.options[e];return t.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),e=this._findAppSegments(e,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let t=!1;for(;r.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(e=>!this.file.available(e.offset||e.start,e.length||e.size));if(t=e>s&&!n?!await i.readNextChunk(e):!await i.readNextChunk(s),void 0===(e=this._findAppSegments(e,i.byteLength)))return}}}_findAppSegments(e,t){let i,s,n,r,a,o,{file:h,findAll:l,wanted:f,remaining:u,options:d}=this;for(;e<t;e++)if(255===h.getUint8(e))if(i=h.getUint8(e+1),ne(i)){if(s=h.getUint16(e+2),n=re(h,e),n&&f.has(n)&&(r=w.get(n),a=r.findPosition(h,e),o=d[n],a.type=n,this.appSegments.push(a),!l&&(r.multiSegment&&o.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=ie.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(se(i)){if(s=h.getUint16(e+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:e,length:s,marker:i}),e+=s+1}return e}mergeMultiSegments(){if(!this.appSegments.some(e=>e.multiSegment))return;let e=function(e,t){let i,s,n,r=new Map;for(let a=0;a<e.length;a++)i=e[a],s=i[t],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r)}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=w.get(e,this.options);if(i.handleMultiSegments){return{type:e,chunk:i.handleMultiSegments(t)}}return t[0]})}async createParsers(){let e=this.mergedAppSegments||this.appSegments;for(let t of e){let{type:e,chunk:i}=t;if(!this.options[e].enabled)continue;let s=this.parsers[e];if(s&&s.append);else if(!s){let t=new(w.get(e,this.options))(i,this.options,this.file);this.parsers[e]=t}}}getSegment(e){return this.appSegments.find(t=>t.type===e)}async getOrFindSegment(e){let t=this.getSegment(e);return void 0===t&&(await this.findAppSegments(0,[e]),t=this.getSegment(e)),t}});const ae=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class oe extends ie{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw l("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw l("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:s,skip:n}=this.options[t];s=new Set(s);let r=s.size>0,a=0===n.size,o=this.chunk.getUint16(e);e+=2;for(let h=0;h<o;h++){let o=this.chunk.getUint16(e);if(r){if(s.has(o)&&(i.set(o,this.parseTag(e,o,t)),s.delete(o),0===s.size))break}else!a&&n.has(o)||i.set(o,this.parseTag(e,o,t));e+=12}return i}parseTag(e,t,i){let s=this.chunk.getUint16(e+2),n=this.chunk.getUint32(e+4),r=ae[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw l("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e));if(e>this.chunk.byteLength)throw l("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(e,n);if(2===s)return f(this.chunk.getString(e,n));if(7===s)return this.chunk.getUint8Array(e,n);if(1===n)return this.parseTagValue(s,e);{let t=new(function(e){switch(e){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}}(s))(n),i=r;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw l("Invalid tiff type ".concat(e))}}}class he extends oe{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(e){try{return await this[e]()}catch(e){this.handleError(e)}}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}parseBlock(e,t){let i=new Map;return this[t]=i,this.parseTags(e,t,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw l("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw l("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,u(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==e.size?(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 ensureBlockChunk(e,t){this.file.isTiff&&await this.file.ensureChunk(e,t),e>this.chunk.byteLength&&(this.chunk=p.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,u(this.options));let e=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=e.get(40965)),this.makerNote=e.get(37500),this.userComment=e.get(37510),this.options.sanitize&&(e.delete(40965),e.delete(37500),e.delete(37510)),this.unpack(e,41728),this.unpack(e,41729),e}unpack(e,t){let i=e.get(t);i&&1===i.length&&e.set(t,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let e=this.parseBlock(this.gpsOffset,"gps");return e&&e.has(2)&&e.has(4)&&(e.set("latitude",le(...e.get(2),e.get(1))),e.set("longitude",le(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(e=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||e))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),void 0===this.ifd1)return;let e=this.ifd1.get(513),t=this.ifd1.get(514);return this.chunk.getUint8Array(e,t)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let e,t,i,s={};for(t of D)if(e=this[t],!h(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(s,i)}else s[t]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(let[i,s]of Object.entries(t))this.assignObjectToOutput(e,i,s)}}function le(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}r(he,"type","tiff"),r(he,"headerLength",10),w.set("tiff",he);k.set("url",class extends ee{async readWhole(){this.chunked=!1;let e=await O(this.input);this._swapArrayBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,s={};(e||i)&&(s.range="bytes=".concat([e,i].join("-")));let n=await fetch(this.input,{headers:s}),r=await n.arrayBuffer(),a=r.byteLength;if(416!==n.status)return a!==t&&(this.size=e+a),this.set(r,e,!0)}});class fe extends te{parseBoxes(e=0){let t=[];for(;e<this.file.byteLength-4;){let i=this.parseBoxHead(e);if(t.push(i),0===i.length)break;e+=i.length}return t}parseSubBoxes(e){e.boxes=this.parseBoxes(e.start)}findBox(e,t){return void 0===e.boxes&&this.parseSubBoxes(e),e.boxes.find(e=>e.kind===t)}parseBoxHead(e){let t=this.file.getUint32(e),i=this.file.getString(e+4,4),s=e+8;return 1===t&&(t=this.file.getUint64(e+8),s+=8),{offset:e,length:t,kind:i,start:s}}parseBoxFullHead(e){let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}b.set("heic",class extends fe{async parse(){var e=this.file.getUint32(0);let t=this.parseBoxHead(e);await this.file.ensureChunk(t.offset,t.length),this.parseBoxFullHead(t),this.parseSubBoxes(t),this.options.icc.enabled&&await this.findIcc(t),this.options.tiff.enabled&&await this.findExif(t)}async registerSegment(e,t,i){await this.file.ensureChunk(t,i);let s=this.file.subarray(t,i);this.createParser(e,s)}async findIcc(e){let t=this.findBox(e,"iprp");if(void 0===t)return;let i=this.findBox(t,"ipco");if(void 0===i)return;let s=this.findBox(i,"colr");void 0!==s&&await this.registerSegment("icc",s.offset+12,s.length)}async findExif(e){let t=this.findBox(e,"iinf");if(void 0===t)return;let i=this.findBox(e,"iloc");if(void 0===i)return;let s=this.findExifLocIdInIinf(t),n=this.findExtentInIloc(i,s);if(void 0===n)return;let[r,a]=n;await this.file.ensureChunk(r,a);let o=4+this.file.getUint32(r);r+=o,a-=o,await this.registerSegment("tiff",r,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,s,n,r=e.start,a=this.file.getUint16(r);for(r+=2;a--;){if(t=this.parseBoxHead(r),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(s=3===t.version?4:2,n=this.file.getString(i+s+2,4),"Exif"===n))return this.file.getUintBytes(i,s);r+=t.length}}get8bits(e){let t=this.file.getUint8(e);return[t>>4,15&t]}findExtentInIloc(e,t){this.parseBoxFullHead(e);let i=e.start,[s,n]=this.get8bits(i++),[r,a]=this.get8bits(i++),o=2===e.version?4:2,h=1===e.version||2===e.version?2:0,l=a+s+n,f=2===e.version?4:2,u=this.file.getUintBytes(i,f);for(i+=f;u--;){let e=this.file.getUintBytes(i,o);i+=o+h+2+r;let f=this.file.getUint16(i);if(i+=2,e===t)return f>1&&console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"),[this.file.getUintBytes(i+a,s),this.file.getUintBytes(i+a+s,n)];i+=f*l}}}),I(U,["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"]]),I(U,"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"]]),I(U,"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"]]),I(B,["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"}]]);let ue=I(B,"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"}]]);const de={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};ue.set(37392,de),ue.set(41488,de);const ce={0:"Normal",1:"Low",2:"High"};function ge(e){let t=Array.from(e).slice(1);return t[1]>15&&(t=t.map(e=>String.fromCharCode(e))),"0"!==t[2]&&0!==t[2]||t.pop(),t.join(".")}function pe(e){if("string"==typeof e){var[t,i,s,n,r,a]=e.trim().split(/[-: ]/g).map(Number),o=new Date(t,i-1,s);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(o.setHours(n),o.setMinutes(r),o.setSeconds(a)),Number.isNaN(+o)?e:o}}function me(e){if("string"==typeof e)return e;let t=[];if(0===e[1]&&0===e[e.length-1])for(let i=0;i<e.length;i+=2)t.push(ye(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(ye(e[i],e[i+1]));return f(String.fromCodePoint(...t))}function ye(e,t){return e<<8|t}ue.set(41992,ce),ue.set(41993,ce),ue.set(41994,ce),I(P,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?g(e):e}],[306,pe],[40091,me],[40092,me],[40093,me],[40094,me],[40095,me]]),I(P,"exif",[[40960,ge],[36864,ge],[36867,pe],[36868,pe]]),I(P,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class be extends ie{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)&&"http://ns.adobe.com/"===e.getString(t+4,"http://ns.adobe.com/".length)}static headerLength(e,t){return"http://ns.adobe.com/xmp/extension/"===e.getString(t+4,"http://ns.adobe.com/xmp/extension/".length)?79:4+"http://ns.adobe.com/xap/1.0/".length+1}static findPosition(e,t){let i=super.findPosition(e,t);return i.multiSegment=i.extended=79===i.headerLength,i.multiSegment?(i.chunkCount=e.getUint8(t+72),i.chunkNumber=e.getUint8(t+76),0!==e.getUint8(t+77)&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(e){return e.map(e=>e.chunk.getString()).join("")}normalizeInput(e){return"string"==typeof e?e:e.getString&&e.getString()}parse(e=this.chunk){if(!this.localOptions.parse)return e;e=function(e){let t={"rdf:li":1,"rdf:Seq":1,"rdf:Bag":1,"rdf:Alt":1};return e.replace(Ie,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=ke.findAll(e,"rdf","Description");0===t.length&&t.push(new ke("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=Oe(t.ns,s),Se(t,i);return function(e){let t;for(let i in e)t=e[i]=a(e[i]),void 0===t&&delete e[i];return a(e)}(s)}assignToOutput(e,t){if(this.localOptions.parse)for(let[i,s]of Object.entries(t))switch(i){case"tiff":this.assignObjectToOutput(e,"ifd0",s);break;case"exif":this.assignObjectToOutput(e,"exif",s);break;case"xmlns":break;default:this.assignObjectToOutput(e,i,s)}else e.xmp=t}}r(be,"type","xmp"),r(be,"multiSegment",!0),w.set("xmp",be);class we{static findAll(e){return Ce(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(we.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[3].slice(1,-1);return s=Ae(s),new we(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class ke{static findAll(e,t,i){if(void 0!==t||void 0!==i){t=t||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var s=new RegExp("<(".concat(t,"):(").concat(i,")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"),"gm")}else s=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return Ce(e,s).map(ke.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new ke(t,i,s,n)}constructor(e,t,i,s){this.ns=e,this.name=t,this.attrString=i,this.innerXml=s,this.attrs=we.findAll(i),this.children=ke.findAll(s),this.value=0===this.children.length?Ae(s):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return void 0!==this.value&&0===this.attrs.length&&0===this.children.length}get isListContainer(){return 1===this.children.length&&this.children[0].isList}get isList(){let{ns:e,name:t}=this;return"rdf"===e&&("Seq"===t||"Bag"===t||"Alt"===t)}get isListItem(){return"rdf"===this.ns&&"li"===this.name}serialize(){if(0===this.properties.length&&void 0===this.value)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return xe(this.children.map(ve));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Se(t,e);return void 0!==this.value&&(e.value=this.value),a(e)}}function Se(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var ve=e=>e.serialize(),xe=e=>1===e.length?e[0]:e,Oe=(e,t)=>t[e]?t[e]:t[e]={};function Ce(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Ae(e){if(function(e){return null==e||"null"===e||"undefined"===e||""===e||""===e.trim()}(e))return;let t=Number(e);if(!Number.isNaN(t))return t;let i=e.toLowerCase();return"true"===i||"false"!==i&&e.trim()}const Ie=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;e.Exifr=Y,e.Options=H,e.allFormatters=M,e.chunkedProps=F,e.createDictionary=I,e.disableAllOptions=X,e.extendDictionary=function(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])},e.fetchUrlAsArrayBuffer=O,e.fileParsers=b,e.fileReaders=k,e.gps=async function(e){let t=new Y(J);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}},e.gpsOnlyOptions=J,e.inheritables=N,e.orientation=async function(e){let t=new Y(q);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]},e.orientationOnlyOptions=q,e.otherSegments=L,e.parse=async function(e,t){let i=new Y(t);return await i.read(e),i.parse()},e.readBlobAsArrayBuffer=C,e.segmentParsers=w,e.segments=T,e.segmentsAndBlocks=V,e.tagKeys=U,e.tagRevivers=P,e.tagValues=B,e.thumbnail=async function(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new Y(i);await s.read(e);let n=await s.extractThumbnail();return n&&t?Buffer.from(n):n},e.thumbnailUrl=async function(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}},e.tiffBlocks=D,e.tiffExtractables=z,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,1 +0,1 @@

var t="undefined"!=typeof Buffer,e="undefined"!=typeof navigator,i=e&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const r=t=>void 0!==t;function a(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(r).length)}function h(t){let e=new Error(t);return delete e.stack,e}function f(t){let e=function(t){let e=0;return t.ifd0.enabled&&(e+=1024),t.exif.enabled&&(e+=2048),t.makerNote&&(e+=2048),t.userComment&&(e+=1024),t.gps.enabled&&(e+=512),t.interop.enabled&&(e+=100),t.ifd1.enabled&&(e+=1024),e+2048}(t);return t.jfif.enabled&&(e+=50),t.xmp.enabled&&(e+=2e4),t.iptc.enabled&&(e+=14e3),t.icc.enabled&&(e+=6e3),e}let o=s?global.BigInt:self.BigInt;const l=new TextDecoder("utf-8");class u{static from(t,e){return t instanceof this&&t.le===e?t:new u(t,void 0,void 0,e)}constructor(t,e=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof u){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw h("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else{if("number"!=typeof t)throw h("Invalid input argument for BufferView: "+t);{let e=new DataView(new ArrayBuffer(t));this._swapDataView(e)}}}_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=u){if(t instanceof DataView||t instanceof u?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw h("BufferView.set(): Invalid data argument.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new u(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){let i=this.getUint8Array(t,e);return s=i,l.decode(s);var s}getUnicodeString(t=0,e=this.byteLength){const i=[];for(let s=0;s<e&&t+s<this.byteLength;s+=2)i.push(this.getUint16(t+s));return i.map(t=>String.fromCharCode(t)).join("")}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)}getUint64(t){let e=this.getUint32(t),i=this.getUint32(t+4);if(e<1048575)return e<<32|i;if(void 0!==typeof o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(e)<<o(32)|o(i);throw h("Trying to read 64b value but JS can only handle 53b numbers.")}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(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(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}}function d(t,e){throw h("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class c extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||d(this.kind,t),e&&(t in e||function(t,e){throw h("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||d(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var p=new c("file parser"),g=new c("segment parser"),y=new c("file reader");function w(t,i){if((n=t).startsWith("data:")||n.length>1e4)return b(t,i,"base64");if(e)return k(t,i,"url",m);if(s)return b(t,i,"fs");throw h("Invalid input argument");var n}async function k(t,e,i,s){if(y.has(i))return b(t,e,i);if(s)return async function(t,e){let i=await e(t);return new DataView(i)}(t,s);throw h("Parser ".concat(i," is not loaded"))}async function b(t,e,i){let s=new(y.get(i))(t,e);return await s.read(),s}async function m(t){return fetch(t).then(t=>t.arrayBuffer())}async function v(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}const O=Symbol("keys"),S=Symbol("values");class U extends Map{get tagKeys(){return this[O]||(this[O]=Array.from(this.keys())),this[O]}get tagValues(){return this[S]||(this[S]=Array.from(this.values())),this[S]}}function A(t,e,i){let s=new U(i);if(Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s}function x(t,e,i){let s,n=t.get(e);for(s of i)n.set(s[0],s[1])}const C=new Map,V=new Map,B=new Map,I=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],T=["jfif","xmp","icc","iptc"],L=["tiff",...T],z=["ifd0","ifd1","exif","gps","interop"],F=[...L,...z],j=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],D=[...E,"sanitize","mergeOutput"];class M{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class N extends M{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=z.includes(t),this.canBeFiltered&&(this.dict=C.get(t)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:t,skip:e}=i;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw h("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(t){let e,i;for(e of E)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of t)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&e.add(Number(n[s]))):e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,K(this.pick,this.deps)):this.enabled&&this.pick.size>0&&K(this.pick,this.deps)}}var _={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},P=new Map;class W extends M{static useCached(t){let e=P.get(t);return void 0!==e?e:(e=new this(t),P.set(t,e),e)}constructor(t){if(super(),!0===t)this.setupFromTrue();else if(void 0===t)this.setupFromUndefined();else if(Array.isArray(t))this.setupFromArray(t);else{if("object"!=typeof t)throw h("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=e?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of I)this[t]=_[t];for(t of D)this[t]=_[t];for(t of j)this[t]=_[t];for(t of F)this[t]=new N(t,_[t],void 0,this)}setupFromTrue(){let t;for(t of I)this[t]=_[t];for(t of D)this[t]=_[t];for(t of j)this[t]=!0;for(t of F)this[t]=new N(t,!0,void 0,this)}setupFromArray(t){let e;for(e of I)this[e]=_[e];for(e of D)this[e]=_[e];for(e of j)this[e]=_[e];for(e of F)this[e]=new N(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,z)}setupFromObject(t){let e;for(e of(z.ifd0=z.ifd0||z.image,z.ifd1=z.ifd1||z.thumbnail,Object.assign(this,t),I))this[e]=H(t[e],_[e]);for(e of D)this[e]=H(t[e],_[e]);for(e of j)this[e]=H(t[e],_[e]);for(e of L)this[e]=new N(e,_[e],t[e],this);for(e of z)this[e]=new N(e,_[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,z,F),!0===t.tiff?this.batchEnableWithBool(z,!0):!1===t.tiff?this.batchEnableWithUserValue(z,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,z):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,z)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let t=e[i];this[i].enabled=!1!==t&&void 0!==t}}setupGlobalFilters(t,e,i,s=i){if(t&&t.length){for(let t of s)this[t].enabled=!1;let e=R(t,i);for(let[t,i]of e)K(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=R(e,i);for(let[e,i]of t)K(this[e].skip,i)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:s,icc:n}=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),s.enabled||t.skip.add(33723),n.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:s}=this;s.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=z.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of z)this[t].finalizeFilters()}get onlyTiff(){return!T.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of L)this[t].enabled&&!g.has(t)&&d("segment parser",t)}}function R(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=C.get(n),s=[],i))(t.includes(r[0])||t.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function H(t,e){return void 0!==t?t:void 0!==e?e:void 0}function K(t,e){for(let i of e)t.add(i)}n(W,"default",_);const G={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},J=Object.assign({},G,{firstChunkSize:4e4,gps:[1,2,3,4]}),X=Object.assign({},G,{firstChunkSize:4e4,ifd0:[274]});class q{constructor(t){n(this,"parsers",{}),this.options=W.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=p.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=p.get("jpeg");else{if(!function(t){if(0!==t.getUint16(0))return!1;let e=t.getUint16(2);if(e>50)return!1;let i=16,s=[];for(;i<e;)s.push(t.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw h("Unknown file format");this.file.isHeic=!0,t=p.get("heic")}this.fileParser=new t(this.options,this.file,this.parsers)}async read(t){this.file=await function(t,s){if("string"==typeof t)return w(t,s);if(e&&!i&&t instanceof HTMLImageElement)return w(t.src,s);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new u(t);if(e&&t instanceof Blob)return k(t,s,"blob",v);throw h("Invalid input argument")}(t,this.options)}async parse(){this.setup(),await this.fileParser.parse();let t={},e=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(t){e.push(t)}i.errors.length&&e.push(...i.errors)}else s=await i.parse();i.assignToOutput(t,s)});var s;return await Promise.all(i),this.options.silentErrors&&e.length>0&&(t.errors=e),t=a(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=g.get("tiff",this.options);var e;if(this.file.isTiff?e={start:0,type:"tiff"}:this.file.isJpeg&&(e=await this.fileParser.getOrFindSegment("tiff")),void 0===e)return;let i=await this.fileParser.ensureSegmentChunk(e),s=this.parsers.tiff=new t(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}async function Q(t,e){let i=new q(e);return await i.read(t),i.parse()}async function Y(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new q(i);await s.read(e);let n=await s.extractThumbnail();return n&&t?Buffer.from(n):n}async function Z(...t){let e=await this.thumbnail(...t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}}async function $(t){let e=new q(J);await e.read(t);let i=await e.parse();if(i&&i.gps){let{latitude:t,longitude:e}=i.gps;return{latitude:t,longitude:e}}}async function tt(t){let e=new q(X);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]}class et extends u{constructor(...t){super(...t),n(this,"ranges",new it),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(0===t&&0===this.byteLength&&i){let t=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(t)}else{let i=t+e;if(i>this.byteLength){let{dataView:t}=this._extend(i);this._swapDataView(t)}}}_extend(e){let i;i=t?Buffer.allocUnsafe(e):new Uint8Array(e);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}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 s=super.set(t,e);return this.ranges.add(e,s.byteLength),s}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)}}class it{constructor(t){n(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}get length(){return this.list.length}addMultiple(t){if(Array.isArray(t[0]))for(let[e,i]of t)this.add(e,i);else for(let{offset:e,length:i}of t)this.add(e,i)}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>st(t,e.offset,s)||st(t,e.end,s));if(n.length>0){t=Math.min(t,...n.map(t=>t.offset)),s=Math.max(s,...n.map(t=>t.end)),e=s-t;let i=n.shift();i.offset=t,i.length=e,i.end=s,this.list=this.list.filter(t=>!n.includes(t))}else this.list.push({offset:t,length:e,end:s})}available(t,e){let i=t+e;return this.list.some(e=>e.offset<=t&&i<=e.end)}}function st(t,e,i){return t<=e&&e<=i}class nt extends et{constructor(t,e){super(0),n(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++,0!==(e=this.safeWrapAddress(t,e)))return this._readChunk(t,e)}safeWrapAddress(t,e){return void 0!==this.size&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}y.set("blob",class extends nt{async readWhole(){this.chunked=!1;let t=await v(this.input);this._swapArrayBuffer(t)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(t,e){let i=e?t+e:void 0,s=this.input.slice(t,i),n=await v(s);return this.set(n,t,!0)}});class rt{static findPosition(t,e){let i=t.getUint16(e+2)+2,s="function"==typeof this.headerLength?this.headerLength(t,e,i):this.headerLength,n=e+s,r=i-s;return{offset:e,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(t,e={}){return new this(t,new W({[this.type]:e})).parse()}normalizeInput(t){return t instanceof u?t:new u(t)}constructor(t,e={},i){n(this,"errors",[]),n(this,"raw",new Map),n(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.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=B.get(e),s=V.get(e),n=C.get(e),r=this.options[e],a=r.reviveValues&&i,h=r.translateValues&&s,f=r.translateKeys&&n,o={};for(let[e,r]of t)a&&i.has(e)?r=i.get(e)(r):h&&s.has(e)&&(r=this.translateValue(r,s.get(e))),f&&n.has(e)&&(e=n.get(e)||e),o[e]=r;return o}translateValue(t,e){return e[t]||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}}n(rt,"headerLength",4),n(rt,"type",void 0),n(rt,"multiSegment",!1),n(rt,"canHandle",()=>!1);function at(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function ht(t){return t>=224&&t<=239}function ft(t,e){for(let[i,s]of g)if(s.canHandle(t,e))return i}p.set("jpeg",class extends class{constructor(t,e,i){n(this,"ensureSegmentChunk",async t=>{let e=t.start,i=t.size||65536;if(this.file.chunked)if(this.file.available(e,i))t.chunk=this.file.subarray(e,i);else try{t.chunk=await this.file.readChunk(e,i)}catch(e){throw h("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.message))}else if(this.file.byteLength>e+i)t.chunk=this.file.subarray(e,i);else{if(void 0!==t.size)throw h("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}createParser(t,e){let i=new(g.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),n(this,"appSegments",[]),n(this,"jpegSegments",[]),n(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let t=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(t)}setupSegmentFinderArgs(t){!0===t?(this.findAll=!0,this.wanted=new Set(g.keyList())):(t=void 0===t?g.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&g.has(t)),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:s,wanted:n,remaining:r}=this;if(!s)for(let t of n){let e=g.get(t),i=this.options[t];if(e.multiSegment&&i.multiSegment){s=!0,this.file.chunked&&await this.file.readWhole();break}}if(t=this._findAppSegments(t,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let e=!1;for(;r.size>0&&!e&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(t=>!this.file.available(t.offset||t.start,t.length||t.size));if(e=t>s&&!n?!await i.readNextChunk(t):!await i.readNextChunk(s),void 0===(t=this._findAppSegments(t,i.byteLength)))return}}}_findAppSegments(t,e){let i,s,n,r,a,h,{file:f,findAll:o,wanted:l,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),ht(i)){if(s=f.getUint16(t+2),n=ft(f,t),n&&l.has(n)&&(r=g.get(n),a=r.findPosition(f,t),h=d[n],a.type=n,this.appSegments.push(a),!o&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=rt.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(at(i)){if(s=f.getUint16(t+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:t,length:s,marker:i}),t+=s+1}return t}mergeMultiSegments(){if(!this.appSegments.some(t=>t.multiSegment))return;let t=function(t,e){let i,s,n,r=new Map;for(let a=0;a<t.length;a++)i=t[a],s=i[e],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r.entries())}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=g.get(t,this.options);if(i.handleMultiSegments){return{type:t,chunk:i.handleMultiSegments(e)}}return e[0]})}async createParsers(){let t=this.mergedAppSegments||this.appSegments;for(let e of t){let{type:t,chunk:i}=e;if(!this.options[t].enabled)continue;let s=this.parsers[t];if(s&&s.append);else if(!s){let e=new(g.get(t,this.options))(i,this.options,this.file);this.parsers[t]=e}}}getSegment(t){return this.appSegments.find(e=>e.type===t)}async getOrFindSegment(t){let e=this.getSegment(t);return void 0===e&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}});const ot=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class lt extends rt{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw h("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw h("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:s,skip:n}=this.options[e];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(t);t+=2;for(let f=0;f<h;f++){let h=this.chunk.getUint16(t);if(r){if(s.has(h)&&(i.set(h,this.parseTag(t,h,e)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(t,h,e));t+=12}return i}parseTag(t,e,i){let s=this.chunk.getUint16(t+2),n=this.chunk.getUint32(t+4),r=ot[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw h("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t));if(t>this.chunk.byteLength)throw h("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(t,n);if(2===s)return""===(a=function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t}(a=this.chunk.getString(t,n)).trim())?void 0:a;var a;if(7===s)return this.chunk.getUint8Array(t,n);if(1===n)return this.parseTagValue(s,t);{let e=new(function(t){switch(t){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}}(s))(n),i=r;for(let r=0;r<n;r++)e[r]=this.parseTagValue(s,t),t+=i;return e}}parseTagValue(t,e){switch(t){case 1:return this.chunk.getUint8(e);case 3:return this.chunk.getUint16(e);case 4:return this.chunk.getUint32(e);case 5:return this.chunk.getUint32(e)/this.chunk.getUint32(e+4);case 6:return this.chunk.getInt8(e);case 8:return this.chunk.getInt16(e);case 9:return this.chunk.getInt32(e);case 10:return this.chunk.getInt32(e)/this.chunk.getInt32(e+4);case 11:return this.chunk.getFloat(e);case 12:return this.chunk.getDouble(e);case 13:return this.chunk.getUint32(e);default:throw h("Invalid tiff type ".concat(t))}}}class ut extends lt{static canHandle(t,e){return 225===t.getUint8(e+1)&&1165519206===t.getUint32(e+4)&&0===t.getUint16(e+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){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;if(this.findIfd0Offset(),this.ifd0Offset<8)throw h("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw h("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,f(this.options));let t=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==t.size?(this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t):void 0}async ensureBlockChunk(t,e){this.file.isTiff&&await this.file.ensureChunk(t,e),t>this.chunk.byteLength&&(this.chunk=u.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,f(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&&1===i.length&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",dt(...t.get(2),t.get(1))),t.set("longitude",dt(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))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),void 0===this.ifd1)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,s={};for(e of z)if(t=this[e],!a(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if("ifd1"===e)continue;Object.assign(s,i)}else s[e]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,s]of Object.entries(e))this.assignObjectToOutput(t,i,s)}}function dt(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}n(ut,"type","tiff"),n(ut,"headerLength",10),g.set("tiff",ut);export{q as Exifr,W as Options,D as allFormatters,I as chunkedProps,A as createDictionary,G as disableAllOptions,x as extendDictionary,m as fetchUrlAsArrayBuffer,p as fileParsers,y as fileReaders,$ as gps,J as gpsOnlyOptions,E as inheritables,tt as orientation,X as orientationOnlyOptions,T as otherSegments,Q as parse,v as readBlobAsArrayBuffer,g as segmentParsers,L as segments,F as segmentsAndBlocks,C as tagKeys,B as tagRevivers,V as tagValues,Y as thumbnail,Z as thumbnailUrl,z as tiffBlocks,j as tiffExtractables};
var t="undefined"!=typeof Buffer,e="undefined"!=typeof navigator,i=e&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const r=t=>void 0!==t;function a(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(r).length)}function h(t){let e=new Error(t);return delete e.stack,e}function f(t){let e=function(t){let e=0;return t.ifd0.enabled&&(e+=1024),t.exif.enabled&&(e+=2048),t.makerNote&&(e+=2048),t.userComment&&(e+=1024),t.gps.enabled&&(e+=512),t.interop.enabled&&(e+=100),t.ifd1.enabled&&(e+=1024),e+2048}(t);return t.jfif.enabled&&(e+=50),t.xmp.enabled&&(e+=2e4),t.iptc.enabled&&(e+=14e3),t.icc.enabled&&(e+=6e3),e}let o=s?global.BigInt:self.BigInt;const l=new TextDecoder("utf-8");class u{static from(t,e){return t instanceof this&&t.le===e?t:new u(t,void 0,void 0,e)}constructor(t,e=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof u){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw h("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else{if("number"!=typeof t)throw h("Invalid input argument for BufferView: "+t);{let e=new DataView(new ArrayBuffer(t));this._swapDataView(e)}}}_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=u){if(t instanceof DataView||t instanceof u?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw h("BufferView.set(): Invalid data argument.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new u(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){let i=this.getUint8Array(t,e);return s=i,l.decode(s);var s}getUnicodeString(t=0,e=this.byteLength){const i=[];for(let s=0;s<e&&t+s<this.byteLength;s+=2)i.push(this.getUint16(t+s));return i.map(t=>String.fromCharCode(t)).join("")}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)}getUint64(t){let e=this.getUint32(t),i=this.getUint32(t+4);if(e<1048575)return e<<32|i;if(void 0!==typeof o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(e)<<o(32)|o(i);throw h("Trying to read 64b value but JS can only handle 53b numbers.")}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(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(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}}function d(t,e){throw h("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class c extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||d(this.kind,t),e&&(t in e||function(t,e){throw h("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||d(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var p=new c("file parser"),g=new c("segment parser"),y=new c("file reader");function w(t,i){if((n=t).startsWith("data:")||n.length>1e4)return m(t,i,"base64");if(e)return k(t,i,"url",b);if(s)return m(t,i,"fs");throw h("Invalid input argument");var n}async function k(t,e,i,s){if(y.has(i))return m(t,e,i);if(s)return async function(t,e){let i=await e(t);return new DataView(i)}(t,s);throw h("Parser ".concat(i," is not loaded"))}async function m(t,e,i){let s=new(y.get(i))(t,e);return await s.read(),s}async function b(t){return fetch(t).then(t=>t.arrayBuffer())}async function v(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}class O 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 S(t,e,i){let s=new O;for(let[t,e]of i)s.set(t,e);if(Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s}function U(t,e,i){let s,n=t.get(e);for(s of i)n.set(s[0],s[1])}const A=new Map,x=new Map,C=new Map,B=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],V=["jfif","xmp","icc","iptc"],I=["tiff",...V],T=["ifd0","ifd1","exif","gps","interop"],L=[...I,...T],z=["makerNote","userComment"],F=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...F,"sanitize","mergeOutput"];class D{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class P extends D{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=T.includes(t),this.canBeFiltered&&(this.dict=A.get(t)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:t,skip:e}=i;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw h("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(t){let e,i;for(e of F)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of t)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&e.add(Number(n[s]))):e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,K(this.pick,this.deps)):this.enabled&&this.pick.size>0&&K(this.pick,this.deps)}}var E={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},M=new Map;class N extends D{static useCached(t){let e=M.get(t);return void 0!==e?e:(e=new this(t),M.set(t,e),e)}constructor(t){if(super(),!0===t)this.setupFromTrue();else if(void 0===t)this.setupFromUndefined();else if(Array.isArray(t))this.setupFromArray(t);else{if("object"!=typeof t)throw h("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=e?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of B)this[t]=E[t];for(t of j)this[t]=E[t];for(t of z)this[t]=E[t];for(t of L)this[t]=new P(t,E[t],void 0,this)}setupFromTrue(){let t;for(t of B)this[t]=E[t];for(t of j)this[t]=E[t];for(t of z)this[t]=!0;for(t of L)this[t]=new P(t,!0,void 0,this)}setupFromArray(t){let e;for(e of B)this[e]=E[e];for(e of j)this[e]=E[e];for(e of z)this[e]=E[e];for(e of L)this[e]=new P(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,T)}setupFromObject(t){let e;for(e of(T.ifd0=T.ifd0||T.image,T.ifd1=T.ifd1||T.thumbnail,Object.assign(this,t),B))this[e]=W(t[e],E[e]);for(e of j)this[e]=W(t[e],E[e]);for(e of z)this[e]=W(t[e],E[e]);for(e of I)this[e]=new P(e,E[e],t[e],this);for(e of T)this[e]=new P(e,E[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,T,L),!0===t.tiff?this.batchEnableWithBool(T,!0):!1===t.tiff?this.batchEnableWithUserValue(T,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,T):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,T)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let t=e[i];this[i].enabled=!1!==t&&void 0!==t}}setupGlobalFilters(t,e,i,s=i){if(t&&t.length){for(let t of s)this[t].enabled=!1;let e=_(t,i);for(let[t,i]of e)K(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=_(e,i);for(let[e,i]of t)K(this[e].skip,i)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:s,icc:n}=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),s.enabled||t.skip.add(33723),n.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:s}=this;s.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=T.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of T)this[t].finalizeFilters()}get onlyTiff(){return!V.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of I)this[t].enabled&&!g.has(t)&&d("segment parser",t)}}function _(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=A.get(n),s=[],i))(t.includes(r[0])||t.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function W(t,e){return void 0!==t?t:void 0!==e?e:void 0}function K(t,e){for(let i of e)t.add(i)}n(N,"default",E);const R={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},H=Object.assign({},R,{firstChunkSize:4e4,gps:[1,2,3,4]}),G=Object.assign({},R,{firstChunkSize:4e4,ifd0:[274]});class J{constructor(t){n(this,"parsers",{}),this.options=N.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=p.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=p.get("jpeg");else{if(!function(t){if(0!==t.getUint16(0))return!1;let e=t.getUint16(2);if(e>50)return!1;let i=16,s=[];for(;i<e;)s.push(t.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw h("Unknown file format");this.file.isHeic=!0,t=p.get("heic")}this.fileParser=new t(this.options,this.file,this.parsers)}async read(t){this.file=await function(t,s){if("string"==typeof t)return w(t,s);if(e&&!i&&t instanceof HTMLImageElement)return w(t.src,s);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new u(t);if(e&&t instanceof Blob)return k(t,s,"blob",v);throw h("Invalid input argument")}(t,this.options)}async parse(){this.setup(),await this.fileParser.parse();let t={},e=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(t){e.push(t)}i.errors.length&&e.push(...i.errors)}else s=await i.parse();i.assignToOutput(t,s)});var s;return await Promise.all(i),this.options.silentErrors&&e.length>0&&(t.errors=e),t=a(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=g.get("tiff",this.options);var e;if(this.file.isTiff?e={start:0,type:"tiff"}:this.file.isJpeg&&(e=await this.fileParser.getOrFindSegment("tiff")),void 0===e)return;let i=await this.fileParser.ensureSegmentChunk(e),s=this.parsers.tiff=new t(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}async function X(t,e){let i=new J(e);return await i.read(t),i.parse()}async function q(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new J(i);await s.read(e);let n=await s.extractThumbnail();return n&&t?Buffer.from(n):n}async function Q(...t){let e=await this.thumbnail(...t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}}async function Y(t){let e=new J(H);await e.read(t);let i=await e.parse();if(i&&i.gps){let{latitude:t,longitude:e}=i.gps;return{latitude:t,longitude:e}}}async function Z(t){let e=new J(G);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]}class $ extends u{constructor(...t){super(...t),n(this,"ranges",new tt),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(0===t&&0===this.byteLength&&i){let t=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(t)}else{let i=t+e;if(i>this.byteLength){let{dataView:t}=this._extend(i);this._swapDataView(t)}}}_extend(e){let i;i=t?Buffer.allocUnsafe(e):new Uint8Array(e);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}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 s=super.set(t,e);return this.ranges.add(e,s.byteLength),s}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)}}class tt{constructor(){n(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>et(t,e.offset,s)||et(t,e.end,s));if(n.length>0){t=Math.min(t,...n.map(t=>t.offset)),s=Math.max(s,...n.map(t=>t.end)),e=s-t;let i=n.shift();i.offset=t,i.length=e,i.end=s,this.list=this.list.filter(t=>!n.includes(t))}else this.list.push({offset:t,length:e,end:s})}available(t,e){let i=t+e;return this.list.some(e=>e.offset<=t&&i<=e.end)}}function et(t,e,i){return t<=e&&e<=i}class it extends ${constructor(t,e){super(0),n(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++,0!==(e=this.safeWrapAddress(t,e)))return this._readChunk(t,e)}safeWrapAddress(t,e){return void 0!==this.size&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}y.set("blob",class extends it{async readWhole(){this.chunked=!1;let t=await v(this.input);this._swapArrayBuffer(t)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(t,e){let i=e?t+e:void 0,s=this.input.slice(t,i),n=await v(s);return this.set(n,t,!0)}});class st{static findPosition(t,e){let i=t.getUint16(e+2)+2,s="function"==typeof this.headerLength?this.headerLength(t,e,i):this.headerLength,n=e+s,r=i-s;return{offset:e,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(t,e={}){return new this(t,new N({[this.type]:e})).parse()}normalizeInput(t){return t instanceof u?t:new u(t)}constructor(t,e={},i){n(this,"errors",[]),n(this,"raw",new Map),n(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.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=C.get(e),s=x.get(e),n=A.get(e),r=this.options[e],a=r.reviveValues&&!!i,h=r.translateValues&&!!s,f=r.translateKeys&&!!n,o={};for(let[e,r]of t)a&&i.has(e)?r=i.get(e)(r):h&&s.has(e)&&(r=this.translateValue(r,s.get(e))),f&&n.has(e)&&(e=n.get(e)||e),o[e]=r;return o}translateValue(t,e){return e[t]||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}}n(st,"headerLength",4),n(st,"type",void 0),n(st,"multiSegment",!1),n(st,"canHandle",()=>!1);function nt(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function rt(t){return t>=224&&t<=239}function at(t,e){for(let[i,s]of g)if(s.canHandle(t,e))return i}p.set("jpeg",class extends class{constructor(t,e,i){n(this,"ensureSegmentChunk",async t=>{let e=t.start,i=t.size||65536;if(this.file.chunked)if(this.file.available(e,i))t.chunk=this.file.subarray(e,i);else try{t.chunk=await this.file.readChunk(e,i)}catch(e){throw h("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.message))}else if(this.file.byteLength>e+i)t.chunk=this.file.subarray(e,i);else{if(void 0!==t.size)throw h("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}createParser(t,e){let i=new(g.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),n(this,"appSegments",[]),n(this,"jpegSegments",[]),n(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let t=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(t)}setupSegmentFinderArgs(t){!0===t?(this.findAll=!0,this.wanted=new Set(g.keyList())):(t=void 0===t?g.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&g.has(t)),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:s,wanted:n,remaining:r}=this;if(!s&&this.file.chunked&&(s=Array.from(n).some(t=>{let e=g.get(t),i=this.options[t];return e.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),t=this._findAppSegments(t,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let e=!1;for(;r.size>0&&!e&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(t=>!this.file.available(t.offset||t.start,t.length||t.size));if(e=t>s&&!n?!await i.readNextChunk(t):!await i.readNextChunk(s),void 0===(t=this._findAppSegments(t,i.byteLength)))return}}}_findAppSegments(t,e){let i,s,n,r,a,h,{file:f,findAll:o,wanted:l,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),rt(i)){if(s=f.getUint16(t+2),n=at(f,t),n&&l.has(n)&&(r=g.get(n),a=r.findPosition(f,t),h=d[n],a.type=n,this.appSegments.push(a),!o&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=st.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(nt(i)){if(s=f.getUint16(t+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:t,length:s,marker:i}),t+=s+1}return t}mergeMultiSegments(){if(!this.appSegments.some(t=>t.multiSegment))return;let t=function(t,e){let i,s,n,r=new Map;for(let a=0;a<t.length;a++)i=t[a],s=i[e],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r)}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=g.get(t,this.options);if(i.handleMultiSegments){return{type:t,chunk:i.handleMultiSegments(e)}}return e[0]})}async createParsers(){let t=this.mergedAppSegments||this.appSegments;for(let e of t){let{type:t,chunk:i}=e;if(!this.options[t].enabled)continue;let s=this.parsers[t];if(s&&s.append);else if(!s){let e=new(g.get(t,this.options))(i,this.options,this.file);this.parsers[t]=e}}}getSegment(t){return this.appSegments.find(e=>e.type===t)}async getOrFindSegment(t){let e=this.getSegment(t);return void 0===e&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}});const ht=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ft extends st{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw h("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw h("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:s,skip:n}=this.options[e];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(t);t+=2;for(let f=0;f<h;f++){let h=this.chunk.getUint16(t);if(r){if(s.has(h)&&(i.set(h,this.parseTag(t,h,e)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(t,h,e));t+=12}return i}parseTag(t,e,i){let s=this.chunk.getUint16(t+2),n=this.chunk.getUint32(t+4),r=ht[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw h("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t));if(t>this.chunk.byteLength)throw h("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(t,n);if(2===s)return""===(a=function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t}(a=this.chunk.getString(t,n)).trim())?void 0:a;var a;if(7===s)return this.chunk.getUint8Array(t,n);if(1===n)return this.parseTagValue(s,t);{let e=new(function(t){switch(t){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}}(s))(n),i=r;for(let r=0;r<n;r++)e[r]=this.parseTagValue(s,t),t+=i;return e}}parseTagValue(t,e){switch(t){case 1:return this.chunk.getUint8(e);case 3:return this.chunk.getUint16(e);case 4:return this.chunk.getUint32(e);case 5:return this.chunk.getUint32(e)/this.chunk.getUint32(e+4);case 6:return this.chunk.getInt8(e);case 8:return this.chunk.getInt16(e);case 9:return this.chunk.getInt32(e);case 10:return this.chunk.getInt32(e)/this.chunk.getInt32(e+4);case 11:return this.chunk.getFloat(e);case 12:return this.chunk.getDouble(e);case 13:return this.chunk.getUint32(e);default:throw h("Invalid tiff type ".concat(t))}}}class ot extends ft{static canHandle(t,e){return 225===t.getUint8(e+1)&&1165519206===t.getUint32(e+4)&&0===t.getUint16(e+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(t){try{return await this[t]()}catch(t){this.handleError(t)}}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){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;if(this.findIfd0Offset(),this.ifd0Offset<8)throw h("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw h("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,f(this.options));let t=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==t.size?(this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t):void 0}async ensureBlockChunk(t,e){this.file.isTiff&&await this.file.ensureChunk(t,e),t>this.chunk.byteLength&&(this.chunk=u.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,f(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&&1===i.length&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",lt(...t.get(2),t.get(1))),t.set("longitude",lt(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await this.parseExifBlock(),void 0!==this.interopOffset))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),void 0===this.ifd1)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,s={};for(e of T)if(t=this[e],!a(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if("ifd1"===e)continue;Object.assign(s,i)}else s[e]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,s]of Object.entries(e))this.assignObjectToOutput(t,i,s)}}function lt(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}n(ot,"type","tiff"),n(ot,"headerLength",10),g.set("tiff",ot);export{J as Exifr,N as Options,j as allFormatters,B as chunkedProps,S as createDictionary,R as disableAllOptions,U as extendDictionary,b as fetchUrlAsArrayBuffer,p as fileParsers,y as fileReaders,Y as gps,H as gpsOnlyOptions,F as inheritables,Z as orientation,G as orientationOnlyOptions,V as otherSegments,X as parse,v as readBlobAsArrayBuffer,g as segmentParsers,I as segments,L as segmentsAndBlocks,A as tagKeys,C as tagRevivers,x as tagValues,q as thumbnail,Q as thumbnailUrl,T as tiffBlocks,z as tiffExtractables};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,r,n,i,a,s){try{var u=e[a](s),o=u.value}catch(e){return void r(e)}u.done?t(o):Promise.resolve(o).then(n,i)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(i,a){var s=e.apply(t,n);function u(e){r(s,i,a,u,o,"next",e)}function o(e){r(s,i,a,u,o,"throw",e)}u(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function h(e,t,r){return(h=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&l(i,r.prototype),i}).apply(null,arguments)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return h(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,i=!1,a=void 0;try{for(var s,u=e[Symbol.iterator]();!(n=(s=u.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function k(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var b="undefined"!=typeof Buffer,m="undefined"!=typeof navigator,w=m&&"undefined"==typeof HTMLImageElement,x=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);var S=function(e){return void 0!==e};function O(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(S).length)}function R(e){var t=new Error(e);return delete t.stack,t}function A(e){var t=function(e){var t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}var U=x?global.BigInt:self.BigInt,C=new TextDecoder("utf-8");function B(e){return C.decode(e)}var V=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;if(i(this,e),"boolean"==typeof a&&(this.le=a),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){var s=new DataView(t,r,n);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof e){var u=t,o=u.byteOffset,f=u.byteLength;if(void 0===n&&(n=f-r),(r+=o)+n>o+f)throw R("Creating view outside of available memory in ArrayBuffer");var l=new DataView(t.buffer,r,n);this._swapDataView(l)}else{if("number"!=typeof t)throw R("Invalid input argument for BufferView: "+t);var c=new DataView(new ArrayBuffer(t));this._swapDataView(c)}}return s(e,null,[{key:"from",value:function(t,r){return t instanceof this&&t.le===r?t:new e(t,void 0,void 0,r)}}]),s(e,[{key:"_swapArrayBuffer",value:function(e){this._swapDataView(new DataView(e))}},{key:"_swapBuffer",value:function(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}},{key:"_swapDataView",value:function(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}},{key:"_lengthToEnd",value:function(e){return this.byteLength-e}},{key:"set",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;if(t instanceof DataView||t instanceof e?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw R("BufferView.set(): Invalid data argument.");var i=this.toUint8();return i.set(t,r),new n(this,r,t.byteLength)}},{key:"subarray",value:function(t,r){return new e(this,t,r=r||this._lengthToEnd(t))}},{key:"toUint8",value:function(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}},{key:"getUint8Array",value:function(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}},{key:"getString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.byteLength,r=this.getUint8Array(e,t);return B(r)}},{key:"getUnicodeString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.byteLength,r=[],n=0;n<t&&e+n<this.byteLength;n+=2)r.push(this.getUint16(e+n));return r.map((function(e){return String.fromCharCode(e)})).join("")}},{key:"getInt8",value:function(e){return this.dataView.getInt8(e)}},{key:"getUint8",value:function(e){return this.dataView.getUint8(e)}},{key:"getInt16",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getInt16(e,t)}},{key:"getInt32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getInt32(e,t)}},{key:"getUint16",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getUint16(e,t)}},{key:"getUint32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getUint32(e,t)}},{key:"getFloat32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat32(e,t)}},{key:"getFloat64",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat64(e,t)}},{key:"getFloat",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat32(e,t)}},{key:"getDouble",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat64(e,t)}},{key:"getUint64",value:function(e){var r=this.getUint32(e),n=this.getUint32(e+4);if(r<1048575)return r<<32|n;if(void 0!==t(U))return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),U(r)<<U(32)|U(n);throw R("Trying to read 64b value but JS can only handle 53b numbers.")}},{key:"getUintBytes",value:function(e,t,r){switch(t){case 1:return this.getUint8(e,r);case 2:return this.getUint16(e,r);case 4:return this.getUint32(e,r);case 8:return this.getUint64(e,r)}}},{key:"getUint",value:function(e,t,r){switch(t){case 8:return this.getUint8(e,r);case 16:return this.getUint16(e,r);case 32:return this.getUint32(e,r);case 64:return this.getUint64(e,r)}}},{key:"toString",value:function(e){return this.dataView.toString(e,this.constructor.name)}},{key:"ensureChunk",value:function(){}}]),e}();function I(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=!0,a=!1,s=void 0;try{for(var u,o=r[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;void 0===e[f]&&(e[f]=t.prototype[f])}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}var l=!0,c=!1,h=void 0;try{for(var p,d=n[Symbol.iterator]();!(l=(p=d.next()).done);l=!0){var y=p.value,v=Object.getOwnPropertyDescriptor(e,y);if(void 0===v){var g=Object.getOwnPropertyDescriptor(t.prototype,y);Object.defineProperty(e,y,g)}}}catch(e){c=!0,h=e}finally{try{l||null==d.return||d.return()}finally{if(c)throw h}}}function T(e,t){throw R("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}var L=function(e){function t(e){var r;return i(this,t),(r=y(this,f(t).call(this))).kind=e,r}return o(t,e),s(t,[{key:"get",value:function(e,r){return this.has(e)||T(this.kind,e),r&&(e in r||function(e,t){throw R("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),r[e].enabled||T(this.kind,e)),v(f(t.prototype),"get",this).call(this,e)}},{key:"keyList",value:function(){return Array.from(this.keys())}}]),t}(p(Map)),j=new L("file parser"),z=new L("segment parser"),F=new L("file reader");function P(e,t){if("string"==typeof e)return E(e,t);if(m&&!w&&e instanceof HTMLImageElement)return E(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new V(e);if(m&&e instanceof Blob)return D(e,t,"blob",J);throw R("Invalid input argument")}function E(e,t){if((r=e).startsWith("data:")||r.length>1e4)return M(e,t,"base64");if(m)return D(e,t,"url",H);if(x)return M(e,t,"fs");throw R("Invalid input argument");var r}function D(e,t,r,n){return _.apply(this,arguments)}function _(){return(_=n(regeneratorRuntime.mark((function e(t,r,n,i){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!F.has(n)){e.next=4;break}return e.abrupt("return",M(t,r,n));case 4:if(!i){e.next=8;break}return e.abrupt("return",W(t,i));case 8:throw R("Parser ".concat(n," is not loaded"));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function M(e,t,r){return N.apply(this,arguments)}function N(){return(N=n(regeneratorRuntime.mark((function e(t,r,n){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=F.get(n),a=new i(t,r),e.next=4,a.read();case 4:return e.abrupt("return",a);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function W(e,t){return K.apply(this,arguments)}function K(){return(K=n(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r(t);case 2:return n=e.sent,e.abrupt("return",new DataView(n));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function H(e){return G.apply(this,arguments)}function G(){return(G=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch(t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function J(e){return X.apply(this,arguments)}function X(){return(X=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){var n=new FileReader;n.onloadend=function(){return e(n.result||new ArrayBuffer)},n.onerror=r,n.readAsArrayBuffer(t)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}I(j,L,["keyList"]),I(z,L,["keyList"]),I(F,L,["keyList"]);var q=Symbol("keys"),Q=Symbol("values"),Y=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}return o(t,e),s(t,[{key:"tagKeys",get:function(){return this[q]||(this[q]=Array.from(this.keys())),this[q]}},{key:"tagValues",get:function(){return this[Q]||(this[Q]=Array.from(this.values())),this[Q]}}]),t}(p(Map));var Z=new Map,$=new Map,ee=new Map,te=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],re=["jfif","xmp","icc","iptc"],ne=["tiff"].concat(re),ie=["ifd0","ifd1","exif","gps","interop"],ae=[].concat(k(ne),ie),se=["makerNote","userComment"],ue=["translateKeys","translateValues","reviveValues","multiSegment"],oe=[].concat(ue,["sanitize","mergeOutput"]),fe=function(){function e(){i(this,e)}return s(e,[{key:"translate",get:function(){return this.translateKeys||this.translateValues||this.reviveValues}}]),e}(),le=function(e){function r(e,n,a,s){var o;if(i(this,r),u(d(o=y(this,f(r).call(this))),"enabled",!1),u(d(o),"skip",new Set),u(d(o),"pick",new Set),u(d(o),"deps",new Set),u(d(o),"translateKeys",!1),u(d(o),"translateValues",!1),u(d(o),"reviveValues",!1),o.key=e,o.enabled=n,o.parse=o.enabled,o.applyInheritables(s),o.canBeFiltered=ie.includes(e),o.canBeFiltered&&(o.dict=Z.get(e)),void 0!==a)if(Array.isArray(a))o.parse=o.enabled=!0,o.canBeFiltered&&a.length>0&&o.translateTagSet(a,o.pick);else if("object"===t(a)){if(o.enabled=!0,o.parse=!1!==a.parse,o.canBeFiltered){var l=a.pick,c=a.skip;l&&l.length>0&&o.translateTagSet(l,o.pick),c&&c.length>0&&o.translateTagSet(c,o.skip)}o.applyInheritables(a)}else{if(!0!==a&&!1!==a)throw R("Invalid options argument: ".concat(a));o.parse=o.enabled=a}return o}return o(r,e),s(r,[{key:"needed",get:function(){return this.enabled||this.deps.size>0}}]),s(r,[{key:"applyInheritables",value:function(e){var t,r,n=!0,i=!1,a=void 0;try{for(var s,u=ue[Symbol.iterator]();!(n=(s=u.next()).done);n=!0)void 0!==(r=e[t=s.value])&&(this[t]=r)}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}}},{key:"translateTagSet",value:function(e,t){var r,n,i=this.dict,a=i.tagKeys,s=i.tagValues,u=!0,o=!1,f=void 0;try{for(var l,c=e[Symbol.iterator]();!(u=(l=c.next()).done);u=!0)"string"==typeof(r=l.value)?(-1===(n=s.indexOf(r))&&(n=a.indexOf(Number(r))),-1!==n&&t.add(Number(a[n]))):t.add(r)}catch(e){o=!0,f=e}finally{try{u||null==c.return||c.return()}finally{if(o)throw f}}}},{key:"finalizeFilters",value:function(){!this.enabled&&this.deps.size>0?(this.enabled=!0,ve(this.pick,this.deps)):this.enabled&&this.pick.size>0&&ve(this.pick,this.deps)}}]),r}(fe),ce={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},he=new Map,pe=function(e){function r(e){var n;if(i(this,r),n=y(this,f(r).call(this)),!0===e)n.setupFromTrue();else if(void 0===e)n.setupFromUndefined();else if(Array.isArray(e))n.setupFromArray(e);else{if("object"!==t(e))throw R("Invalid options argument ".concat(e));n.setupFromObject(e)}return void 0===n.firstChunkSize&&(n.firstChunkSize=m?n.firstChunkSizeBrowser:n.firstChunkSizeNode),n.mergeOutput&&(n.ifd1.enabled=!1),n.filterNestedSegmentTags(),n.traverseTiffDependencyTree(),n.checkLoadedPlugins(),n}return o(r,e),s(r,null,[{key:"useCached",value:function(e){var t=he.get(e);return void 0!==t?t:(t=new this(e),he.set(e,t),t)}}]),s(r,[{key:"setupFromUndefined",value:function(){var e,t=!0,r=!1,n=void 0;try{for(var i,a=te[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)this[e=i.value]=ce[e]}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}var s=!0,u=!1,o=void 0;try{for(var f,l=oe[Symbol.iterator]();!(s=(f=l.next()).done);s=!0)this[e=f.value]=ce[e]}catch(e){u=!0,o=e}finally{try{s||null==l.return||l.return()}finally{if(u)throw o}}var c=!0,h=!1,p=void 0;try{for(var d,y=se[Symbol.iterator]();!(c=(d=y.next()).done);c=!0)this[e=d.value]=ce[e]}catch(e){h=!0,p=e}finally{try{c||null==y.return||y.return()}finally{if(h)throw p}}var v=!0,g=!1,k=void 0;try{for(var b,m=ae[Symbol.iterator]();!(v=(b=m.next()).done);v=!0)this[e=b.value]=new le(e,ce[e],void 0,this)}catch(e){g=!0,k=e}finally{try{v||null==m.return||m.return()}finally{if(g)throw k}}}},{key:"setupFromTrue",value:function(){var e,t=!0,r=!1,n=void 0;try{for(var i,a=te[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)this[e=i.value]=ce[e]}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}var s=!0,u=!1,o=void 0;try{for(var f,l=oe[Symbol.iterator]();!(s=(f=l.next()).done);s=!0)this[e=f.value]=ce[e]}catch(e){u=!0,o=e}finally{try{s||null==l.return||l.return()}finally{if(u)throw o}}var c=!0,h=!1,p=void 0;try{for(var d,y=se[Symbol.iterator]();!(c=(d=y.next()).done);c=!0)this[e=d.value]=!0}catch(e){h=!0,p=e}finally{try{c||null==y.return||y.return()}finally{if(h)throw p}}var v=!0,g=!1,k=void 0;try{for(var b,m=ae[Symbol.iterator]();!(v=(b=m.next()).done);v=!0)this[e=b.value]=new le(e,!0,void 0,this)}catch(e){g=!0,k=e}finally{try{v||null==m.return||m.return()}finally{if(g)throw k}}}},{key:"setupFromArray",value:function(e){var t,r=!0,n=!1,i=void 0;try{for(var a,s=te[Symbol.iterator]();!(r=(a=s.next()).done);r=!0)this[t=a.value]=ce[t]}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}var u=!0,o=!1,f=void 0;try{for(var l,c=oe[Symbol.iterator]();!(u=(l=c.next()).done);u=!0)this[t=l.value]=ce[t]}catch(e){o=!0,f=e}finally{try{u||null==c.return||c.return()}finally{if(o)throw f}}var h=!0,p=!1,d=void 0;try{for(var y,v=se[Symbol.iterator]();!(h=(y=v.next()).done);h=!0)this[t=y.value]=ce[t]}catch(e){p=!0,d=e}finally{try{h||null==v.return||v.return()}finally{if(p)throw d}}var g=!0,k=!1,b=void 0;try{for(var m,w=ae[Symbol.iterator]();!(g=(m=w.next()).done);g=!0)this[t=m.value]=new le(t,!1,void 0,this)}catch(e){k=!0,b=e}finally{try{g||null==w.return||w.return()}finally{if(k)throw b}}this.setupGlobalFilters(e,void 0,ie)}},{key:"setupFromObject",value:function(e){var r;ie.ifd0=ie.ifd0||ie.image,ie.ifd1=ie.ifd1||ie.thumbnail,Object.assign(this,e);var n=!0,i=!1,a=void 0;try{for(var s,u=te[Symbol.iterator]();!(n=(s=u.next()).done);n=!0)this[r=s.value]=ye(e[r],ce[r])}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}var o=!0,f=!1,l=void 0;try{for(var c,h=oe[Symbol.iterator]();!(o=(c=h.next()).done);o=!0)this[r=c.value]=ye(e[r],ce[r])}catch(e){f=!0,l=e}finally{try{o||null==h.return||h.return()}finally{if(f)throw l}}var p=!0,d=!1,y=void 0;try{for(var v,g=se[Symbol.iterator]();!(p=(v=g.next()).done);p=!0)this[r=v.value]=ye(e[r],ce[r])}catch(e){d=!0,y=e}finally{try{p||null==g.return||g.return()}finally{if(d)throw y}}var k=!0,b=!1,m=void 0;try{for(var w,x=ne[Symbol.iterator]();!(k=(w=x.next()).done);k=!0)this[r=w.value]=new le(r,ce[r],e[r],this)}catch(e){b=!0,m=e}finally{try{k||null==x.return||x.return()}finally{if(b)throw m}}var S=!0,O=!1,R=void 0;try{for(var A,U=ie[Symbol.iterator]();!(S=(A=U.next()).done);S=!0)this[r=A.value]=new le(r,ce[r],e[r],this.tiff)}catch(e){O=!0,R=e}finally{try{S||null==U.return||U.return()}finally{if(O)throw R}}this.setupGlobalFilters(e.pick,e.skip,ie,ae),!0===e.tiff?this.batchEnableWithBool(ie,!0):!1===e.tiff?this.batchEnableWithUserValue(ie,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,ie):"object"===t(e.tiff)&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,ie)}},{key:"batchEnableWithBool",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){this[a.value].enabled=t}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}},{key:"batchEnableWithUserValue",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=a.value,o=t[u];this[u].enabled=!1!==o&&void 0!==o}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}},{key:"setupGlobalFilters",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r;if(e&&e.length){var i=!0,a=!1,s=void 0;try{for(var u,o=n[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;this[f].enabled=!1}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}var l=de(e,r),c=!0,h=!1,p=void 0;try{for(var d,y=l[Symbol.iterator]();!(c=(d=y.next()).done);c=!0){var v=g(d.value,2),k=v[0],b=v[1];ve(this[k].pick,b),this[k].enabled=!0}}catch(e){h=!0,p=e}finally{try{c||null==y.return||y.return()}finally{if(h)throw p}}}else if(t&&t.length){var m=de(t,r),w=!0,x=!1,S=void 0;try{for(var O,R=m[Symbol.iterator]();!(w=(O=R.next()).done);w=!0){var A=g(O.value,2),U=A[0],C=A[1];ve(this[U].skip,C)}}catch(e){x=!0,S=e}finally{try{w||null==R.return||R.return()}finally{if(x)throw S}}}}},{key:"filterNestedSegmentTags",value:function(){var e=this.ifd0,t=this.exif,r=this.xmp,n=this.iptc,i=this.icc;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),r.enabled||e.skip.add(700),n.enabled||e.skip.add(33723),i.enabled||e.skip.add(34675)}},{key:"traverseTiffDependencyTree",value:function(){var e=this,t=this.ifd0,r=this.exif,n=this.gps;this.interop.needed&&(r.deps.add(40965),t.deps.add(40965)),r.needed&&t.deps.add(34665),n.needed&&t.deps.add(34853),this.tiff.enabled=ie.some((function(t){return!0===e[t].enabled}))||this.makerNote||this.userComment;var i=!0,a=!1,s=void 0;try{for(var u,o=ie[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){this[u.value].finalizeFilters()}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}}},{key:"checkLoadedPlugins",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=ne[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var a=n.value;this[a].enabled&&!z.has(a)&&T("segment parser",a)}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"onlyTiff",get:function(){var e=this;return!re.map((function(t){return e[t].enabled})).some((function(e){return!0===e}))&&this.tiff.enabled}}]),r}(fe);function de(e,t){var r,n,i,a,s=[],u=!0,o=!1,f=void 0;try{for(var l,c=t[Symbol.iterator]();!(u=(l=c.next()).done);u=!0){i=l.value,r=Z.get(i),n=[];var h=!0,p=!1,d=void 0;try{for(var y,v=r[Symbol.iterator]();!(h=(y=v.next()).done);h=!0)a=y.value,(e.includes(a[0])||e.includes(a[1]))&&n.push(a[0])}catch(e){p=!0,d=e}finally{try{h||null==v.return||v.return()}finally{if(p)throw d}}n.length&&s.push([i,n])}}catch(e){o=!0,f=e}finally{try{u||null==c.return||c.return()}finally{if(o)throw f}}return s}function ye(e,t){return void 0!==e?e:void 0!==t?t:void 0}function ve(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=a.value;e.add(u)}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}u(pe,"default",ce);var ge={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},ke=Object.assign({},ge,{firstChunkSize:4e4,gps:[1,2,3,4]}),be=Object.assign({},ge,{firstChunkSize:4e4,ifd0:[274]});var me=function(){function e(t){i(this,e),u(this,"parsers",{}),this.options=pe.useCached(t)}var t,r;return s(e,[{key:"setup",value:function(){if(!this.fileParser){var e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=j.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=j.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;var t=e.getUint16(2);if(t>50)return!1;for(var r=16,n=[];r<t;)n.push(e.getString(r,4)),r+=4;return n.includes("heic")}(this.file))throw R("Unknown file format");this.file.isHeic=!0,e=j.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}}},{key:"read",value:(r=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,P(t,this.options);case 2:this.file=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){var t,r,i,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setup(),e.next=3,this.fileParser.parse();case 3:return t={},r=[],i=Object.values(this.parsers).map(function(){var e=n(regeneratorRuntime.mark((function e(n){var i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!a.options.silentErrors){e.next=13;break}return e.prev=1,e.next=4,n.parse();case 4:i=e.sent,e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),r.push(e.t0);case 10:n.errors.length&&r.push.apply(r,k(n.errors)),e.next=16;break;case 13:return e.next=15,n.parse();case 15:i=e.sent;case 16:n.assignToOutput(t,i);case 17:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t){return e.apply(this,arguments)}}()),e.next=8,Promise.all(i);case 8:return this.options.silentErrors&&r.length>0&&(t.errors=r),t=O(s=t)?void 0:s,this.file.close&&this.file.close(),e.abrupt("return",t);case 12:case"end":return e.stop()}var s}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"extractThumbnail",value:(t=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.setup(),t=z.get("tiff",this.options),!this.file.isTiff){e.next=6;break}r={start:0,type:"tiff"},e.next=10;break;case 6:if(!this.file.isJpeg){e.next=10;break}return e.next=9,this.fileParser.getOrFindSegment("tiff");case 9:r=e.sent;case 10:if(void 0!==r){e.next=12;break}return e.abrupt("return");case 12:return e.next=14,this.fileParser.ensureSegmentChunk(r);case 14:return n=e.sent,i=this.parsers.tiff=new t(n,this.options,this.file),e.next=18,i.extractThumbnail();case 18:return a=e.sent,this.file.close&&this.file.close(),e.abrupt("return",a);case 21:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function we(){return(we=n(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new me(r),e.next=3,n.read(t);case 3:return e.abrupt("return",n.parse());case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(){return(xe=n(regeneratorRuntime.mark((function e(t){var r,n,i,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=a.length>1&&void 0!==a[1]?a[1]:{}).ifd1=!0,r.mergeOutput=!0,n=new me(r),e.next=6,n.read(t);case 6:return e.next=8,n.extractThumbnail();case 8:if(!(i=e.sent)||!b){e.next=13;break}return e.abrupt("return",Buffer.from(i));case 13:return e.abrupt("return",i);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Se(){return(Se=n(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.thumbnail.apply(this,n);case 2:if(void 0===(t=e.sent)){e.next=6;break}return r=new Blob([t]),e.abrupt("return",URL.createObjectURL(r));case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}function Oe(){return(Oe=n(regeneratorRuntime.mark((function e(t){var r,n,i,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new me(ke),e.next=3,r.read(t);case 3:return e.next=5,r.parse();case 5:if(!(n=e.sent)||!n.gps){e.next=9;break}return i=n.gps,a=i.latitude,s=i.longitude,e.abrupt("return",{latitude:a,longitude:s});case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Re(){return(Re=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new me(be),e.next=3,r.read(t);case 3:return e.next=5,r.parse();case 5:if(!(n=e.sent)||!n.ifd0){e.next=8;break}return e.abrupt("return",n.ifd0[274]);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ae=function(e){function t(){var e,r;i(this,t);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return u(d(r=y(this,(e=f(t)).call.apply(e,[this].concat(a)))),"ranges",new Ue),0!==r.byteLength&&r.ranges.add(0,r.byteLength),r}var r;return o(t,e),s(t,[{key:"_tryExtend",value:function(e,t,r){if(0===e&&0===this.byteLength&&r){var n=new DataView(r.buffer||r,r.byteOffset,r.byteLength);this._swapDataView(n)}else{var i=e+t;if(i>this.byteLength){var a=this._extend(i).dataView;this._swapDataView(a)}}}},{key:"_extend",value:function(e){var t;t=b?Buffer.allocUnsafe(e):new Uint8Array(e);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:r}}},{key:"subarray",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return r=r||this._lengthToEnd(e),n&&this._tryExtend(e,r),this.ranges.add(e,r),v(f(t.prototype),"subarray",this).call(this,e,r)}},{key:"set",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];n&&this._tryExtend(r,e.byteLength,e);var i=v(f(t.prototype),"set",this).call(this,e,r);return this.ranges.add(r,i.byteLength),i}},{key:"ensureChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.chunked){e.next=2;break}return e.abrupt("return");case 2:if(!this.ranges.available(t,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,this.readChunk(t,r);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"available",value:function(e,t){return this.ranges.available(e,t)}}]),t}(V),Ue=function(){function e(t){i(this,e),u(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}return s(e,[{key:"addMultiple",value:function(e){if(Array.isArray(e[0])){var t=!0,r=!1,n=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var s=g(i.value,2),u=s[0],o=s[1];this.add(u,o)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}else{var f=!0,l=!1,c=void 0;try{for(var h,p=e[Symbol.iterator]();!(f=(h=p.next()).done);f=!0){var d=h.value,y=d.offset,v=d.length;this.add(y,v)}}catch(e){l=!0,c=e}finally{try{f||null==p.return||p.return()}finally{if(l)throw c}}}}},{key:"add",value:function(e,t){var r=e+t,n=this.list.filter((function(t){return Ce(e,t.offset,r)||Ce(e,t.end,r)}));if(n.length>0){e=Math.min.apply(Math,[e].concat(k(n.map((function(e){return e.offset}))))),t=(r=Math.max.apply(Math,[r].concat(k(n.map((function(e){return e.end}))))))-e;var i=n.shift();i.offset=e,i.length=t,i.end=r,this.list=this.list.filter((function(e){return!n.includes(e)}))}else this.list.push({offset:e,length:t,end:r})}},{key:"available",value:function(e,t){var r=e+t;return this.list.some((function(t){return t.offset<=e&&r<=t.end}))}},{key:"length",get:function(){return this.list.length}}]),e}();function Ce(e,t,r){return e<=t&&t<=r}var Be=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}var r,a;return o(t,e),s(t,[{key:"readWhole",value:(a=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!1,e.next=3,J(this.input);case 3:t=e.sent,this._swapArrayBuffer(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"readChunked",value:function(){return this.chunked=!0,this.size=this.input.size,v(f(t.prototype),"readChunked",this).call(this)}},{key:"_readChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){var n,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r?t+r:void 0,i=this.input.slice(t,n),e.next=4,J(i);case 4:return a=e.sent,e.abrupt("return",this.set(a,t,!0));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})}]),t}(function(e){function t(e,r){var n;return i(this,t),u(d(n=y(this,f(t).call(this,0))),"chunksRead",0),n.input=e,n.options=r,n}var r,a,l,c;return o(t,e),s(t,[{key:"readWhole",value:(c=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!1,e.next=3,this.readChunk(this.nextChunkOffset);case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"readChunked",value:(l=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!0,e.next=3,this.readChunk(0,this.options.firstChunkSize);case 3:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"readNextChunk",value:(a=n(regeneratorRuntime.mark((function e(){var t,r,n,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:this.nextChunkOffset,!this.fullyRead){e.next=4;break}return this.chunksRead++,e.abrupt("return",!1);case 4:return r=this.options.chunkSize,e.next=7,this.readChunk(t,r);case 7:if(!(n=e.sent)){e.next=10;break}return e.abrupt("return",n.byteLength===r);case 10:return e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"readChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.chunksRead++,0!==(r=this.safeWrapAddress(t,r))){e.next=4;break}return e.abrupt("return",void 0);case 4:return e.abrupt("return",this._readChunk(t,r));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"safeWrapAddress",value:function(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}},{key:"read",value:function(){return this.options.chunked?this.readChunked():this.readWhole()}},{key:"close",value:function(){}},{key:"nextChunkOffset",get:function(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}},{key:"canReadNextChunk",get:function(){return this.chunksRead<this.options.chunkLimit}},{key:"fullyRead",get:function(){return void 0!==this.size&&this.nextChunkOffset===this.size}}]),t}(Ae));F.set("blob",Be);var Ve=function(){function e(t,r,a){var s=this;i(this,e),u(this,"ensureSegmentChunk",function(){var e=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.start,n=t.size||65536,!s.file.chunked){e.next=18;break}if(!s.file.available(r,n)){e.next=7;break}t.chunk=s.file.subarray(r,n),e.next=16;break;case 7:return e.prev=7,e.next=10,s.file.readChunk(r,n);case 10:t.chunk=e.sent,e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(7),R("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.t0.message));case 16:e.next=27;break;case 18:if(!(s.file.byteLength>r+n)){e.next=22;break}t.chunk=s.file.subarray(r,n),e.next=27;break;case 22:if(void 0!==t.size){e.next=26;break}t.chunk=s.file.subarray(r),e.next=27;break;case 26:throw R("Segment unreachable: "+JSON.stringify(t));case 27:return e.abrupt("return",t.chunk);case 28:case"end":return e.stop()}}),e,null,[[7,13]])})));return function(t){return e.apply(this,arguments)}}()),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=r,this.parsers=a}return s(e,[{key:"createParser",value:function(e,t){var r=new(z.get(e))(t,this.options,this.file);return this.parsers[e]=r}}]),e}(),Ie=function(){function e(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;i(this,e),u(this,"errors",[]),u(this,"raw",new Map),u(this,"handleError",(function(e){if(!r.options.silentErrors)throw e;r.errors.push(e.message)})),this.chunk=this.normalizeInput(t),this.file=a,this.type=this.constructor.type,this.globalOptions=this.options=n,this.localOptions=n[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}return s(e,[{key:"normalizeInput",value:function(e){return e instanceof V?e:new V(e)}}],[{key:"findPosition",value:function(e,t){var r=e.getUint16(t+2)+2,n="function"==typeof this.headerLength?this.headerLength(e,t,r):this.headerLength,i=t+n,a=r-n;return{offset:t,length:r,headerLength:n,start:i,size:a,end:i+a}}},{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new pe(u({},this.type,t)),n=new this(e,r);return n.parse()}}]),s(e,[{key:"translate",value:function(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}},{key:"translateBlock",value:function(e,t){var r=ee.get(t),n=$.get(t),i=Z.get(t),a=this.options[t],s=a.reviveValues&&r,u=a.translateValues&&n,o=a.translateKeys&&i,f={},l=!0,c=!1,h=void 0;try{for(var p,d=e[Symbol.iterator]();!(l=(p=d.next()).done);l=!0){var y=g(p.value,2),v=y[0],k=y[1];s&&r.has(v)?k=r.get(v)(k):u&&n.has(v)&&(k=this.translateValue(k,n.get(v))),o&&i.has(v)&&(v=i.get(v)||v),f[v]=k}}catch(e){c=!0,h=e}finally{try{l||null==d.return||d.return()}finally{if(c)throw h}}return f}},{key:"translateValue",value:function(e,t){return t[e]||e}},{key:"assignToOutput",value:function(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}},{key:"assignObjectToOutput",value:function(e,t,r){if(this.globalOptions.mergeOutput)return Object.assign(e,r);e[t]?Object.assign(e[t],r):e[t]=r}},{key:"output",get:function(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}}]),e}();u(Ie,"headerLength",4),u(Ie,"type",void 0),u(Ie,"multiSegment",!1),u(Ie,"canHandle",(function(){return!1}));function Te(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function Le(e){return e>=224&&e<=239}function je(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=z[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=g(a.value,2),o=u[0];if(u[1].canHandle(e,t))return o}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}var ze=function(e){function t(){var e,r;i(this,t);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return u(d(r=y(this,(e=f(t)).call.apply(e,[this].concat(a)))),"appSegments",[]),u(d(r),"jpegSegments",[]),u(d(r),"unknownSegments",[]),r}var r,a,l,c;return o(t,e),s(t,[{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.findAppSegments();case 2:return e.next=4,this.readSegments();case 4:this.mergeMultiSegments(),this.createParsers();case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"readSegments",value:(c=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.appSegments.map(this.ensureSegmentChunk),e.next=3,Promise.all(t);case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"setupSegmentFinderArgs",value:function(e){var t=this;!0===e?(this.findAll=!0,this.wanted=new Set(z.keyList())):(e=void 0===e?z.keyList().filter((function(e){return t.options[e].enabled})):e.filter((function(e){return t.options[e].enabled&&z.has(e)})),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}},{key:"findAppSegments",value:(l=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a,s,u,o,f,l,c,h,p,d,y,v,g,k=this,b=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=b.length>0&&void 0!==b[0]?b[0]:0,r=b.length>1?b[1]:void 0,this.setupSegmentFinderArgs(r),n=this.file,i=this.findAll,a=this.wanted,s=this.remaining,i){e.next=37;break}u=!0,o=!1,f=void 0,e.prev=8,l=a[Symbol.iterator]();case 10:if(u=(c=l.next()).done){e.next=23;break}if(h=c.value,p=z.get(h),d=this.options[h],!p.multiSegment||!d.multiSegment){e.next=20;break}if(i=!0,!this.file.chunked){e.next=19;break}return e.next=19,this.file.readWhole();case 19:return e.abrupt("break",23);case 20:u=!0,e.next=10;break;case 23:e.next=29;break;case 25:e.prev=25,e.t0=e.catch(8),o=!0,f=e.t0;case 29:e.prev=29,e.prev=30,u||null==l.return||l.return();case 32:if(e.prev=32,!o){e.next=35;break}throw f;case 35:return e.finish(32);case 36:return e.finish(29);case 37:if(t=this._findAppSegments(t,n.byteLength,i,a,s),!this.options.onlyTiff){e.next=40;break}return e.abrupt("return");case 40:if(!n.chunked){e.next=59;break}y=!1;case 42:if(!(s.size>0)||y||!n.canReadNextChunk&&!this.unfinishedMultiSegment){e.next=59;break}if(v=n.nextChunkOffset,g=this.appSegments.some((function(e){return!k.file.available(e.offset||e.start,e.length||e.size)})),!(t>v)||g){e.next=51;break}return e.next=48,n.readNextChunk(t);case 48:y=!e.sent,e.next=54;break;case 51:return e.next=53,n.readNextChunk(v);case 53:y=!e.sent;case 54:if(void 0!==(t=this._findAppSegments(t,n.byteLength))){e.next=57;break}return e.abrupt("return");case 57:e.next=42;break;case 59:case"end":return e.stop()}}),e,this,[[8,25,29,37],[30,,32,36]])}))),function(){return l.apply(this,arguments)})},{key:"_findAppSegments",value:function(e,t){for(var r,n,i,a,s,u,o=this.file,f=this.findAll,l=this.wanted,c=this.remaining,h=this.options;e<t;e++)if(255===o.getUint8(e))if(Le(r=o.getUint8(e+1))){if(n=o.getUint16(e+2),(i=je(o,e))&&l.has(i)&&(s=(a=z.get(i)).findPosition(o,e),u=h[i],s.type=i,this.appSegments.push(s),!f&&(a.multiSegment&&u.multiSegment?(this.unfinishedMultiSegment=s.chunkNumber<s.chunkCount,this.unfinishedMultiSegment||c.delete(i)):c.delete(i),0===c.size)))break;h.recordUnknownSegments&&((s=Ie.findPosition(o,e)).marker=r,this.unknownSegments.push(s)),e+=n+1}else if(Te(r)){if(n=o.getUint16(e+2),218===r&&!1!==h.stopAfterSos)return;h.recordJpegSegments&&this.jpegSegments.push({offset:e,length:n,marker:r}),e+=n+1}return e}},{key:"mergeMultiSegments",value:function(){var e=this;if(this.appSegments.some((function(e){return e.multiSegment}))){var t=function(e,t){for(var r,n,i,a=new Map,s=0;s<e.length;s++)r=e[s],n=r[t],a.has(n)?i=a.get(n):a.set(n,i=[]),i.push(r);return Array.from(a.entries())}(this.appSegments,"type");this.mergedAppSegments=t.map((function(t){var r=g(t,2),n=r[0],i=r[1],a=z.get(n,e.options);return a.handleMultiSegments?{type:n,chunk:a.handleMultiSegments(i)}:i[0]}))}}},{key:"createParsers",value:(a=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a,s,u,o,f,l,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.mergedAppSegments||this.appSegments,r=!0,n=!1,i=void 0,e.prev=4,a=t[Symbol.iterator]();case 6:if(r=(s=a.next()).done){e.next=16;break}if(u=s.value,o=u.type,f=u.chunk,this.options[o].enabled){e.next=11;break}return e.abrupt("continue",13);case 11:(l=this.parsers[o])&&l.append||l||(c=z.get(o,this.options),h=new c(f,this.options,this.file),this.parsers[o]=h);case 13:r=!0,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),n=!0,i=e.t0;case 22:e.prev=22,e.prev=23,r||null==a.return||a.return();case 25:if(e.prev=25,!n){e.next=28;break}throw i;case 28:return e.finish(25);case 29:return e.finish(22);case 30:case"end":return e.stop()}}),e,this,[[4,18,22,30],[23,,25,29]])}))),function(){return a.apply(this,arguments)})},{key:"getSegment",value:function(e){return this.appSegments.find((function(t){return t.type===e}))}},{key:"getOrFindSegment",value:(r=n(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(r=this.getSegment(t))){e.next=5;break}return e.next=4,this.findAppSegments(0,[t]);case 4:r=this.getSegment(t);case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})}]),t}(Ve);j.set("jpeg",ze);var Fe=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];var Pe=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}var r,a,u,l,c,h,p;return o(t,e),s(t,[{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.parseHeader(),!this.options.ifd0.enabled){e.next=4;break}return e.next=4,this.parseIfd0Block();case 4:if(!this.options.exif.enabled){e.next=7;break}return e.next=7,this.parseExifBlock().catch(this.handleError);case 7:if(!this.options.gps.enabled){e.next=10;break}return e.next=10,this.parseGpsBlock().catch(this.handleError);case 10:if(!this.options.interop.enabled){e.next=13;break}return e.next=13,this.parseInteropBlock().catch(this.handleError);case 13:if(!this.options.ifd1.enabled){e.next=16;break}return e.next=16,this.parseThumbnailBlock().catch(this.handleError);case 16:return e.abrupt("return",this.createOutput());case 17:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"findIfd0Offset",value:function(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}},{key:"findIfd1Offset",value:function(){if(void 0===this.ifd1Offset){this.findIfd0Offset();var e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}},{key:"parseBlock",value:function(e,t){var r=new Map;return this[t]=r,this.parseTags(e,t,r),r}},{key:"parseIfd0Block",value:(p=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.ifd0){e.next=2;break}return e.abrupt("return");case 2:if(this.findIfd0Offset(),!(this.ifd0Offset<8)){e.next=5;break}throw R("Invalid EXIF data: IFD0 offset should be less than 8");case 5:if(this.file.chunked||!(this.ifd0Offset>this.file.byteLength)){e.next=7;break}throw R("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));case 7:if(!this.file.isTiff){e.next=10;break}return e.next=10,this.file.ensureChunk(this.ifd0Offset,A(this.options));case 10:if(0!==(t=this.parseBlock(this.ifd0Offset,"ifd0")).size){e.next=13;break}return e.abrupt("return");case 13:return this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),e.abrupt("return",t);case 21:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"ensureBlockChunk",value:(h=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.file.isTiff){e.next=3;break}return e.next=3,this.file.ensureChunk(t,r);case 3:t>this.chunk.byteLength&&(this.chunk=V.from(this.file,this.le));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"parseExifBlock",value:(c=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.exif){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.exifOffset){e.next=7;break}return e.abrupt("return");case 7:if(!this.file.isTiff){e.next=10;break}return e.next=10,this.file.ensureChunk(this.exifOffset,A(this.options));case 10:return t=this.parseBlock(this.exifOffset,"exif"),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),e.abrupt("return",t);case 18:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"unpack",value:function(e,t){var r=e.get(t);r&&1===r.length&&e.set(t,r[0])}},{key:"parseGpsBlock",value:(l=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.gps){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.gpsOffset){e.next=7;break}return e.abrupt("return");case 7:return(t=this.parseBlock(this.gpsOffset,"gps"))&&t.has(2)&&t.has(4)&&(t.set("latitude",Ee.apply(void 0,k(t.get(2)).concat([t.get(1)]))),t.set("longitude",Ee.apply(void 0,k(t.get(4)).concat([t.get(3)])))),e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"parseInteropBlock",value:(u=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.interop){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset){e.next=8;break}return e.abrupt("return");case 8:return e.abrupt("return",this.parseBlock(this.interopOffset,"interop"));case 9:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"parseThumbnailBlock",value:(a=n(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this.ifd1&&!this.ifd1Parsed){e.next=3;break}return e.abrupt("return");case 3:if(!this.options.mergeOutput||t){e.next=5;break}return e.abrupt("return");case 5:return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),e.abrupt("return",this.ifd1);case 8:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"extractThumbnail",value:(r=n(regeneratorRuntime.mark((function e(){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.headerParsed||this.parseHeader(),this.ifd1Parsed){e.next=4;break}return e.next=4,this.parseThumbnailBlock(!0);case 4:if(void 0!==this.ifd1){e.next=6;break}return e.abrupt("return");case 6:return t=this.ifd1.get(513),r=this.ifd1.get(514),e.abrupt("return",this.chunk.getUint8Array(t,r));case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createOutput",value:function(){var e,t,r,n={},i=!0,a=!1,s=void 0;try{for(var u,o=ie[Symbol.iterator]();!(i=(u=o.next()).done);i=!0)if(!O(e=this[t=u.value]))if(r=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(n,r)}else n[t]=r}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}return this.makerNote&&(n.makerNote=this.makerNote),this.userComment&&(n.userComment=this.userComment),n}},{key:"assignToOutput",value:function(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(var r=0,n=Object.entries(t);r<n.length;r++){var i=g(n[r],2),a=i[0],s=i[1];this.assignObjectToOutput(e,a,s)}}},{key:"image",get:function(){return this.ifd0}},{key:"thumbnail",get:function(){return this.ifd1}}],[{key:"canHandle",value:function(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}}]),t}(function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}return o(t,e),s(t,[{key:"parseHeader",value:function(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw R("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw R("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}},{key:"parseTags",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,n=this.options[t],i=n.pick,a=n.skip,s=(i=new Set(i)).size>0,u=0===a.size,o=this.chunk.getUint16(e);e+=2;for(var f=0;f<o;f++){var l=this.chunk.getUint16(e);if(s){if(i.has(l)&&(r.set(l,this.parseTag(e,l,t)),i.delete(l),0===i.size))break}else!u&&a.has(l)||r.set(l,this.parseTag(e,l,t));e+=12}return r}},{key:"parseTag",value:function(e,t,r){var n,i=this.chunk.getUint16(e+2),a=this.chunk.getUint32(e+4),s=Fe[i];if(s*a<=4?e+=8:e=this.chunk.getUint32(e+8),i<1||i>13)throw R("Invalid TIFF value type. block: ".concat(r.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e));if(e>this.chunk.byteLength)throw R("Invalid TIFF value offset. block: ".concat(r.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===i)return this.chunk.getUint8Array(e,a);if(2===i)return""===(n=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(n=this.chunk.getString(e,a)).trim())?void 0:n;if(7===i)return this.chunk.getUint8Array(e,a);if(1===a)return this.parseTagValue(i,e);for(var u=new(function(e){switch(e){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}}(i))(a),o=s,f=0;f<a;f++)u[f]=this.parseTagValue(i,e),e+=o;return u}},{key:"parseTagValue",value:function(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw R("Invalid tiff type ".concat(e))}}}]),t}(Ie));function Ee(e,t,r,n){var i=e+t/60+r/3600;return"S"!==n&&"W"!==n||(i*=-1),i}u(Pe,"type","tiff"),u(Pe,"headerLength",10),z.set("tiff",Pe),e.Exifr=me,e.Options=pe,e.allFormatters=oe,e.chunkedProps=te,e.createDictionary=function(e,t,r){var n=new Y(r);if(I(n,Y,void 0,["tagKeys","tagValues"]),Array.isArray(t)){var i=!0,a=!1,s=void 0;try{for(var u,o=t[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;e.set(f,n)}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}}else e.set(t,n);return n},e.disableAllOptions=ge,e.extendDictionary=function(e,t,r){var n,i=e.get(t),a=!0,s=!1,u=void 0;try{for(var o,f=r[Symbol.iterator]();!(a=(o=f.next()).done);a=!0)n=o.value,i.set(n[0],n[1])}catch(e){s=!0,u=e}finally{try{a||null==f.return||f.return()}finally{if(s)throw u}}},e.fetchUrlAsArrayBuffer=H,e.fileParsers=j,e.fileReaders=F,e.gps=function(e){return Oe.apply(this,arguments)},e.gpsOnlyOptions=ke,e.inheritables=ue,e.orientation=function(e){return Re.apply(this,arguments)},e.orientationOnlyOptions=be,e.otherSegments=re,e.parse=function(e,t){return we.apply(this,arguments)},e.readBlobAsArrayBuffer=J,e.segmentParsers=z,e.segments=ne,e.segmentsAndBlocks=ae,e.tagKeys=Z,e.tagRevivers=ee,e.tagValues=$,e.thumbnail=function(e){return xe.apply(this,arguments)},e.thumbnailUrl=function(){return Se.apply(this,arguments)},e.tiffBlocks=ie,e.tiffExtractables=se,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}});var n=["prototype","__proto__","caller","arguments","length","name"];Object.getOwnPropertyNames(t).forEach((function(r){-1===n.indexOf(r)&&e[r]!==t[r]&&(e[r]=t[r])})),t&&u(e,t)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function f(e,t,n){return(f=o()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&u(i,n.prototype),i}).apply(null,arguments)}function h(e){var t="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return f(e,arguments,a(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)})(e)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?c(e):t}function d(e,t,n){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}var v=Object.values||function(e){var t=[];for(var n in e)t.push(e[n]);return t},p=Object.entries||function(e){var t=[];for(var n in e)t.push([n,e[n]]);return t},y=Object.assign||function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.forEach((function(t){for(var n in t)e[n]=t[n]})),e},g=Object.fromEntries||function(e){var t={};return k(e).forEach((function(e){var n=e[0],r=e[1];t[n]=r})),t},k=Array.from||function(e){if(e instanceof P){var t=[];return e.forEach((function(e,n){return t.push([n,e])})),t}return Array.prototype.slice.call(e)};function m(e){return-1!==this.indexOf(e)}Array.prototype.includes||(Array.prototype.includes=m),String.prototype.includes||(String.prototype.includes=m),String.prototype.startsWith||(String.prototype.startsWith=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.substring(t,t+e.length)===e}),String.prototype.endsWith||(String.prototype.endsWith=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return this.substring(t-e.length,t)===e});var b="undefined"!=typeof self?self:global,w=b.TextDecoder||function(){function e(){t(this,e)}return r(e,[{key:"decode",value:function(e){var t=String.fromCharCode.apply(null,e);return decodeURIComponent(escape(t))}}]),e}(),A=b.fetch||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,r){var i=new XMLHttpRequest;if(i.open("get",e,!0),i.responseType="arraybuffer",i.onerror=r,t.headers)for(var s in t.headers)i.setRequestHeader(s,t.headers[s]);i.onload=function(){n({ok:i.status>=200&&i.status<300,status:i.status,arrayBuffer:function(){return Promise.resolve(i.response)}})},i.send(null)}))},O=function(e){var t=[];if(Object.defineProperties(t,{size:{get:function(){return this.length}},has:{value:function(e){return-1!==this.indexOf(e)}},add:{value:function(e){this.has(e)||this.push(e)}},delete:{value:function(e){if(this.has(e)){var t=this.indexOf(e);this.splice(t,1)}}}}),Array.isArray(e))for(var n=0;n<e.length;n++)t.add(e[n]);return t},S=function(e){return new P(e)},P=void 0!==b.Map&&void 0!==b.Map.prototype.keys?b.Map:function(){function e(n){if(t(this,e),this.clear(),n)for(var r=0;r<n.length;r++)this.set(n[r][0],n[r][1])}return r(e,[{key:"clear",value:function(){this._map={},this._keys=[]}},{key:"get",value:function(e){return this._map["map_"+e]}},{key:"set",value:function(e,t){return this._map["map_"+e]=t,this._keys.indexOf(e)<0&&this._keys.push(e),this}},{key:"has",value:function(e){return this._keys.indexOf(e)>=0}},{key:"delete",value:function(e){var t=this._keys.indexOf(e);return!(t<0)&&(delete this._map["map_"+e],this._keys.splice(t,1),!0)}},{key:"keys",value:function(){return this._keys.slice(0)}},{key:"values",value:function(){var e=this;return this._keys.map((function(t){return e.get(t)}))}},{key:"entries",value:function(){var e=this;return this._keys.map((function(t){return[t,e.get(t)]}))}},{key:"forEach",value:function(e,t){for(var n=0;n<this._keys.length;n++)e.call(t,this._map["map_"+this._keys[n]],this._keys[n],this)}},{key:"size",get:function(){return this._keys.length}}]),e}(),U="undefined"!=typeof Buffer,x="undefined"!=typeof navigator,B=x&&"undefined"==typeof HTMLImageElement,C=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);var j=function(e){return void 0!==e};function V(e){return void 0===e||(e instanceof P?0===e.size:0===v(e).filter(j).length)}function _(e){var t=new Error(e);return delete t.stack,t}function I(e){var t=function(e){var t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}var T=C?global.BigInt:self.BigInt,L=new w("utf-8");function z(e){return L.decode(e)}var F=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;if(t(this,e),"boolean"==typeof s&&(this.le=s),Array.isArray(n)&&(n=new Uint8Array(n)),0===n)this.byteOffset=0,this.byteLength=0;else if(n instanceof ArrayBuffer){var a=new DataView(n,r,i);this._swapDataView(a)}else if(n instanceof Uint8Array||n instanceof DataView||n instanceof e){var u=n,o=u.byteOffset,f=u.byteLength;if(void 0===i&&(i=f-r),(r+=o)+i>o+f)throw _("Creating view outside of available memory in ArrayBuffer");var h=new DataView(n.buffer,r,i);this._swapDataView(h)}else{if("number"!=typeof n)throw _("Invalid input argument for BufferView: "+n);var c=new DataView(new ArrayBuffer(n));this._swapDataView(c)}}return r(e,null,[{key:"from",value:function(t,n){return t instanceof this&&t.le===n?t:new e(t,void 0,void 0,n)}}]),r(e,[{key:"_swapArrayBuffer",value:function(e){this._swapDataView(new DataView(e))}},{key:"_swapBuffer",value:function(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}},{key:"_swapDataView",value:function(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}},{key:"_lengthToEnd",value:function(e){return this.byteLength-e}},{key:"set",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;if(t instanceof DataView||t instanceof e?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw _("BufferView.set(): Invalid data argument.");var i=this.toUint8();return i.set(t,n),new r(this,n,t.byteLength)}},{key:"subarray",value:function(t,n){return new e(this,t,n=n||this._lengthToEnd(t))}},{key:"toUint8",value:function(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}},{key:"getUint8Array",value:function(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}},{key:"getString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.byteLength,n=this.getUint8Array(e,t);return z(n)}},{key:"getUnicodeString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.byteLength,n=[],r=0;r<t&&e+r<this.byteLength;r+=2)n.push(this.getUint16(e+r));return n.map((function(e){return String.fromCharCode(e)})).join("")}},{key:"getInt8",value:function(e){return this.dataView.getInt8(e)}},{key:"getUint8",value:function(e){return this.dataView.getUint8(e)}},{key:"getInt16",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getInt16(e,t)}},{key:"getInt32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getInt32(e,t)}},{key:"getUint16",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getUint16(e,t)}},{key:"getUint32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getUint32(e,t)}},{key:"getFloat32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat32(e,t)}},{key:"getFloat64",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat64(e,t)}},{key:"getFloat",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat32(e,t)}},{key:"getDouble",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat64(e,t)}},{key:"getUint64",value:function(e){var t=this.getUint32(e),n=this.getUint32(e+4);if(t<1048575)return t<<32|n;if(void 0!==typeof T)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),T(t)<<T(32)|T(n);throw _("Trying to read 64b value but JS can only handle 53b numbers.")}},{key:"getUintBytes",value:function(e,t,n){switch(t){case 1:return this.getUint8(e,n);case 2:return this.getUint16(e,n);case 4:return this.getUint32(e,n);case 8:return this.getUint64(e,n)}}},{key:"getUint",value:function(e,t,n){switch(t){case 8:return this.getUint8(e,n);case 16:return this.getUint16(e,n);case 32:return this.getUint32(e,n);case 64:return this.getUint64(e,n)}}},{key:"toString",value:function(e){return this.dataView.toString(e,this.constructor.name)}},{key:"ensureChunk",value:function(){}}]),e}();function E(e,t){throw _("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}var D=function(e){function n(e){var r;return t(this,n),(r=l(this,a(n).call(this))).kind=e,r}return s(n,e),r(n,[{key:"get",value:function(e,t){return this.has(e)||E(this.kind,e),t&&(e in t||function(e,t){throw _("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||E(this.kind,e)),d(a(n.prototype),"get",this).call(this,e)}},{key:"keyList",value:function(){return k(this.keys())}}]),n}(h(P)),N=new D("file parser"),R=new D("segment parser"),M=new D("file reader");function W(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function K(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var H=W((function(e){return new Promise((function(t,n){var r=new FileReader;r.onloadend=function(){return t(r.result||new ArrayBuffer)},r.onerror=n,r.readAsArrayBuffer(e)}))})),G=W((function(e){return A(e).then((function(e){return e.arrayBuffer()}))})),J=W((function(e,t){return K(t(e),(function(e){return new DataView(e)}))})),X=W((function(e,t,n){var r=new(M.get(n))(e,t);return K(r.read(),(function(){return r}))})),q=W((function(e,t,n,r){if(M.has(n))return X(e,t,n);if(r)return J(e,r);throw _("Parser ".concat(n," is not loaded"))}));function Q(e,t){if((n=e).startsWith("data:")||n.length>1e4)return X(e,t,"base64");if(x)return q(e,t,"url",G);if(C)return X(e,t,"fs");throw _("Invalid input argument");var n}var Y=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"tagKeys",get:function(){return this.allKeys||(this.allKeys=k(this.keys())),this.allKeys}},{key:"tagValues",get:function(){return this.allValues||(this.allValues=k(this.values())),this.allValues}}]),n}(h(P));var Z=S(),$=S(),ee=S(),te=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],ne=["jfif","xmp","icc","iptc"],re=["tiff"].concat(ne),ie=["ifd0","ifd1","exif","gps","interop"],se=[].concat(re,ie),ae=["makerNote","userComment"],ue=["translateKeys","translateValues","reviveValues","multiSegment"],oe=[].concat(ue,["sanitize","mergeOutput"]),fe=function(){function e(){t(this,e)}return r(e,[{key:"translate",get:function(){return this.translateKeys||this.translateValues||this.reviveValues}}]),e}(),he=function(e){function n(e,r,s,u){var o;if(t(this,n),i(c(o=l(this,a(n).call(this))),"enabled",!1),i(c(o),"skip",O()),i(c(o),"pick",O()),i(c(o),"deps",O()),i(c(o),"translateKeys",!1),i(c(o),"translateValues",!1),i(c(o),"reviveValues",!1),o.key=e,o.enabled=r,o.parse=o.enabled,o.applyInheritables(u),o.canBeFiltered=ie.includes(e),o.canBeFiltered&&(o.dict=Z.get(e)),void 0!==s)if(Array.isArray(s))o.parse=o.enabled=!0,o.canBeFiltered&&s.length>0&&o.translateTagSet(s,o.pick);else if("object"==typeof s){if(o.enabled=!0,o.parse=!1!==s.parse,o.canBeFiltered){var f=s.pick,h=s.skip;f&&f.length>0&&o.translateTagSet(f,o.pick),h&&h.length>0&&o.translateTagSet(h,o.skip)}o.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw _("Invalid options argument: ".concat(s));o.parse=o.enabled=s}return o}return s(n,e),r(n,[{key:"needed",get:function(){return this.enabled||this.deps.size>0}}]),r(n,[{key:"applyInheritables",value:function(e){var t,n,r=ue;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)void 0!==(n=e[t=r[i]])&&(this[t]=n)}},{key:"translateTagSet",value:function(e,t){var n,r,i=this.dict,s=i.tagKeys,a=i.tagValues,u=e;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)"string"==typeof(n=u[o])?(-1===(r=a.indexOf(n))&&(r=s.indexOf(Number(n))),-1!==r&&t.add(Number(s[r]))):t.add(n)}},{key:"finalizeFilters",value:function(){!this.enabled&&this.deps.size>0?(this.enabled=!0,ye(this.pick,this.deps)):this.enabled&&this.pick.size>0&&ye(this.pick,this.deps)}}]),n}(fe),ce={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},le=S(),de=function(e){function n(e){var r;if(t(this,n),r=l(this,a(n).call(this)),!0===e)r.setupFromTrue();else if(void 0===e)r.setupFromUndefined();else if(Array.isArray(e))r.setupFromArray(e);else{if("object"!=typeof e)throw _("Invalid options argument ".concat(e));r.setupFromObject(e)}return void 0===r.firstChunkSize&&(r.firstChunkSize=x?r.firstChunkSizeBrowser:r.firstChunkSizeNode),r.mergeOutput&&(r.ifd1.enabled=!1),r.filterNestedSegmentTags(),r.traverseTiffDependencyTree(),r.checkLoadedPlugins(),r}return s(n,e),r(n,null,[{key:"useCached",value:function(e){var t=le.get(e);return void 0!==t?t:(t=new this(e),le.set(e,t),t)}}]),r(n,[{key:"setupFromUndefined",value:function(){var e,t=te;Array.isArray(t)||("function"==typeof t.entries&&(t=t.entries()),t=k(t));for(var n=0;n<t.length;n++)this[e=t[n]]=ce[e];var r=oe;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)this[e=r[i]]=ce[e];var s=ae;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)this[e=s[a]]=ce[e];var u=se;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)this[e=u[o]]=new he(e,ce[e],void 0,this)}},{key:"setupFromTrue",value:function(){var e,t=te;Array.isArray(t)||("function"==typeof t.entries&&(t=t.entries()),t=k(t));for(var n=0;n<t.length;n++)this[e=t[n]]=ce[e];var r=oe;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)this[e=r[i]]=ce[e];var s=ae;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)this[e=s[a]]=!0;var u=se;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)this[e=u[o]]=new he(e,!0,void 0,this)}},{key:"setupFromArray",value:function(e){var t,n=te;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++)this[t=n[r]]=ce[t];var i=oe;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)this[t=i[s]]=ce[t];var a=ae;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++)this[t=a[u]]=ce[t];var o=se;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)this[t=o[f]]=new he(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,ie)}},{key:"setupFromObject",value:function(e){var t;ie.ifd0=ie.ifd0||ie.image,ie.ifd1=ie.ifd1||ie.thumbnail,y(this,e);var n=te;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++)this[t=n[r]]=pe(e[t],ce[t]);var i=oe;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)this[t=i[s]]=pe(e[t],ce[t]);var a=ae;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++)this[t=a[u]]=pe(e[t],ce[t]);var o=re;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)this[t=o[f]]=new he(t,ce[t],e[t],this);var h=ie;Array.isArray(h)||("function"==typeof h.entries&&(h=h.entries()),h=k(h));for(var c=0;c<h.length;c++)this[t=h[c]]=new he(t,ce[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,ie,se),!0===e.tiff?this.batchEnableWithBool(ie,!0):!1===e.tiff?this.batchEnableWithUserValue(ie,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,ie):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,ie)}},{key:"batchEnableWithBool",value:function(e,t){var n=e;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){this[n[r]].enabled=t}}},{key:"batchEnableWithUserValue",value:function(e,t){var n=e;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=t[i];this[i].enabled=!1!==s&&void 0!==s}}},{key:"setupGlobalFilters",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;if(e&&e.length){var i=r;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){var a=i[s];this[a].enabled=!1}var u=ve(e,n),o=u;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++){var h=o[f],c=h[0],l=h[1];ye(this[c].pick,l),this[c].enabled=!0}}else if(t&&t.length){var d=ve(t,n),v=d;Array.isArray(v)||("function"==typeof v.entries&&(v=v.entries()),v=k(v));for(var p=0;p<v.length;p++){var y=v[p],g=y[0],m=y[1];ye(this[g].skip,m)}}}},{key:"filterNestedSegmentTags",value:function(){var e=this.ifd0,t=this.exif,n=this.xmp,r=this.iptc,i=this.icc;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),n.enabled||e.skip.add(700),r.enabled||e.skip.add(33723),i.enabled||e.skip.add(34675)}},{key:"traverseTiffDependencyTree",value:function(){var e=this,t=this.ifd0,n=this.exif,r=this.gps;this.interop.needed&&(n.deps.add(40965),t.deps.add(40965)),n.needed&&t.deps.add(34665),r.needed&&t.deps.add(34853),this.tiff.enabled=ie.some((function(t){return!0===e[t].enabled}))||this.makerNote||this.userComment;var i=ie;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){this[i[s]].finalizeFilters()}}},{key:"checkLoadedPlugins",value:function(){var e=re;Array.isArray(e)||("function"==typeof e.entries&&(e=e.entries()),e=k(e));for(var t=0;t<e.length;t++){var n=e[t];this[n].enabled&&!R.has(n)&&E("segment parser",n)}}},{key:"onlyTiff",get:function(){var e=this;return!ne.map((function(t){return e[t].enabled})).some((function(e){return!0===e}))&&this.tiff.enabled}}]),n}(fe);function ve(e,t){var n,r,i,s=[],a=t;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++){r=a[u],n=[];var o=Z.get(r);Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)i=o[f],(e.includes(i[0])||e.includes(i[1]))&&n.push(i[0]);n.length&&s.push([r,n])}return s}function pe(e,t){return void 0!==e?e:void 0!==t?t:void 0}function ye(e,t){var n=t;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r];e.add(i)}}i(de,"default",ce);var ge={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},ke=y({},ge,{firstChunkSize:4e4,gps:[1,2,3,4]}),me=y({},ge,{firstChunkSize:4e4,ifd0:[274]});function be(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function we(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function Ae(){}var Oe=function(){function e(n){t(this,e),i(this,"parsers",{}),this.options=de.useCached(n)}return r(e,[{key:"setup",value:function(){if(!this.fileParser){var e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=N.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=N.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;var t=e.getUint16(2);if(t>50)return!1;for(var n=16,r=[];n<t;)r.push(e.getString(n,4)),n+=4;return r.includes("heic")}(this.file))throw _("Unknown file format");this.file.isHeic=!0,e=N.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}}},{key:"read",value:function(e){try{var t=this;return be(function(e,t){if("string"==typeof e)return Q(e,t);if(x&&!B&&e instanceof HTMLImageElement)return Q(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new F(e);if(x&&e instanceof Blob)return q(e,t,"blob",H);throw _("Invalid input argument")}(e,t.options),(function(e){t.file=e}))}catch(e){return Promise.reject(e)}}},{key:"parse",value:function(){try{var e=this;return e.setup(),be(e.fileParser.parse(),(function(){var t,n={},r=[],i=v(e.parsers).map((t=function(t){var i;return we((function(){return e.options.silentErrors?(n=function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return be(t.parse(),(function(e){i=e}))}),(function(e){r.push(e)})),s=function(){t.errors.length&&r.push.apply(r,t.errors)},n&&n.then?n.then(s):s(n)):be(t.parse(),(function(e){i=e}));var n,s}),(function(){t.assignToOutput(n,i)}))},function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(t.apply(this,e))}catch(e){return Promise.reject(e)}}));return be(Promise.all(i),(function(){var t;return e.options.silentErrors&&r.length>0&&(n.errors=r),n=V(t=n)?void 0:t,e.file.close&&e.file.close(),n}))}))}catch(e){return Promise.reject(e)}}},{key:"extractThumbnail",value:function(){try{var e=this;e.setup();var t,n=R.get("tiff",e.options);return we((function(){if(!e.file.isTiff)return function(e){var t=e();if(t&&t.then)return t.then(Ae)}((function(){if(e.file.isJpeg)return be(e.fileParser.getOrFindSegment("tiff"),(function(e){t=e}))}));t={start:0,type:"tiff"}}),(function(){if(void 0!==t)return be(e.fileParser.ensureSegmentChunk(t),(function(t){return be((e.parsers.tiff=new n(t,e.options,e.file)).extractThumbnail(),(function(t){return e.file.close&&e.file.close(),t}))}))}))}catch(e){return Promise.reject(e)}}}]),e}();function Se(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function Pe(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}var Ue=Pe((function(e){var t=new Oe(me);return Se(t.read(e),(function(){return Se(t.parse(),(function(e){if(e&&e.ifd0)return e.ifd0[274]}))}))})),xe=Pe((function(e){var t=new Oe(ke);return Se(t.read(e),(function(){return Se(t.parse(),(function(e){if(e&&e.gps){var t=e.gps;return{latitude:t.latitude,longitude:t.longitude}}}))}))})),Be=Pe((function(){var e=this;return Se(e.thumbnail.apply(e,arguments),(function(e){if(void 0!==e){var t=new Blob([e]);return URL.createObjectURL(t)}}))})),Ce=Pe((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.ifd1=!0,t.mergeOutput=!0;var n=new Oe(t);return Se(n.read(e),(function(){return Se(n.extractThumbnail(),(function(e){return e&&U?Buffer.from(e):e}))}))})),je=Pe((function(e,t){var n=new Oe(t);return Se(n.read(e),(function(){return n.parse()}))}));function Ve(){}var _e=function(e){function n(){var e,r;t(this,n);for(var s=arguments.length,u=new Array(s),o=0;o<s;o++)u[o]=arguments[o];return i(c(r=l(this,(e=a(n)).call.apply(e,[this].concat(u)))),"ranges",new Ie),0!==r.byteLength&&r.ranges.add(0,r.byteLength),r}return s(n,e),r(n,[{key:"_tryExtend",value:function(e,t,n){if(0===e&&0===this.byteLength&&n){var r=new DataView(n.buffer||n,n.byteOffset,n.byteLength);this._swapDataView(r)}else{var i=e+t;if(i>this.byteLength){var s=this._extend(i).dataView;this._swapDataView(s)}}}},{key:"_extend",value:function(e){var t;t=U?Buffer.allocUnsafe(e):new Uint8Array(e);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:n}}},{key:"subarray",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=t||this._lengthToEnd(e),r&&this._tryExtend(e,t),this.ranges.add(e,t),d(a(n.prototype),"subarray",this).call(this,e,t)}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this._tryExtend(t,e.byteLength,e);var i=d(a(n.prototype),"set",this).call(this,e,t);return this.ranges.add(t,i.byteLength),i}},{key:"ensureChunk",value:function(e,t){try{if(!this.chunked)return;if(this.ranges.available(e,t))return;return function(e,t){if(!t)return e&&e.then?e.then(Ve):Promise.resolve()}(this.readChunk(e,t))}catch(e){return Promise.reject(e)}}},{key:"available",value:function(e,t){return this.ranges.available(e,t)}}]),n}(F),Ie=function(){function e(){t(this,e),i(this,"list",[])}return r(e,[{key:"add",value:function(e,t){var n=e+t,r=this.list.filter((function(t){return Te(e,t.offset,n)||Te(e,t.end,n)}));if(r.length>0){e=Math.min.apply(Math,[e].concat(r.map((function(e){return e.offset})))),t=(n=Math.max.apply(Math,[n].concat(r.map((function(e){return e.end})))))-e;var i=r.shift();i.offset=e,i.length=t,i.end=n,this.list=this.list.filter((function(e){return!r.includes(e)}))}else this.list.push({offset:e,length:t,end:n})}},{key:"available",value:function(e,t){var n=e+t;return this.list.some((function(t){return t.offset<=e&&n<=t.end}))}},{key:"length",get:function(){return this.list.length}}]),e}();function Te(e,t,n){return e<=t&&t<=n}function Le(){}function ze(e,t){if(!t)return e&&e.then?e.then(Le):Promise.resolve()}function Fe(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var Ee=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"readWhole",value:function(){try{var e=this;return e.chunked=!1,Fe(H(e.input),(function(t){e._swapArrayBuffer(t)}))}catch(e){return Promise.reject(e)}}},{key:"readChunked",value:function(){return this.chunked=!0,this.size=this.input.size,d(a(n.prototype),"readChunked",this).call(this)}},{key:"_readChunk",value:function(e,t){try{var n=this,r=t?e+t:void 0,i=n.input.slice(e,r);return Fe(H(i),(function(t){return n.set(t,e,!0)}))}catch(e){return Promise.reject(e)}}}]),n}(function(e){function n(e,r){var s;return t(this,n),i(c(s=l(this,a(n).call(this,0))),"chunksRead",0),s.input=e,s.options=r,s}return s(n,e),r(n,[{key:"readWhole",value:function(){try{return this.chunked=!1,ze(this.readChunk(this.nextChunkOffset))}catch(e){return Promise.reject(e)}}},{key:"readChunked",value:function(){try{return this.chunked=!0,ze(this.readChunk(0,this.options.firstChunkSize))}catch(e){return Promise.reject(e)}}},{key:"readNextChunk",value:function(e){try{if(void 0===e&&(e=this.nextChunkOffset),this.fullyRead)return this.chunksRead++,!1;var t=this.options.chunkSize;return n=this.readChunk(e,t),r=function(e){return!!e&&e.byteLength===t},i?r?r(n):n:(n&&n.then||(n=Promise.resolve(n)),r?n.then(r):n)}catch(e){return Promise.reject(e)}var n,r,i}},{key:"readChunk",value:function(e,t){try{if(this.chunksRead++,0===(t=this.safeWrapAddress(e,t)))return;return this._readChunk(e,t)}catch(e){return Promise.reject(e)}}},{key:"safeWrapAddress",value:function(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}},{key:"read",value:function(){return this.options.chunked?this.readChunked():this.readWhole()}},{key:"close",value:function(){}},{key:"nextChunkOffset",get:function(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}},{key:"canReadNextChunk",get:function(){return this.chunksRead<this.options.chunkLimit}},{key:"fullyRead",get:function(){return void 0!==this.size&&this.nextChunkOffset===this.size}}]),n}(_e));M.set("blob",Ee);var De=function(){function e(n,r,s){var a,u=this;t(this,e),i(this,"ensureSegmentChunk",(a=function(e){var t,n,r,i=e.start,s=e.size||65536;return t=function(){if(u.file.chunked)return function(){if(!u.file.available(i,s))return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return t=u.file.readChunk(i,s),n=function(t){e.chunk=t},r?n?n(t):t:(t&&t.then||(t=Promise.resolve(t)),n?t.then(n):t);var t,n,r}),(function(t){throw _("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}));e.chunk=u.file.subarray(i,s)}();if(u.file.byteLength>i+s)e.chunk=u.file.subarray(i,s);else{if(void 0!==e.size)throw _("Segment unreachable: "+JSON.stringify(e));e.chunk=u.file.subarray(i)}},n=function(t){return e.chunk},(r=t())&&r.then?r.then(n):n(r)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(a.apply(this,e))}catch(e){return Promise.reject(e)}})),this.extendOptions&&this.extendOptions(n),this.options=n,this.file=r,this.parsers=s}return r(e,[{key:"createParser",value:function(e,t){var n=new(R.get(e))(t,this.options,this.file);return this.parsers[e]=n}}]),e}(),Ne=function(){function e(n){var r=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;t(this,e),i(this,"errors",[]),i(this,"raw",S()),i(this,"handleError",(function(e){if(!r.options.silentErrors)throw e;r.errors.push(e.message)})),this.chunk=this.normalizeInput(n),this.file=a,this.type=this.constructor.type,this.globalOptions=this.options=s,this.localOptions=s[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}return r(e,[{key:"normalizeInput",value:function(e){return e instanceof F?e:new F(e)}}],[{key:"findPosition",value:function(e,t){var n=e.getUint16(t+2)+2,r="function"==typeof this.headerLength?this.headerLength(e,t,n):this.headerLength,i=t+r,s=n-r;return{offset:t,length:n,headerLength:r,start:i,size:s,end:i+s}}},{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new de(i({},this.type,t)),r=new this(e,n);return r.parse()}}]),r(e,[{key:"translate",value:function(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}},{key:"translateBlock",value:function(e,t){var n=ee.get(t),r=$.get(t),i=Z.get(t),s=this.options[t],a=s.reviveValues&&!!n,u=s.translateValues&&!!r,o=s.translateKeys&&!!i,f={},h=e;Array.isArray(h)||("function"==typeof h.entries&&(h=h.entries()),h=k(h));for(var c=0;c<h.length;c++){var l=h[c],d=l[0],v=l[1];a&&n.has(d)?v=n.get(d)(v):u&&r.has(d)&&(v=this.translateValue(v,r.get(d))),o&&i.has(d)&&(d=i.get(d)||d),f[d]=v}return f}},{key:"translateValue",value:function(e,t){return t[e]||e}},{key:"assignToOutput",value:function(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}},{key:"assignObjectToOutput",value:function(e,t,n){if(this.globalOptions.mergeOutput)return y(e,n);e[t]?y(e[t],n):e[t]=n}},{key:"output",get:function(){return this.translated?this.translated:this.raw?g(this.raw):void 0}}]),e}();function Re(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}i(Ne,"headerLength",4),i(Ne,"type",void 0),i(Ne,"multiSegment",!1),i(Ne,"canHandle",(function(){return!1}));function Me(){}function We(e,t){if(!t)return e&&e.then?e.then(Me):Promise.resolve()}function Ke(e){var t=e();if(t&&t.then)return t.then(Me)}function He(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function Ge(e,t,n){if(!e.s){if(n instanceof Je){if(!n.s)return void(n.o=Ge.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Ge.bind(null,e,t),Ge.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var Je=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var s=1&i?t:n;if(s){try{Ge(r,1,s(this.v))}catch(e){Ge(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?Ge(r,1,t?t(i):i):n?Ge(r,1,n(i)):Ge(r,2,i)}catch(e){Ge(r,2,e)}},r},e}();function Xe(e){return e instanceof Je&&1&e.s}function qe(e,t,n){for(var r;;){var i=e();if(Xe(i)&&(i=i.v),!i)return s;if(i.then){r=0;break}var s=n();if(s&&s.then){if(!Xe(s)){r=1;break}s=s.s}if(t){var a=t();if(a&&a.then&&!Xe(a)){r=2;break}}}var u=new Je,o=Ge.bind(null,u,2);return(0===r?i.then(h):1===r?s.then(f):a.then(c)).then(void 0,o),u;function f(r){s=r;do{if(t&&(a=t())&&a.then&&!Xe(a))return void a.then(c).then(void 0,o);if(!(i=e())||Xe(i)&&!i.v)return void Ge(u,1,s);if(i.then)return void i.then(h).then(void 0,o);Xe(s=n())&&(s=s.v)}while(!s||!s.then);s.then(f).then(void 0,o)}function h(e){e?(s=n())&&s.then?s.then(f).then(void 0,o):f(s):Ge(u,1,s)}function c(){(i=e())?i.then?i.then(h).then(void 0,o):h(i):Ge(u,1,s)}}function Qe(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function Ye(e){return e>=224&&e<=239}function Ze(e,t){var n=R;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=i[0];if(i[1].canHandle(e,t))return s}}var $e=function(e){function n(){var e,r;t(this,n);for(var s=arguments.length,u=new Array(s),o=0;o<s;o++)u[o]=arguments[o];return i(c(r=l(this,(e=a(n)).call.apply(e,[this].concat(u)))),"appSegments",[]),i(c(r),"jpegSegments",[]),i(c(r),"unknownSegments",[]),r}return s(n,e),r(n,[{key:"parse",value:function(){try{var e=this;return Re(e.findAppSegments(),(function(){return Re(e.readSegments(),(function(){e.mergeMultiSegments(),e.createParsers()}))}))}catch(e){return Promise.reject(e)}}},{key:"readSegments",value:function(){try{var e=this.appSegments.map(this.ensureSegmentChunk);return We(Promise.all(e))}catch(e){return Promise.reject(e)}}},{key:"setupSegmentFinderArgs",value:function(e){var t=this;!0===e?(this.findAll=!0,this.wanted=O(R.keyList())):(e=void 0===e?R.keyList().filter((function(e){return t.options[e].enabled})):e.filter((function(e){return t.options[e].enabled&&R.has(e)})),this.findAll=!1,this.remaining=O(e),this.wanted=O(e)),this.unfinishedMultiSegment=!1}},{key:"findAppSegments",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;try{var n=this;n.setupSegmentFinderArgs(t);var r=n.file,i=n.findAll,s=n.wanted,a=n.remaining;return He((function(){if(!i&&n.file.chunked)return i=k(s).some((function(e){var t=R.get(e),r=n.options[e];return t.multiSegment&&r.multiSegment})),Ke((function(){if(i)return We(n.file.readWhole())}))}),(function(){var t=!1;if(e=n._findAppSegments(e,r.byteLength,i,s,a),!n.options.onlyTiff)return function(){if(r.chunked){var i=!1;return qe((function(){return!t&&a.size>0&&!i&&(!!r.canReadNextChunk||!!n.unfinishedMultiSegment)}),void 0,(function(){var s=r.nextChunkOffset,a=n.appSegments.some((function(e){return!n.file.available(e.offset||e.start,e.length||e.size)}));return He((function(){return e>s&&!a?Re(r.readNextChunk(e),(function(e){i=!e})):Re(r.readNextChunk(s),(function(e){i=!e}))}),(function(){void 0===(e=n._findAppSegments(e,r.byteLength))&&(t=!0)}))}))}}()}))}catch(e){return Promise.reject(e)}}},{key:"_findAppSegments",value:function(e,t){for(var n,r,i,s,a,u,o=this.file,f=this.findAll,h=this.wanted,c=this.remaining,l=this.options;e<t;e++)if(255===o.getUint8(e))if(Ye(n=o.getUint8(e+1))){if(r=o.getUint16(e+2),(i=Ze(o,e))&&h.has(i)&&(a=(s=R.get(i)).findPosition(o,e),u=l[i],a.type=i,this.appSegments.push(a),!f&&(s.multiSegment&&u.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||c.delete(i)):c.delete(i),0===c.size)))break;l.recordUnknownSegments&&((a=Ne.findPosition(o,e)).marker=n,this.unknownSegments.push(a)),e+=r+1}else if(Qe(n)){if(r=o.getUint16(e+2),218===n&&!1!==l.stopAfterSos)return;l.recordJpegSegments&&this.jpegSegments.push({offset:e,length:r,marker:n}),e+=r+1}return e}},{key:"mergeMultiSegments",value:function(){var e=this;if(this.appSegments.some((function(e){return e.multiSegment}))){var t=function(e,t){for(var n,r,i,s=S(),a=0;a<e.length;a++)n=e[a],r=n[t],s.has(r)?i=s.get(r):s.set(r,i=[]),i.push(n);return k(s)}(this.appSegments,"type");this.mergedAppSegments=t.map((function(t){var n=t[0],r=t[1],i=R.get(n,e.options);return i.handleMultiSegments?{type:n,chunk:i.handleMultiSegments(r)}:r[0]}))}}},{key:"createParsers",value:function(){try{var e=this.mergedAppSegments||this.appSegments;Array.isArray(e)||("function"==typeof e.entries&&(e=e.entries()),e=k(e));for(var t=0;t<e.length;t++){var n=e[t],r=n.type,i=n.chunk;if(this.options[r].enabled){var s=this.parsers[r];if(s&&s.append);else if(!s){var a=new(R.get(r,this.options))(i,this.options,this.file);this.parsers[r]=a}}}return Re()}catch(e){return Promise.reject(e)}}},{key:"getSegment",value:function(e){return this.appSegments.find((function(t){return t.type===e}))}},{key:"getOrFindSegment",value:function(e){try{var t=this,n=t.getSegment(e);return He((function(){if(void 0===n)return Re(t.findAppSegments(0,[e]),(function(){n=t.getSegment(e)}))}),(function(){return n}))}catch(e){return Promise.reject(e)}}}]),n}(De);function et(){}N.set("jpeg",$e);function tt(e,t){if(!t)return e&&e.then?e.then(et):Promise.resolve()}function nt(e,t){var n=e();return n&&n.then?n.then(t):t(n)}var rt=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];var it=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"parse",value:function(){try{var e=this;return e.parseHeader(),nt((function(){if(e.options.ifd0.enabled)return tt(e.parseIfd0Block())}),(function(){return nt((function(){if(e.options.exif.enabled)return tt(e.saveParseBlock("parseExifBlock"))}),(function(){return nt((function(){if(e.options.gps.enabled)return tt(e.saveParseBlock("parseGpsBlock"))}),(function(){return nt((function(){if(e.options.interop.enabled)return tt(e.saveParseBlock("parseInteropBlock"))}),(function(){return nt((function(){if(e.options.ifd1.enabled)return tt(e.saveParseBlock("parseThumbnailBlock"))}),(function(){return e.createOutput()}))}))}))}))}))}catch(e){return Promise.reject(e)}}},{key:"saveParseBlock",value:function(e){try{var t=this;return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return n=t[e](),i?r?r(n):n:(n&&n.then||(n=Promise.resolve(n)),r?n.then(r):n);var n,r,i}),(function(e){t.handleError(e)}))}catch(e){return Promise.reject(e)}}},{key:"findIfd0Offset",value:function(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}},{key:"findIfd1Offset",value:function(){if(void 0===this.ifd1Offset){this.findIfd0Offset();var e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}},{key:"parseBlock",value:function(e,t){var n=S();return this[t]=n,this.parseTags(e,t,n),n}},{key:"parseIfd0Block",value:function(){try{var e=this;if(e.ifd0)return;if(e.findIfd0Offset(),e.ifd0Offset<8)throw _("Invalid EXIF data: IFD0 offset should be less than 8");if(!e.file.chunked&&e.ifd0Offset>e.file.byteLength)throw _("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(e.ifd0Offset,", file.byteLength: ").concat(e.file.byteLength));return nt((function(){if(e.file.isTiff)return tt(e.file.ensureChunk(e.ifd0Offset,I(e.options)))}),(function(){var t=e.parseBlock(e.ifd0Offset,"ifd0");if(0!==t.size)return e.exifOffset=t.get(34665),e.interopOffset=t.get(40965),e.gpsOffset=t.get(34853),e.xmp=t.get(700),e.iptc=t.get(33723),e.icc=t.get(34675),e.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t}))}catch(e){return Promise.reject(e)}}},{key:"ensureBlockChunk",value:function(e,t){try{var n=this;return nt((function(){if(n.file.isTiff)return tt(n.file.ensureChunk(e,t))}),(function(){e>n.chunk.byteLength&&(n.chunk=F.from(n.file,n.le))}))}catch(e){return Promise.reject(e)}}},{key:"parseExifBlock",value:function(){try{var e=this;if(e.exif)return;return nt((function(){if(!e.ifd0)return tt(e.parseIfd0Block())}),(function(){if(void 0!==e.exifOffset)return nt((function(){if(e.file.isTiff)return tt(e.file.ensureChunk(e.exifOffset,I(e.options)))}),(function(){var t=e.parseBlock(e.exifOffset,"exif");return e.interopOffset||(e.interopOffset=t.get(40965)),e.makerNote=t.get(37500),e.userComment=t.get(37510),e.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),e.unpack(t,41728),e.unpack(t,41729),t}))}))}catch(e){return Promise.reject(e)}}},{key:"unpack",value:function(e,t){var n=e.get(t);n&&1===n.length&&e.set(t,n[0])}},{key:"parseGpsBlock",value:function(){try{var e=this;if(e.gps)return;return nt((function(){if(!e.ifd0)return tt(e.parseIfd0Block())}),(function(){if(void 0!==e.gpsOffset){var t=e.parseBlock(e.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",st.apply(void 0,t.get(2).concat([t.get(1)]))),t.set("longitude",st.apply(void 0,t.get(4).concat([t.get(3)])))),t}}))}catch(e){return Promise.reject(e)}}},{key:"parseInteropBlock",value:function(){try{var e=this;if(e.interop)return;return nt((function(){if(!e.ifd0)return tt(e.parseIfd0Block())}),(function(){return nt((function(){if(void 0===e.interopOffset&&!e.exif)return tt(e.parseExifBlock())}),(function(){if(void 0!==e.interopOffset)return e.parseBlock(e.interopOffset,"interop")}))}))}catch(e){return Promise.reject(e)}}},{key:"parseThumbnailBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{var t=this;if(t.ifd1||t.ifd1Parsed)return;if(t.options.mergeOutput&&!e)return;return t.findIfd1Offset(),t.ifd1Offset>0&&(t.parseBlock(t.ifd1Offset,"ifd1"),t.ifd1Parsed=!0),t.ifd1}catch(e){return Promise.reject(e)}}},{key:"extractThumbnail",value:function(){try{var e=this;return e.headerParsed||e.parseHeader(),nt((function(){if(!e.ifd1Parsed)return tt(e.parseThumbnailBlock(!0))}),(function(){if(void 0!==e.ifd1){var t=e.ifd1.get(513),n=e.ifd1.get(514);return e.chunk.getUint8Array(t,n)}}))}catch(e){return Promise.reject(e)}}},{key:"createOutput",value:function(){var e,t,n,r={},i=ie;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)if(!V(e=this[t=i[s]]))if(n=this.canTranslate?this.translateBlock(e,t):g(e),this.options.mergeOutput){if("ifd1"===t)continue;y(r,n)}else r[t]=n;return this.makerNote&&(r.makerNote=this.makerNote),this.userComment&&(r.userComment=this.userComment),r}},{key:"assignToOutput",value:function(e,t){if(this.globalOptions.mergeOutput)y(e,t);else{var n=p(t);Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=i[0],a=i[1];this.assignObjectToOutput(e,s,a)}}}},{key:"image",get:function(){return this.ifd0}},{key:"thumbnail",get:function(){return this.ifd1}}],[{key:"canHandle",value:function(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}}]),n}(function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"parseHeader",value:function(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw _("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw _("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}},{key:"parseTags",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:S(),r=this.options[t],i=r.pick,s=r.skip,a=(i=O(i)).size>0,u=0===s.size,o=this.chunk.getUint16(e);e+=2;for(var f=0;f<o;f++){var h=this.chunk.getUint16(e);if(a){if(i.has(h)&&(n.set(h,this.parseTag(e,h,t)),i.delete(h),0===i.size))break}else!u&&s.has(h)||n.set(h,this.parseTag(e,h,t));e+=12}return n}},{key:"parseTag",value:function(e,t,n){var r,i=this.chunk.getUint16(e+2),s=this.chunk.getUint32(e+4),a=rt[i];if(a*s<=4?e+=8:e=this.chunk.getUint32(e+8),i<1||i>13)throw _("Invalid TIFF value type. block: ".concat(n.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e));if(e>this.chunk.byteLength)throw _("Invalid TIFF value offset. block: ".concat(n.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===i)return this.chunk.getUint8Array(e,s);if(2===i)return""===(r=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(r=this.chunk.getString(e,s)).trim())?void 0:r;if(7===i)return this.chunk.getUint8Array(e,s);if(1===s)return this.parseTagValue(i,e);for(var u=new(function(e){switch(e){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}}(i))(s),o=a,f=0;f<s;f++)u[f]=this.parseTagValue(i,e),e+=o;return u}},{key:"parseTagValue",value:function(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw _("Invalid tiff type ".concat(e))}}}]),n}(Ne));function st(e,t,n,r){var i=e+t/60+n/3600;return"S"!==r&&"W"!==r||(i*=-1),i}i(it,"type","tiff"),i(it,"headerLength",10),R.set("tiff",it),e.Exifr=Oe,e.Options=de,e.allFormatters=oe,e.chunkedProps=te,e.createDictionary=function(e,t,n){var r=new Y,i=n;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){var a=i[s],u=a[0],o=a[1];r.set(u,o)}if(Array.isArray(t)){var f=t;Array.isArray(f)||("function"==typeof f.entries&&(f=f.entries()),f=k(f));for(var h=0;h<f.length;h++){var c=f[h];e.set(c,r)}}else e.set(t,r);return r},e.disableAllOptions=ge,e.extendDictionary=function(e,t,n){var r,i=e.get(t),s=n;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)r=s[a],i.set(r[0],r[1])},e.fetchUrlAsArrayBuffer=G,e.fileParsers=N,e.fileReaders=M,e.gps=xe,e.gpsOnlyOptions=ke,e.inheritables=ue,e.orientation=Ue,e.orientationOnlyOptions=me,e.otherSegments=ne,e.parse=je,e.readBlobAsArrayBuffer=H,e.segmentParsers=R,e.segments=re,e.segmentsAndBlocks=se,e.tagKeys=Z,e.tagRevivers=ee,e.tagValues=$,e.thumbnail=Ce,e.thumbnailUrl=Be,e.tiffBlocks=ie,e.tiffExtractables=ae,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],e):e((t=t||self).exifr={})}(this,(function(t){"use strict";var e="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const a=t=>void 0!==t;function h(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(a).length)}function f(t){let e=new Error(t);return delete e.stack,e}function o(t){let e=function(t){let e=0;return t.ifd0.enabled&&(e+=1024),t.exif.enabled&&(e+=2048),t.makerNote&&(e+=2048),t.userComment&&(e+=1024),t.gps.enabled&&(e+=512),t.interop.enabled&&(e+=100),t.ifd1.enabled&&(e+=1024),e+2048}(t);return t.jfif.enabled&&(e+=50),t.xmp.enabled&&(e+=2e4),t.iptc.enabled&&(e+=14e3),t.icc.enabled&&(e+=6e3),e}let l=n?global.BigInt:self.BigInt;const u=new TextDecoder("utf-8");class d{static from(t,e){return t instanceof this&&t.le===e?t:new d(t,void 0,void 0,e)}constructor(t,e=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof d){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw f("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else{if("number"!=typeof t)throw f("Invalid input argument for BufferView: "+t);{let e=new DataView(new ArrayBuffer(t));this._swapDataView(e)}}}_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=d){if(t instanceof DataView||t instanceof d?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw f("BufferView.set(): Invalid data argument.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new d(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){let i=this.getUint8Array(t,e);return s=i,u.decode(s);var s}getUnicodeString(t=0,e=this.byteLength){const i=[];for(let s=0;s<e&&t+s<this.byteLength;s+=2)i.push(this.getUint16(t+s));return i.map(t=>String.fromCharCode(t)).join("")}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)}getUint64(t){let e=this.getUint32(t),i=this.getUint32(t+4);if(e<1048575)return e<<32|i;if(void 0!==typeof l)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),l(e)<<l(32)|l(i);throw f("Trying to read 64b value but JS can only handle 53b numbers.")}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(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(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}}function c(t,e){throw f("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class p extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||c(this.kind,t),e&&(t in e||function(t,e){throw f("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||c(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var g=new p("file parser"),y=new p("segment parser"),b=new p("file reader");function m(t,e){if((s=t).startsWith("data:")||s.length>1e4)return k(t,e,"base64");if(i)return w(t,e,"url",O);if(n)return k(t,e,"fs");throw f("Invalid input argument");var s}async function w(t,e,i,s){if(b.has(i))return k(t,e,i);if(s)return async function(t,e){let i=await e(t);return new DataView(i)}(t,s);throw f("Parser ".concat(i," is not loaded"))}async function k(t,e,i){let s=new(b.get(i))(t,e);return await s.read(),s}async function O(t){return fetch(t).then(t=>t.arrayBuffer())}async function v(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}const S=Symbol("keys"),U=Symbol("values");class A extends Map{get tagKeys(){return this[S]||(this[S]=Array.from(this.keys())),this[S]}get tagValues(){return this[U]||(this[U]=Array.from(this.values())),this[U]}}const x=new Map,C=new Map,B=new Map,V=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],I=["jfif","xmp","icc","iptc"],T=["tiff",...I],L=["ifd0","ifd1","exif","gps","interop"],z=[...T,...L],F=["makerNote","userComment"],j=["translateKeys","translateValues","reviveValues","multiSegment"],E=[...j,"sanitize","mergeOutput"];class D{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class M extends D{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=L.includes(t),this.canBeFiltered&&(this.dict=x.get(t)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:t,skip:e}=i;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw f("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(t){let e,i;for(e of j)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of t)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&e.add(Number(n[s]))):e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,H(this.pick,this.deps)):this.enabled&&this.pick.size>0&&H(this.pick,this.deps)}}var P={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},_=new Map;class N extends D{static useCached(t){let e=_.get(t);return void 0!==e?e:(e=new this(t),_.set(t,e),e)}constructor(t){if(super(),!0===t)this.setupFromTrue();else if(void 0===t)this.setupFromUndefined();else if(Array.isArray(t))this.setupFromArray(t);else{if("object"!=typeof t)throw f("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of V)this[t]=P[t];for(t of E)this[t]=P[t];for(t of F)this[t]=P[t];for(t of z)this[t]=new M(t,P[t],void 0,this)}setupFromTrue(){let t;for(t of V)this[t]=P[t];for(t of E)this[t]=P[t];for(t of F)this[t]=!0;for(t of z)this[t]=new M(t,!0,void 0,this)}setupFromArray(t){let e;for(e of V)this[e]=P[e];for(e of E)this[e]=P[e];for(e of F)this[e]=P[e];for(e of z)this[e]=new M(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,L)}setupFromObject(t){let e;for(e of(L.ifd0=L.ifd0||L.image,L.ifd1=L.ifd1||L.thumbnail,Object.assign(this,t),V))this[e]=W(t[e],P[e]);for(e of E)this[e]=W(t[e],P[e]);for(e of F)this[e]=W(t[e],P[e]);for(e of T)this[e]=new M(e,P[e],t[e],this);for(e of L)this[e]=new M(e,P[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,L,z),!0===t.tiff?this.batchEnableWithBool(L,!0):!1===t.tiff?this.batchEnableWithUserValue(L,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,L):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,L)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let t=e[i];this[i].enabled=!1!==t&&void 0!==t}}setupGlobalFilters(t,e,i,s=i){if(t&&t.length){for(let t of s)this[t].enabled=!1;let e=R(t,i);for(let[t,i]of e)H(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=R(e,i);for(let[e,i]of t)H(this[e].skip,i)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:s,icc:n}=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),s.enabled||t.skip.add(33723),n.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:s}=this;s.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=L.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of L)this[t].finalizeFilters()}get onlyTiff(){return!I.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of T)this[t].enabled&&!y.has(t)&&c("segment parser",t)}}function R(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=x.get(n),s=[],i))(t.includes(r[0])||t.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function W(t,e){return void 0!==t?t:void 0!==e?e:void 0}function H(t,e){for(let i of e)t.add(i)}r(N,"default",P);const K={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},G=Object.assign({},K,{firstChunkSize:4e4,gps:[1,2,3,4]}),J=Object.assign({},K,{firstChunkSize:4e4,ifd0:[274]});class X{constructor(t){r(this,"parsers",{}),this.options=N.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=g.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=g.get("jpeg");else{if(!function(t){if(0!==t.getUint16(0))return!1;let e=t.getUint16(2);if(e>50)return!1;let i=16,s=[];for(;i<e;)s.push(t.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw f("Unknown file format");this.file.isHeic=!0,t=g.get("heic")}this.fileParser=new t(this.options,this.file,this.parsers)}async read(t){this.file=await function(t,e){if("string"==typeof t)return m(t,e);if(i&&!s&&t instanceof HTMLImageElement)return m(t.src,e);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new d(t);if(i&&t instanceof Blob)return w(t,e,"blob",v);throw f("Invalid input argument")}(t,this.options)}async parse(){this.setup(),await this.fileParser.parse();let t={},e=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(t){e.push(t)}i.errors.length&&e.push(...i.errors)}else s=await i.parse();i.assignToOutput(t,s)});var s;return await Promise.all(i),this.options.silentErrors&&e.length>0&&(t.errors=e),t=h(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=y.get("tiff",this.options);var e;if(this.file.isTiff?e={start:0,type:"tiff"}:this.file.isJpeg&&(e=await this.fileParser.getOrFindSegment("tiff")),void 0===e)return;let i=await this.fileParser.ensureSegmentChunk(e),s=this.parsers.tiff=new t(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}class q extends d{constructor(...t){super(...t),r(this,"ranges",new Q),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(0===t&&0===this.byteLength&&i){let t=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(t)}else{let i=t+e;if(i>this.byteLength){let{dataView:t}=this._extend(i);this._swapDataView(t)}}}_extend(t){let i;i=e?Buffer.allocUnsafe(t):new Uint8Array(t);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}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 s=super.set(t,e);return this.ranges.add(e,s.byteLength),s}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)}}class Q{constructor(t){r(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}get length(){return this.list.length}addMultiple(t){if(Array.isArray(t[0]))for(let[e,i]of t)this.add(e,i);else for(let{offset:e,length:i}of t)this.add(e,i)}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>Y(t,e.offset,s)||Y(t,e.end,s));if(n.length>0){t=Math.min(t,...n.map(t=>t.offset)),s=Math.max(s,...n.map(t=>t.end)),e=s-t;let i=n.shift();i.offset=t,i.length=e,i.end=s,this.list=this.list.filter(t=>!n.includes(t))}else this.list.push({offset:t,length:e,end:s})}available(t,e){let i=t+e;return this.list.some(e=>e.offset<=t&&i<=e.end)}}function Y(t,e,i){return t<=e&&e<=i}class Z extends q{constructor(t,e){super(0),r(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++,0!==(e=this.safeWrapAddress(t,e)))return this._readChunk(t,e)}safeWrapAddress(t,e){return void 0!==this.size&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}b.set("blob",class extends Z{async readWhole(){this.chunked=!1;let t=await v(this.input);this._swapArrayBuffer(t)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(t,e){let i=e?t+e:void 0,s=this.input.slice(t,i),n=await v(s);return this.set(n,t,!0)}});class ${static findPosition(t,e){let i=t.getUint16(e+2)+2,s="function"==typeof this.headerLength?this.headerLength(t,e,i):this.headerLength,n=e+s,r=i-s;return{offset:e,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(t,e={}){return new this(t,new N({[this.type]:e})).parse()}normalizeInput(t){return t instanceof d?t:new d(t)}constructor(t,e={},i){r(this,"errors",[]),r(this,"raw",new Map),r(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.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=B.get(e),s=C.get(e),n=x.get(e),r=this.options[e],a=r.reviveValues&&i,h=r.translateValues&&s,f=r.translateKeys&&n,o={};for(let[e,r]of t)a&&i.has(e)?r=i.get(e)(r):h&&s.has(e)&&(r=this.translateValue(r,s.get(e))),f&&n.has(e)&&(e=n.get(e)||e),o[e]=r;return o}translateValue(t,e){return e[t]||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}}r($,"headerLength",4),r($,"type",void 0),r($,"multiSegment",!1),r($,"canHandle",()=>!1);function tt(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function et(t){return t>=224&&t<=239}function it(t,e){for(let[i,s]of y)if(s.canHandle(t,e))return i}g.set("jpeg",class extends class{constructor(t,e,i){r(this,"ensureSegmentChunk",async t=>{let e=t.start,i=t.size||65536;if(this.file.chunked)if(this.file.available(e,i))t.chunk=this.file.subarray(e,i);else try{t.chunk=await this.file.readChunk(e,i)}catch(e){throw f("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.message))}else if(this.file.byteLength>e+i)t.chunk=this.file.subarray(e,i);else{if(void 0!==t.size)throw f("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}createParser(t,e){let i=new(y.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),r(this,"appSegments",[]),r(this,"jpegSegments",[]),r(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let t=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(t)}setupSegmentFinderArgs(t){!0===t?(this.findAll=!0,this.wanted=new Set(y.keyList())):(t=void 0===t?y.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&y.has(t)),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:s,wanted:n,remaining:r}=this;if(!s)for(let t of n){let e=y.get(t),i=this.options[t];if(e.multiSegment&&i.multiSegment){s=!0,this.file.chunked&&await this.file.readWhole();break}}if(t=this._findAppSegments(t,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let e=!1;for(;r.size>0&&!e&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(t=>!this.file.available(t.offset||t.start,t.length||t.size));if(e=t>s&&!n?!await i.readNextChunk(t):!await i.readNextChunk(s),void 0===(t=this._findAppSegments(t,i.byteLength)))return}}}_findAppSegments(t,e){let i,s,n,r,a,h,{file:f,findAll:o,wanted:l,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),et(i)){if(s=f.getUint16(t+2),n=it(f,t),n&&l.has(n)&&(r=y.get(n),a=r.findPosition(f,t),h=d[n],a.type=n,this.appSegments.push(a),!o&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=$.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(tt(i)){if(s=f.getUint16(t+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:t,length:s,marker:i}),t+=s+1}return t}mergeMultiSegments(){if(!this.appSegments.some(t=>t.multiSegment))return;let t=function(t,e){let i,s,n,r=new Map;for(let a=0;a<t.length;a++)i=t[a],s=i[e],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r.entries())}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=y.get(t,this.options);if(i.handleMultiSegments){return{type:t,chunk:i.handleMultiSegments(e)}}return e[0]})}async createParsers(){let t=this.mergedAppSegments||this.appSegments;for(let e of t){let{type:t,chunk:i}=e;if(!this.options[t].enabled)continue;let s=this.parsers[t];if(s&&s.append);else if(!s){let e=new(y.get(t,this.options))(i,this.options,this.file);this.parsers[t]=e}}}getSegment(t){return this.appSegments.find(e=>e.type===t)}async getOrFindSegment(t){let e=this.getSegment(t);return void 0===e&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}});const st=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class nt extends ${parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw f("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw f("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:s,skip:n}=this.options[e];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(t);t+=2;for(let f=0;f<h;f++){let h=this.chunk.getUint16(t);if(r){if(s.has(h)&&(i.set(h,this.parseTag(t,h,e)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(t,h,e));t+=12}return i}parseTag(t,e,i){let s=this.chunk.getUint16(t+2),n=this.chunk.getUint32(t+4),r=st[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw f("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t));if(t>this.chunk.byteLength)throw f("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(t,n);if(2===s)return""===(a=function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t}(a=this.chunk.getString(t,n)).trim())?void 0:a;var a;if(7===s)return this.chunk.getUint8Array(t,n);if(1===n)return this.parseTagValue(s,t);{let e=new(function(t){switch(t){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}}(s))(n),i=r;for(let r=0;r<n;r++)e[r]=this.parseTagValue(s,t),t+=i;return e}}parseTagValue(t,e){switch(t){case 1:return this.chunk.getUint8(e);case 3:return this.chunk.getUint16(e);case 4:return this.chunk.getUint32(e);case 5:return this.chunk.getUint32(e)/this.chunk.getUint32(e+4);case 6:return this.chunk.getInt8(e);case 8:return this.chunk.getInt16(e);case 9:return this.chunk.getInt32(e);case 10:return this.chunk.getInt32(e)/this.chunk.getInt32(e+4);case 11:return this.chunk.getFloat(e);case 12:return this.chunk.getDouble(e);case 13:return this.chunk.getUint32(e);default:throw f("Invalid tiff type ".concat(t))}}}class rt extends nt{static canHandle(t,e){return 225===t.getUint8(e+1)&&1165519206===t.getUint32(e+4)&&0===t.getUint16(e+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){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;if(this.findIfd0Offset(),this.ifd0Offset<8)throw f("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw f("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,o(this.options));let t=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==t.size?(this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t):void 0}async ensureBlockChunk(t,e){this.file.isTiff&&await this.file.ensureChunk(t,e),t>this.chunk.byteLength&&(this.chunk=d.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,o(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&&1===i.length&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",at(...t.get(2),t.get(1))),t.set("longitude",at(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))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),void 0===this.ifd1)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,s={};for(e of L)if(t=this[e],!h(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if("ifd1"===e)continue;Object.assign(s,i)}else s[e]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,s]of Object.entries(e))this.assignObjectToOutput(t,i,s)}}function at(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}r(rt,"type","tiff"),r(rt,"headerLength",10),y.set("tiff",rt),t.Exifr=X,t.Options=N,t.allFormatters=E,t.chunkedProps=V,t.createDictionary=function(t,e,i){let s=new A(i);if(Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s},t.disableAllOptions=K,t.extendDictionary=function(t,e,i){let s,n=t.get(e);for(s of i)n.set(s[0],s[1])},t.fetchUrlAsArrayBuffer=O,t.fileParsers=g,t.fileReaders=b,t.gps=async function(t){let e=new X(G);await e.read(t);let i=await e.parse();if(i&&i.gps){let{latitude:t,longitude:e}=i.gps;return{latitude:t,longitude:e}}},t.gpsOnlyOptions=G,t.inheritables=j,t.orientation=async function(t){let e=new X(J);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]},t.orientationOnlyOptions=J,t.otherSegments=I,t.parse=async function(t,e){let i=new X(e);return await i.read(t),i.parse()},t.readBlobAsArrayBuffer=v,t.segmentParsers=y,t.segments=T,t.segmentsAndBlocks=z,t.tagKeys=x,t.tagRevivers=B,t.tagValues=C,t.thumbnail=async function(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new X(i);await s.read(t);let n=await s.extractThumbnail();return n&&e?Buffer.from(n):n},t.thumbnailUrl=async function(...t){let e=await this.thumbnail(...t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}},t.tiffBlocks=L,t.tiffExtractables=F,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],e):e((t=t||self).exifr={})}(this,(function(t){"use strict";var e="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const a=t=>void 0!==t;function h(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(a).length)}function f(t){let e=new Error(t);return delete e.stack,e}function o(t){let e=function(t){let e=0;return t.ifd0.enabled&&(e+=1024),t.exif.enabled&&(e+=2048),t.makerNote&&(e+=2048),t.userComment&&(e+=1024),t.gps.enabled&&(e+=512),t.interop.enabled&&(e+=100),t.ifd1.enabled&&(e+=1024),e+2048}(t);return t.jfif.enabled&&(e+=50),t.xmp.enabled&&(e+=2e4),t.iptc.enabled&&(e+=14e3),t.icc.enabled&&(e+=6e3),e}let l=n?global.BigInt:self.BigInt;const u=new TextDecoder("utf-8");class d{static from(t,e){return t instanceof this&&t.le===e?t:new d(t,void 0,void 0,e)}constructor(t,e=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof d){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw f("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else{if("number"!=typeof t)throw f("Invalid input argument for BufferView: "+t);{let e=new DataView(new ArrayBuffer(t));this._swapDataView(e)}}}_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=d){if(t instanceof DataView||t instanceof d?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw f("BufferView.set(): Invalid data argument.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new d(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){let i=this.getUint8Array(t,e);return s=i,u.decode(s);var s}getUnicodeString(t=0,e=this.byteLength){const i=[];for(let s=0;s<e&&t+s<this.byteLength;s+=2)i.push(this.getUint16(t+s));return i.map(t=>String.fromCharCode(t)).join("")}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)}getUint64(t){let e=this.getUint32(t),i=this.getUint32(t+4);if(e<1048575)return e<<32|i;if(void 0!==typeof l)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),l(e)<<l(32)|l(i);throw f("Trying to read 64b value but JS can only handle 53b numbers.")}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(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(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}}function c(t,e){throw f("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class p extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||c(this.kind,t),e&&(t in e||function(t,e){throw f("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||c(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var g=new p("file parser"),y=new p("segment parser"),k=new p("file reader");function w(t,e){if((s=t).startsWith("data:")||s.length>1e4)return b(t,e,"base64");if(i)return m(t,e,"url",v);if(n)return b(t,e,"fs");throw f("Invalid input argument");var s}async function m(t,e,i,s){if(k.has(i))return b(t,e,i);if(s)return async function(t,e){let i=await e(t);return new DataView(i)}(t,s);throw f("Parser ".concat(i," is not loaded"))}async function b(t,e,i){let s=new(k.get(i))(t,e);return await s.read(),s}async function v(t){return fetch(t).then(t=>t.arrayBuffer())}async function O(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}class S 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}}const U=new Map,A=new Map,x=new Map,B=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],C=["jfif","xmp","icc","iptc"],V=["tiff",...C],I=["ifd0","ifd1","exif","gps","interop"],T=[...V,...I],L=["makerNote","userComment"],z=["translateKeys","translateValues","reviveValues","multiSegment"],F=[...z,"sanitize","mergeOutput"];class j{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class P extends j{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=I.includes(t),this.canBeFiltered&&(this.dict=U.get(t)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:t,skip:e}=i;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw f("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(t){let e,i;for(e of z)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of t)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&e.add(Number(n[s]))):e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,R(this.pick,this.deps)):this.enabled&&this.pick.size>0&&R(this.pick,this.deps)}}var D={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,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},E=new Map;class _ extends j{static useCached(t){let e=E.get(t);return void 0!==e?e:(e=new this(t),E.set(t,e),e)}constructor(t){if(super(),!0===t)this.setupFromTrue();else if(void 0===t)this.setupFromUndefined();else if(Array.isArray(t))this.setupFromArray(t);else{if("object"!=typeof t)throw f("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of B)this[t]=D[t];for(t of F)this[t]=D[t];for(t of L)this[t]=D[t];for(t of T)this[t]=new P(t,D[t],void 0,this)}setupFromTrue(){let t;for(t of B)this[t]=D[t];for(t of F)this[t]=D[t];for(t of L)this[t]=!0;for(t of T)this[t]=new P(t,!0,void 0,this)}setupFromArray(t){let e;for(e of B)this[e]=D[e];for(e of F)this[e]=D[e];for(e of L)this[e]=D[e];for(e of T)this[e]=new P(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,I)}setupFromObject(t){let e;for(e of(I.ifd0=I.ifd0||I.image,I.ifd1=I.ifd1||I.thumbnail,Object.assign(this,t),B))this[e]=N(t[e],D[e]);for(e of F)this[e]=N(t[e],D[e]);for(e of L)this[e]=N(t[e],D[e]);for(e of V)this[e]=new P(e,D[e],t[e],this);for(e of I)this[e]=new P(e,D[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,I,T),!0===t.tiff?this.batchEnableWithBool(I,!0):!1===t.tiff?this.batchEnableWithUserValue(I,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,I):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,I)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let t=e[i];this[i].enabled=!1!==t&&void 0!==t}}setupGlobalFilters(t,e,i,s=i){if(t&&t.length){for(let t of s)this[t].enabled=!1;let e=M(t,i);for(let[t,i]of e)R(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=M(e,i);for(let[e,i]of t)R(this[e].skip,i)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:s,icc:n}=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),s.enabled||t.skip.add(33723),n.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:s}=this;s.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=I.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of I)this[t].finalizeFilters()}get onlyTiff(){return!C.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of V)this[t].enabled&&!y.has(t)&&c("segment parser",t)}}function M(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=U.get(n),s=[],i))(t.includes(r[0])||t.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function N(t,e){return void 0!==t?t:void 0!==e?e:void 0}function R(t,e){for(let i of e)t.add(i)}r(_,"default",D);const W={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},K=Object.assign({},W,{firstChunkSize:4e4,gps:[1,2,3,4]}),H=Object.assign({},W,{firstChunkSize:4e4,ifd0:[274]});class G{constructor(t){r(this,"parsers",{}),this.options=_.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=g.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=g.get("jpeg");else{if(!function(t){if(0!==t.getUint16(0))return!1;let e=t.getUint16(2);if(e>50)return!1;let i=16,s=[];for(;i<e;)s.push(t.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw f("Unknown file format");this.file.isHeic=!0,t=g.get("heic")}this.fileParser=new t(this.options,this.file,this.parsers)}async read(t){this.file=await function(t,e){if("string"==typeof t)return w(t,e);if(i&&!s&&t instanceof HTMLImageElement)return w(t.src,e);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new d(t);if(i&&t instanceof Blob)return m(t,e,"blob",O);throw f("Invalid input argument")}(t,this.options)}async parse(){this.setup(),await this.fileParser.parse();let t={},e=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(t){e.push(t)}i.errors.length&&e.push(...i.errors)}else s=await i.parse();i.assignToOutput(t,s)});var s;return await Promise.all(i),this.options.silentErrors&&e.length>0&&(t.errors=e),t=h(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=y.get("tiff",this.options);var e;if(this.file.isTiff?e={start:0,type:"tiff"}:this.file.isJpeg&&(e=await this.fileParser.getOrFindSegment("tiff")),void 0===e)return;let i=await this.fileParser.ensureSegmentChunk(e),s=this.parsers.tiff=new t(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}class J extends d{constructor(...t){super(...t),r(this,"ranges",new X),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(0===t&&0===this.byteLength&&i){let t=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(t)}else{let i=t+e;if(i>this.byteLength){let{dataView:t}=this._extend(i);this._swapDataView(t)}}}_extend(t){let i;i=e?Buffer.allocUnsafe(t):new Uint8Array(t);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}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 s=super.set(t,e);return this.ranges.add(e,s.byteLength),s}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)}}class X{constructor(){r(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>q(t,e.offset,s)||q(t,e.end,s));if(n.length>0){t=Math.min(t,...n.map(t=>t.offset)),s=Math.max(s,...n.map(t=>t.end)),e=s-t;let i=n.shift();i.offset=t,i.length=e,i.end=s,this.list=this.list.filter(t=>!n.includes(t))}else this.list.push({offset:t,length:e,end:s})}available(t,e){let i=t+e;return this.list.some(e=>e.offset<=t&&i<=e.end)}}function q(t,e,i){return t<=e&&e<=i}class Q extends J{constructor(t,e){super(0),r(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++,0!==(e=this.safeWrapAddress(t,e)))return this._readChunk(t,e)}safeWrapAddress(t,e){return void 0!==this.size&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}k.set("blob",class extends Q{async readWhole(){this.chunked=!1;let t=await O(this.input);this._swapArrayBuffer(t)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(t,e){let i=e?t+e:void 0,s=this.input.slice(t,i),n=await O(s);return this.set(n,t,!0)}});class Y{static findPosition(t,e){let i=t.getUint16(e+2)+2,s="function"==typeof this.headerLength?this.headerLength(t,e,i):this.headerLength,n=e+s,r=i-s;return{offset:e,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(t,e={}){return new this(t,new _({[this.type]:e})).parse()}normalizeInput(t){return t instanceof d?t:new d(t)}constructor(t,e={},i){r(this,"errors",[]),r(this,"raw",new Map),r(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.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=x.get(e),s=A.get(e),n=U.get(e),r=this.options[e],a=r.reviveValues&&!!i,h=r.translateValues&&!!s,f=r.translateKeys&&!!n,o={};for(let[e,r]of t)a&&i.has(e)?r=i.get(e)(r):h&&s.has(e)&&(r=this.translateValue(r,s.get(e))),f&&n.has(e)&&(e=n.get(e)||e),o[e]=r;return o}translateValue(t,e){return e[t]||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}}r(Y,"headerLength",4),r(Y,"type",void 0),r(Y,"multiSegment",!1),r(Y,"canHandle",()=>!1);function Z(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function $(t){return t>=224&&t<=239}function tt(t,e){for(let[i,s]of y)if(s.canHandle(t,e))return i}g.set("jpeg",class extends class{constructor(t,e,i){r(this,"ensureSegmentChunk",async t=>{let e=t.start,i=t.size||65536;if(this.file.chunked)if(this.file.available(e,i))t.chunk=this.file.subarray(e,i);else try{t.chunk=await this.file.readChunk(e,i)}catch(e){throw f("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.message))}else if(this.file.byteLength>e+i)t.chunk=this.file.subarray(e,i);else{if(void 0!==t.size)throw f("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}createParser(t,e){let i=new(y.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),r(this,"appSegments",[]),r(this,"jpegSegments",[]),r(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let t=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(t)}setupSegmentFinderArgs(t){!0===t?(this.findAll=!0,this.wanted=new Set(y.keyList())):(t=void 0===t?y.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&y.has(t)),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:s,wanted:n,remaining:r}=this;if(!s&&this.file.chunked&&(s=Array.from(n).some(t=>{let e=y.get(t),i=this.options[t];return e.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),t=this._findAppSegments(t,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let e=!1;for(;r.size>0&&!e&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(t=>!this.file.available(t.offset||t.start,t.length||t.size));if(e=t>s&&!n?!await i.readNextChunk(t):!await i.readNextChunk(s),void 0===(t=this._findAppSegments(t,i.byteLength)))return}}}_findAppSegments(t,e){let i,s,n,r,a,h,{file:f,findAll:o,wanted:l,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),$(i)){if(s=f.getUint16(t+2),n=tt(f,t),n&&l.has(n)&&(r=y.get(n),a=r.findPosition(f,t),h=d[n],a.type=n,this.appSegments.push(a),!o&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=Y.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(Z(i)){if(s=f.getUint16(t+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:t,length:s,marker:i}),t+=s+1}return t}mergeMultiSegments(){if(!this.appSegments.some(t=>t.multiSegment))return;let t=function(t,e){let i,s,n,r=new Map;for(let a=0;a<t.length;a++)i=t[a],s=i[e],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r)}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=y.get(t,this.options);if(i.handleMultiSegments){return{type:t,chunk:i.handleMultiSegments(e)}}return e[0]})}async createParsers(){let t=this.mergedAppSegments||this.appSegments;for(let e of t){let{type:t,chunk:i}=e;if(!this.options[t].enabled)continue;let s=this.parsers[t];if(s&&s.append);else if(!s){let e=new(y.get(t,this.options))(i,this.options,this.file);this.parsers[t]=e}}}getSegment(t){return this.appSegments.find(e=>e.type===t)}async getOrFindSegment(t){let e=this.getSegment(t);return void 0===e&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}});const et=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class it extends Y{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw f("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw f("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:s,skip:n}=this.options[e];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(t);t+=2;for(let f=0;f<h;f++){let h=this.chunk.getUint16(t);if(r){if(s.has(h)&&(i.set(h,this.parseTag(t,h,e)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(t,h,e));t+=12}return i}parseTag(t,e,i){let s=this.chunk.getUint16(t+2),n=this.chunk.getUint32(t+4),r=et[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw f("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t));if(t>this.chunk.byteLength)throw f("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(t,n);if(2===s)return""===(a=function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t}(a=this.chunk.getString(t,n)).trim())?void 0:a;var a;if(7===s)return this.chunk.getUint8Array(t,n);if(1===n)return this.parseTagValue(s,t);{let e=new(function(t){switch(t){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}}(s))(n),i=r;for(let r=0;r<n;r++)e[r]=this.parseTagValue(s,t),t+=i;return e}}parseTagValue(t,e){switch(t){case 1:return this.chunk.getUint8(e);case 3:return this.chunk.getUint16(e);case 4:return this.chunk.getUint32(e);case 5:return this.chunk.getUint32(e)/this.chunk.getUint32(e+4);case 6:return this.chunk.getInt8(e);case 8:return this.chunk.getInt16(e);case 9:return this.chunk.getInt32(e);case 10:return this.chunk.getInt32(e)/this.chunk.getInt32(e+4);case 11:return this.chunk.getFloat(e);case 12:return this.chunk.getDouble(e);case 13:return this.chunk.getUint32(e);default:throw f("Invalid tiff type ".concat(t))}}}class st extends it{static canHandle(t,e){return 225===t.getUint8(e+1)&&1165519206===t.getUint32(e+4)&&0===t.getUint16(e+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(t){try{return await this[t]()}catch(t){this.handleError(t)}}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){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;if(this.findIfd0Offset(),this.ifd0Offset<8)throw f("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw f("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,o(this.options));let t=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==t.size?(this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t):void 0}async ensureBlockChunk(t,e){this.file.isTiff&&await this.file.ensureChunk(t,e),t>this.chunk.byteLength&&(this.chunk=d.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,o(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&&1===i.length&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",nt(...t.get(2),t.get(1))),t.set("longitude",nt(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await this.parseExifBlock(),void 0!==this.interopOffset))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),void 0===this.ifd1)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,s={};for(e of I)if(t=this[e],!h(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if("ifd1"===e)continue;Object.assign(s,i)}else s[e]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,s]of Object.entries(e))this.assignObjectToOutput(t,i,s)}}function nt(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}r(st,"type","tiff"),r(st,"headerLength",10),y.set("tiff",st),t.Exifr=G,t.Options=_,t.allFormatters=F,t.chunkedProps=B,t.createDictionary=function(t,e,i){let s=new S;for(let[t,e]of i)s.set(t,e);if(Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s},t.disableAllOptions=W,t.extendDictionary=function(t,e,i){let s,n=t.get(e);for(s of i)n.set(s[0],s[1])},t.fetchUrlAsArrayBuffer=v,t.fileParsers=g,t.fileReaders=k,t.gps=async function(t){let e=new G(K);await e.read(t);let i=await e.parse();if(i&&i.gps){let{latitude:t,longitude:e}=i.gps;return{latitude:t,longitude:e}}},t.gpsOnlyOptions=K,t.inheritables=z,t.orientation=async function(t){let e=new G(H);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]},t.orientationOnlyOptions=H,t.otherSegments=C,t.parse=async function(t,e){let i=new G(e);return await i.read(t),i.parse()},t.readBlobAsArrayBuffer=O,t.segmentParsers=y,t.segments=V,t.segmentsAndBlocks=T,t.tagKeys=U,t.tagRevivers=x,t.tagValues=A,t.thumbnail=async function(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new G(i);await s.read(t);let n=await s.extractThumbnail();return n&&e?Buffer.from(n):n},t.thumbnailUrl=async function(...t){let e=await this.thumbnail(...t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}},t.tiffBlocks=I,t.tiffExtractables=L,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "exifr",
"version": "4.0.0",
"version": "4.1.0",
"description": "📷 The fastest and most versatile JavaScript EXIF reading library.",

@@ -38,2 +38,3 @@ "author": "Mike Kovarik",

"coverage": "c8 npm test",
"dev": "rollup -c rollup.config.js -w",
"build": "rollup -c rollup.config.js"

@@ -44,4 +45,18 @@ },

"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-arrow-functions": "^7.8.3",
"@babel/plugin-transform-block-scoping": "^7.8.3",
"@babel/plugin-transform-classes": "^7.8.6",
"@babel/plugin-transform-computed-properties": "^7.8.3",
"@babel/plugin-transform-destructuring": "^7.8.3",
"@babel/plugin-transform-duplicate-keys": "^7.8.3",
"@babel/plugin-transform-function-name": "^7.8.3",
"@babel/plugin-transform-literals": "^7.8.3",
"@babel/plugin-transform-parameters": "^7.8.7",
"@babel/plugin-transform-shorthand-properties": "^7.8.3",
"@babel/plugin-transform-spread": "^7.8.3",
"@babel/plugin-transform-template-literals": "^7.8.3",
"@babel/preset-env": "^7.6.3",
"aurelia-script": "^1.5.2",
"babel-plugin-transform-async-to-promises": "^0.8.15",
"babel-plugin-transform-for-of-without-iterator": "^1.0.3",
"c8": "^7.0.1",

@@ -48,0 +63,0 @@ "chai": "^4.2.0",

@@ -50,3 +50,3 @@ <img src="https://raw.githubusercontent.com/MikeKovarik/exifr/master/logo/blue-small.png" width="160" alt="exifr">

* 🤙 Promises
* 🕸 Supports even IE11
* 🕸 Supports even ~IE11~ **IE10**

@@ -97,24 +97,32 @@ <details>

#### Node.js
**Old Node.js users**: This library is written as an ES module. If you still use CommonJS, you need load UMD bundle.
**New Node**: This library is written as an ES module, with `import` syntax and `"type":"module"` in package.json.
**Old Node**: If you still use CommonJS (`require()` syntax), you need load UMD bundle.
```js
// node.js
import * as exifr from 'exifr' // loads 'full' build by default
// modern node.js
import * as exifr from 'exifr' // => exifr/dist/full.esm.js
// older Node.js or CJS project
var exifr = require('exifr/dist/full.umd.js')
// modern browser
import * as exifr from 'node_modules/exifr/dist/mini.esm.js'
```
**Browser users**: UMD is also compatible with RequireJS. Otherwise exports everything as `window.exifr`
#### Browsers
`lite` and `mini` are recommended for browsers because of balance between features and file size.
UMD format supports AMD (RequireJS) or attached everything to the global `window.exifr` object.
**IE & old browsers:** `legacy` build comes bundled with polyfills. [Learn more](examples/legacy.html).
```html
<!-- modern browsers -->
<script type="module">import * as exifr from 'node_modules/exifr/dist/mini.esm.js'</script>
<!-- classic -->
<script src="https://cdn.jsdelivr.net/npm/exifr/dist/lite.umd.js"></script>
<!-- IE10 & old browsers. You also need Promise polyfill -->
<script src="https://cdn.jsdelivr.net/npm/exifr/dist/lite.legacy.umd.js"></script>
```
`lite` and `mini` are recommended for browsers because of balance between features and file size.
Need to support older browsers? Use `legacy` build along with polyfills. Learn more about IE11 at [examples/legacy.html](examples/legacy.html).
#### Bundles

@@ -129,2 +137,11 @@

#### Variants
* **ESM** - Modern syntax for use in [modern browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) and [Node.js](https://nodejs.org/api/esm.html).
<br>Uses `import` syntax.
* **UMD** - Universal format for browsers and Node.js.
<br>Supports CJS `require('exifr')`, AMD/RequireJS and global `window.exifr`.
* **legacy UMD** - For use in older browsers (up to IE10).
<br>Bundled with polyfills & shims, except for `Promise` polyfill. [Learn more here](https://mutiny.cz/exifr/examples/legacy.html).
<details>

@@ -230,3 +247,3 @@ <summary><b>Detailed comparison (click to expand)</b></summary>

* [examples/legacy.html](https://mutiny.cz/exifr/examples/legacy.html), [code](examples/legacy.html)
<br>Visit in IE11,
<br>Visit in IE10/IE11,
* [benchmark/formats-reading.html](https://mutiny.cz/exifr/benchmark/formats-reading.html), [code](benchmark/formats-reading.html)

@@ -946,3 +963,3 @@ <br>Compares reading speed of various input types.

**npm** (~588 kB): The module includes both `src/` and `dist/`. That source codes of all the readers, parsers and dictionaries. Multiplied by 4 bundles (*full*, *lite*, *mini*, *core*). Then multiplied by 3 bundle formats (*ESM*, *UMD*, *legacy* for IE11). But you will never use all of the files. They're there so you can choose what's best for your project.
**npm** (~600 kB): The module includes both `src/` and `dist/`. That source codes of all the readers, parsers and dictionaries. Multiplied by 4 bundles (*full*, *lite*, *mini*, *core*). Then multiplied by 3 bundle formats (*ESM*, *UMD*, *legacy* for IE11). But you will never use all of the files. They're there so you can choose what's best for your project.

@@ -949,0 +966,0 @@ **bundlephobia** (~63/22 kB): *Full* build is the `"main"` entry point (in `package.json`) picked up by Node and bundlephobia. But it's meant for use in Node where size doesn't matter.

@@ -0,0 +0,0 @@ export * from './bundle-lite.js'

@@ -0,0 +0,0 @@ export * from './bundle-mini.js'

@@ -0,0 +0,0 @@ import {read} from './reader.js'

@@ -131,5 +131,5 @@ import {BufferView} from './util/BufferView.js'

let blockOptions = this.options[blockKey] // todo: refactor tiff so this isn't needed anymore (in favor of segOptions & options)
let canRevive = blockOptions.reviveValues && revivers
let canTranslateVal = blockOptions.translateValues && valDict
let canTranslateKey = blockOptions.translateKeys && keyDict
let canRevive = blockOptions.reviveValues && !!revivers
let canTranslateVal = blockOptions.translateValues && !!valDict
let canTranslateKey = blockOptions.translateKeys && !!keyDict
let output = {}

@@ -136,0 +136,0 @@ for (let [key, val] of rawTags) {

import {customError} from './util/helpers.js'
import {fixIeSubclassing} from './util/ieFix.js'

@@ -41,6 +40,2 @@

export var segmentParsers = new PluginList('segment parser')
export var fileReaders = new PluginList('file reader')
fixIeSubclassing(fileParsers, PluginList, ['keyList'])
fixIeSubclassing(segmentParsers, PluginList, ['keyList'])
fixIeSubclassing(fileReaders, PluginList, ['keyList'])
export var fileReaders = new PluginList('file reader')

@@ -1,17 +0,13 @@

import {fixIeSubclassing} from './util/ieFix.js'
const KEYS = Symbol('keys')
const VALUES = Symbol('values')
class Dictionary extends Map {
get tagKeys() {
if (!this[KEYS]) this[KEYS] = Array.from(this.keys())
return this[KEYS]
if (!this.allKeys)
this.allKeys = Array.from(this.keys())
return this.allKeys
}
get tagValues() {
if (!this[VALUES]) this[VALUES] = Array.from(this.values())
return this[VALUES]
if (!this.allValues)
this.allValues = Array.from(this.values())
return this.allValues
}

@@ -22,4 +18,7 @@

export function createDictionary(group, key, entries) {
let dict = new Dictionary(entries)
fixIeSubclassing(dict, Dictionary, undefined, ['tagKeys', 'tagValues'])
//let dict = new Dictionary(entries)
let dict = new Dictionary()
// ie doesnt support constructor initialization
for (let [key, val] of entries)
dict.set(key, val)
if (Array.isArray(key))

@@ -26,0 +25,0 @@ for (let k of key) group.set(k, dict)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc