/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/libheif-web@1.0.2/bundles/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("libjs-loader")):"function"==typeof define&&define.amd?define(["exports","libjs-loader"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).bundles={},e.libjsLoader)}(this,(function(e,i){"use strict";function t(e,i,t,n){return new(t||(t=Promise))((function(o,r){function d(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var i;e.done?o(e.value):(i=e.value,i instanceof t?i:new t((function(e){e(i)}))).then(d,a)}c((n=n.apply(e,i||[])).next())}))}let n=null;const o=()=>t(void 0,void 0,void 0,(function*(){return yield i.loadLibrary(null!=n?n:"https://github.com/joutvhu/libheif-web/releases/download/v1.12.0_libheif/libheif.min.js","libheif")})),r=e=>{switch(new TextDecoder("utf-8").decode(e.slice(8,12)).replace("\0"," ").trim()){case"mif1":case"msf1":case"heic":case"heix":case"hevc":case"hevx":return!0}return!1},d=e=>t(void 0,void 0,void 0,(function*(){const i=e.get_width(),t=e.get_height(),n=yield new Promise(((n,o)=>{e.display({data:new Uint8ClampedArray(i*t*4),width:i,height:t},(e=>{if(!e)return o(new Error("HEIF processing error"));n(e.data.buffer)}))}));return{width:i,height:t,data:n}})),a=e=>t(void 0,void 0,void 0,(function*(){const i=yield o();if(!r(e.buffer))throw new TypeError("input buffer is not a HEIC image");const n=(new i.HeifDecoder).decode(e.buffer);if(!n.length)throw new Error("HEIF image not found");return e.all?n.map((e=>({decode:()=>t(void 0,void 0,void 0,(function*(){return yield d(e)}))}))):yield d(n[0])})),c=e=>t(void 0,void 0,void 0,(function*(){return yield a({buffer:e,all:!1})})),u=e=>t(void 0,void 0,void 0,(function*(){return yield a({buffer:e,all:!0})})),l=e=>t(void 0,void 0,void 0,(function*(){var i;const t=new Uint8ClampedArray(e.data),n=new ImageData(t,e.width,e.height),o=yield createImageBitmap(n),r=document.createElement("canvas");return r.width=e.width,r.height=e.height,null===(i=r.getContext("2d"))||void 0===i||i.drawImage(o,0,0,e.width,e.height),r})),f=(e,i,n)=>t(void 0,void 0,void 0,(function*(){const t=yield l(e);return yield new Promise(((e,o)=>t.toBlob((i=>{null!=i?e(i):o("Can't convert canvas to blob.")}),i,n)))})),s=(e="image/png")=>{switch(e){case"image/bmp":case"image/gif":return".bmp";case"image/jpeg":return".jpg";case"image/tiff":return".tif";case"image/webp":return".webp";case"image-xbitmap":case"image/xbm":return".xbm";case"image/vnd.microsoft.icon":case"image/x-icon":return".ico";case"image/svg+xml":return".svg";case"image/avif":return".avif";case"image/apng":return".apng";default:return".png"}},v=(e,i,n,o)=>t(void 0,void 0,void 0,(function*(){const t=yield f(e,n,o);return new File([t],i,{lastModified:Date.now(),type:t.type})})),m=(e,i,n,o)=>t(void 0,void 0,void 0,(function*(){const t=yield c(e);return yield v(t,i,n,o)}));e.convert=c,e.convertAll=u,e.convertAllOfHeif=e=>t(void 0,void 0,void 0,(function*(){const i=yield e.arrayBuffer();return(yield u(i)).map((i=>({convert:(n,o,r)=>t(void 0,void 0,void 0,(function*(){const t=yield i.decode();return yield v(t,null!=n?n:e.name+s(o),o,r)}))})))})),e.convertBuffer=m,e.convertHeif=(e,i,n,o)=>t(void 0,void 0,void 0,(function*(){const t=yield e.arrayBuffer();return yield m(t,null!=i?i:e.name+s(n),n,o)})),e.decodeBuffer=a,e.decodeImage=d,e.encodeByCanvas=l,e.isHeic=r,e.loadLib=o,e.toBlob=f,e.toDataURL=(e,i,n)=>t(void 0,void 0,void 0,(function*(){return(yield l(e)).toDataURL(i,n)})),e.toFile=v,e.useUrl=e=>{"string"==typeof e&&(n=e)},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
