// Version Comparison Component class VersionComparison { constructor(options = {}) { this.container = null; this.versions = new Map(); this.selectedVersions = new Set(); this.maxSelections = options.maxSelections || 3; this.onCompare = options.onCompare || (() => {}); this.onRollback = options.onRollback || (() => {}); this.timeline = null; } initialize(containerId) { this.container = document.getElementById(containerId); if (!this.container) { throw new Error(`Container element with id "${containerId}" not found`); } this._initializeTimeline(); } setVersions(versions) { this.versions = new Map(versions.map(v => [v.name, v])); this._updateTimeline(); this.render(); } _initializeTimeline() { this.timeline = document.createElement('div'); this.timeline.className = 'version-timeline'; this.container.appendChild(this.timeline); } _updateTimeline() { const sortedVersions = Array.from(this.versions.values()) .sort((a, b) => new Date(a.created_at) - new Date(b.created_at)); this.timeline.innerHTML = `
${this._escapeHtml(change.old_value)}
${this._escapeHtml(change.new_value)}