import Logger from '@joplin/utils/Logger'; const logger = Logger.create('dialogs'); interface Smalltalk { alert(title: string, message: string): Promise; confirm(title: string, message: string, options: unknown): Promise; prompt(title: string, message: string, defaultValue: string, options: unknown): Promise; } class Dialogs { private activeWindow: Window|null; public setActiveWindow(win: Window) { this.activeWindow = win; } private get smalltalk(): Smalltalk { // The smalltalk library shows prompts in whichever document it is loaded in // (it uses the global document object). // As such, a copy of the library needs to be loaded in each window: if (this.activeWindow && 'smalltalk' in this.activeWindow) { return this.activeWindow.smalltalk as Smalltalk; } if ('smalltalk' in window) { return window.smalltalk as Smalltalk; } throw new Error('Unable to find the smalltalk library. Please make sure it has been loaded with a