var Common;!function(t){!function(e){"use strict";class r{constructor(t=e.FormatServiceHelper.DefaultServices){this.options={};this._services=t;this.options=new e.FormatterOptions}get canFormat(){return this.sourceText&&this.sourceText.text&&this.sourceText.text.trim().length>0}static supportsMimeType(t){if(t){var e=t.toLowerCase();return"text/html"===e||"application/xml"===e||e.lastIndexOf("+xml")===e.length-4}return!1}updateOptions(t){this.options.updateAllOptions(t)}setDocument(t,r,s,i,o){this.sourceText=new e.PositionOffsetMapper(t);this.options.prettyPrint&&o&&(this._prettyPrintPromise=this.startPrettyPrint());return Promise.resolve(null)}getFormattedText(t){if(this.options.prettyPrint){this._prettyPrintPromise=this._prettyPrintPromise||this.startPrettyPrint();return this._prettyPrintPromise}return Promise.resolve(this.sourceText)}startPrettyPrint(){return new Promise(r=>{window.setImmediate(()=>{var s=e.FormatServiceHelper.getWorkerServices(new t.Uri("Html/HtmlFormatWorker.js"),this._services),i=new Worker(s.path);i.onmessage=(t=>{var s=JSON.parse(t.data),o=new e.OffsetTextMapping(s.text,s.mappings,this.sourceText.text);i.terminate();r(o);this._prettyPrintPromise=null});i.onerror=(t=>{i.terminate();r(this.sourceText);this._prettyPrintPromise=null});i.postMessage({services:s.services,text:this.sourceText.text})})})}}e.HtmlFormatter=r}(t.FormatService||(t.FormatService={}))}(Common||(Common={}));
