import{w as m,i as p,t as i,p as y}from"./drawing-BQ51fstA.js";import{$ as s,a1 as c,cH as b}from"./App-CSvRzCsn.js";import"./sentry-common-2nFGZClv.js";import"./PrefsViewStore-B9QxYjkz.js";import"./index-F0fMEJXd.js";import"./index-CZYymlJf.js";import"./main-process-state-jW3BbbTQ.js";import"./index-jPDAJ20a.js";import"./report-dialog-DCdDPy0Y.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"4.2.860"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ce8a42db-b043-4fb5-9081-2c881a0ed5cf",e._sentryDebugIdIdentifier="sentry-dbid-ce8a42db-b043-4fb5-9081-2c881a0ed5cf")})()}catch{}const l=m(new Worker(new URL(""+new URL("worker-xH-lJce6.js",import.meta.url).href,import.meta.url),{type:"module"}));async function w(e,t,o){const r=await(await fetch(t)).arrayBuffer();if(logger.debug("heif image fetched",r.byteLength,"bytes"),p){const a=e.transferControlToOffscreen(),n=await l.decodeHeif(i(r,[r]));await l.draw(i(n,[n.data.buffer]),i(a,[a])),logger.debug("heif worker completed")}else{const a=await l.decodeHeif(i(r,[r]));y(e,a)}}const j=({src:e,...t})=>{const o=s.useRef(!1),[u,r]=s.useState(!0),[a,n]=s.useState(),g=s.useCallback(f=>{o.current=f==null,f&&(async()=>{try{await w(f,e,()=>{o.current||n("HEIF image failed to load")})}catch(d){logger.error("heif decode error",d),o.current||n(d instanceof Error?d.message:"HEIF image failed to decode")}finally{o.current||r(!1)}})()},[e]);return a?c.jsx(b,{error:a,className:t.className,style:t.style}):c.jsx("div",{"data-sentry-component":"HeifImg","data-sentry-source-file":"index.tsx",children:c.jsx("canvas",{className:u?"img loading":"img",ref:g,...t})})};export{j as default,w as drawHeifOnCanvas};
//# sourceMappingURL=index-Ba0CMaeO.js.map
