!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e,r){return(e=function(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */i=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),c=new O(n||[]);return o(a,"_invoke",{value:_(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var h={};function d(){}function v(){}function m(){}var y={};f(y,c,(function(){return this}));var g=Object.getPrototypeOf,w=g&&g(g(P([])));w&&w!==e&&r.call(w,c)&&(y=w);var b=m.prototype=d.prototype=Object.create(y);function E(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var i;o(this,"_invoke",{value:function(o,a){function c(){return new e((function(i,c){!function o(i,a,c,u){var l=p(t[i],t,a);if("throw"!==l.type){var f=l.arg,s=f.value;return s&&"object"==n(s)&&r.call(s,"__await")?e.resolve(s.__await).then((function(t){o("next",t,c,u)}),(function(t){o("throw",t,c,u)})):e.resolve(s).then((function(t){f.value=t,c(f)}),(function(t){return o("throw",t,c,u)}))}u(l.arg)}(o,a,i,c)}))}return i=i?i.then(c,c):c()}})}function _(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return N()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=j(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function j(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function P(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:N}}function N(){return{value:void 0,done:!0}}return v.prototype=m,o(b,"constructor",{value:m,configurable:!0}),o(m,"constructor",{value:v,configurable:!0}),v.displayName=f(m,l,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,f(t,l,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},E(x.prototype),f(x.prototype,u,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(b),f(b,l,"Generator"),f(b,c,(function(){return this})),f(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function a(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function c(t){a(i,n,o,c,u,"next",t)}function u(t){a(i,n,o,c,u,"throw",t)}c(void 0)}))}}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return l(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}r.r(e);var f=wp.element,s=(f.createElement,f.useState),p=f.useEffect,h=f.Fragment,d=f.useRef,v=wp.data,m=(v.dispatch,v.select,function(t){var e=d(null),r=u(s(0),2),n=r[0],a=r[1],l=u(s(1),2),f=l[0],v=l[1],m=u(s(null),2),y=m[0],g=m[1],w=u(s(Math.floor(n/f)),2),b=w[0],E=w[1],x=u(s(null),2),_=x[0],j=x[1],S=u(s(1),2),L=S[0],O=S[1],P=u(s({}),2),N=P[0],k=P[1],A=function(t){return new Promise((function(e){return setTimeout((function(){e()}),t)}))};p((function(){return pdfjsLib.getDocument(t.url).then((function(t){j(t),console.log("@@--\x3e",t.numPages),O(t.numPages)})),document.addEventListener("visibilitychange",T),function(){document.removeEventListener("visibilitychange",T)}}),[t.url]);var T=function(){document.hidden?console.log("pdf Browser tab is hidden"):pdfjsLib.getDocument(t.url).then((function(t){j(t),O(t.numPages)}))};p((function(){L&&null!=_&&I()}),[L,y,f,n,_,b]);var q=function(t){if("prev"===t){if(0===n)return;a(n-f),n<0&&a(0)}if("zoom_out"===t&&y>.5&&g(y-.5),"zoom_in"===t&&g(y+.5),"next"===t){if(n===L-1)return;a(n+f),n>L-1&&a(L-1)}};p((function(){if(e){var t=e.current.getBoundingClientRect();k({width:t.width+"px"})}}),[e]);var C=function(){var t=c(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:parseInt(e.target.value)<=L&&v(Number(e.target.value));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),I=function(){var t=c(i().mark((function t(){var r,o,a,c,u;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,A(150);case 2:for(r=Math.floor(n/f),E(r),a=(o=r*f)+f<L?o+f-1:L-1,c=[],u=o;u<=a;u++)c.push(_.getPage(u+1));e.current&&Promise.all(c).then((function(t){e.current.querySelector(".pdf_wrrap")&&e.current.querySelector(".pdf_wrrap").remove();var r='<div class="pdf_wrrap"><canvas></canvas></div>'.repeat(t.length);e.current.innerHTML=r,t.forEach(G)}));case 9:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),G=function(t){if(e.current&&e.current.children[t.pageIndex-b*f]){var r=e.current.children[t.pageIndex-b*f].children[0],n=t.getViewport(1),o=r.getContext("2d",{preserveDrawingBuffer:!0});if(y)n=t.getViewport(y);else{var i=e.current.querySelector(".pdf_wrrap").clientWidth/n.width;g(i),n=t.getViewport(i)}r.width=n.width,r.height=n.height,t.render({canvasContext:o,viewport:n})}};return wp.element.createElement("div",{className:"pdf-view"},wp.element.createElement("div",{role:"toolbar",className:"toolbar"},wp.element.createElement("div",{className:"pager"},L>1?wp.element.createElement(h,null,n>0?wp.element.createElement("span",{className:"vicon vicon-arrow-left",onClick:function(){q("prev")}}):"",n>=L?"":wp.element.createElement("span",{className:"vicon vicon-arrow-right",onClick:function(){q("next")}})):"",wp.element.createElement("span",{className:"vicon vicon-zoom-in",onClick:function(){q("zoom_in")}}),wp.element.createElement("span",{className:"vicon vicon-zoom-out",onClick:function(){q("zoom_out")}})),wp.element.createElement("div",{className:"page-mode"},L>1?wp.element.createElement("label",null,wp.element.createElement("input",o({type:"number",value:n+1,min:"1",max:L,onChange:C},"value",f))):"")),wp.element.createElement("div",{className:"pdf_view",ref:e,style:N}))}),y=(r(0),wp.element),g=(y.createElement,y.useState,y.useEffect,y.Fragment,y.render),w=wp.data;w.dispatch,w.select;document.addEventListener("VibeBP_Editor_Content",(function(){setTimeout((function(){if(document.querySelectorAll(".vbp_pdf_object")&&document.querySelectorAll(".vbp_pdf_object").length)if(document.querySelector("#vbp-pdf-js"))b();else{var t=document.createElement("script");t.type="text/javascript",t.id="vbp-pdf-js",t.src=window.vibebp.settings.pdfjs_script,document.body.appendChild(t),t.onload=function(){b()}}}),200)}));var b=function(){"undefined"!=typeof pdfjsLib&&document.querySelectorAll(".vbp_pdf_object")&&document.querySelectorAll(".vbp_pdf_object").length&&document.querySelectorAll(".vbp_pdf_object").forEach((function(t){if(t.querySelector("object")){var e=t.querySelector("object").getAttribute("data");g(wp.element.createElement(m,{url:e}),t)}}))}}]);