(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory();else if(typeof define==="function"&&define.amd)define([],factory);else if(typeof exports==="object")exports["advads_postscribe"]=factory();else root["advads_postscribe"]=factory()})(this,function(){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:false};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.loaded=true;return module.exports}__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.p="";return __webpack_require__(0)}([function(module,exports,__webpack_require__){"use strict";var _postscribe=__webpack_require__(1);var _postscribe2=_interopRequireDefault(_postscribe);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}module.exports=_postscribe2["default"]},function(module,exports,__webpack_require__){"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i2&&arguments[2]!==undefined?arguments[2]:null;var attr=BASEATTR+name;if(utils.existy(value)&&value!==""){el.setAttribute(attr,value)}else{el.removeAttribute(attr)}}var WriteStream=function(){function WriteStream(root){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,WriteStream);this.root=root;this.options=options;this.doc=root.ownerDocument;this.win=this.doc.defaultView||this.doc.parentWindow;this.parser=new _prescribe2["default"]("",{autoFix:options.autoFix});this.actuals=[root];this.proxyHistory="";this.proxyRoot=this.doc.createElement(root.nodeName);this.scriptStack=[];this.writeQueue=[];setData(this.proxyRoot,"proxyof",0)}WriteStream.prototype.write=function write(){var _writeQueue;(_writeQueue=this.writeQueue).push.apply(_writeQueue,arguments);while(!this.deferredRemote&&this.writeQueue.length){var arg=this.writeQueue.shift();if(utils.isFunction(arg)){this._callFunction(arg)}else{this._writeImpl(arg)}}};WriteStream.prototype._callFunction=function _callFunction(fn){var tok={type:"function",value:fn.name||fn.toString()};this._onScriptStart(tok);fn.call(this.win,this.doc);this._onScriptDone(tok)};WriteStream.prototype._writeImpl=function _writeImpl(html){this.parser.append(html);var tok=void 0;var script=void 0;var style=void 0;var tokens=[];while((tok=this.parser.readToken())&&!(script=utils.isScript(tok))&&!(style=utils.isStyle(tok))){tok=this.options.beforeWriteToken(tok);if(tok){tokens.push(tok)}}if(tokens.length>0){this._writeStaticTokens(tokens)}if(script){this._handleScriptToken(tok)}if(style){this._handleStyleToken(tok)}};WriteStream.prototype._writeStaticTokens=function _writeStaticTokens(tokens){var chunk=this._buildChunk(tokens);if(!chunk.actual){return null}chunk.html=this.proxyHistory+chunk.actual;this.proxyHistory+=chunk.proxy;this.proxyRoot.innerHTML=chunk.html;if(DEBUG_CHUNK){chunk.proxyInnerHTML=this.proxyRoot.innerHTML}this._walkChunk();if(DEBUG_CHUNK){chunk.actualInnerHTML=this.root.innerHTML}return chunk};WriteStream.prototype._buildChunk=function _buildChunk(tokens){var nextId=this.actuals.length;var raw=[];var actual=[];var proxy=[];var len=tokens.length;for(var i=0;i)/," "+BASEATTR+"id="+id+" $1"));if(tok.attrs.id!==PROXY_SCRIPT&&tok.attrs.id!==PROXY_STYLE){proxy.push(tok.type==="atomicTag"?"":"<"+tok.tagName+" "+BASEATTR+"proxyof="+id+(tok.unary?" />":">"))}}}else{actual.push(tokenRaw);proxy.push(tok.type==="endTag"?tokenRaw:"")}}return{tokens:tokens,raw:raw.join(""),actual:actual.join(""),proxy:proxy.join("")}};WriteStream.prototype._walkChunk=function _walkChunk(){var node=void 0;var stack=[this.proxyRoot];while(utils.existy(node=stack.shift())){var isElement=node.nodeType===1;var isProxy=isElement&&getData(node,"proxyof");if(!isProxy){if(isElement){this.actuals[getData(node,"id")]=node;setData(node,"id")}var parentIsProxyOf=node.parentNode&&getData(node.parentNode,"proxyof");if(parentIsProxyOf){this.actuals[parentIsProxyOf].appendChild(node)}}stack.unshift.apply(stack,utils.toArray(node.childNodes))}};WriteStream.prototype._handleScriptToken=function _handleScriptToken(tok){var _this=this;var remainder=this.parser.clear();if(remainder){this.writeQueue.unshift(remainder)}tok.src=tok.attrs.src||tok.attrs.SRC;tok=this.options.beforeWriteToken(tok);if(!tok){return}if(tok.src&&this.scriptStack.length){this.deferredRemote=tok}else{this._onScriptStart(tok)}this._writeScriptToken(tok,function(){_this._onScriptDone(tok)})};WriteStream.prototype._handleStyleToken=function _handleStyleToken(tok){var remainder=this.parser.clear();if(remainder){this.writeQueue.unshift(remainder)}tok.type=tok.attrs.type||tok.attrs.TYPE||"text/css";tok=this.options.beforeWriteToken(tok);if(tok){this._writeStyleToken(tok)}if(remainder){this.write()}};WriteStream.prototype._writeStyleToken=function _writeStyleToken(tok){var el=this._buildStyle(tok);this._insertCursor(el,PROXY_STYLE);if(tok.content){if(el.styleSheet&&!el.sheet){el.styleSheet.cssText=tok.content}else{el.appendChild(this.doc.createTextNode(tok.content))}}};WriteStream.prototype._buildStyle=function _buildStyle(tok){var el=this.doc.createElement(tok.tagName);el.setAttribute("type",tok.type);utils.eachKey(tok.attrs,function(name,value){el.setAttribute(name,value)});return el};WriteStream.prototype._insertCursor=function _insertCursor(el,which){this._writeImpl('');var cursor=this.doc.getElementById(which);if(cursor){cursor.parentNode.replaceChild(el,cursor)}};WriteStream.prototype._onScriptStart=function _onScriptStart(tok){tok.outerWrites=this.writeQueue;this.writeQueue=[];this.scriptStack.unshift(tok)};WriteStream.prototype._onScriptDone=function _onScriptDone(tok){if(tok!==this.scriptStack[0]){this.options.error({msg:"Bad script nesting or script finished twice"});return}this.scriptStack.shift();this.write.apply(this,tok.outerWrites);if(!this.scriptStack.length&&this.deferredRemote){this._onScriptStart(this.deferredRemote);this.deferredRemote=null}};WriteStream.prototype._writeScriptToken=function _writeScriptToken(tok,done){var el=this._buildScript(tok);var asyncRelease=this._shouldRelease(el);var afterAsync=this.options.afterAsync;if(tok.src){el.src=tok.src;this._scriptLoadHandler(el,!asyncRelease?function(){done();afterAsync()}:afterAsync)}try{this._insertCursor(el,PROXY_SCRIPT);if(!el.src||asyncRelease){done()}}catch(e){this.options.error(e);done()}};WriteStream.prototype._buildScript=function _buildScript(tok){var el=this.doc.createElement(tok.tagName);utils.eachKey(tok.attrs,function(name,value){el.setAttribute(name,value)});if(tok.content){el.text=tok.content}return el};WriteStream.prototype._scriptLoadHandler=function _scriptLoadHandler(el,done){function cleanup(){el=el.onload=el.onreadystatechange=el.onerror=null}var error=this.options.error;function success(){cleanup();if(done!=null){done()}done=null}function failure(err){cleanup();error(err);if(done!=null){done()}done=null}function reattachEventListener(el,evt){var handler=el["on"+evt];if(handler!=null){el["_on"+evt]=handler}}reattachEventListener(el,"load");reattachEventListener(el,"error");_extends(el,{onload:function onload(){if(el._onload){try{el._onload.apply(this,Array.prototype.slice.call(arguments,0))}catch(err){failure({msg:"onload handler failed "+err+" @ "+el.src})}}success()},onerror:function onerror(){if(el._onerror){try{el._onerror.apply(this,Array.prototype.slice.call(arguments,0))}catch(err){failure({msg:"onerror handler failed "+err+" @ "+el.src});return}}failure({msg:"remote script failed "+el.src})},onreadystatechange:function onreadystatechange(){if(/^(loaded|complete)$/.test(el.readyState)){success()}}})};WriteStream.prototype._shouldRelease=function _shouldRelease(el){var isScript=/^script$/i.test(el.nodeName);return!isScript||!!(this.options.releaseAsync&&el.src&&el.hasAttribute("async"))};return WriteStream}();exports["default"]=WriteStream},function(module,exports,__webpack_require__){(function webpackUniversalModuleDefinition(root,factory){if(true)module.exports=factory();else if(typeof define==="function"&&define.amd)define([],factory);else if(typeof exports==="object")exports["Prescribe"]=factory();else root["Prescribe"]=factory()})(this,function(){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:false};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.loaded=true;return module.exports}__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.p="";return __webpack_require__(0)}([function(module,exports,__webpack_require__){"use strict";var _HtmlParser=__webpack_require__(1);var _HtmlParser2=_interopRequireDefault(_HtmlParser);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}module.exports=_HtmlParser2["default"]},function(module,exports,__webpack_require__){"use strict";exports.__esModule=true;var _supports=__webpack_require__(2);var supports=_interopRequireWildcard(_supports);var _streamReaders=__webpack_require__(3);var streamReaders=_interopRequireWildcard(_streamReaders);var _fixedReadTokenFactory=__webpack_require__(6);var _fixedReadTokenFactory2=_interopRequireDefault(_fixedReadTokenFactory);var _utils=__webpack_require__(5);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var detect={comment:/^");if(index>=0){return new _tokens.CommentToken(stream.substr(4,index-1),index+3)}}function chars(stream){var index=stream.indexOf("<");return new _tokens.CharsToken(index>=0?index:stream.length)}function startTag(stream){var endTagIndex=stream.indexOf(">");if(endTagIndex!==-1){var match=stream.match(REGEXES.startTag);if(match){var _ret=function(){var attrs={};var booleanAttrs={};var rest=match[2];match[2].replace(REGEXES.attr,function(match,name){if(!(arguments[2]||arguments[3]||arguments[4]||arguments[5])){attrs[name]=""}else if(arguments[5]){attrs[arguments[5]]="";booleanAttrs[arguments[5]]=true}else{attrs[name]=arguments[2]||arguments[3]||arguments[4]||REGEXES.fillAttr.test(name)&&name||""}rest=rest.replace(match,"")});return{v:new _tokens.StartTagToken(match[1],match[0].length,attrs,booleanAttrs,!!match[3],rest.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""))}}();if((typeof _ret==="undefined"?"undefined":_typeof(_ret))==="object")return _ret.v}}}function atomicTag(stream){var start=startTag(stream);if(start){var rest=stream.slice(start.length);if(rest.match(new RegExp("","i"))){var match=rest.match(new RegExp("([\\s\\S]*?)","i"));if(match){return new _tokens.AtomicTagToken(start.tagName,match[0].length+start.length,start.attrs,start.booleanAttrs,match[1])}}}}function endTag(stream){var match=stream.match(REGEXES.endTag);if(match){return new _tokens.EndTagToken(match[1],match[0].length)}}},function(module,exports,__webpack_require__){"use strict";exports.__esModule=true;exports.EndTagToken=exports.AtomicTagToken=exports.StartTagToken=exports.TagToken=exports.CharsToken=exports.CommentToken=exports.Token=undefined;var _utils=__webpack_require__(5);function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Token=exports.Token=function Token(type,length){_classCallCheck(this,Token);this.type=type;this.length=length;this.text=""};var CommentToken=exports.CommentToken=function(){function CommentToken(content,length){_classCallCheck(this,CommentToken);this.type="comment";this.length=length||(content?content.length:0);this.text="";this.content=content}CommentToken.prototype.toString=function toString(){return"