text: "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends=require("@babel/runtime/helpers/extends"),_objectWithoutPropertiesLoose=require("@babel/runtime/helpers/objectWithoutPropertiesLoose"),_inheritsLoose=require("@babel/runtime/helpers/inheritsLoose"),React=require("react"),primitives=require("@react-pdf/primitives"),_regeneratorRuntime=require("@babel/runtime/regenerator"),_asyncToGenerator=require("@babel/runtime/helpers/asyncToGenerator"),BlobStream=require("blob-stream"),FontStore=require("@react-pdf/font"),renderPDF=require("@react-pdf/render"),PDFDocument=require("@react-pdf/pdfkit"),layoutDocument=require("@react-pdf/layout"),ReactFiberReconciler=require("react-reconciler"),scheduler=require("scheduler");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var _extends__default=_interopDefaultLegacy(_extends),_objectWithoutPropertiesLoose__default=_interopDefaultLegacy(_objectWithoutPropertiesLoose),_inheritsLoose__default=_interopDefaultLegacy(_inheritsLoose),React__default=_interopDefaultLegacy(React),primitives__namespace=_interopNamespace(primitives),_regeneratorRuntime__default=_interopDefaultLegacy(_regeneratorRuntime),_asyncToGenerator__default=_interopDefaultLegacy(_asyncToGenerator),BlobStream__default=_interopDefaultLegacy(BlobStream),FontStore__default=_interopDefaultLegacy(FontStore),renderPDF__default=_interopDefaultLegacy(renderPDF),PDFDocument__default=_interopDefaultLegacy(PDFDocument),layoutDocument__default=_interopDefaultLegacy(layoutDocument),ReactFiberReconciler__default=_interopDefaultLegacy(ReactFiberReconciler),propsEqual=function e(t,r){var n=Object.keys(t),o=Object.keys(r);if(n.length!==o.length)return!1;for(var a=0;a<n.length;a+=1){var u=n[a];if("render"===u&&!t[u]!=!r[u])return!1;if("children"!==u&&t[u]!==r[u]){if("object"==typeof t[u]&&"object"==typeof r[u]&&e(t[u],r[u]))continue;return!1}if("children"===u&&("string"==typeof t[u]||"string"==typeof r[u]))return t[u]===r[u]}return!0},emptyObject={},createRenderer=function(e){var t=e.onChange,r=void 0===t?function(){}:t;return ReactFiberReconciler__default.default({schedulePassiveEffects:scheduler.unstable_scheduleCallback,cancelPassiveEffects:scheduler.unstable_cancelCallback,supportsMutation:!0,isPrimaryRenderer:!1,warnsIfNotActing:!1,appendInitialChild:function(e,t){e.children.push(t)},createInstance:function(e,t){var r=t.style;t.children;return{type:e,box:{},style:r||{},props:_objectWithoutPropertiesLoose__default.default(t,["style","children"])||{},children:[]}},createTextInstance:function(e,t){return{type:"TEXT_INSTANCE",value:e}},finalizeInitialChildren:function(e,t,r){return!1},getPublicInstance:function(e){return e},prepareForCommit:function(){},prepareUpdate:function(e,t,r,n){return!propsEqual(r,n)},resetAfterCommit:r,resetTextContent:function(e){},getRootHostContext:function(){return emptyObject},getChildHostContext:function(){return emptyObject},shouldSetTextContent:function(e,t){return!1},now:Date.now,useSyncScheduling:!0,appendChild:function(e,t){e.children.push(t)},appendChildToContainer:function(e,t){"ROOT"===e.type?e.document=t:e.children.push(t)},insertBefore:function(e,t,r){var n=e.children.indexOf(r);-1!==n&&t&&e.children.splice(n,0,t)},removeChild:function(e,t){var r=e.children.indexOf(t);-1!==r&&e.children.splice(r,1)},removeChildFromContainer:function(e,t){var r=e.children.indexOf(t);-1!==r&&e.children.splice(r,1)},commitTextUpdate:function(e,t,r){e.value=r},commitUpdate:function(e,t,r,n,o){var a=o.style,u=_objectWithoutPropertiesLoose__default.default(o,["style"]);e.props=u,e.style=a}})},version="2.0.0-alpha.15",fontStore=new FontStore__default.default,pdf=function(e){var t=e.initialValue,r=e.onChange,n={type:"ROOT",document:null,lang:"en-US"},o=createRenderer({onChange:r}),a=o.createContainer(n),u=function(e){o.updateContainer(e,a,null)};t&&u(t);var i=function(){var e=_asyncToGenerator__default.default(_regeneratorRuntime__default.default.mark(function e(){var t,r;return _regeneratorRuntime__default.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=new PDFDocument__default.default({autoFirstPage:!1,lang:(o=void 0,o=n.document,o.props?o.props.lang:null)}),e.next=3,layoutDocument__default.default(n.document,fontStore);case 3:return r=e.sent,e.abrupt("return",renderPDF__default.default(t,r));case 5:case"end":return e.stop()}var o},e)}));return function(){return e.apply(this,arguments)}}(),c=function(e){void 0===e&&(e={}),n.document.props.onRender&&n.document.props.onRender(e)};return{container:n,toBlob:function(){var e=_asyncToGenerator__default.default(_regeneratorRuntime__default.default.mark(function e(){var t,r;return _regeneratorRuntime__default.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i();case 2:return t=e.sent,r=t.pipe(BlobStream__default.default()),e.abrupt("return",new Promise(function(e,t){r.on("finish",function(){try{var n=r.toBlob("application/pdf");c({blob:n}),e(n)}catch(e){t(e)}}),r.on("error",t)}));case 5:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),toBuffer:function(){var e=_asyncToGenerator__default.default(_regeneratorRuntime__default.default.mark(function e(){return _regeneratorRuntime__default.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return c(),e.abrupt("return",i());case 2:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),toString:function(){var e=_asyncToGenerator__default.default(_regeneratorRuntime__default.default.mark(function e(){var t,r;return _regeneratorRuntime__default.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t="",e.next=3,i();case 3:return r=e.sent,e.abrupt("return",new Promise(function(e,n){try{r.on("data",function(e){t+=e}),r.on("end",function(){e(t)})}catch(e){n(e)}}));case 5:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),updateContainer:u}},Font=fontStore,StyleSheet={create:function(e){return e}},queue=require("queue"),InternalBlobProvider=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(t=e.call.apply(e,[this].concat(n))||this).renderQueue=queue({autostart:!0,concurrency:1}),t.state={blob:null,url:null,loading:!0,error:null},t.queueDocumentRender=function(){t.renderQueue.splice(0,t.renderQueue.length,function(){return t.state.error?Promise.resolve():t.instance.toBlob()})},t.onRenderFailed=function(e){t.setState({error:e}),console.error(e)},t.onRenderSuccessful=function(e){var r=t.state.url;t.setState({blob:e,url:URL.createObjectURL(e),loading:!1},function(){return URL.revokeObjectURL(r)})},t}_inheritsLoose__default.default(t,e);var r=t.prototype;return r.componentDidMount=function(){this.instance=pdf({onChange:this.queueDocumentRender}),this.instance.updateContainer(this.props.document),this.renderQueue.on("error",this.onRenderFailed),this.renderQueue.on("success",this.onRenderSuccessful)},r.componentDidUpdate=function(){this.instance.updateContainer(this.props.document)},r.componentWillUnmount=function(){this.renderQueue.end()},r.render=function(){return this.props.children(this.state)},t}(React__default.default.PureComponent),BlobProvider=function(e){var t=e.document,r=e.children;return t?React__default.default.createElement(InternalBlobProvider,{document:t},r):(console.warn("You should pass a valid document to BlobProvider"),null)},PDFViewer=function(e){var t=e.className,r=e.style,n=e.title,o=e.children,a=e.innerRef,u=_objectWithoutPropertiesLoose__default.default(e,["className","style","title","children","innerRef"]);return React__default.default.createElement(InternalBlobProvider,{document:o},function(e){var o=e.url;return React__default.default.createElement("iframe",_extends__default.default({src:o,title:n,ref:a,style:r,className:t},u))})},PDFDownloadLink=function(e){var t=e.document,r=e.className,n=e.style,o=e.children,a=e.fileName,u=void 0===a?"document.pdf":a;if(!t)return console.warn("You should pass a valid document to PDFDownloadLink"),null;return React__default.default.createElement(InternalBlobProvider,{document:t},function(e){return React__default.default.createElement("a",{style:n,href:e.url,download:u,className:r,onClick:(t=e.blob,function(){window.navigator.msSaveBlob&&window.navigator.msSaveBlob(t,u)})},"function"==typeof o?o(e):o);var t})},throwEnvironmentError=function(e){throw new Error(e+" is a Node specific API. You're either using this method in a browser, or your bundler is not loading react-pdf from the appropriate web build.")},renderToStream=function(){throwEnvironmentError("renderToStream")},renderToString=function(){throwEnvironmentError("renderToString")},renderToFile=function(){throwEnvironmentError("renderToFile")},render=function(){throwEnvironmentError("render")},dom=_extends__default.default({pdf:pdf,Font:Font,version:version,StyleSheet:StyleSheet,PDFViewer:PDFViewer,BlobProvider:BlobProvider,PDFDownloadLink:PDFDownloadLink,renderToStream:renderToStream,renderToString:renderToString,renderToFile:renderToFile,render:render},primitives__namespace);Object.keys(primitives).forEach(function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return primitives[e]}})}),exports.BlobProvider=BlobProvider,exports.Font=Font,exports.PDFDownloadLink=PDFDownloadLink,exports.PDFViewer=PDFViewer,exports.StyleSheet=StyleSheet,exports.default=dom,exports.pdf=pdf,exports.render=render,exports.renderToFile=renderToFile,exports.renderToStream=renderToStream,exports.renderToString=renderToString,exports.version=version;
  //# sourceMappingURL=react-pdf.browser.cjs.min.js.map
  