@compdfkit_pdf_sdk/webviewer 2.7.4-rc.2 → 2.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ComPDFKitViewer=e()}(this,(function(){"use strict";function t(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function e(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,n(o.key),o)}}function r(){r=function(){return e};var t,e={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,a=Object.create(o.prototype),c=new T(n||[]);return i(a,"_invoke",{value:j(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var p="suspendedStart",d="suspendedYield",v="executing",y="completed",m={};function w(){}function g(){}function b(){}var E={};l(E,c,(function(){return this}));var L=Object.getPrototypeOf,x=L&&L(L(N([])));x&&x!==n&&o.call(x,c)&&(E=x);var _=b.prototype=w.prototype=Object.create(E);function P(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(n,i,a,c){var s=f(t[n],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&o.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new e((function(e,n){r(t,o,e,n)}))}return n=n?n.then(i,i):i()}})}function j(e,r,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=O(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function O(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,O(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function I(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 C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function r(){for(;++n<e.length;)if(o.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=b,i(_,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=l(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},P(k.prototype),l(k.prototype,s,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(h(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},P(_),l(_,u,"Generator"),l(_,c,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.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}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=o.call(a,"catchLoc"),u=o.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;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,m):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),m},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),C(r),m}},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;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function n(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var o,i,a,c={init:function(t,e){return new Promise((function(r){e.addEventListener("ready",(function t(){e.removeEventListener("ready",t);var n=e.querySelector("iframe").contentWindow;Promise.resolve().then((function(){r({docViewer:n.instance,Core:n.instances.Core,UI:n.instances.UI})}))})),new u(t,e)}))}},s=new Map,u=function(){return n=function t(e,r){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!s.get(r)){this.docId=0,s.set(r,!0),this.instance=null,this.options=e,this.initialDoc=e.pdfUrl||null,this.element=r,this.options.path=this.options.path||t.config.path;var n=this.options.path.length-1;n>0&&"/"!==this.options.path[n]&&(this.options.path+="/"),this.options.webviewerPath=this.options.path+t.config.webviewerPath,r.addEventListener("ready",(function t(){r.removeEventListener("ready",t)})),this.create()}},o=[{key:"_createEvent",value:function(t,e){var r;try{r=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0})}catch(n){(r=document.createEvent("Event")).initEvent(t,!0,!0),r.detail=e}return r}},{key:"create",value:function(){this.initialDoc?(this.initialDoc=encodeURIComponent(JSON.stringify(this.initialDoc)),this._create()):this._create()}},{key:"_create",value:function(){this.docId++,this._trigger||(this._trigger=function(t,e){var r=this._createEvent(t,e);this.element.dispatchEvent(r)}),this.createViewer()}},{key:"createViewer",value:function(){var e,n,o,i=this,a=this.options.webviewerPath;this.initialDoc?a+="#d=".concat(this.initialDoc):a+="#",a+="&docId=".concat(this.docId),(null===(e=this.options)||void 0===e?void 0:e.css)&&(a+="&css=".concat(encodeURIComponent(this.options.css))),void 0!==this.options.showToolbarControl&&(a+="&header=".concat(this.options.showToolbarControl?"true":"false"));var c=document.createElement("iframe");c.id="webviewer-"+this.docId,c.src=a,c.frameBorder=0,c.width="100%",c.height="100%",c.setAttribute("allowfullscreen",!0),c.setAttribute("webkitallowfullscreen",!0),c.setAttribute("mozallowfullscreen",!0),this.iframe=c,null!==(n=this.options)&&void 0!==n&&n.backgroundColor&&c.setAttribute("data-bgcolor",this.options.backgroundColor),null!==(o=this.options)&&void 0!==o&&o.assetPath&&c.setAttribute("data-assetpath",encodeURIComponent(this.options.assetPath)),this.element.appendChild(c),this.messageHandler=function(){var e,n=(e=r().mark((function t(e){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("documentViewerLoaded"!==e.data.type||e.data.docId!==i.docId){t.next=14;break}return t.prev=1,i.instance=i.iframe.contentWindow.instance,t.next=5,i.instance.initOptions(i.options);case 5:i._trigger("ready"),t.next=10;break;case 8:t.prev=8,t.t0=t.catch(1);case 10:return t.prev=10,window.removeEventListener("message",i.messageHandler),i._documentViewerLoaded(i.iframe),t.finish(10);case 14:case"end":return t.stop()}}),t,null,[[1,8,10,14]])})),function(){var r=this,n=arguments;return new Promise((function(o,i){var a=e.apply(r,n);function c(e){t(a,o,i,c,s,"next",e)}function s(e){t(a,o,i,c,s,"throw",e)}c(void 0)}))});return function(t){return n.apply(this,arguments)}}(),window.addEventListener("message",this.messageHandler)}},{key:"_documentViewerLoaded",value:function(t){this.options.pdfUrl&&t.contentWindow.instances.UI.loadDocument(this.options.pdfUrl)}}],o&&e(n.prototype,o),i&&e(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,o,i}();return o=u,a={path:"",webviewerPath:"./webviewer/index.html"},(i=n(i="config"))in o?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a,c}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ComPDFKitViewer=t()}(this,(function(){"use strict";function e(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function t(t,i){for(var n=0;n<i.length;n++){var o=i[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,e(o.key),o)}}var i={init:function(e,t){return new Promise((function(i){t.addEventListener("ready",(function e(){t.removeEventListener("ready",e);var n=t.querySelector("iframe").contentWindow;try{var o=n.instance;Promise.resolve().then((function(){i(o)}))}catch(e){i()}})),new s(e,t)}))}};var n,o,r,a=new Map,s=function(){return e=function e(t,i){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!a.get(i)){this.docId=0,a.set(i,!0),this.instance=null,this.options=t,this.initialDoc=t.pdfUrl||null,this.element=i,this.options.path=this.options.path||e.config.path;var n=this.options.path.length-1;n>0&&"/"!==this.options.path[n]&&(this.options.path+="/"),this.options.webviewerPath=this.options.path+e.config.webviewerPath,i.addEventListener("ready",(function e(){i.removeEventListener("ready",e)})),this.create()}},(i=[{key:"_createEvent",value:function(e,t){var i;try{i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0})}catch(n){(i=document.createEvent("Event")).initEvent(e,!0,!0),i.detail=t}return i}},{key:"create",value:function(){this.initialDoc?(this.initialDoc=encodeURIComponent(JSON.stringify(this.initialDoc)),this._create()):this._create()}},{key:"_create",value:function(){this.docId++,this._trigger||(this._trigger=function(e,t){var i=this._createEvent(e,t);this.element.dispatchEvent(i)});var e=this;this.messageHandler=function(t){if("requestConfig"===t.data.type&&t.data.docId===e.docId&&t.source){var i=e.options.config?e._correctRelativePath(e.options.config):"";t.source.postMessage({type:"responseConfig",value:i},"*")}},window.addEventListener("message",this.messageHandler,!1),this.createViewer()}},{key:"_correctRelativePath",value:function(e){return function(e,t){if("string"!=typeof e||!t)return e;var i=t.substring(0,t.lastIndexOf("/"));return/^(\/|%2F|[a-z0-9-]+:)/i.test(e)?e:"".concat(i,"/").concat(e)}(e,window.location.pathname)}},{key:"createViewer",value:function(){var e,t,i,n=this,o=this.options.webviewerPath;this.initialDoc?o+="#d=".concat(this.initialDoc):o+="#",o+="&docId=".concat(this.docId),(null===(e=this.options)||void 0===e?void 0:e.css)&&(o+="&css=".concat(encodeURIComponent(this.options.css))),void 0!==this.options.showToolbarControl&&(o+="&header=".concat(this.options.showToolbarControl?"true":"false"));var r=document.createElement("iframe");r.id="webviewer-"+this.docId,r.src=o,r.frameBorder=0,r.width="100%",r.height="100%",r.setAttribute("allowfullscreen",!0),r.setAttribute("webkitallowfullscreen",!0),r.setAttribute("mozallowfullscreen",!0),this.iframe=r,null!==(t=this.options)&&void 0!==t&&t.backgroundColor&&r.setAttribute("data-bgcolor",this.options.backgroundColor),null!==(i=this.options)&&void 0!==i&&i.assetPath&&r.setAttribute("data-assetpath",encodeURIComponent(this.options.assetPath)),this.element.appendChild(r),window.addEventListener("message",(function e(t){if("viewerLoaded"===t.data.type&&t.data.docId===n.docId)try{n.instance=n.iframe.contentWindow.instance}catch(e){}finally{window.removeEventListener("message",e),n._viewerLoaded(n.iframe)}}))}},{key:"_documentViewerLoaded",value:function(e){this.options.pdfUrl&&e.contentWindow.instance.UI.loadDocument(this.options.pdfUrl)}},{key:"_viewerLoaded",value:function(e){this._trigger("ready");try{e.contentWindow.postMessage({type:"viewerLoaded",options:this.options},"*")}catch(e){}}}])&&t(e.prototype,i),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,i,n}();return n=s,r={path:"",webviewerPath:"./webviewer/index.html"},(o=e(o="config"))in n?Object.defineProperty(n,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[o]=r,i}));
package/webviewer.js CHANGED
@@ -1 +1 @@
1
- function t(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function e(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,n(o.key),o)}}function r(){r=function(){return e};var t,e={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,a=Object.create(o.prototype),c=new N(n||[]);return i(a,"_invoke",{value:O(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",d="suspendedYield",v="executing",y="completed",m={};function w(){}function g(){}function b(){}var E={};h(E,c,(function(){return this}));var L=Object.getPrototypeOf,x=L&&L(L(S([])));x&&x!==n&&o.call(x,c)&&(E=x);var _=b.prototype=w.prototype=Object.create(E);function P(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(n,i,a,c){var s=f(t[n],t,i);if("throw"!==s.type){var u=s.arg,h=u.value;return h&&"object"==typeof h&&o.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(h).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new e((function(e,n){r(t,o,e,n)}))}return n=n?n.then(i,i):i()}})}function O(e,r,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=j(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function j(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,j(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function I(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 C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function S(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function r(){for(;++n<e.length;)if(o.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=b,i(_,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=h(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,h(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},P(k.prototype),h(k.prototype,s,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},P(_),h(_,u,"Generator"),h(_,c,(function(){return this})),h(_,"toString",(function(){return"[object Generator]"})),e.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}},e.values=S,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=o.call(a,"catchLoc"),u=o.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;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,m):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),m},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),C(r),m}},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;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:S(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function n(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var o,i,a,c={init:function(t,e){return new Promise((function(r){e.addEventListener("ready",(function t(){e.removeEventListener("ready",t);var n=e.querySelector("iframe").contentWindow;Promise.resolve().then((function(){r({docViewer:n.instance,Core:n.instances.Core,UI:n.instances.UI})}))})),new u(t,e)}))}},s=new Map,u=function(){return n=function t(e,r){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!s.get(r)){this.docId=0,s.set(r,!0),this.instance=null,this.options=e,this.initialDoc=e.pdfUrl||null,this.element=r,this.options.path=this.options.path||t.config.path;var n=this.options.path.length-1;n>0&&"/"!==this.options.path[n]&&(this.options.path+="/"),this.options.webviewerPath=this.options.path+t.config.webviewerPath,r.addEventListener("ready",(function t(){r.removeEventListener("ready",t)})),this.create()}},o=[{key:"_createEvent",value:function(t,e){var r;try{r=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0})}catch(n){(r=document.createEvent("Event")).initEvent(t,!0,!0),r.detail=e}return r}},{key:"create",value:function(){this.initialDoc?(this.initialDoc=encodeURIComponent(JSON.stringify(this.initialDoc)),this._create()):this._create()}},{key:"_create",value:function(){this.docId++,this._trigger||(this._trigger=function(t,e){var r=this._createEvent(t,e);this.element.dispatchEvent(r)}),this.createViewer()}},{key:"createViewer",value:function(){var e,n,o,i=this,a=this.options.webviewerPath;this.initialDoc?a+="#d=".concat(this.initialDoc):a+="#",a+="&docId=".concat(this.docId),(null===(e=this.options)||void 0===e?void 0:e.css)&&(a+="&css=".concat(encodeURIComponent(this.options.css))),void 0!==this.options.showToolbarControl&&(a+="&header=".concat(this.options.showToolbarControl?"true":"false"));var c=document.createElement("iframe");c.id="webviewer-"+this.docId,c.src=a,c.frameBorder=0,c.width="100%",c.height="100%",c.setAttribute("allowfullscreen",!0),c.setAttribute("webkitallowfullscreen",!0),c.setAttribute("mozallowfullscreen",!0),this.iframe=c,null!==(n=this.options)&&void 0!==n&&n.backgroundColor&&c.setAttribute("data-bgcolor",this.options.backgroundColor),null!==(o=this.options)&&void 0!==o&&o.assetPath&&c.setAttribute("data-assetpath",encodeURIComponent(this.options.assetPath)),this.element.appendChild(c),this.messageHandler=function(){var e,n=(e=r().mark((function t(e){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("documentViewerLoaded"!==e.data.type||e.data.docId!==i.docId){t.next=14;break}return t.prev=1,i.instance=i.iframe.contentWindow.instance,t.next=5,i.instance.initOptions(i.options);case 5:i._trigger("ready"),t.next=10;break;case 8:t.prev=8,t.t0=t.catch(1);case 10:return t.prev=10,window.removeEventListener("message",i.messageHandler),i._documentViewerLoaded(i.iframe),t.finish(10);case 14:case"end":return t.stop()}}),t,null,[[1,8,10,14]])})),function(){var r=this,n=arguments;return new Promise((function(o,i){var a=e.apply(r,n);function c(e){t(a,o,i,c,s,"next",e)}function s(e){t(a,o,i,c,s,"throw",e)}c(void 0)}))});return function(t){return n.apply(this,arguments)}}(),window.addEventListener("message",this.messageHandler)}},{key:"_documentViewerLoaded",value:function(t){this.options.pdfUrl&&t.contentWindow.instances.UI.loadDocument(this.options.pdfUrl)}}],o&&e(n.prototype,o),i&&e(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,o,i}();o=u,a={path:"",webviewerPath:"./webviewer/index.html"},(i=n(i="config"))in o?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a;export{c as default};
1
+ function t(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function e(e,i){for(var n=0;n<i.length;n++){var o=i[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,t(o.key),o)}}var i={init:function(t,e){return new Promise((function(i){e.addEventListener("ready",(function t(){e.removeEventListener("ready",t);var n=e.querySelector("iframe").contentWindow;try{var o=n.instance;Promise.resolve().then((function(){i(o)}))}catch(t){i()}})),new s(t,e)}))}};var n,o,r,a=new Map,s=function(){return t=function t(e,i){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!a.get(i)){this.docId=0,a.set(i,!0),this.instance=null,this.options=e,this.initialDoc=e.pdfUrl||null,this.element=i,this.options.path=this.options.path||t.config.path;var n=this.options.path.length-1;n>0&&"/"!==this.options.path[n]&&(this.options.path+="/"),this.options.webviewerPath=this.options.path+t.config.webviewerPath,i.addEventListener("ready",(function t(){i.removeEventListener("ready",t)})),this.create()}},(i=[{key:"_createEvent",value:function(t,e){var i;try{i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0})}catch(n){(i=document.createEvent("Event")).initEvent(t,!0,!0),i.detail=e}return i}},{key:"create",value:function(){this.initialDoc?(this.initialDoc=encodeURIComponent(JSON.stringify(this.initialDoc)),this._create()):this._create()}},{key:"_create",value:function(){this.docId++,this._trigger||(this._trigger=function(t,e){var i=this._createEvent(t,e);this.element.dispatchEvent(i)});var t=this;this.messageHandler=function(e){if("requestConfig"===e.data.type&&e.data.docId===t.docId&&e.source){var i=t.options.config?t._correctRelativePath(t.options.config):"";e.source.postMessage({type:"responseConfig",value:i},"*")}},window.addEventListener("message",this.messageHandler,!1),this.createViewer()}},{key:"_correctRelativePath",value:function(t){return function(t,e){if("string"!=typeof t||!e)return t;var i=e.substring(0,e.lastIndexOf("/"));return/^(\/|%2F|[a-z0-9-]+:)/i.test(t)?t:"".concat(i,"/").concat(t)}(t,window.location.pathname)}},{key:"createViewer",value:function(){var t,e,i,n=this,o=this.options.webviewerPath;this.initialDoc?o+="#d=".concat(this.initialDoc):o+="#",o+="&docId=".concat(this.docId),(null===(t=this.options)||void 0===t?void 0:t.css)&&(o+="&css=".concat(encodeURIComponent(this.options.css))),void 0!==this.options.showToolbarControl&&(o+="&header=".concat(this.options.showToolbarControl?"true":"false"));var r=document.createElement("iframe");r.id="webviewer-"+this.docId,r.src=o,r.frameBorder=0,r.width="100%",r.height="100%",r.setAttribute("allowfullscreen",!0),r.setAttribute("webkitallowfullscreen",!0),r.setAttribute("mozallowfullscreen",!0),this.iframe=r,null!==(e=this.options)&&void 0!==e&&e.backgroundColor&&r.setAttribute("data-bgcolor",this.options.backgroundColor),null!==(i=this.options)&&void 0!==i&&i.assetPath&&r.setAttribute("data-assetpath",encodeURIComponent(this.options.assetPath)),this.element.appendChild(r),window.addEventListener("message",(function t(e){if("viewerLoaded"===e.data.type&&e.data.docId===n.docId)try{n.instance=n.iframe.contentWindow.instance}catch(t){}finally{window.removeEventListener("message",t),n._viewerLoaded(n.iframe)}}))}},{key:"_documentViewerLoaded",value:function(t){this.options.pdfUrl&&t.contentWindow.instance.UI.loadDocument(this.options.pdfUrl)}},{key:"_viewerLoaded",value:function(t){this._trigger("ready");try{t.contentWindow.postMessage({type:"viewerLoaded",options:this.options},"*")}catch(t){}}}])&&e(t.prototype,i),n&&e(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,n}();n=s,r={path:"",webviewerPath:"./webviewer/index.html"},(o=t(o="config"))in n?Object.defineProperty(n,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[o]=r;export{i as default};