((e,o)=>{"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.postscribe=o():e.postscribe=o()})(this,function(){return r=[function(e,o,t){var t=t(1),t=(t=t)&&t.__esModule?t:{default:t};e.exports=t.default},function(e,o,t){function s(){}function c(){var e,o=d.shift();o&&((e=n.last(o)).afterDequeue(),o.stream=function(e,o,r){function n(e){e=r.beforeWrite(e),f.write(e),r.afterWrite(e)}(f=new _.default(e,r)).id=l++,f.name=r.name||f.id,a.streams[f.name]=f;var t=e.ownerDocument,i={close:t.close,open:t.open,write:t.write,writeln:t.writeln},d=(p(t,{close:s,open:s,write:function(){for(var e=arguments.length,o=Array(e),t=0;t{if(e&&e.__esModule)return e;var o={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[t]=e[t]);return o.default=e,o})(t(4)),i={afterAsync:s,afterDequeue:s,afterStreamStart:s,afterWrite:s,autoFix:!0,beforeEnqueue:s,beforeWriteToken:function(e){return e},beforeWrite:function(e){return e},done:s,error:function(e){throw new Error(e.msg)},releaseAsync:!1},l=0,d=[],f=null;p(a,{streams:{},queue:d,WriteStream:_.default})},function(e,o,t){function r(e,o){e=e.getAttribute(p+o);return c.existy(e)?String(e):e}function n(e,o,t){t=2{if(e&&e.__esModule)return e;var o={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[t]=e[t]);return o.default=e,o})(t(4)),p="data-ps-",_="ps-style",l="ps-script";function a(e){var o=1)/," "+p+"id="+s+" $1")),c.attrs.id!==l&&c.attrs.id!==_&&n.push("atomicTag"===c.type?"":"<"+c.tagName+" "+p+"proxyof="+s+(c.unary?" />":">"))):(r.push(a),n.push("endTag"===c.type?a:""))}return{tokens:e,raw:t.join(""),actual:r.join(""),proxy:n.join("")}},a.prototype._walkChunk=function(){for(var e,o=[this.proxyRoot];c.existy(e=o.shift());){var t=1===e.nodeType;!(t&&r(e,"proxyof"))&&(t&&n(this.actuals[r(e,"id")]=e,"id"),t=e.parentNode&&r(e.parentNode,"proxyof"))&&this.actuals[t].appendChild(e),o.unshift.apply(o,c.toArray(e.childNodes))}},a.prototype._handleScriptToken=function(e){var o=this,t=this.parser.clear();t&&this.writeQueue.unshift(t),e.src=e.attrs.src||e.attrs.SRC,(e=this.options.beforeWriteToken(e))&&(e.src&&this.scriptStack.length?this.deferredRemote=e:this._onScriptStart(e),this._writeScriptToken(e,function(){o._onScriptDone(e)}))},a.prototype._handleStyleToken=function(e){var o=this.parser.clear();o&&this.writeQueue.unshift(o),e.type=e.attrs.type||e.attrs.TYPE||"text/css",(e=this.options.beforeWriteToken(e))&&this._writeStyleToken(e),o&&this.write()},a.prototype._writeStyleToken=function(e){var o=this._buildStyle(e);this._insertCursor(o,_),e.content&&(o.styleSheet&&!o.sheet?o.styleSheet.cssText=e.content:o.appendChild(this.doc.createTextNode(e.content)))},a.prototype._buildStyle=function(e){var t=this.doc.createElement(e.tagName);return t.setAttribute("type",e.type),c.eachKey(e.attrs,function(e,o){t.setAttribute(e,o)}),t},a.prototype._insertCursor=function(e,o){this._writeImpl('');o=this.doc.getElementById(o);o&&o.parentNode.replaceChild(e,o)},a.prototype._onScriptStart=function(e){e.outerWrites=this.writeQueue,this.writeQueue=[],this.scriptStack.unshift(e)},a.prototype._onScriptDone=function(e){return e!==this.scriptStack[0]?void this.options.error({msg:"Bad script nesting or script finished twice"}):(this.scriptStack.shift(),this.write.apply(this,e.outerWrites),void(!this.scriptStack.length&&this.deferredRemote&&(this._onScriptStart(this.deferredRemote),this.deferredRemote=null)))},a.prototype._writeScriptToken=function(e,o){var t=this._buildScript(e),r=this._shouldRelease(t),n=this.options.afterAsync;e.src&&(t.src=e.src,this._scriptLoadHandler(t,r?n:function(){o(),n()}));try{this._insertCursor(t,l),t.src&&!r||o()}catch(e){this.options.error(e),o()}},a.prototype._buildScript=function(e){var t=this.doc.createElement(e.tagName);return c.eachKey(e.attrs,function(e,o){t.setAttribute(e,o)}),e.content&&(t.text=e.content),t},a.prototype._scriptLoadHandler=function(o,t){function r(){o=o.onload=o.onreadystatechange=o.onerror=null}function e(){r(),null!=t&&t(),t=null}function n(e){r(),d(e),null!=t&&t(),t=null}function i(e,o){var t=e["on"+o];null!=t&&(e["_on"+o]=t)}var d=this.options.error;i(o,"load"),i(o,"error"),s(o,{onload:function(){if(o._onload)try{o._onload.apply(this,Array.prototype.slice.call(arguments,0))}catch(e){n({msg:"onload handler failed "+e+" @ "+o.src})}e()},onerror:function(){if(o._onerror)try{o._onerror.apply(this,Array.prototype.slice.call(arguments,0))}catch(e){return void n({msg:"onerror handler failed "+e+" @ "+o.src})}n({msg:"remote script failed "+o.src})},onreadystatechange:function(){/^(loaded|complete)$/.test(o.readyState)&&e()}})},a.prototype._shouldRelease=function(e){return!/^script$/i.test(e.nodeName)||!!(this.options.releaseAsync&&e.src&&e.hasAttribute("async"))},o.default=a},function(e,o,t){function r(e){var o;return(i[e]||(o=i[e]={exports:{},id:e,loaded:!1},n[e].call(o.exports,o,o.exports,r),o.loaded=!0,o)).exports}var n,i;e.exports=(n=[function(e,o,t){var t=t(1),t=(t=t)&&t.__esModule?t:{default:t};e.exports=t.default},function(e,o,t){function r(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[t]=e[t]);return o.default=e,o}o.__esModule=!0;var n,c=r(t(2)),i=r(t(3)),d=t(6),a=(d=d)&&d.__esModule?d:{default:d},s=t(5),p={comment:/^