text: function _asyncToGenerator(e){return function(){var c=e.apply(this,arguments);return new Promise(function(a,i){return function t(e,n){try{var r=c[e](n),o=r.value}catch(e){return void i(e)}if(!r.done)return Promise.resolve(o).then(function(e){t("next",e)},function(e){t("throw",e)});a(o)}("next")})}}!function(e){"use strict";var l,s=Object.prototype.hasOwnProperty,t="function"==typeof Symbol?Symbol:{},o=t.iterator||"@@iterator",n=t.toStringTag||"@@toStringTag",r="object"==typeof module,a=e.regeneratorRuntime;if(a)r&&(module.exports=a);else{(a=e.regeneratorRuntime=r?module.exports:{}).wrap=c;var f="suspendedStart",p="suspendedYield",h="executing",y="completed",g={},i=v.prototype=u.prototype;m.prototype=i.constructor=v,v.constructor=m,v[n]=m.displayName="GeneratorFunction",a.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,n in e||(e[n]="GeneratorFunction")),e.prototype=Object.create(i),e},a.awrap=function(e){return new w(e)},d(b.prototype),a.async=function(e,t,n,r){var o=new b(c(e,t,n,r));return a.isGeneratorFunction(t)?o:o.next().then(function(e){return e.done?e.value:o.next()})},d(i),i[o]=function(){return this},i[n]="Generator",i.toString=function(){return"[object Generator]"},a.keys=function(n){var r=[];for(var e in n)r.push(e);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=E,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=l,this.done=!1,this.delegate=null,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=l)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return a.type="throw",a.arg=n,r.next=e,!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],a=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var i=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(i&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?this.next=o.finallyLoc:this.complete(a),g},complete:function(e,t){if("throw"===e.type)throw e.arg;"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=e.arg,this.next="end"):"normal"===e.type&&t&&(this.next=t)},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;k(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:E(e),resultName:t,nextLoc:n},g}}}function c(e,t,n,r){var o=t&&t.prototype instanceof u?t:u,a=Object.create(o.prototype),i=new D(r||[]);return a._invoke=function(i,c,s){var u=f;return function(e,t){if(u===h)throw new Error("Generator is already running");if(u===y){if("throw"===e)throw t;return L()}for(;;){var n=s.delegate;if(n){if("return"===e||"throw"===e&&n.iterator[e]===l){s.delegate=null;var r=n.iterator.return;if(r)if("throw"===(o=x(r,n.iterator,t)).type){e="throw",t=o.arg;continue}if("return"===e)continue}var o;if("throw"===(o=x(n.iterator[e],n.iterator,t)).type){s.delegate=null,e="throw",t=o.arg;continue}if(e="next",t=l,!(a=o.arg).done)return u=p,a;s[n.resultName]=a.value,s.next=n.nextLoc,s.delegate=null}if("next"===e)s.sent=s._sent=t;else if("throw"===e){if(u===f)throw u=y,t;s.dispatchException(t)&&(e="next",t=l)}else"return"===e&&s.abrupt("return",t);if(u=h,"normal"===(o=x(i,c,s)).type){u=s.done?y:p;var a={value:o.arg,done:s.done};if(o.arg!==g)return a;s.delegate&&"next"===e&&(t=l)}else"throw"===o.type&&(u=y,e="throw",t=o.arg)}}}(e,n,i),a}function x(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function u(){}function m(){}function v(){}function d(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function w(e){this.arg=e}function b(c){function s(e,t,n,r){var o=x(c[e],c,t);if("throw"!==o.type){var a=o.arg,i=a.value;return i instanceof w?Promise.resolve(i.arg).then(function(e){s("next",e,n,r)},function(e){s("throw",e,n,r)}):Promise.resolve(i).then(function(e){a.value=e,n(a)},r)}r(o.arg)}var t;"object"==typeof process&&process.domain&&(s=process.domain.bind(s)),this._invoke=function(n,r){function e(){return new Promise(function(e,t){s(n,r,e,t)})}return t=t?t.then(e,e):e()}}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(s.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=l,e.done=!0,e};return r.next=r}}return{next:L}}function L(){return{value:l,done:!0}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:this),function(){var E=[],t=void 0,p=[];$(document).on("documentLoaded",function(){PDFNet.initialize().then(function(){var u=!1,l=readerControl.docViewer,f=l.getDocument();f.getPDFDoc().then(function(s){t&&(l.getViewer()[0].removeEventListener("mousedown",t),E=[]);function e(e){if(!u){u=!0;var t=readerControl.docViewer.getAnnotationManager();if(0<p.length){for(var n=0;n<p.length;n++)t.deleteAnnotation(p[n]);p=[]}console.log("MouseClick X: "+e.pageX+", MouseClick Y: "+e.pageY);var r=$(".DocumentContainer"),o=r.scrollTop(),a=r.scrollLeft(),i={x:e.pageX+a,y:e.pageY+o},c=l.getDisplayModeManager().getDisplayMode().getSelectedPages(i,i).first;s.requirePage(c+1).then(function(){return f.extractPDFNetLayersContext()}).then(function(e){return h(s,e,i,c,l,Annotations,t)}).then(function(){console.log("finished script"),l.updateView(),u=!1})}}t=e,l.getViewer()[0].addEventListener("mousedown",e)})})});var h=function(h,y,g,x,e,u,P){t=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n,r,o,a,i){var c,s,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return c=5,void 0!==i&&(c=i),e.next=4,PDFNet.Matrix2D.create(c,0,0,c,t.x-2.5,t.y-2.5);case 4:return s=e.sent,e.next=7,r.createImageFromMatrix(a,s);case 7:u=e.sent,o.writePlacedElement(u);case 9:case"end":return e.stop()}},e,void 0)}));var t,a,r,c,o,n,i,m=(a=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n,r,o,a){var i,c,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:i=D.getViewerCoordinates(t,n,r),c=D.getViewerCoordinates(t,o,a),(s=new u.RectangleAnnotation).setPageNumber(t+1),s.setRect(new u.Rect(i.x,Math.min(i.y,c.y),c.x,Math.max(i.y,c.y))),P.addAnnotation(s),p.push(s);case 7:case"end":return e.stop()}},e,void 0)})),function(e,t,n,r,o){return a.apply(this,arguments)}),k=(r=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n,r){var o,a,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:o=D.getViewerCoordinates(t,n,r),a=D.getViewerCoordinates(t,n,r),o.x-=2,o.y-=2,a.x+=2,a.y+=2,(i=new u.RectangleAnnotation).setPageNumber(t+1),i.FillColor=new u.Color(255,255,0,1),i.StrokeColor=new u.Color(255,0,0,1),i.setRect(new u.Rect(o.x,Math.min(o.y,a.y),a.x,Math.max(o.y,a.y))),P.addAnnotation(i),p.push(i);case 13:case"end":return e.stop()}},e,void 0)})),function(e,t,n){return r.apply(this,arguments)}),v=(c=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n,r,o,a,i,c){var s,u,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.getDefaultMatrix();case 2:return s=e.sent,e.next=5,s.inverse();case 5:return s=e.sent,e.next=8,s.mult(i.x,i.y);case 8:u=e.sent,l=t.length-1;case 10:if(!(0<=l)){e.next=28;break}if(f=t[l],!((p=f.bbox).x1<u.x&&p.x2>u.x&&p.y1<u.y&&p.y2>u.y)){e.next=17;break}console.log("bounding box detected"),e.next=18;break;case 17:return e.abrupt("continue",25);case 18:return e.next=20,m(a,p.x1,p.y1,p.x2,p.y2);case 20:if("path"===f.name)return e.next=23,d(f.operators,f.points,f.ctm,a);e.next=23;break;case 23:if(c)return e.abrupt("break",28);e.next=25;break;case 25:l--,e.next=10;break;case 28:case"end":return e.stop()}},e,void 0)})),function(e,t,n,r,o,a,i){return c.apply(this,arguments)}),d=(o=_asyncToGenerator(regeneratorRuntime.mark(function e(t,n,r,o){var a,i,c,s,u,l,f,p,h,y,g,x,m,v,d,w,b;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=0,4e3<t.length?console.log("Processing "+t.length+" points. This will take significant time."):500<t.length&&console.log("Processing "+t.length+" points. This may take some time."),i=0;case 3:if(!(i<t.length)){e.next=86;break}b=w=d=v=m=x=g=y=h=p=f=l=u=s=c=void 0,e.t0=t[i],e.next=e.t0===PDFNet.Element.PathSegmentType.e_moveto?8:e.t0===PDFNet.Element.PathSegmentType.e_lineto?18:e.t0===PDFNet.Element.PathSegmentType.e_cubicto?28:e.t0===PDFNet.Element.PathSegmentType.e_rect?46:e.t0===PDFNet.Element.PathSegmentType.e_closepath?81:82;break;case 8:return c=n[a],s=n[++a],++a,e.next=14,r.mult(c,s);case 14:return m=e.sent,e.next=17,k(o,m.x,m.y);case 17:return e.abrupt("break",83);case 18:return c=n[a],s=n[++a],++a,e.next=24,r.mult(c,s);case 24:return m=e.sent,e.next=27,k(o,m.x,m.y);case 27:return e.abrupt("break",83);case 28:return c=n[a],s=n[++a],u=n[++a],l=n[++a],f=n[++a],p=n[++a],++a,e.next=42,r.mult(f,p);case 42:return m=e.sent,e.next=45,k(o,m.x,m.y);case 45:return e.abrupt("break",83);case 46:return c=n[a],s=n[++a],g=n[++a],x=n[++a],++a,f=u=c+g,h=c,y=p=(l=s)+x,e.next=62,r.mult(c,s);case 62:return v=e.sent,e.next=65,r.mult(u,l);case 65:return d=e.sent,e.next=68,r.mult(f,p);case 68:return w=e.sent,e.next=71,r.mult(h,y);case 71:return b=e.sent,e.next=74,k(o,v.x,v.y);case 74:return e.next=76,k(o,d.x,d.y);case 76:return e.next=78,k(o,w.x,w.y);case 78:return e.next=80,k(o,b.x,b.y);case 80:case 81:case 82:return e.abrupt("break",83);case 83:++i,e.next=3;break;case 86:P.drawAnnotations(o+1);case 87:case"end":return e.stop()}},e,void 0)})),function(e,t,n,r){return o.apply(this,arguments)}),w=(n=_asyncToGenerator(regeneratorRuntime.mark(function e(t){var n,r,o,a,i,c,s,u,l,f,p,h;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.next=3,t.next();case 3:r=e.sent;case 4:if(null!==r)return e.next=7,r.isOCVisible();e.next=60;break;case 7:if(e.t0=!e.sent,e.t0){e.next=12;break}return e.next=11,r.isClippingPath();case 11:e.t0=e.sent;case 12:if(e.t0)return e.abrupt("continue",55);e.next=14;break;case 14:return e.next=16,r.getCTM();case 16:return o=e.sent,e.next=19,r.getType();case 19:a=e.sent,c=i=void 0,e.t1=a,e.next=e.t1===PDFNet.Element.Type.e_path?24:e.t1===PDFNet.Element.Type.e_image?35:e.t1===PDFNet.Element.Type.e_form?47:54;break;case 24:return e.next=26,r.getPathData();case 26:return s=e.sent,u=new Uint8Array(s.operators),l=new Float64Array(s.points),e.next=31,r.getBBox();case 31:return i=e.sent,c={name:"path",type:a,ctm:o,operators:u,points:l,bbox:i},n.push(c),e.abrupt("break",55);case 35:return e.next=37,r.getBBox();case 37:return i=e.sent,e.next=40,r.getXObject();case 40:return f=e.sent,e.next=43,f.getObjNum();case 43:return p=e.sent,c={name:"image",type:a,num:p,ctm:o,bbox:i},n.push(c),e.abrupt("break",55);case 47:return t.formBegin(),e.next=50,w(t);case 50:return h=e.sent,n=n.concat(h),t.end(),e.abrupt("break",55);case 54:return e.abrupt("break",55);case 55:return e.next=57,t.next();case 57:r=e.sent,e.next=4;break;case 60:return e.abrupt("return",n);case 61:case"end":return e.stop()}},e,void 0)})),function(e){return n.apply(this,arguments)}),b=e.getDisplayModeManager().getDisplayMode(),D=e.getDocument(),s=(i=_asyncToGenerator(regeneratorRuntime.mark(function e(){var t,n,r,o,a,i,c,s,u,l,f,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return 0,e.prev=1,(t=h).lock(),t.initSecurityHandler(),n=!0,r=x+1,o=b.windowToPage(g,x),a=D.getPDFCoordinates(x,o.x,o.y),e.next=11,PDFNet.ElementReader.create();case 11:return i=e.sent,e.next=14,PDFNet.ElementBuilder.create();case 14:return c=e.sent,e.next=17,t.getPage(r);case 17:return s=e.sent,e.next=20,s.getDefaultMatrix();case 20:return u=e.sent,e.next=23,u.mult(a.x,a.y);case 23:if(a=e.sent,l=E[x],(f=void 0)===l)return e.next=29,t.getPage(r);e.next=37;break;case 29:return s=e.sent,f=new PDFNet.OCGContext(y),i.beginOnPage(s,f),e.next=34,w(i);case 34:l=e.sent,E[x]=l,i.end();case 37:return e.next=39,t.getPage(r);case 39:return s=e.sent,f=new PDFNet.OCGContext(y),e.next=43,v(l,c,t,s,x,a,n);case 43:return e.next=45,PDFNet.SquareAnnot.create(t,PDFNet.Rect(10,200,800,300));case 45:return p=e.sent,e.t0=p,e.next=49,PDFNet.ColorPt.init(0,0,0);case 49:e.t1=e.sent,e.t0.setColor.call(e.t0,e.t1,3),p.refreshAppearance(),s.annotPushBack(p),e.next=59;break;case 55:e.prev=55,e.t2=e.catch(1),console.log(e.t2.stack),1;case 59:case"end":return e.stop()}},e,void 0,[[1,55]])})),function(){return i.apply(this,arguments)});return PDFNet.runWithCleanup(s)}}(window);