UNPKG

@imagemagick/magick-wasm

Version:
1,963 lines (1,962 loc) 276 kB
//#region src/byte-array.ts function e(e) { return e instanceof Int8Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray; } //#endregion //#region src/configuration/configuration-file.ts var t = class { fileName; data; constructor(e, t) { this.fileName = e, this.data = t; } }, n = { XmlResourceFiles: { log: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE logmap [\n<!ELEMENT logmap (log)+>\n<!ELEMENT log (#PCDATA)>\n<!ATTLIST log events CDATA #IMPLIED>\n<!ATTLIST log output CDATA #IMPLIED>\n<!ATTLIST log filename CDATA #IMPLIED>\n<!ATTLIST log generations CDATA #IMPLIED>\n<!ATTLIST log limit CDATA #IMPLIED>\n<!ATTLIST log format CDATA #IMPLIED>\n]>\n<logmap>\n <log events=\"None\"/>\n <log output=\"Debug\"/>\n <log filename=\"Magick-%g.log\"/>\n <log generations=\"3\"/>\n <log limit=\"2000\"/>\n <log format=\"%t %r %u %v %d %c[%p]: %m/%f/%l/%d\n %e\"/>\n</logmap>\n", policy: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE policymap [\n<!ELEMENT policymap (policy)*>\n<!ATTLIST policymap xmlns CDATA #FIXED \"\">\n<!ELEMENT policy EMPTY>\n<!ATTLIST policy xmlns CDATA #FIXED \"\">\n<!ATTLIST policy domain NMTOKEN #REQUIRED>\n<!ATTLIST policy name NMTOKEN #IMPLIED>\n<!ATTLIST policy pattern CDATA #IMPLIED>\n<!ATTLIST policy rights NMTOKEN #IMPLIED>\n<!ATTLIST policy stealth NMTOKEN #IMPLIED>\n<!ATTLIST policy value CDATA #IMPLIED>\n]>\n<policymap>\n <policy domain=\"cache\" name=\"shared-secret\" value=\"passphrase\"/>\n <policy domain=\"coder\" rights=\"none\" pattern=\"EPHEMERAL\" />\n <policy domain=\"coder\" rights=\"none\" pattern=\"MVG\" />\n <policy domain=\"coder\" rights=\"none\" pattern=\"MSL\" />\n <policy domain=\"path\" rights=\"none\" pattern=\"@*\" />\n <policy domain=\"path\" rights=\"none\" pattern=\"|*\" />\n</policymap>\n" } }, r = class e { constructor() { this.log = new t("log.xml", n.XmlResourceFiles.log), this.policy = new t("policy.xml", n.XmlResourceFiles.policy); } static default = new e(); *all() { yield this.log, yield this.policy; } log; policy; }, i = class { constructor(e, t, n) { this.format = e, this.name = t, this.value = n; } format; name; value; }, a = class { format; constructor(e) { this.format = e; } createDefine(e, t) { return typeof t == "boolean" ? new i(this.format, e, t ? "true" : "false") : typeof t == "string" ? new i(this.format, e, t) : new i(this.format, e, t.toString()); } hasValue(e) { return e != null; } }, o = class e { _scaleX; _scaleY; _shearX; _shearY; _translateX; _translateY; constructor(e = 1, t = 1, n = 0, r = 0, i = 0, a = 0) { this._scaleX = e, this._scaleY = t, this._shearX = n, this._shearY = r, this._translateX = i, this._translateY = a; } get scaleX() { return this._scaleX; } get scaleY() { return this._scaleY; } get shearX() { return this._shearX; } get shearY() { return this._shearY; } get translateX() { return this._translateX; } get translateY() { return this._translateY; } draw(e) { e.affine(this._scaleX, this._scaleY, this._shearX, this._shearY, this._translateX, this._translateY); } reset() { this._scaleX = 1, this._scaleY = 1, this._shearX = 0, this._shearY = 0, this._translateX = 0, this._translateY = 0; } transformOrigin(t, n) { let r = new e(); r._translateX = t, r._translateY = n, this.transform(r); } transformRotation(t) { let n = new e(); n._scaleX = Math.cos(e.normalizeAngleToRadians(t)), n._scaleY = Math.cos(e.normalizeAngleToRadians(t)), n._shearX = -Math.sin(e.normalizeAngleToRadians(t)), n._shearY = Math.sin(e.normalizeAngleToRadians(t)), this.transform(n); } transformScale(t, n) { let r = new e(); r._scaleX = t, r._scaleY = n, this.transform(r); } transformSkewX(t) { let n = new e(); n._shearX = Math.tan(e.normalizeAngleToRadians(t)), this.transform(n); } transformSkewY(t) { let n = new e(); n._shearY = Math.tan(e.normalizeAngleToRadians(t)), this.transform(n); } static normalizeAngleToRadians(e) { let t = e / 360, n = Math.round(t); return Math.abs(t - n) === .5 && n % 2 != 0 && (n = t > 0 ? n - 1 : n + 1), Math.PI * (e - n * 360) / 180; } transform(e) { let t = this._scaleX, n = this._scaleY, r = this._shearX, i = this._shearY, a = this._translateX, o = this._translateY; this._scaleX = t * e._scaleX + i * e._shearX, this._scaleY = r * e._shearY + n * e._scaleY, this._shearX = r * e._scaleX + n * e._shearX, this._shearY = t * e._shearY + i * e._scaleY, this._translateX = t * e._translateX + i * e._translateY + a, this._translateY = r * e._translateX + n * e._translateY + o; } }, s = class { _color; constructor(e) { this._color = e; } get color() { return this._color; } draw(e) { e.borderColor(this._color); } }, c = class { _x; _y; _paintMethod; constructor(e, t, n) { this._x = e, this._y = t, this._paintMethod = n; } get x() { return this._x; } get y() { return this._y; } get paintMethod() { return this._paintMethod; } draw(e) { e.color(this._x, this._y, this._paintMethod); } }, l = class { _color; constructor(e) { this._color = e; } get color() { return this._color; } draw(e) { e.fillColor(this._color); } }, u = class { _opacity; constructor(e) { this._opacity = e; } get opacity() { return this._opacity; } draw(e) { e.fillOpacity(this._opacity.toDouble() / 100); } }, d = class { _fillRule; constructor(e) { this._fillRule = e; } get fillRule() { return this._fillRule; } draw(e) { e.fillRule(this._fillRule); } }, f = class { _pointSize; constructor(e) { this._pointSize = e; } get pointSize() { return this._pointSize; } draw(e) { e.fontPointSize(this._pointSize); } }, p = class { constructor(e, t) { this.eventType = e, this.message = t ?? ""; } eventType; message; }, ee = { Undefined: 0, Activate: 1, Associate: 2, Background: 3, Copy: 4, Deactivate: 5, Discrete: 6, Disassociate: 7, Extract: 8, Off: 9, On: 10, Opaque: 11, Remove: 12, Set: 13, Shape: 14, Transparent: 15, OffIfOpaque: 16 }, m = { Red: 0, Cyan: 0, Gray: 0, Green: 1, Magenta: 1, Blue: 2, Yellow: 2, Black: 3, Alpha: 4, Index: 5, Meta0: 10, Meta1: 11, Meta2: 12, Meta3: 13, Meta4: 14, Meta5: 15, Meta6: 16, Meta7: 17, Meta8: 18, Meta9: 19, Meta10: 20, Meta11: 21, Meta12: 22, Meta13: 23, Meta14: 24, Meta15: 25, Meta16: 26, Meta17: 27, Meta18: 28, Meta19: 29, Meta20: 30, Meta21: 31, Meta22: 32, Meta23: 33, Meta24: 34, Meta25: 35, Meta26: 36, Meta27: 37, Meta28: 38, Meta29: 39, Meta30: 40, Meta31: 41, Meta32: 42, Meta33: 43, Meta34: 44, Meta35: 45, Meta36: 46, Meta37: 47, Meta38: 48, Meta39: 49, Meta40: 50, Meta41: 51, Meta42: 52, Meta43: 53, Meta44: 54, Meta45: 55, Meta46: 56, Meta47: 57, Meta48: 58, Meta49: 59, Meta50: 60, Meta51: 61, Meta52: 62, Composite: 64 }, h = { Undefined: 0, Red: 1, Gray: 1, Cyan: 1, Green: 2, Magenta: 2, Blue: 4, Yellow: 4, Black: 8, Alpha: 16, Opacity: 16, Index: 32, Composite: 31, TrueAlpha: 256, get RGB() { return this.Red | this.Green | this.Blue; }, get CMYK() { return this.Cyan | this.Magenta | this.Yellow | this.Black; }, get CMYKA() { return this.Cyan | this.Magenta | this.Yellow | this.Black | this.Alpha; }, Meta0: 1 << m.Meta0, Meta1: 1 << m.Meta1, Meta2: 1 << m.Meta2, Meta3: 1 << m.Meta3, Meta4: 1 << m.Meta4, Meta5: 1 << m.Meta5, Meta6: 1 << m.Meta6, Meta7: 1 << m.Meta7, Meta8: 1 << m.Meta8, Meta9: 1 << m.Meta9, Meta10: 1 << m.Meta10, Meta11: 1 << m.Meta11, Meta12: 1 << m.Meta12, Meta13: 1 << m.Meta13, Meta14: 1 << m.Meta14, Meta15: 1 << m.Meta15, Meta16: 1 << m.Meta16, Meta17: 1 << m.Meta17, Meta18: 1 << m.Meta18, Meta19: 1 << m.Meta19, Meta20: 1 << m.Meta20, Meta21: 1 << m.Meta21, All: 134217727 }, te = class { constructor(e, t, n, r) { this.red = e, this.green = t, this.blue = n, this.white = r; } red; green; blue; white; }, g = { Undefined: 0, CMY: 1, CMYK: 2, Gray: 3, HCL: 4, HCLp: 5, HSB: 6, HSI: 7, HSL: 8, HSV: 9, HWB: 10, Lab: 11, LCH: 12, LCHab: 13, LCHuv: 14, Log: 15, LMS: 16, Luv: 17, OHTA: 18, Rec601YCbCr: 19, Rec709YCbCr: 20, RGB: 21, scRGB: 22, sRGB: 23, Transparent: 24, XyY: 25, XYZ: 26, YCbCr: 27, YCC: 28, YDbDr: 29, YIQ: 30, YPbPr: 31, YUV: 32, LinearGray: 33, Jzazbz: 34, DisplayP3: 35, Adobe98: 36, ProPhoto: 37, Oklab: 38, Oklch: 39, CAT02LMSC: 40 }, ne = { [g.Undefined]: "Undefined", [g.CMY]: "CMY", [g.CMYK]: "CMYK", [g.Gray]: "Gray", [g.HCL]: "HCL", [g.HCLp]: "HCLp", [g.HSB]: "HSB", [g.HSI]: "HSI", [g.HSL]: "HSL", [g.HSV]: "HSV", [g.HWB]: "HWB", [g.Lab]: "Lab", [g.LCH]: "LCH", [g.LCHab]: "LCHab", [g.LCHuv]: "LCHuv", [g.Log]: "Log", [g.LMS]: "LMS", [g.Luv]: "Luv", [g.OHTA]: "OHTA", [g.Rec601YCbCr]: "Rec601YCbCr", [g.Rec709YCbCr]: "Rec709YCbCr", [g.RGB]: "RGB", [g.scRGB]: "scRGB", [g.sRGB]: "sRGB", [g.Transparent]: "Transparent", [g.XyY]: "XyY", [g.XYZ]: "XYZ", [g.YCbCr]: "YCbCr", [g.YCC]: "YCC", [g.YDbDr]: "YDbDr", [g.YIQ]: "YIQ", [g.YPbPr]: "YPbPr", [g.YUV]: "YUV", [g.LinearGray]: "LinearGray", [g.Jzazbz]: "Jzazbz", [g.DisplayP3]: "DisplayP3", [g.Adobe98]: "Adobe98", [g.ProPhoto]: "ProPhoto", [g.Oklab]: "Oklab", [g.Oklch]: "Oklch", [g.CAT02LMSC]: "CAT02LMS" }, _ = class { colorSpace = g.Undefined; copyright = null; description = null; manufacturer = null; model = null; }, v = class { _data; _index; constructor(e) { this._data = e, this._index = 0, this.isLittleEndian = !1; } get index() { return this._index; } isLittleEndian; readLong() { return this.canRead(4) ? this.isLittleEndian ? this.readLongLSB() : this.readLongMSB() : null; } readString(e) { if (e == 0) return ""; if (!this.canRead(e)) return null; let t = new TextDecoder("utf-8").decode(this._data.subarray(this._index, this._index + e)), n = t.indexOf("\0"); return n != -1 && (t = t.substring(0, n)), this._index += e, t; } seek(e) { return e >= this._data.length ? !1 : (this._index = e, !0); } skip(e) { return this._index + e >= this._data.length ? !1 : (this._index += e, !0); } canRead(e) { return e > this._data.length ? !1 : this._index + e <= this._data.length; } readLongLSB() { let e = this._data[this._index]; return e |= this._data[this._index + 1] << 8, e |= this._data[this._index + 2] << 16, e |= this._data[this._index + 3] << 24, this._index += 4, e; } readLongMSB() { let e = this._data[this._index] << 24; return e |= this._data[this._index + 1] << 16, e |= this._data[this._index + 2] << 8, e |= this._data[this._index + 3], this._index += 4, e; } }, y = class e { _data = new _(); _reader; constructor(e) { this._reader = new v(e); } static read(t) { let n = new e(t); return n.readColorSpace(), n.readTagTable(), n._data; } readColorSpace() { this._reader.seek(16); let e = this._reader.readString(4); e != null && (this._data.colorSpace = this.determineColorSpace(e.trimEnd())); } determineColorSpace(e) { switch (e) { case "CMY": return g.CMY; case "CMYK": return g.CMYK; case "GRAY": return g.Gray; case "HSL": return g.HSL; case "HSV": return g.HSV; case "Lab": return g.Lab; case "Luv": return g.Luv; case "RGB": return g.sRGB; case "XYZ": return g.XYZ; case "YCbr": return g.YCbCr; default: return g.Undefined; } } readTagTable() { if (!this._reader.seek(128)) return; let e = this._reader.readLong(); if (e != null) for (let t = 0; t < e; t++) switch (this._reader.readLong()) { case 1668313716: this._data.copyright = this.readTag(); break; case 1684370275: this._data.description = this.readTag(); break; case 1684893284: this._data.manufacturer = this.readTag(); break; case 1684890724: this._data.model = this.readTag(); break; default: this._reader.skip(8); break; } } readTag() { let e = this._reader.readLong(), t = this._reader.readLong(); if (e === null || t === null) return null; let n = this._reader.index; if (!this._reader.seek(e)) return null; let r = this.readTagValue(t); return this._reader.seek(n), r; } readTagValue(e) { switch (this._reader.readString(4)) { case "desc": return this.readTextDescriptionTypeValue(); case "text": return this.readTextTypeValue(e); default: return null; } } readTextDescriptionTypeValue() { if (!this._reader.skip(4)) return null; let e = this._reader.readLong(); return e == null ? null : this._reader.readString(e); } readTextTypeValue(e) { return this._reader.skip(4) ? this._reader.readString(e) : null; } }, re = class { constructor(e, t) { this.name = e, this.data = t; } name; data; }, b = class extends re { _data; constructor(e) { super("icc", e); } get colorSpace() { return this.initialize(), this._data.colorSpace; } get copyright() { return this.initialize(), this._data.copyright; } get description() { return this.initialize(), this._data.description; } get manufacturer() { return this.initialize(), this._data.manufacturer; } get model() { return this.initialize(), this._data.model; } initialize() { this._data ||= y.read(this.data); } }, x = { HighRes: 0, Quantum: 1 }, ie = class e { constructor(e, t) { this.distortion = e, this.difference = t; } difference; distortion; static _create(t, n) { return new e(t, n); } }, S = class { constructor(e) { this.metric = e; } metric; highlightColor; lowlightColor; masklightColor; _setArtifacts(e) { this.highlightColor !== void 0 && e.setArtifact("compare:highlight-color", this.highlightColor), this.lowlightColor !== void 0 && e.setArtifact("compare:lowlight-color", this.lowlightColor), this.masklightColor !== void 0 && e.setArtifact("compare:masklight-color", this.masklightColor); } }, ae = { Undefined: 0, Alpha: 1, Atop: 2, Blend: 3, Blur: 4, Bumpmap: 5, ChangeMask: 6, Clear: 7, ColorBurn: 8, ColorDodge: 9, Colorize: 10, CopyBlack: 11, CopyBlue: 12, Copy: 13, CopyCyan: 14, CopyGreen: 15, CopyMagenta: 16, CopyAlpha: 17, CopyRed: 18, CopyYellow: 19, Darken: 20, DarkenIntensity: 21, Difference: 22, Displace: 23, Dissolve: 24, Distort: 25, DivideDst: 26, DivideSrc: 27, DstAtop: 28, Dst: 29, DstIn: 30, DstOut: 31, DstOver: 32, Exclusion: 33, HardLight: 34, HardMix: 35, Hue: 36, In: 37, Intensity: 38, Lighten: 39, LightenIntensity: 40, LinearBurn: 41, LinearDodge: 42, LinearLight: 43, Luminize: 44, Mathematics: 45, MinusDst: 46, MinusSrc: 47, Modulate: 48, ModulusAdd: 49, ModulusSubtract: 50, Multiply: 51, No: 52, Out: 53, Over: 54, Overlay: 55, PegtopLight: 56, PinLight: 57, Plus: 58, Replace: 59, Saturate: 60, Screen: 61, SoftLight: 62, SrcAtop: 63, Src: 64, SrcIn: 65, SrcOut: 66, SrcOver: 67, Threshold: 68, VividLight: 69, Xor: 70, Stereo: 71, Freeze: 72, Interpolate: 73, Negate: 74, Reflect: 75, SoftBurn: 76, SoftDodge: 77, Stamp: 78, RMSE: 79, SaliencyBlend: 80, SeamlessBlend: 81 }, oe = { Warning: 300, ResourceLimitWarning: 300, TypeWarning: 305, OptionWarning: 310, DelegateWarning: 315, MissingDelegateWarning: 320, CorruptImageWarning: 325, FileOpenWarning: 330, BlobWarning: 335, StreamWarning: 340, CacheWarning: 345, CoderWarning: 350, FilterWarning: 352, ModuleWarning: 355, DrawWarning: 360, ImageWarning: 365, WandWarning: 370, RandomWarning: 375, XServerWarning: 380, MonitorWarning: 385, RegistryWarning: 390, ConfigureWarning: 395, PolicyWarning: 399, Error: 400, ResourceLimitError: 400, TypeError: 405, OptionError: 410, DelegateError: 415, MissingDelegateError: 420, CorruptImageError: 425, FileOpenError: 430, BlobError: 435, StreamError: 440, CacheError: 445, CoderError: 450, FilterError: 452, ModuleError: 455, DrawError: 460, ImageError: 465, WandError: 470, RandomError: 475, XServerError: 480, MonitorError: 485, RegistryError: 490, ConfigureError: 495, PolicyError: 499 }, C = class extends Error { _relatedErrors = []; constructor(e, t = oe.Error) { super(e), this.severity = t; } severity; get relatedErrors() { return this._relatedErrors; } _setRelatedErrors(e) { this._relatedErrors = e; } }, w = class { static get depth() { return V._api._Quantum_Depth_Get(); } static get max() { return V._api._Quantum_Max_Get(); } }; //#endregion //#region src/internal/native/string.ts function T(e, t) { return e === 0 ? t ?? null : V._api.UTF8ToString(e); } function se(e, t) { let n = T(t); return e._MagickMemory_Relinquish(t), n; } function ce(e, t, n) { let r = e.lengthBytesUTF8(t) + 1, i = e._malloc(r); try { return e.stringToUTF8(t, i, r), n(i); } finally { e._free(i); } } function E(e, t) { return e === null ? t(0) : ce(V._api, e, t); } //#endregion //#region src/magick-color.ts var D = class e { constructor(e, t, n, r, i) { if (e !== void 0) if (typeof e == "string") { let t = 0; try { t = V._api._MagickColor_Create(), E(e, (e) => { if (V._api._MagickColor_Initialize(t, e) === 0) throw new C("invalid color specified"); this.initialize(t); }); } finally { V._api._free(t); } } else this.r = e, this.g = t ?? 0, this.b = n ?? 0, i === void 0 ? this.a = r ?? w.max : (this.k = r ?? 0, this.a = i, this.isCmyk = !0); } r = 0; g = 0; b = 0; a = 0; k = 0; isCmyk = !1; static _create(t) { let n = new e(); return n.initialize(t), n; } fuzzyEquals(e, t) { return e == this ? !0 : this._use((n) => e._use((e) => V._api._MagickColor_FuzzyEquals(n, e, t._toQuantum()) === 1)); } toShortString() { return this.a === w.max ? this.isCmyk ? `cmyka(${this.r},${this.g},${this.b},${this.k})` : `#${this.toHex(this.r)}${this.toHex(this.g)}${this.toHex(this.b)}` : this.toString(); } toString() { return this.isCmyk ? `cmyka(${this.r},${this.g},${this.b},${this.k},${(this.a / w.max).toFixed(4)})` : `#${this.toHex(this.r)}${this.toHex(this.g)}${this.toHex(this.b)}${this.toHex(this.a)}`; } _use(e) { let t = 0; try { return t = V._api._MagickColor_Create(), V._api._MagickColor_Red_Set(t, this.r), V._api._MagickColor_Green_Set(t, this.g), V._api._MagickColor_Blue_Set(t, this.b), V._api._MagickColor_Alpha_Set(t, this.a), this.isCmyk ? (V._api._MagickColor_Black_Set(t, this.k), V._api._MagickColor_IsCMYK_Set(t, 1)) : V._api._MagickColor_IsCMYK_Set(t, 0), e(t); } finally { V._api._MagickColor_Dispose(t); } } initialize(e) { this.r = V._api._MagickColor_Red_Get(e), this.g = V._api._MagickColor_Green_Get(e), this.b = V._api._MagickColor_Blue_Get(e), this.a = V._api._MagickColor_Alpha_Get(e), this.isCmyk = V._api._MagickColor_IsCMYK_Get(e) === 1, this.isCmyk && (this.k = V._api._MagickColor_Black_Get(e)); } toHex(e) { return e.toString(16).padStart(2, "0"); } }, le = /* @__PURE__ */ function(e) { return e[e.NoValue = 0] = "NoValue", e[e.PercentValue = 4096] = "PercentValue", e[e.IgnoreAspectRatio = 8192] = "IgnoreAspectRatio", e[e.Less = 16384] = "Less", e[e.Greater = 32768] = "Greater", e[e.FillArea = 65536] = "FillArea", e[e.LimitPixels = 131072] = "LimitPixels", e[e.AspectRatio = 1048576] = "AspectRatio", e; }({}), O = class e { _includeXyInToString; _width = 0; _height = 0; _x = 0; _y = 0; _aspectRatio = !1; _fillArea = !1; _greater = !1; _isPercentage = !1; _ignoreAspectRatio = !1; _less = !1; _limitPixels = !1; constructor(e, t, n, r) { if (typeof e == "number") { if (n !== void 0 && r !== void 0 ? (this._width = n, this._height = r, this._x = e, this._y = t ?? 0, this._includeXyInToString = !0) : (this._width = e, this._height = t ?? this._width, this._x = 0, this._y = 0, this._includeXyInToString = !1), this._width < 0) throw new C("negative width is not allowed"); if (this._height < 0) throw new C("negative height is not allowed"); } else { this._includeXyInToString = e.indexOf("+") >= 0 || e.indexOf("-") >= 0; let t = V._api._MagickGeometry_Create(); try { E(e, (n) => { let r = V._api._MagickGeometry_Initialize(t, n); if (r === le.NoValue) throw new C("invalid geometry specified"); this.hasFlag(r, le.AspectRatio) ? this.initializeFromAspectRation(t, e) : this.initialize(t, r); }); } finally { V._api._MagickGeometry_Dispose(t); } } } get aspectRatio() { return this._aspectRatio; } get fillArea() { return this._fillArea; } set fillArea(e) { this._fillArea = e; } get greater() { return this._greater; } set greater(e) { this._greater = e; } get height() { return this._height; } set height(e) { this._height = e; } get ignoreAspectRatio() { return this._ignoreAspectRatio; } set ignoreAspectRatio(e) { this._ignoreAspectRatio = e; } get isPercentage() { return this._isPercentage; } set isPercentage(e) { this._isPercentage = e; } get less() { return this._less; } set less(e) { this._less = e; } get limitPixels() { return this._limitPixels; } set limitPixels(e) { this._limitPixels = e; } get width() { return this._width; } set width(e) { this._width = e; } get x() { return this._x; } set x(e) { this._x = e; } get y() { return this._y; } set y(e) { this._y = e; } toString() { if (this._aspectRatio) return this._width + ":" + this._height; let e = ""; return this._width == 0 && this._height == 0 ? e += "0x0" : (this._width > 0 && (e += this._width.toString()), this._height > 0 ? e += "x" + this._height.toString() : e += "x"), (this._x != 0 || this._y != 0 || this._includeXyInToString) && (this._x >= 0 && (e += "+"), e += this._x, this.y >= 0 && (e += "+"), e += this.y), this._fillArea && (e += "^"), this._greater && (e += ">"), this._isPercentage && (e += "%"), this._ignoreAspectRatio && (e += "!"), this._less && (e += "<"), this._limitPixels && (e += "@"), e; } static _fromRectangle(t) { if (t === 0) throw new C("unable to allocate memory"); try { let n = V._api._MagickRectangle_Width_Get(t), r = V._api._MagickRectangle_Height_Get(t); return new e(V._api._MagickRectangle_X_Get(t), V._api._MagickRectangle_Y_Get(t), n, r); } finally { V._api._MagickRectangle_Dispose(t); } } _toRectangle(e) { let t = V._api._MagickRectangle_Create(); if (t === 0) throw new C("unable to allocate memory"); try { return V._api._MagickRectangle_Width_Set(t, this._width), V._api._MagickRectangle_Height_Set(t, this._height), V._api._MagickRectangle_X_Set(t, this._x), V._api._MagickRectangle_Y_Set(t, this._y), e(t); } finally { V._api._MagickRectangle_Dispose(t); } } initialize(e, t) { this._width = V._api._MagickGeometry_Width_Get(e), this._height = V._api._MagickGeometry_Height_Get(e), this._x = V._api._MagickGeometry_X_Get(e), this._y = V._api._MagickGeometry_Y_Get(e), this._ignoreAspectRatio = this.hasFlag(t, le.IgnoreAspectRatio), this._isPercentage = this.hasFlag(t, le.PercentValue), this._fillArea = this.hasFlag(t, le.FillArea), this._greater = this.hasFlag(t, le.Greater), this._less = this.hasFlag(t, le.Less), this._limitPixels = this.hasFlag(t, le.LimitPixels); } initializeFromAspectRation(e, t) { this._aspectRatio = !0; let n = t.split(":"); this._width = this.parseNumber(n[0]), this._height = this.parseNumber(n[1]), this._x = V._api._MagickGeometry_X_Get(e), this._y = V._api._MagickGeometry_Y_Get(e); } parseNumber(e) { let t = 0; for (; t < e.length && !this.isNumber(e[t]);) t++; let n = t; for (; t < e.length && this.isNumber(e[t]);) t++; return parseInt(e.substr(n, t - n)); } isNumber(e) { return e >= "0" && e <= "9"; } hasFlag(e, t) { return (e & t) === t; } }, ue = class e { constructor(e, t) { this.x = e, this.y = t ?? e; } x; y; static _create(t) { return t === 0 ? new e(0, 0) : new e(V._api._PointInfo_X_Get(t), V._api._PointInfo_Y_Get(t)); } }, de = class e { constructor(e) { this.area = V._api._ConnectedComponent_GetArea(e), this.centroid = ue._create(V._api._ConnectedComponent_GetCentroid(e)), this.color = D._create(V._api._ConnectedComponent_GetColor(e)), this.height = V._api._ConnectedComponent_GetHeight(e), this.id = V._api._ConnectedComponent_GetId(e), this.width = V._api._ConnectedComponent_GetWidth(e), this.x = V._api._ConnectedComponent_GetX(e), this.y = V._api._ConnectedComponent_GetY(e); } area; centroid; color; height; id; width; x; y; static _create(t, n) { let r = []; if (t === 0) return r; for (let i = 0; i < n; i++) { let n = V._api._ConnectedComponent_GetInstance(t, i); n === 0 || V._api._ConnectedComponent_GetArea(n) < 2 ** -52 || r.push(new e(n)); } return r; } toGeometry() { return new O(this.x, this.y, this.width, this.height); } }, fe = class { angleThreshold; areaThreshold; circularityThreshold; connectivity; diameterThreshold; eccentricityThreshold; majorAxisThreshold; meanColor; minorAxisThreshold; perimeterThreshold; constructor(e) { this.connectivity = e; } _setArtifacts(e) { this.angleThreshold !== void 0 && e.setArtifact("connected-components:angle-threshold", this.angleThreshold.toString()), this.areaThreshold !== void 0 && e.setArtifact("connected-components:area-threshold", this.areaThreshold.toString()), this.circularityThreshold !== void 0 && e.setArtifact("connected-components:circularity-threshold", this.circularityThreshold.toString()), this.diameterThreshold !== void 0 && e.setArtifact("connected-components:diameter-threshold", this.diameterThreshold.toString()), this.eccentricityThreshold !== void 0 && e.setArtifact("connected-components:eccentricity-threshold", this.eccentricityThreshold.toString()), this.majorAxisThreshold !== void 0 && e.setArtifact("connected-components:major-axis-threshold", this.majorAxisThreshold.toString()), this.meanColor !== void 0 && e.setArtifact("connected-components:mean-color", this.meanColor.toString()), this.minorAxisThreshold !== void 0 && e.setArtifact("connected-components:minor-axis-threshold", this.minorAxisThreshold.toString()), this.perimeterThreshold !== void 0 && e.setArtifact("connected-components:perimeter-threshold", this.perimeterThreshold.toString()); } }, pe = { Undefined: 0, PixelsPerInch: 1, PixelsPerCentimeter: 2 }, me = class e { constructor(e, t, n) { t === void 0 ? (this.x = e, this.y = e, this.units = pe.PixelsPerInch) : n === void 0 ? (this.x = e, this.y = e, this.units = t) : (this.x = e, this.y = t, this.units = n); } x; y; units; toString(t) { return t == this.units || t === pe.Undefined || t === void 0 ? e.toString(this.x, this.y, t ?? pe.Undefined) : this.units == pe.PixelsPerCentimeter && t == pe.PixelsPerInch ? e.toString(this.x * 2.54, this.y * 2.54, t) : e.toString(this.x / 2.54, this.y / 2.54, t); } static toString(e, t, n) { let r = `${e}x${t}`; switch (n) { case pe.PixelsPerCentimeter: r += "cm"; break; case pe.PixelsPerInch: r += "inch"; break; } return r; } }, k = class e { static _disposeAfterExecution(t, n) { try { let r = n(t); return r instanceof Promise ? Promise.resolve(r).then((n) => (t.dispose(), e.checkResult(t, n), n)) : (t.dispose(), e.checkResult(t, r), r); } catch (e) { throw t.dispose(), e; } } static checkResult(e, t) { if (t === e) throw new C("The result of the function cannot be the instance that has been disposed."); return t; } }, he = class { _pointer; _bytes; _func; constructor(e, t, n) { this._pointer = e, this._func = n, this._bytes = V._api.HEAPU8.subarray(e, e + t); } func(e) { return e._bytes === void 0 ? e._func(new Uint8Array()) : e._func(e._bytes); } dispose() { this._pointer = V._api._MagickMemory_Relinquish(this._pointer); } }, ge = class { instance; type; constructor(e, t) { this.instance = V._api._malloc(e), this.type = t, V._api.setValue(this.instance, 0, this.type); } get ptr() { return this.instance; } get value() { return V._api.getValue(this.instance, this.type); } }, _e = class e extends ge { constructor() { super(4, "i32"); } static use(t) { let n = new e(); try { return t(n); } finally { V._api._free(n.ptr); } } }, A = class e { pointer; constructor(e) { this.pointer = e; } get ptr() { return this.pointer.ptr; } check(e, t) { return this.isError() ? t() : e(); } static usePointer(t, n) { return _e.use((r) => { let i = t(r.ptr); return e.checkException(r, i, n); }); } static use(t, n) { return _e.use((r) => { let i = t(new e(r)); return e.checkException(r, i, n); }); } static checkException(t, n, r) { if (!e.isRaised(t)) return n; let i = e.getErrorSeverity(t.value); return i >= oe.Error ? e.throw(t, i) : r === void 0 ? e.dispose(t) : r(e.createError(t.value, i)), n; } isError() { return e.isRaised(this.pointer) ? e.getErrorSeverity(this.pointer.value) >= oe.Error : !1; } static getErrorSeverity(e) { return V._api._MagickExceptionHelper_Severity(e); } static isRaised(e) { return e.value !== 0; } static throw(t, n) { let r = e.createError(t.value, n); throw e.dispose(t), r; } static createError(t, n) { let r = new C(e.getMessage(t), n), i = V._api._MagickExceptionHelper_RelatedCount(t); if (i === 0) return r; let a = []; for (let n = 0; n < i; n++) { let r = V._api._MagickExceptionHelper_Related(t, n), i = e.getErrorSeverity(r), o = e.createError(r, i); a.push(o); } return r._setRelatedErrors(a), r; } static getMessage(e) { let t = V._api._MagickExceptionHelper_Message(e), n = V._api._MagickExceptionHelper_Description(e), r = T(t, "Unknown error"); return n !== 0 && (r += `(${V._api.UTF8ToString(n)})`), r; } static dispose(e) { V._api._MagickExceptionHelper_Dispose(e.value); } }, ve = class { disposeMethod; instance; constructor(e, t) { this.instance = e, this.disposeMethod = t; } get _instance() { if (this.instance > 0) return this.instance; throw this.instance === -1 && this._instanceNotInitialized(), new C("instance is disposed"); } set _instance(e) { this.disposeInstance(this.instance), this.instance = e; } dispose() { this.instance = this.disposeInstance(this.instance); } _instanceNotInitialized() { throw new C("instance is not initialized"); } _setInstance(e, t) { return t.check(() => this.instance === 0 ? !1 : (this.dispose(), this.instance = e, !0), () => (this.disposeInstance(e), !0)); } disposeInstance(e) { return e > 0 && (this.onDispose !== void 0 && this.onDispose(), this.disposeMethod(e)), 0; } }, ye = class e { constructor(e, t, n, r, i, a, o) { this.ascent = e, this.descent = t, this.maxHorizontalAdvance = n, this.textHeight = r, this.textWidth = i, this.underlinePosition = a, this.underlineThickness = o; } ascent; descent; maxHorizontalAdvance; textHeight; textWidth; underlinePosition; underlineThickness; static _create(t) { if (t == 0) return null; try { return new e(V._api._TypeMetric_Ascent_Get(t), V._api._TypeMetric_Descent_Get(t), V._api._TypeMetric_MaxHorizontalAdvance_Get(t), V._api._TypeMetric_TextHeight_Get(t), V._api._TypeMetric_TextWidth_Get(t), V._api._TypeMetric_UnderlinePosition_Get(t), V._api._TypeMetric_UnderlineThickness_Get(t)); } finally { V._api._TypeMetric_Dispose(t); } } }; //#endregion //#region src/internal/native/array.ts function be(e, t) { if (e.byteLength === 0) throw new C("The specified array cannot be empty"); let n = 0; try { return n = V._api._malloc(e.byteLength), V._api.HEAPU8.set(e, n), t(n); } finally { n !== 0 && V._api._free(n); } } function xe(e, t) { if (e.length === 0) throw new C("The specified array cannot be empty"); let n = e.length * 8, r = 0; try { r = V._api._malloc(n); let i = new ArrayBuffer(n), a = new Float64Array(i); for (let t = 0; t < e.length; t++) a[t] = e[t]; return V._api.HEAPU8.set(new Int8Array(i), r), t(r); } finally { r !== 0 && V._api._free(r); } } function Se(e, t) { if (e.byteLength === 0) throw new C("The specified array cannot be empty"); let n = 0; try { return n = V._api._malloc(e.byteLength), V._api.HEAPU8.set(e, n), t(n); } finally { n !== 0 && V._api._free(n); } } //#endregion //#region src/drawing/drawing-wand.ts var Ce = class e extends ve { constructor(e) { let t = e.settings._drawing._use((t) => V._api._DrawingWand_Create(e._instance, t._instance)), n = V._api._DrawingWand_Dispose; super(t, n); } affine(e, t, n, r, i, a) { A.usePointer((o) => { V._api._DrawingWand_Affine(this._instance, e, t, n, r, i, a, o); }); } borderColor(e) { A.usePointer((t) => { e._use((e) => { V._api._DrawingWand_BorderColor(this._instance, e, t); }); }); } color(e, t, n) { A.usePointer((r) => { V._api._DrawingWand_Color(this._instance, e, t, n, r); }); } draw(e) { e.forEach((e) => { e.draw(this); }), A.usePointer((e) => { V._api._DrawingWand_Render(this._instance, e); }); } fillColor(e) { A.usePointer((t) => { e._use((e) => { V._api._DrawingWand_FillColor(this._instance, e, t); }); }); } fillOpacity(e) { A.usePointer((t) => { V._api._DrawingWand_FillOpacity(this._instance, e, t); }); } fillRule(e) { A.usePointer((t) => { V._api._DrawingWand_FillRule(this._instance, e, t); }); } font(e) { A.usePointer((t) => { E(e, (e) => { V._api._DrawingWand_Font(this._instance, e, t); }); }); } fontPointSize(e) { A.usePointer((t) => { V._api._DrawingWand_FontPointSize(this._instance, e, t); }); } fontTypeMetrics(e, t) { return A.usePointer((n) => E(e, (e) => { let r = V._api._DrawingWand_FontTypeMetrics(this._instance, e, +!!t, n); return ye._create(r); })); } gravity(e) { A.usePointer((t) => { V._api._DrawingWand_Gravity(this._instance, e, t); }); } line(e, t, n, r) { A.usePointer((i) => { V._api._DrawingWand_Line(this._instance, e, t, n, r, i); }); } pathFinish() { A.usePointer((e) => { V._api._DrawingWand_PathFinish(this._instance, e); }); } pathLineToAbs(e, t) { A.usePointer((n) => { V._api._DrawingWand_PathLineToAbs(this._instance, e, t, n); }); } pathLineToRel(e, t) { A.usePointer((n) => { V._api._DrawingWand_PathLineToRel(this._instance, e, t, n); }); } pathMoveToAbs(e, t) { A.usePointer((n) => { V._api._DrawingWand_PathMoveToAbs(this._instance, e, t, n); }); } pathMoveToRel(e, t) { A.usePointer((n) => { V._api._DrawingWand_PathMoveToRel(this._instance, e, t, n); }); } pathStart() { A.usePointer((e) => { V._api._DrawingWand_PathStart(this._instance, e); }); } point(e, t) { A.usePointer((n) => { V._api._DrawingWand_Point(this._instance, e, t, n); }); } rectangle(e, t, n, r) { A.usePointer((i) => { V._api._DrawingWand_Rectangle(this._instance, e, t, n, r, i); }); } roundRectangle(e, t, n, r, i, a) { A.usePointer((o) => { V._api._DrawingWand_RoundRectangle(this._instance, e, t, n, r, i, a, o); }); } strokeColor(e) { A.usePointer((t) => { e._use((e) => { V._api._DrawingWand_StrokeColor(this._instance, e, t); }); }); } strokeDashArray(e) { A.usePointer((t) => { xe(e, (n) => { V._api._DrawingWand_StrokeDashArray(this._instance, n, e.length, t); }); }); } strokeDashOffset(e) { A.usePointer((t) => { V._api._DrawingWand_StrokeDashOffset(this._instance, e, t); }); } strokeWidth(e) { A.usePointer((t) => { V._api._DrawingWand_StrokeWidth(this._instance, e, t); }); } text(e, t, n) { A.usePointer((r) => { E(n, (n) => { V._api._DrawingWand_Text(this._instance, e, t, n, r); }); }); } textAlignment(e) { A.usePointer((t) => { V._api._DrawingWand_TextAlignment(this._instance, e, t); }); } textAntialias(e) { A.usePointer((t) => { V._api._DrawingWand_TextAntialias(this._instance, +!!e, t); }); } textDecoration(e) { A.usePointer((t) => { V._api._DrawingWand_TextDecoration(this._instance, e, t); }); } textInterlineSpacing(e) { A.usePointer((t) => { V._api._DrawingWand_TextInterlineSpacing(this._instance, e, t); }); } textInterwordspacing(e) { A.usePointer((t) => { V._api._DrawingWand_TextInterwordSpacing(this._instance, e, t); }); } textKerning(e) { A.usePointer((t) => { V._api._DrawingWand_TextKerning(this._instance, e, t); }); } textUnderColor(e) { A.usePointer((t) => { e._use((e) => { V._api._DrawingWand_TextUnderColor(this._instance, e, t); }); }); } static _use(t, n) { let r = new e(t); return k._disposeAfterExecution(r, n); } }, we = class e extends ge { constructor() { super(8, "double"); } static use(t) { let n = new e(); try { return t(n); } finally { V._api._free(n.ptr); } } }, j = { Undefined: 0, Forget: 0, Northwest: 1, North: 2, Northeast: 3, West: 4, Center: 5, East: 6, Southwest: 7, South: 8, Southeast: 9 }; function* Te(e) { for (let t of e) switch (t) { case j.North: yield "north"; break; case j.Northeast: yield "north", yield "east"; break; case j.Northwest: yield "north", yield "west"; break; case j.East: yield "east"; break; case j.West: yield "west"; break; case j.South: yield "south"; break; case j.Southeast: yield "south", yield "east"; break; case j.Southwest: yield "south", yield "west"; } } function M(e) { switch (e) { case j.North: return "north"; case j.Northeast: return "northeast"; case j.Northwest: return "northwest"; case j.East: return "east"; case j.West: return "west"; case j.South: return "south"; case j.Southeast: return "southeast"; case j.Southwest: return "southwest"; case j.Center: return "center"; default: return; } } //#endregion //#region src/types/magick-error-info.ts var N = class e { constructor(e, t, n) { this.meanErrorPerPixel = e, this.normalizedMeanError = t, this.normalizedMaximumError = n; } meanErrorPerPixel; normalizedMaximumError; normalizedMeanError; static _create(t) { return new e(V._api._MagickImage_MeanErrorPerPixel_Get(t._instance), V._api._MagickImage_NormalizedMeanError_Get(t._instance), V._api._MagickImage_NormalizedMaximumError_Get(t._instance)); } }, Ee = { Unknown: "UNKNOWN", ThreeFr: "3FR", ThreeG2: "3G2", ThreeGp: "3GP", A: "A", Aai: "AAI", Ai: "AI", APng: "APNG", Art: "ART", Arw: "ARW", Ashlar: "ASHLAR", Avci: "AVCI", Avi: "AVI", Avif: "AVIF", Avs: "AVS", B: "B", Bayer: "BAYER", Bayera: "BAYERA", Bgr: "BGR", Bgra: "BGRA", Bgro: "BGRO", Bmp: "BMP", Bmp2: "BMP2", Bmp3: "BMP3", Brf: "BRF", C: "C", Cal: "CAL", Cals: "CALS", Canvas: "CANVAS", Caption: "CAPTION", Cin: "CIN", Cip: "CIP", Clip: "CLIP", Cmyk: "CMYK", Cmyka: "CMYKA", Cr2: "CR2", Cr3: "CR3", Crw: "CRW", Cube: "CUBE", Cur: "CUR", Cut: "CUT", Data: "DATA", Dcm: "DCM", Dcr: "DCR", Dcraw: "DCRAW", Dcx: "DCX", Dds: "DDS", Dfont: "DFONT", Dng: "DNG", Dpx: "DPX", Dxt1: "DXT1", Dxt5: "DXT5", Epdf: "EPDF", Epi: "EPI", Eps: "EPS", Eps2: "EPS2", Eps3: "EPS3", Epsf: "EPSF", Epsi: "EPSI", Ept: "EPT", Ept2: "EPT2", Ept3: "EPT3", Erf: "ERF", Exr: "EXR", Farbfeld: "FARBFELD", Fax: "FAX", Ff: "FF", Fff: "FFF", File: "FILE", Fits: "FITS", Fl32: "FL32", Flv: "FLV", Fractal: "FRACTAL", Ftp: "FTP", Fts: "FTS", Ftxt: "FTXT", G: "G", G3: "G3", G4: "G4", Gif: "GIF", Gif87: "GIF87", Gradient: "GRADIENT", Gray: "GRAY", Graya: "GRAYA", Group4: "GROUP4", Hald: "HALD", Hdr: "HDR", Heic: "HEIC", Heif: "HEIF", Histogram: "HISTOGRAM", Hrz: "HRZ", Htm: "HTM", Html: "HTML", Http: "HTTP", Https: "HTTPS", Icb: "ICB", Ico: "ICO", Icon: "ICON", Icn: "ICN", Iiq: "IIQ", Info: "INFO", Inline: "INLINE", Ipl: "IPL", Isobrl: "ISOBRL", Isobrl6: "ISOBRL6", J2c: "J2C", J2k: "J2K", Jng: "JNG", Jnx: "JNX", Jp2: "JP2", Jpc: "JPC", Jpe: "JPE", Jpeg: "JPEG", Jpg: "JPG", Jpm: "JPM", Jps: "JPS", Jpt: "JPT", Json: "JSON", Jxl: "JXL", K: "K", K25: "K25", Kdc: "KDC", Label: "LABEL", M: "M", M2v: "M2V", M4v: "M4V", Mac: "MAC", Map: "MAP", Mask: "MASK", Mat: "MAT", Matte: "MATTE", Mdc: "MDC", Mef: "MEF", Miff: "MIFF", Mkv: "MKV", Mng: "MNG", Mono: "MONO", Mov: "MOV", Mos: "MOS", Mp4: "MP4", Mpc: "MPC", Mpeg: "MPEG", Mpg: "MPG", Mpo: "MPO", Mrw: "MRW", Msl: "MSL", Msvg: "MSVG", Mtv: "MTV", Mvg: "MVG", Nef: "NEF", Nrw: "NRW", Null: "NULL", O: "O", Ora: "ORA", Orf: "ORF", Otb: "OTB", Otf: "OTF", Pal: "PAL", Palm: "PALM", Pam: "PAM", Pango: "PANGO", Pattern: "PATTERN", Pbm: "PBM", Pcd: "PCD", Pcds: "PCDS", Pcl: "PCL", Pct: "PCT", Pcx: "PCX", Pdb: "PDB", Pdf: "PDF", Pdfa: "PDFA", Pef: "PEF", Pes: "PES", Pfa: "PFA", Pfb: "PFB", Pfm: "PFM", Pgm: "PGM", Pgx: "PGX", Phm: "PHM", Picon: "PICON", Pict: "PICT", Pix: "PIX", Pjpeg: "PJPEG", Plasma: "PLASMA", Png: "PNG", Png00: "PNG00", Png24: "PNG24", Png32: "PNG32", Png48: "PNG48", Png64: "PNG64", Png8: "PNG8", Pnm: "PNM", Pocketmod: "POCKETMOD", Ppm: "PPM", Ps: "PS", Ps2: "PS2", Ps3: "PS3", Psb: "PSB", Psd: "PSD", Ptif: "PTIF", Pwp: "PWP", Qoi: "QOI", R: "R", RadialGradient: "RADIAL-GRADIENT", Raf: "RAF", Ras: "RAS", Raw: "RAW", Rgb: "RGB", Rgb565: "RGB565", Rgba: "RGBA", Rgbo: "RGBO", Rgf: "RGF", Rla: "RLA", Rle: "RLE", Rmf: "RMF", Rw2: "RW2", Rwl: "RWL", Scr: "SCR", Screenshot: "SCREENSHOT", Sct: "SCT", Sf3: "SF3", Sfw: "SFW", Sgi: "SGI", Shtml: "SHTML", Six: "SIX", Sixel: "SIXEL", SparseColor: "SPARSE-COLOR", Sr2: "SR2", Srf: "SRF", Srw: "SRW", Stegano: "STEGANO", Sti: "STI", StrImg: "STRIMG", Sun: "SUN", Svg: "SVG", Svgz: "SVGZ", Text: "TEXT", Tga: "TGA", Thumbnail: "THUMBNAIL", Tif: "TIF", Tiff: "TIFF", Tiff64: "TIFF64", Tile: "TILE", Tim: "TIM", Tm2: "TM2", Ttc: "TTC", Ttf: "TTF", Txt: "TXT", Ubrl: "UBRL", Ubrl6: "UBRL6", Uil: "UIL", Uyvy: "UYVY", Vda: "VDA", Vicar: "VICAR", Vid: "VID", Viff: "VIFF", Vips: "VIPS", Vst: "VST", WebM: "WEBM", WebP: "WEBP", Wbmp: "WBMP", Wmv: "WMV", Wpg: "WPG", X3f: "X3F", Xbm: "XBM", Xc: "XC", Xcf: "XCF", Xpm: "XPM", Xps: "XPS", Xv: "XV", Y: "Y", Yaml: "YAML", Ycbcr: "YCBCR", Ycbcra: "YCBCRA", Yuv: "YUV" }, De = { Undefined: 0, Coalesce: 1, CompareAny: 2, CompareClear: 3, CompareOverlay: 4, Dispose: 5, Optimize: 6, OptimizeImage: 7, OptimizePlus: 8, OptimizeTrans: 9, RemoveDups: 10, RemoveZero: 11, Composite: 12, Merge: 13, Flatten: 14, Mosaic: 15, Trimbounds: 16 }, P = class extends ve { constructor(e) { let t = V._api._DrawingSettings_Create(), n = V._api._DrawingSettings_Dispose; super(t, n); let r = e.affine; r !== void 0 && V._api._DrawingSettings_SetAffine(this._instance, r.scaleX, r.scaleY, r.shearX, r.shearY, r.translateX, r.translateY), e.borderColor !== void 0 && e.borderColor._use((e) => { V._api._DrawingSettings_BorderColor_Set(this._instance, e); }), e.fillColor !== void 0 && e.fillColor._use((e) => { V._api._DrawingSettings_FillColor_Set(this._instance, e); }), e.fillRule !== void 0 && V._api._DrawingSettings_FillRule_Set(this._instance, e.fillRule), e.font !== void 0 && E($e._getFontFileName(e.font), (e) => { V._api._DrawingSettings_Font_Set(this._instance, e); }), e.fontPointsize !== void 0 && V._api._DrawingSettings_FontPointsize_Set(this._instance, e.fontPointsize), e.strokeColor !== void 0 && e.strokeColor._use((e) => { V._api._DrawingSettings_StrokeColor_Set(this._instance, e); }); let i = e.strokeDashArray; i !== void 0 && xe(i, (e) => { V._api._DrawingSettings_SetStrokeDashArray(this._instance, e, i.length); }), e.strokeDashOffset !== void 0 && V._api._DrawingSettings_StrokeDashOffset_Set(this._instance, e.strokeDashOffset), e.strokeWidth !== void 0 && V._api._DrawingSettings_StrokeWidth_Set(this._instance, e.strokeWidth), e.textAntiAlias !== void 0 && V._api._DrawingSettings_TextAntiAlias_Set(this._instance, +!!e.textAntiAlias), e.textGravity !== void 0 && V._api._DrawingSettings_TextGravity_Set(this._instance, e.textGravity), e.textKerning !== void 0 && V._api._DrawingSettings_TextKerning_Set(this._instance, e.textKerning), e.textUnderColor !== void 0 && e.textUnderColor._use((e) => { V._api._DrawingSettings_TextUnderColor_Set(this._instance, e); }); } setFillColor(e) { e === void 0 ? V._api._DrawingSettings_FillColor_Set(this._instance, 0) : e._use((e) => { V._api._DrawingSettings_FillColor_Set(this._instance, e); }); } setFillPattern(e) { A.usePointer((t) => { e === void 0 ? V._api._DrawingSettings_SetFillPattern(this._instance, 0, t) : V._api._DrawingSettings_SetFillPattern(this._instance, e._instance, t); }); } }, Oe = class { affine; borderColor; backgroundColor; fillColor; fillRule; font; fontPointsize; strokeColor; strokeDashArray; strokeDashOffset; strokeWidth; textAntiAlias; textGravity; textKerning; textUnderColor; _use(e) { let t = new P(this); return k._disposeAfterExecution(t, e); } }, ke = { Undefined: 0, EvenOdd: 1, NonZero: 2 }, F = class extends ve { constructor(e) { let t = V._api._MagickSettings_Create(), n = V._api._MagickSettings_Dispose; super(t, n), e._colorFuzz !== void 0 && V._api._MagickSettings_SetColorFuzz(this._instance, e._colorFuzz), e._fileName !== void 0 && E(e._fileName, (e) => { V._api._MagickSettings_SetFileName(this._instance, e); }), e._ping && V._api._MagickSettings_SetPing(this._instance, 1), e._quality !== void 0 && V._api._MagickSettings_SetQuality(this._instance, e._quality), e.antiAlias !== void 0 && V._api._MagickSettings_AntiAlias_Set(this._instance, +!!e.antiAlias), e.backgroundColor !== void 0 && e.backgroundColor._use((e) => { V._api._MagickSettings_BackgroundColor_Set(this._instance, e); }), e.colorSpace !== void 0 && V._api._MagickSettings_ColorSpace_Set(this._instance, e.colorSpace), e.colorType !== void 0 && V._api._MagickSettings_ColorType_Set(this._instance, e.colorType), e.compression !== void 0 && V._api._MagickSettings_Compression_Set(this._instance, e.compression), e.debug !== void 0 && V._api._MagickSettings_Debug_Set(this._instance, +!!e.debug), e.density !== void 0 && E(e.density.toString(), (e) => { V._api._MagickSettings_Density_Set(this._instance, e); }), e.depth !== void 0 && V._api._MagickSettings_Depth_Set(this._instance, e.depth), e.endian !== void 0 && V._api._MagickSettings_Endian_Set(this._instance, e.endian), e.fillColor !== void 0 && this.setOption("fill", e.fillColor.toString()), e.font !== void 0 && E($e._getFontFileName(e.font), (e) => { V._api._MagickSettings_SetFont(this._instance, e); }), e.fontPointsize !== void 0 && V._api._MagickSettings_FontPointsize_Set(this._instance, e.fontPointsize), e.format !== void 0 && E(e.format, (e) => { V._api._MagickSettings_Format_Set(this._instance, e); }), e.interlace !== void 0 && V._api._MagickSettings_Interlace_Set(this._instance, e.interlace), e.page !== void 0 && E(e.page.toString(), (e) => { V._api._MagickSettings_SetPage(this._instance, e); }), e.strokeColor !== void 0 && this.setOption("stroke", e.strokeColor.toString()), e.strokeWidth !== void 0 && this.setOption("strokeWidth", e.strokeWidth.toString()), e.textInterlineSpacing !== void 0 && this.setOption("interline-spacing", e.textInterlineSpacing.toString()); for (let t in e._options) this.setOption(t, e._options[t]); } setOption(e, t) { E(e, (e) => { E(t, (t) => { V._api._MagickSettings_SetOption(this._instance, e, t); }); }); } }, Ae = class e { _colorFuzz; _drawing = new Oe(); _fileName; _onArtifact; _options = {}; _ping = !1; _quality; get affine() { return this._drawing.affine; } set affine(e) { this._drawing.affine = e; } antiAlias; backgroundColor; get borderColor() { return this._drawing.borderColor; } set borderColor(e) { this._drawing.borderColor = e; } colorSpace; colorType; compression; debug; density; depth; endian; get fillColor() { return this._drawing.fillColor; } set fillColor(e) { this.setDefineAndArtifact("fill", e?.toString()), this._drawing.fillColor = e; } get fillRule() { return this._drawing.fillRule ?? ke.Undefined; } set fillRule(e) { this._drawing.fillRule = e; } get font() { return this._drawing.font; } set font(e) { this._drawing.font = e; } get fontPointsize() { return this._drawing.fontPointsize; } set fontPointsize(e) { this._drawing.fontPointsize = e; } format; interlace; page; get strokeColor() { return this._drawing.strokeColor; } set strokeColor(e) { this._drawing.strokeColor = e; } get strokeDashArray() { return this._drawing.strokeDashArray; } set strokeDashArray(e) { this._drawing.strokeDashArray = e; } get strokeDashOffset() { return this._drawing.strokeDashOffset; } set strokeDashOffset(e) { this._drawing.strokeDashOffset = e; } get strokeWidth() { return this._drawing.strokeWidth; } set strokeWidth(e) { this.setDefineAndArtifact("stroke", e?.toString()), this._drawing.strokeWidth = e; } get textAntiAlias() { return this._drawing.textAntiAlias; } set textAntiAlias(e) { this._drawing.textAntiAlias = e; } textInterlineSpacing; get textKerning() { return this._drawing.textKerning; } set textKerning(e) { this.setDefineAndArtifact("kerning", e?.toString()), this._drawing.textKerning = e; } get textGravity() { return this._drawing.textGravity; } set textGravity(e) { this.setDefineAndArtifact("gravity", M(e)), this._drawing.textGravity = e; } get textUnderColor() { return this._drawing.textUnderColor; } set textUnderColor(e) { this._drawing.textUnderColor = e; } getDefine(e, t) { return t === void 0 ? this._options[e] ?? null : this._options[`${e}:${t}`] ?? null; } removeDefine(e, t) { if (t === void 0) delete this._options[e]; else { let n = this.parseDefine(e, t); delete this._options[n]; } } setDefine(e, t, n) { if (n === void 0) this._options[e] = t; else { let r = this.parseDefine(e, t); typeof n == "string" ? this._options[r] = n : typeof n == "number" ? this._options[r] = n.toString() : this._options[r] = n ? "true" : "false"; } } setDefines(e) {