{"version":3,"sources":["node_modules/@arcgis/core/core/imageUtils.js"],"sourcesContent":["/*\nAll material copyright ESRI, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/4.31/esri/copyright.txt for details.\n*/\nimport t from \"../request.js\";\nimport e from \"./Error.js\";\nimport { isAbortError as r } from \"./promiseUtils.js\";\nimport { dataComponents as a } from \"./urlUtils.js\";\nimport { base64ToArrayBuffer as n } from \"../support/base64Utils.js\";\nlet i = null,\n o = !0;\nfunction s(t, e, r) {\n if (!t || !e) throw new Error(\"Cannot construct image data without dimensions\");\n if (o) try {\n return new ImageData(t, e);\n } catch (a) {\n o = !1;\n }\n return m(t, e, r);\n}\nfunction c(t, e, r, a) {\n if (!e || !r) throw new Error(\"Cannot construct image data without dimensions\");\n if (o) try {\n return new ImageData(t, e, r);\n } catch (i) {\n o = !1;\n }\n const n = m(e, r, a);\n return n.data.set(t, 0), n;\n}\nfunction f() {\n return i || (i = document.createElement(\"canvas\"), i.width = 1, i.height = 1), i;\n}\nfunction m(t, e, r) {\n return r || (r = f()), r.getContext(\"2d\").createImageData(t, e);\n}\nasync function u(a, n) {\n const i = window.URL.createObjectURL(a);\n try {\n const {\n data: e\n } = await t(i, {\n ...n,\n responseType: \"image\"\n });\n return e;\n } catch (o) {\n if (!r(o)) throw new e(\"invalid-image\", `Could not fetch requested image at ${i}`);\n throw o;\n } finally {\n window.URL.revokeObjectURL(i);\n }\n}\nasync function p(t, e) {\n const {\n arrayBuffer: r,\n mediaType: a\n } = await d(t, e),\n n = \"image/png\" === a;\n if (\"image/gif\" === a) {\n const {\n isAnimatedGIF: t,\n parseGif: a\n } = await import(\"./image/gif.js\");\n if (t(r)) return a(r, e);\n }\n if (n) {\n const {\n isAnimatedPNG: t,\n parseApng: a\n } = await import(\"./image/apng.js\");\n if (t(r)) return a(r, e);\n }\n return u(new Blob([r], {\n type: a\n }), e);\n}\nasync function d(e, r) {\n const i = a(e);\n if (i?.isBase64) return {\n arrayBuffer: n(i.data),\n mediaType: i.mediaType\n };\n const o = await t(e, {\n responseType: \"array-buffer\",\n ...r\n });\n return {\n arrayBuffer: o.data,\n mediaType: o.getHeader?.(\"Content-Type\") ?? \"\"\n };\n}\nexport { s as createEmptyImageData, p as getImageData, c as wrapImageData };"],"mappings":"6NASA,IAAIA,EAAI,KACNC,EAAI,GACN,SAASC,EAAEC,EAAGC,EAAGC,EAAG,CAClB,GAAI,CAACF,GAAK,CAACC,EAAG,MAAM,IAAI,MAAM,gDAAgD,EAC9E,GAAIH,EAAG,GAAI,CACT,OAAO,IAAI,UAAUE,EAAGC,CAAC,CAC3B,MAAY,CACVH,EAAI,EACN,CACA,OAAOK,EAAEH,EAAGC,EAAGC,CAAC,CAClB,CACA,SAASE,EAAEJ,EAAGC,EAAGC,EAAGG,EAAG,CACrB,GAAI,CAACJ,GAAK,CAACC,EAAG,MAAM,IAAI,MAAM,gDAAgD,EAC9E,GAAIJ,EAAG,GAAI,CACT,OAAO,IAAI,UAAUE,EAAGC,EAAGC,CAAC,CAC9B,MAAY,CACVJ,EAAI,EACN,CACA,IAAMQ,EAAIH,EAAEF,EAAGC,EAAGG,CAAC,EACnB,OAAOC,EAAE,KAAK,IAAIN,EAAG,CAAC,EAAGM,CAC3B,CACA,SAASC,GAAI,CACX,OAAOV,IAAMA,EAAI,SAAS,cAAc,QAAQ,EAAGA,EAAE,MAAQ,EAAGA,EAAE,OAAS,GAAIA,CACjF,CACA,SAASM,EAAEH,EAAGC,EAAGC,EAAG,CAClB,OAAOA,IAAMA,EAAIK,EAAE,GAAIL,EAAE,WAAW,IAAI,EAAE,gBAAgBF,EAAGC,CAAC,CAChE,CACA,SAAeO,EAAEH,EAAGC,EAAG,QAAAG,EAAA,sBACrB,IAAMZ,EAAI,OAAO,IAAI,gBAAgBQ,CAAC,EACtC,GAAI,CACF,GAAM,CACJ,KAAMJ,CACR,EAAI,MAAMS,EAAEb,EAAGc,EAAAC,EAAA,GACVN,GADU,CAEb,aAAc,OAChB,EAAC,EACD,OAAOL,CACT,OAASH,EAAG,CACV,MAAKe,EAAEf,CAAC,EACFA,EADW,IAAIC,EAAE,gBAAiB,sCAAsCF,CAAC,EAAE,CAEnF,QAAE,CACA,OAAO,IAAI,gBAAgBA,CAAC,CAC9B,CACF,GACA,SAAeiB,EAAEd,EAAGC,EAAG,QAAAQ,EAAA,sBACrB,GAAM,CACF,YAAaP,EACb,UAAWG,CACb,EAAI,MAAMU,EAAEf,EAAGC,CAAC,EAChBK,EAAoBD,IAAhB,YACN,GAAoBA,IAAhB,YAAmB,CACrB,GAAM,CACJ,cAAeL,EACf,SAAUK,CACZ,EAAI,KAAM,QAAO,qBAAgB,EACjC,GAAIL,EAAEE,CAAC,EAAG,OAAOG,EAAEH,EAAGD,CAAC,CACzB,CACA,GAAIK,EAAG,CACL,GAAM,CACJ,cAAeN,EACf,UAAWK,CACb,EAAI,KAAM,QAAO,qBAAiB,EAClC,GAAIL,EAAEE,CAAC,EAAG,OAAOG,EAAEH,EAAGD,CAAC,CACzB,CACA,OAAOO,EAAE,IAAI,KAAK,CAACN,CAAC,EAAG,CACrB,KAAMG,CACR,CAAC,EAAGJ,CAAC,CACP,GACA,SAAec,EAAE,EAAGb,EAAG,QAAAO,EAAA,sBACrB,IAAMZ,EAAImB,EAAE,CAAC,EACb,GAAInB,GAAG,SAAU,MAAO,CACtB,YAAaG,EAAEH,EAAE,IAAI,EACrB,UAAWA,EAAE,SACf,EACA,IAAMC,EAAI,MAAMY,EAAE,EAAGE,EAAA,CACnB,aAAc,gBACXV,EACJ,EACD,MAAO,CACL,YAAaJ,EAAE,KACf,UAAWA,EAAE,YAAY,cAAc,GAAK,EAC9C,CACF","names":["i","o","s","t","e","r","m","c","a","n","f","u","__async","U","__spreadProps","__spreadValues","b","p","d","ot"],"x_google_ignoreList":[0]}