 
 import Cocoa
 import WebKit
+import Rc2Common
 import ClientCore
 import SyntaxParsing
 import ReactiveSwift
 import Down
+import MJLLogger
+
+// code to extract a zip file with preview_support locally is commented out because of a bug where WKWebView tries to load with %20 in app support url, which fails
 
 protocol LivePreviewOutputController {
 	/// might not need to be accessible

			guard let me = self else { return }
			me.parseContent()
		}
	}
	
	private func parseContent() {
		guard let curDoc = context.value?.currentDocument.value,
			let newText = curDoc.currentContents
		else {
			outputView?.loadHTMLString("", baseURL: nil)
			return
		}
		let content = """
			document.getElementById('foobar').innerText = <b>blow me</b>;
		"""
		outputView?.evaluateJavaScript(content, completionHandler: nil)
		// TODO: send file directory as baseURL
		//outputView.loadHTMLString(newText, baseURL: nil)
	}
	
	private func escapeForJavascript(_ source: String) -> String {

	func contentsEdited(range: NSRange, delta: Int) -> Bool
}

class LivePreviewDisplayController: AbstractSessionViewController, OutputController, LivePreviewOutputController, WKUIDelegate, WKNavigationDelegate
{
	var contextualMenuDelegate: ContextualMenuDelegate?
	var sessionController: SessionController?
	private var context: MutableProperty<EditorContext?> = MutableProperty<EditorContext?>(nil) { didSet { contextChanged() }}
	private let contextDisposables = CompositeDisposable()
	private var contentsDisposable: Disposable?
	private var lineContiuationRegex: NSRegularExpression!
	private var openDoubleDollarRegex: NSRegularExpression!
	private var closeDoubleDollarRegex: NSRegularExpression!
	private var documentRoot: URL?
	private var initialDocumentLoaded = false
	private var needToLoadDocumentOnLoad = false
	private var resourcesExtracted = false
	private var readyForContent: Bool { return resourcesExtracted && needToLoadDocumentOnLoad }
	private var parseInProgress = false
	
	var editorContext: EditorContext? {
		get { return context.value }
