"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MagickSettings = exports.NativeMagickSettings = void 0;
const image_magick_1 = require("../image-magick");
const native_instance_1 = require("../native-instance");
const string_1 = require("../native/string");
class NativeMagickSettings extends native_instance_1.NativeInstance {
    constructor(settings) {
        const instance = image_magick_1.ImageMagick._api._MagickSettings_Create();
        const disposeMethod = image_magick_1.ImageMagick._api._MagickSettings_Dispose;
        super(instance, disposeMethod);
        if (settings._fileName !== undefined) {
            string_1._withString(settings._fileName, (filenamePtr) => {
                image_magick_1.ImageMagick._api._MagickSettings_SetFileName(this._instance, filenamePtr);
            });
        }
        if (settings.format !== undefined) {
            string_1._withString(settings.format, (formatPtr) => {
                image_magick_1.ImageMagick._api._MagickSettings_Format_Set(this._instance, formatPtr);
            });
        }
    }
}
exports.NativeMagickSettings = NativeMagickSettings;
class MagickSettings {
    _clone() {
        const clone = new MagickSettings();
        return clone;
    }
    _use(func) {
        const settings = new NativeMagickSettings(this);
        try {
            return func(settings);
        }
        finally {
            settings.dispose();
        }
    }
}
exports.MagickSettings = MagickSettings;
