(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "./text-editor"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.BatchReplacementError = exports.FileExistsError = exports.TextEditorDocument = exports.FileNotFoundError = exports.InvalidPathError = exports.parseStrReplacements = exports.NoMatchFoundError = exports.MultipleMatchesError = exports.InvalidViewRangeError = exports.InvalidLineNumberError = exports.formatTextWithLineNumbers = exports.findDivergenceContext = void 0;
    const text_editor_1 = require("./text-editor");
    Object.defineProperty(exports, "findDivergenceContext", { enumerable: true, get: function () { return text_editor_1.findDivergenceContext; } });
    Object.defineProperty(exports, "formatTextWithLineNumbers", { enumerable: true, get: function () { return text_editor_1.formatTextWithLineNumbers; } });
    Object.defineProperty(exports, "InvalidLineNumberError", { enumerable: true, get: function () { return text_editor_1.InvalidLineNumberError; } });
    Object.defineProperty(exports, "InvalidViewRangeError", { enumerable: true, get: function () { return text_editor_1.InvalidViewRangeError; } });
    Object.defineProperty(exports, "MultipleMatchesError", { enumerable: true, get: function () { return text_editor_1.MultipleMatchesError; } });
    Object.defineProperty(exports, "NoMatchFoundError", { enumerable: true, get: function () { return text_editor_1.NoMatchFoundError; } });
    Object.defineProperty(exports, "parseStrReplacements", { enumerable: true, get: function () { return text_editor_1.parseStrReplacements; } });
    class InvalidPathError extends text_editor_1.InvalidPathError {
        constructor(path, supportedPath = '/workflow.js', message) {
            super(path, supportedPath, message);
        }
    }
    exports.InvalidPathError = InvalidPathError;
    class FileNotFoundError extends text_editor_1.FileNotFoundError {
        constructor(message = 'No workflow code exists yet. Use create first.') {
            super(message);
        }
    }
    exports.FileNotFoundError = FileNotFoundError;
    class TextEditorDocument extends text_editor_1.TextEditorDocument {
        constructor(options = {}) {
            const fileNotFoundMessage = options.fileNotFoundMessage ?? 'No workflow code exists yet. Use create first.';
            super({
                ...options,
                fileNotFoundMessage,
            });
            this.fileNotFoundMessage = fileNotFoundMessage;
        }
        createInvalidPathError(path, supportedPath, message) {
            return new InvalidPathError(path, supportedPath, message);
        }
        createFileNotFoundError() {
            return new FileNotFoundError(this.fileNotFoundMessage);
        }
    }
    exports.TextEditorDocument = TextEditorDocument;
    class FileExistsError extends Error {
        constructor() {
            super('File already exists. Use text editor tools to modify existing content.');
            this.name = 'FileExistsError';
        }
    }
    exports.FileExistsError = FileExistsError;
    class BatchReplacementError extends Error {
        constructor(failedIndex, totalCount, cause) {
            super(`Batch replacement failed at index ${failedIndex} of ${totalCount}: ${cause.message}. All changes have been rolled back.`);
            this.name = 'BatchReplacementError';
            this.failedIndex = failedIndex;
            this.totalCount = totalCount;
            this.cause = cause;
        }
    }
    exports.BatchReplacementError = BatchReplacementError;
});
//# sourceMappingURL=workflow-text-editor.js.map