import { PatchableFileModel } from './PatchableFileModel.js';
export default class PatchableRawContentModel extends PatchableFileModel {
    constructor(options) {
        super(options);
        this.changeListener = this.changeListener.bind(this);
    }
    changeListener() {
        this.handleChange();
        this.dispatchEvent(new Event('change'));
    }
    setupFile(content) {
        this.raw = content;
        const typed = content;
        typed.addEventListener('change', this.changeListener);
        this.setupPreviousData(content);
    }
    createRevision() {
        return JSON.parse(JSON.stringify(this.value));
    }
    readValue() {
        const v = this.value;
        if (v) {
            return JSON.parse(JSON.stringify(this.value));
        }
        return v;
    }
    setValue(content) {
        if (this.value) {
            const typed = this.value;
            typed.removeEventListener('change', this.changeListener);
        }
        const typed = content;
        typed.addEventListener('change', this.changeListener);
        this.raw = content;
        this.changeListener();
    }
}
//# sourceMappingURL=PatchableRawContentModel.js.map