diff --git a/README.md b/README.md index bbca47c1..6d6e888c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ To report issues for pdf-annotate.js, please file them under the [Submitty/Submi ## Installation ```bash -npm install @submitty/pdf-annotate.js +npm install Submitty/pdf-annotate.js ``` ## Example @@ -73,3 +73,15 @@ $ npm test # lint the code $ npm run lint ``` + +## Building +**Do not** commit your built files when contributing. +If on Windows, change the `build` script in `package.json` to `webpack && SET MINIFY=1&webpack`. +```bash +# switch to node v14 or earlier +$ nvm use 14 + +# build the dist files +$ npm run build +``` + diff --git a/dist/pdf-annotate.js b/dist/pdf-annotate.js index ec294869..757d0399 100644 --- a/dist/pdf-annotate.js +++ b/dist/pdf-annotate.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PDFAnnotate=e():t.PDFAnnotate=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";var r,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var a=Number.isNaN||function(t){return t!=t};function u(){u.init.call(this)}t.exports=u,t.exports.once=function(t,e){return new Promise((function(n,r){function o(n){t.removeListener(e,i),r(n)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}h(t,e,i,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&h(t,"error",e,n)}(t,o,{once:!0})}))},u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function l(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function s(t){return void 0===t._maxListeners?u.defaultMaxListeners:t._maxListeners}function d(t,e,n,r){var o,i,a,u;if(l(n),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),i=t._events),a=i[e]),void 0===a)a=i[e]=n,++t._eventsCount;else if("function"==typeof a?a=i[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=s(t))>0&&a.length>o&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,u=c,console&&console.warn&&console.warn(u)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=f.bind(r);return o.listener=n,r.wrapFn=o,o}function y(t,e,n){var r=t._events;if(void 0===r)return[];var o=r[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(a=e[0]),a instanceof Error)throw a;var u=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw u.context=a,u}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)i(c,this,e);else{var l=c.length,s=v(c,l);for(n=0;n=0;i--)if(n[i]===e||n[i].listener===e){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},u.prototype.listeners=function(t){return y(this,t,!0)},u.prototype.rawListeners=function(t){return y(this,t,!1)},u.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},u.prototype.listenerCount=m,u.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){"use strict";function r(t){throw new Error(t+" is not implemented")}n.r(e);var o=n(0),i=n.n(o),a=/[A-Z]/g,u=["viewBox"];function c(t,e){Object.keys(e).forEach((function(n){t.setAttribute(function(t){return-1===u.indexOf(t)&&(t=t.replace(a,(function(t){return"-"+t.toLowerCase()}))),t}(n),e[n])}))}var l=/^([a-f0-9]{6}|[a-f0-9]{3})$/i;function s(t){return l.test(t)&&(t="#".concat(t)),t}function d(t){var e=document.createElementNS("http://www.w3.org/2000/svg","rect");return c(e,{x:t.x,y:t.y,width:t.width,height:t.height}),e}function f(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0){e.push("M".concat(t.lines[0][0]," ").concat(t.lines[0][1]));for(var r=1,o=t.lines.length;r=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right}function q(t){var e=t.getBoundingClientRect(),n=e.width,r=e.height,o=0,i=0;if(["line","path"].indexOf(t.tagName.toLowerCase())>-1&&t.getBBox){var a=t.getBBox();o=(e.width-a.width)/2,i=(e.height-a.height)/2,n=a.width,r=a.height}var u=function(t){var e=t;for(;(e=e.parentNode)&&e!==document&&"SVG"!==e.nodeName.toUpperCase(););var n=e.getBoundingClientRect();return{offsetLeft:n.left,offsetTop:n.top}}(t),c=u.offsetLeft,l=u.offsetTop;return{top:e.top-l+i,left:e.left-c+o,bottom:e.bottom-l-i,right:e.right-c-o,width:n,height:r}}function F(t,e){var n={},r=H(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]*r.scale})),n}function z(t,e,n){var r=[1,0,0,1,0,0];r=h(r=g(r,(n=n||H(e).viewport).scale,n.scale),n.rotation);var o,i,a,u=k(n);return r=v(r,u.x,u.y),o=t,a=(i=r)[0]*i[3]-i[1]*i[2],[(o[0]*i[3]-o[1]*i[2]+i[2]*i[5]-i[4]*i[3])/a,(-o[0]*i[1]+o[1]*i[0]+i[4]*i[1]-i[5]*i[0])/a]}function X(t,e,n){var r=[1,0,0,1,0,0];r=h(r=g(r,(n=n||H(e).viewport).scale,n.scale),n.rotation);var o,i,a=k(n);return r=v(r,a.x,a.y),i=r,[(o=t)[0]*i[0]+o[1]*i[2]+i[4],o[0]*i[1]+o[1]*i[3]+i[5]]}function Y(t,e){var n={},r=H(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]/r.scale})),n}function U(){P.parentNode||document.head.appendChild(P)}function Q(){P.parentNode&&P.parentNode.removeChild(P)}function H(t){return{documentId:t.getAttribute("data-pdf-annotate-document"),pageNumber:parseInt(t.getAttribute("data-pdf-annotate-page"),10),viewport:JSON.parse(t.getAttribute("data-pdf-annotate-viewport"))}}P.innerHTML="\nbody {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n",P.setAttribute("data-pdf-annotate-user-select","true");var D,W=new i.a;function $(){W.emit.apply(W,arguments)}function J(){W.on.apply(W,arguments)}function V(){W.removeListener.apply(W,arguments)}function G(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function K(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};G(this,t),Object.keys(n).forEach((function(t){"function"==typeof n[t]&&"function"==typeof e[t]&&(e[t]=n[t])}))}var e,n,o;return e=t,(n=[{key:"__getAnnotations",value:function(t,e){r("getAnnotations")}},{key:"getAnnotations",get:function(){return this.__getAnnotations},set:function(t){this.__getAnnotations=function(e,n){return t.apply(void 0,arguments).then((function(t){return t.annotations&&t.annotations.forEach((function(t){t.documentId=e})),t}))}}},{key:"getAnnotation",value:function(t,e){r("getAnnotation")}},{key:"__addAnnotation",value:function(t,e,n){r("addAnnotation")}},{key:"addAnnotation",get:function(){return this.__addAnnotation},set:function(t){this.__addAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("annotation:add",e,n,t),t}))}}},{key:"__editAnnotation",value:function(t,e,n){r("editAnnotation")}},{key:"editAnnotation",get:function(){return this.__editAnnotation},set:function(t){this.__editAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("annotation:edit",e,n,t),t}))}}},{key:"__deleteAnnotation",value:function(t,e){r("deleteAnnotation")}},{key:"deleteAnnotation",get:function(){return this.__deleteAnnotation},set:function(t){this.__deleteAnnotation=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&$("annotation:delete",e,n),t}))}}},{key:"getComments",value:function(t,e){r("getComments")}},{key:"__addComment",value:function(t,e,n){r("addComment")}},{key:"addComment",get:function(){return this.__addComment},set:function(t){this.__addComment=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("comment:add",e,n,t),t}))}}},{key:"__deleteComment",value:function(t,e){r("deleteComment")}},{key:"deleteComment",get:function(){return this.__deleteComment},set:function(t){this.__deleteComment=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&$("comment:delete",e,n),t}))}}}])&&K(e.prototype,n),o&&K(e,o),Object.defineProperty(e,"prototype",{writable:!1}),t}(),tt=/[xy]/g;function et(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}function nt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(tt,et)}function rt(t){return(rt="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 ot(t,e){for(var n=0;n-1){var i=st(t);i.splice(o,1),dt(t,i)}n(!0)}))},t.getComments=function(t,e){return new Promise((function(n,r){n(st(t).filter((function(t){return"Comment"===t.class&&t.annotation===e})))}))},t.addComment=function(t,e,n){return new Promise((function(r,o){var i={class:"Comment",uuid:nt(),annotation:e,content:n},a=st(t);a.push(i),dt(t,a),r(i)}))},t.deleteComment=function(t,e){return new Promise((function(n,r){if(!(st(t).filter((function(t){return t.uuid===e}))[0]||{}))return r("Could not find annotation");for(var o=-1,i=st(t),a=0,u=i.length;a-1&&(i.splice(o,1),dt(t,i)),n(!0)}))},t}return e=i,n&&ot(e.prototype,n),r&&ot(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(Z);function st(t){return JSON.parse(localStorage.getItem("".concat(t,"/annotations")))||[]}function dt(t,e){localStorage.setItem("".concat(t,"/annotations"),JSON.stringify(e))}function ft(t,e){for(var n=-1,r=st(t),o=0,i=r.length;ot.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&void 0!==arguments[0]?arguments[0]:"user",n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return vt(this,i),(t=o.call(this,{getAnnotations:function(t,e){return new Promise((function(n,r){var o=St(t).filter((function(t){return t.page===e&&"Annotation"===t.class}));n({documentId:t,pageNumber:e,annotations:o})}))}}))._userId=e,t._globalEdit=n,t.getAnnotation=function(e,n){return Promise.resolve(Et(e,t._userId)[Lt(e,t._userId,n)])},t.addAnnotation=function(e,n,r){return new Promise((function(o,i){r.class="Annotation",r.uuid=nt(),r.page=n,r.userId=t._userId;var a=Et(e,t._userId);a.push(r),Ct(e,t._userId,a),o(r)}))},t.editAnnotation=function(e,n,r){return new Promise((function(o,i){!t._globalEdit&&r.userId&&r.userId!==t._userId&&i("Non-matching userId");var a=Et(e,r.userId);a[Lt(e,r.userId,n)]=r,Ct(e,r.userId,a),o(r)}))},t.deleteAnnotation=function(e,n){return new Promise((function(r,o){var i=St(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");var a=Lt(e,i.userId,n);if(a>-1){var u=Et(e,i.userId);u.splice(a,1),Ct(e,i.userId,u)}r(!0)}))},t.getComments=function(e,n){return new Promise((function(r,o){r(Et(e,t._userId).filter((function(t){return"Comment"===t.class&&t.annotation===n})))}))},t.addComment=function(e,n,r){return new Promise((function(o,i){var a={class:"Comment",uuid:nt(),annotation:n,content:r,userId:t._userId},u=Et(e,t._userId);u.push(a),Ct(e,t._userId,u),o(a)}))},t.deleteComment=function(e,n){return new Promise((function(r,o){var i=St(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");for(var a=-1,u=Et(e,i.userId),c=0,l=u.length;c-1&&(u.splice(a,1),Ct(e,i.userId,u)),r(!0)}))},t}return e=i,(n=[{key:"userId",get:function(){return this._userId}}])&&ht(e.prototype,n),r&&ht(e,r),Object.defineProperty(e,"prototype",{writable:!1}),i}(Z);function St(t){for(var e=[],n=new RegExp("".concat(t,"/(.*)/annotations")),r=0;r-1&&e.push.apply(e,yt(JSON.parse(localStorage.getItem(localStorage.key(r)))));return e}function Et(t,e){return JSON.parse(localStorage.getItem("".concat(t,"/").concat(e,"/annotations")))||[]}function Ct(t,e,n){localStorage.setItem("".concat(t,"/").concat(e,"/annotations"),JSON.stringify(n))}function Lt(t,e,n){for(var r=-1,o=Et(t,e),i=0,a=o.length;it.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&n+Ot.offsetHeight0&&r+Ot.offsetWidth-1&&(a="cx",u="cy"),"point"!==r){if(["area","highlight","textbox","circle","fillcircle","emptycircle"].indexOf(r)>-1){var c=z([Pt,Rt],o),l=z([Ot.offsetLeft,Ot.offsetTop],o),s={x:l[0]-c[0],y:l[1]-c[1]};"textbox"===r&&(n=[n[0].firstChild]),_t(n).forEach((function(e,n){var r=parseInt(e.getAttribute(a),10),o=parseInt(e.getAttribute(u),10);0!==s.y&&(o+=s.y,e.setAttribute(u,o),t.rectangles&&n1&&(n=M(t,e))){var r=H(n),o=r.documentId,i=r.pageNumber;Cn.getStoreAdapter().addAnnotation(o,i,{type:"drawing",width:Ht,color:Dt,lines:Vt}).then((function(t){Wt&&n.removeChild(Wt),N(n,t)}))}}(t.clientX,t.clientY)}function Zt(t){M(t.clientX,t.clientY)&&Jt&&function(t,e){var n=M(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=z([t-r.left,e-r.top],n);if(o[0]=o[0].toFixed(2),o[1]=o[1].toFixed(2),Vt.push(o),Vt.length<=1)return;Wt&&n.removeChild(Wt);Wt=N(n,{type:"drawing",color:Dt,width:Ht,lines:Vt})}(t.clientX,t.clientY)}function te(t){27===t.keyCode&&(Vt=null,Wt.parentNode.removeChild(Wt),document.removeEventListener("pointermove",Zt),document.removeEventListener("pointerup",Kt))}var ee,ne,re,oe,ie,ae,ue=!1;function ce(t){var e=T(t.clientX,t.clientY);if(null!==e){var n=e.getAttribute("data-pdf-annotate-type");if("circle"===n||"fillcircle"===n||"emptycircle"===n){var r=R(e),o=H(r).documentId,i=e.getAttribute("data-pdf-annotate-id");Cn.getStoreAdapter().getAnnotation(o,i).then((function(t){if(t){re=null,oe=[];var e=X([t.cx,t.cy],r),n=r.getBoundingClientRect();ae=e[0]+n.left,ie=e[1]+n.top,document.addEventListener("mousemove",se),document.addEventListener("mouseup",le)}}))}}}function le(t){var e;if(oe.length>1&&(e=M(t.clientX,t.clientY))){var n=H(e),r=n.documentId,o=n.pageNumber;Cn.getStoreAdapter().addAnnotation(r,o,{type:"arrow",width:ee,color:ne,lines:oe}).then((function(t){re&&e.removeChild(re),N(e,t)}))}document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",le)}function se(t){!function(t,e){var n=M(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=z([t-r.left,e-r.top],n);if(oe.length<2)return void oe.push(o);oe[1]=o;re&&n.removeChild(re);re=N(n,{type:"arrow",color:ne,width:ee,lines:oe})}(0===oe.length?ae:t.clientX,0===oe.length?ie:t.clientY)}function de(t){27===t.keyCode&&(oe=null,re.parentNode.removeChild(re),document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",le))}function fe(t){return function(t){if(Array.isArray(t))return pe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return pe(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pe(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pe(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=1||r>=1)for(var o=Math.round(Math.max(n,r)),i=Math.min(n,r)/o,a=n0){var t=parseInt(we.style.left,10),e=parseInt(we.style.top,10),n=we.value.trim(),r=M(t,e);if(!r)return;var o=r.getBoundingClientRect(),i=H(r),a=i.documentId,u=i.pageNumber,c=Object.assign({type:"point"},Y(r,{x:t-o.left,y:e-o.top}));Cn.getStoreAdapter().addAnnotation(a,u,c).then((function(t){Cn.getStoreAdapter().addComment(a,t.uuid,n),N(r,t)}))}Le()}function Le(){we.removeEventListener("blur",Se),we.removeEventListener("keyup",Ee),document.body.removeChild(we),we=null}function Ie(t){return function(t){if(Array.isArray(t))return _e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return _e(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _e(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&t[0].width>0&&t[0].height>0)return t}catch(t){}return null}()))qe(ke,Ie(e).map((function(t){return{top:t.top,left:t.left,width:t.width,height:t.height}})));else if("area"===ke&&Oe){var n=Oe.parentNode.querySelector(It.annotationSvgQuery()).getBoundingClientRect();qe(ke,[{top:parseInt(Oe.style.top,10)+n.top,left:parseInt(Oe.style.left,10)+n.left,width:parseInt(Oe.style.width,10),height:parseInt(Oe.style.height,10)}]),Oe.parentNode.removeChild(Oe),Oe=null,document.removeEventListener("mousemove",Me),Q()}}function Be(t){27===t.keyCode&&(window.getSelection().removeAllRanges(),Oe&&Oe.parentNode&&(Oe.parentNode.removeChild(Oe),Oe=null,document.removeEventListener("mousemove",Me)))}function qe(t,e,n){var r,o=M(e[0].left,e[0].top);if(o){var i=o.getBoundingClientRect();if(n||("highlight"===t?n="FFFF00":"strikeout"===t&&(n="FF0000")),0!==(r={type:t,color:n,rectangles:Ie(e).map((function(e){var n=0;return"strikeout"===t&&(n=e.height/2),function(t,e,n){var r=[t.x,t.y],o=[t.x+t.width,t.y+t.height];return r=z(r,e,n),o=z(o,e,n),{x:Math.min(r[0],o[0]),y:Math.min(r[1],o[1]),width:Math.abs(o[0]-r[0]),height:Math.abs(o[1]-r[1])}}({y:e.top+n-i.top,x:e.left-i.left,width:e.width,height:e.height},o)})).filter((function(t){return t.width>0&&t.height>0&&t.x>-1&&t.y>-1}))}).rectangles.length){if("area"===t){var a=r.rectangles[0];delete r.rectangles,r.x=a.x,r.y=a.y,r.width=a.width,r.height=a.height}var u=H(o),c=u.documentId,l=u.pageNumber;Cn.getStoreAdapter().addAnnotation(c,l,r).then((function(t){N(o,t)}))}}}var Fe,ze=!1,Xe=10,Ye="0000FF";function Ue(t){var e=M(t.clientX,t.clientY);if(e){var n=e.getBoundingClientRect();!function(t,e,n,r,o){var i=z([n.x,n.y],t),a={type:e,color:o,cx:i[0],cy:i[1],r:r},u=H(t),c=u.documentId,l=u.pageNumber;Cn.getStoreAdapter().addAnnotation(c,l,a).then((function(e){N(t,e)}))}(e,Fe,{x:t.clientX-n.left,y:t.clientY-n.top},Xe,Ye)}}var Qe,He=!1,De=localStorage.getItem("text/size")||12,We=localStorage.getItem("text/color")||"#000000";function $e(t){!Qe&&M(t.clientX,t.clientY)&&t.srcElement.classList.contains("annotationLayer")&&((Qe=document.createElement("textarea")).setAttribute("id","pdf-annotate-text-input"),Qe.setAttribute("placeholder","Enter text... SHIFT + ENTER for new line"),Qe.style.border="3px solid ".concat("#00BFFF"),Qe.style.borderRadius="3px",Qe.style.position="fixed",Qe.style.top="".concat(t.clientY,"px"),Qe.style.left="".concat(t.clientX,"px"),Qe.style.fontSize="".concat(De,"px"),Qe.style.zIndex="41",Qe.addEventListener("blur",Je),Qe.addEventListener("keyup",Ve),document.body.appendChild(Qe),Qe.focus())}function Je(){Ge()}function Ve(t){27===t.keyCode?Ke():13!==t.keyCode||t.shiftKey||Ge()}function Ge(){var t=Qe.value?Qe.value.replace(/ +$/,""):"";if(t.length>0){var e=parseInt(Qe.style.left,10),n=parseInt(Qe.style.top,10),r=M(e,n);if(!r)return;var o=De,i=H(r),a=i.documentId,u=i.pageNumber,c=i.viewport,l=1/c.scale,s=r.getBoundingClientRect(),d=z([e-s.left,n-s.top+o],r,c),f={type:"textbox",size:De*l,color:We,content:t,x:d[0],y:d[1],rotation:-c.rotation};Cn.getStoreAdapter().addAnnotation(a,u,f).then((function(t){N(r,t)}))}Ke()}function Ke(){Qe&&(Qe.removeEventListener("blur",Je),Qe.removeEventListener("keyup",Ve),document.body.removeChild(Qe),Qe=null)}function Ze(t,e){var n=document.createElement("div"),r=document.createTextNode(t);return n.appendChild(r),n.setAttribute("id","pdf-annotate-screenreader-".concat(e)),n.style.position="absolute",n.style.left="-10000px",n.style.top="auto",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n}function tn(t){return function(t){if(Array.isArray(t))return en(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return en(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function en(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n"===l[l.length-1])for(;l.length&&(s.unshift(l.pop()),"<"!==s[0]););if(c.innerHTML=l.join(""),u+Y(a,{width:c.getBoundingClientRect().width}).width<=e)break;s.unshift(l.pop())}return i.innerHTML=l.join("")+t.outerHTML+s.join(""),c.parentNode.removeChild(c),!0}function rn(t){return function(t){if(Array.isArray(t))return on(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return on(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return on(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function on(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n div"));n=F(o,{y:n}).y+i.top,e=F(o,{x:e}).x+i.left;for(var u=0,c=a.length;u1&&void 0!==arguments[1]?arguments[1]:0;switch(t.type){case"highlight":case"strikeout":var n=t.rectangles,r=n[0],o=n[n.length-1];nn(Ze("Begin ".concat(t.type," annotation ").concat(e),t.uuid),r.x,r.y,t.page,!0),nn(Ze("End ".concat(t.type," annotation ").concat(e),"".concat(t.uuid,"-end")),o.x+o.width,o.y,t.page,!1);break;case"textbox":case"point":var i="textbox"===t.type?" (content: ".concat(t.content,")"):"";an(Ze("".concat(t.type," annotation ").concat(e).concat(i),t.uuid),t.x,t.y,t.page);break;case"drawing":case"area":var a=void 0!==t.x?t.x:t.lines[0][0],u=void 0!==t.y?t.y:t.lines[0][1];an(Ze("Unlabeled drawing",t.uuid),a,u,t.page);break;case"circle":case"fillcircle":case"emptycircle":var c=void 0!==t.cx?t.cx:t.lines[0][0],l=void 0!==t.cy?t.cy:t.lines[0][1];an(Ze("Unlabeled drawing",t.uuid),c,l,t.page)}ln.includes(t.type)&&cn(t.documentId,t.uuid)}(t,e+1)}))}))}function vn(t,e){return t.yt.length)&&(e=t.length);for(var n=0,r=new Array(e);n\n \n \n';function An(t){if(Math.floor(t)===t)return[t,1];var e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];for(var n=t>1?e:t,r=0,o=1,i=1,a=1;;){var u=r+i,c=o+a;if(c>8)break;n<=u/c?(i=u,a=c):(r=u,o=c)}return n-r/o0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";Ht=Math.round(100*parseFloat(t))/100,Dt=e},disablePoint:function(){xe&&(xe=!1,document.removeEventListener("mouseup",Ae))},enablePoint:function(){xe||(xe=!0,document.addEventListener("mouseup",Ae))},disableRect:function(){Pe&&(Pe=!1,document.removeEventListener("mouseup",Te),document.removeEventListener("mousedown",Re),document.removeEventListener("keyup",Be))},enableRect:function(t){ke=t,Pe||(Pe=!0,document.addEventListener("mouseup",Te),document.addEventListener("mousedown",Re),document.addEventListener("keyup",Be))},disableCircle:function(){ze&&(ze=!1,document.removeEventListener("mouseup",Ue))},enableCircle:function(t){Fe=t,ze||(ze=!0,document.addEventListener("mouseup",Ue))},setCircle:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";Xe=parseInt(t,10),Ye=e},addCircle:function(t,e){var n=Fe;Fe=t,Ue(e),Fe=n},disableArrow:function(){ue&&(ue=!1,document.removeEventListener("mousedown",ce),document.removeEventListener("keyup",de),Q())},enableArrow:function(){ue||(ue=!0,document.addEventListener("mousedown",ce),document.addEventListener("keyup",de),U())},setArrow:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";ee=parseInt(t,10),ne=e},disableEraser:function(){document.removeEventListener("pointermove",ge),document.removeEventListener("pointerdown",ve),document.removeEventListener("pointerup",he)},enableEraser:function(){document.addEventListener("pointermove",ge),document.addEventListener("pointerdown",ve),document.addEventListener("pointerup",he)},disableText:function(){He&&(He=!1,document.removeEventListener("mouseup",$e))},enableText:function(){He||(He=!0,document.addEventListener("mouseup",$e))},setText:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";De=parseInt(t,10),We=e},createPage:function(t){var e=document.createElement("div");e.innerHTML=xn;var n=e.children[0],r=n.querySelector("canvas");return n.setAttribute("id","pageContainer".concat(t)),n.setAttribute("data-page-number",t),r.mozOpaque=!0,r.setAttribute("id","page".concat(t)),n},renderPage:function(t,e){var n=e.documentId,r=e.pdfDocument,o=e.scale,i=e.rotate,a=new pdfjsViewer.EventBus;return Promise.all([r.getPage(t),Cn.getAnnotations(n,t)]).then((function(e){var n=bn(e,2),r=n[0],u=n[1],c=document.getElementById("pageContainer".concat(t)),l=c.querySelector(It.annotationClassQuery()),s=c.querySelector(".canvasWrapper canvas").getContext("2d",{alpha:!1}),d=(i+r.rotate)%360,f=r.getViewport({scale:o,rotation:d}),p=function(t,e,n){var r=document.getElementById("pageContainer".concat(t)),o=r.querySelector(".canvasWrapper canvas"),i=r.querySelector(It.annotationClassQuery()),a=r.querySelector(".canvasWrapper"),u=r.querySelector(It.textClassQuery()),c=(f=n,p=window.devicePixelRatio||1,y=f.webkitBackingStorePixelRatio||f.mozBackingStorePixelRatio||f.msBackingStorePixelRatio||f.oBackingStorePixelRatio||f.backingStorePixelRatio||1,m=p/y,{sx:m,sy:m,scaled:1!==m}),l=c.scaled?[c.sx,0,0,c.sy,0,0]:null,s=An(c.sx),d=An(c.sy);var f,p,y,m;return r.style.visibility="",o.width=Sn(e.width*c.sx,s[0]),o.height=Sn(e.height*c.sy,d[0]),o.style.width=Sn(e.width,s[1])+"px",o.style.height=Sn(e.height,s[1])+"px",i.setAttribute("width",e.width),i.setAttribute("height",e.height),i.style.width="".concat(e.width,"px"),i.style.height="".concat(e.height,"px"),r.style.width="".concat(e.width,"px"),r.style.height="".concat(e.height,"px"),a.style.width="".concat(e.width,"px"),a.style.height="".concat(e.height,"px"),u.style.width="".concat(e.width,"px"),u.style.height="".concat(e.height,"px"),l}(t,f,s);return Promise.all([r.render({canvasContext:s,viewport:f,transform:p}).promise,Cn.render(l,f,u)]).then((function(){return r.getTextContent({normalizeWhitespace:!0}).then((function(e){return new Promise((function(n,r){var o=c.querySelector(It.textClassQuery()),i=(new pdfjsViewer.DefaultTextLayerFactory).createTextLayerBuilder(o,t-1,f,!1,a);i.setTextContent(e),i.render(),setTimeout((function(){try{mn(u.annotations),n()}catch(t){r(t)}}))}))}))})).then((function(){return c.setAttribute("data-loaded","true"),[r,u]}))}))}},Cn={findAnnotationAtPoint:T,findSVGContainer:R,convertToScreenPoint:X,StoreAdapter:Z,LocalStoreAdapter:lt,LocalUserStoreAdapter:At,__storeAdapter:new Z,getStoreAdapter:function(){return this.__storeAdapter},setStoreAdapter:function(t){this.__storeAdapter=t},UI:En,render:function(t,e,n){return new Promise((function(r,o){return t.setAttribute("data-pdf-annotate-container",!0),t.setAttribute("data-pdf-annotate-viewport",JSON.stringify(e)),t.removeAttribute("data-pdf-annotate-document"),t.removeAttribute("data-pdf-annotate-page"),n?(t.setAttribute("data-pdf-annotate-document",n.documentId),t.setAttribute("data-pdf-annotate-page",n.pageNumber),Array.isArray(n.annotations)&&0!==n.annotations.length?(n.annotations.forEach((function(n){var r=t.querySelector('[data-pdf-annotate-id="'+n.uuid+'"]');r?j(t,r,e):N(t,n,e)})),void r(t)):r(t)):(t.innerHTML="",r(t))}))},getAnnotations:function(t,e){var n;return(n=this.getStoreAdapter()).getAnnotations.apply(n,arguments)},config:It,uuid:nt};e.default=Cn}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PDFAnnotate=e():t.PDFAnnotate=e()}(self,(()=>(()=>{"use strict";var t={7:t=>{var e,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function i(){i.init.call(this)}t.exports=i,t.exports.once=function(t,e){return new Promise((function(n,r){function o(n){t.removeListener(e,i),r(n)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}v(t,e,i,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&v(t,"error",e,{once:!0})}(t,o)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?i.defaultMaxListeners:t._maxListeners}function l(t,e,n,r){var o,i,a,l;if(c(n),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),i=t._events),a=i[e]),void 0===a)a=i[e]=n,++t._eventsCount;else if("function"==typeof a?a=i[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=u(t))>0&&a.length>o&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,l=s,console&&console.warn&&console.warn(l)}return t}function s(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=s.bind(r);return o.listener=n,r.wrapFn=o,o}function f(t,e,n){var r=t._events;if(void 0===r)return[];var o=r[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(a=e[0]),a instanceof Error)throw a;var c=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw c.context=a,c}var u=i[t];if(void 0===u)return!1;if("function"==typeof u)r(u,this,e);else{var l=u.length,s=y(u,l);for(n=0;n=0;i--)if(n[i]===e||n[i].listener===e){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},i.prototype.listeners=function(t){return f(this,t,!0)},i.prototype.rawListeners=function(t){return f(this,t,!1)},i.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};function o(t){throw new Error(t+" is not implemented")}n.r(r),n.d(r,{default:()=>bn});var i=n(7),a=n.n(i),c=/[A-Z]/g,u=["viewBox"],l=function(t){return-1===u.indexOf(t)&&(t=t.replace(c,(function(t){return"-"+t.toLowerCase()}))),t};function s(t,e){Object.keys(e).forEach((function(n){t.setAttribute(l(n),e[n])}))}var d=/^([a-f0-9]{6}|[a-f0-9]{3})$/i;function f(t){return d.test(t)&&(t="#".concat(t)),t}var p=25,y="M499.968 214.336q-113.832 0 -212.877 38.781t-157.356 104.625 -58.311 142.29q0 62.496 39.897 119.133t112.437 97.929l48.546 27.9 -15.066 53.568q-13.392 50.778 -39.06 95.976 84.816 -35.154 153.45 -95.418l23.994 -21.204 31.806 3.348q38.502 4.464 72.54 4.464 113.832 0 212.877 -38.781t157.356 -104.625 58.311 -142.29 -58.311 -142.29 -157.356 -104.625 -212.877 -38.781z";function v(t){var e=document.createElementNS("http://www.w3.org/2000/svg","rect");return s(e,{x:t.x,y:t.y,width:t.width,height:t.height}),e}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}(r);try{for(c.s();!(n=c.n()).done;){var u=n.value,l=document.createElementNS("http://www.w3.org/2000/svg","tspan");l.setAttribute("y",i.toString()),l.setAttribute("x",o),l.innerHTML=u,t.appendChild(l),i+=a}}catch(t){c.e(t)}finally{c.f()}}(e,t.content);var n=document.createElementNS("http://www.w3.org/2000/svg","g");return n.appendChild(e),n}function g(t,e,n){return[t[0],t[1],t[2],t[3],t[0]*e+t[2]*n+t[4],t[1]*e+t[3]*n+t[5]]}function b(t,e){e=e*Math.PI/180;var n=Math.cos(e),r=Math.sin(e);return[t[0]*n+t[2]*r,t[1]*n+t[3]*r,t[0]*-r+t[2]*n,t[1]*-r+t[3]*n,t[4],t[5]]}function w(t,e,n){return[t[0]*e,t[1]*e,t[2]*n,t[3]*n,t[4],t[5]]}function x(t,e,n){return{x:t,y:e,z:n}}function A(t,e,n){return{xcoord:t,ycoord:e,zcoord:n}}function S(t,e){return A(e.x-t.x,e.y-t.y,e.z-t.z)}function E(t,e){return x(t.x+e.xcoord,t.y+e.ycoord,t.z+e.zcoord)}function C(t,e){return A(t.xcoord*e,t.ycoord*e,t.zcoord*e)}function L(t){return Math.sqrt(Math.pow(t.xcoord,2)+Math.pow(t.ycoord,2)+Math.pow(t.zcoord,2))}function I(t){return C(t,-1)}function _(t){var e=L(t);return A(t.xcoord/e,t.ycoord/e,t.zcoord/e)}var k=/firefox/i.test(navigator.userAgent);function N(t){var e,n;switch(t.rotation%360){case 0:e=n=0;break;case 90:e=0,n=t.width/t.scale*-1;break;case 180:e=t.width/t.scale*-1,n=t.height/t.scale*-1;break;case 270:e=t.height/t.scale*-1,n=0}return{x:e,y:n}}function O(t,e){var n=N(e);if(t.setAttribute("transform","scale(".concat(e.scale,") rotate(").concat(e.rotation,") translate(").concat(n.x,", ").concat(n.y,")")),!k&&"svg"===t.nodeName.toLowerCase()){t.setAttribute("x",parseInt(t.getAttribute("x"),10)*e.scale),t.setAttribute("y",parseInt(t.getAttribute("y"),10)*e.scale);var r=parseInt(t.getAttribute("x",10)),o=parseInt(t.getAttribute("y",10)),i=parseInt(t.getAttribute("width"),10),a=parseInt(t.getAttribute("height"),10),c=t.querySelector("path"),u=c.parentNode;switch([t,u,c,t.querySelector("rect")].forEach((function(t){t.setAttribute("width",parseInt(t.getAttribute("width"),10)*e.scale),t.setAttribute("height",parseInt(t.getAttribute("height"),10)*e.scale)})),O(c,Object.assign({},e,{scale:1})),e.rotation%360){case 90:t.setAttribute("x",e.width-o-i),t.setAttribute("y",r),u.setAttribute("x",1),u.setAttribute("y",0);break;case 180:t.setAttribute("x",e.width-r-i),t.setAttribute("y",e.height-o-a),u.setAttribute("y",2);break;case 270:t.setAttribute("x",o),t.setAttribute("y",e.height-r-a),u.setAttribute("x",-1),u.setAttribute("y",0)}}return t}function j(t,e,n){var r,o,i;switch(n||(n=JSON.parse(t.getAttribute("data-pdf-annotate-viewport"))),e.type){case"area":case"highlight":r=function(t){if("highlight"===t.type){var e=document.createElementNS("http://www.w3.org/2000/svg","g");return s(e,{fill:f(t.color||"#ff0"),fillOpacity:.2}),t.rectangles.forEach((function(t){e.appendChild(v(t))})),e}var n=v(t);return s(n,{stroke:f(t.color||"#f00"),fill:"none"}),n}(e);break;case"circle":case"fillcircle":case"emptycircle":r=function(t){var e=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","circle");return s(e,{cx:t.cx,cy:t.cy,r:t.r}),e}(t),n=f(t.color||"#f00");return"circle"===t.type&&s(e,{stroke:n,fill:"none","stroke-width":5}),"emptycircle"===t.type&&s(e,{stroke:n,fill:"none","stroke-width":2}),"fillcircle"===t.type&&s(e,{stroke:n,fill:n,"stroke-width":5}),e}(e);break;case"strikeout":o=e,s(i=document.createElementNS("http://www.w3.org/2000/svg","g"),{stroke:f(o.color||"#f00"),strokeWidth:1}),o.rectangles.forEach((function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","line");s(e,{x1:t.x,y1:t.y,x2:t.x+t.width,y2:t.y}),i.appendChild(e)})),r=i;break;case"point":r=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","rect"),o=document.createElementNS("http://www.w3.org/2000/svg","path");return s(e,{width:p,height:p,x:t.x,y:t.y}),s(n,{width:p,height:p,x:0,y:.05*p*-1,viewBox:"0 0 1000 1000"}),s(r,{width:p,height:p,stroke:"#000",fill:"#ff0"}),s(o,{d:y,strokeWidth:50,stroke:"#000",fill:"#fff"}),n.appendChild(o),e.appendChild(r),e.appendChild(n),e}(e);break;case"textbox":r=h(e);break;case"drawing":r=function(t){var e=[],n=document.createElementNS("http://www.w3.org/2000/svg","path");if(t.lines.length>0){e.push("M".concat(t.lines[0][0]," ").concat(t.lines[0][1]));for(var r=1,o=t.lines.length;r=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right}function z(t,e){var n={},r=H(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]*r.scale})),n}function F(t,e,n){var r=[1,0,0,1,0,0];r=b(r=w(r,(n=n||H(e).viewport).scale,n.scale),n.rotation);var o,i,a,c=N(n);return o=t,a=(i=r=g(r,c.x,c.y))[0]*i[3]-i[1]*i[2],[(o[0]*i[3]-o[1]*i[2]+i[2]*i[5]-i[4]*i[3])/a,(-o[0]*i[1]+o[1]*i[0]+i[4]*i[1]-i[5]*i[0])/a]}function X(t,e,n){var r=[1,0,0,1,0,0];r=b(r=w(r,(n=n||H(e).viewport).scale,n.scale),n.rotation);var o,i,a=N(n);return i=r=g(r,a.x,a.y),[(o=t)[0]*i[0]+o[1]*i[2]+i[4],o[0]*i[1]+o[1]*i[3]+i[5]]}function Y(t,e){var n={},r=H(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]/r.scale})),n}function U(){M.parentNode||document.head.appendChild(M)}function Q(){M.parentNode&&M.parentNode.removeChild(M)}function H(t){return{documentId:t.getAttribute("data-pdf-annotate-document"),pageNumber:parseInt(t.getAttribute("data-pdf-annotate-page"),10),viewport:JSON.parse(t.getAttribute("data-pdf-annotate-viewport"))}}M.innerHTML="\nbody {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n",M.setAttribute("data-pdf-annotate-user-select","true");var D,W=new(a());function $(){W.emit.apply(W,arguments)}function J(){W.on.apply(W,arguments)}function V(){W.removeListener.apply(W,arguments)}function G(t){return G="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},G(t)}function K(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.keys(n).forEach((function(t){"function"==typeof n[t]&&"function"==typeof e[t]&&(e[t]=n[t])}))},e=[{key:"__getAnnotations",value:function(t,e){o("getAnnotations")}},{key:"getAnnotations",get:function(){return this.__getAnnotations},set:function(t){this.__getAnnotations=function(e,n){return t.apply(void 0,arguments).then((function(t){return t.annotations&&t.annotations.forEach((function(t){t.documentId=e})),t}))}}},{key:"getAnnotation",value:function(t,e){o("getAnnotation")}},{key:"__addAnnotation",value:function(t,e,n){o("addAnnotation")}},{key:"addAnnotation",get:function(){return this.__addAnnotation},set:function(t){this.__addAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("annotation:add",e,n,t),t}))}}},{key:"__editAnnotation",value:function(t,e,n){o("editAnnotation")}},{key:"editAnnotation",get:function(){return this.__editAnnotation},set:function(t){this.__editAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("annotation:edit",e,n,t),t}))}}},{key:"__deleteAnnotation",value:function(t,e){o("deleteAnnotation")}},{key:"deleteAnnotation",get:function(){return this.__deleteAnnotation},set:function(t){this.__deleteAnnotation=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&$("annotation:delete",e,n),t}))}}},{key:"getComments",value:function(t,e){o("getComments")}},{key:"__addComment",value:function(t,e,n){o("addComment")}},{key:"addComment",get:function(){return this.__addComment},set:function(t){this.__addComment=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("comment:add",e,n,t),t}))}}},{key:"__deleteComment",value:function(t,e){o("deleteComment")}},{key:"deleteComment",get:function(){return this.__deleteComment},set:function(t){this.__deleteComment=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&$("comment:delete",e,n),t}))}}}],e&&K(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),et=/[xy]/g;function nt(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}function rt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(et,nt)}function ot(t){return ot="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},ot(t)}function it(t,e,n){return e=ct(e),function(t,e){if(e&&("object"==ot(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,at()?Reflect.construct(e,n||[],ct(t).constructor):e.apply(t,n))}function at(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(at=function(){return!!t})()}function ct(t){return ct=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ct(t)}function ut(t,e){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ut(t,e)}var lt=function(t){function e(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(t=it(this,e,[{getAnnotations:function(t,e){return new Promise((function(n,r){var o=st(t).filter((function(t){return t.page===e&&"Annotation"===t.class}));n({documentId:t,pageNumber:e,annotations:o})}))}}])).getAnnotation=function(t,e){return Promise.resolve(st(t)[ft(t,e)])},t.addAnnotation=function(t,e,n){return new Promise((function(r,o){n.class="Annotation",n.uuid=rt(),n.page=e;var i=st(t);i.push(n),dt(t,i),r(n)}))},t.editAnnotation=function(t,e,n){return new Promise((function(r,o){var i=st(t);i[ft(t,e)]=n,dt(t,i),r(n)}))},t.deleteAnnotation=function(t,e){return new Promise((function(n,r){st(t).filter((function(t){return t.uuid===e}))[0];var o=ft(t,e);if(o>-1){var i=st(t);i.splice(o,1),dt(t,i)}n(!0)}))},t.getComments=function(t,e){return new Promise((function(n,r){n(st(t).filter((function(t){return"Comment"===t.class&&t.annotation===e})))}))},t.addComment=function(t,e,n){return new Promise((function(r,o){var i={class:"Comment",uuid:rt(),annotation:e,content:n},a=st(t);a.push(i),dt(t,a),r(i)}))},t.deleteComment=function(t,e){return new Promise((function(n,r){var o=st(t).filter((function(t){return t.uuid===e}))[0]||{};if(!o)return r("Could not find annotation");for(var i=-1,a=st(t),c=0,u=a.length;c-1&&(a.splice(i,1),dt(t,a)),n(!0)}))},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ut(t,e)}(e,t),n=e,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(tt);function st(t){return JSON.parse(localStorage.getItem("".concat(t,"/annotations")))||[]}function dt(t,e){localStorage.setItem("".concat(t,"/annotations"),JSON.stringify(e))}function ft(t,e){for(var n=-1,r=st(t),o=0,i=r.length;ot.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:"user",r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(t=ht(this,e,[{getAnnotations:function(t,e){return new Promise((function(n,r){var o=At(t).filter((function(t){return t.page===e&&"Annotation"===t.class}));n({documentId:t,pageNumber:e,annotations:o})}))}}]))._userId=n,t._globalEdit=r,t.getAnnotation=function(e,n){return Promise.resolve(St(e,t._userId)[Ct(e,t._userId,n)])},t.addAnnotation=function(e,n,r){return new Promise((function(o,i){r.class="Annotation",r.uuid=rt(),r.page=n,r.userId=t._userId;var a=St(e,t._userId);a.push(r),Et(e,t._userId,a),o(r)}))},t.editAnnotation=function(e,n,r){return new Promise((function(o,i){!t._globalEdit&&r.userId&&r.userId!==t._userId&&i("Non-matching userId");var a=St(e,r.userId);a[Ct(e,r.userId,n)]=r,Et(e,r.userId,a),o(r)}))},t.deleteAnnotation=function(e,n){return new Promise((function(r,o){var i=At(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");var a=Ct(e,i.userId,n);if(a>-1){var c=St(e,i.userId);c.splice(a,1),Et(e,i.userId,c)}r(!0)}))},t.getComments=function(e,n){return new Promise((function(r,o){r(St(e,t._userId).filter((function(t){return"Comment"===t.class&&t.annotation===n})))}))},t.addComment=function(e,n,r){return new Promise((function(o,i){var a={class:"Comment",uuid:rt(),annotation:n,content:r,userId:t._userId},c=St(e,t._userId);c.push(a),Et(e,t._userId,c),o(a)}))},t.deleteComment=function(e,n){return new Promise((function(r,o){var i=At(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");for(var a=-1,c=St(e,i.userId),u=0,l=c.length;u-1&&(c.splice(a,1),Et(e,i.userId,c)),r(!0)}))},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&wt(t,e)}(e,t),n=e,(r=[{key:"userId",get:function(){return this._userId}}])&&vt(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(tt);function At(t){for(var e=[],n=new RegExp("".concat(t,"/(.*)/annotations")),r=0;r-1&&e.push.apply(e,function(t){if(Array.isArray(t))return yt(t)}(o=JSON.parse(localStorage.getItem(localStorage.key(r))))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return yt(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yt(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());var o;return e}function St(t,e){return JSON.parse(localStorage.getItem("".concat(t,"/").concat(e,"/annotations")))||[]}function Et(t,e,n){localStorage.setItem("".concat(t,"/").concat(e,"/annotations"),JSON.stringify(n))}function Ct(t,e,n){for(var r=-1,o=St(t,e),i=0,a=o.length;it.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&n+kt.offsetHeight0&&r+kt.offsetWidth-1&&(a="cx",c="cy"),"point"!==r){if(["area","highlight","textbox","circle","fillcircle","emptycircle"].indexOf(r)>-1){var u=F([jt,Pt],o),l=F([kt.offsetLeft,kt.offsetTop],o),s={x:l[0]-u[0],y:l[1]-u[1]};"textbox"===r&&(n=[n[0].firstChild]),It(n).forEach((function(e,n){var r=parseInt(e.getAttribute(a),10),o=parseInt(e.getAttribute(c),10);0!==s.y&&(o+=s.y,e.setAttribute(c,o),t.rectangles&&n-1&&t.getBBox){var a=t.getBBox();o=(e.width-a.width)/2,i=(e.height-a.height)/2,n=a.width,r=a.height}var c=function(t){for(var e=t;(e=e.parentNode)&&e!==document&&"SVG"!==e.nodeName.toUpperCase(););var n=e.getBoundingClientRect();return{offsetLeft:n.left,offsetTop:n.top}}(t),u=c.offsetLeft,l=c.offsetTop;return{top:e.top-l+i,left:e.left-u+o,bottom:e.bottom-l-i,right:e.right-u-o,width:n,height:r}}(t),i=o.left-3,a=o.top-3;kt.setAttribute("id","pdf-annotate-edit-overlay"),kt.setAttribute("data-target-id",r),kt.style.boxSizing="content-box",kt.style.position="absolute",kt.style.top="".concat(a,"px"),kt.style.left="".concat(i,"px"),kt.style.width="".concat(o.width,"px"),kt.style.height="".concat(o.height,"px"),kt.style.border="".concat(3,"px solid ").concat(P),kt.style.borderRadius="".concat(3,"px"),kt.style.zIndex=20100,e.innerHTML="×",e.setAttribute("href","javascript://"),e.style.background="#fff",e.style.borderRadius="20px",e.style.border="1px solid #bbb",e.style.color="#bbb",e.style.fontSize="16px",e.style.padding="2px",e.style.textAlign="center",e.style.textDecoration="none",e.style.position="absolute",e.style.top="-13px",e.style.right="-13px",e.style.width="25px",e.style.height="25px",kt.appendChild(e),n.appendChild(kt),document.addEventListener("click",qt),document.addEventListener("keyup",zt),document.addEventListener("mousedown",Ft),e.addEventListener("click",Bt),e.addEventListener("mouseover",(function(){e.style.color="#35A4DC",e.style.borderColor="#999",e.style.boxShadow="0 1px 1px #ccc"})),e.addEventListener("mouseout",(function(){e.style.color="#bbb",e.style.borderColor="#bbb",e.style.boxShadow=""})),kt.addEventListener("mouseover",(function(){Rt||(e.style.display="")})),kt.addEventListener("mouseout",(function(){e.style.display="none"}))}(t)}var Qt,Ht,Dt,Wt=!1,$t=!1,Jt=[];function Vt(t){Dt=null,Jt=[],T(t.clientX,t.clientY)&&($t=!0,t.preventDefault())}function Gt(t){!function(t,e){var n;if($t&&($t=!1,Jt.length>1&&(n=T(t,e)))){var r=H(n),o=r.documentId,i=r.pageNumber;gn.getStoreAdapter().addAnnotation(o,i,{type:"drawing",width:Qt,color:Ht,lines:Jt}).then((function(t){Dt&&n.removeChild(Dt),j(n,t)}))}}(t.clientX,t.clientY)}function Kt(t){T(t.clientX,t.clientY)&&$t&&function(t,e){var n=T(t,e);if(n){var r=n.getBoundingClientRect(),o=F([t-r.left,e-r.top],n);o[0]=o[0].toFixed(2),o[1]=o[1].toFixed(2),Jt.push(o),Jt.length<=1||(Dt&&n.removeChild(Dt),Dt=j(n,{type:"drawing",color:Ht,width:Qt,lines:Jt}))}}(t.clientX,t.clientY)}function Zt(t){27===t.keyCode&&(Jt=null,Dt.parentNode.removeChild(Dt),document.removeEventListener("pointermove",Kt),document.removeEventListener("pointerup",Gt))}var te,ee,ne,re,oe,ie,ae=!1;function ce(t){var e=B(t.clientX,t.clientY);if(null!==e){var n=e.getAttribute("data-pdf-annotate-type");if("circle"===n||"fillcircle"===n||"emptycircle"===n){var r=R(e),o=H(r).documentId,i=e.getAttribute("data-pdf-annotate-id");gn.getStoreAdapter().getAnnotation(o,i).then((function(t){if(t){ne=null,re=[];var e=X([t.cx,t.cy],r),n=r.getBoundingClientRect();ie=e[0]+n.left,oe=e[1]+n.top,document.addEventListener("mousemove",le),document.addEventListener("mouseup",ue)}}))}}}function ue(t){var e;if(re.length>1&&(e=T(t.clientX,t.clientY))){var n=H(e),r=n.documentId,o=n.pageNumber;gn.getStoreAdapter().addAnnotation(r,o,{type:"arrow",width:te,color:ee,lines:re}).then((function(t){ne&&e.removeChild(ne),j(e,t)}))}document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",ue)}function le(t){!function(t,e){var n=T(t,e);if(n){var r=n.getBoundingClientRect(),o=F([t-r.left,e-r.top],n);re.length<2?re.push(o):(re[1]=o,ne&&n.removeChild(ne),ne=j(n,{type:"arrow",color:ee,width:te,lines:re}))}}(0===re.length?ie:t.clientX,0===re.length?oe:t.clientY)}function se(t){27===t.keyCode&&(re=null,ne.parentNode.removeChild(ne),document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",ue))}function de(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=1||r>=1)for(var o=Math.round(Math.max(n,r)),i=Math.min(n,r)/o,a=n0){var t=parseInt(ge.style.left,10),e=parseInt(ge.style.top,10),n=ge.value.trim(),r=T(t,e);if(!r)return;var o=r.getBoundingClientRect(),i=H(r),a=i.documentId,c=i.pageNumber,u=Object.assign({type:"point"},Y(r,{x:t-o.left,y:e-o.top}));gn.getStoreAdapter().addAnnotation(a,c,u).then((function(t){gn.getStoreAdapter().addComment(a,t.uuid,n),j(r,t)}))}Ee()}function Ee(){ge.removeEventListener("blur",xe),ge.removeEventListener("keyup",Ae),document.body.removeChild(ge),ge=null}function Ce(t){return function(t){if(Array.isArray(t))return Le(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Le(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Le(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Le(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&t[0].width>0&&t[0].height>0)return t}catch(t){}return null}()))Te(Ie,Ce(e).map((function(t){return{top:t.top,left:t.left,width:t.width,height:t.height}})));else if("area"===Ie&&_e){var n=_e.parentNode.querySelector(Lt.annotationSvgQuery()).getBoundingClientRect();Te(Ie,[{top:parseInt(_e.style.top,10)+n.top,left:parseInt(_e.style.left,10)+n.left,width:parseInt(_e.style.width,10),height:parseInt(_e.style.height,10)}]),_e.parentNode.removeChild(_e),_e=null,document.removeEventListener("mousemove",Pe),Q()}}function Re(t){27===t.keyCode&&(window.getSelection().removeAllRanges(),_e&&_e.parentNode&&(_e.parentNode.removeChild(_e),_e=null,document.removeEventListener("mousemove",Pe)))}function Te(t,e,n){var r,o=T(e[0].left,e[0].top);if(o){var i=o.getBoundingClientRect();if(n||("highlight"===t?n="FFFF00":"strikeout"===t&&(n="FF0000")),r={type:t,color:n,rectangles:Ce(e).map((function(e){var n=0;return"strikeout"===t&&(n=e.height/2),function(t,e,n){var r=[t.x,t.y],o=[t.x+t.width,t.y+t.height];return r=F(r,e,n),o=F(o,e,n),{x:Math.min(r[0],o[0]),y:Math.min(r[1],o[1]),width:Math.abs(o[0]-r[0]),height:Math.abs(o[1]-r[1])}}({y:e.top+n-i.top,x:e.left-i.left,width:e.width,height:e.height},o)})).filter((function(t){return t.width>0&&t.height>0&&t.x>-1&&t.y>-1}))},0!==r.rectangles.length){if("area"===t){var a=r.rectangles[0];delete r.rectangles,r.x=a.x,r.y=a.y,r.width=a.width,r.height=a.height}var c=H(o),u=c.documentId,l=c.pageNumber;gn.getStoreAdapter().addAnnotation(u,l,r).then((function(t){j(o,t)}))}}}var Be,qe=!1,ze=10,Fe="0000FF";function Xe(t){var e=T(t.clientX,t.clientY);if(e){var n=e.getBoundingClientRect();!function(t,e,n,r,o){var i=F([n.x,n.y],t),a={type:e,color:o,cx:i[0],cy:i[1],r},c=H(t),u=c.documentId,l=c.pageNumber;gn.getStoreAdapter().addAnnotation(u,l,a).then((function(e){j(t,e)}))}(e,Be,{x:t.clientX-n.left,y:t.clientY-n.top},ze,Fe)}}var Ye,Ue=!1,Qe=localStorage.getItem("text/size")||12,He=localStorage.getItem("text/color")||"#000000";function De(t){!Ye&&T(t.clientX,t.clientY)&&t.srcElement.classList.contains("annotationLayer")&&((Ye=document.createElement("textarea")).setAttribute("id","pdf-annotate-text-input"),Ye.setAttribute("placeholder","Enter text... SHIFT + ENTER for new line"),Ye.style.border="3px solid ".concat(P),Ye.style.borderRadius="3px",Ye.style.position="fixed",Ye.style.top="".concat(t.clientY,"px"),Ye.style.left="".concat(t.clientX,"px"),Ye.style.fontSize="".concat(Qe,"px"),Ye.style.zIndex="41",Ye.addEventListener("blur",We),Ye.addEventListener("keyup",$e),document.body.appendChild(Ye),Ye.focus())}function We(){Je()}function $e(t){27===t.keyCode?Ve():13!==t.keyCode||t.shiftKey||Je()}function Je(){var t=Ye.value?Ye.value.replace(/ +$/,""):"";if(t.length>0){var e=parseInt(Ye.style.left,10),n=parseInt(Ye.style.top,10),r=T(e,n);if(!r)return;var o=Qe,i=H(r),a=i.documentId,c=i.pageNumber,u=i.viewport,l=1/u.scale,s=r.getBoundingClientRect(),d=F([e-s.left,n-s.top+o],r,u),f={type:"textbox",size:Qe*l,color:He,content:t,x:d[0],y:d[1],rotation:-u.rotation};gn.getStoreAdapter().addAnnotation(a,c,f).then((function(t){j(r,t)}))}Ve()}function Ve(){Ye&&(Ye.removeEventListener("blur",We),Ye.removeEventListener("keyup",$e),document.body.removeChild(Ye),Ye=null)}function Ge(t,e){var n=document.createElement("div"),r=document.createTextNode(t);return n.appendChild(r),n.setAttribute("id","pdf-annotate-screenreader-".concat(e)),n.style.position="absolute",n.style.left="-10000px",n.style.top="auto",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n}function Ke(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n"===l[l.length-1])for(;l.length&&(s.unshift(l.pop()),"<"!==s[0]););if(u.innerHTML=l.join(""),c+Y(a,{width:u.getBoundingClientRect().width}).width<=e)break;s.unshift(l.pop())}return i.innerHTML=l.join("")+t.outerHTML+s.join(""),u.parentNode.removeChild(u),!0}function tn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n div"))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return tn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tn(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();n=z(i,{y:n}).y+a.top,e=z(i,{x:e}).x+a.left;for(var u=0,l=c.length;u1&&void 0!==arguments[1]?arguments[1]:0;switch(t.type){case"highlight":case"strikeout":var n=t.rectangles,r=n[0],o=n[n.length-1];Ze(Ge("Begin ".concat(t.type," annotation ").concat(e),t.uuid),r.x,r.y,t.page,!0),Ze(Ge("End ".concat(t.type," annotation ").concat(e),"".concat(t.uuid,"-end")),o.x+o.width,o.y,t.page,!1);break;case"textbox":case"point":var i="textbox"===t.type?" (content: ".concat(t.content,")"):"";en(Ge("".concat(t.type," annotation ").concat(e).concat(i),t.uuid),t.x,t.y,t.page);break;case"drawing":case"area":var a=void 0!==t.x?t.x:t.lines[0][0],c=void 0!==t.y?t.y:t.lines[0][1];en(Ge("Unlabeled drawing",t.uuid),a,c,t.page);break;case"circle":case"fillcircle":case"emptycircle":var u=void 0!==t.cx?t.cx:t.lines[0][0],l=void 0!==t.cy?t.cy:t.lines[0][1];en(Ge("Unlabeled drawing",t.uuid),u,l,t.page)}on.includes(t.type)&&rn(t.documentId,t.uuid)}(t,e+1)}))}))}function sn(t,e){return t.yt.length)&&(e=t.length);for(var n=0,r=Array(e);n\n \n \n';function vn(t){if(Math.floor(t)===t)return[t,1];var e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];for(var n=t>1?e:t,r=0,o=1,i=1,a=1;;){var c=r+i,u=o+a;if(u>8)break;n<=c/u?(i=c,a=u):(r=c,o=u)}return n-r/o0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";Qt=Math.round(100*parseFloat(t))/100,Ht=e},disablePoint:function(){be&&(be=!1,document.removeEventListener("mouseup",we))},enablePoint:function(){be||(be=!0,document.addEventListener("mouseup",we))},disableRect:function(){Oe&&(Oe=!1,document.removeEventListener("mouseup",Me),document.removeEventListener("mousedown",je),document.removeEventListener("keyup",Re))},enableRect:function(t){Ie=t,Oe||(Oe=!0,document.addEventListener("mouseup",Me),document.addEventListener("mousedown",je),document.addEventListener("keyup",Re))},disableCircle:function(){qe&&(qe=!1,document.removeEventListener("mouseup",Xe))},enableCircle:function(t){Be=t,qe||(qe=!0,document.addEventListener("mouseup",Xe))},setCircle:function(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";ze=parseInt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,10),Fe=t},addCircle:function(t,e){var n=Be;Be=t,Xe(e),Be=n},disableArrow:function(){ae&&(ae=!1,document.removeEventListener("mousedown",ce),document.removeEventListener("keyup",se),Q())},enableArrow:function(){ae||(ae=!0,document.addEventListener("mousedown",ce),document.addEventListener("keyup",se),U())},setArrow:function(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";te=parseInt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,10),ee=t},disableEraser:function(){document.removeEventListener("pointermove",me),document.removeEventListener("pointerdown",ye),document.removeEventListener("pointerup",ve)},enableEraser:function(){document.addEventListener("pointermove",me),document.addEventListener("pointerdown",ye),document.addEventListener("pointerup",ve)},disableText:function(){Ue&&(Ue=!1,document.removeEventListener("mouseup",De))},enableText:function(){Ue||(Ue=!0,document.addEventListener("mouseup",De))},setText:function(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";Qe=parseInt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,10),He=t},createPage:function(t){var e=document.createElement("div");e.innerHTML=yn;var n=e.children[0],r=n.querySelector("canvas");return n.setAttribute("id","pageContainer".concat(t)),n.setAttribute("data-page-number",t),r.mozOpaque=!0,r.setAttribute("id","page".concat(t)),n},renderPage:function(t,e){var n=e.documentId,r=e.pdfDocument,o=e.scale,i=e.rotate,a=new pdfjsViewer.EventBus;return Promise.all([r.getPage(t),gn.getAnnotations(n,t)]).then((function(e){var n,r,c=(r=2,function(t){if(Array.isArray(t))return t}(n=e)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,c=[],u=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(n,r)||function(t,e){if(t){if("string"==typeof t)return pn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pn(t,e):void 0}}(n,r)||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.")}()),u=c[0],l=c[1],s=document.getElementById("pageContainer".concat(t)),d=s.querySelector(Lt.annotationClassQuery()),f=s.querySelector(".canvasWrapper canvas").getContext("2d",{alpha:!1}),p=(i+u.rotate)%360,y=u.getViewport({scale:o,rotation:p}),v=function(t,e,n){var r,o,i=document.getElementById("pageContainer".concat(t)),a=i.querySelector(".canvasWrapper canvas"),c=i.querySelector(Lt.annotationClassQuery()),u=i.querySelector(".canvasWrapper"),l=i.querySelector(Lt.textClassQuery()),s=(r=n,{sx:o=(window.devicePixelRatio||1)/(r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1),sy:o,scaled:1!==o}),d=s.scaled?[s.sx,0,0,s.sy,0,0]:null,f=vn(s.sx),p=vn(s.sy);return i.style.visibility="",a.width=mn(e.width*s.sx,f[0]),a.height=mn(e.height*s.sy,p[0]),a.style.width=mn(e.width,f[1])+"px",a.style.height=mn(e.height,f[1])+"px",c.setAttribute("width",e.width),c.setAttribute("height",e.height),c.style.width="".concat(e.width,"px"),c.style.height="".concat(e.height,"px"),i.style.width="".concat(e.width,"px"),i.style.height="".concat(e.height,"px"),u.style.width="".concat(e.width,"px"),u.style.height="".concat(e.height,"px"),l.style.width="".concat(e.width,"px"),l.style.height="".concat(e.height,"px"),d}(t,y,f);return Promise.all([u.render({canvasContext:f,viewport:y,transform:v}).promise,gn.render(d,y,l)]).then((function(){return u.getTextContent({normalizeWhitespace:!0}).then((function(e){return new Promise((function(n,r){var o=s.querySelector(Lt.textClassQuery()),i=(new pdfjsViewer.DefaultTextLayerFactory).createTextLayerBuilder(o,t-1,y,!1,a);i.setTextContent(e),i.render(),setTimeout((function(){try{ln(l.annotations),n()}catch(t){r(t)}}))}))}))})).then((function(){return s.setAttribute("data-loaded","true"),[u,l]}))}))}},gn={findAnnotationAtPoint:B,findSVGContainer:R,convertToScreenPoint:X,StoreAdapter:tt,LocalStoreAdapter:lt,LocalUserStoreAdapter:xt,__storeAdapter:new tt,getStoreAdapter:function(){return this.__storeAdapter},setStoreAdapter:function(t){this.__storeAdapter=t},UI:hn,render:function(t,e,n){return new Promise((function(r,o){return t.setAttribute("data-pdf-annotate-container",!0),t.setAttribute("data-pdf-annotate-viewport",JSON.stringify(e)),t.removeAttribute("data-pdf-annotate-document"),t.removeAttribute("data-pdf-annotate-page"),n?(t.setAttribute("data-pdf-annotate-document",n.documentId),t.setAttribute("data-pdf-annotate-page",n.pageNumber),Array.isArray(n.annotations)&&0!==n.annotations.length?(n.annotations.forEach((function(n){var r=t.querySelector('[data-pdf-annotate-id="'+n.uuid+'"]');r?function(t,e,n){n||(n=JSON.parse(t.getAttribute("data-pdf-annotate-viewport"))),e&&(e=O(e,n))}(t,r,e):j(t,n,e)})),void r(t)):r(t)):(t.innerHTML="",r(t))}))},getAnnotations:function(t,e){var n;return(n=this.getStoreAdapter()).getAnnotations.apply(n,arguments)},config:Lt,uuid:rt},bn=gn;return r})())); //# sourceMappingURL=pdf-annotate.js.map \ No newline at end of file diff --git a/dist/pdf-annotate.js.map b/dist/pdf-annotate.js.map index 55014caf..11fbd9a9 100644 --- a/dist/pdf-annotate.js.map +++ b/dist/pdf-annotate.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://PDFAnnotate/webpack/universalModuleDefinition","webpack://PDFAnnotate/webpack/bootstrap","webpack://PDFAnnotate/./node_modules/events/events.js","webpack://PDFAnnotate/./src/utils/abstractFunction.js","webpack://PDFAnnotate/./src/utils/setAttributes.js","webpack://PDFAnnotate/./src/utils/normalizeColor.js","webpack://PDFAnnotate/./src/render/renderRect.js","webpack://PDFAnnotate/./src/render/renderText.js","webpack://PDFAnnotate/./src/render/renderCircle.js","webpack://PDFAnnotate/./src/utils/mathUtils.js","webpack://PDFAnnotate/./src/render/renderArrow.js","webpack://PDFAnnotate/./src/render/appendChild.js","webpack://PDFAnnotate/./src/render/renderLine.js","webpack://PDFAnnotate/./src/render/renderPoint.js","webpack://PDFAnnotate/./src/render/renderPath.js","webpack://PDFAnnotate/./src/UI/utils.js","webpack://PDFAnnotate/./src/UI/event.js","webpack://PDFAnnotate/./src/adapter/StoreAdapter.js","webpack://PDFAnnotate/./src/utils/uuid.js","webpack://PDFAnnotate/./src/adapter/LocalStoreAdapter.js","webpack://PDFAnnotate/./src/adapter/LocalUserStoreAdapter.js","webpack://PDFAnnotate/./src/config.js","webpack://PDFAnnotate/./src/UI/edit.js","webpack://PDFAnnotate/./src/UI/pen.js","webpack://PDFAnnotate/./src/UI/arrow.js","webpack://PDFAnnotate/./src/UI/eraser.js","webpack://PDFAnnotate/./src/UI/point.js","webpack://PDFAnnotate/./src/UI/rect.js","webpack://PDFAnnotate/./src/UI/circle.js","webpack://PDFAnnotate/./src/UI/text.js","webpack://PDFAnnotate/./src/a11y/createScreenReaderOnly.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinElement.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinChildren.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderComment.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderComments.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderHint.js","webpack://PDFAnnotate/./src/a11y/initEventHandlers.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderHints.js","webpack://PDFAnnotate/./src/UI/page.js","webpack://PDFAnnotate/./src/UI/index.js","webpack://PDFAnnotate/./src/PDFJSAnnotate.js","webpack://PDFAnnotate/./src/render/index.js","webpack://PDFAnnotate/./index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","EventEmitter","init","this","once","emitter","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","events","existing","warning","newListener","emit","unshift","push","length","warned","w","Error","String","count","console","warn","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","_listeners","unwrap","evlistener","arr","ret","Array","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","error","er","message","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","keys","rawListeners","eventNames","abstractFunction","UPPER_REGEX","BLACKLIST","setAttributes","node","attributes","forEach","setAttribute","indexOf","replace","match","toLowerCase","keyCase","REGEX_HASHLESS_HEX","normalizeColor","color","test","createRect","rect","document","createElementNS","x","y","width","height","renderText","a","text","fill","fontSize","size","transform","rotation","style","textElement","textContent","_step","lines","split","getAttribute","_iterator","_createForOfIteratorHelper","done","line","tspan","toString","innerHTML","appendChild","e","f","insertLineBreaks","content","g","renderCircle","circle","cx","cy","createCircle","stroke","translate","rotate","angle","Math","PI","cosValue","cos","sinValue","sin","scale","makePoint","z","makeVector","xcoord","ycoord","zcoord","makeVectorFromPoints","pt1","pt2","addVector","pt","v","multiplyVector","scalar","magnitude","sqrt","pow","negateVector","unitVector","mag","renderArrow","u","arrow","p1","p2","pt0","unitX","unitZ","unitY","thickness","A","B","C","D","G","F","E","points","isFirefox","navigator","userAgent","getTranslation","viewport","trans","nodeName","parseInt","path","querySelector","svg","parentNode","assign","annotation","child","group","JSON","parse","fillOpacity","rectangles","renderRect","strokeWidth","x1","y1","x2","y2","outerSVG","innerSVG","SIZE","viewBox","renderPoint","join","renderPath","uuid","filter","transformChild","userSelectStyleSheet","createElement","findSVGContainer","toUpperCase","findSVGAtPoint","elements","querySelectorAll","el","pointIntersectsRect","getBoundingClientRect","findAnnotationAtPoint","candidate","elementFromPoint","top","bottom","left","right","getOffsetAnnotationRect","extraOffsetWidth","extraOffsetHeight","tagName","getBBox","bbox","_getOffset","offsetLeft","offsetTop","getOffset","scaleUp","result","getMetadata","convertToSvgPoint","xform","offset","convertToScreenPoint","scaleDown","disableUserSelect","head","enableUserSelect","removeChild","documentId","pageNumber","clickNode","fireEvent","clientX","clientY","StoreAdapter","_this","definition","_classCallCheck","__getAnnotations","fn","then","annotations","annotationId","__addAnnotation","__editAnnotation","__deleteAnnotation","success","__addComment","comment","commentId","__deleteComment","REGEXP","replacement","random","LocalStoreAdapter","_StoreAdapter","_inherits","_super","_createSuper","getAnnotations","page","getAnnotation","findAnnotation","addAnnotation","updateAnnotations","editAnnotation","deleteAnnotation","splice","getComments","addComment","class","deleteComment","localStorage","getItem","setItem","stringify","LocalUserStoreAdapter","userId","globalEdit","getAllAnnotations","_userId","_globalEdit","all_annotations","re","RegExp","search","_toConsumableArray","annotationLayerName","textLayerName","annotationSvgQuery","annotationClassQuery","textClassQuery","overlay","dragOffsetX","dragOffsetY","dragStartX","dragStartY","_enabled","isDragging","destroyEditOverlay","handleDocumentClick","handleDocumentKeyup","handleDocumentMousedown","handleDocumentMousemove","handleDocumentMouseup","config","PDFJSAnnotate","getStoreAdapter","getElementById","keyTest","keyCode","preventDefault","background","cursor","display","maxY","maxX","offsetHeight","offsetWidth","attribX","attribY","modelStart","modelEnd","modelDelta","firstChild","modelX","modelY","setTimeout","handleAnnotationClick","anchor","id","styleLeft","styleTop","boxSizing","border","borderRadius","zIndex","padding","textAlign","textDecoration","borderColor","boxShadow","createEditOverlay","_penSize","_penColor","_candraw","handleDocumentPointerdown","handleDocumentPointerup","_getMetadata","saveToStorage","handleDocumentPointermove","point","toFixed","savePoint","originY","originX","_getMetadata2","_canerase","previousPoint","handleDocumentDown","handleDocumentUp","erase","handleDocumentMouseMove","check","diffX","abs","diffY","maxSteps","round","max","subStepSize","min","smallerTest","startPoint","_i","_check","parentElement","input","handleInputBlur","handleInputKeyup","body","focus","closeInput","trim","_type","rects","getSelection","getRangeAt","getClientRects","getSelectionRects","saveRect","map","removeAllRanges","boundingRect","convertToSvgRect","_circleRadius","_circleColor","radius","svg_pt","saveCircle","_textSize","_textColor","srcElement","classList","contains","saveText","shiftKey","createScreenReaderOnly","createTextNode","overflow","insertElementWithinElement","insertBefore","textLayerElementFromPoint","temp","cloneNode","tail","outerHTML","insertElementWithinChildren","nodes","textLayer","insertScreenReaderComment","item","renderScreenReaderComments","comments","isArray","COMMENT_TYPES","reorderAnnotationsByType","removeAnnotation","renderScreenReaderHints","removeElementById","insertComment","removeComment","elementId","SORT_TYPES","sortBy","sort","num","first","last","includes","insertScreenReaderHint","sortByPoint","b","sortByRectPoint","lineA","lineB","PAGE_TEMPLATE","approximateFraction","floor","xinv","x_","q","roundToDivide","div","disableEdit","enableEdit","disablePen","enablePen","setPen","penSize","penColor","parseFloat","disablePoint","enablePoint","disableRect","enableRect","disableCircle","enableCircle","setCircle","circleRadius","circleColor","addCircle","oldType","disableArrow","enableArrow","setArrow","disableEraser","enableEraser","disableText","enableText","setText","textSize","textColor","createPage","children","canvas","mozOpaque","renderPage","renderOptions","pdfDocument","eventBus","pdfjsViewer","EventBus","all","getPage","_ref","_ref2","_slicedToArray","pdfPage","canvasContext","getContext","alpha","totalRotation","getViewport","wrapper","outputScale","ctx","devicePixelRatio","backingStoreRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","pixelRatio","sx","sy","scaled","sfx","sfy","visibility","scalePage","render","promise","getTextContent","normalizeWhitespace","textLayerBuilder","DefaultTextLayerFactory","createTextLayerBuilder","setTextContent","__storeAdapter","setStoreAdapter","adapter","UI","data","removeAttribute","_this$getStoreAdapter"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,IARxB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EA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"pdf-annotate.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PDFAnnotate\"] = factory();\n\telse\n\t\troot[\"PDFAnnotate\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/**\r\n * Throw an Error for an abstract function that hasn't been implemented.\r\n *\r\n * @param {String} name The name of the abstract function\r\n */\r\nexport default function abstractFunction(name) {\r\n throw new Error(name + ' is not implemented');\r\n}\r\n","const UPPER_REGEX = /[A-Z]/g;\r\n\r\n// Don't convert these attributes from camelCase to hyphenated-attributes\r\nconst BLACKLIST = [\r\n 'viewBox'\r\n];\r\n\r\nlet keyCase = (key) => {\r\n if (BLACKLIST.indexOf(key) === -1) {\r\n key = key.replace(UPPER_REGEX, match => '-' + match.toLowerCase());\r\n }\r\n return key;\r\n};\r\n\r\n/**\r\n * Set attributes for a node from a map\r\n *\r\n * @param {Node} node The node to set attributes on\r\n * @param {Object} attributes The map of key/value pairs to use for attributes\r\n */\r\nexport default function setAttributes(node, attributes) {\r\n Object.keys(attributes).forEach((key) => {\r\n node.setAttribute(keyCase(key), attributes[key]);\r\n });\r\n}\r\n","const REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i;\r\n\r\n/**\r\n * Normalize a color value\r\n *\r\n * @param {String} color The color to normalize\r\n * @return {String}\r\n */\r\nexport default function normalizeColor(color) {\r\n if (REGEX_HASHLESS_HEX.test(color)) {\r\n color = `#${color}`;\r\n }\r\n return color;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGRectElements from an annotation definition.\r\n * This is used for anntations of type `area` and `highlight`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered\r\n */\r\nexport default function renderRect(a) {\r\n if (a.type === 'highlight') {\r\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n setAttributes(group, {\r\n fill: normalizeColor(a.color || '#ff0'),\r\n fillOpacity: 0.2\r\n });\r\n\r\n a.rectangles.forEach((r) => {\r\n group.appendChild(createRect(r));\r\n });\r\n\r\n return group;\r\n }\r\n else {\r\n let rect = createRect(a);\r\n setAttributes(rect, {\r\n stroke: normalizeColor(a.color || '#f00'),\r\n fill: 'none'\r\n });\r\n\r\n return rect;\r\n }\r\n}\r\n\r\nfunction createRect(r) {\r\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\r\n\r\n setAttributes(rect, {\r\n x: r.x,\r\n y: r.y,\r\n width: r.width,\r\n height: r.height\r\n });\r\n\r\n return rect;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Wrap each line of given text in a `` element and append these\r\n * lines to the given SVGTextElement\r\n *\r\n * @param {SVGTextElement} textElement A text element to hold the split text\r\n * @param {String} textContent String to render with line breaks\r\n */\r\nfunction insertLineBreaks(textElement, textContent) {\r\n const lines = (textContent || '').split('\\n');\r\n // can't use dy attribute here since we want empty lines to take up space as well,\r\n // so we will update y manually based on font size\r\n const x = textElement.getAttribute('x');\r\n let y = Number(textElement.getAttribute('y'));\r\n const size = Number(textElement.getAttribute('font-size'));\r\n for (const line of lines) {\r\n const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');\r\n tspan.setAttribute('y', y.toString());\r\n tspan.setAttribute('x', x);\r\n tspan.innerHTML = line;\r\n textElement.appendChild(tspan);\r\n\r\n y += size;\r\n }\r\n}\r\n\r\n/**\r\n * Create SVGTextElement from an annotation definition.\r\n * This is used for anntations of type `textbox`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGTextElement} A text to be rendered\r\n */\r\nexport default function renderText(a) {\r\n // Text should be rendered at 0 degrees relative to\r\n // document rotation\r\n let text = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r\n setAttributes(text, {\r\n x: a.x,\r\n y: a.y,\r\n fill: normalizeColor(a.color || '#000'),\r\n fontSize: a.size,\r\n transform: `rotate(${a.rotation})`,\r\n style: 'white-space: pre'\r\n });\r\n\r\n insertLineBreaks(text, a.content);\r\n\r\n let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n g.appendChild(text);\r\n\r\n return g;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create an SVGCircleElement from an annotation definition.\r\n * This is used for annotations of type `circle`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement|SVGCircleElement} A circle to be rendered\r\n */\r\nexport default function renderCircle(a) {\r\n let circle = createCircle(a);\r\n let color = normalizeColor(a.color || '#f00');\r\n\r\n if (a.type === 'circle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: 'none',\r\n 'stroke-width': 5\r\n });\r\n }\r\n if (a.type === 'emptycircle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: 'none',\r\n 'stroke-width': 2\r\n });\r\n }\r\n\r\n if (a.type === 'fillcircle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: color,\r\n 'stroke-width': 5\r\n });\r\n }\r\n\r\n return circle;\r\n}\r\n\r\nfunction createCircle(a) {\r\n let circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\r\n setAttributes(circle, {\r\n cx: a.cx,\r\n cy: a.cy,\r\n r: a.r\r\n });\r\n\r\n return circle;\r\n}\r\n","// Transform point by matrix\r\n//\r\nexport function applyTransform(p, m) {\r\n return [\r\n p[0] * m[0] + p[1] * m[2] + m[4],\r\n p[0] * m[1] + p[1] * m[3] + m[5]\r\n ];\r\n};\r\n\r\n// Transform point by matrix inverse\r\n//\r\nexport function applyInverseTransform(p, m) {\r\n let d = m[0] * m[3] - m[1] * m[2];\r\n return [\r\n (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d,\r\n (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d\r\n ];\r\n};\r\n\r\n// Concatenates two transformation matrices together and returns the result.\r\nexport function transform(m1, m2) {\r\n return [\r\n m1[0] * m2[0] + m1[2] * m2[1],\r\n m1[1] * m2[0] + m1[3] * m2[1],\r\n m1[0] * m2[2] + m1[2] * m2[3],\r\n m1[1] * m2[2] + m1[3] * m2[3],\r\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\r\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5]\r\n ];\r\n};\r\n\r\nexport function translate(m, x, y) {\r\n return [\r\n m[0],\r\n m[1],\r\n m[2],\r\n m[3],\r\n m[0] * x + m[2] * y + m[4],\r\n m[1] * x + m[3] * y + m[5]\r\n ];\r\n};\r\n\r\nexport function rotate(m, angle) {\r\n angle = angle * Math.PI / 180;\r\n\r\n let cosValue = Math.cos(angle);\r\n let sinValue = Math.sin(angle);\r\n\r\n return [\r\n m[0] * cosValue + m[2] * sinValue,\r\n m[1] * cosValue + m[3] * sinValue,\r\n m[0] * (-sinValue) + m[2] * cosValue,\r\n m[1] * (-sinValue) + m[3] * cosValue,\r\n m[4],\r\n m[5]\r\n ];\r\n};\r\n\r\nexport function scale(m, x, y) {\r\n return [\r\n m[0] * x,\r\n m[1] * x,\r\n m[2] * y,\r\n m[3] * y,\r\n m[4],\r\n m[5]\r\n ];\r\n};\r\n\r\nexport function makePoint(x, y, z) {\r\n return { x: x, y: y, z: z };\r\n};\r\n\r\nexport function makeVector(xcoord, ycoord, zcoord) {\r\n return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord };\r\n};\r\n\r\nexport function makeVectorFromPoints(pt1, pt2) {\r\n let xcoord = pt2.x - pt1.x;\r\n let ycoord = pt2.y - pt1.y;\r\n let zcoord = pt2.z - pt1.z;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n\r\nexport function addVector(pt, v) {\r\n return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord);\r\n};\r\n\r\nexport function multiplyVector(v, scalar) {\r\n return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar);\r\n};\r\n\r\nexport function magnitude(v) {\r\n return Math.sqrt(\r\n Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)\r\n );\r\n};\r\n\r\nexport function negateVector(v) {\r\n return multiplyVector(v, -1);\r\n};\r\n\r\nexport function unitVector(v) {\r\n let mag = magnitude(v);\r\n let xcoord = v.xcoord / mag;\r\n let ycoord = v.ycoord / mag;\r\n let zcoord = v.zcoord / mag;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n\r\nexport function crossProduct(u, v) {\r\n //\r\n // u X v = < u2*v3 - u3*v2,\r\n // u3*v1 - u1*v3,\r\n // u1*v2 - u2*v1 >\r\n let xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord;\r\n let ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord;\r\n let zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\nimport {\r\n makePoint, makeVector, makeVectorFromPoints,\r\n magnitude, unitVector, crossProduct,\r\n addVector, multiplyVector, negateVector\r\n} from '../utils/mathUtils';\r\n\r\n/**\r\n * Create SVGPathElement from an annotation definition.\r\n * This is used for anntations of type `drawing`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGPathElement} The path to be rendered\r\n */\r\nexport default function renderArrow(a) {\r\n let arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');\r\n\r\n if (a.lines.length === 2) {\r\n let p1 = a.lines[0];\r\n let p2 = a.lines[a.lines.length - 1];\r\n\r\n let arrowLength = 40;\r\n let pt0 = makePoint(p1[0], p1[1], 0);\r\n let pt1 = makePoint(p2[0], p2[1], 0);\r\n let x = makeVectorFromPoints(pt0, pt1);\r\n let unitX = unitVector(x);\r\n pt1 = addVector(pt0, multiplyVector(unitX, arrowLength));\r\n x = makeVectorFromPoints(pt0, pt1);\r\n let unitZ = makeVector(0, 0, 1);\r\n let unitY = unitVector(crossProduct(unitX, unitZ));\r\n let thickness = a.width || 10;\r\n\r\n let A = addVector(pt0, multiplyVector(unitY, thickness * 0.5));\r\n let B = addVector(A, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\r\n let C = addVector(B, multiplyVector(unitY, thickness));\r\n let D = pt1;\r\n let G = addVector(pt0, multiplyVector(negateVector(unitY), thickness * 0.5));\r\n let F = addVector(G, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\r\n let E = addVector(F, multiplyVector(negateVector(unitY), thickness));\r\n\r\n let points = '' +\r\n A.x + ',' + A.y + ' ' +\r\n B.x + ',' + B.y + ' ' +\r\n C.x + ',' + C.y + ' ' +\r\n D.x + ',' + D.y + ' ' +\r\n E.x + ',' + E.y + ' ' +\r\n F.x + ',' + F.y + ' ' +\r\n G.x + ',' + G.y;\r\n\r\n setAttributes(arrow, {\r\n points: points,\r\n stroke: normalizeColor(a.color || '#000'),\r\n fill: normalizeColor(a.color || '#000')\r\n });\r\n }\r\n\r\n return arrow;\r\n}\r\n","import renderLine from './renderLine';\r\nimport renderPath from './renderPath';\r\nimport renderPoint from './renderPoint';\r\nimport renderRect from './renderRect';\r\nimport renderText from './renderText';\r\nimport renderCircle from './renderCircle';\r\nimport renderArrow from './renderArrow';\r\n\r\nconst isFirefox = /firefox/i.test(navigator.userAgent);\r\n\r\n/**\r\n * Get the x/y translation to be used for transforming the annotations\r\n * based on the rotation of the viewport.\r\n *\r\n * @param {Object} viewport The viewport data from the page\r\n * @return {Object}\r\n */\r\nexport function getTranslation(viewport) {\r\n let x;\r\n let y;\r\n\r\n // Modulus 360 on the rotation so that we only\r\n // have to worry about four possible values.\r\n switch (viewport.rotation % 360) {\r\n case 0:\r\n x = y = 0;\r\n break;\r\n case 90:\r\n x = 0;\r\n y = (viewport.width / viewport.scale) * -1;\r\n break;\r\n case 180:\r\n x = (viewport.width / viewport.scale) * -1;\r\n y = (viewport.height / viewport.scale) * -1;\r\n break;\r\n case 270:\r\n x = (viewport.height / viewport.scale) * -1;\r\n y = 0;\r\n break;\r\n }\r\n\r\n return { x, y };\r\n}\r\n\r\n/**\r\n * Transform the rotation and scale of a node using SVG's native transform attribute.\r\n *\r\n * @param {Node} node The node to be transformed\r\n * @param {Object} viewport The page's viewport data\r\n * @return {Node}\r\n */\r\nfunction transform(node, viewport) {\r\n let trans = getTranslation(viewport);\r\n\r\n // Let SVG natively transform the element\r\n node.setAttribute('transform', `scale(${viewport.scale}) rotate(${viewport.rotation}) translate(${trans.x}, ${trans.y})`);\r\n\r\n // Manually adjust x/y for nested SVG nodes\r\n if (!isFirefox && node.nodeName.toLowerCase() === 'svg') {\r\n node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale);\r\n node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale);\r\n\r\n let x = parseInt(node.getAttribute('x', 10));\r\n let y = parseInt(node.getAttribute('y', 10));\r\n let width = parseInt(node.getAttribute('width'), 10);\r\n let height = parseInt(node.getAttribute('height'), 10);\r\n let path = node.querySelector('path');\r\n let svg = path.parentNode;\r\n\r\n // Scale width/height\r\n [node, svg, path, node.querySelector('rect')].forEach((n) => {\r\n n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale);\r\n n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale);\r\n });\r\n\r\n // Transform path but keep scale at 100% since it will be handled natively\r\n transform(path, Object.assign({}, viewport, { scale: 1 }));\r\n\r\n switch (viewport.rotation % 360) {\r\n case 90:\r\n node.setAttribute('x', viewport.width - y - width);\r\n node.setAttribute('y', x);\r\n svg.setAttribute('x', 1);\r\n svg.setAttribute('y', 0);\r\n break;\r\n case 180:\r\n node.setAttribute('x', viewport.width - x - width);\r\n node.setAttribute('y', viewport.height - y - height);\r\n svg.setAttribute('y', 2);\r\n break;\r\n case 270:\r\n node.setAttribute('x', y);\r\n node.setAttribute('y', viewport.height - x - height);\r\n svg.setAttribute('x', -1);\r\n svg.setAttribute('y', 0);\r\n break;\r\n }\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Append an annotation as a child of an SVG.\r\n *\r\n * @param {SVGElement} svg The SVG element to append the annotation to\r\n * @param {Object} annotation The annotation definition to render and append\r\n * @param {Object} viewport The page's viewport data\r\n * @return {SVGElement} A node that was created and appended by this function\r\n */\r\nexport function appendChild(svg, annotation, viewport) {\r\n if (!viewport) {\r\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\r\n }\r\n\r\n let child;\r\n switch (annotation.type) {\r\n case 'area':\r\n case 'highlight':\r\n child = renderRect(annotation);\r\n break;\r\n case 'circle':\r\n case 'fillcircle':\r\n case 'emptycircle':\r\n child = renderCircle(annotation);\r\n break;\r\n case 'strikeout':\r\n child = renderLine(annotation);\r\n break;\r\n case 'point':\r\n child = renderPoint(annotation);\r\n break;\r\n case 'textbox':\r\n child = renderText(annotation);\r\n break;\r\n case 'drawing':\r\n child = renderPath(annotation);\r\n break;\r\n case 'arrow':\r\n child = renderArrow(annotation);\r\n break;\r\n }\r\n\r\n // If no type was provided for an annotation it will result in node being null.\r\n // Skip appending/transforming if node doesn't exist.\r\n if (child) {\r\n // Set attributes\r\n child.setAttribute('data-pdf-annotate-id', annotation.uuid);\r\n child.setAttribute('aria-hidden', true);\r\n\r\n // Dynamically set any other attributes associated with annotation that is not related to drawing it\r\n Object.keys(annotation).filter((key) => {\r\n return ['color', 'x', 'y', 'cx', 'cy', 'color', 'documentId', 'lines', 'page',\r\n 'width', 'class', 'content', 'size', 'rotation', 'r'].indexOf(key) === -1;\r\n }).forEach((key) => {\r\n child.setAttribute(`data-pdf-annotate-${key}`, annotation[key]);\r\n });\r\n\r\n svg.appendChild(transform(child, viewport));\r\n }\r\n\r\n return child;\r\n}\r\n\r\n/**\r\n * Transform a child annotation of an SVG.\r\n *\r\n * @param {SVGElement} svg The SVG element with the child annotation\r\n * @param {Object} child The SVG child to transform\r\n * @param {Object} viewport The page's viewport data\r\n * @return {SVGElement} A node that was transformed by this function\r\n */\r\nexport function transformChild(svg, child, viewport) {\r\n if (!viewport) {\r\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\r\n }\r\n\r\n // If no type was provided for an annotation it will result in node being null.\r\n // Skip transforming if node doesn't exist.\r\n if (child) {\r\n child = transform(child, viewport);\r\n }\r\n\r\n return child;\r\n}\r\n\r\nexport default {\r\n /**\r\n * Get the x/y translation to be used for transforming the annotations\r\n * based on the rotation of the viewport.\r\n */\r\n getTranslation,\r\n\r\n /**\r\n * Append an SVG child for an annotation\r\n */\r\n appendChild,\r\n\r\n /**\r\n * Transform an existing SVG child\r\n */\r\n transformChild\r\n};\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGLineElements from an annotation definition.\r\n * This is used for anntations of type `strikeout`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement} A group of all lines to be rendered\r\n */\r\nexport default function renderLine(a) {\r\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n setAttributes(group, {\r\n stroke: normalizeColor(a.color || '#f00'),\r\n strokeWidth: 1\r\n });\r\n\r\n a.rectangles.forEach((r) => {\r\n let line = document.createElementNS('http://www.w3.org/2000/svg', 'line');\r\n\r\n setAttributes(line, {\r\n x1: r.x,\r\n y1: r.y,\r\n x2: r.x + r.width,\r\n y2: r.y\r\n });\r\n\r\n group.appendChild(line);\r\n });\r\n\r\n return group;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\n\r\nconst SIZE = 25;\r\nconst D = 'M499.968 214.336q-113.832 0 -212.877 38.781t-157.356 104.625 -58.311 142.29q0 62.496 39.897 119.133t112.437 97.929l48.546 27.9 -15.066 53.568q-13.392 50.778 -39.06 95.976 84.816 -35.154 153.45 -95.418l23.994 -21.204 31.806 3.348q38.502 4.464 72.54 4.464 113.832 0 212.877 -38.781t157.356 -104.625 58.311 -142.29 -58.311 -142.29 -157.356 -104.625 -212.877 -38.781z';\r\n\r\n/**\r\n * Create SVGElement from an annotation definition.\r\n * This is used for anntations of type `comment`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGElement} A svg to be rendered\r\n */\r\nexport default function renderPoint(a) {\r\n let outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r\n let innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\r\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r\n\r\n setAttributes(outerSVG, {\r\n width: SIZE,\r\n height: SIZE,\r\n x: a.x,\r\n y: a.y\r\n });\r\n\r\n setAttributes(innerSVG, {\r\n width: SIZE,\r\n height: SIZE,\r\n x: 0,\r\n y: (SIZE * 0.05) * -1,\r\n viewBox: '0 0 1000 1000'\r\n });\r\n\r\n setAttributes(rect, {\r\n width: SIZE,\r\n height: SIZE,\r\n stroke: '#000',\r\n fill: '#ff0'\r\n });\r\n\r\n setAttributes(path, {\r\n d: D,\r\n strokeWidth: 50,\r\n stroke: '#000',\r\n fill: '#fff'\r\n });\r\n\r\n innerSVG.appendChild(path);\r\n outerSVG.appendChild(rect);\r\n outerSVG.appendChild(innerSVG);\r\n\r\n return outerSVG;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGPathElement from an annotation definition.\r\n * This is used for anntations of type `drawing`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGPathElement} The path to be rendered\r\n */\r\nexport default function renderPath(a) {\r\n let d = [];\r\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r\n\r\n if (a.lines.length > 0) {\r\n d.push(`M${a.lines[0][0]} ${a.lines[0][1]}`);\r\n for (let i = 1, l = a.lines.length; i < l; i++) {\r\n let p1 = a.lines[i];\r\n let p2 = a.lines[i + 1];\r\n if (p2) {\r\n d.push(`L${p1[0]} ${p1[1]}`);\r\n }\r\n }\r\n }\r\n\r\n /*\r\n\r\n if(a.lines.length>2) {\r\n var p1 = a.lines[0];\r\n var p2 = a.lines[a.lines.length-1];\r\n\r\n var p3 = []; //arrow\r\n var p4 = [];\r\n var p0 = []; //arrow intersection\r\n\r\n if (p2) {\r\n var k = -(p2[0]-p1[0])/(p2[1]-p1[1]);\r\n\r\n var deltaX = 3;\r\n p0[0] = p1[0]+0.8*(p2[0]-p1[0]);\r\n p0[1] = p1[1]+0.8*(p2[1]-p1[1]);\r\n\r\n p3[0] = p0[0] + deltaX;\r\n p3[1] = p0[1] + k*deltaX;\r\n\r\n p4[0] = p0[0] - deltaX;\r\n p4[1] = p0[1] - k*deltaX;\r\n\r\n if(Math.abs(p2[1]-p1[1]) < 20) {\r\n\r\n p3[0] = p0[0] ;\r\n p3[1] = p0[1] + deltaX*1;\r\n\r\n p4[0] = p0[0] ;\r\n p4[1] = p0[1] - deltaX*1;\r\n\r\n }\r\n\r\n d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\r\n //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\r\n d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`);\r\n d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`);\r\n d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`);\r\n }\r\n } */\r\n\r\n setAttributes(path, {\r\n d: `${d.join(' ')}`, // `${d.join(' ')}Z`,\r\n stroke: normalizeColor(a.color || '#000'),\r\n strokeWidth: a.width || 1,\r\n fill: 'none'\r\n });\r\n\r\n return path;\r\n}\r\n","import { getTranslation } from '../render/appendChild';\r\nimport {\r\n applyTransform,\r\n applyInverseTransform,\r\n translate,\r\n rotate,\r\n scale\r\n} from '../utils/mathUtils';\r\n\r\nexport const BORDER_COLOR = '#00BFFF';\r\n\r\nconst userSelectStyleSheet = document.createElement('style');\r\nuserSelectStyleSheet.innerHTML = `\r\nbody {\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n}\r\n`;\r\n\r\nuserSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true');\r\n\r\n/**\r\n * Find the SVGElement that contains all the annotations for a page\r\n *\r\n * @param {Element} node An annotation within that container\r\n * @return {SVGElement} The container SVG or null if it can't be found\r\n */\r\nexport function findSVGContainer(node) {\r\n let parentNode = node;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n if (parentNode.nodeName.toUpperCase() === 'SVG' &&\r\n parentNode.getAttribute('data-pdf-annotate-container') === 'true') {\r\n return parentNode;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Find an SVGElement container at a given point\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @return {SVGElement} The container SVG or null if one can't be found\r\n */\r\nexport function findSVGAtPoint(x, y) {\r\n let elements = document.querySelectorAll('svg[data-pdf-annotate-container=\"true\"]');\r\n\r\n for (let i = 0, l = elements.length; i < l; i++) {\r\n let el = elements[i];\r\n let rect = el.getBoundingClientRect();\r\n\r\n if (pointIntersectsRect(x, y, rect)) {\r\n return el;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Find an Element that represents an annotation at a given point.\r\n *\r\n * IMPORTANT: Requires the annotation layer to be the top most element so\r\n * either use z-ordering or make it the leaf container.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @return {Element} The annotation element or null if one can't be found\r\n */\r\nexport function findAnnotationAtPoint(x, y) {\r\n let el = null;\r\n let candidate = document.elementFromPoint(x, y);\r\n while (!el && candidate && candidate !== document) {\r\n let type = candidate.getAttribute('data-pdf-annotate-type');\r\n if (type) {\r\n el = candidate;\r\n }\r\n candidate = candidate.parentNode;\r\n }\r\n return el;\r\n}\r\n\r\n/**\r\n * Determine if a point intersects a rect\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Object} rect The points of a rect (likely from getBoundingClientRect)\r\n * @return {Boolean} True if a collision occurs, otherwise false\r\n */\r\nexport function pointIntersectsRect(x, y, rect) {\r\n return y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;\r\n}\r\n\r\n/**\r\n * Get the rect of an annotation element accounting for offset.\r\n *\r\n * @param {Element} el The element to get the rect of\r\n * @return {Object} The dimensions of the element\r\n */\r\nexport function getOffsetAnnotationRect(el) {\r\n let rect = el.getBoundingClientRect();\r\n let { width, height } = rect;\r\n let extraOffsetWidth = 0;\r\n let extraOffsetHeight = 0;\r\n if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) {\r\n let bbox = el.getBBox();\r\n extraOffsetWidth = (rect.width - bbox.width) / 2;\r\n extraOffsetHeight = (rect.height - bbox.height) / 2;\r\n width = bbox.width;\r\n height = bbox.height;\r\n }\r\n let { offsetLeft, offsetTop } = getOffset(el);\r\n return {\r\n top: rect.top - offsetTop + extraOffsetHeight,\r\n left: rect.left - offsetLeft + extraOffsetWidth,\r\n bottom: rect.bottom - offsetTop - extraOffsetHeight,\r\n right: rect.right - offsetLeft - extraOffsetWidth,\r\n width: width,\r\n height: height\r\n };\r\n}\r\n\r\n/**\r\n * Adjust scale from normalized scale (100%) to rendered scale.\r\n *\r\n * @param {SVGElement} svg The SVG to gather metadata from\r\n * @param {Object} rect A map of numeric values to scale\r\n * @return {Object} A copy of `rect` with values scaled up\r\n */\r\nexport function scaleUp(svg, rect) {\r\n let result = {};\r\n let { viewport } = getMetadata(svg);\r\n\r\n Object.keys(rect).forEach((key) => {\r\n result[key] = rect[key] * viewport.scale;\r\n });\r\n\r\n return result;\r\n}\r\n\r\nexport function convertToSvgRect(rect, svg, viewport) {\r\n let pt1 = [rect.x, rect.y];\r\n let pt2 = [rect.x + rect.width, rect.y + rect.height];\r\n\r\n pt1 = convertToSvgPoint(pt1, svg, viewport);\r\n pt2 = convertToSvgPoint(pt2, svg, viewport);\r\n\r\n return {\r\n x: Math.min(pt1[0], pt2[0]),\r\n y: Math.min(pt1[1], pt2[1]),\r\n width: Math.abs(pt2[0] - pt1[0]),\r\n height: Math.abs(pt2[1] - pt1[1])\r\n };\r\n}\r\n\r\nexport function convertToSvgPoint(pt, svg, viewport) {\r\n viewport = viewport || getMetadata(svg).viewport;\r\n\r\n let xform = [ 1, 0, 0, 1, 0, 0 ];\r\n xform = scale(xform, viewport.scale, viewport.scale);\r\n xform = rotate(xform, viewport.rotation);\r\n\r\n let offset = getTranslation(viewport);\r\n xform = translate(xform, offset.x, offset.y);\r\n\r\n return applyInverseTransform(pt, xform);\r\n}\r\n\r\nexport function convertToScreenPoint(pt, svg, viewport) {\r\n viewport = viewport || getMetadata(svg).viewport;\r\n\r\n let xform = [ 1, 0, 0, 1, 0, 0 ];\r\n xform = scale(xform, viewport.scale, viewport.scale);\r\n xform = rotate(xform, viewport.rotation);\r\n\r\n let offset = getTranslation(viewport);\r\n xform = translate(xform, offset.x, offset.y);\r\n\r\n return applyTransform(pt, xform);\r\n}\r\n\r\n/**\r\n * Adjust scale from rendered scale to a normalized scale (100%).\r\n *\r\n * @param {SVGElement} svg The SVG to gather metadata from\r\n * @param {Object} rect A map of numeric values to scale\r\n * @return {Object} A copy of `rect` with values scaled down\r\n */\r\nexport function scaleDown(svg, rect) {\r\n let result = {};\r\n let { viewport } = getMetadata(svg);\r\n\r\n Object.keys(rect).forEach((key) => {\r\n result[key] = rect[key] / viewport.scale;\r\n });\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the scroll position of an element, accounting for parent elements\r\n *\r\n * @param {Element} el The element to get the scroll position for\r\n * @return {Object} The scrollTop and scrollLeft position\r\n */\r\nexport function getScroll(el) {\r\n let scrollTop = 0;\r\n let scrollLeft = 0;\r\n let parentNode = el;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n scrollTop += parentNode.scrollTop;\r\n scrollLeft += parentNode.scrollLeft;\r\n }\r\n\r\n return { scrollTop, scrollLeft };\r\n}\r\n\r\n/**\r\n * Get the offset position of an element, accounting for parent elements\r\n *\r\n * @param {Element} el The element to get the offset position for\r\n * @return {Object} The offsetTop and offsetLeft position\r\n */\r\nexport function getOffset(el) {\r\n let parentNode = el;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n if (parentNode.nodeName.toUpperCase() === 'SVG') {\r\n break;\r\n }\r\n }\r\n\r\n let rect = parentNode.getBoundingClientRect();\r\n\r\n return { offsetLeft: rect.left, offsetTop: rect.top };\r\n}\r\n\r\n/**\r\n * Disable user ability to select text on page\r\n */\r\nexport function disableUserSelect() {\r\n if (!userSelectStyleSheet.parentNode) {\r\n document.head.appendChild(userSelectStyleSheet);\r\n }\r\n}\r\n\r\n/**\r\n * Enable user ability to select text on page\r\n */\r\nexport function enableUserSelect() {\r\n if (userSelectStyleSheet.parentNode) {\r\n userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet);\r\n }\r\n}\r\n\r\n/**\r\n * Get the metadata for a SVG container\r\n *\r\n * @param {SVGElement} svg The SVG container to get metadata for\r\n */\r\nexport function getMetadata(svg) {\r\n return {\r\n documentId: svg.getAttribute('data-pdf-annotate-document'),\r\n pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10),\r\n viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'))\r\n };\r\n}\r\n","import EventEmitter from 'events';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGAtPoint\r\n} from './utils';\r\n\r\nconst emitter = new EventEmitter();\r\n\r\nlet clickNode;\r\n\r\n/**\r\n * Handle document.click event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\ndocument.addEventListener('click', function handleDocumentClick(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n\r\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n\r\n // Emit annotation:blur if clickNode is no longer clicked\r\n if (clickNode && clickNode !== target) {\r\n emitter.emit('annotation:blur', clickNode);\r\n }\r\n\r\n // Emit annotation:click if target was clicked\r\n if (target) {\r\n emitter.emit('annotation:click', target);\r\n }\r\n\r\n clickNode = target;\r\n});\r\n\r\n// let mouseOverNode;\r\n// document.addEventListener('mousemove', function handleDocumentMousemove(e) {\r\n// let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n//\r\n// // Emit annotation:mouseout if target was mouseout'd\r\n// if (mouseOverNode && !target) {\r\n// emitter.emit('annotation:mouseout', mouseOverNode);\r\n// }\r\n//\r\n// // Emit annotation:mouseover if target was mouseover'd\r\n// if (target && mouseOverNode !== target) {\r\n// emitter.emit('annotation:mouseover', target);\r\n// }\r\n//\r\n// mouseOverNode = target;\r\n// });\r\n\r\nexport function fireEvent() { emitter.emit(...arguments); };\r\nexport function addEventListener() { emitter.on(...arguments); };\r\nexport function removeEventListener() { emitter.removeListener(...arguments); };\r\n","// Disable JSDoc as it cannot really deal with the odd way that the functions are defined\r\n/* eslint valid-jsdoc: 0 */\r\n\r\nimport abstractFunction from '../utils/abstractFunction';\r\nimport { fireEvent } from '../UI/event';\r\n\r\n// Adapter should never be invoked publicly\r\nexport default class StoreAdapter {\r\n /**\r\n * Create a new StoreAdapter instance\r\n *\r\n * @param {Object} [definition] The definition to use for overriding abstract methods\r\n */\r\n constructor(definition = {}) {\r\n // Copy each function from definition if it is a function we know about\r\n Object.keys(definition).forEach((key) => {\r\n if (typeof definition[key] === 'function' &&\r\n typeof this[key] === 'function') {\r\n this[key] = definition[key];\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Get all the annotations for a given document and page number.\r\n *\r\n * @param {String} documentId The ID for the document the annotations belong to\r\n * @param {Number} pageNumber The number of the page the annotations belong to\r\n * @return {Promise} Promise that returns with list of annotations for document and page\r\n */\r\n __getAnnotations(documentId, pageNumber) { abstractFunction('getAnnotations'); }\r\n get getAnnotations() { return this.__getAnnotations; }\r\n set getAnnotations(fn) {\r\n this.__getAnnotations = function getAnnotations(documentId, pageNumber) {\r\n return fn(...arguments).then((annotations) => {\r\n // TODO may be best to have this happen on the server\r\n if (annotations.annotations) {\r\n annotations.annotations.forEach((a) => {\r\n a.documentId = documentId;\r\n });\r\n }\r\n return annotations;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Get the definition for a specific annotation.\r\n *\r\n * @param {String} documentId The ID for the document the annotation belongs to\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns the requested annotation\r\n */\r\n getAnnotation(documentId, annotationId) { abstractFunction('getAnnotation'); }\r\n\r\n /**\r\n * Add an annotation\r\n *\r\n * @param {String} documentId The ID for the document to add the annotation to\r\n * @param {String} pageNumber The page number to add the annotation to\r\n * @param {Object} annotation The definition for the new annotation\r\n * @return {Promise} Promise that returns with the added annotation\r\n */\r\n __addAnnotation(documentId, pageNumber, annotation) { abstractFunction('addAnnotation'); }\r\n get addAnnotation() { return this.__addAnnotation; }\r\n set addAnnotation(fn) {\r\n this.__addAnnotation = function addAnnotation(documentId, pageNumber, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:add', documentId, pageNumber, annotation);\r\n return annotation;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Edit an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} pageNumber the page number of the annotation\r\n * @param {Object} annotation The definition of the modified annotation\r\n * @return {Promise} Promise that returns with the edited annotation\r\n */\r\n __editAnnotation(documentId, pageNumber, annotation) { abstractFunction('editAnnotation'); }\r\n get editAnnotation() { return this.__editAnnotation; }\r\n set editAnnotation(fn) {\r\n this.__editAnnotation = function editAnnotation(documentId, annotationId, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:edit', documentId, annotationId, annotation);\r\n return annotation;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Delete an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns with boolean if annotation was deleted\r\n */\r\n __deleteAnnotation(documentId, annotationId) { abstractFunction('deleteAnnotation'); }\r\n get deleteAnnotation() { return this.__deleteAnnotation; }\r\n set deleteAnnotation(fn) {\r\n this.__deleteAnnotation = function deleteAnnotation(documentId, annotationId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('annotation:delete', documentId, annotationId);\r\n }\r\n return success;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Get all the comments for an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns with comments for annotation\r\n */\r\n getComments(documentId, annotationId) { abstractFunction('getComments'); }\r\n\r\n /**\r\n * Add a new comment\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @param {Object} content The definition of the comment\r\n * @return {Promise} Promise that returns with the added comment\r\n */\r\n __addComment(documentId, annotationId, content) { abstractFunction('addComment'); }\r\n get addComment() { return this.__addComment; }\r\n set addComment(fn) {\r\n this.__addComment = function addComment(documentId, annotationId, content) {\r\n return fn(...arguments).then((comment) => {\r\n fireEvent('comment:add', documentId, annotationId, comment);\r\n return comment;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Delete a comment\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} commentId The ID for the comment\r\n * @return {Promise} Promise that returns with boolean if comment was deleted\r\n */\r\n __deleteComment(documentId, commentId) { abstractFunction('deleteComment'); }\r\n get deleteComment() { return this.__deleteComment; }\r\n set deleteComment(fn) {\r\n this.__deleteComment = function deleteComment(documentId, commentId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('comment:delete', documentId, commentId);\r\n }\r\n return success;\r\n });\r\n };\r\n }\r\n}\r\n","const REGEXP = /[xy]/g;\r\nconst PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\r\n\r\nfunction replacement(c) {\r\n let r = Math.random() * 16 | 0;\r\n let v = c === 'x' ? r : (r & 0x3 | 0x8);\r\n return v.toString(16);\r\n}\r\n\r\n/**\r\n * Generate a univierally unique identifier\r\n *\r\n * @return {String} A UUID\r\n */\r\nexport default function uuid() {\r\n return PATTERN.replace(REGEXP, replacement);\r\n}\r\n","import uuid from '../utils/uuid';\r\nimport StoreAdapter from './StoreAdapter';\r\n\r\n// StoreAdapter for working with localStorage\r\n// This is ideal for testing, examples, and prototyping\r\nexport default class LocalStoreAdapter extends StoreAdapter {\r\n constructor() {\r\n super({\r\n getAnnotations(documentId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId).filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n }\r\n });\r\n\r\n this.getAnnotation = (documentId, annotationId) => {\r\n return Promise.resolve(getAnnotations(documentId)[findAnnotation(documentId, annotationId)]);\r\n };\r\n\r\n this.addAnnotation = (documentId, pageNumber, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n annotation.class = 'Annotation';\r\n annotation.uuid = uuid();\r\n annotation.page = pageNumber;\r\n\r\n let annotations = getAnnotations(documentId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.editAnnotation = (documentId, annotationId, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId);\r\n annotations[findAnnotation(documentId, annotationId)] = annotation;\r\n updateAnnotations(documentId, annotations);\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.deleteAnnotation = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n let annotation = getAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\r\n if (!annotation) {\r\n return reject('Could not find annotation');\r\n }\r\n let index = findAnnotation(documentId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n\r\n this.getComments = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n };\r\n\r\n this.addComment = (documentId, annotationId, content) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = {\r\n class: 'Comment',\r\n uuid: uuid(),\r\n annotation: annotationId,\r\n content: content\r\n };\r\n\r\n let annotations = getAnnotations(documentId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n };\r\n\r\n this.deleteComment = (documentId, commentId) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = getAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\r\n if (!comment) {\r\n return reject('Could not find annotation');\r\n }\r\n let index = -1;\r\n let annotations = getAnnotations(documentId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === commentId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n if (index > -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n }\r\n}\r\n\r\nfunction getAnnotations(documentId) {\r\n return JSON.parse(localStorage.getItem(`${documentId}/annotations`)) || [];\r\n}\r\n\r\nfunction updateAnnotations(documentId, annotations) {\r\n localStorage.setItem(`${documentId}/annotations`, JSON.stringify(annotations));\r\n}\r\n/**\r\n *\r\n * @param {String} documentId Document id of the annotation\r\n * @param {String} annotationId The id of the annotation\r\n *\r\n * This function finds all the annotation made by one user.\r\n *\r\n * @return {int} The index of the annotation in localstorage\r\n */\r\nfunction findAnnotation(documentId, annotationId) {\r\n let index = -1;\r\n let annotations = getAnnotations(documentId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === annotationId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n return index;\r\n}\r\n","import uuid from '../utils/uuid';\r\nimport StoreAdapter from './StoreAdapter';\r\n\r\n// StoreAdapter for working with localStorage and associated user id\r\n// This is ideal for testing, examples, and prototyping\r\nexport default class LocalUserStoreAdapter extends StoreAdapter {\r\n constructor(userId = 'user', globalEdit = false) {\r\n super({\r\n getAnnotations(documentId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAllAnnotations(documentId).filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n }\r\n });\r\n\r\n this._userId = userId;\r\n this._globalEdit = globalEdit;\r\n\r\n this.getAnnotation = (documentId, annotationId) => {\r\n return Promise.resolve(getAnnotations(documentId, this._userId)[findAnnotation(documentId, this._userId, annotationId)]);\r\n };\r\n\r\n this.addAnnotation = (documentId, pageNumber, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n annotation.class = 'Annotation';\r\n annotation.uuid = uuid();\r\n annotation.page = pageNumber;\r\n annotation.userId = this._userId;\r\n\r\n let annotations = getAnnotations(documentId, this._userId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, this._userId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.editAnnotation = (documentId, annotationId, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\r\n reject('Non-matching userId');\r\n }\r\n let annotations = getAnnotations(documentId, annotation.userId);\r\n annotations[findAnnotation(documentId, annotation.userId, annotationId)] = annotation;\r\n updateAnnotations(documentId, annotation.userId, annotations);\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.deleteAnnotation = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n let annotation = getAllAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\r\n if (!annotation) {\r\n return reject('Could not find annotation');\r\n }\r\n else if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\r\n return reject('Non-matching userId');\r\n }\r\n let index = findAnnotation(documentId, annotation.userId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId, annotation.userId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotation.userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n\r\n this.getComments = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId, this._userId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n };\r\n\r\n this.addComment = (documentId, annotationId, content) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = {\r\n class: 'Comment',\r\n uuid: uuid(),\r\n annotation: annotationId,\r\n content: content,\r\n userId: this._userId\r\n };\r\n\r\n let annotations = getAnnotations(documentId, this._userId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, this._userId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n };\r\n\r\n this.deleteComment = (documentId, commentId) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = getAllAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\r\n if (!comment) {\r\n return reject('Could not find annotation');\r\n }\r\n else if (!this._globalEdit && comment.userId && comment.userId !== this._userId) {\r\n return reject('Non-matching userId');\r\n }\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, comment.userId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === commentId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n if (index > -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, comment.userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n }\r\n\r\n get userId() {\r\n return this._userId;\r\n }\r\n}\r\n\r\nfunction getAllAnnotations(documentId) {\r\n let all_annotations = [];\r\n let re = new RegExp(`${documentId}/(.*)/annotations`);\r\n for (let i = 0; i < localStorage.length; i++) {\r\n if (localStorage.key(i).search(re) > -1) {\r\n all_annotations.push(...JSON.parse(localStorage.getItem(localStorage.key(i))));\r\n }\r\n }\r\n return all_annotations;\r\n}\r\n\r\nfunction getAnnotations(documentId, userId) {\r\n return JSON.parse(localStorage.getItem(`${documentId}/${userId}/annotations`)) || [];\r\n}\r\n\r\nfunction updateAnnotations(documentId, userId, annotations) {\r\n localStorage.setItem(`${documentId}/${userId}/annotations`, JSON.stringify(annotations));\r\n}\r\n/**\r\n *\r\n * @param {String} documentId Document id of the annotation\r\n * @param {String} userId User id of the annotation\r\n * @param {String} annotationId The id of the annotation\r\n *\r\n * This function finds all the annotation made by one user.\r\n *\r\n * @return {int} The index of the annotation in localstorage\r\n */\r\nfunction findAnnotation(documentId, userId, annotationId) {\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, userId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === annotationId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n return index;\r\n}\r\n","export default {\r\n annotationLayerName: 'annotationLayer',\r\n textLayerName: 'textLayer',\r\n annotationSvgQuery: function() {\r\n return 'svg.' + this.annotationLayerName;\r\n },\r\n annotationClassQuery: function() {\r\n return '.' + this.annotationLayerName;\r\n },\r\n textClassQuery: function() {\r\n return '.' + this.textLayerName;\r\n }\r\n};\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport {\r\n addEventListener,\r\n removeEventListener\r\n} from './event';\r\nimport {\r\n BORDER_COLOR,\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGContainer,\r\n findSVGAtPoint,\r\n getOffsetAnnotationRect,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet isDragging = false;\r\nlet overlay;\r\nlet dragOffsetX, dragOffsetY, dragStartX, dragStartY;\r\nconst OVERLAY_BORDER_SIZE = 3;\r\n\r\n/**\r\n * Create an overlay for editing an annotation.\r\n *\r\n * @param {Element} target The annotation element to apply overlay for\r\n */\r\nfunction createEditOverlay(target) {\r\n destroyEditOverlay();\r\n\r\n overlay = document.createElement('div');\r\n let anchor = document.createElement('a');\r\n let parentNode = findSVGContainer(target).parentNode;\r\n let id = target.getAttribute('data-pdf-annotate-id');\r\n let rect = getOffsetAnnotationRect(target);\r\n let styleLeft = rect.left - OVERLAY_BORDER_SIZE;\r\n let styleTop = rect.top - OVERLAY_BORDER_SIZE;\r\n\r\n overlay.setAttribute('id', 'pdf-annotate-edit-overlay');\r\n overlay.setAttribute('data-target-id', id);\r\n overlay.style.boxSizing = 'content-box';\r\n overlay.style.position = 'absolute';\r\n overlay.style.top = `${styleTop}px`;\r\n overlay.style.left = `${styleLeft}px`;\r\n overlay.style.width = `${rect.width}px`;\r\n overlay.style.height = `${rect.height}px`;\r\n overlay.style.border = `${OVERLAY_BORDER_SIZE}px solid ${BORDER_COLOR}`;\r\n overlay.style.borderRadius = `${OVERLAY_BORDER_SIZE}px`;\r\n overlay.style.zIndex = 20100;\r\n\r\n anchor.innerHTML = '×';\r\n anchor.setAttribute('href', 'javascript://');\r\n anchor.style.background = '#fff';\r\n anchor.style.borderRadius = '20px';\r\n anchor.style.border = '1px solid #bbb';\r\n anchor.style.color = '#bbb';\r\n anchor.style.fontSize = '16px';\r\n anchor.style.padding = '2px';\r\n anchor.style.textAlign = 'center';\r\n anchor.style.textDecoration = 'none';\r\n anchor.style.position = 'absolute';\r\n anchor.style.top = '-13px';\r\n anchor.style.right = '-13px';\r\n anchor.style.width = '25px';\r\n anchor.style.height = '25px';\r\n\r\n overlay.appendChild(anchor);\r\n parentNode.appendChild(overlay);\r\n document.addEventListener('click', handleDocumentClick);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n anchor.addEventListener('click', deleteAnnotation);\r\n anchor.addEventListener('mouseover', () => {\r\n anchor.style.color = '#35A4DC';\r\n anchor.style.borderColor = '#999';\r\n anchor.style.boxShadow = '0 1px 1px #ccc';\r\n });\r\n anchor.addEventListener('mouseout', () => {\r\n anchor.style.color = '#bbb';\r\n anchor.style.borderColor = '#bbb';\r\n anchor.style.boxShadow = '';\r\n });\r\n overlay.addEventListener('mouseover', () => {\r\n if (!isDragging) { anchor.style.display = ''; }\r\n });\r\n overlay.addEventListener('mouseout', () => {\r\n anchor.style.display = 'none';\r\n });\r\n}\r\n\r\n/**\r\n * Destroy the edit overlay if it exists.\r\n */\r\nfunction destroyEditOverlay() {\r\n if (overlay) {\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n }\r\n\r\n document.removeEventListener('click', handleDocumentClick);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n enableUserSelect();\r\n}\r\n\r\n/**\r\n * Delete currently selected annotation\r\n */\r\nfunction deleteAnnotation() {\r\n if (!overlay) {\r\n return;\r\n }\r\n\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n });\r\n\r\n destroyEditOverlay();\r\n}\r\n\r\n/**\r\n * Handle document.click event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentClick(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) { return; }\r\n\r\n // Remove current overlay\r\n let overlay = document.getElementById('pdf-annotate-edit-overlay');\r\n if (overlay) {\r\n if (isDragging || e.target === overlay) {\r\n return;\r\n }\r\n\r\n destroyEditOverlay();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {KeyboardEvent} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // keyCode is deprecated, so prefer the newer \"key\" method if possible\r\n let keyTest;\r\n if (e.key) {\r\n keyTest = e.key.toLowerCase() === 'delete' || e.key.toLowerCase() === 'backspace';\r\n }\r\n else {\r\n keyTest = e.keyCode === 8 || e.keyCode === 46;\r\n }\r\n if (overlay && keyTest &&\r\n e.target.nodeName.toLowerCase() !== 'textarea' &&\r\n e.target.nodeName.toLowerCase() !== 'input') {\r\n e.preventDefault();\r\n deleteAnnotation();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mousedown event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n if (e.target !== overlay) {\r\n return;\r\n }\r\n\r\n // Highlight and strikeout annotations are bound to text within the document.\r\n // It doesn't make sense to allow repositioning these types of annotations.\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let target = document.querySelector(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let type = target.getAttribute('data-pdf-annotate-type');\r\n\r\n if (type === 'highlight' || type === 'strikeout') { return; }\r\n\r\n isDragging = true;\r\n dragOffsetX = e.clientX;\r\n dragOffsetY = e.clientY;\r\n dragStartX = overlay.offsetLeft;\r\n dragStartY = overlay.offsetTop;\r\n\r\n overlay.style.background = 'rgba(255, 255, 255, 0.7)';\r\n overlay.style.cursor = 'move';\r\n overlay.querySelector('a').style.display = 'none';\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let parentNode = overlay.parentNode;\r\n let rect = parentNode.getBoundingClientRect();\r\n let y = (dragStartY + (e.clientY - dragOffsetY));\r\n let x = (dragStartX + (e.clientX - dragOffsetX));\r\n let minY = 0;\r\n let maxY = rect.height;\r\n let minX = 0;\r\n let maxX = rect.width;\r\n\r\n if (y > minY && y + overlay.offsetHeight < maxY) {\r\n overlay.style.top = `${y}px`;\r\n }\r\n\r\n if (x > minX && x + overlay.offsetWidth < maxX) {\r\n overlay.style.left = `${x}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let target = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let type = target[0].getAttribute('data-pdf-annotate-type');\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n overlay.querySelector('a').style.display = '';\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\r\n let attribX = 'x';\r\n let attribY = 'y';\r\n if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\r\n attribX = 'cx';\r\n attribY = 'cy';\r\n }\r\n\r\n if (type === 'point') {\r\n // Broken\r\n /*\r\n [...target].forEach((t, i) => {\r\n let moveTo = {\r\n x: overlay.offsetLeft + 3,\r\n y: overlay.offsetTop + 3\r\n };\r\n t.setAttribute(attribX, moveTo.x);\r\n t.setAttribute(attribY, moveTo.y);\r\n annotation[attribX] = moveTo.x;\r\n annotation[attribY] = moveTo.y;\r\n });\r\n */\r\n return;\r\n }\r\n else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\r\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\r\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\r\n let modelDelta = {\r\n x: modelEnd[0] - modelStart[0],\r\n y: modelEnd[1] - modelStart[1]\r\n };\r\n\r\n if (type === 'textbox') {\r\n target = [target[0].firstChild];\r\n }\r\n\r\n [...target].forEach((t, i) => {\r\n let modelX = parseInt(t.getAttribute(attribX), 10);\r\n let modelY = parseInt(t.getAttribute(attribY), 10);\r\n if (modelDelta.y !== 0) {\r\n modelY = modelY + modelDelta.y;\r\n\r\n t.setAttribute(attribY, modelY);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].y = modelY;\r\n }\r\n else if (annotation[attribY]) {\r\n annotation[attribY] = modelY;\r\n }\r\n }\r\n if (modelDelta.x !== 0) {\r\n modelX = modelX + modelDelta.x;\r\n\r\n t.setAttribute(attribX, modelX);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].x = modelX;\r\n }\r\n else if (annotation[attribX]) {\r\n annotation[attribX] = modelX;\r\n }\r\n }\r\n });\r\n }\r\n else if (type === 'strikeout') {\r\n return;\r\n // let { deltaX, deltaY } = getDelta('x1', 'y1');\r\n // [...target].forEach(target, (t, i) => {\r\n // if (deltaY !== 0) {\r\n // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY);\r\n // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY);\r\n // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10);\r\n // }\r\n // if (deltaX !== 0) {\r\n // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX);\r\n // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX);\r\n // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10);\r\n // }\r\n // });\r\n }\r\n else if (type === 'drawing' || type === 'arrow') {\r\n // Do nothing as currently broken\r\n /*\r\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\r\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\r\n let modelDelta = {\r\n x: modelEnd[0] - modelStart[0],\r\n y: modelEnd[1] - modelStart[1]\r\n };\r\n\r\n annotation.lines.forEach((line, i) => {\r\n let [x, y] = annotation.lines[i];\r\n annotation.lines[i][0] = x + modelDelta.x;\r\n annotation.lines[i][1] = y + modelDelta.y;\r\n });\r\n\r\n target[0].parentNode.removeChild(target[0]);\r\n appendChild(svg, annotation);\r\n */\r\n return;\r\n }\r\n\r\n PDFJSAnnotate.getStoreAdapter().editAnnotation(documentId, annotationId, annotation);\r\n });\r\n\r\n setTimeout(() => {\r\n isDragging = false;\r\n }, 0);\r\n\r\n overlay.style.background = '';\r\n overlay.style.cursor = '';\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n enableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle annotation.click event\r\n *\r\n * @param {Element} e The annotation element that was clicked\r\n */\r\nfunction handleAnnotationClick(target) {\r\n createEditOverlay(target);\r\n}\r\n\r\n/**\r\n * Enable edit mode behavior.\r\n */\r\nexport function enableEdit() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n addEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n/**\r\n * Disable edit mode behavior.\r\n */\r\nexport function disableEdit() {\r\n destroyEditOverlay();\r\n\r\n if (!_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = false;\r\n removeEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _candraw = false;\r\nlet _penSize;\r\nlet _penColor;\r\nlet path;\r\nlet lines = [];\r\n\r\n/**\r\n * Handle document.touchdown or document.pointerdown event\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerdown(e) {\r\n path = null;\r\n lines = [];\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n _candraw = true;\r\n e.preventDefault();\r\n}\r\n\r\n/**\r\n * Handle document.pointerup event\r\n *\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerup(e) {\r\n saveToStorage(e.clientX, e.clientY);\r\n}\r\n\r\nfunction saveToStorage(x, y) {\r\n if (!_candraw) {\r\n return;\r\n }\r\n _candraw = false;\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\r\n type: 'drawing',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }).then((annotation) => {\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointermove(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY) || !_candraw) {\r\n return;\r\n }\r\n savePoint(e.clientX, e.clientY);\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {KeyboardEvent} e The DOM event to be handled\r\n * } e The DOM event to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n lines = null;\r\n path.parentNode.removeChild(path);\r\n document.removeEventListener('pointermove', handleDocumentPointermove);\r\n document.removeEventListener('pointerup', handleDocumentPointerup);\r\n }\r\n}\r\n\r\n/**\r\n * Save a point to the line being drawn.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n */\r\nfunction savePoint(x, y) {\r\n let svg = findSVGAtPoint(x, y);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let point = convertToSvgPoint([\r\n x - rect.left,\r\n y - rect.top\r\n ], svg);\r\n point[0] = point[0].toFixed(2);\r\n point[1] = point[1].toFixed(2);\r\n lines.push(point);\r\n\r\n if (lines.length <= 1) {\r\n return;\r\n }\r\n\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n path = appendChild(svg, {\r\n type: 'drawing',\r\n color: _penColor,\r\n width: _penSize,\r\n lines\r\n });\r\n}\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} penSize The size of the lines drawn by the pen, rounded to 2 decimal places\r\n * @param {String} penColor The color of the lines drawn by the pen\r\n */\r\nexport function setPen(penSize = 1, penColor = '000000') {\r\n _penSize = Math.round(parseFloat(penSize) * 1e2) / 1e2;\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Return pen attributes of the pen\r\n *\r\n * @return {Object} Object with size and color\r\n */\r\nexport function getPen() {\r\n return {\r\n size: _penSize,\r\n color: _penColor\r\n };\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enablePen() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n // Chrome and Firefox has different behaviors with how pen works, so we need different events.\r\n document.addEventListener('pointerdown', handleDocumentPointerdown);\r\n document.addEventListener('pointermove', handleDocumentPointermove);\r\n document.addEventListener('pointerup', handleDocumentPointerup);\r\n\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Disable the pen behavior\r\n */\r\nexport function disablePen() {\r\n if (!_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = false;\r\n document.removeEventListener('pointerdown', handleDocumentPointerdown);\r\n document.removeEventListener('pointermove', handleDocumentPointermove);\r\n document.removeEventListener('pointerup', handleDocumentPointerup);\r\n\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n enableUserSelect();\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n findSVGContainer,\r\n getMetadata,\r\n convertToSvgPoint,\r\n convertToScreenPoint,\r\n findAnnotationAtPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _penSize;\r\nlet _penColor;\r\nlet path;\r\nlet lines;\r\nlet originY;\r\nlet originX;\r\n\r\n/**\r\n * Handle document.mousedown event\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n if (target === null) {\r\n return;\r\n }\r\n\r\n let type = target.getAttribute('data-pdf-annotate-type');\r\n if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') {\r\n return;\r\n }\r\n\r\n let svg = findSVGContainer(target);\r\n let { documentId } = getMetadata(svg);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\r\n if (annotation) {\r\n path = null;\r\n lines = [];\r\n\r\n let point = convertToScreenPoint([\r\n annotation.cx,\r\n annotation.cy\r\n ], svg);\r\n\r\n let rect = svg.getBoundingClientRect();\r\n\r\n originX = point[0] + rect.left;\r\n originY = point[1] + rect.top;\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(e.clientX, e.clientY))) {\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\r\n type: 'arrow',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }).then((annotation) => {\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let x = lines.length === 0 ? originX : e.clientX;\r\n let y = lines.length === 0 ? originY : e.clientY;\r\n\r\n savePoint(x, y);\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n lines = null;\r\n path.parentNode.removeChild(path);\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n }\r\n}\r\n\r\n/**\r\n * Save a point to the line being drawn.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n */\r\nfunction savePoint(x, y) {\r\n let svg = findSVGAtPoint(x, y);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let point = convertToSvgPoint([\r\n x - rect.left,\r\n y - rect.top\r\n ], svg);\r\n\r\n if (lines.length < 2) {\r\n lines.push(point);\r\n return;\r\n }\r\n else {\r\n lines[1] = point; // update end point\r\n }\r\n\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n path = appendChild(svg, {\r\n type: 'arrow',\r\n color: _penColor,\r\n width: _penSize,\r\n lines\r\n });\r\n}\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} penSize The size of the lines drawn by the pen\r\n * @param {String} penColor The color of the lines drawn by the pen\r\n */\r\nexport function setArrow(penSize = 10, penColor = '0000FF') {\r\n _penSize = parseInt(penSize, 10);\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enableArrow() {\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Disable the pen behavior\r\n */\r\nexport function disableArrow() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n enableUserSelect();\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport {\r\n findAnnotationAtPoint,\r\n getMetadata\r\n} from './utils';\r\n\r\nlet _canerase = false;\r\nlet previousPoint = null;\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentDown(e) {\r\n _canerase = true;\r\n previousPoint = [e.clientX, e.clientY];\r\n}\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentUp(e) {\r\n _canerase = false;\r\n erase(findAnnotationAtPoint(e.clientX, e.clientY));\r\n}\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentMouseMove(e) {\r\n if (!_canerase) {\r\n return;\r\n }\r\n\r\n // This algorithm attempts to get the various points between the last\r\n // PointerEvent and this one\r\n let check = [];\r\n let diffX = Math.abs(previousPoint[0] - e.clientX);\r\n let diffY = Math.abs(previousPoint[1] - e.clientY);\r\n if (diffX >= 1 || diffY >= 1) {\r\n let maxSteps = Math.round(Math.max(diffX, diffY));\r\n let subStepSize = Math.min(diffX, diffY) / maxSteps;\r\n let smallerTest = diffX < diffY;\r\n let startPoint = [\r\n Math.min(previousPoint[0], e.clientX),\r\n Math.min(previousPoint[1], e.clientY)\r\n ];\r\n for (let i = 0; i < maxSteps; i++) {\r\n if (smallerTest) {\r\n check.push([Math.round(startPoint[0] + (subStepSize * i)), Math.round(startPoint[1] + i)]);\r\n }\r\n else {\r\n check.push([Math.round(startPoint[0] + i), Math.round(startPoint[1] + (subStepSize * i))]);\r\n }\r\n }\r\n }\r\n for (let point of check) {\r\n erase(findAnnotationAtPoint(point[0], point[1]));\r\n }\r\n previousPoint = [e.clientX, e.clientY];\r\n}\r\n\r\nfunction erase(target) {\r\n if (!_canerase) {\r\n return;\r\n }\r\n\r\n if (target) {\r\n let { documentId } = getMetadata(target.parentElement);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n });\r\n }\r\n}\r\n\r\nexport function enableEraser() {\r\n document.addEventListener('pointermove', handleDocumentMouseMove);\r\n document.addEventListener('pointerdown', handleDocumentDown);\r\n document.addEventListener('pointerup', handleDocumentUp);\r\n}\r\n\r\nexport function disableEraser() {\r\n document.removeEventListener('pointermove', handleDocumentMouseMove);\r\n document.removeEventListener('pointerdown', handleDocumentDown);\r\n document.removeEventListener('pointerup', handleDocumentUp);\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n findSVGAtPoint,\r\n getMetadata,\r\n scaleDown\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet input;\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} The DOM event to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n\r\n input = document.createElement('input');\r\n input.setAttribute('id', 'pdf-annotate-point-input');\r\n input.setAttribute('placeholder', 'Enter comment');\r\n input.style.border = `3px solid ${BORDER_COLOR}`;\r\n input.style.borderRadius = '3px';\r\n input.style.position = 'absolute';\r\n input.style.top = `${e.clientY}px`;\r\n input.style.left = `${e.clientX}px`;\r\n\r\n input.addEventListener('blur', handleInputBlur);\r\n input.addEventListener('keyup', handleInputKeyup);\r\n\r\n document.body.appendChild(input);\r\n input.focus();\r\n}\r\n\r\n/**\r\n * Handle input.blur event\r\n */\r\nfunction handleInputBlur() {\r\n savePoint();\r\n}\r\n\r\n/**\r\n * Handle input.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleInputKeyup(e) {\r\n if (e.keyCode === 27) {\r\n closeInput();\r\n }\r\n else if (e.keyCode === 13) {\r\n savePoint();\r\n }\r\n}\r\n\r\n/**\r\n * Save a new point annotation from input\r\n */\r\nfunction savePoint() {\r\n if (input.value.trim().length > 0) {\r\n let clientX = parseInt(input.style.left, 10);\r\n let clientY = parseInt(input.style.top, 10);\r\n let content = input.value.trim();\r\n let svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n let annotation = Object.assign({\r\n type: 'point'\r\n }, scaleDown(svg, {\r\n x: clientX - rect.left,\r\n y: clientY - rect.top\r\n }));\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n PDFJSAnnotate.getStoreAdapter().addComment(\r\n documentId,\r\n annotation.uuid,\r\n content\r\n );\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n closeInput();\r\n}\r\n\r\n/**\r\n * Close the input element\r\n */\r\nfunction closeInput() {\r\n input.removeEventListener('blur', handleInputBlur);\r\n input.removeEventListener('keyup', handleInputKeyup);\r\n document.body.removeChild(input);\r\n input = null;\r\n}\r\n\r\n/**\r\n * Enable point annotation behavior\r\n */\r\nexport function enablePoint() {\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable point annotation behavior\r\n */\r\nexport function disablePoint() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgRect\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _type;\r\nlet overlay;\r\nlet originY;\r\nlet originX;\r\n\r\n/**\r\n * Get the current window selection as rects\r\n *\r\n * @return {Array} An Array of rects\r\n */\r\nfunction getSelectionRects() {\r\n try {\r\n let selection = window.getSelection();\r\n let range = selection.getRangeAt(0);\r\n let rects = range.getClientRects();\r\n\r\n if (rects.length > 0 &&\r\n rects[0].width > 0 &&\r\n rects[0].height > 0) {\r\n return rects;\r\n }\r\n }\r\n catch (e) {}\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Handle document.mousedown event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n let svg;\r\n if (_type !== 'area' || !(svg = findSVGAtPoint(e.clientX, e.clientY))) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n originY = e.clientY;\r\n originX = e.clientX;\r\n\r\n overlay = document.createElement('div');\r\n overlay.style.position = 'absolute';\r\n overlay.style.top = `${originY - rect.top}px`;\r\n overlay.style.left = `${originX - rect.left}px`;\r\n overlay.style.border = `3px solid ${BORDER_COLOR}`;\r\n overlay.style.borderRadius = '3px';\r\n svg.parentNode.appendChild(overlay);\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let rect = svg.getBoundingClientRect();\r\n\r\n if (originX + (e.clientX - originX) < rect.right) {\r\n overlay.style.width = `${e.clientX - originX}px`;\r\n }\r\n\r\n if (originY + (e.clientY - originY) < rect.bottom) {\r\n overlay.style.height = `${e.clientY - originY}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let rects;\r\n if (_type !== 'area' && (rects = getSelectionRects())) {\r\n saveRect(_type, [...rects].map((r) => {\r\n return {\r\n top: r.top,\r\n left: r.left,\r\n width: r.width,\r\n height: r.height\r\n };\r\n }));\r\n }\r\n else if (_type === 'area' && overlay) {\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let rect = svg.getBoundingClientRect();\r\n saveRect(_type, [{\r\n top: parseInt(overlay.style.top, 10) + rect.top,\r\n left: parseInt(overlay.style.left, 10) + rect.left,\r\n width: parseInt(overlay.style.width, 10),\r\n height: parseInt(overlay.style.height, 10)\r\n }]);\r\n\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n enableUserSelect();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n let selection = window.getSelection();\r\n selection.removeAllRanges();\r\n if (overlay && overlay.parentNode) {\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Save a rect annotation\r\n *\r\n * @param {String} type The type of rect (area, highlight, strikeout)\r\n * @param {Array} rects The rects to use for annotation\r\n * @param {String} color The color of the rects\r\n */\r\nfunction saveRect(type, rects, color) {\r\n let svg = findSVGAtPoint(rects[0].left, rects[0].top);\r\n let annotation;\r\n\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let boundingRect = svg.getBoundingClientRect();\r\n\r\n if (!color) {\r\n if (type === 'highlight') {\r\n color = 'FFFF00';\r\n }\r\n else if (type === 'strikeout') {\r\n color = 'FF0000';\r\n }\r\n }\r\n\r\n // Initialize the annotation\r\n annotation = {\r\n type,\r\n color,\r\n rectangles: [...rects].map((r) => {\r\n let offset = 0;\r\n\r\n if (type === 'strikeout') {\r\n offset = r.height / 2;\r\n }\r\n\r\n return convertToSvgRect({\r\n y: (r.top + offset) - boundingRect.top,\r\n x: r.left - boundingRect.left,\r\n width: r.width,\r\n height: r.height\r\n }, svg);\r\n }).filter((r) => r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1)\r\n };\r\n\r\n // Short circuit if no rectangles exist\r\n if (annotation.rectangles.length === 0) {\r\n return;\r\n }\r\n\r\n // Special treatment for area as it only supports a single rect\r\n if (type === 'area') {\r\n let rect = annotation.rectangles[0];\r\n delete annotation.rectangles;\r\n annotation.x = rect.x;\r\n annotation.y = rect.y;\r\n annotation.width = rect.width;\r\n annotation.height = rect.height;\r\n }\r\n\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n}\r\n\r\n/**\r\n * Enable rect behavior\r\n */\r\nexport function enableRect(type) {\r\n _type = type;\r\n\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n}\r\n\r\n/**\r\n * Disable rect behavior\r\n */\r\nexport function disableRect() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _type;\r\nlet _circleRadius = 10;\r\nlet _circleColor = '0000FF';\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} circleRadius The radius of the circle\r\n * @param {String} circleColor The color of the circle\r\n */\r\nexport function setCircle(circleRadius = 10, circleColor = '0000FF') {\r\n _circleRadius = parseInt(circleRadius, 10);\r\n _circleColor = circleColor;\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let svg = findSVGAtPoint(e.clientX, e.clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let rect = svg.getBoundingClientRect();\r\n saveCircle(svg, _type, {\r\n x: e.clientX - rect.left,\r\n y: e.clientY - rect.top\r\n }, _circleRadius, _circleColor);\r\n}\r\n\r\n/**\r\n * Save a circle annotation\r\n *\r\n * @param {SVGElement} svg\r\n * @param {String} type The type of circle (circle, emptycircle, fillcircle)\r\n * @param {Object} pt The point to use for annotation\r\n * @param {float} radius\r\n * @param {String} color The color of the rects\r\n */\r\nfunction saveCircle(svg, type, pt, radius, color) {\r\n // Initialize the annotation\r\n let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg);\r\n let annotation = {\r\n type,\r\n color,\r\n cx: svg_pt[0],\r\n cy: svg_pt[1],\r\n r: radius\r\n };\r\n\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n}\r\n\r\n/**\r\n * Enable circle behavior\r\n */\r\nexport function enableCircle(type) {\r\n _type = type;\r\n\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable circle behavior\r\n */\r\nexport function disableCircle() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\nexport function addCircle(type, e) {\r\n let oldType = _type;\r\n _type = type;\r\n handleDocumentMouseup(e);\r\n _type = oldType;\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet input;\r\nlet _textSize = localStorage.getItem(`text/size`) || 12;\r\nlet _textColor = localStorage.getItem(`text/color`) || '#000000';\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n if (!e.srcElement.classList.contains('annotationLayer')) {\r\n return;\r\n }\r\n input = document.createElement('textarea');\r\n input.setAttribute('id', 'pdf-annotate-text-input');\r\n input.setAttribute('placeholder', 'Enter text... SHIFT + ENTER for new line');\r\n input.style.border = `3px solid ${BORDER_COLOR}`;\r\n input.style.borderRadius = '3px';\r\n input.style.position = 'fixed';\r\n input.style.top = `${e.clientY}px`;\r\n input.style.left = `${e.clientX}px`;\r\n input.style.fontSize = `${_textSize}px`;\r\n input.style.zIndex = '41';\r\n input.addEventListener('blur', handleInputBlur);\r\n input.addEventListener('keyup', handleInputKeyup);\r\n\r\n document.body.appendChild(input);\r\n input.focus();\r\n}\r\n\r\n/**\r\n * Handle input.blur event\r\n */\r\nfunction handleInputBlur() {\r\n saveText();\r\n}\r\n\r\n/**\r\n * Handle input.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleInputKeyup(e) {\r\n if (e.keyCode === 27) {\r\n closeInput();\r\n }\r\n else if (e.keyCode === 13 && !e.shiftKey) {\r\n saveText();\r\n }\r\n}\r\n\r\n/**\r\n * Save a text annotation from input\r\n */\r\nfunction saveText() {\r\n let value = (input.value) ? input.value.replace(/ +$/, '') : '';\r\n if (value.length > 0) {\r\n let clientX = parseInt(input.style.left, 10);\r\n let clientY = parseInt(input.style.top, 10);\r\n let svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let height = _textSize;\r\n let { documentId, pageNumber, viewport } = getMetadata(svg);\r\n let scale = 1 / viewport.scale;\r\n let rect = svg.getBoundingClientRect();\r\n let pt = convertToSvgPoint([\r\n clientX - rect.left,\r\n clientY - rect.top + height], svg, viewport);\r\n let annotation = {\r\n type: 'textbox',\r\n size: _textSize * scale,\r\n color: _textColor,\r\n content: value,\r\n x: pt[0],\r\n y: pt[1],\r\n rotation: -viewport.rotation\r\n };\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n closeInput();\r\n}\r\n\r\n/**\r\n * Close the input\r\n */\r\nfunction closeInput() {\r\n if (input) {\r\n input.removeEventListener('blur', handleInputBlur);\r\n input.removeEventListener('keyup', handleInputKeyup);\r\n document.body.removeChild(input);\r\n input = null;\r\n }\r\n}\r\n\r\n/**\r\n * Set the text attributes\r\n *\r\n * @param {Number} textSize The size of the text\r\n * @param {String} textColor The color of the text\r\n */\r\nexport function setText(textSize = 12, textColor = '000000') {\r\n _textSize = parseInt(textSize, 10);\r\n _textColor = textColor;\r\n}\r\n\r\n/**\r\n * Enable text behavior\r\n */\r\nexport function enableText() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable text behavior\r\n */\r\nexport function disableText() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n","/**\r\n * Create a node that is only visible to screen readers\r\n *\r\n * @param {String} content The text content that should be read by screen reader\r\n * @param {String} [annotationId] The ID of the annotation assocaited\r\n * @return {Element} An Element that is only visible to screen readers\r\n */\r\nexport default function createScreenReaderOnly(content, annotationId) {\r\n let node = document.createElement('div');\r\n let text = document.createTextNode(content);\r\n node.appendChild(text);\r\n node.setAttribute('id', `pdf-annotate-screenreader-${annotationId}`);\r\n node.style.position = 'absolute';\r\n node.style.left = '-10000px';\r\n node.style.top = 'auto';\r\n node.style.width = '1px';\r\n node.style.height = '1px';\r\n node.style.overflow = 'hidden';\r\n return node;\r\n}\r\n","import config from '../config';\r\nimport {\r\n pointIntersectsRect,\r\n scaleUp,\r\n scaleDown\r\n} from '../UI/utils';\r\n\r\n/**\r\n * Insert an element at a point within the document.\r\n * This algorithm will only insert within an element amidst it's text content.\r\n *\r\n * @param {Element} el The element to be inserted\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page number to limit elements to\r\n * @param {Boolean} insertBefore Whether the element is to be inserted before or after x\r\n * @return {Boolean} True if element was able to be inserted, otherwise false\r\n */\r\nexport default function insertElementWithinElement(el, x, y, pageNumber, insertBefore) {\r\n const OFFSET_ADJUST = 2;\r\n\r\n // If inserting before adjust `x` by looking for element a few px to the right\r\n // Otherwise adjust a few px to the left\r\n // This is to allow a little tolerance by searching within the box, instead\r\n // of getting a false negative by testing right on the border.\r\n x = Math.max(x + (OFFSET_ADJUST * (insertBefore ? 1 : -1)), 0);\r\n\r\n let node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber);\r\n if (!node) {\r\n return false;\r\n }\r\n\r\n // Now that node has been found inverse the adjustment for `x`.\r\n // This is done to accomodate tolerance by cutting off on the outside of the\r\n // text boundary, instead of missing a character by cutting off within.\r\n x = x + (OFFSET_ADJUST * (insertBefore ? -1 : 1));\r\n\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let left = scaleDown(svg, {left: node.getBoundingClientRect().left}).left - svg.getBoundingClientRect().left;\r\n let temp = node.cloneNode(true);\r\n let head = temp.innerHTML.split('');\r\n let tail = [];\r\n\r\n // Insert temp off screen\r\n temp.style.position = 'absolute';\r\n temp.style.top = '-10000px';\r\n temp.style.left = '-10000px';\r\n document.body.appendChild(temp);\r\n\r\n while (head.length) {\r\n // Don't insert within HTML tags\r\n if (head[head.length - 1] === '>') {\r\n while (head.length) {\r\n tail.unshift(head.pop());\r\n if (tail[0] === '<') {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // Check if width of temp based on current head value satisfies x\r\n temp.innerHTML = head.join('');\r\n let width = scaleDown(svg, {width: temp.getBoundingClientRect().width}).width;\r\n if (left + width <= x) {\r\n break;\r\n }\r\n tail.unshift(head.pop());\r\n }\r\n\r\n // Update original node with new markup, including element to be inserted\r\n node.innerHTML = head.join('') + el.outerHTML + tail.join('');\r\n temp.parentNode.removeChild(temp);\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Get a text layer element at a given point on a page\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page to limit elements to\r\n * @return {Element} First text layer element found at the point\r\n */\r\nfunction textLayerElementFromPoint(x, y, pageNumber) {\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let rect = svg.getBoundingClientRect();\r\n y = scaleUp(svg, {y}).y + rect.top;\r\n x = scaleUp(svg, {x}).x + rect.left;\r\n return [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' [data-canvas-width]')].filter((el) => {\r\n return pointIntersectsRect(x, y, el.getBoundingClientRect());\r\n })[0];\r\n}\r\n","import config from '../config';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport { pointIntersectsRect, scaleUp } from '../UI/utils';\r\n\r\n/**\r\n * Insert an element at a point within the document.\r\n * This algorithm will try to insert between elements if possible.\r\n * It will however use `insertElementWithinElement` if it is more accurate.\r\n *\r\n * @param {Element} el The element to be inserted\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page number to limit elements to\r\n * @return {Boolean} True if element was able to be inserted, otherwise false\r\n */\r\nexport default function insertElementWithinChildren(el, x, y, pageNumber) {\r\n // Try and use most accurate method of inserting within an element\r\n if (insertElementWithinElement(el, x, y, pageNumber, true)) {\r\n return true;\r\n }\r\n\r\n // Fall back to inserting between elements\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let rect = svg.getBoundingClientRect();\r\n let nodes = [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' > div')];\r\n\r\n y = scaleUp(svg, {y}).y + rect.top;\r\n x = scaleUp(svg, {x}).x + rect.left;\r\n\r\n // Find the best node to insert before\r\n for (let i = 0, l = nodes.length; i < l; i++) {\r\n let n = nodes[i];\r\n let r = n.getBoundingClientRect();\r\n if (y <= r.top) {\r\n n.parentNode.insertBefore(el, n);\r\n return true;\r\n }\r\n }\r\n\r\n // If all else fails try to append to the bottom\r\n let textLayer = svg.parentNode.querySelector(config.textClassQuery());\r\n if (textLayer) {\r\n let textRect = textLayer.getBoundingClientRect();\r\n if (pointIntersectsRect(x, y, textRect)) {\r\n textLayer.appendChild(el);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n","/**\r\n * Insert a comment into the DOM to be available by screen reader\r\n *\r\n * @param {Object} comment The comment to be inserted\r\n */\r\nexport default function insertScreenReaderComment(comment) {\r\n if (!comment) {\r\n return;\r\n }\r\n\r\n let list = document.querySelector(`#pdf-annotate-screenreader-${comment.annotation} ol`);\r\n if (list) {\r\n let item = document.createElement('li');\r\n item.setAttribute('id', `pdf-annotate-screenreader-comment-${comment.uuid}`);\r\n item.appendChild(document.createTextNode(`${comment.content}`));\r\n list.appendChild(item);\r\n }\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport insertScreenReaderComment from './insertScreenReaderComment';\r\n\r\n/**\r\n * Insert the comments into the DOM to be available by screen reader\r\n *\r\n * Example output:\r\n *
\r\n *
Begin highlight 1
\r\n *
    \r\n *
  1. Foo
  2. \r\n *
  3. Bar
  4. \r\n *
  5. Baz
  6. \r\n *
  7. Qux
  8. \r\n *
\r\n *
\r\n *
Some highlighted text goes here...
\r\n *
End highlight 1
\r\n *\r\n * NOTE: `screenReaderOnly` is not a real class, just used for brevity\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The ID of the annotation\r\n * @param {Array} [comments] Optionally preloaded comments to be rendered\r\n * @return {Promise} Promise that once has comments, render them for screen reader\r\n */\r\nexport default function renderScreenReaderComments(documentId, annotationId, comments) {\r\n let promise;\r\n\r\n if (Array.isArray(comments)) {\r\n promise = Promise.resolve(comments);\r\n }\r\n else {\r\n promise = PDFJSAnnotate.getStoreAdapter().getComments(documentId, annotationId);\r\n }\r\n\r\n return promise.then((comments) => {\r\n // Node needs to be found by querying DOM as it may have been inserted as innerHTML\r\n // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`).\r\n let node = document.getElementById(`pdf-annotate-screenreader-${annotationId}`);\r\n if (node) {\r\n let list = document.createElement('ol');\r\n list.setAttribute('id', `pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n list.setAttribute('aria-label', 'Comments');\r\n node.appendChild(list);\r\n comments.forEach(insertScreenReaderComment);\r\n }\r\n });\r\n}\r\n","import createScreenReaderOnly from './createScreenReaderOnly';\r\nimport insertElementWithinChildren from './insertElementWithinChildren';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport renderScreenReaderComments from './renderScreenReaderComments';\r\n\r\n// Annotation types that support comments\r\nconst COMMENT_TYPES = ['highlight', 'point', 'area', 'circle', 'emptycircle', 'fillcircle'];\r\n\r\n/**\r\n * Insert a hint into the DOM for screen readers for a specific annotation.\r\n *\r\n * @param {Object} annotation The annotation to insert a hint for\r\n * @param {Number} num The number of the annotation out of all annotations of the same type\r\n */\r\nexport default function insertScreenReaderHint(annotation, num = 0) {\r\n switch (annotation.type) {\r\n case 'highlight':\r\n case 'strikeout':\r\n let rects = annotation.rectangles;\r\n let first = rects[0];\r\n let last = rects[rects.length - 1];\r\n\r\n insertElementWithinElement(\r\n createScreenReaderOnly(`Begin ${annotation.type} annotation ${num}`, annotation.uuid),\r\n first.x, first.y, annotation.page, true\r\n );\r\n\r\n insertElementWithinElement(\r\n createScreenReaderOnly(`End ${annotation.type} annotation ${num}`, `${annotation.uuid}-end`),\r\n last.x + last.width, last.y, annotation.page, false\r\n );\r\n break;\r\n\r\n case 'textbox':\r\n case 'point':\r\n let text = annotation.type === 'textbox' ? ` (content: ${annotation.content})` : '';\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`${annotation.type} annotation ${num}${text}`, annotation.uuid),\r\n annotation.x, annotation.y, annotation.page\r\n );\r\n break;\r\n\r\n case 'drawing':\r\n case 'area':\r\n let x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0];\r\n let y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1];\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\r\n x, y, annotation.page\r\n );\r\n break;\r\n\r\n case 'circle':\r\n case 'fillcircle':\r\n case 'emptycircle':\r\n let x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0];\r\n let y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1];\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\r\n x2, y2, annotation.page\r\n );\r\n break;\r\n }\r\n\r\n // Include comments in screen reader hint\r\n if (COMMENT_TYPES.includes(annotation.type)) {\r\n renderScreenReaderComments(annotation.documentId, annotation.uuid);\r\n }\r\n}\r\n","import renderScreenReaderHints from './renderScreenReaderHints';\r\nimport insertScreenReaderComment from './insertScreenReaderComment';\r\nimport renderScreenReaderComments from './renderScreenReaderComments';\r\nimport { addEventListener } from '../UI/event';\r\nimport PDFJSAnnotate from '../PDFJSAnnotate';\r\n\r\n/**\r\n * Initialize the event handlers for keeping screen reader hints synced with data\r\n */\r\nexport default function initEventHandlers() {\r\n addEventListener('annotation:add', (documentId, pageNumber, annotation) => {\r\n reorderAnnotationsByType(documentId, pageNumber, annotation.type);\r\n });\r\n addEventListener('annotation:edit', (documentId, annotationId, annotation) => {\r\n reorderAnnotationsByType(documentId, annotation.page, annotation.type);\r\n });\r\n addEventListener('annotation:delete', removeAnnotation);\r\n addEventListener('comment:add', insertComment);\r\n addEventListener('comment:delete', removeComment);\r\n}\r\n\r\n/**\r\n * Reorder the annotation numbers by annotation type\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {Number} pageNumber The page number of the annotations\r\n * @param {Strig} type The annotation type\r\n */\r\nfunction reorderAnnotationsByType(documentId, pageNumber, type) {\r\n PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, pageNumber)\r\n .then((annotations) => {\r\n return annotations.annotations.filter((a) => {\r\n return a.type === type;\r\n });\r\n })\r\n .then((annotations) => {\r\n annotations.forEach((a) => {\r\n removeAnnotation(documentId, a.uuid);\r\n });\r\n\r\n return annotations;\r\n })\r\n .then(renderScreenReaderHints);\r\n}\r\n\r\n/**\r\n * Remove the screen reader hint for an annotation\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The Id of the annotation\r\n */\r\nfunction removeAnnotation(documentId, annotationId) {\r\n removeElementById(`pdf-annotate-screenreader-${annotationId}`);\r\n removeElementById(`pdf-annotate-screenreader-${annotationId}-end`);\r\n}\r\n\r\n/**\r\n * Insert a screen reader hint for a comment\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The ID of tha assocated annotation\r\n * @param {Object} comment The comment to insert a hint for\r\n */\r\nfunction insertComment(documentId, annotationId, comment) {\r\n let list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n let promise;\r\n\r\n if (!list) {\r\n promise = renderScreenReaderComments(documentId, annotationId, []).then(() => {\r\n list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n return true;\r\n });\r\n }\r\n else {\r\n promise = Promise.resolve(true);\r\n }\r\n\r\n promise.then(() => {\r\n insertScreenReaderComment(comment);\r\n });\r\n}\r\n\r\n/**\r\n * Remove a screen reader hint for a comment\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} commentId The ID of the comment\r\n */\r\nfunction removeComment(documentId, commentId) {\r\n removeElementById(`pdf-annotate-screenreader-comment-${commentId}`);\r\n}\r\n\r\n/**\r\n * Remove an element from the DOM by it's ID if it exists\r\n *\r\n * @param {String} elementId The ID of the element to be removed\r\n */\r\nfunction removeElementById(elementId) {\r\n let el = document.getElementById(elementId);\r\n if (el) {\r\n el.parentNode.removeChild(el);\r\n }\r\n}\r\n","import insertScreenReaderHint from './insertScreenReaderHint';\r\nimport initEventHandlers from './initEventHandlers';\r\n\r\n// TODO This is not the right place for this to live\r\ninitEventHandlers();\r\n\r\n/**\r\n * Insert hints into the DOM for screen readers.\r\n *\r\n * @param {Array} annotations The annotations that hints are inserted for\r\n */\r\nexport default function renderScreenReaderHints(annotations) {\r\n annotations = Array.isArray(annotations) ? annotations : [];\r\n\r\n // Insert hints for each type\r\n Object.keys(SORT_TYPES).forEach((type) => {\r\n let sortBy = SORT_TYPES[type];\r\n annotations\r\n .filter((a) => a.type === type)\r\n .sort(sortBy)\r\n .forEach((a, i) => insertScreenReaderHint(a, i + 1));\r\n });\r\n}\r\n\r\n// Sort annotations first by y, then by x.\r\n// This allows hints to be injected in the order they appear,\r\n// which makes numbering them easier.\r\nfunction sortByPoint(a, b) {\r\n if (a.y < b.y) {\r\n return a.x - b.x;\r\n }\r\n else {\r\n return 1;\r\n }\r\n}\r\n\r\n// Sort annotation by it's first rectangle\r\nfunction sortByRectPoint(a, b) {\r\n return sortByPoint(a.rectangles[0], b.rectangles[0]);\r\n}\r\n\r\n// Sort annotation by it's first line\r\nfunction sortByLinePoint(a, b) {\r\n let lineA = a.lines[0];\r\n let lineB = b.lines[0];\r\n return sortByPoint(\r\n {x: lineA[0], y: lineA[1]},\r\n {x: lineB[0], y: lineB[1]}\r\n );\r\n}\r\n\r\n// Arrange supported types and associated sort methods\r\nconst SORT_TYPES = {\r\n 'highlight': sortByRectPoint,\r\n 'strikeout': sortByRectPoint,\r\n 'drawing': sortByLinePoint,\r\n 'textbox': sortByPoint,\r\n 'point': sortByPoint,\r\n 'area': sortByPoint\r\n};\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport renderScreenReaderHints from '../a11y/renderScreenReaderHints';\r\n\r\n// Template for creating a new page\r\nconst PAGE_TEMPLATE = `\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n`;\r\n\r\n/**\r\n * Create a new page to be appended to the DOM.\r\n *\r\n * @param {Number} pageNumber The page number that is being created\r\n * @return {HTMLElement}\r\n */\r\nexport function createPage(pageNumber) {\r\n let temp = document.createElement('div');\r\n temp.innerHTML = PAGE_TEMPLATE;\r\n\r\n let page = temp.children[0];\r\n let canvas = page.querySelector('canvas');\r\n\r\n page.setAttribute('id', `pageContainer${pageNumber}`);\r\n page.setAttribute('data-page-number', pageNumber);\r\n\r\n canvas.mozOpaque = true;\r\n canvas.setAttribute('id', `page${pageNumber}`);\r\n\r\n return page;\r\n}\r\n\r\n/**\r\n * Render a page that has already been created.\r\n *\r\n * @param {Number} pageNumber The page number to be rendered\r\n * @param {Object} renderOptions The options for rendering\r\n * @return {Promise} Settled once rendering has completed\r\n * A settled Promise will be either:\r\n * - fulfilled: [pdfPage, annotations]\r\n * - rejected: Error\r\n */\r\nexport function renderPage(pageNumber, renderOptions) {\r\n let {\r\n documentId,\r\n pdfDocument,\r\n scale,\r\n rotate\r\n } = renderOptions;\r\n\r\n const eventBus = new pdfjsViewer.EventBus();\r\n\r\n // Load the page and annotations\r\n return Promise.all([\r\n pdfDocument.getPage(pageNumber),\r\n PDFJSAnnotate.getAnnotations(documentId, pageNumber)\r\n ]).then(([pdfPage, annotations]) => {\r\n let page = document.getElementById(`pageContainer${pageNumber}`);\r\n let svg = page.querySelector(config.annotationClassQuery());\r\n let canvas = page.querySelector('.canvasWrapper canvas');\r\n let canvasContext = canvas.getContext('2d', {alpha: false});\r\n let totalRotation = (rotate + pdfPage.rotate) % 360;\r\n let viewport = pdfPage.getViewport({scale: scale, rotation: totalRotation});\r\n let transform = scalePage(pageNumber, viewport, canvasContext);\r\n\r\n // Render the page\r\n return Promise.all([\r\n pdfPage.render({ canvasContext, viewport, transform }).promise,\r\n PDFJSAnnotate.render(svg, viewport, annotations)\r\n ]).then(() => {\r\n // Text content is needed for a11y, but is also necessary for creating\r\n // highlight and strikeout annotations which require selecting text.\r\n return pdfPage.getTextContent({normalizeWhitespace: true}).then((textContent) => {\r\n return new Promise((resolve, reject) => {\r\n // Render text layer for a11y of text content\r\n let textLayer = page.querySelector(config.textClassQuery());\r\n let textLayerFactory = new pdfjsViewer.DefaultTextLayerFactory();\r\n let textLayerBuilder = textLayerFactory.createTextLayerBuilder(\r\n textLayer,\r\n pageNumber - 1,\r\n viewport,\r\n false,\r\n eventBus\r\n );\r\n textLayerBuilder.setTextContent(textContent);\r\n textLayerBuilder.render();\r\n\r\n // Enable a11y for annotations\r\n // Timeout is needed to wait for `textLayerBuilder.render`\r\n setTimeout(() => {\r\n try {\r\n renderScreenReaderHints(annotations.annotations);\r\n resolve();\r\n }\r\n catch (e) {\r\n reject(e);\r\n }\r\n });\r\n });\r\n });\r\n }).then(() => {\r\n // Indicate that the page was loaded\r\n page.setAttribute('data-loaded', 'true');\r\n\r\n return [pdfPage, annotations];\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Scale the elements of a page.\r\n *\r\n * @param {Number} pageNumber The page number to be scaled\r\n * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate))\r\n * @param {Object} context The canvas context that the PDF page is rendered to\r\n * @return {Array} The transform data for rendering the PDF page\r\n */\r\nfunction scalePage(pageNumber, viewport, context) {\r\n let page = document.getElementById(`pageContainer${pageNumber}`);\r\n let canvas = page.querySelector('.canvasWrapper canvas');\r\n let svg = page.querySelector(config.annotationClassQuery());\r\n let wrapper = page.querySelector('.canvasWrapper');\r\n let textLayer = page.querySelector(config.textClassQuery());\r\n let outputScale = getOutputScale(context);\r\n let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];\r\n let sfx = approximateFraction(outputScale.sx);\r\n let sfy = approximateFraction(outputScale.sy);\r\n\r\n // Adjust width/height for scale\r\n page.style.visibility = '';\r\n canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);\r\n canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);\r\n canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';\r\n canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';\r\n svg.setAttribute('width', viewport.width);\r\n svg.setAttribute('height', viewport.height);\r\n svg.style.width = `${viewport.width}px`;\r\n svg.style.height = `${viewport.height}px`;\r\n page.style.width = `${viewport.width}px`;\r\n page.style.height = `${viewport.height}px`;\r\n wrapper.style.width = `${viewport.width}px`;\r\n wrapper.style.height = `${viewport.height}px`;\r\n textLayer.style.width = `${viewport.width}px`;\r\n textLayer.style.height = `${viewport.height}px`;\r\n\r\n return transform;\r\n}\r\n\r\n/**\r\n * Approximates a float number as a fraction using Farey sequence (max order of 8).\r\n *\r\n * @param {Number} x Positive float number\r\n * @return {Array} Estimated fraction: the first array item is a numerator,\r\n * the second one is a denominator.\r\n */\r\nfunction approximateFraction(x) {\r\n // Fast path for int numbers or their inversions.\r\n if (Math.floor(x) === x) {\r\n return [x, 1];\r\n }\r\n\r\n const xinv = 1 / x;\r\n const limit = 8;\r\n if (xinv > limit) {\r\n return [1, limit];\r\n }\r\n else if (Math.floor(xinv) === xinv) {\r\n return [1, xinv];\r\n }\r\n\r\n const x_ = x > 1 ? xinv : x;\r\n\r\n // a/b and c/d are neighbours in Farey sequence.\r\n let a = 0; let b = 1; let c = 1; let d = 1;\r\n\r\n // Limit search to order 8.\r\n while (true) {\r\n // Generating next term in sequence (order of q).\r\n let p = a + c; let q = b + d;\r\n if (q > limit) {\r\n break;\r\n }\r\n if (x_ <= p / q) {\r\n c = p; d = q;\r\n }\r\n else {\r\n a = p; b = q;\r\n }\r\n }\r\n\r\n // Select closest of neighbours to x.\r\n if (x_ - a / b < c / d - x_) {\r\n return x_ === x ? [a, b] : [b, a];\r\n }\r\n else {\r\n return x_ === x ? [c, d] : [d, c];\r\n }\r\n}\r\n\r\nfunction getOutputScale(ctx) {\r\n let devicePixelRatio = window.devicePixelRatio || 1;\r\n let backingStoreRatio = ctx.webkitBackingStorePixelRatio ||\r\n ctx.mozBackingStorePixelRatio ||\r\n ctx.msBackingStorePixelRatio ||\r\n ctx.oBackingStorePixelRatio ||\r\n ctx.backingStorePixelRatio || 1;\r\n let pixelRatio = devicePixelRatio / backingStoreRatio;\r\n return {\r\n sx: pixelRatio,\r\n sy: pixelRatio,\r\n scaled: pixelRatio !== 1\r\n };\r\n}\r\n\r\nfunction roundToDivide(x, div) {\r\n let r = x % div;\r\n return r === 0 ? x : Math.round(x - r + div);\r\n}\r\n","import { addEventListener, removeEventListener, fireEvent } from './event';\r\nimport { disableEdit, enableEdit } from './edit';\r\nimport { disablePen, enablePen, setPen } from './pen';\r\nimport { disableArrow, enableArrow, setArrow } from './arrow';\r\nimport { disableEraser, enableEraser } from './eraser';\r\nimport { disablePoint, enablePoint } from './point';\r\nimport { disableRect, enableRect } from './rect';\r\nimport { disableCircle, enableCircle, setCircle, addCircle } from './circle';\r\nimport { disableText, enableText, setText } from './text';\r\nimport { createPage, renderPage } from './page';\r\n\r\nexport default {\r\n addEventListener,\r\n removeEventListener,\r\n fireEvent,\r\n\r\n disableEdit,\r\n enableEdit,\r\n\r\n disablePen,\r\n enablePen,\r\n setPen,\r\n\r\n disablePoint,\r\n enablePoint,\r\n\r\n disableRect,\r\n enableRect,\r\n\r\n disableCircle,\r\n enableCircle,\r\n setCircle,\r\n addCircle,\r\n\r\n disableArrow,\r\n enableArrow,\r\n setArrow,\r\n\r\n disableEraser,\r\n enableEraser,\r\n\r\n disableText,\r\n enableText,\r\n setText,\r\n\r\n createPage,\r\n renderPage\r\n};\r\n","import StoreAdapter from './adapter/StoreAdapter';\r\nimport LocalStoreAdapter from './adapter/LocalStoreAdapter';\r\nimport LocalUserStoreAdapter from './adapter/LocalUserStoreAdapter';\r\nimport render from './render';\r\nimport UI from './UI';\r\nimport config from './config';\r\nimport uuid from './utils/uuid';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGContainer,\r\n convertToScreenPoint\r\n} from './UI/utils';\r\n\r\nexport default {\r\n findAnnotationAtPoint,\r\n findSVGContainer,\r\n convertToScreenPoint,\r\n\r\n /**\r\n * Abstract class that needs to be defined so PDFJSAnnotate\r\n * knows how to communicate with your server.\r\n */\r\n StoreAdapter,\r\n\r\n /**\r\n * Implementation of StoreAdapter that stores annotation data to localStorage.\r\n */\r\n LocalStoreAdapter,\r\n\r\n /**\r\n * Implementation of StoreAdapter that stores annotation data to localStorage particular\r\n * to a specific user\r\n */\r\n LocalUserStoreAdapter,\r\n\r\n /**\r\n * Abstract instance of StoreAdapter\r\n */\r\n __storeAdapter: new StoreAdapter(),\r\n\r\n /**\r\n * Getter for the underlying StoreAdapter property\r\n *\r\n * @return {StoreAdapter}\r\n */\r\n getStoreAdapter() {\r\n return this.__storeAdapter;\r\n },\r\n\r\n /**\r\n * Setter for the underlying StoreAdapter property\r\n *\r\n * @param {StoreAdapter} adapter The StoreAdapter implementation to be used.\r\n */\r\n setStoreAdapter(adapter) {\r\n // TODO this throws an error when bundled\r\n // if (!(adapter instanceof StoreAdapter)) {\r\n // throw new Error('adapter must be an instance of StoreAdapter');\r\n // }\r\n\r\n this.__storeAdapter = adapter;\r\n },\r\n\r\n /**\r\n * UI is a helper for instrumenting UI interactions for creating,\r\n * editing, and deleting annotations in the browser.\r\n */\r\n UI,\r\n\r\n /**\r\n * Render the annotations for a page in the PDF Document\r\n *\r\n * @param {SVGElement} svg The SVG element that annotations should be rendered to\r\n * @param {PageViewport} viewport The PDFPage.getViewport data\r\n * @param {Object} data The StoreAdapter.getAnnotations data\r\n * @return {Promise}\r\n */\r\n render,\r\n\r\n /**\r\n * Convenience method for getting annotation data\r\n *\r\n * @alias StoreAdapter.getAnnotations\r\n * @param {String} documentId The ID of the document\r\n * @param {String} pageNumber The page number\r\n * @return {Promise}\r\n */\r\n getAnnotations(documentId, pageNumber) {\r\n return this.getStoreAdapter().getAnnotations(...arguments);\r\n },\r\n\r\n config,\r\n\r\n uuid\r\n};\r\n","import { appendChild, transformChild } from './appendChild';\r\n\r\n/**\r\n * Render the response from PDFJSAnnotate.getStoreAdapter().getAnnotations to SVG\r\n *\r\n * @param {SVGElement} svg The SVG element to render the annotations to\r\n * @param {Object} viewport The page viewport data\r\n * @param {Object} data The response from PDFJSAnnotate.getStoreAdapter().getAnnotations\r\n * @return {Promise} Settled once rendering has completed\r\n * A settled Promise will be either:\r\n * - fulfilled: SVGElement\r\n * - rejected: Error\r\n */\r\nexport default function render(svg, viewport, data) {\r\n return new Promise((resolve, reject) => {\r\n // Reset the content of the SVG\r\n svg.setAttribute('data-pdf-annotate-container', true);\r\n svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport));\r\n svg.removeAttribute('data-pdf-annotate-document');\r\n svg.removeAttribute('data-pdf-annotate-page');\r\n\r\n // If there's no data nothing can be done\r\n if (!data) {\r\n svg.innerHTML = '';\r\n return resolve(svg);\r\n }\r\n\r\n svg.setAttribute('data-pdf-annotate-document', data.documentId);\r\n svg.setAttribute('data-pdf-annotate-page', data.pageNumber);\r\n\r\n // Make sure annotations is an array\r\n if (!Array.isArray(data.annotations) || data.annotations.length === 0) {\r\n return resolve(svg);\r\n }\r\n\r\n // Append or transform annotation to svg\r\n data.annotations.forEach((a) => {\r\n let node = svg.querySelector('[data-pdf-annotate-id=\"' + a.uuid + '\"]');\r\n if (node) {\r\n transformChild(svg, node, viewport);\r\n }\r\n else {\r\n appendChild(svg, a, viewport);\r\n }\r\n });\r\n\r\n resolve(svg);\r\n });\r\n}\r\n","import PDFJSAnnotate from './src/PDFJSAnnotate';\r\n\r\nexport default PDFJSAnnotate;\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"pdf-annotate.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,MAAM,I,gCCcT,IAOIC,EAPAC,EAAuB,iBAAZC,QAAuBA,QAAU,KAC5CC,EAAeF,GAAwB,mBAAZA,EAAEG,MAC7BH,EAAEG,MACF,SAAsBC,EAAQC,EAAUC,GACxC,OAAOC,SAASC,UAAUL,MAAMM,KAAKL,EAAQC,EAAUC,EACzD,EAIAP,EADEC,GAA0B,mBAAdA,EAAEU,QACCV,E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IE3FF,M","sources":["webpack://PDFAnnotate/webpack/universalModuleDefinition","webpack://PDFAnnotate/./node_modules/events/events.js","webpack://PDFAnnotate/webpack/bootstrap","webpack://PDFAnnotate/webpack/runtime/compat get default export","webpack://PDFAnnotate/webpack/runtime/define property getters","webpack://PDFAnnotate/webpack/runtime/hasOwnProperty shorthand","webpack://PDFAnnotate/webpack/runtime/make namespace object","webpack://PDFAnnotate/./src/utils/abstractFunction.js","webpack://PDFAnnotate/./src/utils/setAttributes.js","webpack://PDFAnnotate/./src/utils/normalizeColor.js","webpack://PDFAnnotate/./src/render/renderPoint.js","webpack://PDFAnnotate/./src/render/renderRect.js","webpack://PDFAnnotate/./src/render/renderText.js","webpack://PDFAnnotate/./src/utils/mathUtils.js","webpack://PDFAnnotate/./src/render/appendChild.js","webpack://PDFAnnotate/./src/render/renderLine.js","webpack://PDFAnnotate/./src/render/renderCircle.js","webpack://PDFAnnotate/./src/render/renderPath.js","webpack://PDFAnnotate/./src/render/renderArrow.js","webpack://PDFAnnotate/./src/UI/utils.js","webpack://PDFAnnotate/./src/UI/event.js","webpack://PDFAnnotate/./src/adapter/StoreAdapter.js","webpack://PDFAnnotate/./src/utils/uuid.js","webpack://PDFAnnotate/./src/adapter/LocalStoreAdapter.js","webpack://PDFAnnotate/./src/adapter/LocalUserStoreAdapter.js","webpack://PDFAnnotate/./src/config.js","webpack://PDFAnnotate/./src/UI/edit.js","webpack://PDFAnnotate/./src/UI/pen.js","webpack://PDFAnnotate/./src/UI/arrow.js","webpack://PDFAnnotate/./src/UI/eraser.js","webpack://PDFAnnotate/./src/UI/point.js","webpack://PDFAnnotate/./src/UI/rect.js","webpack://PDFAnnotate/./src/UI/circle.js","webpack://PDFAnnotate/./src/UI/text.js","webpack://PDFAnnotate/./src/a11y/createScreenReaderOnly.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinElement.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinChildren.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderComment.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderComments.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderHint.js","webpack://PDFAnnotate/./src/a11y/initEventHandlers.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderHints.js","webpack://PDFAnnotate/./src/UI/page.js","webpack://PDFAnnotate/./src/UI/index.js","webpack://PDFAnnotate/./src/PDFJSAnnotate.js","webpack://PDFAnnotate/./src/render/index.js","webpack://PDFAnnotate/./index.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PDFAnnotate\"] = factory();\n\telse\n\t\troot[\"PDFAnnotate\"] = factory();\n})(self, () => {\nreturn ","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Throw an Error for an abstract function that hasn't been implemented.\n *\n * @param {String} name The name of the abstract function\n */\nexport default function abstractFunction(name) {\n throw new Error(name + ' is not implemented');\n}\n","const UPPER_REGEX = /[A-Z]/g;\n\n// Don't convert these attributes from camelCase to hyphenated-attributes\nconst BLACKLIST = [\n 'viewBox'\n];\n\nlet keyCase = (key) => {\n if (BLACKLIST.indexOf(key) === -1) {\n key = key.replace(UPPER_REGEX, match => '-' + match.toLowerCase());\n }\n return key;\n};\n\n/**\n * Set attributes for a node from a map\n *\n * @param {Node} node The node to set attributes on\n * @param {Object} attributes The map of key/value pairs to use for attributes\n */\nexport default function setAttributes(node, attributes) {\n Object.keys(attributes).forEach((key) => {\n node.setAttribute(keyCase(key), attributes[key]);\n });\n}\n","const REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i;\n\n/**\n * Normalize a color value\n *\n * @param {String} color The color to normalize\n * @return {String}\n */\nexport default function normalizeColor(color) {\n if (REGEX_HASHLESS_HEX.test(color)) {\n color = `#${color}`;\n }\n return color;\n}\n","import setAttributes from '../utils/setAttributes';\n\nconst SIZE = 25;\nconst D = 'M499.968 214.336q-113.832 0 -212.877 38.781t-157.356 104.625 -58.311 142.29q0 62.496 39.897 119.133t112.437 97.929l48.546 27.9 -15.066 53.568q-13.392 50.778 -39.06 95.976 84.816 -35.154 153.45 -95.418l23.994 -21.204 31.806 3.348q38.502 4.464 72.54 4.464 113.832 0 212.877 -38.781t157.356 -104.625 58.311 -142.29 -58.311 -142.29 -157.356 -104.625 -212.877 -38.781z';\n\n/**\n * Create SVGElement from an annotation definition.\n * This is used for anntations of type `comment`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGElement} A svg to be rendered\n */\nexport default function renderPoint(a) {\n let outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n let innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\n setAttributes(outerSVG, {\n width: SIZE,\n height: SIZE,\n x: a.x,\n y: a.y\n });\n\n setAttributes(innerSVG, {\n width: SIZE,\n height: SIZE,\n x: 0,\n y: (SIZE * 0.05) * -1,\n viewBox: '0 0 1000 1000'\n });\n\n setAttributes(rect, {\n width: SIZE,\n height: SIZE,\n stroke: '#000',\n fill: '#ff0'\n });\n\n setAttributes(path, {\n d: D,\n strokeWidth: 50,\n stroke: '#000',\n fill: '#fff'\n });\n\n innerSVG.appendChild(path);\n outerSVG.appendChild(rect);\n outerSVG.appendChild(innerSVG);\n\n return outerSVG;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGRectElements from an annotation definition.\n * This is used for anntations of type `area` and `highlight`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered\n */\nexport default function renderRect(a) {\n if (a.type === 'highlight') {\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n setAttributes(group, {\n fill: normalizeColor(a.color || '#ff0'),\n fillOpacity: 0.2\n });\n\n a.rectangles.forEach((r) => {\n group.appendChild(createRect(r));\n });\n\n return group;\n }\n else {\n let rect = createRect(a);\n setAttributes(rect, {\n stroke: normalizeColor(a.color || '#f00'),\n fill: 'none'\n });\n\n return rect;\n }\n}\n\nfunction createRect(r) {\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n\n setAttributes(rect, {\n x: r.x,\n y: r.y,\n width: r.width,\n height: r.height\n });\n\n return rect;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Wrap each line of given text in a `` element and append these\n * lines to the given SVGTextElement\n *\n * @param {SVGTextElement} textElement A text element to hold the split text\n * @param {String} textContent String to render with line breaks\n */\nfunction insertLineBreaks(textElement, textContent) {\n const lines = (textContent || '').split('\\n');\n // can't use dy attribute here since we want empty lines to take up space as well,\n // so we will update y manually based on font size\n const x = textElement.getAttribute('x');\n let y = Number(textElement.getAttribute('y'));\n const size = Number(textElement.getAttribute('font-size'));\n for (const line of lines) {\n const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');\n tspan.setAttribute('y', y.toString());\n tspan.setAttribute('x', x);\n tspan.innerHTML = line;\n textElement.appendChild(tspan);\n\n y += size;\n }\n}\n\n/**\n * Create SVGTextElement from an annotation definition.\n * This is used for anntations of type `textbox`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGTextElement} A text to be rendered\n */\nexport default function renderText(a) {\n // Text should be rendered at 0 degrees relative to\n // document rotation\n let text = document.createElementNS('http://www.w3.org/2000/svg', 'text');\n setAttributes(text, {\n x: a.x,\n y: a.y,\n fill: normalizeColor(a.color || '#000'),\n fontSize: a.size,\n transform: `rotate(${a.rotation})`,\n style: 'white-space: pre'\n });\n\n insertLineBreaks(text, a.content);\n\n let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n g.appendChild(text);\n\n return g;\n}\n","// Transform point by matrix\n//\nexport function applyTransform(p, m) {\n return [\n p[0] * m[0] + p[1] * m[2] + m[4],\n p[0] * m[1] + p[1] * m[3] + m[5]\n ];\n};\n\n// Transform point by matrix inverse\n//\nexport function applyInverseTransform(p, m) {\n let d = m[0] * m[3] - m[1] * m[2];\n return [\n (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d,\n (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d\n ];\n};\n\n// Concatenates two transformation matrices together and returns the result.\nexport function transform(m1, m2) {\n return [\n m1[0] * m2[0] + m1[2] * m2[1],\n m1[1] * m2[0] + m1[3] * m2[1],\n m1[0] * m2[2] + m1[2] * m2[3],\n m1[1] * m2[2] + m1[3] * m2[3],\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5]\n ];\n};\n\nexport function translate(m, x, y) {\n return [\n m[0],\n m[1],\n m[2],\n m[3],\n m[0] * x + m[2] * y + m[4],\n m[1] * x + m[3] * y + m[5]\n ];\n};\n\nexport function rotate(m, angle) {\n angle = angle * Math.PI / 180;\n\n let cosValue = Math.cos(angle);\n let sinValue = Math.sin(angle);\n\n return [\n m[0] * cosValue + m[2] * sinValue,\n m[1] * cosValue + m[3] * sinValue,\n m[0] * (-sinValue) + m[2] * cosValue,\n m[1] * (-sinValue) + m[3] * cosValue,\n m[4],\n m[5]\n ];\n};\n\nexport function scale(m, x, y) {\n return [\n m[0] * x,\n m[1] * x,\n m[2] * y,\n m[3] * y,\n m[4],\n m[5]\n ];\n};\n\nexport function makePoint(x, y, z) {\n return { x: x, y: y, z: z };\n};\n\nexport function makeVector(xcoord, ycoord, zcoord) {\n return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord };\n};\n\nexport function makeVectorFromPoints(pt1, pt2) {\n let xcoord = pt2.x - pt1.x;\n let ycoord = pt2.y - pt1.y;\n let zcoord = pt2.z - pt1.z;\n return makeVector(xcoord, ycoord, zcoord);\n};\n\nexport function addVector(pt, v) {\n return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord);\n};\n\nexport function multiplyVector(v, scalar) {\n return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar);\n};\n\nexport function magnitude(v) {\n return Math.sqrt(\n Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)\n );\n};\n\nexport function negateVector(v) {\n return multiplyVector(v, -1);\n};\n\nexport function unitVector(v) {\n let mag = magnitude(v);\n let xcoord = v.xcoord / mag;\n let ycoord = v.ycoord / mag;\n let zcoord = v.zcoord / mag;\n return makeVector(xcoord, ycoord, zcoord);\n};\n\nexport function crossProduct(u, v) {\n //\n // u X v = < u2*v3 - u3*v2,\n // u3*v1 - u1*v3,\n // u1*v2 - u2*v1 >\n let xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord;\n let ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord;\n let zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord;\n return makeVector(xcoord, ycoord, zcoord);\n};\n","import renderLine from './renderLine';\nimport renderPath from './renderPath';\nimport renderPoint from './renderPoint';\nimport renderRect from './renderRect';\nimport renderText from './renderText';\nimport renderCircle from './renderCircle';\nimport renderArrow from './renderArrow';\n\nconst isFirefox = /firefox/i.test(navigator.userAgent);\n\n/**\n * Get the x/y translation to be used for transforming the annotations\n * based on the rotation of the viewport.\n *\n * @param {Object} viewport The viewport data from the page\n * @return {Object}\n */\nexport function getTranslation(viewport) {\n let x;\n let y;\n\n // Modulus 360 on the rotation so that we only\n // have to worry about four possible values.\n switch (viewport.rotation % 360) {\n case 0:\n x = y = 0;\n break;\n case 90:\n x = 0;\n y = (viewport.width / viewport.scale) * -1;\n break;\n case 180:\n x = (viewport.width / viewport.scale) * -1;\n y = (viewport.height / viewport.scale) * -1;\n break;\n case 270:\n x = (viewport.height / viewport.scale) * -1;\n y = 0;\n break;\n }\n\n return { x, y };\n}\n\n/**\n * Transform the rotation and scale of a node using SVG's native transform attribute.\n *\n * @param {Node} node The node to be transformed\n * @param {Object} viewport The page's viewport data\n * @return {Node}\n */\nfunction transform(node, viewport) {\n let trans = getTranslation(viewport);\n\n // Let SVG natively transform the element\n node.setAttribute('transform', `scale(${viewport.scale}) rotate(${viewport.rotation}) translate(${trans.x}, ${trans.y})`);\n\n // Manually adjust x/y for nested SVG nodes\n if (!isFirefox && node.nodeName.toLowerCase() === 'svg') {\n node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale);\n node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale);\n\n let x = parseInt(node.getAttribute('x', 10));\n let y = parseInt(node.getAttribute('y', 10));\n let width = parseInt(node.getAttribute('width'), 10);\n let height = parseInt(node.getAttribute('height'), 10);\n let path = node.querySelector('path');\n let svg = path.parentNode;\n\n // Scale width/height\n [node, svg, path, node.querySelector('rect')].forEach((n) => {\n n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale);\n n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale);\n });\n\n // Transform path but keep scale at 100% since it will be handled natively\n transform(path, Object.assign({}, viewport, { scale: 1 }));\n\n switch (viewport.rotation % 360) {\n case 90:\n node.setAttribute('x', viewport.width - y - width);\n node.setAttribute('y', x);\n svg.setAttribute('x', 1);\n svg.setAttribute('y', 0);\n break;\n case 180:\n node.setAttribute('x', viewport.width - x - width);\n node.setAttribute('y', viewport.height - y - height);\n svg.setAttribute('y', 2);\n break;\n case 270:\n node.setAttribute('x', y);\n node.setAttribute('y', viewport.height - x - height);\n svg.setAttribute('x', -1);\n svg.setAttribute('y', 0);\n break;\n }\n }\n\n return node;\n}\n\n/**\n * Append an annotation as a child of an SVG.\n *\n * @param {SVGElement} svg The SVG element to append the annotation to\n * @param {Object} annotation The annotation definition to render and append\n * @param {Object} viewport The page's viewport data\n * @return {SVGElement} A node that was created and appended by this function\n */\nexport function appendChild(svg, annotation, viewport) {\n if (!viewport) {\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\n }\n\n let child;\n switch (annotation.type) {\n case 'area':\n case 'highlight':\n child = renderRect(annotation);\n break;\n case 'circle':\n case 'fillcircle':\n case 'emptycircle':\n child = renderCircle(annotation);\n break;\n case 'strikeout':\n child = renderLine(annotation);\n break;\n case 'point':\n child = renderPoint(annotation);\n break;\n case 'textbox':\n child = renderText(annotation);\n break;\n case 'drawing':\n child = renderPath(annotation);\n break;\n case 'arrow':\n child = renderArrow(annotation);\n break;\n }\n\n // If no type was provided for an annotation it will result in node being null.\n // Skip appending/transforming if node doesn't exist.\n if (child) {\n // Set attributes\n child.setAttribute('data-pdf-annotate-id', annotation.uuid);\n child.setAttribute('aria-hidden', true);\n\n // Dynamically set any other attributes associated with annotation that is not related to drawing it\n Object.keys(annotation).filter((key) => {\n return ['color', 'x', 'y', 'cx', 'cy', 'color', 'documentId', 'lines', 'page',\n 'width', 'class', 'content', 'size', 'rotation', 'r'].indexOf(key) === -1;\n }).forEach((key) => {\n child.setAttribute(`data-pdf-annotate-${key}`, annotation[key]);\n });\n\n svg.appendChild(transform(child, viewport));\n }\n\n return child;\n}\n\n/**\n * Transform a child annotation of an SVG.\n *\n * @param {SVGElement} svg The SVG element with the child annotation\n * @param {Object} child The SVG child to transform\n * @param {Object} viewport The page's viewport data\n * @return {SVGElement} A node that was transformed by this function\n */\nexport function transformChild(svg, child, viewport) {\n if (!viewport) {\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\n }\n\n // If no type was provided for an annotation it will result in node being null.\n // Skip transforming if node doesn't exist.\n if (child) {\n child = transform(child, viewport);\n }\n\n return child;\n}\n\nexport default {\n /**\n * Get the x/y translation to be used for transforming the annotations\n * based on the rotation of the viewport.\n */\n getTranslation,\n\n /**\n * Append an SVG child for an annotation\n */\n appendChild,\n\n /**\n * Transform an existing SVG child\n */\n transformChild\n};\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGLineElements from an annotation definition.\n * This is used for anntations of type `strikeout`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement} A group of all lines to be rendered\n */\nexport default function renderLine(a) {\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n setAttributes(group, {\n stroke: normalizeColor(a.color || '#f00'),\n strokeWidth: 1\n });\n\n a.rectangles.forEach((r) => {\n let line = document.createElementNS('http://www.w3.org/2000/svg', 'line');\n\n setAttributes(line, {\n x1: r.x,\n y1: r.y,\n x2: r.x + r.width,\n y2: r.y\n });\n\n group.appendChild(line);\n });\n\n return group;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create an SVGCircleElement from an annotation definition.\n * This is used for annotations of type `circle`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement|SVGCircleElement} A circle to be rendered\n */\nexport default function renderCircle(a) {\n let circle = createCircle(a);\n let color = normalizeColor(a.color || '#f00');\n\n if (a.type === 'circle') {\n setAttributes(circle, {\n stroke: color,\n fill: 'none',\n 'stroke-width': 5\n });\n }\n if (a.type === 'emptycircle') {\n setAttributes(circle, {\n stroke: color,\n fill: 'none',\n 'stroke-width': 2\n });\n }\n\n if (a.type === 'fillcircle') {\n setAttributes(circle, {\n stroke: color,\n fill: color,\n 'stroke-width': 5\n });\n }\n\n return circle;\n}\n\nfunction createCircle(a) {\n let circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\n setAttributes(circle, {\n cx: a.cx,\n cy: a.cy,\n r: a.r\n });\n\n return circle;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGPathElement from an annotation definition.\n * This is used for anntations of type `drawing`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGPathElement} The path to be rendered\n */\nexport default function renderPath(a) {\n let d = [];\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\n if (a.lines.length > 0) {\n d.push(`M${a.lines[0][0]} ${a.lines[0][1]}`);\n for (let i = 1, l = a.lines.length; i < l; i++) {\n let p1 = a.lines[i];\n let p2 = a.lines[i + 1];\n if (p2) {\n d.push(`L${p1[0]} ${p1[1]}`);\n }\n }\n }\n\n /*\n\n if(a.lines.length>2) {\n var p1 = a.lines[0];\n var p2 = a.lines[a.lines.length-1];\n\n var p3 = []; //arrow\n var p4 = [];\n var p0 = []; //arrow intersection\n\n if (p2) {\n var k = -(p2[0]-p1[0])/(p2[1]-p1[1]);\n\n var deltaX = 3;\n p0[0] = p1[0]+0.8*(p2[0]-p1[0]);\n p0[1] = p1[1]+0.8*(p2[1]-p1[1]);\n\n p3[0] = p0[0] + deltaX;\n p3[1] = p0[1] + k*deltaX;\n\n p4[0] = p0[0] - deltaX;\n p4[1] = p0[1] - k*deltaX;\n\n if(Math.abs(p2[1]-p1[1]) < 20) {\n\n p3[0] = p0[0] ;\n p3[1] = p0[1] + deltaX*1;\n\n p4[0] = p0[0] ;\n p4[1] = p0[1] - deltaX*1;\n\n }\n\n d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\n //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\n d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`);\n d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`);\n d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`);\n }\n } */\n\n setAttributes(path, {\n d: `${d.join(' ')}`, // `${d.join(' ')}Z`,\n stroke: normalizeColor(a.color || '#000'),\n strokeWidth: a.width || 1,\n fill: 'none'\n });\n\n return path;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\nimport {\n makePoint, makeVector, makeVectorFromPoints,\n magnitude, unitVector, crossProduct,\n addVector, multiplyVector, negateVector\n} from '../utils/mathUtils';\n\n/**\n * Create SVGPathElement from an annotation definition.\n * This is used for anntations of type `drawing`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGPathElement} The path to be rendered\n */\nexport default function renderArrow(a) {\n let arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');\n\n if (a.lines.length === 2) {\n let p1 = a.lines[0];\n let p2 = a.lines[a.lines.length - 1];\n\n let arrowLength = 40;\n let pt0 = makePoint(p1[0], p1[1], 0);\n let pt1 = makePoint(p2[0], p2[1], 0);\n let x = makeVectorFromPoints(pt0, pt1);\n let unitX = unitVector(x);\n pt1 = addVector(pt0, multiplyVector(unitX, arrowLength));\n x = makeVectorFromPoints(pt0, pt1);\n let unitZ = makeVector(0, 0, 1);\n let unitY = unitVector(crossProduct(unitX, unitZ));\n let thickness = a.width || 10;\n\n let A = addVector(pt0, multiplyVector(unitY, thickness * 0.5));\n let B = addVector(A, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\n let C = addVector(B, multiplyVector(unitY, thickness));\n let D = pt1;\n let G = addVector(pt0, multiplyVector(negateVector(unitY), thickness * 0.5));\n let F = addVector(G, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\n let E = addVector(F, multiplyVector(negateVector(unitY), thickness));\n\n let points = '' +\n A.x + ',' + A.y + ' ' +\n B.x + ',' + B.y + ' ' +\n C.x + ',' + C.y + ' ' +\n D.x + ',' + D.y + ' ' +\n E.x + ',' + E.y + ' ' +\n F.x + ',' + F.y + ' ' +\n G.x + ',' + G.y;\n\n setAttributes(arrow, {\n points: points,\n stroke: normalizeColor(a.color || '#000'),\n fill: normalizeColor(a.color || '#000')\n });\n }\n\n return arrow;\n}\n","import { getTranslation } from '../render/appendChild';\nimport {\n applyTransform,\n applyInverseTransform,\n translate,\n rotate,\n scale\n} from '../utils/mathUtils';\n\nexport const BORDER_COLOR = '#00BFFF';\n\nconst userSelectStyleSheet = document.createElement('style');\nuserSelectStyleSheet.innerHTML = `\nbody {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n`;\n\nuserSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true');\n\n/**\n * Find the SVGElement that contains all the annotations for a page\n *\n * @param {Element} node An annotation within that container\n * @return {SVGElement} The container SVG or null if it can't be found\n */\nexport function findSVGContainer(node) {\n let parentNode = node;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n if (parentNode.nodeName.toUpperCase() === 'SVG' &&\n parentNode.getAttribute('data-pdf-annotate-container') === 'true') {\n return parentNode;\n }\n }\n\n return null;\n}\n\n/**\n * Find an SVGElement container at a given point\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @return {SVGElement} The container SVG or null if one can't be found\n */\nexport function findSVGAtPoint(x, y) {\n let elements = document.querySelectorAll('svg[data-pdf-annotate-container=\"true\"]');\n\n for (let i = 0, l = elements.length; i < l; i++) {\n let el = elements[i];\n let rect = el.getBoundingClientRect();\n\n if (pointIntersectsRect(x, y, rect)) {\n return el;\n }\n }\n\n return null;\n}\n\n/**\n * Find an Element that represents an annotation at a given point.\n *\n * IMPORTANT: Requires the annotation layer to be the top most element so\n * either use z-ordering or make it the leaf container.\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @return {Element} The annotation element or null if one can't be found\n */\nexport function findAnnotationAtPoint(x, y) {\n let el = null;\n let candidate = document.elementFromPoint(x, y);\n while (!el && candidate && candidate !== document) {\n let type = candidate.getAttribute('data-pdf-annotate-type');\n if (type) {\n el = candidate;\n }\n candidate = candidate.parentNode;\n }\n return el;\n}\n\n/**\n * Determine if a point intersects a rect\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Object} rect The points of a rect (likely from getBoundingClientRect)\n * @return {Boolean} True if a collision occurs, otherwise false\n */\nexport function pointIntersectsRect(x, y, rect) {\n return y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;\n}\n\n/**\n * Get the rect of an annotation element accounting for offset.\n *\n * @param {Element} el The element to get the rect of\n * @return {Object} The dimensions of the element\n */\nexport function getOffsetAnnotationRect(el) {\n let rect = el.getBoundingClientRect();\n let { width, height } = rect;\n let extraOffsetWidth = 0;\n let extraOffsetHeight = 0;\n if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) {\n let bbox = el.getBBox();\n extraOffsetWidth = (rect.width - bbox.width) / 2;\n extraOffsetHeight = (rect.height - bbox.height) / 2;\n width = bbox.width;\n height = bbox.height;\n }\n let { offsetLeft, offsetTop } = getOffset(el);\n return {\n top: rect.top - offsetTop + extraOffsetHeight,\n left: rect.left - offsetLeft + extraOffsetWidth,\n bottom: rect.bottom - offsetTop - extraOffsetHeight,\n right: rect.right - offsetLeft - extraOffsetWidth,\n width: width,\n height: height\n };\n}\n\n/**\n * Adjust scale from normalized scale (100%) to rendered scale.\n *\n * @param {SVGElement} svg The SVG to gather metadata from\n * @param {Object} rect A map of numeric values to scale\n * @return {Object} A copy of `rect` with values scaled up\n */\nexport function scaleUp(svg, rect) {\n let result = {};\n let { viewport } = getMetadata(svg);\n\n Object.keys(rect).forEach((key) => {\n result[key] = rect[key] * viewport.scale;\n });\n\n return result;\n}\n\nexport function convertToSvgRect(rect, svg, viewport) {\n let pt1 = [rect.x, rect.y];\n let pt2 = [rect.x + rect.width, rect.y + rect.height];\n\n pt1 = convertToSvgPoint(pt1, svg, viewport);\n pt2 = convertToSvgPoint(pt2, svg, viewport);\n\n return {\n x: Math.min(pt1[0], pt2[0]),\n y: Math.min(pt1[1], pt2[1]),\n width: Math.abs(pt2[0] - pt1[0]),\n height: Math.abs(pt2[1] - pt1[1])\n };\n}\n\nexport function convertToSvgPoint(pt, svg, viewport) {\n viewport = viewport || getMetadata(svg).viewport;\n\n let xform = [ 1, 0, 0, 1, 0, 0 ];\n xform = scale(xform, viewport.scale, viewport.scale);\n xform = rotate(xform, viewport.rotation);\n\n let offset = getTranslation(viewport);\n xform = translate(xform, offset.x, offset.y);\n\n return applyInverseTransform(pt, xform);\n}\n\nexport function convertToScreenPoint(pt, svg, viewport) {\n viewport = viewport || getMetadata(svg).viewport;\n\n let xform = [ 1, 0, 0, 1, 0, 0 ];\n xform = scale(xform, viewport.scale, viewport.scale);\n xform = rotate(xform, viewport.rotation);\n\n let offset = getTranslation(viewport);\n xform = translate(xform, offset.x, offset.y);\n\n return applyTransform(pt, xform);\n}\n\n/**\n * Adjust scale from rendered scale to a normalized scale (100%).\n *\n * @param {SVGElement} svg The SVG to gather metadata from\n * @param {Object} rect A map of numeric values to scale\n * @return {Object} A copy of `rect` with values scaled down\n */\nexport function scaleDown(svg, rect) {\n let result = {};\n let { viewport } = getMetadata(svg);\n\n Object.keys(rect).forEach((key) => {\n result[key] = rect[key] / viewport.scale;\n });\n\n return result;\n}\n\n/**\n * Get the scroll position of an element, accounting for parent elements\n *\n * @param {Element} el The element to get the scroll position for\n * @return {Object} The scrollTop and scrollLeft position\n */\nexport function getScroll(el) {\n let scrollTop = 0;\n let scrollLeft = 0;\n let parentNode = el;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n scrollTop += parentNode.scrollTop;\n scrollLeft += parentNode.scrollLeft;\n }\n\n return { scrollTop, scrollLeft };\n}\n\n/**\n * Get the offset position of an element, accounting for parent elements\n *\n * @param {Element} el The element to get the offset position for\n * @return {Object} The offsetTop and offsetLeft position\n */\nexport function getOffset(el) {\n let parentNode = el;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n if (parentNode.nodeName.toUpperCase() === 'SVG') {\n break;\n }\n }\n\n let rect = parentNode.getBoundingClientRect();\n\n return { offsetLeft: rect.left, offsetTop: rect.top };\n}\n\n/**\n * Disable user ability to select text on page\n */\nexport function disableUserSelect() {\n if (!userSelectStyleSheet.parentNode) {\n document.head.appendChild(userSelectStyleSheet);\n }\n}\n\n/**\n * Enable user ability to select text on page\n */\nexport function enableUserSelect() {\n if (userSelectStyleSheet.parentNode) {\n userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet);\n }\n}\n\n/**\n * Get the metadata for a SVG container\n *\n * @param {SVGElement} svg The SVG container to get metadata for\n */\nexport function getMetadata(svg) {\n return {\n documentId: svg.getAttribute('data-pdf-annotate-document'),\n pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10),\n viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'))\n };\n}\n","import EventEmitter from 'events';\nimport {\n findAnnotationAtPoint,\n findSVGAtPoint\n} from './utils';\n\nconst emitter = new EventEmitter();\n\nlet clickNode;\n\n/**\n * Handle document.click event\n *\n * @param {Event} e The DOM event to be handled\n */\ndocument.addEventListener('click', function handleDocumentClick(e) {\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\n\n // Emit annotation:blur if clickNode is no longer clicked\n if (clickNode && clickNode !== target) {\n emitter.emit('annotation:blur', clickNode);\n }\n\n // Emit annotation:click if target was clicked\n if (target) {\n emitter.emit('annotation:click', target);\n }\n\n clickNode = target;\n});\n\n// let mouseOverNode;\n// document.addEventListener('mousemove', function handleDocumentMousemove(e) {\n// let target = findAnnotationAtPoint(e.clientX, e.clientY);\n//\n// // Emit annotation:mouseout if target was mouseout'd\n// if (mouseOverNode && !target) {\n// emitter.emit('annotation:mouseout', mouseOverNode);\n// }\n//\n// // Emit annotation:mouseover if target was mouseover'd\n// if (target && mouseOverNode !== target) {\n// emitter.emit('annotation:mouseover', target);\n// }\n//\n// mouseOverNode = target;\n// });\n\nexport function fireEvent() { emitter.emit(...arguments); };\nexport function addEventListener() { emitter.on(...arguments); };\nexport function removeEventListener() { emitter.removeListener(...arguments); };\n","// Disable JSDoc as it cannot really deal with the odd way that the functions are defined\n/* eslint valid-jsdoc: 0 */\n\nimport abstractFunction from '../utils/abstractFunction';\nimport { fireEvent } from '../UI/event';\n\n// Adapter should never be invoked publicly\nexport default class StoreAdapter {\n /**\n * Create a new StoreAdapter instance\n *\n * @param {Object} [definition] The definition to use for overriding abstract methods\n */\n constructor(definition = {}) {\n // Copy each function from definition if it is a function we know about\n Object.keys(definition).forEach((key) => {\n if (typeof definition[key] === 'function' &&\n typeof this[key] === 'function') {\n this[key] = definition[key];\n }\n });\n }\n\n /**\n * Get all the annotations for a given document and page number.\n *\n * @param {String} documentId The ID for the document the annotations belong to\n * @param {Number} pageNumber The number of the page the annotations belong to\n * @return {Promise} Promise that returns with list of annotations for document and page\n */\n __getAnnotations(documentId, pageNumber) { abstractFunction('getAnnotations'); }\n get getAnnotations() { return this.__getAnnotations; }\n set getAnnotations(fn) {\n this.__getAnnotations = function getAnnotations(documentId, pageNumber) {\n return fn(...arguments).then((annotations) => {\n // TODO may be best to have this happen on the server\n if (annotations.annotations) {\n annotations.annotations.forEach((a) => {\n a.documentId = documentId;\n });\n }\n return annotations;\n });\n };\n }\n\n /**\n * Get the definition for a specific annotation.\n *\n * @param {String} documentId The ID for the document the annotation belongs to\n * @param {String} annotationId The ID for the annotation\n * @return {Promise} Promise that returns the requested annotation\n */\n getAnnotation(documentId, annotationId) { abstractFunction('getAnnotation'); }\n\n /**\n * Add an annotation\n *\n * @param {String} documentId The ID for the document to add the annotation to\n * @param {String} pageNumber The page number to add the annotation to\n * @param {Object} annotation The definition for the new annotation\n * @return {Promise} Promise that returns with the added annotation\n */\n __addAnnotation(documentId, pageNumber, annotation) { abstractFunction('addAnnotation'); }\n get addAnnotation() { return this.__addAnnotation; }\n set addAnnotation(fn) {\n this.__addAnnotation = function addAnnotation(documentId, pageNumber, annotation) {\n return fn(...arguments).then((annotation) => {\n fireEvent('annotation:add', documentId, pageNumber, annotation);\n return annotation;\n });\n };\n }\n\n /**\n * Edit an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} pageNumber the page number of the annotation\n * @param {Object} annotation The definition of the modified annotation\n * @return {Promise} Promise that returns with the edited annotation\n */\n __editAnnotation(documentId, pageNumber, annotation) { abstractFunction('editAnnotation'); }\n get editAnnotation() { return this.__editAnnotation; }\n set editAnnotation(fn) {\n this.__editAnnotation = function editAnnotation(documentId, annotationId, annotation) {\n return fn(...arguments).then((annotation) => {\n fireEvent('annotation:edit', documentId, annotationId, annotation);\n return annotation;\n });\n };\n }\n\n /**\n * Delete an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} annotationId The ID for the annotation\n * @return {Promise} Promise that returns with boolean if annotation was deleted\n */\n __deleteAnnotation(documentId, annotationId) { abstractFunction('deleteAnnotation'); }\n get deleteAnnotation() { return this.__deleteAnnotation; }\n set deleteAnnotation(fn) {\n this.__deleteAnnotation = function deleteAnnotation(documentId, annotationId) {\n return fn(...arguments).then((success) => {\n if (success) {\n fireEvent('annotation:delete', documentId, annotationId);\n }\n return success;\n });\n };\n }\n\n /**\n * Get all the comments for an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} annotationId The ID for the annotation\n * @return {Promise} Promise that returns with comments for annotation\n */\n getComments(documentId, annotationId) { abstractFunction('getComments'); }\n\n /**\n * Add a new comment\n *\n * @param {String} documentId The ID for the document\n * @param {String} annotationId The ID for the annotation\n * @param {Object} content The definition of the comment\n * @return {Promise} Promise that returns with the added comment\n */\n __addComment(documentId, annotationId, content) { abstractFunction('addComment'); }\n get addComment() { return this.__addComment; }\n set addComment(fn) {\n this.__addComment = function addComment(documentId, annotationId, content) {\n return fn(...arguments).then((comment) => {\n fireEvent('comment:add', documentId, annotationId, comment);\n return comment;\n });\n };\n }\n\n /**\n * Delete a comment\n *\n * @param {String} documentId The ID for the document\n * @param {String} commentId The ID for the comment\n * @return {Promise} Promise that returns with boolean if comment was deleted\n */\n __deleteComment(documentId, commentId) { abstractFunction('deleteComment'); }\n get deleteComment() { return this.__deleteComment; }\n set deleteComment(fn) {\n this.__deleteComment = function deleteComment(documentId, commentId) {\n return fn(...arguments).then((success) => {\n if (success) {\n fireEvent('comment:delete', documentId, commentId);\n }\n return success;\n });\n };\n }\n}\n","const REGEXP = /[xy]/g;\nconst PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nfunction replacement(c) {\n let r = Math.random() * 16 | 0;\n let v = c === 'x' ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n}\n\n/**\n * Generate a univierally unique identifier\n *\n * @return {String} A UUID\n */\nexport default function uuid() {\n return PATTERN.replace(REGEXP, replacement);\n}\n","import uuid from '../utils/uuid';\nimport StoreAdapter from './StoreAdapter';\n\n// StoreAdapter for working with localStorage\n// This is ideal for testing, examples, and prototyping\nexport default class LocalStoreAdapter extends StoreAdapter {\n constructor() {\n super({\n getAnnotations(documentId, pageNumber) {\n return new Promise((resolve, reject) => {\n let annotations = getAnnotations(documentId).filter((i) => {\n return i.page === pageNumber && i.class === 'Annotation';\n });\n\n resolve({\n documentId,\n pageNumber,\n annotations\n });\n });\n }\n });\n\n this.getAnnotation = (documentId, annotationId) => {\n return Promise.resolve(getAnnotations(documentId)[findAnnotation(documentId, annotationId)]);\n };\n\n this.addAnnotation = (documentId, pageNumber, annotation) => {\n return new Promise((resolve, reject) => {\n annotation.class = 'Annotation';\n annotation.uuid = uuid();\n annotation.page = pageNumber;\n\n let annotations = getAnnotations(documentId);\n annotations.push(annotation);\n updateAnnotations(documentId, annotations);\n\n resolve(annotation);\n });\n };\n\n this.editAnnotation = (documentId, annotationId, annotation) => {\n return new Promise((resolve, reject) => {\n let annotations = getAnnotations(documentId);\n annotations[findAnnotation(documentId, annotationId)] = annotation;\n updateAnnotations(documentId, annotations);\n resolve(annotation);\n });\n };\n\n this.deleteAnnotation = (documentId, annotationId) => {\n return new Promise((resolve, reject) => {\n let annotation = getAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\n if (!annotation) {\n return reject('Could not find annotation');\n }\n let index = findAnnotation(documentId, annotationId);\n if (index > -1) {\n let annotations = getAnnotations(documentId);\n annotations.splice(index, 1);\n updateAnnotations(documentId, annotations);\n }\n\n resolve(true);\n });\n };\n\n this.getComments = (documentId, annotationId) => {\n return new Promise((resolve, reject) => {\n resolve(getAnnotations(documentId).filter((i) => {\n return i.class === 'Comment' && i.annotation === annotationId;\n }));\n });\n };\n\n this.addComment = (documentId, annotationId, content) => {\n return new Promise((resolve, reject) => {\n let comment = {\n class: 'Comment',\n uuid: uuid(),\n annotation: annotationId,\n content: content\n };\n\n let annotations = getAnnotations(documentId);\n annotations.push(comment);\n updateAnnotations(documentId, annotations);\n\n resolve(comment);\n });\n };\n\n this.deleteComment = (documentId, commentId) => {\n return new Promise((resolve, reject) => {\n let comment = getAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\n if (!comment) {\n return reject('Could not find annotation');\n }\n let index = -1;\n let annotations = getAnnotations(documentId);\n for (let i = 0, l = annotations.length; i < l; i++) {\n if (annotations[i].uuid === commentId) {\n index = i;\n break;\n }\n }\n\n if (index > -1) {\n annotations.splice(index, 1);\n updateAnnotations(documentId, annotations);\n }\n\n resolve(true);\n });\n };\n }\n}\n\nfunction getAnnotations(documentId) {\n return JSON.parse(localStorage.getItem(`${documentId}/annotations`)) || [];\n}\n\nfunction updateAnnotations(documentId, annotations) {\n localStorage.setItem(`${documentId}/annotations`, JSON.stringify(annotations));\n}\n/**\n *\n * @param {String} documentId Document id of the annotation\n * @param {String} annotationId The id of the annotation\n *\n * This function finds all the annotation made by one user.\n *\n * @return {int} The index of the annotation in localstorage\n */\nfunction findAnnotation(documentId, annotationId) {\n let index = -1;\n let annotations = getAnnotations(documentId);\n for (let i = 0, l = annotations.length; i < l; i++) {\n if (annotations[i].uuid === annotationId) {\n index = i;\n break;\n }\n }\n return index;\n}\n","import uuid from '../utils/uuid';\nimport StoreAdapter from './StoreAdapter';\n\n// StoreAdapter for working with localStorage and associated user id\n// This is ideal for testing, examples, and prototyping\nexport default class LocalUserStoreAdapter extends StoreAdapter {\n constructor(userId = 'user', globalEdit = false) {\n super({\n getAnnotations(documentId, pageNumber) {\n return new Promise((resolve, reject) => {\n let annotations = getAllAnnotations(documentId).filter((i) => {\n return i.page === pageNumber && i.class === 'Annotation';\n });\n\n resolve({\n documentId,\n pageNumber,\n annotations\n });\n });\n }\n });\n\n this._userId = userId;\n this._globalEdit = globalEdit;\n\n this.getAnnotation = (documentId, annotationId) => {\n return Promise.resolve(getAnnotations(documentId, this._userId)[findAnnotation(documentId, this._userId, annotationId)]);\n };\n\n this.addAnnotation = (documentId, pageNumber, annotation) => {\n return new Promise((resolve, reject) => {\n annotation.class = 'Annotation';\n annotation.uuid = uuid();\n annotation.page = pageNumber;\n annotation.userId = this._userId;\n\n let annotations = getAnnotations(documentId, this._userId);\n annotations.push(annotation);\n updateAnnotations(documentId, this._userId, annotations);\n\n resolve(annotation);\n });\n };\n\n this.editAnnotation = (documentId, annotationId, annotation) => {\n return new Promise((resolve, reject) => {\n if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\n reject('Non-matching userId');\n }\n let annotations = getAnnotations(documentId, annotation.userId);\n annotations[findAnnotation(documentId, annotation.userId, annotationId)] = annotation;\n updateAnnotations(documentId, annotation.userId, annotations);\n resolve(annotation);\n });\n };\n\n this.deleteAnnotation = (documentId, annotationId) => {\n return new Promise((resolve, reject) => {\n let annotation = getAllAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\n if (!annotation) {\n return reject('Could not find annotation');\n }\n else if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\n return reject('Non-matching userId');\n }\n let index = findAnnotation(documentId, annotation.userId, annotationId);\n if (index > -1) {\n let annotations = getAnnotations(documentId, annotation.userId);\n annotations.splice(index, 1);\n updateAnnotations(documentId, annotation.userId, annotations);\n }\n\n resolve(true);\n });\n };\n\n this.getComments = (documentId, annotationId) => {\n return new Promise((resolve, reject) => {\n resolve(getAnnotations(documentId, this._userId).filter((i) => {\n return i.class === 'Comment' && i.annotation === annotationId;\n }));\n });\n };\n\n this.addComment = (documentId, annotationId, content) => {\n return new Promise((resolve, reject) => {\n let comment = {\n class: 'Comment',\n uuid: uuid(),\n annotation: annotationId,\n content: content,\n userId: this._userId\n };\n\n let annotations = getAnnotations(documentId, this._userId);\n annotations.push(comment);\n updateAnnotations(documentId, this._userId, annotations);\n\n resolve(comment);\n });\n };\n\n this.deleteComment = (documentId, commentId) => {\n return new Promise((resolve, reject) => {\n let comment = getAllAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\n if (!comment) {\n return reject('Could not find annotation');\n }\n else if (!this._globalEdit && comment.userId && comment.userId !== this._userId) {\n return reject('Non-matching userId');\n }\n let index = -1;\n let annotations = getAnnotations(documentId, comment.userId);\n for (let i = 0, l = annotations.length; i < l; i++) {\n if (annotations[i].uuid === commentId) {\n index = i;\n break;\n }\n }\n\n if (index > -1) {\n annotations.splice(index, 1);\n updateAnnotations(documentId, comment.userId, annotations);\n }\n\n resolve(true);\n });\n };\n }\n\n get userId() {\n return this._userId;\n }\n}\n\nfunction getAllAnnotations(documentId) {\n let all_annotations = [];\n let re = new RegExp(`${documentId}/(.*)/annotations`);\n for (let i = 0; i < localStorage.length; i++) {\n if (localStorage.key(i).search(re) > -1) {\n all_annotations.push(...JSON.parse(localStorage.getItem(localStorage.key(i))));\n }\n }\n return all_annotations;\n}\n\nfunction getAnnotations(documentId, userId) {\n return JSON.parse(localStorage.getItem(`${documentId}/${userId}/annotations`)) || [];\n}\n\nfunction updateAnnotations(documentId, userId, annotations) {\n localStorage.setItem(`${documentId}/${userId}/annotations`, JSON.stringify(annotations));\n}\n/**\n *\n * @param {String} documentId Document id of the annotation\n * @param {String} userId User id of the annotation\n * @param {String} annotationId The id of the annotation\n *\n * This function finds all the annotation made by one user.\n *\n * @return {int} The index of the annotation in localstorage\n */\nfunction findAnnotation(documentId, userId, annotationId) {\n let index = -1;\n let annotations = getAnnotations(documentId, userId);\n for (let i = 0, l = annotations.length; i < l; i++) {\n if (annotations[i].uuid === annotationId) {\n index = i;\n break;\n }\n }\n return index;\n}\n","export default {\n annotationLayerName: 'annotationLayer',\n textLayerName: 'textLayer',\n annotationSvgQuery: function() {\n return 'svg.' + this.annotationLayerName;\n },\n annotationClassQuery: function() {\n return '.' + this.annotationLayerName;\n },\n textClassQuery: function() {\n return '.' + this.textLayerName;\n }\n};\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport {\n addEventListener,\n removeEventListener\n} from './event';\nimport {\n BORDER_COLOR,\n disableUserSelect,\n enableUserSelect,\n findSVGContainer,\n findSVGAtPoint,\n getOffsetAnnotationRect,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet isDragging = false;\nlet overlay;\nlet dragOffsetX, dragOffsetY, dragStartX, dragStartY;\nconst OVERLAY_BORDER_SIZE = 3;\n\n/**\n * Create an overlay for editing an annotation.\n *\n * @param {Element} target The annotation element to apply overlay for\n */\nfunction createEditOverlay(target) {\n destroyEditOverlay();\n\n overlay = document.createElement('div');\n let anchor = document.createElement('a');\n let parentNode = findSVGContainer(target).parentNode;\n let id = target.getAttribute('data-pdf-annotate-id');\n let rect = getOffsetAnnotationRect(target);\n let styleLeft = rect.left - OVERLAY_BORDER_SIZE;\n let styleTop = rect.top - OVERLAY_BORDER_SIZE;\n\n overlay.setAttribute('id', 'pdf-annotate-edit-overlay');\n overlay.setAttribute('data-target-id', id);\n overlay.style.boxSizing = 'content-box';\n overlay.style.position = 'absolute';\n overlay.style.top = `${styleTop}px`;\n overlay.style.left = `${styleLeft}px`;\n overlay.style.width = `${rect.width}px`;\n overlay.style.height = `${rect.height}px`;\n overlay.style.border = `${OVERLAY_BORDER_SIZE}px solid ${BORDER_COLOR}`;\n overlay.style.borderRadius = `${OVERLAY_BORDER_SIZE}px`;\n overlay.style.zIndex = 20100;\n\n anchor.innerHTML = '×';\n anchor.setAttribute('href', 'javascript://');\n anchor.style.background = '#fff';\n anchor.style.borderRadius = '20px';\n anchor.style.border = '1px solid #bbb';\n anchor.style.color = '#bbb';\n anchor.style.fontSize = '16px';\n anchor.style.padding = '2px';\n anchor.style.textAlign = 'center';\n anchor.style.textDecoration = 'none';\n anchor.style.position = 'absolute';\n anchor.style.top = '-13px';\n anchor.style.right = '-13px';\n anchor.style.width = '25px';\n anchor.style.height = '25px';\n\n overlay.appendChild(anchor);\n parentNode.appendChild(overlay);\n document.addEventListener('click', handleDocumentClick);\n document.addEventListener('keyup', handleDocumentKeyup);\n document.addEventListener('mousedown', handleDocumentMousedown);\n anchor.addEventListener('click', deleteAnnotation);\n anchor.addEventListener('mouseover', () => {\n anchor.style.color = '#35A4DC';\n anchor.style.borderColor = '#999';\n anchor.style.boxShadow = '0 1px 1px #ccc';\n });\n anchor.addEventListener('mouseout', () => {\n anchor.style.color = '#bbb';\n anchor.style.borderColor = '#bbb';\n anchor.style.boxShadow = '';\n });\n overlay.addEventListener('mouseover', () => {\n if (!isDragging) { anchor.style.display = ''; }\n });\n overlay.addEventListener('mouseout', () => {\n anchor.style.display = 'none';\n });\n}\n\n/**\n * Destroy the edit overlay if it exists.\n */\nfunction destroyEditOverlay() {\n if (overlay) {\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n }\n\n document.removeEventListener('click', handleDocumentClick);\n document.removeEventListener('keyup', handleDocumentKeyup);\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n enableUserSelect();\n}\n\n/**\n * Delete currently selected annotation\n */\nfunction deleteAnnotation() {\n if (!overlay) {\n return;\n }\n\n let annotationId = overlay.getAttribute('data-target-id');\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let { documentId } = getMetadata(svg);\n\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n\n [...nodes].forEach((n) => {\n n.parentNode.removeChild(n);\n });\n });\n\n destroyEditOverlay();\n}\n\n/**\n * Handle document.click event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentClick(e) {\n if (!findSVGAtPoint(e.clientX, e.clientY)) { return; }\n\n // Remove current overlay\n let overlay = document.getElementById('pdf-annotate-edit-overlay');\n if (overlay) {\n if (isDragging || e.target === overlay) {\n return;\n }\n\n destroyEditOverlay();\n }\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {KeyboardEvent} e The DOM event that needs to be handled\n */\nfunction handleDocumentKeyup(e) {\n // keyCode is deprecated, so prefer the newer \"key\" method if possible\n let keyTest;\n if (e.key) {\n keyTest = e.key.toLowerCase() === 'delete' || e.key.toLowerCase() === 'backspace';\n }\n else {\n keyTest = e.keyCode === 8 || e.keyCode === 46;\n }\n if (overlay && keyTest &&\n e.target.nodeName.toLowerCase() !== 'textarea' &&\n e.target.nodeName.toLowerCase() !== 'input') {\n e.preventDefault();\n deleteAnnotation();\n }\n}\n\n/**\n * Handle document.mousedown event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMousedown(e) {\n if (e.target !== overlay) {\n return;\n }\n\n // Highlight and strikeout annotations are bound to text within the document.\n // It doesn't make sense to allow repositioning these types of annotations.\n let annotationId = overlay.getAttribute('data-target-id');\n let target = document.querySelector(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n let type = target.getAttribute('data-pdf-annotate-type');\n\n if (type === 'highlight' || type === 'strikeout') { return; }\n\n isDragging = true;\n dragOffsetX = e.clientX;\n dragOffsetY = e.clientY;\n dragStartX = overlay.offsetLeft;\n dragStartY = overlay.offsetTop;\n\n overlay.style.background = 'rgba(255, 255, 255, 0.7)';\n overlay.style.cursor = 'move';\n overlay.querySelector('a').style.display = 'none';\n\n document.addEventListener('mousemove', handleDocumentMousemove);\n document.addEventListener('mouseup', handleDocumentMouseup);\n disableUserSelect();\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMousemove(e) {\n let parentNode = overlay.parentNode;\n let rect = parentNode.getBoundingClientRect();\n let y = (dragStartY + (e.clientY - dragOffsetY));\n let x = (dragStartX + (e.clientX - dragOffsetX));\n let minY = 0;\n let maxY = rect.height;\n let minX = 0;\n let maxX = rect.width;\n\n if (y > minY && y + overlay.offsetHeight < maxY) {\n overlay.style.top = `${y}px`;\n }\n\n if (x > minX && x + overlay.offsetWidth < maxX) {\n overlay.style.left = `${x}px`;\n }\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMouseup(e) {\n let annotationId = overlay.getAttribute('data-target-id');\n let target = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n let type = target[0].getAttribute('data-pdf-annotate-type');\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let { documentId } = getMetadata(svg);\n\n overlay.querySelector('a').style.display = '';\n\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\n let attribX = 'x';\n let attribY = 'y';\n if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\n attribX = 'cx';\n attribY = 'cy';\n }\n\n if (type === 'point') {\n // Broken\n /*\n [...target].forEach((t, i) => {\n let moveTo = {\n x: overlay.offsetLeft + 3,\n y: overlay.offsetTop + 3\n };\n t.setAttribute(attribX, moveTo.x);\n t.setAttribute(attribY, moveTo.y);\n annotation[attribX] = moveTo.x;\n annotation[attribY] = moveTo.y;\n });\n */\n return;\n }\n else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\n let modelDelta = {\n x: modelEnd[0] - modelStart[0],\n y: modelEnd[1] - modelStart[1]\n };\n\n if (type === 'textbox') {\n target = [target[0].firstChild];\n }\n\n [...target].forEach((t, i) => {\n let modelX = parseInt(t.getAttribute(attribX), 10);\n let modelY = parseInt(t.getAttribute(attribY), 10);\n if (modelDelta.y !== 0) {\n modelY = modelY + modelDelta.y;\n\n t.setAttribute(attribY, modelY);\n if (annotation.rectangles && i < annotation.rectangles.length) {\n annotation.rectangles[i].y = modelY;\n }\n else if (annotation[attribY]) {\n annotation[attribY] = modelY;\n }\n }\n if (modelDelta.x !== 0) {\n modelX = modelX + modelDelta.x;\n\n t.setAttribute(attribX, modelX);\n if (annotation.rectangles && i < annotation.rectangles.length) {\n annotation.rectangles[i].x = modelX;\n }\n else if (annotation[attribX]) {\n annotation[attribX] = modelX;\n }\n }\n });\n }\n else if (type === 'strikeout') {\n return;\n // let { deltaX, deltaY } = getDelta('x1', 'y1');\n // [...target].forEach(target, (t, i) => {\n // if (deltaY !== 0) {\n // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY);\n // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY);\n // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10);\n // }\n // if (deltaX !== 0) {\n // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX);\n // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX);\n // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10);\n // }\n // });\n }\n else if (type === 'drawing' || type === 'arrow') {\n // Do nothing as currently broken\n /*\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\n let modelDelta = {\n x: modelEnd[0] - modelStart[0],\n y: modelEnd[1] - modelStart[1]\n };\n\n annotation.lines.forEach((line, i) => {\n let [x, y] = annotation.lines[i];\n annotation.lines[i][0] = x + modelDelta.x;\n annotation.lines[i][1] = y + modelDelta.y;\n });\n\n target[0].parentNode.removeChild(target[0]);\n appendChild(svg, annotation);\n */\n return;\n }\n\n PDFJSAnnotate.getStoreAdapter().editAnnotation(documentId, annotationId, annotation);\n });\n\n setTimeout(() => {\n isDragging = false;\n }, 0);\n\n overlay.style.background = '';\n overlay.style.cursor = '';\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n enableUserSelect();\n}\n\n/**\n * Handle annotation.click event\n *\n * @param {Element} e The annotation element that was clicked\n */\nfunction handleAnnotationClick(target) {\n createEditOverlay(target);\n}\n\n/**\n * Enable edit mode behavior.\n */\nexport function enableEdit() {\n if (_enabled) {\n return;\n }\n\n _enabled = true;\n addEventListener('annotation:click', handleAnnotationClick);\n};\n\n/**\n * Disable edit mode behavior.\n */\nexport function disableEdit() {\n destroyEditOverlay();\n\n if (!_enabled) {\n return;\n }\n\n _enabled = false;\n removeEventListener('annotation:click', handleAnnotationClick);\n};\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet _candraw = false;\nlet _penSize;\nlet _penColor;\nlet path;\nlet lines = [];\n\n/**\n * Handle document.touchdown or document.pointerdown event\n * @param {PointerEvent} e The DOM event to be handled\n */\nfunction handleDocumentPointerdown(e) {\n path = null;\n lines = [];\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n _candraw = true;\n e.preventDefault();\n}\n\n/**\n * Handle document.pointerup event\n *\n * @param {PointerEvent} e The DOM event to be handled\n */\nfunction handleDocumentPointerup(e) {\n saveToStorage(e.clientX, e.clientY);\n}\n\nfunction saveToStorage(x, y) {\n if (!_candraw) {\n return;\n }\n _candraw = false;\n let svg;\n if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {\n let { documentId, pageNumber } = getMetadata(svg);\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\n type: 'drawing',\n width: _penSize,\n color: _penColor,\n lines\n }).then((annotation) => {\n if (path) {\n svg.removeChild(path);\n }\n\n appendChild(svg, annotation);\n });\n }\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {PointerEvent} e The DOM event to be handled\n */\nfunction handleDocumentPointermove(e) {\n if (!findSVGAtPoint(e.clientX, e.clientY) || !_candraw) {\n return;\n }\n savePoint(e.clientX, e.clientY);\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {KeyboardEvent} e The DOM event to be handled\n * } e The DOM event to be handled\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n lines = null;\n path.parentNode.removeChild(path);\n document.removeEventListener('pointermove', handleDocumentPointermove);\n document.removeEventListener('pointerup', handleDocumentPointerup);\n }\n}\n\n/**\n * Save a point to the line being drawn.\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n */\nfunction savePoint(x, y) {\n let svg = findSVGAtPoint(x, y);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let point = convertToSvgPoint([\n x - rect.left,\n y - rect.top\n ], svg);\n point[0] = point[0].toFixed(2);\n point[1] = point[1].toFixed(2);\n lines.push(point);\n\n if (lines.length <= 1) {\n return;\n }\n\n if (path) {\n svg.removeChild(path);\n }\n\n path = appendChild(svg, {\n type: 'drawing',\n color: _penColor,\n width: _penSize,\n lines\n });\n}\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} penSize The size of the lines drawn by the pen, rounded to 2 decimal places\n * @param {String} penColor The color of the lines drawn by the pen\n */\nexport function setPen(penSize = 1, penColor = '000000') {\n _penSize = Math.round(parseFloat(penSize) * 1e2) / 1e2;\n _penColor = penColor;\n}\n\n/**\n * Return pen attributes of the pen\n *\n * @return {Object} Object with size and color\n */\nexport function getPen() {\n return {\n size: _penSize,\n color: _penColor\n };\n}\n\n/**\n * Enable the pen behavior\n */\nexport function enablePen() {\n if (_enabled) {\n return;\n }\n\n _enabled = true;\n // Chrome and Firefox has different behaviors with how pen works, so we need different events.\n document.addEventListener('pointerdown', handleDocumentPointerdown);\n document.addEventListener('pointermove', handleDocumentPointermove);\n document.addEventListener('pointerup', handleDocumentPointerup);\n\n document.addEventListener('keyup', handleDocumentKeyup);\n disableUserSelect();\n}\n\n/**\n * Disable the pen behavior\n */\nexport function disablePen() {\n if (!_enabled) {\n return;\n }\n\n _enabled = false;\n document.removeEventListener('pointerdown', handleDocumentPointerdown);\n document.removeEventListener('pointermove', handleDocumentPointermove);\n document.removeEventListener('pointerup', handleDocumentPointerup);\n\n document.removeEventListener('keyup', handleDocumentKeyup);\n enableUserSelect();\n}\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n findSVGContainer,\n getMetadata,\n convertToSvgPoint,\n convertToScreenPoint,\n findAnnotationAtPoint\n} from './utils';\n\nlet _enabled = false;\nlet _penSize;\nlet _penColor;\nlet path;\nlet lines;\nlet originY;\nlet originX;\n\n/**\n * Handle document.mousedown event\n */\nfunction handleDocumentMousedown(e) {\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\n if (target === null) {\n return;\n }\n\n let type = target.getAttribute('data-pdf-annotate-type');\n if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') {\n return;\n }\n\n let svg = findSVGContainer(target);\n let { documentId } = getMetadata(svg);\n let annotationId = target.getAttribute('data-pdf-annotate-id');\n\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\n if (annotation) {\n path = null;\n lines = [];\n\n let point = convertToScreenPoint([\n annotation.cx,\n annotation.cy\n ], svg);\n\n let rect = svg.getBoundingClientRect();\n\n originX = point[0] + rect.left;\n originY = point[1] + rect.top;\n\n document.addEventListener('mousemove', handleDocumentMousemove);\n document.addEventListener('mouseup', handleDocumentMouseup);\n }\n });\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentMouseup(e) {\n let svg;\n if (lines.length > 1 && (svg = findSVGAtPoint(e.clientX, e.clientY))) {\n let { documentId, pageNumber } = getMetadata(svg);\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\n type: 'arrow',\n width: _penSize,\n color: _penColor,\n lines\n }).then((annotation) => {\n if (path) {\n svg.removeChild(path);\n }\n\n appendChild(svg, annotation);\n });\n }\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentMousemove(e) {\n let x = lines.length === 0 ? originX : e.clientX;\n let y = lines.length === 0 ? originY : e.clientY;\n\n savePoint(x, y);\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n lines = null;\n path.parentNode.removeChild(path);\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n }\n}\n\n/**\n * Save a point to the line being drawn.\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n */\nfunction savePoint(x, y) {\n let svg = findSVGAtPoint(x, y);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let point = convertToSvgPoint([\n x - rect.left,\n y - rect.top\n ], svg);\n\n if (lines.length < 2) {\n lines.push(point);\n return;\n }\n else {\n lines[1] = point; // update end point\n }\n\n if (path) {\n svg.removeChild(path);\n }\n\n path = appendChild(svg, {\n type: 'arrow',\n color: _penColor,\n width: _penSize,\n lines\n });\n}\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} penSize The size of the lines drawn by the pen\n * @param {String} penColor The color of the lines drawn by the pen\n */\nexport function setArrow(penSize = 10, penColor = '0000FF') {\n _penSize = parseInt(penSize, 10);\n _penColor = penColor;\n}\n\n/**\n * Enable the pen behavior\n */\nexport function enableArrow() {\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mousedown', handleDocumentMousedown);\n document.addEventListener('keyup', handleDocumentKeyup);\n disableUserSelect();\n}\n\n/**\n * Disable the pen behavior\n */\nexport function disableArrow() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('keyup', handleDocumentKeyup);\n enableUserSelect();\n}\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport {\n findAnnotationAtPoint,\n getMetadata\n} from './utils';\n\nlet _canerase = false;\nlet previousPoint = null;\n\n/**\n *\n * @param {PointerEvent} e DOM event to handle\n */\nfunction handleDocumentDown(e) {\n _canerase = true;\n previousPoint = [e.clientX, e.clientY];\n}\n\n/**\n *\n * @param {PointerEvent} e DOM event to handle\n */\nfunction handleDocumentUp(e) {\n _canerase = false;\n erase(findAnnotationAtPoint(e.clientX, e.clientY));\n}\n\n/**\n *\n * @param {PointerEvent} e DOM event to handle\n */\nfunction handleDocumentMouseMove(e) {\n if (!_canerase) {\n return;\n }\n\n // This algorithm attempts to get the various points between the last\n // PointerEvent and this one\n let check = [];\n let diffX = Math.abs(previousPoint[0] - e.clientX);\n let diffY = Math.abs(previousPoint[1] - e.clientY);\n if (diffX >= 1 || diffY >= 1) {\n let maxSteps = Math.round(Math.max(diffX, diffY));\n let subStepSize = Math.min(diffX, diffY) / maxSteps;\n let smallerTest = diffX < diffY;\n let startPoint = [\n Math.min(previousPoint[0], e.clientX),\n Math.min(previousPoint[1], e.clientY)\n ];\n for (let i = 0; i < maxSteps; i++) {\n if (smallerTest) {\n check.push([Math.round(startPoint[0] + (subStepSize * i)), Math.round(startPoint[1] + i)]);\n }\n else {\n check.push([Math.round(startPoint[0] + i), Math.round(startPoint[1] + (subStepSize * i))]);\n }\n }\n }\n for (let point of check) {\n erase(findAnnotationAtPoint(point[0], point[1]));\n }\n previousPoint = [e.clientX, e.clientY];\n}\n\nfunction erase(target) {\n if (!_canerase) {\n return;\n }\n\n if (target) {\n let { documentId } = getMetadata(target.parentElement);\n let annotationId = target.getAttribute('data-pdf-annotate-id');\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n [...nodes].forEach((n) => {\n n.parentNode.removeChild(n);\n });\n });\n }\n}\n\nexport function enableEraser() {\n document.addEventListener('pointermove', handleDocumentMouseMove);\n document.addEventListener('pointerdown', handleDocumentDown);\n document.addEventListener('pointerup', handleDocumentUp);\n}\n\nexport function disableEraser() {\n document.removeEventListener('pointermove', handleDocumentMouseMove);\n document.removeEventListener('pointerdown', handleDocumentDown);\n document.removeEventListener('pointerup', handleDocumentUp);\n}\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n findSVGAtPoint,\n getMetadata,\n scaleDown\n} from './utils';\n\nlet _enabled = false;\nlet input;\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} The DOM event to be handled\n */\nfunction handleDocumentMouseup(e) {\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n\n input = document.createElement('input');\n input.setAttribute('id', 'pdf-annotate-point-input');\n input.setAttribute('placeholder', 'Enter comment');\n input.style.border = `3px solid ${BORDER_COLOR}`;\n input.style.borderRadius = '3px';\n input.style.position = 'absolute';\n input.style.top = `${e.clientY}px`;\n input.style.left = `${e.clientX}px`;\n\n input.addEventListener('blur', handleInputBlur);\n input.addEventListener('keyup', handleInputKeyup);\n\n document.body.appendChild(input);\n input.focus();\n}\n\n/**\n * Handle input.blur event\n */\nfunction handleInputBlur() {\n savePoint();\n}\n\n/**\n * Handle input.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleInputKeyup(e) {\n if (e.keyCode === 27) {\n closeInput();\n }\n else if (e.keyCode === 13) {\n savePoint();\n }\n}\n\n/**\n * Save a new point annotation from input\n */\nfunction savePoint() {\n if (input.value.trim().length > 0) {\n let clientX = parseInt(input.style.left, 10);\n let clientY = parseInt(input.style.top, 10);\n let content = input.value.trim();\n let svg = findSVGAtPoint(clientX, clientY);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let { documentId, pageNumber } = getMetadata(svg);\n let annotation = Object.assign({\n type: 'point'\n }, scaleDown(svg, {\n x: clientX - rect.left,\n y: clientY - rect.top\n }));\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\n .then((annotation) => {\n PDFJSAnnotate.getStoreAdapter().addComment(\n documentId,\n annotation.uuid,\n content\n );\n\n appendChild(svg, annotation);\n });\n }\n\n closeInput();\n}\n\n/**\n * Close the input element\n */\nfunction closeInput() {\n input.removeEventListener('blur', handleInputBlur);\n input.removeEventListener('keyup', handleInputKeyup);\n document.body.removeChild(input);\n input = null;\n}\n\n/**\n * Enable point annotation behavior\n */\nexport function enablePoint() {\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Disable point annotation behavior\n */\nexport function disablePoint() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n getMetadata,\n convertToSvgRect\n} from './utils';\n\nlet _enabled = false;\nlet _type;\nlet overlay;\nlet originY;\nlet originX;\n\n/**\n * Get the current window selection as rects\n *\n * @return {Array} An Array of rects\n */\nfunction getSelectionRects() {\n try {\n let selection = window.getSelection();\n let range = selection.getRangeAt(0);\n let rects = range.getClientRects();\n\n if (rects.length > 0 &&\n rects[0].width > 0 &&\n rects[0].height > 0) {\n return rects;\n }\n }\n catch (e) {}\n\n return null;\n}\n\n/**\n * Handle document.mousedown event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMousedown(e) {\n let svg;\n if (_type !== 'area' || !(svg = findSVGAtPoint(e.clientX, e.clientY))) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n originY = e.clientY;\n originX = e.clientX;\n\n overlay = document.createElement('div');\n overlay.style.position = 'absolute';\n overlay.style.top = `${originY - rect.top}px`;\n overlay.style.left = `${originX - rect.left}px`;\n overlay.style.border = `3px solid ${BORDER_COLOR}`;\n overlay.style.borderRadius = '3px';\n svg.parentNode.appendChild(overlay);\n\n document.addEventListener('mousemove', handleDocumentMousemove);\n disableUserSelect();\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMousemove(e) {\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let rect = svg.getBoundingClientRect();\n\n if (originX + (e.clientX - originX) < rect.right) {\n overlay.style.width = `${e.clientX - originX}px`;\n }\n\n if (originY + (e.clientY - originY) < rect.bottom) {\n overlay.style.height = `${e.clientY - originY}px`;\n }\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n let rects;\n if (_type !== 'area' && (rects = getSelectionRects())) {\n saveRect(_type, [...rects].map((r) => {\n return {\n top: r.top,\n left: r.left,\n width: r.width,\n height: r.height\n };\n }));\n }\n else if (_type === 'area' && overlay) {\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let rect = svg.getBoundingClientRect();\n saveRect(_type, [{\n top: parseInt(overlay.style.top, 10) + rect.top,\n left: parseInt(overlay.style.left, 10) + rect.left,\n width: parseInt(overlay.style.width, 10),\n height: parseInt(overlay.style.height, 10)\n }]);\n\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n enableUserSelect();\n }\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n let selection = window.getSelection();\n selection.removeAllRanges();\n if (overlay && overlay.parentNode) {\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n document.removeEventListener('mousemove', handleDocumentMousemove);\n }\n }\n}\n\n/**\n * Save a rect annotation\n *\n * @param {String} type The type of rect (area, highlight, strikeout)\n * @param {Array} rects The rects to use for annotation\n * @param {String} color The color of the rects\n */\nfunction saveRect(type, rects, color) {\n let svg = findSVGAtPoint(rects[0].left, rects[0].top);\n let annotation;\n\n if (!svg) {\n return;\n }\n\n let boundingRect = svg.getBoundingClientRect();\n\n if (!color) {\n if (type === 'highlight') {\n color = 'FFFF00';\n }\n else if (type === 'strikeout') {\n color = 'FF0000';\n }\n }\n\n // Initialize the annotation\n annotation = {\n type,\n color,\n rectangles: [...rects].map((r) => {\n let offset = 0;\n\n if (type === 'strikeout') {\n offset = r.height / 2;\n }\n\n return convertToSvgRect({\n y: (r.top + offset) - boundingRect.top,\n x: r.left - boundingRect.left,\n width: r.width,\n height: r.height\n }, svg);\n }).filter((r) => r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1)\n };\n\n // Short circuit if no rectangles exist\n if (annotation.rectangles.length === 0) {\n return;\n }\n\n // Special treatment for area as it only supports a single rect\n if (type === 'area') {\n let rect = annotation.rectangles[0];\n delete annotation.rectangles;\n annotation.x = rect.x;\n annotation.y = rect.y;\n annotation.width = rect.width;\n annotation.height = rect.height;\n }\n\n let { documentId, pageNumber } = getMetadata(svg);\n\n // Add the annotation\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n}\n\n/**\n * Enable rect behavior\n */\nexport function enableRect(type) {\n _type = type;\n\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n document.addEventListener('mousedown', handleDocumentMousedown);\n document.addEventListener('keyup', handleDocumentKeyup);\n}\n\n/**\n * Disable rect behavior\n */\nexport function disableRect() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('keyup', handleDocumentKeyup);\n}\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet _type;\nlet _circleRadius = 10;\nlet _circleColor = '0000FF';\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} circleRadius The radius of the circle\n * @param {String} circleColor The color of the circle\n */\nexport function setCircle(circleRadius = 10, circleColor = '0000FF') {\n _circleRadius = parseInt(circleRadius, 10);\n _circleColor = circleColor;\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n let svg = findSVGAtPoint(e.clientX, e.clientY);\n if (!svg) {\n return;\n }\n let rect = svg.getBoundingClientRect();\n saveCircle(svg, _type, {\n x: e.clientX - rect.left,\n y: e.clientY - rect.top\n }, _circleRadius, _circleColor);\n}\n\n/**\n * Save a circle annotation\n *\n * @param {SVGElement} svg\n * @param {String} type The type of circle (circle, emptycircle, fillcircle)\n * @param {Object} pt The point to use for annotation\n * @param {float} radius\n * @param {String} color The color of the rects\n */\nfunction saveCircle(svg, type, pt, radius, color) {\n // Initialize the annotation\n let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg);\n let annotation = {\n type,\n color,\n cx: svg_pt[0],\n cy: svg_pt[1],\n r: radius\n };\n\n let { documentId, pageNumber } = getMetadata(svg);\n\n // Add the annotation\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n}\n\n/**\n * Enable circle behavior\n */\nexport function enableCircle(type) {\n _type = type;\n\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Disable circle behavior\n */\nexport function disableCircle() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\nexport function addCircle(type, e) {\n let oldType = _type;\n _type = type;\n handleDocumentMouseup(e);\n _type = oldType;\n}\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet input;\nlet _textSize = localStorage.getItem(`text/size`) || 12;\nlet _textColor = localStorage.getItem(`text/color`) || '#000000';\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n if (!e.srcElement.classList.contains('annotationLayer')) {\n return;\n }\n input = document.createElement('textarea');\n input.setAttribute('id', 'pdf-annotate-text-input');\n input.setAttribute('placeholder', 'Enter text... SHIFT + ENTER for new line');\n input.style.border = `3px solid ${BORDER_COLOR}`;\n input.style.borderRadius = '3px';\n input.style.position = 'fixed';\n input.style.top = `${e.clientY}px`;\n input.style.left = `${e.clientX}px`;\n input.style.fontSize = `${_textSize}px`;\n input.style.zIndex = '41';\n input.addEventListener('blur', handleInputBlur);\n input.addEventListener('keyup', handleInputKeyup);\n\n document.body.appendChild(input);\n input.focus();\n}\n\n/**\n * Handle input.blur event\n */\nfunction handleInputBlur() {\n saveText();\n}\n\n/**\n * Handle input.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleInputKeyup(e) {\n if (e.keyCode === 27) {\n closeInput();\n }\n else if (e.keyCode === 13 && !e.shiftKey) {\n saveText();\n }\n}\n\n/**\n * Save a text annotation from input\n */\nfunction saveText() {\n let value = (input.value) ? input.value.replace(/ +$/, '') : '';\n if (value.length > 0) {\n let clientX = parseInt(input.style.left, 10);\n let clientY = parseInt(input.style.top, 10);\n let svg = findSVGAtPoint(clientX, clientY);\n if (!svg) {\n return;\n }\n let height = _textSize;\n let { documentId, pageNumber, viewport } = getMetadata(svg);\n let scale = 1 / viewport.scale;\n let rect = svg.getBoundingClientRect();\n let pt = convertToSvgPoint([\n clientX - rect.left,\n clientY - rect.top + height], svg, viewport);\n let annotation = {\n type: 'textbox',\n size: _textSize * scale,\n color: _textColor,\n content: value,\n x: pt[0],\n y: pt[1],\n rotation: -viewport.rotation\n };\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n }\n\n closeInput();\n}\n\n/**\n * Close the input\n */\nfunction closeInput() {\n if (input) {\n input.removeEventListener('blur', handleInputBlur);\n input.removeEventListener('keyup', handleInputKeyup);\n document.body.removeChild(input);\n input = null;\n }\n}\n\n/**\n * Set the text attributes\n *\n * @param {Number} textSize The size of the text\n * @param {String} textColor The color of the text\n */\nexport function setText(textSize = 12, textColor = '000000') {\n _textSize = parseInt(textSize, 10);\n _textColor = textColor;\n}\n\n/**\n * Enable text behavior\n */\nexport function enableText() {\n if (_enabled) {\n return;\n }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Disable text behavior\n */\nexport function disableText() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n","/**\n * Create a node that is only visible to screen readers\n *\n * @param {String} content The text content that should be read by screen reader\n * @param {String} [annotationId] The ID of the annotation assocaited\n * @return {Element} An Element that is only visible to screen readers\n */\nexport default function createScreenReaderOnly(content, annotationId) {\n let node = document.createElement('div');\n let text = document.createTextNode(content);\n node.appendChild(text);\n node.setAttribute('id', `pdf-annotate-screenreader-${annotationId}`);\n node.style.position = 'absolute';\n node.style.left = '-10000px';\n node.style.top = 'auto';\n node.style.width = '1px';\n node.style.height = '1px';\n node.style.overflow = 'hidden';\n return node;\n}\n","import config from '../config';\nimport {\n pointIntersectsRect,\n scaleUp,\n scaleDown\n} from '../UI/utils';\n\n/**\n * Insert an element at a point within the document.\n * This algorithm will only insert within an element amidst it's text content.\n *\n * @param {Element} el The element to be inserted\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page number to limit elements to\n * @param {Boolean} insertBefore Whether the element is to be inserted before or after x\n * @return {Boolean} True if element was able to be inserted, otherwise false\n */\nexport default function insertElementWithinElement(el, x, y, pageNumber, insertBefore) {\n const OFFSET_ADJUST = 2;\n\n // If inserting before adjust `x` by looking for element a few px to the right\n // Otherwise adjust a few px to the left\n // This is to allow a little tolerance by searching within the box, instead\n // of getting a false negative by testing right on the border.\n x = Math.max(x + (OFFSET_ADJUST * (insertBefore ? 1 : -1)), 0);\n\n let node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber);\n if (!node) {\n return false;\n }\n\n // Now that node has been found inverse the adjustment for `x`.\n // This is done to accomodate tolerance by cutting off on the outside of the\n // text boundary, instead of missing a character by cutting off within.\n x = x + (OFFSET_ADJUST * (insertBefore ? -1 : 1));\n\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let left = scaleDown(svg, {left: node.getBoundingClientRect().left}).left - svg.getBoundingClientRect().left;\n let temp = node.cloneNode(true);\n let head = temp.innerHTML.split('');\n let tail = [];\n\n // Insert temp off screen\n temp.style.position = 'absolute';\n temp.style.top = '-10000px';\n temp.style.left = '-10000px';\n document.body.appendChild(temp);\n\n while (head.length) {\n // Don't insert within HTML tags\n if (head[head.length - 1] === '>') {\n while (head.length) {\n tail.unshift(head.pop());\n if (tail[0] === '<') {\n break;\n }\n }\n }\n\n // Check if width of temp based on current head value satisfies x\n temp.innerHTML = head.join('');\n let width = scaleDown(svg, {width: temp.getBoundingClientRect().width}).width;\n if (left + width <= x) {\n break;\n }\n tail.unshift(head.pop());\n }\n\n // Update original node with new markup, including element to be inserted\n node.innerHTML = head.join('') + el.outerHTML + tail.join('');\n temp.parentNode.removeChild(temp);\n\n return true;\n}\n\n/**\n * Get a text layer element at a given point on a page\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page to limit elements to\n * @return {Element} First text layer element found at the point\n */\nfunction textLayerElementFromPoint(x, y, pageNumber) {\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let rect = svg.getBoundingClientRect();\n y = scaleUp(svg, {y}).y + rect.top;\n x = scaleUp(svg, {x}).x + rect.left;\n return [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' [data-canvas-width]')].filter((el) => {\n return pointIntersectsRect(x, y, el.getBoundingClientRect());\n })[0];\n}\n","import config from '../config';\nimport insertElementWithinElement from './insertElementWithinElement';\nimport { pointIntersectsRect, scaleUp } from '../UI/utils';\n\n/**\n * Insert an element at a point within the document.\n * This algorithm will try to insert between elements if possible.\n * It will however use `insertElementWithinElement` if it is more accurate.\n *\n * @param {Element} el The element to be inserted\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page number to limit elements to\n * @return {Boolean} True if element was able to be inserted, otherwise false\n */\nexport default function insertElementWithinChildren(el, x, y, pageNumber) {\n // Try and use most accurate method of inserting within an element\n if (insertElementWithinElement(el, x, y, pageNumber, true)) {\n return true;\n }\n\n // Fall back to inserting between elements\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let rect = svg.getBoundingClientRect();\n let nodes = [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' > div')];\n\n y = scaleUp(svg, {y}).y + rect.top;\n x = scaleUp(svg, {x}).x + rect.left;\n\n // Find the best node to insert before\n for (let i = 0, l = nodes.length; i < l; i++) {\n let n = nodes[i];\n let r = n.getBoundingClientRect();\n if (y <= r.top) {\n n.parentNode.insertBefore(el, n);\n return true;\n }\n }\n\n // If all else fails try to append to the bottom\n let textLayer = svg.parentNode.querySelector(config.textClassQuery());\n if (textLayer) {\n let textRect = textLayer.getBoundingClientRect();\n if (pointIntersectsRect(x, y, textRect)) {\n textLayer.appendChild(el);\n return true;\n }\n }\n\n return false;\n}\n","/**\n * Insert a comment into the DOM to be available by screen reader\n *\n * @param {Object} comment The comment to be inserted\n */\nexport default function insertScreenReaderComment(comment) {\n if (!comment) {\n return;\n }\n\n let list = document.querySelector(`#pdf-annotate-screenreader-${comment.annotation} ol`);\n if (list) {\n let item = document.createElement('li');\n item.setAttribute('id', `pdf-annotate-screenreader-comment-${comment.uuid}`);\n item.appendChild(document.createTextNode(`${comment.content}`));\n list.appendChild(item);\n }\n}\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport insertScreenReaderComment from './insertScreenReaderComment';\n\n/**\n * Insert the comments into the DOM to be available by screen reader\n *\n * Example output:\n *
\n *
Begin highlight 1
\n *
    \n *
  1. Foo
  2. \n *
  3. Bar
  4. \n *
  5. Baz
  6. \n *
  7. Qux
  8. \n *
\n *
\n *
Some highlighted text goes here...
\n *
End highlight 1
\n *\n * NOTE: `screenReaderOnly` is not a real class, just used for brevity\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The ID of the annotation\n * @param {Array} [comments] Optionally preloaded comments to be rendered\n * @return {Promise} Promise that once has comments, render them for screen reader\n */\nexport default function renderScreenReaderComments(documentId, annotationId, comments) {\n let promise;\n\n if (Array.isArray(comments)) {\n promise = Promise.resolve(comments);\n }\n else {\n promise = PDFJSAnnotate.getStoreAdapter().getComments(documentId, annotationId);\n }\n\n return promise.then((comments) => {\n // Node needs to be found by querying DOM as it may have been inserted as innerHTML\n // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`).\n let node = document.getElementById(`pdf-annotate-screenreader-${annotationId}`);\n if (node) {\n let list = document.createElement('ol');\n list.setAttribute('id', `pdf-annotate-screenreader-comment-list-${annotationId}`);\n list.setAttribute('aria-label', 'Comments');\n node.appendChild(list);\n comments.forEach(insertScreenReaderComment);\n }\n });\n}\n","import createScreenReaderOnly from './createScreenReaderOnly';\nimport insertElementWithinChildren from './insertElementWithinChildren';\nimport insertElementWithinElement from './insertElementWithinElement';\nimport renderScreenReaderComments from './renderScreenReaderComments';\n\n// Annotation types that support comments\nconst COMMENT_TYPES = ['highlight', 'point', 'area', 'circle', 'emptycircle', 'fillcircle'];\n\n/**\n * Insert a hint into the DOM for screen readers for a specific annotation.\n *\n * @param {Object} annotation The annotation to insert a hint for\n * @param {Number} num The number of the annotation out of all annotations of the same type\n */\nexport default function insertScreenReaderHint(annotation, num = 0) {\n switch (annotation.type) {\n case 'highlight':\n case 'strikeout':\n let rects = annotation.rectangles;\n let first = rects[0];\n let last = rects[rects.length - 1];\n\n insertElementWithinElement(\n createScreenReaderOnly(`Begin ${annotation.type} annotation ${num}`, annotation.uuid),\n first.x, first.y, annotation.page, true\n );\n\n insertElementWithinElement(\n createScreenReaderOnly(`End ${annotation.type} annotation ${num}`, `${annotation.uuid}-end`),\n last.x + last.width, last.y, annotation.page, false\n );\n break;\n\n case 'textbox':\n case 'point':\n let text = annotation.type === 'textbox' ? ` (content: ${annotation.content})` : '';\n\n insertElementWithinChildren(\n createScreenReaderOnly(`${annotation.type} annotation ${num}${text}`, annotation.uuid),\n annotation.x, annotation.y, annotation.page\n );\n break;\n\n case 'drawing':\n case 'area':\n let x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0];\n let y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1];\n\n insertElementWithinChildren(\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\n x, y, annotation.page\n );\n break;\n\n case 'circle':\n case 'fillcircle':\n case 'emptycircle':\n let x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0];\n let y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1];\n\n insertElementWithinChildren(\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\n x2, y2, annotation.page\n );\n break;\n }\n\n // Include comments in screen reader hint\n if (COMMENT_TYPES.includes(annotation.type)) {\n renderScreenReaderComments(annotation.documentId, annotation.uuid);\n }\n}\n","import renderScreenReaderHints from './renderScreenReaderHints';\nimport insertScreenReaderComment from './insertScreenReaderComment';\nimport renderScreenReaderComments from './renderScreenReaderComments';\nimport { addEventListener } from '../UI/event';\nimport PDFJSAnnotate from '../PDFJSAnnotate';\n\n/**\n * Initialize the event handlers for keeping screen reader hints synced with data\n */\nexport default function initEventHandlers() {\n addEventListener('annotation:add', (documentId, pageNumber, annotation) => {\n reorderAnnotationsByType(documentId, pageNumber, annotation.type);\n });\n addEventListener('annotation:edit', (documentId, annotationId, annotation) => {\n reorderAnnotationsByType(documentId, annotation.page, annotation.type);\n });\n addEventListener('annotation:delete', removeAnnotation);\n addEventListener('comment:add', insertComment);\n addEventListener('comment:delete', removeComment);\n}\n\n/**\n * Reorder the annotation numbers by annotation type\n *\n * @param {String} documentId The ID of the document\n * @param {Number} pageNumber The page number of the annotations\n * @param {Strig} type The annotation type\n */\nfunction reorderAnnotationsByType(documentId, pageNumber, type) {\n PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, pageNumber)\n .then((annotations) => {\n return annotations.annotations.filter((a) => {\n return a.type === type;\n });\n })\n .then((annotations) => {\n annotations.forEach((a) => {\n removeAnnotation(documentId, a.uuid);\n });\n\n return annotations;\n })\n .then(renderScreenReaderHints);\n}\n\n/**\n * Remove the screen reader hint for an annotation\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The Id of the annotation\n */\nfunction removeAnnotation(documentId, annotationId) {\n removeElementById(`pdf-annotate-screenreader-${annotationId}`);\n removeElementById(`pdf-annotate-screenreader-${annotationId}-end`);\n}\n\n/**\n * Insert a screen reader hint for a comment\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The ID of tha assocated annotation\n * @param {Object} comment The comment to insert a hint for\n */\nfunction insertComment(documentId, annotationId, comment) {\n let list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\n let promise;\n\n if (!list) {\n promise = renderScreenReaderComments(documentId, annotationId, []).then(() => {\n list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\n return true;\n });\n }\n else {\n promise = Promise.resolve(true);\n }\n\n promise.then(() => {\n insertScreenReaderComment(comment);\n });\n}\n\n/**\n * Remove a screen reader hint for a comment\n *\n * @param {String} documentId The ID of the document\n * @param {String} commentId The ID of the comment\n */\nfunction removeComment(documentId, commentId) {\n removeElementById(`pdf-annotate-screenreader-comment-${commentId}`);\n}\n\n/**\n * Remove an element from the DOM by it's ID if it exists\n *\n * @param {String} elementId The ID of the element to be removed\n */\nfunction removeElementById(elementId) {\n let el = document.getElementById(elementId);\n if (el) {\n el.parentNode.removeChild(el);\n }\n}\n","import insertScreenReaderHint from './insertScreenReaderHint';\nimport initEventHandlers from './initEventHandlers';\n\n// TODO This is not the right place for this to live\ninitEventHandlers();\n\n/**\n * Insert hints into the DOM for screen readers.\n *\n * @param {Array} annotations The annotations that hints are inserted for\n */\nexport default function renderScreenReaderHints(annotations) {\n annotations = Array.isArray(annotations) ? annotations : [];\n\n // Insert hints for each type\n Object.keys(SORT_TYPES).forEach((type) => {\n let sortBy = SORT_TYPES[type];\n annotations\n .filter((a) => a.type === type)\n .sort(sortBy)\n .forEach((a, i) => insertScreenReaderHint(a, i + 1));\n });\n}\n\n// Sort annotations first by y, then by x.\n// This allows hints to be injected in the order they appear,\n// which makes numbering them easier.\nfunction sortByPoint(a, b) {\n if (a.y < b.y) {\n return a.x - b.x;\n }\n else {\n return 1;\n }\n}\n\n// Sort annotation by it's first rectangle\nfunction sortByRectPoint(a, b) {\n return sortByPoint(a.rectangles[0], b.rectangles[0]);\n}\n\n// Sort annotation by it's first line\nfunction sortByLinePoint(a, b) {\n let lineA = a.lines[0];\n let lineB = b.lines[0];\n return sortByPoint(\n {x: lineA[0], y: lineA[1]},\n {x: lineB[0], y: lineB[1]}\n );\n}\n\n// Arrange supported types and associated sort methods\nconst SORT_TYPES = {\n 'highlight': sortByRectPoint,\n 'strikeout': sortByRectPoint,\n 'drawing': sortByLinePoint,\n 'textbox': sortByPoint,\n 'point': sortByPoint,\n 'area': sortByPoint\n};\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport renderScreenReaderHints from '../a11y/renderScreenReaderHints';\n\n// Template for creating a new page\nconst PAGE_TEMPLATE = `\n
\n
\n \n
\n
\n \n
\n`;\n\n/**\n * Create a new page to be appended to the DOM.\n *\n * @param {Number} pageNumber The page number that is being created\n * @return {HTMLElement}\n */\nexport function createPage(pageNumber) {\n let temp = document.createElement('div');\n temp.innerHTML = PAGE_TEMPLATE;\n\n let page = temp.children[0];\n let canvas = page.querySelector('canvas');\n\n page.setAttribute('id', `pageContainer${pageNumber}`);\n page.setAttribute('data-page-number', pageNumber);\n\n canvas.mozOpaque = true;\n canvas.setAttribute('id', `page${pageNumber}`);\n\n return page;\n}\n\n/**\n * Render a page that has already been created.\n *\n * @param {Number} pageNumber The page number to be rendered\n * @param {Object} renderOptions The options for rendering\n * @return {Promise} Settled once rendering has completed\n * A settled Promise will be either:\n * - fulfilled: [pdfPage, annotations]\n * - rejected: Error\n */\nexport function renderPage(pageNumber, renderOptions) {\n let {\n documentId,\n pdfDocument,\n scale,\n rotate\n } = renderOptions;\n\n const eventBus = new pdfjsViewer.EventBus();\n\n // Load the page and annotations\n return Promise.all([\n pdfDocument.getPage(pageNumber),\n PDFJSAnnotate.getAnnotations(documentId, pageNumber)\n ]).then(([pdfPage, annotations]) => {\n let page = document.getElementById(`pageContainer${pageNumber}`);\n let svg = page.querySelector(config.annotationClassQuery());\n let canvas = page.querySelector('.canvasWrapper canvas');\n let canvasContext = canvas.getContext('2d', {alpha: false});\n let totalRotation = (rotate + pdfPage.rotate) % 360;\n let viewport = pdfPage.getViewport({scale: scale, rotation: totalRotation});\n let transform = scalePage(pageNumber, viewport, canvasContext);\n\n // Render the page\n return Promise.all([\n pdfPage.render({ canvasContext, viewport, transform }).promise,\n PDFJSAnnotate.render(svg, viewport, annotations)\n ]).then(() => {\n // Text content is needed for a11y, but is also necessary for creating\n // highlight and strikeout annotations which require selecting text.\n return pdfPage.getTextContent({normalizeWhitespace: true}).then((textContent) => {\n return new Promise((resolve, reject) => {\n // Render text layer for a11y of text content\n let textLayer = page.querySelector(config.textClassQuery());\n let textLayerFactory = new pdfjsViewer.DefaultTextLayerFactory();\n let textLayerBuilder = textLayerFactory.createTextLayerBuilder(\n textLayer,\n pageNumber - 1,\n viewport,\n false,\n eventBus\n );\n textLayerBuilder.setTextContent(textContent);\n textLayerBuilder.render();\n\n // Enable a11y for annotations\n // Timeout is needed to wait for `textLayerBuilder.render`\n setTimeout(() => {\n try {\n renderScreenReaderHints(annotations.annotations);\n resolve();\n }\n catch (e) {\n reject(e);\n }\n });\n });\n });\n }).then(() => {\n // Indicate that the page was loaded\n page.setAttribute('data-loaded', 'true');\n\n return [pdfPage, annotations];\n });\n });\n}\n\n/**\n * Scale the elements of a page.\n *\n * @param {Number} pageNumber The page number to be scaled\n * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate))\n * @param {Object} context The canvas context that the PDF page is rendered to\n * @return {Array} The transform data for rendering the PDF page\n */\nfunction scalePage(pageNumber, viewport, context) {\n let page = document.getElementById(`pageContainer${pageNumber}`);\n let canvas = page.querySelector('.canvasWrapper canvas');\n let svg = page.querySelector(config.annotationClassQuery());\n let wrapper = page.querySelector('.canvasWrapper');\n let textLayer = page.querySelector(config.textClassQuery());\n let outputScale = getOutputScale(context);\n let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];\n let sfx = approximateFraction(outputScale.sx);\n let sfy = approximateFraction(outputScale.sy);\n\n // Adjust width/height for scale\n page.style.visibility = '';\n canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);\n canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);\n canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';\n canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';\n svg.setAttribute('width', viewport.width);\n svg.setAttribute('height', viewport.height);\n svg.style.width = `${viewport.width}px`;\n svg.style.height = `${viewport.height}px`;\n page.style.width = `${viewport.width}px`;\n page.style.height = `${viewport.height}px`;\n wrapper.style.width = `${viewport.width}px`;\n wrapper.style.height = `${viewport.height}px`;\n textLayer.style.width = `${viewport.width}px`;\n textLayer.style.height = `${viewport.height}px`;\n\n return transform;\n}\n\n/**\n * Approximates a float number as a fraction using Farey sequence (max order of 8).\n *\n * @param {Number} x Positive float number\n * @return {Array} Estimated fraction: the first array item is a numerator,\n * the second one is a denominator.\n */\nfunction approximateFraction(x) {\n // Fast path for int numbers or their inversions.\n if (Math.floor(x) === x) {\n return [x, 1];\n }\n\n const xinv = 1 / x;\n const limit = 8;\n if (xinv > limit) {\n return [1, limit];\n }\n else if (Math.floor(xinv) === xinv) {\n return [1, xinv];\n }\n\n const x_ = x > 1 ? xinv : x;\n\n // a/b and c/d are neighbours in Farey sequence.\n let a = 0; let b = 1; let c = 1; let d = 1;\n\n // Limit search to order 8.\n while (true) {\n // Generating next term in sequence (order of q).\n let p = a + c; let q = b + d;\n if (q > limit) {\n break;\n }\n if (x_ <= p / q) {\n c = p; d = q;\n }\n else {\n a = p; b = q;\n }\n }\n\n // Select closest of neighbours to x.\n if (x_ - a / b < c / d - x_) {\n return x_ === x ? [a, b] : [b, a];\n }\n else {\n return x_ === x ? [c, d] : [d, c];\n }\n}\n\nfunction getOutputScale(ctx) {\n let devicePixelRatio = window.devicePixelRatio || 1;\n let backingStoreRatio = ctx.webkitBackingStorePixelRatio ||\n ctx.mozBackingStorePixelRatio ||\n ctx.msBackingStorePixelRatio ||\n ctx.oBackingStorePixelRatio ||\n ctx.backingStorePixelRatio || 1;\n let pixelRatio = devicePixelRatio / backingStoreRatio;\n return {\n sx: pixelRatio,\n sy: pixelRatio,\n scaled: pixelRatio !== 1\n };\n}\n\nfunction roundToDivide(x, div) {\n let r = x % div;\n return r === 0 ? x : Math.round(x - r + div);\n}\n","import { addEventListener, removeEventListener, fireEvent } from './event';\nimport { disableEdit, enableEdit } from './edit';\nimport { disablePen, enablePen, setPen } from './pen';\nimport { disableArrow, enableArrow, setArrow } from './arrow';\nimport { disableEraser, enableEraser } from './eraser';\nimport { disablePoint, enablePoint } from './point';\nimport { disableRect, enableRect } from './rect';\nimport { disableCircle, enableCircle, setCircle, addCircle } from './circle';\nimport { disableText, enableText, setText } from './text';\nimport { createPage, renderPage } from './page';\n\nexport default {\n addEventListener,\n removeEventListener,\n fireEvent,\n\n disableEdit,\n enableEdit,\n\n disablePen,\n enablePen,\n setPen,\n\n disablePoint,\n enablePoint,\n\n disableRect,\n enableRect,\n\n disableCircle,\n enableCircle,\n setCircle,\n addCircle,\n\n disableArrow,\n enableArrow,\n setArrow,\n\n disableEraser,\n enableEraser,\n\n disableText,\n enableText,\n setText,\n\n createPage,\n renderPage\n};\n","import StoreAdapter from './adapter/StoreAdapter';\nimport LocalStoreAdapter from './adapter/LocalStoreAdapter';\nimport LocalUserStoreAdapter from './adapter/LocalUserStoreAdapter';\nimport render from './render';\nimport UI from './UI';\nimport config from './config';\nimport uuid from './utils/uuid';\nimport {\n findAnnotationAtPoint,\n findSVGContainer,\n convertToScreenPoint\n} from './UI/utils';\n\nexport default {\n findAnnotationAtPoint,\n findSVGContainer,\n convertToScreenPoint,\n\n /**\n * Abstract class that needs to be defined so PDFJSAnnotate\n * knows how to communicate with your server.\n */\n StoreAdapter,\n\n /**\n * Implementation of StoreAdapter that stores annotation data to localStorage.\n */\n LocalStoreAdapter,\n\n /**\n * Implementation of StoreAdapter that stores annotation data to localStorage particular\n * to a specific user\n */\n LocalUserStoreAdapter,\n\n /**\n * Abstract instance of StoreAdapter\n */\n __storeAdapter: new StoreAdapter(),\n\n /**\n * Getter for the underlying StoreAdapter property\n *\n * @return {StoreAdapter}\n */\n getStoreAdapter() {\n return this.__storeAdapter;\n },\n\n /**\n * Setter for the underlying StoreAdapter property\n *\n * @param {StoreAdapter} adapter The StoreAdapter implementation to be used.\n */\n setStoreAdapter(adapter) {\n // TODO this throws an error when bundled\n // if (!(adapter instanceof StoreAdapter)) {\n // throw new Error('adapter must be an instance of StoreAdapter');\n // }\n\n this.__storeAdapter = adapter;\n },\n\n /**\n * UI is a helper for instrumenting UI interactions for creating,\n * editing, and deleting annotations in the browser.\n */\n UI,\n\n /**\n * Render the annotations for a page in the PDF Document\n *\n * @param {SVGElement} svg The SVG element that annotations should be rendered to\n * @param {PageViewport} viewport The PDFPage.getViewport data\n * @param {Object} data The StoreAdapter.getAnnotations data\n * @return {Promise}\n */\n render,\n\n /**\n * Convenience method for getting annotation data\n *\n * @alias StoreAdapter.getAnnotations\n * @param {String} documentId The ID of the document\n * @param {String} pageNumber The page number\n * @return {Promise}\n */\n getAnnotations(documentId, pageNumber) {\n return this.getStoreAdapter().getAnnotations(...arguments);\n },\n\n config,\n\n uuid\n};\n","import { appendChild, transformChild } from './appendChild';\n\n/**\n * Render the response from PDFJSAnnotate.getStoreAdapter().getAnnotations to SVG\n *\n * @param {SVGElement} svg The SVG element to render the annotations to\n * @param {Object} viewport The page viewport data\n * @param {Object} data The response from PDFJSAnnotate.getStoreAdapter().getAnnotations\n * @return {Promise} Settled once rendering has completed\n * A settled Promise will be either:\n * - fulfilled: SVGElement\n * - rejected: Error\n */\nexport default function render(svg, viewport, data) {\n return new Promise((resolve, reject) => {\n // Reset the content of the SVG\n svg.setAttribute('data-pdf-annotate-container', true);\n svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport));\n svg.removeAttribute('data-pdf-annotate-document');\n svg.removeAttribute('data-pdf-annotate-page');\n\n // If there's no data nothing can be done\n if (!data) {\n svg.innerHTML = '';\n return resolve(svg);\n }\n\n svg.setAttribute('data-pdf-annotate-document', data.documentId);\n svg.setAttribute('data-pdf-annotate-page', data.pageNumber);\n\n // Make sure annotations is an array\n if (!Array.isArray(data.annotations) || data.annotations.length === 0) {\n return resolve(svg);\n }\n\n // Append or transform annotation to svg\n data.annotations.forEach((a) => {\n let node = svg.querySelector('[data-pdf-annotate-id=\"' + a.uuid + '\"]');\n if (node) {\n transformChild(svg, node, viewport);\n }\n else {\n appendChild(svg, a, viewport);\n }\n });\n\n resolve(svg);\n });\n}\n","import PDFJSAnnotate from './src/PDFJSAnnotate';\n\nexport default PDFJSAnnotate;\n"],"names":["root","factory","exports","module","define","amd","self","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","prototype","call","ownKeys","Object","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","value","EventEmitter","init","this","once","emitter","name","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","m","events","existing","warning","create","newListener","emit","unshift","push","length","warned","w","Error","String","count","console","warn","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","bind","_listeners","unwrap","evlistener","arr","ret","Array","i","unwrapListeners","arrayClone","listenerCount","n","copy","addEventListener","wrapListener","arg","removeEventListener","defineProperty","enumerable","get","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","error","er","message","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","key","keys","rawListeners","eventNames","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","getter","__esModule","d","a","definition","o","obj","prop","hasOwnProperty","r","Symbol","toStringTag","abstractFunction","UPPER_REGEX","BLACKLIST","keyCase","indexOf","replace","match","toLowerCase","setAttributes","node","attributes","forEach","setAttribute","REGEX_HASHLESS_HEX","normalizeColor","color","test","SIZE","D","createRect","rect","document","createElementNS","x","y","width","height","renderText","text","fill","fontSize","size","transform","rotation","style","textElement","textContent","_step","lines","split","getAttribute","_iterator","_createForOfIteratorHelper","s","done","line","tspan","toString","innerHTML","appendChild","e","f","insertLineBreaks","content","g","translate","rotate","angle","Math","PI","cosValue","cos","sinValue","sin","scale","makePoint","z","makeVector","xcoord","ycoord","zcoord","makeVectorFromPoints","pt1","pt2","addVector","pt","v","multiplyVector","scalar","magnitude","sqrt","pow","negateVector","unitVector","mag","isFirefox","navigator","userAgent","getTranslation","viewport","trans","nodeName","parseInt","path","querySelector","svg","parentNode","assign","annotation","child","group","JSON","parse","fillOpacity","rectangles","stroke","renderRect","circle","cx","cy","createCircle","renderCircle","strokeWidth","x1","y1","x2","y2","outerSVG","innerSVG","viewBox","renderPoint","l","p1","join","renderPath","u","arrow","p2","pt0","unitX","unitY","thickness","A","B","C","G","F","E","points","renderArrow","uuid","filter","BORDER_COLOR","userSelectStyleSheet","createElement","findSVGContainer","toUpperCase","findSVGAtPoint","elements","querySelectorAll","el","pointIntersectsRect","getBoundingClientRect","findAnnotationAtPoint","candidate","elementFromPoint","top","bottom","left","right","scaleUp","result","getMetadata","convertToSvgPoint","xform","p","offset","convertToScreenPoint","scaleDown","disableUserSelect","head","enableUserSelect","removeChild","documentId","pageNumber","clickNode","fireEvent","clientX","clientY","StoreAdapter","_this","_classCallCheck","__getAnnotations","fn","then","annotations","annotationId","__addAnnotation","__editAnnotation","__deleteAnnotation","success","__addComment","comment","commentId","__deleteComment","REGEXP","replacement","c","random","LocalStoreAdapter","_StoreAdapter","_callSuper","getAnnotations","page","getAnnotation","findAnnotation","addAnnotation","updateAnnotations","editAnnotation","deleteAnnotation","splice","getComments","addComment","class","deleteComment","_inherits","localStorage","getItem","setItem","stringify","LocalUserStoreAdapter","userId","globalEdit","getAllAnnotations","_userId","_globalEdit","all_annotations","re","RegExp","search","annotationLayerName","textLayerName","annotationSvgQuery","annotationClassQuery","textClassQuery","overlay","dragOffsetX","dragOffsetY","dragStartX","dragStartY","_enabled","isDragging","destroyEditOverlay","handleDocumentClick","handleDocumentKeyup","handleDocumentMousedown","handleDocumentMousemove","handleDocumentMouseup","config","PDFJSAnnotate","getStoreAdapter","_toConsumableArray","getElementById","keyTest","keyCode","preventDefault","offsetLeft","offsetTop","background","cursor","display","maxY","maxX","offsetHeight","offsetWidth","attribX","attribY","modelStart","modelEnd","modelDelta","firstChild","t","modelX","modelY","setTimeout","handleAnnotationClick","anchor","id","extraOffsetWidth","extraOffsetHeight","tagName","getBBox","bbox","_getOffset","getOffset","getOffsetAnnotationRect","styleLeft","styleTop","boxSizing","border","borderRadius","zIndex","padding","textAlign","textDecoration","borderColor","boxShadow","createEditOverlay","_penSize","_penColor","_candraw","handleDocumentPointerdown","handleDocumentPointerup","_getMetadata","saveToStorage","handleDocumentPointermove","point","toFixed","savePoint","originY","originX","_getMetadata2","_canerase","previousPoint","handleDocumentDown","handleDocumentUp","erase","handleDocumentMouseMove","check","diffX","abs","diffY","maxSteps","round","max","subStepSize","min","smallerTest","startPoint","_i","_check","parentElement","input","handleInputBlur","handleInputKeyup","body","focus","closeInput","trim","_type","rects","window","getSelection","getRangeAt","getClientRects","getSelectionRects","saveRect","map","removeAllRanges","boundingRect","convertToSvgRect","_circleRadius","_circleColor","radius","svg_pt","saveCircle","_textSize","_textColor","srcElement","classList","contains","saveText","shiftKey","createScreenReaderOnly","createTextNode","overflow","insertElementWithinElement","insertBefore","textLayerElementFromPoint","temp","cloneNode","tail","outerHTML","insertElementWithinChildren","nodes","textLayer","insertScreenReaderComment","item","renderScreenReaderComments","comments","isArray","COMMENT_TYPES","reorderAnnotationsByType","removeAnnotation","renderScreenReaderHints","removeElementById","elementId","SORT_TYPES","sortBy","sort","num","first","last","includes","insertScreenReaderHint","sortByPoint","b","sortByRectPoint","lineA","lineB","PAGE_TEMPLATE","approximateFraction","floor","xinv","x_","q","roundToDivide","div","disableEdit","enableEdit","disablePen","enablePen","setPen","penSize","penColor","parseFloat","disablePoint","enablePoint","disableRect","enableRect","disableCircle","enableCircle","setCircle","circleColor","addCircle","oldType","disableArrow","enableArrow","setArrow","disableEraser","enableEraser","disableText","enableText","setText","textColor","createPage","children","canvas","mozOpaque","renderPage","renderOptions","pdfDocument","eventBus","pdfjsViewer","EventBus","all","getPage","_ref","_ref2","pdfPage","canvasContext","getContext","alpha","totalRotation","getViewport","ctx","pixelRatio","wrapper","outputScale","sx","devicePixelRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","sy","scaled","sfx","sfy","visibility","scalePage","render","promise","getTextContent","normalizeWhitespace","textLayerBuilder","DefaultTextLayerFactory","createTextLayerBuilder","setTextContent","__storeAdapter","setStoreAdapter","adapter","UI","data","removeAttribute","transformChild","_this$getStoreAdapter"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pdf-annotate.min.js b/dist/pdf-annotate.min.js index 8dd179b4..c97b6af7 100644 --- a/dist/pdf-annotate.min.js +++ b/dist/pdf-annotate.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PDFAnnotate=e():t.PDFAnnotate=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";var r,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var a=Number.isNaN||function(t){return t!=t};function u(){u.init.call(this)}t.exports=u,t.exports.once=function(t,e){return new Promise((function(n,r){function o(n){t.removeListener(e,i),r(n)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}h(t,e,i,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&h(t,"error",e,n)}(t,o,{once:!0})}))},u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function l(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function s(t){return void 0===t._maxListeners?u.defaultMaxListeners:t._maxListeners}function d(t,e,n,r){var o,i,a,u;if(l(n),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),i=t._events),a=i[e]),void 0===a)a=i[e]=n,++t._eventsCount;else if("function"==typeof a?a=i[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=s(t))>0&&a.length>o&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,u=c,console&&console.warn&&console.warn(u)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=f.bind(r);return o.listener=n,r.wrapFn=o,o}function y(t,e,n){var r=t._events;if(void 0===r)return[];var o=r[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(a=e[0]),a instanceof Error)throw a;var u=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw u.context=a,u}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)i(c,this,e);else{var l=c.length,s=v(c,l);for(n=0;n=0;i--)if(n[i]===e||n[i].listener===e){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},u.prototype.listeners=function(t){return y(this,t,!0)},u.prototype.rawListeners=function(t){return y(this,t,!1)},u.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},u.prototype.listenerCount=m,u.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){"use strict";function r(t){throw new Error(t+" is not implemented")}n.r(e);var o=n(0),i=n.n(o),a=/[A-Z]/g,u=["viewBox"];function c(t,e){Object.keys(e).forEach((function(n){t.setAttribute(function(t){return-1===u.indexOf(t)&&(t=t.replace(a,(function(t){return"-"+t.toLowerCase()}))),t}(n),e[n])}))}var l=/^([a-f0-9]{6}|[a-f0-9]{3})$/i;function s(t){return l.test(t)&&(t="#".concat(t)),t}var d=25;function f(t){var e=document.createElementNS("http://www.w3.org/2000/svg","rect");return c(e,{x:t.x,y:t.y,width:t.width,height:t.height}),e}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0){e.push("M".concat(t.lines[0][0]," ").concat(t.lines[0][1]));for(var r=1,o=t.lines.length;r=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right}function F(t){var e=t.getBoundingClientRect(),n=e.width,r=e.height,o=0,i=0;if(["line","path"].indexOf(t.tagName.toLowerCase())>-1&&t.getBBox){var a=t.getBBox();o=(e.width-a.width)/2,i=(e.height-a.height)/2,n=a.width,r=a.height}var u=function(t){var e=t;for(;(e=e.parentNode)&&e!==document&&"SVG"!==e.nodeName.toUpperCase(););var n=e.getBoundingClientRect();return{offsetLeft:n.left,offsetTop:n.top}}(t),c=u.offsetLeft,l=u.offsetTop;return{top:e.top-l+i,left:e.left-c+o,bottom:e.bottom-l-i,right:e.right-c-o,width:n,height:r}}function X(t,e){var n={},r=W(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]*r.scale})),n}function Y(t,e,n){var r=[1,0,0,1,0,0];r=g(r=b(r,(n=n||W(e).viewport).scale,n.scale),n.rotation);var o,i,a,u=O(n);return r=h(r,u.x,u.y),o=t,a=(i=r)[0]*i[3]-i[1]*i[2],[(o[0]*i[3]-o[1]*i[2]+i[2]*i[5]-i[4]*i[3])/a,(-o[0]*i[1]+o[1]*i[0]+i[4]*i[1]-i[5]*i[0])/a]}function U(t,e,n){var r=[1,0,0,1,0,0];r=g(r=b(r,(n=n||W(e).viewport).scale,n.scale),n.rotation);var o,i,a=O(n);return r=h(r,a.x,a.y),i=r,[(o=t)[0]*i[0]+o[1]*i[2]+i[4],o[0]*i[1]+o[1]*i[3]+i[5]]}function Q(t,e){var n={},r=W(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]/r.scale})),n}function H(){M.parentNode||document.head.appendChild(M)}function D(){M.parentNode&&M.parentNode.removeChild(M)}function W(t){return{documentId:t.getAttribute("data-pdf-annotate-document"),pageNumber:parseInt(t.getAttribute("data-pdf-annotate-page"),10),viewport:JSON.parse(t.getAttribute("data-pdf-annotate-viewport"))}}M.innerHTML="\nbody {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n",M.setAttribute("data-pdf-annotate-user-select","true");var $,J=new i.a;function V(){J.emit.apply(J,arguments)}function G(){J.on.apply(J,arguments)}function K(){J.removeListener.apply(J,arguments)}function Z(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tt(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};Z(this,t),Object.keys(n).forEach((function(t){"function"==typeof n[t]&&"function"==typeof e[t]&&(e[t]=n[t])}))}var e,n,o;return e=t,n=[{key:"__getAnnotations",value:function(t,e){r("getAnnotations")}},{key:"getAnnotations",get:function(){return this.__getAnnotations},set:function(t){this.__getAnnotations=function(e,n){return t.apply(void 0,arguments).then((function(t){return t.annotations&&t.annotations.forEach((function(t){t.documentId=e})),t}))}}},{key:"getAnnotation",value:function(t,e){r("getAnnotation")}},{key:"__addAnnotation",value:function(t,e,n){r("addAnnotation")}},{key:"addAnnotation",get:function(){return this.__addAnnotation},set:function(t){this.__addAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return V("annotation:add",e,n,t),t}))}}},{key:"__editAnnotation",value:function(t,e,n){r("editAnnotation")}},{key:"editAnnotation",get:function(){return this.__editAnnotation},set:function(t){this.__editAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return V("annotation:edit",e,n,t),t}))}}},{key:"__deleteAnnotation",value:function(t,e){r("deleteAnnotation")}},{key:"deleteAnnotation",get:function(){return this.__deleteAnnotation},set:function(t){this.__deleteAnnotation=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&V("annotation:delete",e,n),t}))}}},{key:"getComments",value:function(t,e){r("getComments")}},{key:"__addComment",value:function(t,e,n){r("addComment")}},{key:"addComment",get:function(){return this.__addComment},set:function(t){this.__addComment=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return V("comment:add",e,n,t),t}))}}},{key:"__deleteComment",value:function(t,e){r("deleteComment")}},{key:"deleteComment",get:function(){return this.__deleteComment},set:function(t){this.__deleteComment=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&V("comment:delete",e,n),t}))}}}],n&&tt(e.prototype,n),o&&tt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),t}(),nt=/[xy]/g;function rt(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}function ot(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(nt,rt)}function it(t){return it="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},it(t)}function at(t,e){for(var n=0;n-1){var i=ft(t);i.splice(o,1),pt(t,i)}n(!0)}))},t.getComments=function(t,e){return new Promise((function(n,r){n(ft(t).filter((function(t){return"Comment"===t.class&&t.annotation===e})))}))},t.addComment=function(t,e,n){return new Promise((function(r,o){var i={class:"Comment",uuid:ot(),annotation:e,content:n},a=ft(t);a.push(i),pt(t,a),r(i)}))},t.deleteComment=function(t,e){return new Promise((function(n,r){var o=ft(t).filter((function(t){return t.uuid===e}))[0]||{};if(!o)return r("Could not find annotation");for(var i=-1,a=ft(t),u=0,c=a.length;u-1&&(a.splice(i,1),pt(t,a)),n(!0)}))},t}return e=i,n&&at(e.prototype,n),r&&at(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(et);function ft(t){return JSON.parse(localStorage.getItem("".concat(t,"/annotations")))||[]}function pt(t,e){localStorage.setItem("".concat(t,"/annotations"),JSON.stringify(e))}function yt(t,e){for(var n=-1,r=ft(t),o=0,i=r.length;ot.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&void 0!==arguments[0]?arguments[0]:"user",n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return gt(this,i),(t=o.call(this,{getAnnotations:function(t,e){return new Promise((function(n,r){var o=Ct(t).filter((function(t){return t.page===e&&"Annotation"===t.class}));n({documentId:t,pageNumber:e,annotations:o})}))}}))._userId=e,t._globalEdit=n,t.getAnnotation=function(e,n){return Promise.resolve(Lt(e,t._userId)[_t(e,t._userId,n)])},t.addAnnotation=function(e,n,r){return new Promise((function(o,i){r.class="Annotation",r.uuid=ot(),r.page=n,r.userId=t._userId;var a=Lt(e,t._userId);a.push(r),It(e,t._userId,a),o(r)}))},t.editAnnotation=function(e,n,r){return new Promise((function(o,i){!t._globalEdit&&r.userId&&r.userId!==t._userId&&i("Non-matching userId");var a=Lt(e,r.userId);a[_t(e,r.userId,n)]=r,It(e,r.userId,a),o(r)}))},t.deleteAnnotation=function(e,n){return new Promise((function(r,o){var i=Ct(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");var a=_t(e,i.userId,n);if(a>-1){var u=Lt(e,i.userId);u.splice(a,1),It(e,i.userId,u)}r(!0)}))},t.getComments=function(e,n){return new Promise((function(r,o){r(Lt(e,t._userId).filter((function(t){return"Comment"===t.class&&t.annotation===n})))}))},t.addComment=function(e,n,r){return new Promise((function(o,i){var a={class:"Comment",uuid:ot(),annotation:n,content:r,userId:t._userId},u=Lt(e,t._userId);u.push(a),It(e,t._userId,u),o(a)}))},t.deleteComment=function(e,n){return new Promise((function(r,o){var i=Ct(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");for(var a=-1,u=Lt(e,i.userId),c=0,l=u.length;c-1&&(u.splice(a,1),It(e,i.userId,u)),r(!0)}))},t}return e=i,(n=[{key:"userId",get:function(){return this._userId}}])&&bt(e.prototype,n),r&&bt(e,r),Object.defineProperty(e,"prototype",{writable:!1}),i}(et);function Ct(t){for(var e=[],n=new RegExp("".concat(t,"/(.*)/annotations")),r=0;r-1&&e.push.apply(e,vt(JSON.parse(localStorage.getItem(localStorage.key(r)))));return e}function Lt(t,e){return JSON.parse(localStorage.getItem("".concat(t,"/").concat(e,"/annotations")))||[]}function It(t,e,n){localStorage.setItem("".concat(t,"/").concat(e,"/annotations"),JSON.stringify(n))}function _t(t,e,n){for(var r=-1,o=Lt(t,e),i=0,a=o.length;it.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&n+jt.offsetHeight0&&r+jt.offsetWidth-1&&(a="cx",u="cy"),"point"!==r){if(["area","highlight","textbox","circle","fillcircle","emptycircle"].indexOf(r)>-1){var c=Y([Mt,Tt],o),l=Y([jt.offsetLeft,jt.offsetTop],o),s={x:l[0]-c[0],y:l[1]-c[1]};"textbox"===r&&(n=[n[0].firstChild]),Ot(n).forEach((function(e,n){var r=parseInt(e.getAttribute(a),10),o=parseInt(e.getAttribute(u),10);0!==s.y&&(o+=s.y,e.setAttribute(u,o),t.rectangles&&n1&&(n=B(t,e))){var r=W(n),o=r.documentId,i=r.pageNumber;In.getStoreAdapter().addAnnotation(o,i,{type:"drawing",width:Wt,color:$t,lines:Kt}).then((function(t){Jt&&n.removeChild(Jt),j(n,t)}))}}(t.clientX,t.clientY)}function ee(t){B(t.clientX,t.clientY)&&Gt&&function(t,e){var n=B(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=Y([t-r.left,e-r.top],n);if(o[0]=o[0].toFixed(2),o[1]=o[1].toFixed(2),Kt.push(o),Kt.length<=1)return;Jt&&n.removeChild(Jt);Jt=j(n,{type:"drawing",color:$t,width:Wt,lines:Kt})}(t.clientX,t.clientY)}function ne(t){27===t.keyCode&&(Kt=null,Jt.parentNode.removeChild(Jt),document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",te))}var re,oe,ie,ae,ue,ce,le=!1;function se(t){var e=q(t.clientX,t.clientY);if(null!==e){var n=e.getAttribute("data-pdf-annotate-type");if("circle"===n||"fillcircle"===n||"emptycircle"===n){var r=T(e),o=W(r).documentId,i=e.getAttribute("data-pdf-annotate-id");In.getStoreAdapter().getAnnotation(o,i).then((function(t){if(t){ie=null,ae=[];var e=U([t.cx,t.cy],r),n=r.getBoundingClientRect();ce=e[0]+n.left,ue=e[1]+n.top,document.addEventListener("mousemove",fe),document.addEventListener("mouseup",de)}}))}}}function de(t){var e;if(ae.length>1&&(e=B(t.clientX,t.clientY))){var n=W(e),r=n.documentId,o=n.pageNumber;In.getStoreAdapter().addAnnotation(r,o,{type:"arrow",width:re,color:oe,lines:ae}).then((function(t){ie&&e.removeChild(ie),j(e,t)}))}document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",de)}function fe(t){!function(t,e){var n=B(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=Y([t-r.left,e-r.top],n);if(ae.length<2)return void ae.push(o);ae[1]=o;ie&&n.removeChild(ie);ie=j(n,{type:"arrow",color:oe,width:re,lines:ae})}(0===ae.length?ce:t.clientX,0===ae.length?ue:t.clientY)}function pe(t){27===t.keyCode&&(ae=null,ie.parentNode.removeChild(ie),document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",de))}function ye(t){return function(t){if(Array.isArray(t))return me(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return me(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return me(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function me(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=1||r>=1)for(var o=Math.round(Math.max(n,r)),i=Math.min(n,r)/o,a=n0){var t=parseInt(Ae.style.left,10),e=parseInt(Ae.style.top,10),n=Ae.value.trim(),r=B(t,e);if(!r)return;var o=r.getBoundingClientRect(),i=W(r),a=i.documentId,u=i.pageNumber,c=Object.assign({type:"point"},Q(r,{x:t-o.left,y:e-o.top}));In.getStoreAdapter().addAnnotation(a,u,c).then((function(t){In.getStoreAdapter().addComment(a,t.uuid,n),j(r,t)}))}_e()}function _e(){Ae.removeEventListener("blur",Ce),Ae.removeEventListener("keyup",Le),document.body.removeChild(Ae),Ae=null}function ke(t){return function(t){if(Array.isArray(t))return Oe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return Oe(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Oe(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oe(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&t[0].width>0&&t[0].height>0)return t}catch(t){}return null}()))Fe(Ne,ke(e).map((function(t){return{top:t.top,left:t.left,width:t.width,height:t.height}})));else if("area"===Ne&&je){var n=je.parentNode.querySelector(kt.annotationSvgQuery()).getBoundingClientRect();Fe(Ne,[{top:parseInt(je.style.top,10)+n.top,left:parseInt(je.style.left,10)+n.left,width:parseInt(je.style.width,10),height:parseInt(je.style.height,10)}]),je.parentNode.removeChild(je),je=null,document.removeEventListener("mousemove",Be),D()}}function ze(t){27===t.keyCode&&(window.getSelection().removeAllRanges(),je&&je.parentNode&&(je.parentNode.removeChild(je),je=null,document.removeEventListener("mousemove",Be)))}function Fe(t,e,n){var r,o=B(e[0].left,e[0].top);if(o){var i=o.getBoundingClientRect();if(n||("highlight"===t?n="FFFF00":"strikeout"===t&&(n="FF0000")),r={type:t,color:n,rectangles:ke(e).map((function(e){var n=0;return"strikeout"===t&&(n=e.height/2),function(t,e,n){var r=[t.x,t.y],o=[t.x+t.width,t.y+t.height];return r=Y(r,e,n),o=Y(o,e,n),{x:Math.min(r[0],o[0]),y:Math.min(r[1],o[1]),width:Math.abs(o[0]-r[0]),height:Math.abs(o[1]-r[1])}}({y:e.top+n-i.top,x:e.left-i.left,width:e.width,height:e.height},o)})).filter((function(t){return t.width>0&&t.height>0&&t.x>-1&&t.y>-1}))},0!==r.rectangles.length){if("area"===t){var a=r.rectangles[0];delete r.rectangles,r.x=a.x,r.y=a.y,r.width=a.width,r.height=a.height}var u=W(o),c=u.documentId,l=u.pageNumber;In.getStoreAdapter().addAnnotation(c,l,r).then((function(t){j(o,t)}))}}}var Xe,Ye=!1,Ue=10,Qe="0000FF";function He(t){var e=B(t.clientX,t.clientY);if(e){var n=e.getBoundingClientRect();!function(t,e,n,r,o){var i=Y([n.x,n.y],t),a={type:e,color:o,cx:i[0],cy:i[1],r:r},u=W(t),c=u.documentId,l=u.pageNumber;In.getStoreAdapter().addAnnotation(c,l,a).then((function(e){j(t,e)}))}(e,Xe,{x:t.clientX-n.left,y:t.clientY-n.top},Ue,Qe)}}var De,We=!1,$e=localStorage.getItem("text/size")||12,Je=localStorage.getItem("text/color")||"#000000";function Ve(t){!De&&B(t.clientX,t.clientY)&&t.srcElement.classList.contains("annotationLayer")&&((De=document.createElement("textarea")).setAttribute("id","pdf-annotate-text-input"),De.setAttribute("placeholder","Enter text... SHIFT + ENTER for new line"),De.style.border="3px solid ".concat(R),De.style.borderRadius="3px",De.style.position="fixed",De.style.top="".concat(t.clientY,"px"),De.style.left="".concat(t.clientX,"px"),De.style.fontSize="".concat($e,"px"),De.style.zIndex="41",De.addEventListener("blur",Ge),De.addEventListener("keyup",Ke),document.body.appendChild(De),De.focus())}function Ge(){Ze()}function Ke(t){27===t.keyCode?tn():13!==t.keyCode||t.shiftKey||Ze()}function Ze(){var t=De.value?De.value.replace(/ +$/,""):"";if(t.length>0){var e=parseInt(De.style.left,10),n=parseInt(De.style.top,10),r=B(e,n);if(!r)return;var o=$e,i=W(r),a=i.documentId,u=i.pageNumber,c=i.viewport,l=1/c.scale,s=r.getBoundingClientRect(),d=Y([e-s.left,n-s.top+o],r,c),f={type:"textbox",size:$e*l,color:Je,content:t,x:d[0],y:d[1],rotation:-c.rotation};In.getStoreAdapter().addAnnotation(a,u,f).then((function(t){j(r,t)}))}tn()}function tn(){De&&(De.removeEventListener("blur",Ge),De.removeEventListener("keyup",Ke),document.body.removeChild(De),De=null)}function en(t,e){var n=document.createElement("div"),r=document.createTextNode(t);return n.appendChild(r),n.setAttribute("id","pdf-annotate-screenreader-".concat(e)),n.style.position="absolute",n.style.left="-10000px",n.style.top="auto",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n}function nn(t){return function(t){if(Array.isArray(t))return rn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return rn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rn(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n"===l[l.length-1])for(;l.length&&(s.unshift(l.pop()),"<"!==s[0]););if(c.innerHTML=l.join(""),u+Q(a,{width:c.getBoundingClientRect().width}).width<=e)break;s.unshift(l.pop())}return i.innerHTML=l.join("")+t.outerHTML+s.join(""),c.parentNode.removeChild(c),!0}function an(t){return function(t){if(Array.isArray(t))return un(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return un(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return un(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function un(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n div"));n=X(o,{y:n}).y+i.top,e=X(o,{x:e}).x+i.left;for(var u=0,c=a.length;u1&&void 0!==arguments[1]?arguments[1]:0;switch(t.type){case"highlight":case"strikeout":var n=t.rectangles,r=n[0],o=n[n.length-1];on(en("Begin ".concat(t.type," annotation ").concat(e),t.uuid),r.x,r.y,t.page,!0),on(en("End ".concat(t.type," annotation ").concat(e),"".concat(t.uuid,"-end")),o.x+o.width,o.y,t.page,!1);break;case"textbox":case"point":var i="textbox"===t.type?" (content: ".concat(t.content,")"):"";cn(en("".concat(t.type," annotation ").concat(e).concat(i),t.uuid),t.x,t.y,t.page);break;case"drawing":case"area":var a=void 0!==t.x?t.x:t.lines[0][0],u=void 0!==t.y?t.y:t.lines[0][1];cn(en("Unlabeled drawing",t.uuid),a,u,t.page);break;case"circle":case"fillcircle":case"emptycircle":var c=void 0!==t.cx?t.cx:t.lines[0][0],l=void 0!==t.cy?t.cy:t.lines[0][1];cn(en("Unlabeled drawing",t.uuid),c,l,t.page)}dn.includes(t.type)&&sn(t.documentId,t.uuid)}(t,e+1)}))}))}function gn(t,e){return t.yt.length)&&(e=t.length);for(var n=0,r=new Array(e);n\n \n \n';function En(t){if(Math.floor(t)===t)return[t,1];var e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];for(var n=t>1?e:t,r=0,o=1,i=1,a=1;;){var u=r+i,c=o+a;if(c>8)break;n<=u/c?(i=u,a=c):(r=u,o=c)}return n-r/o0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";Wt=Math.round(100*parseFloat(t))/100,$t=e},disablePoint:function(){Se&&(Se=!1,document.removeEventListener("mouseup",Ee))},enablePoint:function(){Se||(Se=!0,document.addEventListener("mouseup",Ee))},disableRect:function(){Me&&(Me=!1,document.removeEventListener("mouseup",qe),document.removeEventListener("mousedown",Te),document.removeEventListener("keyup",ze))},enableRect:function(t){Ne=t,Me||(Me=!0,document.addEventListener("mouseup",qe),document.addEventListener("mousedown",Te),document.addEventListener("keyup",ze))},disableCircle:function(){Ye&&(Ye=!1,document.removeEventListener("mouseup",He))},enableCircle:function(t){Xe=t,Ye||(Ye=!0,document.addEventListener("mouseup",He))},setCircle:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";Ue=parseInt(t,10),Qe=e},addCircle:function(t,e){var n=Xe;Xe=t,He(e),Xe=n},disableArrow:function(){le&&(le=!1,document.removeEventListener("mousedown",se),document.removeEventListener("keyup",pe),D())},enableArrow:function(){le||(le=!0,document.addEventListener("mousedown",se),document.addEventListener("keyup",pe),H())},setArrow:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";re=parseInt(t,10),oe=e},disableEraser:function(){document.removeEventListener("pointermove",we),document.removeEventListener("pointerdown",ge),document.removeEventListener("pointerup",be)},enableEraser:function(){document.addEventListener("pointermove",we),document.addEventListener("pointerdown",ge),document.addEventListener("pointerup",be)},disableText:function(){We&&(We=!1,document.removeEventListener("mouseup",Ve))},enableText:function(){We||(We=!0,document.addEventListener("mouseup",Ve))},setText:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";$e=parseInt(t,10),Je=e},createPage:function(t){var e=document.createElement("div");e.innerHTML=Sn;var n=e.children[0],r=n.querySelector("canvas");return n.setAttribute("id","pageContainer".concat(t)),n.setAttribute("data-page-number",t),r.mozOpaque=!0,r.setAttribute("id","page".concat(t)),n},renderPage:function(t,e){var n=e.documentId,r=e.pdfDocument,o=e.scale,i=e.rotate,a=new pdfjsViewer.EventBus;return Promise.all([r.getPage(t),In.getAnnotations(n,t)]).then((function(e){var n=xn(e,2),r=n[0],u=n[1],c=document.getElementById("pageContainer".concat(t)),l=c.querySelector(kt.annotationClassQuery()),s=c.querySelector(".canvasWrapper canvas").getContext("2d",{alpha:!1}),d=(i+r.rotate)%360,f=r.getViewport({scale:o,rotation:d}),p=function(t,e,n){var r=document.getElementById("pageContainer".concat(t)),o=r.querySelector(".canvasWrapper canvas"),i=r.querySelector(kt.annotationClassQuery()),a=r.querySelector(".canvasWrapper"),u=r.querySelector(kt.textClassQuery()),c=(f=n,p=window.devicePixelRatio||1,y=f.webkitBackingStorePixelRatio||f.mozBackingStorePixelRatio||f.msBackingStorePixelRatio||f.oBackingStorePixelRatio||f.backingStorePixelRatio||1,m=p/y,{sx:m,sy:m,scaled:1!==m}),l=c.scaled?[c.sx,0,0,c.sy,0,0]:null,s=En(c.sx),d=En(c.sy);var f,p,y,m;return r.style.visibility="",o.width=Cn(e.width*c.sx,s[0]),o.height=Cn(e.height*c.sy,d[0]),o.style.width=Cn(e.width,s[1])+"px",o.style.height=Cn(e.height,s[1])+"px",i.setAttribute("width",e.width),i.setAttribute("height",e.height),i.style.width="".concat(e.width,"px"),i.style.height="".concat(e.height,"px"),r.style.width="".concat(e.width,"px"),r.style.height="".concat(e.height,"px"),a.style.width="".concat(e.width,"px"),a.style.height="".concat(e.height,"px"),u.style.width="".concat(e.width,"px"),u.style.height="".concat(e.height,"px"),l}(t,f,s);return Promise.all([r.render({canvasContext:s,viewport:f,transform:p}).promise,In.render(l,f,u)]).then((function(){return r.getTextContent({normalizeWhitespace:!0}).then((function(e){return new Promise((function(n,r){var o=c.querySelector(kt.textClassQuery()),i=(new pdfjsViewer.DefaultTextLayerFactory).createTextLayerBuilder(o,t-1,f,!1,a);i.setTextContent(e),i.render(),setTimeout((function(){try{hn(u.annotations),n()}catch(t){r(t)}}))}))}))})).then((function(){return c.setAttribute("data-loaded","true"),[r,u]}))}))}},In={findAnnotationAtPoint:q,findSVGContainer:T,convertToScreenPoint:U,StoreAdapter:et,LocalStoreAdapter:dt,LocalUserStoreAdapter:Et,__storeAdapter:new et,getStoreAdapter:function(){return this.__storeAdapter},setStoreAdapter:function(t){this.__storeAdapter=t},UI:Ln,render:function(t,e,n){return new Promise((function(r,o){return t.setAttribute("data-pdf-annotate-container",!0),t.setAttribute("data-pdf-annotate-viewport",JSON.stringify(e)),t.removeAttribute("data-pdf-annotate-document"),t.removeAttribute("data-pdf-annotate-page"),n?(t.setAttribute("data-pdf-annotate-document",n.documentId),t.setAttribute("data-pdf-annotate-page",n.pageNumber),Array.isArray(n.annotations)&&0!==n.annotations.length?(n.annotations.forEach((function(n){var r=t.querySelector('[data-pdf-annotate-id="'+n.uuid+'"]');r?P(t,r,e):j(t,n,e)})),void r(t)):r(t)):(t.innerHTML="",r(t))}))},getAnnotations:function(t,e){var n;return(n=this.getStoreAdapter()).getAnnotations.apply(n,arguments)},config:kt,uuid:ot};e.default=In}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PDFAnnotate=e():t.PDFAnnotate=e()}(self,(()=>(()=>{"use strict";var t={7:t=>{var e,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function i(){i.init.call(this)}t.exports=i,t.exports.once=function(t,e){return new Promise((function(n,r){function o(n){t.removeListener(e,i),r(n)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}v(t,e,i,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&v(t,"error",e,n)}(t,o,{once:!0})}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function u(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?i.defaultMaxListeners:t._maxListeners}function l(t,e,n,r){var o,i,a,l;if(u(n),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),i=t._events),a=i[e]),void 0===a)a=i[e]=n,++t._eventsCount;else if("function"==typeof a?a=i[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=c(t))>0&&a.length>o&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,l=s,console&&console.warn&&console.warn(l)}return t}function s(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=s.bind(r);return o.listener=n,r.wrapFn=o,o}function f(t,e,n){var r=t._events;if(void 0===r)return[];var o=r[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(a=e[0]),a instanceof Error)throw a;var u=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw u.context=a,u}var c=i[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var l=c.length,s=y(c,l);for(n=0;n=0;i--)if(n[i]===e||n[i].listener===e){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},i.prototype.listeners=function(t){return f(this,t,!0)},i.prototype.rawListeners=function(t){return f(this,t,!1)},i.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};function o(t){throw new Error(t+" is not implemented")}n.r(r),n.d(r,{default:()=>Mn});var i=n(7),a=n.n(i),u=/[A-Z]/g,c=["viewBox"],l=function(t){return-1===c.indexOf(t)&&(t=t.replace(u,(function(t){return"-"+t.toLowerCase()}))),t};function s(t,e){Object.keys(e).forEach((function(n){t.setAttribute(l(n),e[n])}))}var d=/^([a-f0-9]{6}|[a-f0-9]{3})$/i;function f(t){return d.test(t)&&(t="#".concat(t)),t}var p=25,y="M499.968 214.336q-113.832 0 -212.877 38.781t-157.356 104.625 -58.311 142.29q0 62.496 39.897 119.133t112.437 97.929l48.546 27.9 -15.066 53.568q-13.392 50.778 -39.06 95.976 84.816 -35.154 153.45 -95.418l23.994 -21.204 31.806 3.348q38.502 4.464 72.54 4.464 113.832 0 212.877 -38.781t157.356 -104.625 58.311 -142.29 -58.311 -142.29 -157.356 -104.625 -212.877 -38.781z";function v(t){var e=document.createElementNS("http://www.w3.org/2000/svg","rect");return s(e,{x:t.x,y:t.y,width:t.width,height:t.height}),e}function m(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return h(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0){e.push("M".concat(t.lines[0][0]," ").concat(t.lines[0][1]));for(var r=1,o=t.lines.length;r=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right}function U(t){var e=t.getBoundingClientRect(),n=e.width,r=e.height,o=0,i=0;if(["line","path"].indexOf(t.tagName.toLowerCase())>-1&&t.getBBox){var a=t.getBBox();o=(e.width-a.width)/2,i=(e.height-a.height)/2,n=a.width,r=a.height}var u=function(t){var e=t;for(;(e=e.parentNode)&&e!==document&&"SVG"!==e.nodeName.toUpperCase(););var n=e.getBoundingClientRect();return{offsetLeft:n.left,offsetTop:n.top}}(t),c=u.offsetLeft,l=u.offsetTop;return{top:e.top-l+i,left:e.left-c+o,bottom:e.bottom-l-i,right:e.right-c-o,width:n,height:r}}function Q(t,e){var n={},r=V(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]*r.scale})),n}function H(t,e,n){var r=[1,0,0,1,0,0];r=x(r=A(r,(n=n||V(e).viewport).scale,n.scale),n.rotation);var o,i,a,u=P(n);return r=w(r,u.x,u.y),o=t,a=(i=r)[0]*i[3]-i[1]*i[2],[(o[0]*i[3]-o[1]*i[2]+i[2]*i[5]-i[4]*i[3])/a,(-o[0]*i[1]+o[1]*i[0]+i[4]*i[1]-i[5]*i[0])/a]}function D(t,e,n){var r=[1,0,0,1,0,0];r=x(r=A(r,(n=n||V(e).viewport).scale,n.scale),n.rotation);var o,i,a=P(n);return r=w(r,a.x,a.y),i=r,[(o=t)[0]*i[0]+o[1]*i[2]+i[4],o[0]*i[1]+o[1]*i[3]+i[5]]}function W(t,e){var n={},r=V(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]/r.scale})),n}function $(){q.parentNode||document.head.appendChild(q)}function J(){q.parentNode&&q.parentNode.removeChild(q)}function V(t){return{documentId:t.getAttribute("data-pdf-annotate-document"),pageNumber:parseInt(t.getAttribute("data-pdf-annotate-page"),10),viewport:JSON.parse(t.getAttribute("data-pdf-annotate-viewport"))}}q.innerHTML="\nbody {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n",q.setAttribute("data-pdf-annotate-user-select","true");var G,K=new(a());function Z(){K.emit.apply(K,arguments)}function tt(){K.on.apply(K,arguments)}function et(){K.removeListener.apply(K,arguments)}function nt(t){return nt="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},nt(t)}function rt(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.keys(n).forEach((function(t){"function"==typeof n[t]&&"function"==typeof e[t]&&(e[t]=n[t])}))},e=[{key:"__getAnnotations",value:function(t,e){o("getAnnotations")}},{key:"getAnnotations",get:function(){return this.__getAnnotations},set:function(t){this.__getAnnotations=function(e,n){return t.apply(void 0,arguments).then((function(t){return t.annotations&&t.annotations.forEach((function(t){t.documentId=e})),t}))}}},{key:"getAnnotation",value:function(t,e){o("getAnnotation")}},{key:"__addAnnotation",value:function(t,e,n){o("addAnnotation")}},{key:"addAnnotation",get:function(){return this.__addAnnotation},set:function(t){this.__addAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return Z("annotation:add",e,n,t),t}))}}},{key:"__editAnnotation",value:function(t,e,n){o("editAnnotation")}},{key:"editAnnotation",get:function(){return this.__editAnnotation},set:function(t){this.__editAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return Z("annotation:edit",e,n,t),t}))}}},{key:"__deleteAnnotation",value:function(t,e){o("deleteAnnotation")}},{key:"deleteAnnotation",get:function(){return this.__deleteAnnotation},set:function(t){this.__deleteAnnotation=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&Z("annotation:delete",e,n),t}))}}},{key:"getComments",value:function(t,e){o("getComments")}},{key:"__addComment",value:function(t,e,n){o("addComment")}},{key:"addComment",get:function(){return this.__addComment},set:function(t){this.__addComment=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return Z("comment:add",e,n,t),t}))}}},{key:"__deleteComment",value:function(t,e){o("deleteComment")}},{key:"deleteComment",get:function(){return this.__deleteComment},set:function(t){this.__deleteComment=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&Z("comment:delete",e,n),t}))}}}],e&&rt(t.prototype,e),n&&rt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}(),at=/[xy]/g;function ut(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}function ct(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(at,ut)}function lt(t){return lt="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},lt(t)}function st(t,e){for(var n=0;n-1){var i=ht(t);i.splice(o,1),gt(t,i)}n(!0)}))},t.getComments=function(t,e){return new Promise((function(n,r){n(ht(t).filter((function(t){return"Comment"===t.class&&t.annotation===e})))}))},t.addComment=function(t,e,n){return new Promise((function(r,o){var i={class:"Comment",uuid:ct(),annotation:e,content:n},a=ht(t);a.push(i),gt(t,a),r(i)}))},t.deleteComment=function(t,e){return new Promise((function(n,r){var o=ht(t).filter((function(t){return t.uuid===e}))[0]||{};if(!o)return r("Could not find annotation");for(var i=-1,a=ht(t),u=0,c=a.length;u-1&&(a.splice(i,1),gt(t,a)),n(!0)}))},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&vt(t,e)}(e,t),n=e,r&&st(n.prototype,r),o&&st(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(it);function ht(t){return JSON.parse(localStorage.getItem("".concat(t,"/annotations")))||[]}function gt(t,e){localStorage.setItem("".concat(t,"/annotations"),JSON.stringify(e))}function bt(t,e){for(var n=-1,r=ht(t),o=0,i=r.length;ot.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:"user",r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(t=Ct(this,e,[{getAnnotations:function(t,e){return new Promise((function(n,r){var o=Nt(t).filter((function(t){return t.page===e&&"Annotation"===t.class}));n({documentId:t,pageNumber:e,annotations:o})}))}}]))._userId=n,t._globalEdit=r,t.getAnnotation=function(e,n){return Promise.resolve(Ot(e,t._userId)[Pt(e,t._userId,n)])},t.addAnnotation=function(e,n,r){return new Promise((function(o,i){r.class="Annotation",r.uuid=ct(),r.page=n,r.userId=t._userId;var a=Ot(e,t._userId);a.push(r),jt(e,t._userId,a),o(r)}))},t.editAnnotation=function(e,n,r){return new Promise((function(o,i){!t._globalEdit&&r.userId&&r.userId!==t._userId&&i("Non-matching userId");var a=Ot(e,r.userId);a[Pt(e,r.userId,n)]=r,jt(e,r.userId,a),o(r)}))},t.deleteAnnotation=function(e,n){return new Promise((function(r,o){var i=Nt(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");var a=Pt(e,i.userId,n);if(a>-1){var u=Ot(e,i.userId);u.splice(a,1),jt(e,i.userId,u)}r(!0)}))},t.getComments=function(e,n){return new Promise((function(r,o){r(Ot(e,t._userId).filter((function(t){return"Comment"===t.class&&t.annotation===n})))}))},t.addComment=function(e,n,r){return new Promise((function(o,i){var a={class:"Comment",uuid:ct(),annotation:n,content:r,userId:t._userId},u=Ot(e,t._userId);u.push(a),jt(e,t._userId,u),o(a)}))},t.deleteComment=function(e,n){return new Promise((function(r,o){var i=Nt(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");for(var a=-1,u=Ot(e,i.userId),c=0,l=u.length;c-1&&(u.splice(a,1),jt(e,i.userId,u)),r(!0)}))},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&kt(t,e)}(e,t),n=e,(r=[{key:"userId",get:function(){return this._userId}}])&&St(n.prototype,r),o&&St(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(it);function Nt(t){for(var e=[],n=new RegExp("".concat(t,"/(.*)/annotations")),r=0;r-1&&e.push.apply(e,xt(JSON.parse(localStorage.getItem(localStorage.key(r)))));return e}function Ot(t,e){return JSON.parse(localStorage.getItem("".concat(t,"/").concat(e,"/annotations")))||[]}function jt(t,e,n){localStorage.setItem("".concat(t,"/").concat(e,"/annotations"),JSON.stringify(n))}function Pt(t,e,n){for(var r=-1,o=Ot(t,e),i=0,a=o.length;it.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&n+Bt.offsetHeight0&&r+Bt.offsetWidth-1&&(a="cx",u="cy"),"point"!==r){if(["area","highlight","textbox","circle","fillcircle","emptycircle"].indexOf(r)>-1){var c=H([Ft,Xt],o),l=H([Bt.offsetLeft,Bt.offsetTop],o),s={x:l[0]-c[0],y:l[1]-c[1]};"textbox"===r&&(n=[n[0].firstChild]),Rt(n).forEach((function(e,n){var r=parseInt(e.getAttribute(a),10),o=parseInt(e.getAttribute(u),10);0!==s.y&&(o+=s.y,e.setAttribute(u,o),t.rectangles&&n1&&(n=F(t,e))){var r=V(n),o=r.documentId,i=r.pageNumber;Pn.getStoreAdapter().addAnnotation(o,i,{type:"drawing",width:Zt,color:te,lines:oe}).then((function(t){ee&&n.removeChild(ee),R(n,t)}))}}(t.clientX,t.clientY)}function ue(t){F(t.clientX,t.clientY)&&re&&function(t,e){var n=F(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=H([t-r.left,e-r.top],n);if(o[0]=o[0].toFixed(2),o[1]=o[1].toFixed(2),oe.push(o),oe.length<=1)return;ee&&n.removeChild(ee);ee=R(n,{type:"drawing",color:te,width:Zt,lines:oe})}(t.clientX,t.clientY)}function ce(t){27===t.keyCode&&(oe=null,ee.parentNode.removeChild(ee),document.removeEventListener("pointermove",ue),document.removeEventListener("pointerup",ae))}var le,se,de,fe,pe,ye,ve=!1;function me(t){var e=X(t.clientX,t.clientY);if(null!==e){var n=e.getAttribute("data-pdf-annotate-type");if("circle"===n||"fillcircle"===n||"emptycircle"===n){var r=z(e),o=V(r).documentId,i=e.getAttribute("data-pdf-annotate-id");Pn.getStoreAdapter().getAnnotation(o,i).then((function(t){if(t){de=null,fe=[];var e=D([t.cx,t.cy],r),n=r.getBoundingClientRect();ye=e[0]+n.left,pe=e[1]+n.top,document.addEventListener("mousemove",ge),document.addEventListener("mouseup",he)}}))}}}function he(t){var e;if(fe.length>1&&(e=F(t.clientX,t.clientY))){var n=V(e),r=n.documentId,o=n.pageNumber;Pn.getStoreAdapter().addAnnotation(r,o,{type:"arrow",width:le,color:se,lines:fe}).then((function(t){de&&e.removeChild(de),R(e,t)}))}document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",he)}function ge(t){!function(t,e){var n=F(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=H([t-r.left,e-r.top],n);if(fe.length<2)return void fe.push(o);fe[1]=o;de&&n.removeChild(de);de=R(n,{type:"arrow",color:se,width:le,lines:fe})}(0===fe.length?ye:t.clientX,0===fe.length?pe:t.clientY)}function be(t){27===t.keyCode&&(fe=null,de.parentNode.removeChild(de),document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",he))}function we(t){return function(t){if(Array.isArray(t))return xe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return xe(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xe(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function xe(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=1||r>=1)for(var o=Math.round(Math.max(n,r)),i=Math.min(n,r)/o,a=n0){var t=parseInt(ke.style.left,10),e=parseInt(ke.style.top,10),n=ke.value.trim(),r=F(t,e);if(!r)return;var o=r.getBoundingClientRect(),i=V(r),a=i.documentId,u=i.pageNumber,c=Object.assign({type:"point"},W(r,{x:t-o.left,y:e-o.top}));Pn.getStoreAdapter().addAnnotation(a,u,c).then((function(t){Pn.getStoreAdapter().addComment(a,t.uuid,n),R(r,t)}))}Me()}function Me(){ke.removeEventListener("blur",Oe),ke.removeEventListener("keyup",je),document.body.removeChild(ke),ke=null}function Re(t){return function(t){if(Array.isArray(t))return Te(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Te(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Te(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Te(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&t[0].width>0&&t[0].height>0)return t}catch(t){}return null}()))De(Be,Re(e).map((function(t){return{top:t.top,left:t.left,width:t.width,height:t.height}})));else if("area"===Be&&qe){var n=qe.parentNode.querySelector(Mt.annotationSvgQuery()).getBoundingClientRect();De(Be,[{top:parseInt(qe.style.top,10)+n.top,left:parseInt(qe.style.left,10)+n.left,width:parseInt(qe.style.width,10),height:parseInt(qe.style.height,10)}]),qe.parentNode.removeChild(qe),qe=null,document.removeEventListener("mousemove",Ue),J()}}function He(t){27===t.keyCode&&(window.getSelection().removeAllRanges(),qe&&qe.parentNode&&(qe.parentNode.removeChild(qe),qe=null,document.removeEventListener("mousemove",Ue)))}function De(t,e,n){var r,o=F(e[0].left,e[0].top);if(o){var i=o.getBoundingClientRect();if(n||("highlight"===t?n="FFFF00":"strikeout"===t&&(n="FF0000")),r={type:t,color:n,rectangles:Re(e).map((function(e){var n=0;return"strikeout"===t&&(n=e.height/2),function(t,e,n){var r=[t.x,t.y],o=[t.x+t.width,t.y+t.height];return r=H(r,e,n),o=H(o,e,n),{x:Math.min(r[0],o[0]),y:Math.min(r[1],o[1]),width:Math.abs(o[0]-r[0]),height:Math.abs(o[1]-r[1])}}({y:e.top+n-i.top,x:e.left-i.left,width:e.width,height:e.height},o)})).filter((function(t){return t.width>0&&t.height>0&&t.x>-1&&t.y>-1}))},0!==r.rectangles.length){if("area"===t){var a=r.rectangles[0];delete r.rectangles,r.x=a.x,r.y=a.y,r.width=a.width,r.height=a.height}var u=V(o),c=u.documentId,l=u.pageNumber;Pn.getStoreAdapter().addAnnotation(c,l,r).then((function(t){R(o,t)}))}}}var We,$e=!1,Je=10,Ve="0000FF";function Ge(t){var e=F(t.clientX,t.clientY);if(e){var n=e.getBoundingClientRect();!function(t,e,n,r,o){var i=H([n.x,n.y],t),a={type:e,color:o,cx:i[0],cy:i[1],r},u=V(t),c=u.documentId,l=u.pageNumber;Pn.getStoreAdapter().addAnnotation(c,l,a).then((function(e){R(t,e)}))}(e,We,{x:t.clientX-n.left,y:t.clientY-n.top},Je,Ve)}}var Ke,Ze=!1,tn=localStorage.getItem("text/size")||12,en=localStorage.getItem("text/color")||"#000000";function nn(t){!Ke&&F(t.clientX,t.clientY)&&t.srcElement.classList.contains("annotationLayer")&&((Ke=document.createElement("textarea")).setAttribute("id","pdf-annotate-text-input"),Ke.setAttribute("placeholder","Enter text... SHIFT + ENTER for new line"),Ke.style.border="3px solid ".concat(B),Ke.style.borderRadius="3px",Ke.style.position="fixed",Ke.style.top="".concat(t.clientY,"px"),Ke.style.left="".concat(t.clientX,"px"),Ke.style.fontSize="".concat(tn,"px"),Ke.style.zIndex="41",Ke.addEventListener("blur",rn),Ke.addEventListener("keyup",on),document.body.appendChild(Ke),Ke.focus())}function rn(){an()}function on(t){27===t.keyCode?un():13!==t.keyCode||t.shiftKey||an()}function an(){var t=Ke.value?Ke.value.replace(/ +$/,""):"";if(t.length>0){var e=parseInt(Ke.style.left,10),n=parseInt(Ke.style.top,10),r=F(e,n);if(!r)return;var o=tn,i=V(r),a=i.documentId,u=i.pageNumber,c=i.viewport,l=1/c.scale,s=r.getBoundingClientRect(),d=H([e-s.left,n-s.top+o],r,c),f={type:"textbox",size:tn*l,color:en,content:t,x:d[0],y:d[1],rotation:-c.rotation};Pn.getStoreAdapter().addAnnotation(a,u,f).then((function(t){R(r,t)}))}un()}function un(){Ke&&(Ke.removeEventListener("blur",rn),Ke.removeEventListener("keyup",on),document.body.removeChild(Ke),Ke=null)}function cn(t,e){var n=document.createElement("div"),r=document.createTextNode(t);return n.appendChild(r),n.setAttribute("id","pdf-annotate-screenreader-".concat(e)),n.style.position="absolute",n.style.left="-10000px",n.style.top="auto",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n}function ln(t){return function(t){if(Array.isArray(t))return sn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return sn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sn(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n"===l[l.length-1])for(;l.length&&(s.unshift(l.pop()),"<"!==s[0]););if(c.innerHTML=l.join(""),u+W(a,{width:c.getBoundingClientRect().width}).width<=e)break;s.unshift(l.pop())}return i.innerHTML=l.join("")+t.outerHTML+s.join(""),c.parentNode.removeChild(c),!0}function fn(t){return function(t){if(Array.isArray(t))return pn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return pn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pn(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n div"));n=Q(o,{y:n}).y+i.top,e=Q(o,{x:e}).x+i.left;for(var u=0,c=a.length;u1&&void 0!==arguments[1]?arguments[1]:0;switch(t.type){case"highlight":case"strikeout":var n=t.rectangles,r=n[0],o=n[n.length-1];dn(cn("Begin ".concat(t.type," annotation ").concat(e),t.uuid),r.x,r.y,t.page,!0),dn(cn("End ".concat(t.type," annotation ").concat(e),"".concat(t.uuid,"-end")),o.x+o.width,o.y,t.page,!1);break;case"textbox":case"point":var i="textbox"===t.type?" (content: ".concat(t.content,")"):"";yn(cn("".concat(t.type," annotation ").concat(e).concat(i),t.uuid),t.x,t.y,t.page);break;case"drawing":case"area":var a=void 0!==t.x?t.x:t.lines[0][0],u=void 0!==t.y?t.y:t.lines[0][1];yn(cn("Unlabeled drawing",t.uuid),a,u,t.page);break;case"circle":case"fillcircle":case"emptycircle":var c=void 0!==t.cx?t.cx:t.lines[0][0],l=void 0!==t.cy?t.cy:t.lines[0][1];yn(cn("Unlabeled drawing",t.uuid),c,l,t.page)}hn.includes(t.type)&&mn(t.documentId,t.uuid)}(t,e+1)}))}))}function En(t,e){return t.yt.length)&&(e=t.length);for(var n=0,r=Array(e);n\n \n \n';function Nn(t){if(Math.floor(t)===t)return[t,1];var e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];for(var n=t>1?e:t,r=0,o=1,i=1,a=1;;){var u=r+i,c=o+a;if(c>8)break;n<=u/c?(i=u,a=c):(r=u,o=c)}return n-r/o0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";Zt=Math.round(100*parseFloat(t))/100,te=e},disablePoint:function(){_e&&(_e=!1,document.removeEventListener("mouseup",Ne))},enablePoint:function(){_e||(_e=!0,document.addEventListener("mouseup",Ne))},disableRect:function(){Xe&&(Xe=!1,document.removeEventListener("mouseup",Qe),document.removeEventListener("mousedown",Ye),document.removeEventListener("keyup",He))},enableRect:function(t){Be=t,Xe||(Xe=!0,document.addEventListener("mouseup",Qe),document.addEventListener("mousedown",Ye),document.addEventListener("keyup",He))},disableCircle:function(){$e&&($e=!1,document.removeEventListener("mouseup",Ge))},enableCircle:function(t){We=t,$e||($e=!0,document.addEventListener("mouseup",Ge))},setCircle:function(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";Je=parseInt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,10),Ve=t},addCircle:function(t,e){var n=We;We=t,Ge(e),We=n},disableArrow:function(){ve&&(ve=!1,document.removeEventListener("mousedown",me),document.removeEventListener("keyup",be),J())},enableArrow:function(){ve||(ve=!0,document.addEventListener("mousedown",me),document.addEventListener("keyup",be),$())},setArrow:function(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";le=parseInt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,10),se=t},disableEraser:function(){document.removeEventListener("pointermove",Le),document.removeEventListener("pointerdown",Ee),document.removeEventListener("pointerup",Ce)},enableEraser:function(){document.addEventListener("pointermove",Le),document.addEventListener("pointerdown",Ee),document.addEventListener("pointerup",Ce)},disableText:function(){Ze&&(Ze=!1,document.removeEventListener("mouseup",nn))},enableText:function(){Ze||(Ze=!0,document.addEventListener("mouseup",nn))},setText:function(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";tn=parseInt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,10),en=t},createPage:function(t){var e=document.createElement("div");e.innerHTML=_n;var n=e.children[0],r=n.querySelector("canvas");return n.setAttribute("id","pageContainer".concat(t)),n.setAttribute("data-page-number",t),r.mozOpaque=!0,r.setAttribute("id","page".concat(t)),n},renderPage:function(t,e){var n=e.documentId,r=e.pdfDocument,o=e.scale,i=e.rotate,a=new pdfjsViewer.EventBus;return Promise.all([r.getPage(t),Pn.getAnnotations(n,t)]).then((function(e){var n=In(e,2),r=n[0],u=n[1],c=document.getElementById("pageContainer".concat(t)),l=c.querySelector(Mt.annotationClassQuery()),s=c.querySelector(".canvasWrapper canvas").getContext("2d",{alpha:!1}),d=(i+r.rotate)%360,f=r.getViewport({scale:o,rotation:d}),p=function(t,e,n){var r=document.getElementById("pageContainer".concat(t)),o=r.querySelector(".canvasWrapper canvas"),i=r.querySelector(Mt.annotationClassQuery()),a=r.querySelector(".canvasWrapper"),u=r.querySelector(Mt.textClassQuery()),c=(f=n,p=window.devicePixelRatio||1,y=f.webkitBackingStorePixelRatio||f.mozBackingStorePixelRatio||f.msBackingStorePixelRatio||f.oBackingStorePixelRatio||f.backingStorePixelRatio||1,v=p/y,{sx:v,sy:v,scaled:1!==v}),l=c.scaled?[c.sx,0,0,c.sy,0,0]:null,s=Nn(c.sx),d=Nn(c.sy);var f,p,y,v;return r.style.visibility="",o.width=On(e.width*c.sx,s[0]),o.height=On(e.height*c.sy,d[0]),o.style.width=On(e.width,s[1])+"px",o.style.height=On(e.height,s[1])+"px",i.setAttribute("width",e.width),i.setAttribute("height",e.height),i.style.width="".concat(e.width,"px"),i.style.height="".concat(e.height,"px"),r.style.width="".concat(e.width,"px"),r.style.height="".concat(e.height,"px"),a.style.width="".concat(e.width,"px"),a.style.height="".concat(e.height,"px"),u.style.width="".concat(e.width,"px"),u.style.height="".concat(e.height,"px"),l}(t,f,s);return Promise.all([r.render({canvasContext:s,viewport:f,transform:p}).promise,Pn.render(l,f,u)]).then((function(){return r.getTextContent({normalizeWhitespace:!0}).then((function(e){return new Promise((function(n,r){var o=c.querySelector(Mt.textClassQuery()),i=(new pdfjsViewer.DefaultTextLayerFactory).createTextLayerBuilder(o,t-1,f,!1,a);i.setTextContent(e),i.render(),setTimeout((function(){try{Sn(u.annotations),n()}catch(t){r(t)}}))}))}))})).then((function(){return c.setAttribute("data-loaded","true"),[r,u]}))}))}},Pn={findAnnotationAtPoint:X,findSVGContainer:z,convertToScreenPoint:D,StoreAdapter:it,LocalStoreAdapter:mt,LocalUserStoreAdapter:_t,__storeAdapter:new it,getStoreAdapter:function(){return this.__storeAdapter},setStoreAdapter:function(t){this.__storeAdapter=t},UI:jn,render:function(t,e,n){return new Promise((function(r,o){return t.setAttribute("data-pdf-annotate-container",!0),t.setAttribute("data-pdf-annotate-viewport",JSON.stringify(e)),t.removeAttribute("data-pdf-annotate-document"),t.removeAttribute("data-pdf-annotate-page"),n?(t.setAttribute("data-pdf-annotate-document",n.documentId),t.setAttribute("data-pdf-annotate-page",n.pageNumber),Array.isArray(n.annotations)&&0!==n.annotations.length?(n.annotations.forEach((function(n){var r=t.querySelector('[data-pdf-annotate-id="'+n.uuid+'"]');r?T(t,r,e):R(t,n,e)})),void r(t)):r(t)):(t.innerHTML="",r(t))}))},getAnnotations:function(t,e){var n;return(n=this.getStoreAdapter()).getAnnotations.apply(n,arguments)},config:Mt,uuid:ct},Mn=Pn;return r})())); //# sourceMappingURL=pdf-annotate.min.js.map \ No newline at end of file diff --git a/dist/pdf-annotate.min.js.map b/dist/pdf-annotate.min.js.map index 429e9f8c..35b7daa0 100644 --- a/dist/pdf-annotate.min.js.map +++ b/dist/pdf-annotate.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://PDFAnnotate/webpack/universalModuleDefinition","webpack://PDFAnnotate/webpack/bootstrap","webpack://PDFAnnotate/./node_modules/events/events.js","webpack://PDFAnnotate/./src/utils/abstractFunction.js","webpack://PDFAnnotate/./src/utils/setAttributes.js","webpack://PDFAnnotate/./src/utils/normalizeColor.js","webpack://PDFAnnotate/./src/render/renderPoint.js","webpack://PDFAnnotate/./src/render/renderRect.js","webpack://PDFAnnotate/./src/render/renderText.js","webpack://PDFAnnotate/./src/render/renderCircle.js","webpack://PDFAnnotate/./src/utils/mathUtils.js","webpack://PDFAnnotate/./src/render/renderArrow.js","webpack://PDFAnnotate/./src/render/appendChild.js","webpack://PDFAnnotate/./src/render/renderLine.js","webpack://PDFAnnotate/./src/render/renderPath.js","webpack://PDFAnnotate/./src/UI/utils.js","webpack://PDFAnnotate/./src/UI/event.js","webpack://PDFAnnotate/./src/adapter/StoreAdapter.js","webpack://PDFAnnotate/./src/utils/uuid.js","webpack://PDFAnnotate/./src/adapter/LocalStoreAdapter.js","webpack://PDFAnnotate/./src/adapter/LocalUserStoreAdapter.js","webpack://PDFAnnotate/./src/config.js","webpack://PDFAnnotate/./src/UI/edit.js","webpack://PDFAnnotate/./src/UI/pen.js","webpack://PDFAnnotate/./src/UI/arrow.js","webpack://PDFAnnotate/./src/UI/eraser.js","webpack://PDFAnnotate/./src/UI/point.js","webpack://PDFAnnotate/./src/UI/rect.js","webpack://PDFAnnotate/./src/UI/circle.js","webpack://PDFAnnotate/./src/UI/text.js","webpack://PDFAnnotate/./src/a11y/createScreenReaderOnly.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinElement.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinChildren.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderComment.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderComments.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderHint.js","webpack://PDFAnnotate/./src/a11y/initEventHandlers.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderHints.js","webpack://PDFAnnotate/./src/UI/page.js","webpack://PDFAnnotate/./src/UI/index.js","webpack://PDFAnnotate/./src/PDFJSAnnotate.js","webpack://PDFAnnotate/./src/render/index.js","webpack://PDFAnnotate/./index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","EventEmitter","init","this","once","emitter","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","events","existing","warning","newListener","emit","unshift","push","length","warned","w","Error","String","count","console","warn","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","_listeners","unwrap","evlistener","arr","ret","Array","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","error","er","message","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","keys","rawListeners","eventNames","abstractFunction","UPPER_REGEX","BLACKLIST","setAttributes","node","attributes","forEach","setAttribute","indexOf","replace","match","toLowerCase","keyCase","REGEX_HASHLESS_HEX","normalizeColor","color","test","SIZE","createRect","rect","document","createElementNS","x","y","width","height","renderText","a","text","fill","fontSize","size","transform","rotation","style","textElement","textContent","_step","lines","split","getAttribute","_iterator","_createForOfIteratorHelper","done","line","tspan","toString","innerHTML","appendChild","e","f","insertLineBreaks","content","g","renderCircle","circle","cx","cy","createCircle","stroke","translate","rotate","angle","Math","PI","cosValue","cos","sinValue","sin","scale","makePoint","z","makeVector","xcoord","ycoord","zcoord","makeVectorFromPoints","pt1","pt2","addVector","pt","v","multiplyVector","scalar","magnitude","sqrt","pow","negateVector","unitVector","mag","renderArrow","u","arrow","p1","p2","pt0","unitX","unitZ","unitY","thickness","A","B","C","D","G","F","E","points","isFirefox","navigator","userAgent","getTranslation","viewport","trans","nodeName","parseInt","path","querySelector","svg","parentNode","assign","annotation","child","group","JSON","parse","fillOpacity","rectangles","renderRect","strokeWidth","x1","y1","x2","y2","outerSVG","innerSVG","viewBox","renderPoint","join","renderPath","uuid","filter","transformChild","BORDER_COLOR","userSelectStyleSheet","createElement","findSVGContainer","toUpperCase","findSVGAtPoint","elements","querySelectorAll","el","pointIntersectsRect","getBoundingClientRect","findAnnotationAtPoint","candidate","elementFromPoint","top","bottom","left","right","getOffsetAnnotationRect","extraOffsetWidth","extraOffsetHeight","tagName","getBBox","bbox","_getOffset","offsetLeft","offsetTop","getOffset","scaleUp","result","getMetadata","convertToSvgPoint","xform","offset","convertToScreenPoint","scaleDown","disableUserSelect","head","enableUserSelect","removeChild","documentId","pageNumber","clickNode","fireEvent","clientX","clientY","StoreAdapter","_this","definition","_classCallCheck","__getAnnotations","fn","then","annotations","annotationId","__addAnnotation","__editAnnotation","__deleteAnnotation","success","__addComment","comment","commentId","__deleteComment","REGEXP","replacement","random","LocalStoreAdapter","_StoreAdapter","_inherits","_super","_createSuper","getAnnotations","page","getAnnotation","findAnnotation","addAnnotation","updateAnnotations","editAnnotation","deleteAnnotation","splice","getComments","addComment","class","deleteComment","localStorage","getItem","setItem","stringify","LocalUserStoreAdapter","userId","globalEdit","getAllAnnotations","_userId","_globalEdit","all_annotations","re","RegExp","search","_toConsumableArray","annotationLayerName","textLayerName","annotationSvgQuery","annotationClassQuery","textClassQuery","overlay","dragOffsetX","dragOffsetY","dragStartX","dragStartY","_enabled","isDragging","destroyEditOverlay","handleDocumentClick","handleDocumentKeyup","handleDocumentMousedown","handleDocumentMousemove","handleDocumentMouseup","config","PDFJSAnnotate","getStoreAdapter","getElementById","keyTest","keyCode","preventDefault","background","cursor","display","maxY","maxX","offsetHeight","offsetWidth","attribX","attribY","modelStart","modelEnd","modelDelta","firstChild","modelX","modelY","setTimeout","handleAnnotationClick","anchor","id","styleLeft","styleTop","boxSizing","border","borderRadius","zIndex","padding","textAlign","textDecoration","borderColor","boxShadow","createEditOverlay","_penSize","_penColor","_candraw","handleDocumentPointerdown","handleDocumentPointerup","_getMetadata","saveToStorage","handleDocumentPointermove","point","toFixed","savePoint","originY","originX","_getMetadata2","_canerase","previousPoint","handleDocumentDown","handleDocumentUp","erase","handleDocumentMouseMove","check","diffX","abs","diffY","maxSteps","round","max","subStepSize","min","smallerTest","startPoint","_i","_check","parentElement","input","handleInputBlur","handleInputKeyup","body","focus","closeInput","trim","_type","rects","getSelection","getRangeAt","getClientRects","getSelectionRects","saveRect","map","removeAllRanges","boundingRect","convertToSvgRect","_circleRadius","_circleColor","radius","svg_pt","saveCircle","_textSize","_textColor","srcElement","classList","contains","saveText","shiftKey","createScreenReaderOnly","createTextNode","overflow","insertElementWithinElement","insertBefore","textLayerElementFromPoint","temp","cloneNode","tail","outerHTML","insertElementWithinChildren","nodes","textLayer","insertScreenReaderComment","item","renderScreenReaderComments","comments","isArray","COMMENT_TYPES","reorderAnnotationsByType","removeAnnotation","renderScreenReaderHints","removeElementById","insertComment","removeComment","elementId","SORT_TYPES","sortBy","sort","num","first","last","includes","insertScreenReaderHint","sortByPoint","b","sortByRectPoint","lineA","lineB","PAGE_TEMPLATE","approximateFraction","floor","xinv","x_","q","roundToDivide","div","disableEdit","enableEdit","disablePen","enablePen","setPen","penSize","penColor","parseFloat","disablePoint","enablePoint","disableRect","enableRect","disableCircle","enableCircle","setCircle","circleRadius","circleColor","addCircle","oldType","disableArrow","enableArrow","setArrow","disableEraser","enableEraser","disableText","enableText","setText","textSize","textColor","createPage","children","canvas","mozOpaque","renderPage","renderOptions","pdfDocument","eventBus","pdfjsViewer","EventBus","all","getPage","_ref","_ref2","_slicedToArray","pdfPage","canvasContext","getContext","alpha","totalRotation","getViewport","wrapper","outputScale","ctx","devicePixelRatio","backingStoreRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","pixelRatio","sx","sy","scaled","sfx","sfy","visibility","scalePage","render","promise","getTextContent","normalizeWhitespace","textLayerBuilder","DefaultTextLayerFactory","createTextLayerBuilder","setTextContent","__storeAdapter","setStoreAdapter","adapter","UI","data","removeAttribute","_this$getStoreAdapter"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,CAAC,EAGxB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,CAAC,GAUX,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,OACf,CAyDA,OArDAM,EAAoBM,EAAIF,EAGxBJ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tH,IAC9DM,EAAIoX,gBAAgB,8BACpBpX,EAAIoX,gBAAgB,0BAGfD,GAKLnX,EAAI/G,aAAa,6BAA8Bke,EAAKlT,YACpDjE,EAAI/G,aAAa,yBAA0Bke,EAAKjT,YAG3C5N,MAAM+Z,QAAQ8G,EAAKrS,cAA4C,IAA5BqS,EAAKrS,YAAY3P,QAKzDgiB,EAAKrS,YAAY9L,SAAQ,SAACqB,GACxB,IAAIvB,EAAOkH,EAAID,cAAc,0BAA4B1F,EAAEiH,KAAO,MAC9DxI,EACF0I,EAAexB,EAAKlH,EAAM4G,GAG1BhE,EAAYsE,EAAK3F,EAAGqF,EAExB,SAEAxM,EAAQ8M,IAdC9M,EAAQ8M,KATfA,EAAIvE,UAAY,GACTvI,EAAQ8M,GAuBnB,GACF,EDuCEgG,eAAc,SAAC/B,EAAYC,GAAY,IAAAmT,EACrC,OAAOA,EAAAvkB,KAAKkW,mBAAkBhD,eAAchU,MAAAqlB,EAAI5jB,UAClD,EAEAqV,UAEAxH,SE3FayH,Y","file":"pdf-annotate.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PDFAnnotate\"] = factory();\n\telse\n\t\troot[\"PDFAnnotate\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/**\r\n * Throw an Error for an abstract function that hasn't been implemented.\r\n *\r\n * @param {String} name The name of the abstract function\r\n */\r\nexport default function abstractFunction(name) {\r\n throw new Error(name + ' is not implemented');\r\n}\r\n","const UPPER_REGEX = /[A-Z]/g;\r\n\r\n// Don't convert these attributes from camelCase to hyphenated-attributes\r\nconst BLACKLIST = [\r\n 'viewBox'\r\n];\r\n\r\nlet keyCase = (key) => {\r\n if (BLACKLIST.indexOf(key) === -1) {\r\n key = key.replace(UPPER_REGEX, match => '-' + match.toLowerCase());\r\n }\r\n return key;\r\n};\r\n\r\n/**\r\n * Set attributes for a node from a map\r\n *\r\n * @param {Node} node The node to set attributes on\r\n * @param {Object} attributes The map of key/value pairs to use for attributes\r\n */\r\nexport default function setAttributes(node, attributes) {\r\n Object.keys(attributes).forEach((key) => {\r\n node.setAttribute(keyCase(key), attributes[key]);\r\n });\r\n}\r\n","const REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i;\r\n\r\n/**\r\n * Normalize a color value\r\n *\r\n * @param {String} color The color to normalize\r\n * @return {String}\r\n */\r\nexport default function normalizeColor(color) {\r\n if (REGEX_HASHLESS_HEX.test(color)) {\r\n color = `#${color}`;\r\n }\r\n return color;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\n\r\nconst SIZE = 25;\r\nconst D = 'M499.968 214.336q-113.832 0 -212.877 38.781t-157.356 104.625 -58.311 142.29q0 62.496 39.897 119.133t112.437 97.929l48.546 27.9 -15.066 53.568q-13.392 50.778 -39.06 95.976 84.816 -35.154 153.45 -95.418l23.994 -21.204 31.806 3.348q38.502 4.464 72.54 4.464 113.832 0 212.877 -38.781t157.356 -104.625 58.311 -142.29 -58.311 -142.29 -157.356 -104.625 -212.877 -38.781z';\r\n\r\n/**\r\n * Create SVGElement from an annotation definition.\r\n * This is used for anntations of type `comment`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGElement} A svg to be rendered\r\n */\r\nexport default function renderPoint(a) {\r\n let outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r\n let innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\r\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r\n\r\n setAttributes(outerSVG, {\r\n width: SIZE,\r\n height: SIZE,\r\n x: a.x,\r\n y: a.y\r\n });\r\n\r\n setAttributes(innerSVG, {\r\n width: SIZE,\r\n height: SIZE,\r\n x: 0,\r\n y: (SIZE * 0.05) * -1,\r\n viewBox: '0 0 1000 1000'\r\n });\r\n\r\n setAttributes(rect, {\r\n width: SIZE,\r\n height: SIZE,\r\n stroke: '#000',\r\n fill: '#ff0'\r\n });\r\n\r\n setAttributes(path, {\r\n d: D,\r\n strokeWidth: 50,\r\n stroke: '#000',\r\n fill: '#fff'\r\n });\r\n\r\n innerSVG.appendChild(path);\r\n outerSVG.appendChild(rect);\r\n outerSVG.appendChild(innerSVG);\r\n\r\n return outerSVG;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGRectElements from an annotation definition.\r\n * This is used for anntations of type `area` and `highlight`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered\r\n */\r\nexport default function renderRect(a) {\r\n if (a.type === 'highlight') {\r\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n setAttributes(group, {\r\n fill: normalizeColor(a.color || '#ff0'),\r\n fillOpacity: 0.2\r\n });\r\n\r\n a.rectangles.forEach((r) => {\r\n group.appendChild(createRect(r));\r\n });\r\n\r\n return group;\r\n }\r\n else {\r\n let rect = createRect(a);\r\n setAttributes(rect, {\r\n stroke: normalizeColor(a.color || '#f00'),\r\n fill: 'none'\r\n });\r\n\r\n return rect;\r\n }\r\n}\r\n\r\nfunction createRect(r) {\r\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\r\n\r\n setAttributes(rect, {\r\n x: r.x,\r\n y: r.y,\r\n width: r.width,\r\n height: r.height\r\n });\r\n\r\n return rect;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Wrap each line of given text in a `` element and append these\r\n * lines to the given SVGTextElement\r\n *\r\n * @param {SVGTextElement} textElement A text element to hold the split text\r\n * @param {String} textContent String to render with line breaks\r\n */\r\nfunction insertLineBreaks(textElement, textContent) {\r\n const lines = (textContent || '').split('\\n');\r\n // can't use dy attribute here since we want empty lines to take up space as well,\r\n // so we will update y manually based on font size\r\n const x = textElement.getAttribute('x');\r\n let y = Number(textElement.getAttribute('y'));\r\n const size = Number(textElement.getAttribute('font-size'));\r\n for (const line of lines) {\r\n const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');\r\n tspan.setAttribute('y', y.toString());\r\n tspan.setAttribute('x', x);\r\n tspan.innerHTML = line;\r\n textElement.appendChild(tspan);\r\n\r\n y += size;\r\n }\r\n}\r\n\r\n/**\r\n * Create SVGTextElement from an annotation definition.\r\n * This is used for anntations of type `textbox`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGTextElement} A text to be rendered\r\n */\r\nexport default function renderText(a) {\r\n // Text should be rendered at 0 degrees relative to\r\n // document rotation\r\n let text = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r\n setAttributes(text, {\r\n x: a.x,\r\n y: a.y,\r\n fill: normalizeColor(a.color || '#000'),\r\n fontSize: a.size,\r\n transform: `rotate(${a.rotation})`,\r\n style: 'white-space: pre'\r\n });\r\n\r\n insertLineBreaks(text, a.content);\r\n\r\n let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n g.appendChild(text);\r\n\r\n return g;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create an SVGCircleElement from an annotation definition.\r\n * This is used for annotations of type `circle`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement|SVGCircleElement} A circle to be rendered\r\n */\r\nexport default function renderCircle(a) {\r\n let circle = createCircle(a);\r\n let color = normalizeColor(a.color || '#f00');\r\n\r\n if (a.type === 'circle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: 'none',\r\n 'stroke-width': 5\r\n });\r\n }\r\n if (a.type === 'emptycircle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: 'none',\r\n 'stroke-width': 2\r\n });\r\n }\r\n\r\n if (a.type === 'fillcircle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: color,\r\n 'stroke-width': 5\r\n });\r\n }\r\n\r\n return circle;\r\n}\r\n\r\nfunction createCircle(a) {\r\n let circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\r\n setAttributes(circle, {\r\n cx: a.cx,\r\n cy: a.cy,\r\n r: a.r\r\n });\r\n\r\n return circle;\r\n}\r\n","// Transform point by matrix\r\n//\r\nexport function applyTransform(p, m) {\r\n return [\r\n p[0] * m[0] + p[1] * m[2] + m[4],\r\n p[0] * m[1] + p[1] * m[3] + m[5]\r\n ];\r\n};\r\n\r\n// Transform point by matrix inverse\r\n//\r\nexport function applyInverseTransform(p, m) {\r\n let d = m[0] * m[3] - m[1] * m[2];\r\n return [\r\n (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d,\r\n (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d\r\n ];\r\n};\r\n\r\n// Concatenates two transformation matrices together and returns the result.\r\nexport function transform(m1, m2) {\r\n return [\r\n m1[0] * m2[0] + m1[2] * m2[1],\r\n m1[1] * m2[0] + m1[3] * m2[1],\r\n m1[0] * m2[2] + m1[2] * m2[3],\r\n m1[1] * m2[2] + m1[3] * m2[3],\r\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\r\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5]\r\n ];\r\n};\r\n\r\nexport function translate(m, x, y) {\r\n return [\r\n m[0],\r\n m[1],\r\n m[2],\r\n m[3],\r\n m[0] * x + m[2] * y + m[4],\r\n m[1] * x + m[3] * y + m[5]\r\n ];\r\n};\r\n\r\nexport function rotate(m, angle) {\r\n angle = angle * Math.PI / 180;\r\n\r\n let cosValue = Math.cos(angle);\r\n let sinValue = Math.sin(angle);\r\n\r\n return [\r\n m[0] * cosValue + m[2] * sinValue,\r\n m[1] * cosValue + m[3] * sinValue,\r\n m[0] * (-sinValue) + m[2] * cosValue,\r\n m[1] * (-sinValue) + m[3] * cosValue,\r\n m[4],\r\n m[5]\r\n ];\r\n};\r\n\r\nexport function scale(m, x, y) {\r\n return [\r\n m[0] * x,\r\n m[1] * x,\r\n m[2] * y,\r\n m[3] * y,\r\n m[4],\r\n m[5]\r\n ];\r\n};\r\n\r\nexport function makePoint(x, y, z) {\r\n return { x: x, y: y, z: z };\r\n};\r\n\r\nexport function makeVector(xcoord, ycoord, zcoord) {\r\n return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord };\r\n};\r\n\r\nexport function makeVectorFromPoints(pt1, pt2) {\r\n let xcoord = pt2.x - pt1.x;\r\n let ycoord = pt2.y - pt1.y;\r\n let zcoord = pt2.z - pt1.z;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n\r\nexport function addVector(pt, v) {\r\n return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord);\r\n};\r\n\r\nexport function multiplyVector(v, scalar) {\r\n return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar);\r\n};\r\n\r\nexport function magnitude(v) {\r\n return Math.sqrt(\r\n Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)\r\n );\r\n};\r\n\r\nexport function negateVector(v) {\r\n return multiplyVector(v, -1);\r\n};\r\n\r\nexport function unitVector(v) {\r\n let mag = magnitude(v);\r\n let xcoord = v.xcoord / mag;\r\n let ycoord = v.ycoord / mag;\r\n let zcoord = v.zcoord / mag;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n\r\nexport function crossProduct(u, v) {\r\n //\r\n // u X v = < u2*v3 - u3*v2,\r\n // u3*v1 - u1*v3,\r\n // u1*v2 - u2*v1 >\r\n let xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord;\r\n let ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord;\r\n let zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\nimport {\r\n makePoint, makeVector, makeVectorFromPoints,\r\n magnitude, unitVector, crossProduct,\r\n addVector, multiplyVector, negateVector\r\n} from '../utils/mathUtils';\r\n\r\n/**\r\n * Create SVGPathElement from an annotation definition.\r\n * This is used for anntations of type `drawing`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGPathElement} The path to be rendered\r\n */\r\nexport default function renderArrow(a) {\r\n let arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');\r\n\r\n if (a.lines.length === 2) {\r\n let p1 = a.lines[0];\r\n let p2 = a.lines[a.lines.length - 1];\r\n\r\n let arrowLength = 40;\r\n let pt0 = makePoint(p1[0], p1[1], 0);\r\n let pt1 = makePoint(p2[0], p2[1], 0);\r\n let x = makeVectorFromPoints(pt0, pt1);\r\n let unitX = unitVector(x);\r\n pt1 = addVector(pt0, multiplyVector(unitX, arrowLength));\r\n x = makeVectorFromPoints(pt0, pt1);\r\n let unitZ = makeVector(0, 0, 1);\r\n let unitY = unitVector(crossProduct(unitX, unitZ));\r\n let thickness = a.width || 10;\r\n\r\n let A = addVector(pt0, multiplyVector(unitY, thickness * 0.5));\r\n let B = addVector(A, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\r\n let C = addVector(B, multiplyVector(unitY, thickness));\r\n let D = pt1;\r\n let G = addVector(pt0, multiplyVector(negateVector(unitY), thickness * 0.5));\r\n let F = addVector(G, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\r\n let E = addVector(F, multiplyVector(negateVector(unitY), thickness));\r\n\r\n let points = '' +\r\n A.x + ',' + A.y + ' ' +\r\n B.x + ',' + B.y + ' ' +\r\n C.x + ',' + C.y + ' ' +\r\n D.x + ',' + D.y + ' ' +\r\n E.x + ',' + E.y + ' ' +\r\n F.x + ',' + F.y + ' ' +\r\n G.x + ',' + G.y;\r\n\r\n setAttributes(arrow, {\r\n points: points,\r\n stroke: normalizeColor(a.color || '#000'),\r\n fill: normalizeColor(a.color || '#000')\r\n });\r\n }\r\n\r\n return arrow;\r\n}\r\n","import renderLine from './renderLine';\r\nimport renderPath from './renderPath';\r\nimport renderPoint from './renderPoint';\r\nimport renderRect from './renderRect';\r\nimport renderText from './renderText';\r\nimport renderCircle from './renderCircle';\r\nimport renderArrow from './renderArrow';\r\n\r\nconst isFirefox = /firefox/i.test(navigator.userAgent);\r\n\r\n/**\r\n * Get the x/y translation to be used for transforming the annotations\r\n * based on the rotation of the viewport.\r\n *\r\n * @param {Object} viewport The viewport data from the page\r\n * @return {Object}\r\n */\r\nexport function getTranslation(viewport) {\r\n let x;\r\n let y;\r\n\r\n // Modulus 360 on the rotation so that we only\r\n // have to worry about four possible values.\r\n switch (viewport.rotation % 360) {\r\n case 0:\r\n x = y = 0;\r\n break;\r\n case 90:\r\n x = 0;\r\n y = (viewport.width / viewport.scale) * -1;\r\n break;\r\n case 180:\r\n x = (viewport.width / viewport.scale) * -1;\r\n y = (viewport.height / viewport.scale) * -1;\r\n break;\r\n case 270:\r\n x = (viewport.height / viewport.scale) * -1;\r\n y = 0;\r\n break;\r\n }\r\n\r\n return { x, y };\r\n}\r\n\r\n/**\r\n * Transform the rotation and scale of a node using SVG's native transform attribute.\r\n *\r\n * @param {Node} node The node to be transformed\r\n * @param {Object} viewport The page's viewport data\r\n * @return {Node}\r\n */\r\nfunction transform(node, viewport) {\r\n let trans = getTranslation(viewport);\r\n\r\n // Let SVG natively transform the element\r\n node.setAttribute('transform', `scale(${viewport.scale}) rotate(${viewport.rotation}) translate(${trans.x}, ${trans.y})`);\r\n\r\n // Manually adjust x/y for nested SVG nodes\r\n if (!isFirefox && node.nodeName.toLowerCase() === 'svg') {\r\n node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale);\r\n node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale);\r\n\r\n let x = parseInt(node.getAttribute('x', 10));\r\n let y = parseInt(node.getAttribute('y', 10));\r\n let width = parseInt(node.getAttribute('width'), 10);\r\n let height = parseInt(node.getAttribute('height'), 10);\r\n let path = node.querySelector('path');\r\n let svg = path.parentNode;\r\n\r\n // Scale width/height\r\n [node, svg, path, node.querySelector('rect')].forEach((n) => {\r\n n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale);\r\n n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale);\r\n });\r\n\r\n // Transform path but keep scale at 100% since it will be handled natively\r\n transform(path, Object.assign({}, viewport, { scale: 1 }));\r\n\r\n switch (viewport.rotation % 360) {\r\n case 90:\r\n node.setAttribute('x', viewport.width - y - width);\r\n node.setAttribute('y', x);\r\n svg.setAttribute('x', 1);\r\n svg.setAttribute('y', 0);\r\n break;\r\n case 180:\r\n node.setAttribute('x', viewport.width - x - width);\r\n node.setAttribute('y', viewport.height - y - height);\r\n svg.setAttribute('y', 2);\r\n break;\r\n case 270:\r\n node.setAttribute('x', y);\r\n node.setAttribute('y', viewport.height - x - height);\r\n svg.setAttribute('x', -1);\r\n svg.setAttribute('y', 0);\r\n break;\r\n }\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Append an annotation as a child of an SVG.\r\n *\r\n * @param {SVGElement} svg The SVG element to append the annotation to\r\n * @param {Object} annotation The annotation definition to render and append\r\n * @param {Object} viewport The page's viewport data\r\n * @return {SVGElement} A node that was created and appended by this function\r\n */\r\nexport function appendChild(svg, annotation, viewport) {\r\n if (!viewport) {\r\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\r\n }\r\n\r\n let child;\r\n switch (annotation.type) {\r\n case 'area':\r\n case 'highlight':\r\n child = renderRect(annotation);\r\n break;\r\n case 'circle':\r\n case 'fillcircle':\r\n case 'emptycircle':\r\n child = renderCircle(annotation);\r\n break;\r\n case 'strikeout':\r\n child = renderLine(annotation);\r\n break;\r\n case 'point':\r\n child = renderPoint(annotation);\r\n break;\r\n case 'textbox':\r\n child = renderText(annotation);\r\n break;\r\n case 'drawing':\r\n child = renderPath(annotation);\r\n break;\r\n case 'arrow':\r\n child = renderArrow(annotation);\r\n break;\r\n }\r\n\r\n // If no type was provided for an annotation it will result in node being null.\r\n // Skip appending/transforming if node doesn't exist.\r\n if (child) {\r\n // Set attributes\r\n child.setAttribute('data-pdf-annotate-id', annotation.uuid);\r\n child.setAttribute('aria-hidden', true);\r\n\r\n // Dynamically set any other attributes associated with annotation that is not related to drawing it\r\n Object.keys(annotation).filter((key) => {\r\n return ['color', 'x', 'y', 'cx', 'cy', 'color', 'documentId', 'lines', 'page',\r\n 'width', 'class', 'content', 'size', 'rotation', 'r'].indexOf(key) === -1;\r\n }).forEach((key) => {\r\n child.setAttribute(`data-pdf-annotate-${key}`, annotation[key]);\r\n });\r\n\r\n svg.appendChild(transform(child, viewport));\r\n }\r\n\r\n return child;\r\n}\r\n\r\n/**\r\n * Transform a child annotation of an SVG.\r\n *\r\n * @param {SVGElement} svg The SVG element with the child annotation\r\n * @param {Object} child The SVG child to transform\r\n * @param {Object} viewport The page's viewport data\r\n * @return {SVGElement} A node that was transformed by this function\r\n */\r\nexport function transformChild(svg, child, viewport) {\r\n if (!viewport) {\r\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\r\n }\r\n\r\n // If no type was provided for an annotation it will result in node being null.\r\n // Skip transforming if node doesn't exist.\r\n if (child) {\r\n child = transform(child, viewport);\r\n }\r\n\r\n return child;\r\n}\r\n\r\nexport default {\r\n /**\r\n * Get the x/y translation to be used for transforming the annotations\r\n * based on the rotation of the viewport.\r\n */\r\n getTranslation,\r\n\r\n /**\r\n * Append an SVG child for an annotation\r\n */\r\n appendChild,\r\n\r\n /**\r\n * Transform an existing SVG child\r\n */\r\n transformChild\r\n};\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGLineElements from an annotation definition.\r\n * This is used for anntations of type `strikeout`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement} A group of all lines to be rendered\r\n */\r\nexport default function renderLine(a) {\r\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n setAttributes(group, {\r\n stroke: normalizeColor(a.color || '#f00'),\r\n strokeWidth: 1\r\n });\r\n\r\n a.rectangles.forEach((r) => {\r\n let line = document.createElementNS('http://www.w3.org/2000/svg', 'line');\r\n\r\n setAttributes(line, {\r\n x1: r.x,\r\n y1: r.y,\r\n x2: r.x + r.width,\r\n y2: r.y\r\n });\r\n\r\n group.appendChild(line);\r\n });\r\n\r\n return group;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGPathElement from an annotation definition.\r\n * This is used for anntations of type `drawing`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGPathElement} The path to be rendered\r\n */\r\nexport default function renderPath(a) {\r\n let d = [];\r\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r\n\r\n if (a.lines.length > 0) {\r\n d.push(`M${a.lines[0][0]} ${a.lines[0][1]}`);\r\n for (let i = 1, l = a.lines.length; i < l; i++) {\r\n let p1 = a.lines[i];\r\n let p2 = a.lines[i + 1];\r\n if (p2) {\r\n d.push(`L${p1[0]} ${p1[1]}`);\r\n }\r\n }\r\n }\r\n\r\n /*\r\n\r\n if(a.lines.length>2) {\r\n var p1 = a.lines[0];\r\n var p2 = a.lines[a.lines.length-1];\r\n\r\n var p3 = []; //arrow\r\n var p4 = [];\r\n var p0 = []; //arrow intersection\r\n\r\n if (p2) {\r\n var k = -(p2[0]-p1[0])/(p2[1]-p1[1]);\r\n\r\n var deltaX = 3;\r\n p0[0] = p1[0]+0.8*(p2[0]-p1[0]);\r\n p0[1] = p1[1]+0.8*(p2[1]-p1[1]);\r\n\r\n p3[0] = p0[0] + deltaX;\r\n p3[1] = p0[1] + k*deltaX;\r\n\r\n p4[0] = p0[0] - deltaX;\r\n p4[1] = p0[1] - k*deltaX;\r\n\r\n if(Math.abs(p2[1]-p1[1]) < 20) {\r\n\r\n p3[0] = p0[0] ;\r\n p3[1] = p0[1] + deltaX*1;\r\n\r\n p4[0] = p0[0] ;\r\n p4[1] = p0[1] - deltaX*1;\r\n\r\n }\r\n\r\n d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\r\n //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\r\n d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`);\r\n d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`);\r\n d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`);\r\n }\r\n } */\r\n\r\n setAttributes(path, {\r\n d: `${d.join(' ')}`, // `${d.join(' ')}Z`,\r\n stroke: normalizeColor(a.color || '#000'),\r\n strokeWidth: a.width || 1,\r\n fill: 'none'\r\n });\r\n\r\n return path;\r\n}\r\n","import { getTranslation } from '../render/appendChild';\r\nimport {\r\n applyTransform,\r\n applyInverseTransform,\r\n translate,\r\n rotate,\r\n scale\r\n} from '../utils/mathUtils';\r\n\r\nexport const BORDER_COLOR = '#00BFFF';\r\n\r\nconst userSelectStyleSheet = document.createElement('style');\r\nuserSelectStyleSheet.innerHTML = `\r\nbody {\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n}\r\n`;\r\n\r\nuserSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true');\r\n\r\n/**\r\n * Find the SVGElement that contains all the annotations for a page\r\n *\r\n * @param {Element} node An annotation within that container\r\n * @return {SVGElement} The container SVG or null if it can't be found\r\n */\r\nexport function findSVGContainer(node) {\r\n let parentNode = node;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n if (parentNode.nodeName.toUpperCase() === 'SVG' &&\r\n parentNode.getAttribute('data-pdf-annotate-container') === 'true') {\r\n return parentNode;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Find an SVGElement container at a given point\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @return {SVGElement} The container SVG or null if one can't be found\r\n */\r\nexport function findSVGAtPoint(x, y) {\r\n let elements = document.querySelectorAll('svg[data-pdf-annotate-container=\"true\"]');\r\n\r\n for (let i = 0, l = elements.length; i < l; i++) {\r\n let el = elements[i];\r\n let rect = el.getBoundingClientRect();\r\n\r\n if (pointIntersectsRect(x, y, rect)) {\r\n return el;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Find an Element that represents an annotation at a given point.\r\n *\r\n * IMPORTANT: Requires the annotation layer to be the top most element so\r\n * either use z-ordering or make it the leaf container.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @return {Element} The annotation element or null if one can't be found\r\n */\r\nexport function findAnnotationAtPoint(x, y) {\r\n let el = null;\r\n let candidate = document.elementFromPoint(x, y);\r\n while (!el && candidate && candidate !== document) {\r\n let type = candidate.getAttribute('data-pdf-annotate-type');\r\n if (type) {\r\n el = candidate;\r\n }\r\n candidate = candidate.parentNode;\r\n }\r\n return el;\r\n}\r\n\r\n/**\r\n * Determine if a point intersects a rect\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Object} rect The points of a rect (likely from getBoundingClientRect)\r\n * @return {Boolean} True if a collision occurs, otherwise false\r\n */\r\nexport function pointIntersectsRect(x, y, rect) {\r\n return y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;\r\n}\r\n\r\n/**\r\n * Get the rect of an annotation element accounting for offset.\r\n *\r\n * @param {Element} el The element to get the rect of\r\n * @return {Object} The dimensions of the element\r\n */\r\nexport function getOffsetAnnotationRect(el) {\r\n let rect = el.getBoundingClientRect();\r\n let { width, height } = rect;\r\n let extraOffsetWidth = 0;\r\n let extraOffsetHeight = 0;\r\n if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) {\r\n let bbox = el.getBBox();\r\n extraOffsetWidth = (rect.width - bbox.width) / 2;\r\n extraOffsetHeight = (rect.height - bbox.height) / 2;\r\n width = bbox.width;\r\n height = bbox.height;\r\n }\r\n let { offsetLeft, offsetTop } = getOffset(el);\r\n return {\r\n top: rect.top - offsetTop + extraOffsetHeight,\r\n left: rect.left - offsetLeft + extraOffsetWidth,\r\n bottom: rect.bottom - offsetTop - extraOffsetHeight,\r\n right: rect.right - offsetLeft - extraOffsetWidth,\r\n width: width,\r\n height: height\r\n };\r\n}\r\n\r\n/**\r\n * Adjust scale from normalized scale (100%) to rendered scale.\r\n *\r\n * @param {SVGElement} svg The SVG to gather metadata from\r\n * @param {Object} rect A map of numeric values to scale\r\n * @return {Object} A copy of `rect` with values scaled up\r\n */\r\nexport function scaleUp(svg, rect) {\r\n let result = {};\r\n let { viewport } = getMetadata(svg);\r\n\r\n Object.keys(rect).forEach((key) => {\r\n result[key] = rect[key] * viewport.scale;\r\n });\r\n\r\n return result;\r\n}\r\n\r\nexport function convertToSvgRect(rect, svg, viewport) {\r\n let pt1 = [rect.x, rect.y];\r\n let pt2 = [rect.x + rect.width, rect.y + rect.height];\r\n\r\n pt1 = convertToSvgPoint(pt1, svg, viewport);\r\n pt2 = convertToSvgPoint(pt2, svg, viewport);\r\n\r\n return {\r\n x: Math.min(pt1[0], pt2[0]),\r\n y: Math.min(pt1[1], pt2[1]),\r\n width: Math.abs(pt2[0] - pt1[0]),\r\n height: Math.abs(pt2[1] - pt1[1])\r\n };\r\n}\r\n\r\nexport function convertToSvgPoint(pt, svg, viewport) {\r\n viewport = viewport || getMetadata(svg).viewport;\r\n\r\n let xform = [ 1, 0, 0, 1, 0, 0 ];\r\n xform = scale(xform, viewport.scale, viewport.scale);\r\n xform = rotate(xform, viewport.rotation);\r\n\r\n let offset = getTranslation(viewport);\r\n xform = translate(xform, offset.x, offset.y);\r\n\r\n return applyInverseTransform(pt, xform);\r\n}\r\n\r\nexport function convertToScreenPoint(pt, svg, viewport) {\r\n viewport = viewport || getMetadata(svg).viewport;\r\n\r\n let xform = [ 1, 0, 0, 1, 0, 0 ];\r\n xform = scale(xform, viewport.scale, viewport.scale);\r\n xform = rotate(xform, viewport.rotation);\r\n\r\n let offset = getTranslation(viewport);\r\n xform = translate(xform, offset.x, offset.y);\r\n\r\n return applyTransform(pt, xform);\r\n}\r\n\r\n/**\r\n * Adjust scale from rendered scale to a normalized scale (100%).\r\n *\r\n * @param {SVGElement} svg The SVG to gather metadata from\r\n * @param {Object} rect A map of numeric values to scale\r\n * @return {Object} A copy of `rect` with values scaled down\r\n */\r\nexport function scaleDown(svg, rect) {\r\n let result = {};\r\n let { viewport } = getMetadata(svg);\r\n\r\n Object.keys(rect).forEach((key) => {\r\n result[key] = rect[key] / viewport.scale;\r\n });\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the scroll position of an element, accounting for parent elements\r\n *\r\n * @param {Element} el The element to get the scroll position for\r\n * @return {Object} The scrollTop and scrollLeft position\r\n */\r\nexport function getScroll(el) {\r\n let scrollTop = 0;\r\n let scrollLeft = 0;\r\n let parentNode = el;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n scrollTop += parentNode.scrollTop;\r\n scrollLeft += parentNode.scrollLeft;\r\n }\r\n\r\n return { scrollTop, scrollLeft };\r\n}\r\n\r\n/**\r\n * Get the offset position of an element, accounting for parent elements\r\n *\r\n * @param {Element} el The element to get the offset position for\r\n * @return {Object} The offsetTop and offsetLeft position\r\n */\r\nexport function getOffset(el) {\r\n let parentNode = el;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n if (parentNode.nodeName.toUpperCase() === 'SVG') {\r\n break;\r\n }\r\n }\r\n\r\n let rect = parentNode.getBoundingClientRect();\r\n\r\n return { offsetLeft: rect.left, offsetTop: rect.top };\r\n}\r\n\r\n/**\r\n * Disable user ability to select text on page\r\n */\r\nexport function disableUserSelect() {\r\n if (!userSelectStyleSheet.parentNode) {\r\n document.head.appendChild(userSelectStyleSheet);\r\n }\r\n}\r\n\r\n/**\r\n * Enable user ability to select text on page\r\n */\r\nexport function enableUserSelect() {\r\n if (userSelectStyleSheet.parentNode) {\r\n userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet);\r\n }\r\n}\r\n\r\n/**\r\n * Get the metadata for a SVG container\r\n *\r\n * @param {SVGElement} svg The SVG container to get metadata for\r\n */\r\nexport function getMetadata(svg) {\r\n return {\r\n documentId: svg.getAttribute('data-pdf-annotate-document'),\r\n pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10),\r\n viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'))\r\n };\r\n}\r\n","import EventEmitter from 'events';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGAtPoint\r\n} from './utils';\r\n\r\nconst emitter = new EventEmitter();\r\n\r\nlet clickNode;\r\n\r\n/**\r\n * Handle document.click event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\ndocument.addEventListener('click', function handleDocumentClick(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n\r\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n\r\n // Emit annotation:blur if clickNode is no longer clicked\r\n if (clickNode && clickNode !== target) {\r\n emitter.emit('annotation:blur', clickNode);\r\n }\r\n\r\n // Emit annotation:click if target was clicked\r\n if (target) {\r\n emitter.emit('annotation:click', target);\r\n }\r\n\r\n clickNode = target;\r\n});\r\n\r\n// let mouseOverNode;\r\n// document.addEventListener('mousemove', function handleDocumentMousemove(e) {\r\n// let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n//\r\n// // Emit annotation:mouseout if target was mouseout'd\r\n// if (mouseOverNode && !target) {\r\n// emitter.emit('annotation:mouseout', mouseOverNode);\r\n// }\r\n//\r\n// // Emit annotation:mouseover if target was mouseover'd\r\n// if (target && mouseOverNode !== target) {\r\n// emitter.emit('annotation:mouseover', target);\r\n// }\r\n//\r\n// mouseOverNode = target;\r\n// });\r\n\r\nexport function fireEvent() { emitter.emit(...arguments); };\r\nexport function addEventListener() { emitter.on(...arguments); };\r\nexport function removeEventListener() { emitter.removeListener(...arguments); };\r\n","// Disable JSDoc as it cannot really deal with the odd way that the functions are defined\r\n/* eslint valid-jsdoc: 0 */\r\n\r\nimport abstractFunction from '../utils/abstractFunction';\r\nimport { fireEvent } from '../UI/event';\r\n\r\n// Adapter should never be invoked publicly\r\nexport default class StoreAdapter {\r\n /**\r\n * Create a new StoreAdapter instance\r\n *\r\n * @param {Object} [definition] The definition to use for overriding abstract methods\r\n */\r\n constructor(definition = {}) {\r\n // Copy each function from definition if it is a function we know about\r\n Object.keys(definition).forEach((key) => {\r\n if (typeof definition[key] === 'function' &&\r\n typeof this[key] === 'function') {\r\n this[key] = definition[key];\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Get all the annotations for a given document and page number.\r\n *\r\n * @param {String} documentId The ID for the document the annotations belong to\r\n * @param {Number} pageNumber The number of the page the annotations belong to\r\n * @return {Promise} Promise that returns with list of annotations for document and page\r\n */\r\n __getAnnotations(documentId, pageNumber) { abstractFunction('getAnnotations'); }\r\n get getAnnotations() { return this.__getAnnotations; }\r\n set getAnnotations(fn) {\r\n this.__getAnnotations = function getAnnotations(documentId, pageNumber) {\r\n return fn(...arguments).then((annotations) => {\r\n // TODO may be best to have this happen on the server\r\n if (annotations.annotations) {\r\n annotations.annotations.forEach((a) => {\r\n a.documentId = documentId;\r\n });\r\n }\r\n return annotations;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Get the definition for a specific annotation.\r\n *\r\n * @param {String} documentId The ID for the document the annotation belongs to\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns the requested annotation\r\n */\r\n getAnnotation(documentId, annotationId) { abstractFunction('getAnnotation'); }\r\n\r\n /**\r\n * Add an annotation\r\n *\r\n * @param {String} documentId The ID for the document to add the annotation to\r\n * @param {String} pageNumber The page number to add the annotation to\r\n * @param {Object} annotation The definition for the new annotation\r\n * @return {Promise} Promise that returns with the added annotation\r\n */\r\n __addAnnotation(documentId, pageNumber, annotation) { abstractFunction('addAnnotation'); }\r\n get addAnnotation() { return this.__addAnnotation; }\r\n set addAnnotation(fn) {\r\n this.__addAnnotation = function addAnnotation(documentId, pageNumber, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:add', documentId, pageNumber, annotation);\r\n return annotation;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Edit an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} pageNumber the page number of the annotation\r\n * @param {Object} annotation The definition of the modified annotation\r\n * @return {Promise} Promise that returns with the edited annotation\r\n */\r\n __editAnnotation(documentId, pageNumber, annotation) { abstractFunction('editAnnotation'); }\r\n get editAnnotation() { return this.__editAnnotation; }\r\n set editAnnotation(fn) {\r\n this.__editAnnotation = function editAnnotation(documentId, annotationId, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:edit', documentId, annotationId, annotation);\r\n return annotation;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Delete an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns with boolean if annotation was deleted\r\n */\r\n __deleteAnnotation(documentId, annotationId) { abstractFunction('deleteAnnotation'); }\r\n get deleteAnnotation() { return this.__deleteAnnotation; }\r\n set deleteAnnotation(fn) {\r\n this.__deleteAnnotation = function deleteAnnotation(documentId, annotationId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('annotation:delete', documentId, annotationId);\r\n }\r\n return success;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Get all the comments for an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns with comments for annotation\r\n */\r\n getComments(documentId, annotationId) { abstractFunction('getComments'); }\r\n\r\n /**\r\n * Add a new comment\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @param {Object} content The definition of the comment\r\n * @return {Promise} Promise that returns with the added comment\r\n */\r\n __addComment(documentId, annotationId, content) { abstractFunction('addComment'); }\r\n get addComment() { return this.__addComment; }\r\n set addComment(fn) {\r\n this.__addComment = function addComment(documentId, annotationId, content) {\r\n return fn(...arguments).then((comment) => {\r\n fireEvent('comment:add', documentId, annotationId, comment);\r\n return comment;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Delete a comment\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} commentId The ID for the comment\r\n * @return {Promise} Promise that returns with boolean if comment was deleted\r\n */\r\n __deleteComment(documentId, commentId) { abstractFunction('deleteComment'); }\r\n get deleteComment() { return this.__deleteComment; }\r\n set deleteComment(fn) {\r\n this.__deleteComment = function deleteComment(documentId, commentId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('comment:delete', documentId, commentId);\r\n }\r\n return success;\r\n });\r\n };\r\n }\r\n}\r\n","const REGEXP = /[xy]/g;\r\nconst PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\r\n\r\nfunction replacement(c) {\r\n let r = Math.random() * 16 | 0;\r\n let v = c === 'x' ? r : (r & 0x3 | 0x8);\r\n return v.toString(16);\r\n}\r\n\r\n/**\r\n * Generate a univierally unique identifier\r\n *\r\n * @return {String} A UUID\r\n */\r\nexport default function uuid() {\r\n return PATTERN.replace(REGEXP, replacement);\r\n}\r\n","import uuid from '../utils/uuid';\r\nimport StoreAdapter from './StoreAdapter';\r\n\r\n// StoreAdapter for working with localStorage\r\n// This is ideal for testing, examples, and prototyping\r\nexport default class LocalStoreAdapter extends StoreAdapter {\r\n constructor() {\r\n super({\r\n getAnnotations(documentId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId).filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n }\r\n });\r\n\r\n this.getAnnotation = (documentId, annotationId) => {\r\n return Promise.resolve(getAnnotations(documentId)[findAnnotation(documentId, annotationId)]);\r\n };\r\n\r\n this.addAnnotation = (documentId, pageNumber, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n annotation.class = 'Annotation';\r\n annotation.uuid = uuid();\r\n annotation.page = pageNumber;\r\n\r\n let annotations = getAnnotations(documentId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.editAnnotation = (documentId, annotationId, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId);\r\n annotations[findAnnotation(documentId, annotationId)] = annotation;\r\n updateAnnotations(documentId, annotations);\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.deleteAnnotation = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n let annotation = getAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\r\n if (!annotation) {\r\n return reject('Could not find annotation');\r\n }\r\n let index = findAnnotation(documentId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n\r\n this.getComments = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n };\r\n\r\n this.addComment = (documentId, annotationId, content) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = {\r\n class: 'Comment',\r\n uuid: uuid(),\r\n annotation: annotationId,\r\n content: content\r\n };\r\n\r\n let annotations = getAnnotations(documentId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n };\r\n\r\n this.deleteComment = (documentId, commentId) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = getAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\r\n if (!comment) {\r\n return reject('Could not find annotation');\r\n }\r\n let index = -1;\r\n let annotations = getAnnotations(documentId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === commentId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n if (index > -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n }\r\n}\r\n\r\nfunction getAnnotations(documentId) {\r\n return JSON.parse(localStorage.getItem(`${documentId}/annotations`)) || [];\r\n}\r\n\r\nfunction updateAnnotations(documentId, annotations) {\r\n localStorage.setItem(`${documentId}/annotations`, JSON.stringify(annotations));\r\n}\r\n/**\r\n *\r\n * @param {String} documentId Document id of the annotation\r\n * @param {String} annotationId The id of the annotation\r\n *\r\n * This function finds all the annotation made by one user.\r\n *\r\n * @return {int} The index of the annotation in localstorage\r\n */\r\nfunction findAnnotation(documentId, annotationId) {\r\n let index = -1;\r\n let annotations = getAnnotations(documentId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === annotationId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n return index;\r\n}\r\n","import uuid from '../utils/uuid';\r\nimport StoreAdapter from './StoreAdapter';\r\n\r\n// StoreAdapter for working with localStorage and associated user id\r\n// This is ideal for testing, examples, and prototyping\r\nexport default class LocalUserStoreAdapter extends StoreAdapter {\r\n constructor(userId = 'user', globalEdit = false) {\r\n super({\r\n getAnnotations(documentId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAllAnnotations(documentId).filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n }\r\n });\r\n\r\n this._userId = userId;\r\n this._globalEdit = globalEdit;\r\n\r\n this.getAnnotation = (documentId, annotationId) => {\r\n return Promise.resolve(getAnnotations(documentId, this._userId)[findAnnotation(documentId, this._userId, annotationId)]);\r\n };\r\n\r\n this.addAnnotation = (documentId, pageNumber, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n annotation.class = 'Annotation';\r\n annotation.uuid = uuid();\r\n annotation.page = pageNumber;\r\n annotation.userId = this._userId;\r\n\r\n let annotations = getAnnotations(documentId, this._userId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, this._userId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.editAnnotation = (documentId, annotationId, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\r\n reject('Non-matching userId');\r\n }\r\n let annotations = getAnnotations(documentId, annotation.userId);\r\n annotations[findAnnotation(documentId, annotation.userId, annotationId)] = annotation;\r\n updateAnnotations(documentId, annotation.userId, annotations);\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.deleteAnnotation = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n let annotation = getAllAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\r\n if (!annotation) {\r\n return reject('Could not find annotation');\r\n }\r\n else if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\r\n return reject('Non-matching userId');\r\n }\r\n let index = findAnnotation(documentId, annotation.userId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId, annotation.userId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotation.userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n\r\n this.getComments = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId, this._userId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n };\r\n\r\n this.addComment = (documentId, annotationId, content) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = {\r\n class: 'Comment',\r\n uuid: uuid(),\r\n annotation: annotationId,\r\n content: content,\r\n userId: this._userId\r\n };\r\n\r\n let annotations = getAnnotations(documentId, this._userId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, this._userId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n };\r\n\r\n this.deleteComment = (documentId, commentId) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = getAllAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\r\n if (!comment) {\r\n return reject('Could not find annotation');\r\n }\r\n else if (!this._globalEdit && comment.userId && comment.userId !== this._userId) {\r\n return reject('Non-matching userId');\r\n }\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, comment.userId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === commentId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n if (index > -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, comment.userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n }\r\n\r\n get userId() {\r\n return this._userId;\r\n }\r\n}\r\n\r\nfunction getAllAnnotations(documentId) {\r\n let all_annotations = [];\r\n let re = new RegExp(`${documentId}/(.*)/annotations`);\r\n for (let i = 0; i < localStorage.length; i++) {\r\n if (localStorage.key(i).search(re) > -1) {\r\n all_annotations.push(...JSON.parse(localStorage.getItem(localStorage.key(i))));\r\n }\r\n }\r\n return all_annotations;\r\n}\r\n\r\nfunction getAnnotations(documentId, userId) {\r\n return JSON.parse(localStorage.getItem(`${documentId}/${userId}/annotations`)) || [];\r\n}\r\n\r\nfunction updateAnnotations(documentId, userId, annotations) {\r\n localStorage.setItem(`${documentId}/${userId}/annotations`, JSON.stringify(annotations));\r\n}\r\n/**\r\n *\r\n * @param {String} documentId Document id of the annotation\r\n * @param {String} userId User id of the annotation\r\n * @param {String} annotationId The id of the annotation\r\n *\r\n * This function finds all the annotation made by one user.\r\n *\r\n * @return {int} The index of the annotation in localstorage\r\n */\r\nfunction findAnnotation(documentId, userId, annotationId) {\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, userId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === annotationId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n return index;\r\n}\r\n","export default {\r\n annotationLayerName: 'annotationLayer',\r\n textLayerName: 'textLayer',\r\n annotationSvgQuery: function() {\r\n return 'svg.' + this.annotationLayerName;\r\n },\r\n annotationClassQuery: function() {\r\n return '.' + this.annotationLayerName;\r\n },\r\n textClassQuery: function() {\r\n return '.' + this.textLayerName;\r\n }\r\n};\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport {\r\n addEventListener,\r\n removeEventListener\r\n} from './event';\r\nimport {\r\n BORDER_COLOR,\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGContainer,\r\n findSVGAtPoint,\r\n getOffsetAnnotationRect,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet isDragging = false;\r\nlet overlay;\r\nlet dragOffsetX, dragOffsetY, dragStartX, dragStartY;\r\nconst OVERLAY_BORDER_SIZE = 3;\r\n\r\n/**\r\n * Create an overlay for editing an annotation.\r\n *\r\n * @param {Element} target The annotation element to apply overlay for\r\n */\r\nfunction createEditOverlay(target) {\r\n destroyEditOverlay();\r\n\r\n overlay = document.createElement('div');\r\n let anchor = document.createElement('a');\r\n let parentNode = findSVGContainer(target).parentNode;\r\n let id = target.getAttribute('data-pdf-annotate-id');\r\n let rect = getOffsetAnnotationRect(target);\r\n let styleLeft = rect.left - OVERLAY_BORDER_SIZE;\r\n let styleTop = rect.top - OVERLAY_BORDER_SIZE;\r\n\r\n overlay.setAttribute('id', 'pdf-annotate-edit-overlay');\r\n overlay.setAttribute('data-target-id', id);\r\n overlay.style.boxSizing = 'content-box';\r\n overlay.style.position = 'absolute';\r\n overlay.style.top = `${styleTop}px`;\r\n overlay.style.left = `${styleLeft}px`;\r\n overlay.style.width = `${rect.width}px`;\r\n overlay.style.height = `${rect.height}px`;\r\n overlay.style.border = `${OVERLAY_BORDER_SIZE}px solid ${BORDER_COLOR}`;\r\n overlay.style.borderRadius = `${OVERLAY_BORDER_SIZE}px`;\r\n overlay.style.zIndex = 20100;\r\n\r\n anchor.innerHTML = '×';\r\n anchor.setAttribute('href', 'javascript://');\r\n anchor.style.background = '#fff';\r\n anchor.style.borderRadius = '20px';\r\n anchor.style.border = '1px solid #bbb';\r\n anchor.style.color = '#bbb';\r\n anchor.style.fontSize = '16px';\r\n anchor.style.padding = '2px';\r\n anchor.style.textAlign = 'center';\r\n anchor.style.textDecoration = 'none';\r\n anchor.style.position = 'absolute';\r\n anchor.style.top = '-13px';\r\n anchor.style.right = '-13px';\r\n anchor.style.width = '25px';\r\n anchor.style.height = '25px';\r\n\r\n overlay.appendChild(anchor);\r\n parentNode.appendChild(overlay);\r\n document.addEventListener('click', handleDocumentClick);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n anchor.addEventListener('click', deleteAnnotation);\r\n anchor.addEventListener('mouseover', () => {\r\n anchor.style.color = '#35A4DC';\r\n anchor.style.borderColor = '#999';\r\n anchor.style.boxShadow = '0 1px 1px #ccc';\r\n });\r\n anchor.addEventListener('mouseout', () => {\r\n anchor.style.color = '#bbb';\r\n anchor.style.borderColor = '#bbb';\r\n anchor.style.boxShadow = '';\r\n });\r\n overlay.addEventListener('mouseover', () => {\r\n if (!isDragging) { anchor.style.display = ''; }\r\n });\r\n overlay.addEventListener('mouseout', () => {\r\n anchor.style.display = 'none';\r\n });\r\n}\r\n\r\n/**\r\n * Destroy the edit overlay if it exists.\r\n */\r\nfunction destroyEditOverlay() {\r\n if (overlay) {\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n }\r\n\r\n document.removeEventListener('click', handleDocumentClick);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n enableUserSelect();\r\n}\r\n\r\n/**\r\n * Delete currently selected annotation\r\n */\r\nfunction deleteAnnotation() {\r\n if (!overlay) {\r\n return;\r\n }\r\n\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n });\r\n\r\n destroyEditOverlay();\r\n}\r\n\r\n/**\r\n * Handle document.click event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentClick(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) { return; }\r\n\r\n // Remove current overlay\r\n let overlay = document.getElementById('pdf-annotate-edit-overlay');\r\n if (overlay) {\r\n if (isDragging || e.target === overlay) {\r\n return;\r\n }\r\n\r\n destroyEditOverlay();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {KeyboardEvent} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // keyCode is deprecated, so prefer the newer \"key\" method if possible\r\n let keyTest;\r\n if (e.key) {\r\n keyTest = e.key.toLowerCase() === 'delete' || e.key.toLowerCase() === 'backspace';\r\n }\r\n else {\r\n keyTest = e.keyCode === 8 || e.keyCode === 46;\r\n }\r\n if (overlay && keyTest &&\r\n e.target.nodeName.toLowerCase() !== 'textarea' &&\r\n e.target.nodeName.toLowerCase() !== 'input') {\r\n e.preventDefault();\r\n deleteAnnotation();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mousedown event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n if (e.target !== overlay) {\r\n return;\r\n }\r\n\r\n // Highlight and strikeout annotations are bound to text within the document.\r\n // It doesn't make sense to allow repositioning these types of annotations.\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let target = document.querySelector(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let type = target.getAttribute('data-pdf-annotate-type');\r\n\r\n if (type === 'highlight' || type === 'strikeout') { return; }\r\n\r\n isDragging = true;\r\n dragOffsetX = e.clientX;\r\n dragOffsetY = e.clientY;\r\n dragStartX = overlay.offsetLeft;\r\n dragStartY = overlay.offsetTop;\r\n\r\n overlay.style.background = 'rgba(255, 255, 255, 0.7)';\r\n overlay.style.cursor = 'move';\r\n overlay.querySelector('a').style.display = 'none';\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let parentNode = overlay.parentNode;\r\n let rect = parentNode.getBoundingClientRect();\r\n let y = (dragStartY + (e.clientY - dragOffsetY));\r\n let x = (dragStartX + (e.clientX - dragOffsetX));\r\n let minY = 0;\r\n let maxY = rect.height;\r\n let minX = 0;\r\n let maxX = rect.width;\r\n\r\n if (y > minY && y + overlay.offsetHeight < maxY) {\r\n overlay.style.top = `${y}px`;\r\n }\r\n\r\n if (x > minX && x + overlay.offsetWidth < maxX) {\r\n overlay.style.left = `${x}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let target = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let type = target[0].getAttribute('data-pdf-annotate-type');\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n overlay.querySelector('a').style.display = '';\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\r\n let attribX = 'x';\r\n let attribY = 'y';\r\n if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\r\n attribX = 'cx';\r\n attribY = 'cy';\r\n }\r\n\r\n if (type === 'point') {\r\n // Broken\r\n /*\r\n [...target].forEach((t, i) => {\r\n let moveTo = {\r\n x: overlay.offsetLeft + 3,\r\n y: overlay.offsetTop + 3\r\n };\r\n t.setAttribute(attribX, moveTo.x);\r\n t.setAttribute(attribY, moveTo.y);\r\n annotation[attribX] = moveTo.x;\r\n annotation[attribY] = moveTo.y;\r\n });\r\n */\r\n return;\r\n }\r\n else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\r\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\r\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\r\n let modelDelta = {\r\n x: modelEnd[0] - modelStart[0],\r\n y: modelEnd[1] - modelStart[1]\r\n };\r\n\r\n if (type === 'textbox') {\r\n target = [target[0].firstChild];\r\n }\r\n\r\n [...target].forEach((t, i) => {\r\n let modelX = parseInt(t.getAttribute(attribX), 10);\r\n let modelY = parseInt(t.getAttribute(attribY), 10);\r\n if (modelDelta.y !== 0) {\r\n modelY = modelY + modelDelta.y;\r\n\r\n t.setAttribute(attribY, modelY);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].y = modelY;\r\n }\r\n else if (annotation[attribY]) {\r\n annotation[attribY] = modelY;\r\n }\r\n }\r\n if (modelDelta.x !== 0) {\r\n modelX = modelX + modelDelta.x;\r\n\r\n t.setAttribute(attribX, modelX);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].x = modelX;\r\n }\r\n else if (annotation[attribX]) {\r\n annotation[attribX] = modelX;\r\n }\r\n }\r\n });\r\n }\r\n else if (type === 'strikeout') {\r\n return;\r\n // let { deltaX, deltaY } = getDelta('x1', 'y1');\r\n // [...target].forEach(target, (t, i) => {\r\n // if (deltaY !== 0) {\r\n // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY);\r\n // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY);\r\n // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10);\r\n // }\r\n // if (deltaX !== 0) {\r\n // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX);\r\n // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX);\r\n // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10);\r\n // }\r\n // });\r\n }\r\n else if (type === 'drawing' || type === 'arrow') {\r\n // Do nothing as currently broken\r\n /*\r\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\r\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\r\n let modelDelta = {\r\n x: modelEnd[0] - modelStart[0],\r\n y: modelEnd[1] - modelStart[1]\r\n };\r\n\r\n annotation.lines.forEach((line, i) => {\r\n let [x, y] = annotation.lines[i];\r\n annotation.lines[i][0] = x + modelDelta.x;\r\n annotation.lines[i][1] = y + modelDelta.y;\r\n });\r\n\r\n target[0].parentNode.removeChild(target[0]);\r\n appendChild(svg, annotation);\r\n */\r\n return;\r\n }\r\n\r\n PDFJSAnnotate.getStoreAdapter().editAnnotation(documentId, annotationId, annotation);\r\n });\r\n\r\n setTimeout(() => {\r\n isDragging = false;\r\n }, 0);\r\n\r\n overlay.style.background = '';\r\n overlay.style.cursor = '';\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n enableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle annotation.click event\r\n *\r\n * @param {Element} e The annotation element that was clicked\r\n */\r\nfunction handleAnnotationClick(target) {\r\n createEditOverlay(target);\r\n}\r\n\r\n/**\r\n * Enable edit mode behavior.\r\n */\r\nexport function enableEdit() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n addEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n/**\r\n * Disable edit mode behavior.\r\n */\r\nexport function disableEdit() {\r\n destroyEditOverlay();\r\n\r\n if (!_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = false;\r\n removeEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _candraw = false;\r\nlet _penSize;\r\nlet _penColor;\r\nlet path;\r\nlet lines = [];\r\n\r\n/**\r\n * Handle document.touchdown or document.pointerdown event\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerdown(e) {\r\n path = null;\r\n lines = [];\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n _candraw = true;\r\n e.preventDefault();\r\n}\r\n\r\n/**\r\n * Handle document.pointerup event\r\n *\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerup(e) {\r\n saveToStorage(e.clientX, e.clientY);\r\n}\r\n\r\nfunction saveToStorage(x, y) {\r\n if (!_candraw) {\r\n return;\r\n }\r\n _candraw = false;\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\r\n type: 'drawing',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }).then((annotation) => {\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointermove(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY) || !_candraw) {\r\n return;\r\n }\r\n savePoint(e.clientX, e.clientY);\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {KeyboardEvent} e The DOM event to be handled\r\n * } e The DOM event to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n lines = null;\r\n path.parentNode.removeChild(path);\r\n document.removeEventListener('pointermove', handleDocumentPointermove);\r\n document.removeEventListener('pointerup', handleDocumentPointerup);\r\n }\r\n}\r\n\r\n/**\r\n * Save a point to the line being drawn.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n */\r\nfunction savePoint(x, y) {\r\n let svg = findSVGAtPoint(x, y);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let point = convertToSvgPoint([\r\n x - rect.left,\r\n y - rect.top\r\n ], svg);\r\n point[0] = point[0].toFixed(2);\r\n point[1] = point[1].toFixed(2);\r\n lines.push(point);\r\n\r\n if (lines.length <= 1) {\r\n return;\r\n }\r\n\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n path = appendChild(svg, {\r\n type: 'drawing',\r\n color: _penColor,\r\n width: _penSize,\r\n lines\r\n });\r\n}\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} penSize The size of the lines drawn by the pen, rounded to 2 decimal places\r\n * @param {String} penColor The color of the lines drawn by the pen\r\n */\r\nexport function setPen(penSize = 1, penColor = '000000') {\r\n _penSize = Math.round(parseFloat(penSize) * 1e2) / 1e2;\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Return pen attributes of the pen\r\n *\r\n * @return {Object} Object with size and color\r\n */\r\nexport function getPen() {\r\n return {\r\n size: _penSize,\r\n color: _penColor\r\n };\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enablePen() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n // Chrome and Firefox has different behaviors with how pen works, so we need different events.\r\n document.addEventListener('pointerdown', handleDocumentPointerdown);\r\n document.addEventListener('pointermove', handleDocumentPointermove);\r\n document.addEventListener('pointerup', handleDocumentPointerup);\r\n\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Disable the pen behavior\r\n */\r\nexport function disablePen() {\r\n if (!_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = false;\r\n document.removeEventListener('pointerdown', handleDocumentPointerdown);\r\n document.removeEventListener('pointermove', handleDocumentPointermove);\r\n document.removeEventListener('pointerup', handleDocumentPointerup);\r\n\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n enableUserSelect();\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n findSVGContainer,\r\n getMetadata,\r\n convertToSvgPoint,\r\n convertToScreenPoint,\r\n findAnnotationAtPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _penSize;\r\nlet _penColor;\r\nlet path;\r\nlet lines;\r\nlet originY;\r\nlet originX;\r\n\r\n/**\r\n * Handle document.mousedown event\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n if (target === null) {\r\n return;\r\n }\r\n\r\n let type = target.getAttribute('data-pdf-annotate-type');\r\n if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') {\r\n return;\r\n }\r\n\r\n let svg = findSVGContainer(target);\r\n let { documentId } = getMetadata(svg);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\r\n if (annotation) {\r\n path = null;\r\n lines = [];\r\n\r\n let point = convertToScreenPoint([\r\n annotation.cx,\r\n annotation.cy\r\n ], svg);\r\n\r\n let rect = svg.getBoundingClientRect();\r\n\r\n originX = point[0] + rect.left;\r\n originY = point[1] + rect.top;\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(e.clientX, e.clientY))) {\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\r\n type: 'arrow',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }).then((annotation) => {\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let x = lines.length === 0 ? originX : e.clientX;\r\n let y = lines.length === 0 ? originY : e.clientY;\r\n\r\n savePoint(x, y);\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n lines = null;\r\n path.parentNode.removeChild(path);\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n }\r\n}\r\n\r\n/**\r\n * Save a point to the line being drawn.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n */\r\nfunction savePoint(x, y) {\r\n let svg = findSVGAtPoint(x, y);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let point = convertToSvgPoint([\r\n x - rect.left,\r\n y - rect.top\r\n ], svg);\r\n\r\n if (lines.length < 2) {\r\n lines.push(point);\r\n return;\r\n }\r\n else {\r\n lines[1] = point; // update end point\r\n }\r\n\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n path = appendChild(svg, {\r\n type: 'arrow',\r\n color: _penColor,\r\n width: _penSize,\r\n lines\r\n });\r\n}\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} penSize The size of the lines drawn by the pen\r\n * @param {String} penColor The color of the lines drawn by the pen\r\n */\r\nexport function setArrow(penSize = 10, penColor = '0000FF') {\r\n _penSize = parseInt(penSize, 10);\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enableArrow() {\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Disable the pen behavior\r\n */\r\nexport function disableArrow() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n enableUserSelect();\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport {\r\n findAnnotationAtPoint,\r\n getMetadata\r\n} from './utils';\r\n\r\nlet _canerase = false;\r\nlet previousPoint = null;\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentDown(e) {\r\n _canerase = true;\r\n previousPoint = [e.clientX, e.clientY];\r\n}\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentUp(e) {\r\n _canerase = false;\r\n erase(findAnnotationAtPoint(e.clientX, e.clientY));\r\n}\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentMouseMove(e) {\r\n if (!_canerase) {\r\n return;\r\n }\r\n\r\n // This algorithm attempts to get the various points between the last\r\n // PointerEvent and this one\r\n let check = [];\r\n let diffX = Math.abs(previousPoint[0] - e.clientX);\r\n let diffY = Math.abs(previousPoint[1] - e.clientY);\r\n if (diffX >= 1 || diffY >= 1) {\r\n let maxSteps = Math.round(Math.max(diffX, diffY));\r\n let subStepSize = Math.min(diffX, diffY) / maxSteps;\r\n let smallerTest = diffX < diffY;\r\n let startPoint = [\r\n Math.min(previousPoint[0], e.clientX),\r\n Math.min(previousPoint[1], e.clientY)\r\n ];\r\n for (let i = 0; i < maxSteps; i++) {\r\n if (smallerTest) {\r\n check.push([Math.round(startPoint[0] + (subStepSize * i)), Math.round(startPoint[1] + i)]);\r\n }\r\n else {\r\n check.push([Math.round(startPoint[0] + i), Math.round(startPoint[1] + (subStepSize * i))]);\r\n }\r\n }\r\n }\r\n for (let point of check) {\r\n erase(findAnnotationAtPoint(point[0], point[1]));\r\n }\r\n previousPoint = [e.clientX, e.clientY];\r\n}\r\n\r\nfunction erase(target) {\r\n if (!_canerase) {\r\n return;\r\n }\r\n\r\n if (target) {\r\n let { documentId } = getMetadata(target.parentElement);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n });\r\n }\r\n}\r\n\r\nexport function enableEraser() {\r\n document.addEventListener('pointermove', handleDocumentMouseMove);\r\n document.addEventListener('pointerdown', handleDocumentDown);\r\n document.addEventListener('pointerup', handleDocumentUp);\r\n}\r\n\r\nexport function disableEraser() {\r\n document.removeEventListener('pointermove', handleDocumentMouseMove);\r\n document.removeEventListener('pointerdown', handleDocumentDown);\r\n document.removeEventListener('pointerup', handleDocumentUp);\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n findSVGAtPoint,\r\n getMetadata,\r\n scaleDown\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet input;\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} The DOM event to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n\r\n input = document.createElement('input');\r\n input.setAttribute('id', 'pdf-annotate-point-input');\r\n input.setAttribute('placeholder', 'Enter comment');\r\n input.style.border = `3px solid ${BORDER_COLOR}`;\r\n input.style.borderRadius = '3px';\r\n input.style.position = 'absolute';\r\n input.style.top = `${e.clientY}px`;\r\n input.style.left = `${e.clientX}px`;\r\n\r\n input.addEventListener('blur', handleInputBlur);\r\n input.addEventListener('keyup', handleInputKeyup);\r\n\r\n document.body.appendChild(input);\r\n input.focus();\r\n}\r\n\r\n/**\r\n * Handle input.blur event\r\n */\r\nfunction handleInputBlur() {\r\n savePoint();\r\n}\r\n\r\n/**\r\n * Handle input.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleInputKeyup(e) {\r\n if (e.keyCode === 27) {\r\n closeInput();\r\n }\r\n else if (e.keyCode === 13) {\r\n savePoint();\r\n }\r\n}\r\n\r\n/**\r\n * Save a new point annotation from input\r\n */\r\nfunction savePoint() {\r\n if (input.value.trim().length > 0) {\r\n let clientX = parseInt(input.style.left, 10);\r\n let clientY = parseInt(input.style.top, 10);\r\n let content = input.value.trim();\r\n let svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n let annotation = Object.assign({\r\n type: 'point'\r\n }, scaleDown(svg, {\r\n x: clientX - rect.left,\r\n y: clientY - rect.top\r\n }));\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n PDFJSAnnotate.getStoreAdapter().addComment(\r\n documentId,\r\n annotation.uuid,\r\n content\r\n );\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n closeInput();\r\n}\r\n\r\n/**\r\n * Close the input element\r\n */\r\nfunction closeInput() {\r\n input.removeEventListener('blur', handleInputBlur);\r\n input.removeEventListener('keyup', handleInputKeyup);\r\n document.body.removeChild(input);\r\n input = null;\r\n}\r\n\r\n/**\r\n * Enable point annotation behavior\r\n */\r\nexport function enablePoint() {\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable point annotation behavior\r\n */\r\nexport function disablePoint() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgRect\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _type;\r\nlet overlay;\r\nlet originY;\r\nlet originX;\r\n\r\n/**\r\n * Get the current window selection as rects\r\n *\r\n * @return {Array} An Array of rects\r\n */\r\nfunction getSelectionRects() {\r\n try {\r\n let selection = window.getSelection();\r\n let range = selection.getRangeAt(0);\r\n let rects = range.getClientRects();\r\n\r\n if (rects.length > 0 &&\r\n rects[0].width > 0 &&\r\n rects[0].height > 0) {\r\n return rects;\r\n }\r\n }\r\n catch (e) {}\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Handle document.mousedown event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n let svg;\r\n if (_type !== 'area' || !(svg = findSVGAtPoint(e.clientX, e.clientY))) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n originY = e.clientY;\r\n originX = e.clientX;\r\n\r\n overlay = document.createElement('div');\r\n overlay.style.position = 'absolute';\r\n overlay.style.top = `${originY - rect.top}px`;\r\n overlay.style.left = `${originX - rect.left}px`;\r\n overlay.style.border = `3px solid ${BORDER_COLOR}`;\r\n overlay.style.borderRadius = '3px';\r\n svg.parentNode.appendChild(overlay);\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let rect = svg.getBoundingClientRect();\r\n\r\n if (originX + (e.clientX - originX) < rect.right) {\r\n overlay.style.width = `${e.clientX - originX}px`;\r\n }\r\n\r\n if (originY + (e.clientY - originY) < rect.bottom) {\r\n overlay.style.height = `${e.clientY - originY}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let rects;\r\n if (_type !== 'area' && (rects = getSelectionRects())) {\r\n saveRect(_type, [...rects].map((r) => {\r\n return {\r\n top: r.top,\r\n left: r.left,\r\n width: r.width,\r\n height: r.height\r\n };\r\n }));\r\n }\r\n else if (_type === 'area' && overlay) {\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let rect = svg.getBoundingClientRect();\r\n saveRect(_type, [{\r\n top: parseInt(overlay.style.top, 10) + rect.top,\r\n left: parseInt(overlay.style.left, 10) + rect.left,\r\n width: parseInt(overlay.style.width, 10),\r\n height: parseInt(overlay.style.height, 10)\r\n }]);\r\n\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n enableUserSelect();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n let selection = window.getSelection();\r\n selection.removeAllRanges();\r\n if (overlay && overlay.parentNode) {\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Save a rect annotation\r\n *\r\n * @param {String} type The type of rect (area, highlight, strikeout)\r\n * @param {Array} rects The rects to use for annotation\r\n * @param {String} color The color of the rects\r\n */\r\nfunction saveRect(type, rects, color) {\r\n let svg = findSVGAtPoint(rects[0].left, rects[0].top);\r\n let annotation;\r\n\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let boundingRect = svg.getBoundingClientRect();\r\n\r\n if (!color) {\r\n if (type === 'highlight') {\r\n color = 'FFFF00';\r\n }\r\n else if (type === 'strikeout') {\r\n color = 'FF0000';\r\n }\r\n }\r\n\r\n // Initialize the annotation\r\n annotation = {\r\n type,\r\n color,\r\n rectangles: [...rects].map((r) => {\r\n let offset = 0;\r\n\r\n if (type === 'strikeout') {\r\n offset = r.height / 2;\r\n }\r\n\r\n return convertToSvgRect({\r\n y: (r.top + offset) - boundingRect.top,\r\n x: r.left - boundingRect.left,\r\n width: r.width,\r\n height: r.height\r\n }, svg);\r\n }).filter((r) => r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1)\r\n };\r\n\r\n // Short circuit if no rectangles exist\r\n if (annotation.rectangles.length === 0) {\r\n return;\r\n }\r\n\r\n // Special treatment for area as it only supports a single rect\r\n if (type === 'area') {\r\n let rect = annotation.rectangles[0];\r\n delete annotation.rectangles;\r\n annotation.x = rect.x;\r\n annotation.y = rect.y;\r\n annotation.width = rect.width;\r\n annotation.height = rect.height;\r\n }\r\n\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n}\r\n\r\n/**\r\n * Enable rect behavior\r\n */\r\nexport function enableRect(type) {\r\n _type = type;\r\n\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n}\r\n\r\n/**\r\n * Disable rect behavior\r\n */\r\nexport function disableRect() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _type;\r\nlet _circleRadius = 10;\r\nlet _circleColor = '0000FF';\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} circleRadius The radius of the circle\r\n * @param {String} circleColor The color of the circle\r\n */\r\nexport function setCircle(circleRadius = 10, circleColor = '0000FF') {\r\n _circleRadius = parseInt(circleRadius, 10);\r\n _circleColor = circleColor;\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let svg = findSVGAtPoint(e.clientX, e.clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let rect = svg.getBoundingClientRect();\r\n saveCircle(svg, _type, {\r\n x: e.clientX - rect.left,\r\n y: e.clientY - rect.top\r\n }, _circleRadius, _circleColor);\r\n}\r\n\r\n/**\r\n * Save a circle annotation\r\n *\r\n * @param {SVGElement} svg\r\n * @param {String} type The type of circle (circle, emptycircle, fillcircle)\r\n * @param {Object} pt The point to use for annotation\r\n * @param {float} radius\r\n * @param {String} color The color of the rects\r\n */\r\nfunction saveCircle(svg, type, pt, radius, color) {\r\n // Initialize the annotation\r\n let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg);\r\n let annotation = {\r\n type,\r\n color,\r\n cx: svg_pt[0],\r\n cy: svg_pt[1],\r\n r: radius\r\n };\r\n\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n}\r\n\r\n/**\r\n * Enable circle behavior\r\n */\r\nexport function enableCircle(type) {\r\n _type = type;\r\n\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable circle behavior\r\n */\r\nexport function disableCircle() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\nexport function addCircle(type, e) {\r\n let oldType = _type;\r\n _type = type;\r\n handleDocumentMouseup(e);\r\n _type = oldType;\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet input;\r\nlet _textSize = localStorage.getItem(`text/size`) || 12;\r\nlet _textColor = localStorage.getItem(`text/color`) || '#000000';\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n if (!e.srcElement.classList.contains('annotationLayer')) {\r\n return;\r\n }\r\n input = document.createElement('textarea');\r\n input.setAttribute('id', 'pdf-annotate-text-input');\r\n input.setAttribute('placeholder', 'Enter text... SHIFT + ENTER for new line');\r\n input.style.border = `3px solid ${BORDER_COLOR}`;\r\n input.style.borderRadius = '3px';\r\n input.style.position = 'fixed';\r\n input.style.top = `${e.clientY}px`;\r\n input.style.left = `${e.clientX}px`;\r\n input.style.fontSize = `${_textSize}px`;\r\n input.style.zIndex = '41';\r\n input.addEventListener('blur', handleInputBlur);\r\n input.addEventListener('keyup', handleInputKeyup);\r\n\r\n document.body.appendChild(input);\r\n input.focus();\r\n}\r\n\r\n/**\r\n * Handle input.blur event\r\n */\r\nfunction handleInputBlur() {\r\n saveText();\r\n}\r\n\r\n/**\r\n * Handle input.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleInputKeyup(e) {\r\n if (e.keyCode === 27) {\r\n closeInput();\r\n }\r\n else if (e.keyCode === 13 && !e.shiftKey) {\r\n saveText();\r\n }\r\n}\r\n\r\n/**\r\n * Save a text annotation from input\r\n */\r\nfunction saveText() {\r\n let value = (input.value) ? input.value.replace(/ +$/, '') : '';\r\n if (value.length > 0) {\r\n let clientX = parseInt(input.style.left, 10);\r\n let clientY = parseInt(input.style.top, 10);\r\n let svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let height = _textSize;\r\n let { documentId, pageNumber, viewport } = getMetadata(svg);\r\n let scale = 1 / viewport.scale;\r\n let rect = svg.getBoundingClientRect();\r\n let pt = convertToSvgPoint([\r\n clientX - rect.left,\r\n clientY - rect.top + height], svg, viewport);\r\n let annotation = {\r\n type: 'textbox',\r\n size: _textSize * scale,\r\n color: _textColor,\r\n content: value,\r\n x: pt[0],\r\n y: pt[1],\r\n rotation: -viewport.rotation\r\n };\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n closeInput();\r\n}\r\n\r\n/**\r\n * Close the input\r\n */\r\nfunction closeInput() {\r\n if (input) {\r\n input.removeEventListener('blur', handleInputBlur);\r\n input.removeEventListener('keyup', handleInputKeyup);\r\n document.body.removeChild(input);\r\n input = null;\r\n }\r\n}\r\n\r\n/**\r\n * Set the text attributes\r\n *\r\n * @param {Number} textSize The size of the text\r\n * @param {String} textColor The color of the text\r\n */\r\nexport function setText(textSize = 12, textColor = '000000') {\r\n _textSize = parseInt(textSize, 10);\r\n _textColor = textColor;\r\n}\r\n\r\n/**\r\n * Enable text behavior\r\n */\r\nexport function enableText() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable text behavior\r\n */\r\nexport function disableText() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n","/**\r\n * Create a node that is only visible to screen readers\r\n *\r\n * @param {String} content The text content that should be read by screen reader\r\n * @param {String} [annotationId] The ID of the annotation assocaited\r\n * @return {Element} An Element that is only visible to screen readers\r\n */\r\nexport default function createScreenReaderOnly(content, annotationId) {\r\n let node = document.createElement('div');\r\n let text = document.createTextNode(content);\r\n node.appendChild(text);\r\n node.setAttribute('id', `pdf-annotate-screenreader-${annotationId}`);\r\n node.style.position = 'absolute';\r\n node.style.left = '-10000px';\r\n node.style.top = 'auto';\r\n node.style.width = '1px';\r\n node.style.height = '1px';\r\n node.style.overflow = 'hidden';\r\n return node;\r\n}\r\n","import config from '../config';\r\nimport {\r\n pointIntersectsRect,\r\n scaleUp,\r\n scaleDown\r\n} from '../UI/utils';\r\n\r\n/**\r\n * Insert an element at a point within the document.\r\n * This algorithm will only insert within an element amidst it's text content.\r\n *\r\n * @param {Element} el The element to be inserted\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page number to limit elements to\r\n * @param {Boolean} insertBefore Whether the element is to be inserted before or after x\r\n * @return {Boolean} True if element was able to be inserted, otherwise false\r\n */\r\nexport default function insertElementWithinElement(el, x, y, pageNumber, insertBefore) {\r\n const OFFSET_ADJUST = 2;\r\n\r\n // If inserting before adjust `x` by looking for element a few px to the right\r\n // Otherwise adjust a few px to the left\r\n // This is to allow a little tolerance by searching within the box, instead\r\n // of getting a false negative by testing right on the border.\r\n x = Math.max(x + (OFFSET_ADJUST * (insertBefore ? 1 : -1)), 0);\r\n\r\n let node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber);\r\n if (!node) {\r\n return false;\r\n }\r\n\r\n // Now that node has been found inverse the adjustment for `x`.\r\n // This is done to accomodate tolerance by cutting off on the outside of the\r\n // text boundary, instead of missing a character by cutting off within.\r\n x = x + (OFFSET_ADJUST * (insertBefore ? -1 : 1));\r\n\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let left = scaleDown(svg, {left: node.getBoundingClientRect().left}).left - svg.getBoundingClientRect().left;\r\n let temp = node.cloneNode(true);\r\n let head = temp.innerHTML.split('');\r\n let tail = [];\r\n\r\n // Insert temp off screen\r\n temp.style.position = 'absolute';\r\n temp.style.top = '-10000px';\r\n temp.style.left = '-10000px';\r\n document.body.appendChild(temp);\r\n\r\n while (head.length) {\r\n // Don't insert within HTML tags\r\n if (head[head.length - 1] === '>') {\r\n while (head.length) {\r\n tail.unshift(head.pop());\r\n if (tail[0] === '<') {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // Check if width of temp based on current head value satisfies x\r\n temp.innerHTML = head.join('');\r\n let width = scaleDown(svg, {width: temp.getBoundingClientRect().width}).width;\r\n if (left + width <= x) {\r\n break;\r\n }\r\n tail.unshift(head.pop());\r\n }\r\n\r\n // Update original node with new markup, including element to be inserted\r\n node.innerHTML = head.join('') + el.outerHTML + tail.join('');\r\n temp.parentNode.removeChild(temp);\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Get a text layer element at a given point on a page\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page to limit elements to\r\n * @return {Element} First text layer element found at the point\r\n */\r\nfunction textLayerElementFromPoint(x, y, pageNumber) {\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let rect = svg.getBoundingClientRect();\r\n y = scaleUp(svg, {y}).y + rect.top;\r\n x = scaleUp(svg, {x}).x + rect.left;\r\n return [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' [data-canvas-width]')].filter((el) => {\r\n return pointIntersectsRect(x, y, el.getBoundingClientRect());\r\n })[0];\r\n}\r\n","import config from '../config';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport { pointIntersectsRect, scaleUp } from '../UI/utils';\r\n\r\n/**\r\n * Insert an element at a point within the document.\r\n * This algorithm will try to insert between elements if possible.\r\n * It will however use `insertElementWithinElement` if it is more accurate.\r\n *\r\n * @param {Element} el The element to be inserted\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page number to limit elements to\r\n * @return {Boolean} True if element was able to be inserted, otherwise false\r\n */\r\nexport default function insertElementWithinChildren(el, x, y, pageNumber) {\r\n // Try and use most accurate method of inserting within an element\r\n if (insertElementWithinElement(el, x, y, pageNumber, true)) {\r\n return true;\r\n }\r\n\r\n // Fall back to inserting between elements\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let rect = svg.getBoundingClientRect();\r\n let nodes = [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' > div')];\r\n\r\n y = scaleUp(svg, {y}).y + rect.top;\r\n x = scaleUp(svg, {x}).x + rect.left;\r\n\r\n // Find the best node to insert before\r\n for (let i = 0, l = nodes.length; i < l; i++) {\r\n let n = nodes[i];\r\n let r = n.getBoundingClientRect();\r\n if (y <= r.top) {\r\n n.parentNode.insertBefore(el, n);\r\n return true;\r\n }\r\n }\r\n\r\n // If all else fails try to append to the bottom\r\n let textLayer = svg.parentNode.querySelector(config.textClassQuery());\r\n if (textLayer) {\r\n let textRect = textLayer.getBoundingClientRect();\r\n if (pointIntersectsRect(x, y, textRect)) {\r\n textLayer.appendChild(el);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n","/**\r\n * Insert a comment into the DOM to be available by screen reader\r\n *\r\n * @param {Object} comment The comment to be inserted\r\n */\r\nexport default function insertScreenReaderComment(comment) {\r\n if (!comment) {\r\n return;\r\n }\r\n\r\n let list = document.querySelector(`#pdf-annotate-screenreader-${comment.annotation} ol`);\r\n if (list) {\r\n let item = document.createElement('li');\r\n item.setAttribute('id', `pdf-annotate-screenreader-comment-${comment.uuid}`);\r\n item.appendChild(document.createTextNode(`${comment.content}`));\r\n list.appendChild(item);\r\n }\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport insertScreenReaderComment from './insertScreenReaderComment';\r\n\r\n/**\r\n * Insert the comments into the DOM to be available by screen reader\r\n *\r\n * Example output:\r\n *
\r\n *
Begin highlight 1
\r\n *
    \r\n *
  1. Foo
  2. \r\n *
  3. Bar
  4. \r\n *
  5. Baz
  6. \r\n *
  7. Qux
  8. \r\n *
\r\n *
\r\n *
Some highlighted text goes here...
\r\n *
End highlight 1
\r\n *\r\n * NOTE: `screenReaderOnly` is not a real class, just used for brevity\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The ID of the annotation\r\n * @param {Array} [comments] Optionally preloaded comments to be rendered\r\n * @return {Promise} Promise that once has comments, render them for screen reader\r\n */\r\nexport default function renderScreenReaderComments(documentId, annotationId, comments) {\r\n let promise;\r\n\r\n if (Array.isArray(comments)) {\r\n promise = Promise.resolve(comments);\r\n }\r\n else {\r\n promise = PDFJSAnnotate.getStoreAdapter().getComments(documentId, annotationId);\r\n }\r\n\r\n return promise.then((comments) => {\r\n // Node needs to be found by querying DOM as it may have been inserted as innerHTML\r\n // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`).\r\n let node = document.getElementById(`pdf-annotate-screenreader-${annotationId}`);\r\n if (node) {\r\n let list = document.createElement('ol');\r\n list.setAttribute('id', `pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n list.setAttribute('aria-label', 'Comments');\r\n node.appendChild(list);\r\n comments.forEach(insertScreenReaderComment);\r\n }\r\n });\r\n}\r\n","import createScreenReaderOnly from './createScreenReaderOnly';\r\nimport insertElementWithinChildren from './insertElementWithinChildren';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport renderScreenReaderComments from './renderScreenReaderComments';\r\n\r\n// Annotation types that support comments\r\nconst COMMENT_TYPES = ['highlight', 'point', 'area', 'circle', 'emptycircle', 'fillcircle'];\r\n\r\n/**\r\n * Insert a hint into the DOM for screen readers for a specific annotation.\r\n *\r\n * @param {Object} annotation The annotation to insert a hint for\r\n * @param {Number} num The number of the annotation out of all annotations of the same type\r\n */\r\nexport default function insertScreenReaderHint(annotation, num = 0) {\r\n switch (annotation.type) {\r\n case 'highlight':\r\n case 'strikeout':\r\n let rects = annotation.rectangles;\r\n let first = rects[0];\r\n let last = rects[rects.length - 1];\r\n\r\n insertElementWithinElement(\r\n createScreenReaderOnly(`Begin ${annotation.type} annotation ${num}`, annotation.uuid),\r\n first.x, first.y, annotation.page, true\r\n );\r\n\r\n insertElementWithinElement(\r\n createScreenReaderOnly(`End ${annotation.type} annotation ${num}`, `${annotation.uuid}-end`),\r\n last.x + last.width, last.y, annotation.page, false\r\n );\r\n break;\r\n\r\n case 'textbox':\r\n case 'point':\r\n let text = annotation.type === 'textbox' ? ` (content: ${annotation.content})` : '';\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`${annotation.type} annotation ${num}${text}`, annotation.uuid),\r\n annotation.x, annotation.y, annotation.page\r\n );\r\n break;\r\n\r\n case 'drawing':\r\n case 'area':\r\n let x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0];\r\n let y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1];\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\r\n x, y, annotation.page\r\n );\r\n break;\r\n\r\n case 'circle':\r\n case 'fillcircle':\r\n case 'emptycircle':\r\n let x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0];\r\n let y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1];\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\r\n x2, y2, annotation.page\r\n );\r\n break;\r\n }\r\n\r\n // Include comments in screen reader hint\r\n if (COMMENT_TYPES.includes(annotation.type)) {\r\n renderScreenReaderComments(annotation.documentId, annotation.uuid);\r\n }\r\n}\r\n","import renderScreenReaderHints from './renderScreenReaderHints';\r\nimport insertScreenReaderComment from './insertScreenReaderComment';\r\nimport renderScreenReaderComments from './renderScreenReaderComments';\r\nimport { addEventListener } from '../UI/event';\r\nimport PDFJSAnnotate from '../PDFJSAnnotate';\r\n\r\n/**\r\n * Initialize the event handlers for keeping screen reader hints synced with data\r\n */\r\nexport default function initEventHandlers() {\r\n addEventListener('annotation:add', (documentId, pageNumber, annotation) => {\r\n reorderAnnotationsByType(documentId, pageNumber, annotation.type);\r\n });\r\n addEventListener('annotation:edit', (documentId, annotationId, annotation) => {\r\n reorderAnnotationsByType(documentId, annotation.page, annotation.type);\r\n });\r\n addEventListener('annotation:delete', removeAnnotation);\r\n addEventListener('comment:add', insertComment);\r\n addEventListener('comment:delete', removeComment);\r\n}\r\n\r\n/**\r\n * Reorder the annotation numbers by annotation type\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {Number} pageNumber The page number of the annotations\r\n * @param {Strig} type The annotation type\r\n */\r\nfunction reorderAnnotationsByType(documentId, pageNumber, type) {\r\n PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, pageNumber)\r\n .then((annotations) => {\r\n return annotations.annotations.filter((a) => {\r\n return a.type === type;\r\n });\r\n })\r\n .then((annotations) => {\r\n annotations.forEach((a) => {\r\n removeAnnotation(documentId, a.uuid);\r\n });\r\n\r\n return annotations;\r\n })\r\n .then(renderScreenReaderHints);\r\n}\r\n\r\n/**\r\n * Remove the screen reader hint for an annotation\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The Id of the annotation\r\n */\r\nfunction removeAnnotation(documentId, annotationId) {\r\n removeElementById(`pdf-annotate-screenreader-${annotationId}`);\r\n removeElementById(`pdf-annotate-screenreader-${annotationId}-end`);\r\n}\r\n\r\n/**\r\n * Insert a screen reader hint for a comment\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The ID of tha assocated annotation\r\n * @param {Object} comment The comment to insert a hint for\r\n */\r\nfunction insertComment(documentId, annotationId, comment) {\r\n let list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n let promise;\r\n\r\n if (!list) {\r\n promise = renderScreenReaderComments(documentId, annotationId, []).then(() => {\r\n list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n return true;\r\n });\r\n }\r\n else {\r\n promise = Promise.resolve(true);\r\n }\r\n\r\n promise.then(() => {\r\n insertScreenReaderComment(comment);\r\n });\r\n}\r\n\r\n/**\r\n * Remove a screen reader hint for a comment\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} commentId The ID of the comment\r\n */\r\nfunction removeComment(documentId, commentId) {\r\n removeElementById(`pdf-annotate-screenreader-comment-${commentId}`);\r\n}\r\n\r\n/**\r\n * Remove an element from the DOM by it's ID if it exists\r\n *\r\n * @param {String} elementId The ID of the element to be removed\r\n */\r\nfunction removeElementById(elementId) {\r\n let el = document.getElementById(elementId);\r\n if (el) {\r\n el.parentNode.removeChild(el);\r\n }\r\n}\r\n","import insertScreenReaderHint from './insertScreenReaderHint';\r\nimport initEventHandlers from './initEventHandlers';\r\n\r\n// TODO This is not the right place for this to live\r\ninitEventHandlers();\r\n\r\n/**\r\n * Insert hints into the DOM for screen readers.\r\n *\r\n * @param {Array} annotations The annotations that hints are inserted for\r\n */\r\nexport default function renderScreenReaderHints(annotations) {\r\n annotations = Array.isArray(annotations) ? annotations : [];\r\n\r\n // Insert hints for each type\r\n Object.keys(SORT_TYPES).forEach((type) => {\r\n let sortBy = SORT_TYPES[type];\r\n annotations\r\n .filter((a) => a.type === type)\r\n .sort(sortBy)\r\n .forEach((a, i) => insertScreenReaderHint(a, i + 1));\r\n });\r\n}\r\n\r\n// Sort annotations first by y, then by x.\r\n// This allows hints to be injected in the order they appear,\r\n// which makes numbering them easier.\r\nfunction sortByPoint(a, b) {\r\n if (a.y < b.y) {\r\n return a.x - b.x;\r\n }\r\n else {\r\n return 1;\r\n }\r\n}\r\n\r\n// Sort annotation by it's first rectangle\r\nfunction sortByRectPoint(a, b) {\r\n return sortByPoint(a.rectangles[0], b.rectangles[0]);\r\n}\r\n\r\n// Sort annotation by it's first line\r\nfunction sortByLinePoint(a, b) {\r\n let lineA = a.lines[0];\r\n let lineB = b.lines[0];\r\n return sortByPoint(\r\n {x: lineA[0], y: lineA[1]},\r\n {x: lineB[0], y: lineB[1]}\r\n );\r\n}\r\n\r\n// Arrange supported types and associated sort methods\r\nconst SORT_TYPES = {\r\n 'highlight': sortByRectPoint,\r\n 'strikeout': sortByRectPoint,\r\n 'drawing': sortByLinePoint,\r\n 'textbox': sortByPoint,\r\n 'point': sortByPoint,\r\n 'area': sortByPoint\r\n};\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport renderScreenReaderHints from '../a11y/renderScreenReaderHints';\r\n\r\n// Template for creating a new page\r\nconst PAGE_TEMPLATE = `\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n`;\r\n\r\n/**\r\n * Create a new page to be appended to the DOM.\r\n *\r\n * @param {Number} pageNumber The page number that is being created\r\n * @return {HTMLElement}\r\n */\r\nexport function createPage(pageNumber) {\r\n let temp = document.createElement('div');\r\n temp.innerHTML = PAGE_TEMPLATE;\r\n\r\n let page = temp.children[0];\r\n let canvas = page.querySelector('canvas');\r\n\r\n page.setAttribute('id', `pageContainer${pageNumber}`);\r\n page.setAttribute('data-page-number', pageNumber);\r\n\r\n canvas.mozOpaque = true;\r\n canvas.setAttribute('id', `page${pageNumber}`);\r\n\r\n return page;\r\n}\r\n\r\n/**\r\n * Render a page that has already been created.\r\n *\r\n * @param {Number} pageNumber The page number to be rendered\r\n * @param {Object} renderOptions The options for rendering\r\n * @return {Promise} Settled once rendering has completed\r\n * A settled Promise will be either:\r\n * - fulfilled: [pdfPage, annotations]\r\n * - rejected: Error\r\n */\r\nexport function renderPage(pageNumber, renderOptions) {\r\n let {\r\n documentId,\r\n pdfDocument,\r\n scale,\r\n rotate\r\n } = renderOptions;\r\n\r\n const eventBus = new pdfjsViewer.EventBus();\r\n\r\n // Load the page and annotations\r\n return Promise.all([\r\n pdfDocument.getPage(pageNumber),\r\n PDFJSAnnotate.getAnnotations(documentId, pageNumber)\r\n ]).then(([pdfPage, annotations]) => {\r\n let page = document.getElementById(`pageContainer${pageNumber}`);\r\n let svg = page.querySelector(config.annotationClassQuery());\r\n let canvas = page.querySelector('.canvasWrapper canvas');\r\n let canvasContext = canvas.getContext('2d', {alpha: false});\r\n let totalRotation = (rotate + pdfPage.rotate) % 360;\r\n let viewport = pdfPage.getViewport({scale: scale, rotation: totalRotation});\r\n let transform = scalePage(pageNumber, viewport, canvasContext);\r\n\r\n // Render the page\r\n return Promise.all([\r\n pdfPage.render({ canvasContext, viewport, transform }).promise,\r\n PDFJSAnnotate.render(svg, viewport, annotations)\r\n ]).then(() => {\r\n // Text content is needed for a11y, but is also necessary for creating\r\n // highlight and strikeout annotations which require selecting text.\r\n return pdfPage.getTextContent({normalizeWhitespace: true}).then((textContent) => {\r\n return new Promise((resolve, reject) => {\r\n // Render text layer for a11y of text content\r\n let textLayer = page.querySelector(config.textClassQuery());\r\n let textLayerFactory = new pdfjsViewer.DefaultTextLayerFactory();\r\n let textLayerBuilder = textLayerFactory.createTextLayerBuilder(\r\n textLayer,\r\n pageNumber - 1,\r\n viewport,\r\n false,\r\n eventBus\r\n );\r\n textLayerBuilder.setTextContent(textContent);\r\n textLayerBuilder.render();\r\n\r\n // Enable a11y for annotations\r\n // Timeout is needed to wait for `textLayerBuilder.render`\r\n setTimeout(() => {\r\n try {\r\n renderScreenReaderHints(annotations.annotations);\r\n resolve();\r\n }\r\n catch (e) {\r\n reject(e);\r\n }\r\n });\r\n });\r\n });\r\n }).then(() => {\r\n // Indicate that the page was loaded\r\n page.setAttribute('data-loaded', 'true');\r\n\r\n return [pdfPage, annotations];\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Scale the elements of a page.\r\n *\r\n * @param {Number} pageNumber The page number to be scaled\r\n * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate))\r\n * @param {Object} context The canvas context that the PDF page is rendered to\r\n * @return {Array} The transform data for rendering the PDF page\r\n */\r\nfunction scalePage(pageNumber, viewport, context) {\r\n let page = document.getElementById(`pageContainer${pageNumber}`);\r\n let canvas = page.querySelector('.canvasWrapper canvas');\r\n let svg = page.querySelector(config.annotationClassQuery());\r\n let wrapper = page.querySelector('.canvasWrapper');\r\n let textLayer = page.querySelector(config.textClassQuery());\r\n let outputScale = getOutputScale(context);\r\n let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];\r\n let sfx = approximateFraction(outputScale.sx);\r\n let sfy = approximateFraction(outputScale.sy);\r\n\r\n // Adjust width/height for scale\r\n page.style.visibility = '';\r\n canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);\r\n canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);\r\n canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';\r\n canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';\r\n svg.setAttribute('width', viewport.width);\r\n svg.setAttribute('height', viewport.height);\r\n svg.style.width = `${viewport.width}px`;\r\n svg.style.height = `${viewport.height}px`;\r\n page.style.width = `${viewport.width}px`;\r\n page.style.height = `${viewport.height}px`;\r\n wrapper.style.width = `${viewport.width}px`;\r\n wrapper.style.height = `${viewport.height}px`;\r\n textLayer.style.width = `${viewport.width}px`;\r\n textLayer.style.height = `${viewport.height}px`;\r\n\r\n return transform;\r\n}\r\n\r\n/**\r\n * Approximates a float number as a fraction using Farey sequence (max order of 8).\r\n *\r\n * @param {Number} x Positive float number\r\n * @return {Array} Estimated fraction: the first array item is a numerator,\r\n * the second one is a denominator.\r\n */\r\nfunction approximateFraction(x) {\r\n // Fast path for int numbers or their inversions.\r\n if (Math.floor(x) === x) {\r\n return [x, 1];\r\n }\r\n\r\n const xinv = 1 / x;\r\n const limit = 8;\r\n if (xinv > limit) {\r\n return [1, limit];\r\n }\r\n else if (Math.floor(xinv) === xinv) {\r\n return [1, xinv];\r\n }\r\n\r\n const x_ = x > 1 ? xinv : x;\r\n\r\n // a/b and c/d are neighbours in Farey sequence.\r\n let a = 0; let b = 1; let c = 1; let d = 1;\r\n\r\n // Limit search to order 8.\r\n while (true) {\r\n // Generating next term in sequence (order of q).\r\n let p = a + c; let q = b + d;\r\n if (q > limit) {\r\n break;\r\n }\r\n if (x_ <= p / q) {\r\n c = p; d = q;\r\n }\r\n else {\r\n a = p; b = q;\r\n }\r\n }\r\n\r\n // Select closest of neighbours to x.\r\n if (x_ - a / b < c / d - x_) {\r\n return x_ === x ? [a, b] : [b, a];\r\n }\r\n else {\r\n return x_ === x ? [c, d] : [d, c];\r\n }\r\n}\r\n\r\nfunction getOutputScale(ctx) {\r\n let devicePixelRatio = window.devicePixelRatio || 1;\r\n let backingStoreRatio = ctx.webkitBackingStorePixelRatio ||\r\n ctx.mozBackingStorePixelRatio ||\r\n ctx.msBackingStorePixelRatio ||\r\n ctx.oBackingStorePixelRatio ||\r\n ctx.backingStorePixelRatio || 1;\r\n let pixelRatio = devicePixelRatio / backingStoreRatio;\r\n return {\r\n sx: pixelRatio,\r\n sy: pixelRatio,\r\n scaled: pixelRatio !== 1\r\n };\r\n}\r\n\r\nfunction roundToDivide(x, div) {\r\n let r = x % div;\r\n return r === 0 ? x : Math.round(x - r + div);\r\n}\r\n","import { addEventListener, removeEventListener, fireEvent } from './event';\r\nimport { disableEdit, enableEdit } from './edit';\r\nimport { disablePen, enablePen, setPen } from './pen';\r\nimport { disableArrow, enableArrow, setArrow } from './arrow';\r\nimport { disableEraser, enableEraser } from './eraser';\r\nimport { disablePoint, enablePoint } from './point';\r\nimport { disableRect, enableRect } from './rect';\r\nimport { disableCircle, enableCircle, setCircle, addCircle } from './circle';\r\nimport { disableText, enableText, setText } from './text';\r\nimport { createPage, renderPage } from './page';\r\n\r\nexport default {\r\n addEventListener,\r\n removeEventListener,\r\n fireEvent,\r\n\r\n disableEdit,\r\n enableEdit,\r\n\r\n disablePen,\r\n enablePen,\r\n setPen,\r\n\r\n disablePoint,\r\n enablePoint,\r\n\r\n disableRect,\r\n enableRect,\r\n\r\n disableCircle,\r\n enableCircle,\r\n setCircle,\r\n addCircle,\r\n\r\n disableArrow,\r\n enableArrow,\r\n setArrow,\r\n\r\n disableEraser,\r\n enableEraser,\r\n\r\n disableText,\r\n enableText,\r\n setText,\r\n\r\n createPage,\r\n renderPage\r\n};\r\n","import StoreAdapter from './adapter/StoreAdapter';\r\nimport LocalStoreAdapter from './adapter/LocalStoreAdapter';\r\nimport LocalUserStoreAdapter from './adapter/LocalUserStoreAdapter';\r\nimport render from './render';\r\nimport UI from './UI';\r\nimport config from './config';\r\nimport uuid from './utils/uuid';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGContainer,\r\n convertToScreenPoint\r\n} from './UI/utils';\r\n\r\nexport default {\r\n findAnnotationAtPoint,\r\n findSVGContainer,\r\n convertToScreenPoint,\r\n\r\n /**\r\n * Abstract class that needs to be defined so PDFJSAnnotate\r\n * knows how to communicate with your server.\r\n */\r\n StoreAdapter,\r\n\r\n /**\r\n * Implementation of StoreAdapter that stores annotation data to localStorage.\r\n */\r\n LocalStoreAdapter,\r\n\r\n /**\r\n * Implementation of StoreAdapter that stores annotation data to localStorage particular\r\n * to a specific user\r\n */\r\n LocalUserStoreAdapter,\r\n\r\n /**\r\n * Abstract instance of StoreAdapter\r\n */\r\n __storeAdapter: new StoreAdapter(),\r\n\r\n /**\r\n * Getter for the underlying StoreAdapter property\r\n *\r\n * @return {StoreAdapter}\r\n */\r\n getStoreAdapter() {\r\n return this.__storeAdapter;\r\n },\r\n\r\n /**\r\n * Setter for the underlying StoreAdapter property\r\n *\r\n * @param {StoreAdapter} adapter The StoreAdapter implementation to be used.\r\n */\r\n setStoreAdapter(adapter) {\r\n // TODO this throws an error when bundled\r\n // if (!(adapter instanceof StoreAdapter)) {\r\n // throw new Error('adapter must be an instance of StoreAdapter');\r\n // }\r\n\r\n this.__storeAdapter = adapter;\r\n },\r\n\r\n /**\r\n * UI is a helper for instrumenting UI interactions for creating,\r\n * editing, and deleting annotations in the browser.\r\n */\r\n UI,\r\n\r\n /**\r\n * Render the annotations for a page in the PDF Document\r\n *\r\n * @param {SVGElement} svg The SVG element that annotations should be rendered to\r\n * @param {PageViewport} viewport The PDFPage.getViewport data\r\n * @param {Object} data The StoreAdapter.getAnnotations data\r\n * @return {Promise}\r\n */\r\n render,\r\n\r\n /**\r\n * Convenience method for getting annotation data\r\n *\r\n * @alias StoreAdapter.getAnnotations\r\n * @param {String} documentId The ID of the document\r\n * @param {String} pageNumber The page number\r\n * @return {Promise}\r\n */\r\n getAnnotations(documentId, pageNumber) {\r\n return this.getStoreAdapter().getAnnotations(...arguments);\r\n },\r\n\r\n config,\r\n\r\n uuid\r\n};\r\n","import { appendChild, transformChild } from './appendChild';\r\n\r\n/**\r\n * Render the response from PDFJSAnnotate.getStoreAdapter().getAnnotations to SVG\r\n *\r\n * @param {SVGElement} svg The SVG element to render the annotations to\r\n * @param {Object} viewport The page viewport data\r\n * @param {Object} data The response from PDFJSAnnotate.getStoreAdapter().getAnnotations\r\n * @return {Promise} Settled once rendering has completed\r\n * A settled Promise will be either:\r\n * - fulfilled: SVGElement\r\n * - rejected: Error\r\n */\r\nexport default function render(svg, viewport, data) {\r\n return new Promise((resolve, reject) => {\r\n // Reset the content of the SVG\r\n svg.setAttribute('data-pdf-annotate-container', true);\r\n svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport));\r\n svg.removeAttribute('data-pdf-annotate-document');\r\n svg.removeAttribute('data-pdf-annotate-page');\r\n\r\n // If there's no data nothing can be done\r\n if (!data) {\r\n svg.innerHTML = '';\r\n return resolve(svg);\r\n }\r\n\r\n svg.setAttribute('data-pdf-annotate-document', data.documentId);\r\n svg.setAttribute('data-pdf-annotate-page', data.pageNumber);\r\n\r\n // Make sure annotations is an array\r\n if (!Array.isArray(data.annotations) || data.annotations.length === 0) {\r\n return resolve(svg);\r\n }\r\n\r\n // Append or transform annotation to svg\r\n data.annotations.forEach((a) => {\r\n let node = svg.querySelector('[data-pdf-annotate-id=\"' + a.uuid + '\"]');\r\n if (node) {\r\n transformChild(svg, node, viewport);\r\n }\r\n else {\r\n appendChild(svg, a, viewport);\r\n }\r\n });\r\n\r\n resolve(svg);\r\n });\r\n}\r\n","import PDFJSAnnotate from './src/PDFJSAnnotate';\r\n\r\nexport default PDFJSAnnotate;\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"pdf-annotate.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,MAAM,I,gCCcT,IAOIC,EAPAC,EAAuB,iBAAZC,QAAuBA,QAAU,KAC5CC,EAAeF,GAAwB,mBAAZA,EAAEG,MAC7BH,EAAEG,MACF,SAAsBC,EAAQC,EAAUC,GACxC,OAAOC,SAASC,UAAUL,MAAMM,KAAKL,EAAQC,EAAUC,EACzD,EAIAP,EADEC,GAA0B,mBAAdA,EAAEU,QACCV,EAAEU,QACVC,OAAOC,sBACC,SAAwBR,GACvC,OAAOO,OAAOE,oBAAoBT,GAC/BU,OAAOH,OAAOC,sBAAsBR,GACzC,EAEiB,SAAwBA,GACvC,OAAOO,OAAOE,oBAAoBT,EACpC,EAOF,IAAIW,EAAcC,OAAOC,OAAS,SAAqBC,GACrD,OAAOA,GAAUA,CACnB,EAEA,SAASC,IACPA,EAAaC,KAAKX,KAAKY,KACzB,CACA1B,EAAOD,QAAUyB,EACjBxB,EAAOD,QAAQ4B,KAwYf,SAAcC,EAASC,GACrB,OAAO,IAAIC,SAAQ,SAAUC,EAASC,GACpC,SAASC,EAAcC,GACrBN,EAAQO,eAAeN,EAAMO,GAC7BJ,EAAOE,EACT,CAEA,SAASE,IAC+B,mBAA3BR,EAAQO,gBACjBP,EAAQO,eAAe,QAASF,GAElCF,EAAQ,GAAGM,MAAMvB,KAAKwB,WACxB,CAEAC,EAA+BX,EAASC,EAAMO,EA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,OAAO/X,KAAK8lB,cACd,EAOAC,gBAAe,SAACC,GAMdhmB,KAAK8lB,eAAiBE,CACxB,EAMAC,GAAAA,GAUAX,OChEa,SAAgBzW,EAAKN,EAAU2X,GAC5C,OAAO,IAAI9lB,SAAQ,SAACC,EAASC,GAQ3B,OANAuO,EAAI1G,aAAa,+BAA+B,GAChD0G,EAAI1G,aAAa,6BAA8BgH,KAAK2G,UAAUvH,IAC9DM,EAAIsX,gBAAgB,8BACpBtX,EAAIsX,gBAAgB,0BAGfD,GAKLrX,EAAI1G,aAAa,6BAA8B+d,EAAKlT,YACpDnE,EAAI1G,aAAa,yBAA0B+d,EAAKjT,YAG3CrP,MAAM0b,QAAQ4G,EAAKtS,cAA4C,IAA5BsS,EAAKtS,YAAYpR,QAKzD0jB,EAAKtS,YAAY1L,SAAQ,SAACpB,GACxB,IAAIkB,EAAO6G,EAAID,cAAc,0BAA4B9H,EAAEsJ,KAAO,MAC9DpI,EACFsI,EAAezB,EAAK7G,EAAMuG,GAG1B/D,EAAYqE,EAAK/H,EAAGyH,EAExB,SAEAlO,EAAQwO,IAdCxO,EAAQwO,KATfA,EAAItE,UAAY,GACTlK,EAAQwO,GAuBnB,GACF,EDuCEgG,eAAc,SAAC7B,EAAYC,GAAY,IAAAmT,EACrC,OAAOA,EAAApmB,KAAK+X,mBAAkBlD,eAAc/V,MAAAsnB,EAAIxlB,UAClD,EAEAiX,OAAAA,GAEAzH,KAAAA,IE3FF,M","sources":["webpack://PDFAnnotate/webpack/universalModuleDefinition","webpack://PDFAnnotate/./node_modules/events/events.js","webpack://PDFAnnotate/webpack/bootstrap","webpack://PDFAnnotate/webpack/runtime/compat get default export","webpack://PDFAnnotate/webpack/runtime/define property getters","webpack://PDFAnnotate/webpack/runtime/hasOwnProperty shorthand","webpack://PDFAnnotate/webpack/runtime/make namespace object","webpack://PDFAnnotate/./src/utils/abstractFunction.js","webpack://PDFAnnotate/./src/utils/setAttributes.js","webpack://PDFAnnotate/./src/utils/normalizeColor.js","webpack://PDFAnnotate/./src/render/renderPoint.js","webpack://PDFAnnotate/./src/render/renderRect.js","webpack://PDFAnnotate/./src/render/renderText.js","webpack://PDFAnnotate/./src/render/renderCircle.js","webpack://PDFAnnotate/./src/utils/mathUtils.js","webpack://PDFAnnotate/./src/render/renderArrow.js","webpack://PDFAnnotate/./src/render/appendChild.js","webpack://PDFAnnotate/./src/render/renderLine.js","webpack://PDFAnnotate/./src/render/renderPath.js","webpack://PDFAnnotate/./src/UI/utils.js","webpack://PDFAnnotate/./src/UI/event.js","webpack://PDFAnnotate/./src/adapter/StoreAdapter.js","webpack://PDFAnnotate/./src/utils/uuid.js","webpack://PDFAnnotate/./src/adapter/LocalStoreAdapter.js","webpack://PDFAnnotate/./src/adapter/LocalUserStoreAdapter.js","webpack://PDFAnnotate/./src/config.js","webpack://PDFAnnotate/./src/UI/edit.js","webpack://PDFAnnotate/./src/UI/pen.js","webpack://PDFAnnotate/./src/UI/arrow.js","webpack://PDFAnnotate/./src/UI/eraser.js","webpack://PDFAnnotate/./src/UI/point.js","webpack://PDFAnnotate/./src/UI/rect.js","webpack://PDFAnnotate/./src/UI/circle.js","webpack://PDFAnnotate/./src/UI/text.js","webpack://PDFAnnotate/./src/a11y/createScreenReaderOnly.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinElement.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinChildren.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderComment.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderComments.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderHint.js","webpack://PDFAnnotate/./src/a11y/initEventHandlers.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderHints.js","webpack://PDFAnnotate/./src/UI/page.js","webpack://PDFAnnotate/./src/UI/index.js","webpack://PDFAnnotate/./src/PDFJSAnnotate.js","webpack://PDFAnnotate/./src/render/index.js","webpack://PDFAnnotate/./index.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PDFAnnotate\"] = factory();\n\telse\n\t\troot[\"PDFAnnotate\"] = factory();\n})(self, () => {\nreturn ","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Throw an Error for an abstract function that hasn't been implemented.\n *\n * @param {String} name The name of the abstract function\n */\nexport default function abstractFunction(name) {\n throw new Error(name + ' is not implemented');\n}\n","const UPPER_REGEX = /[A-Z]/g;\n\n// Don't convert these attributes from camelCase to hyphenated-attributes\nconst BLACKLIST = [\n 'viewBox'\n];\n\nlet keyCase = (key) => {\n if (BLACKLIST.indexOf(key) === -1) {\n key = key.replace(UPPER_REGEX, match => '-' + match.toLowerCase());\n }\n return key;\n};\n\n/**\n * Set attributes for a node from a map\n *\n * @param {Node} node The node to set attributes on\n * @param {Object} attributes The map of key/value pairs to use for attributes\n */\nexport default function setAttributes(node, attributes) {\n Object.keys(attributes).forEach((key) => {\n node.setAttribute(keyCase(key), attributes[key]);\n });\n}\n","const REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i;\n\n/**\n * Normalize a color value\n *\n * @param {String} color The color to normalize\n * @return {String}\n */\nexport default function normalizeColor(color) {\n if (REGEX_HASHLESS_HEX.test(color)) {\n color = `#${color}`;\n }\n return color;\n}\n","import setAttributes from '../utils/setAttributes';\n\nconst SIZE = 25;\nconst D = 'M499.968 214.336q-113.832 0 -212.877 38.781t-157.356 104.625 -58.311 142.29q0 62.496 39.897 119.133t112.437 97.929l48.546 27.9 -15.066 53.568q-13.392 50.778 -39.06 95.976 84.816 -35.154 153.45 -95.418l23.994 -21.204 31.806 3.348q38.502 4.464 72.54 4.464 113.832 0 212.877 -38.781t157.356 -104.625 58.311 -142.29 -58.311 -142.29 -157.356 -104.625 -212.877 -38.781z';\n\n/**\n * Create SVGElement from an annotation definition.\n * This is used for anntations of type `comment`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGElement} A svg to be rendered\n */\nexport default function renderPoint(a) {\n let outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n let innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\n setAttributes(outerSVG, {\n width: SIZE,\n height: SIZE,\n x: a.x,\n y: a.y\n });\n\n setAttributes(innerSVG, {\n width: SIZE,\n height: SIZE,\n x: 0,\n y: (SIZE * 0.05) * -1,\n viewBox: '0 0 1000 1000'\n });\n\n setAttributes(rect, {\n width: SIZE,\n height: SIZE,\n stroke: '#000',\n fill: '#ff0'\n });\n\n setAttributes(path, {\n d: D,\n strokeWidth: 50,\n stroke: '#000',\n fill: '#fff'\n });\n\n innerSVG.appendChild(path);\n outerSVG.appendChild(rect);\n outerSVG.appendChild(innerSVG);\n\n return outerSVG;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGRectElements from an annotation definition.\n * This is used for anntations of type `area` and `highlight`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered\n */\nexport default function renderRect(a) {\n if (a.type === 'highlight') {\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n setAttributes(group, {\n fill: normalizeColor(a.color || '#ff0'),\n fillOpacity: 0.2\n });\n\n a.rectangles.forEach((r) => {\n group.appendChild(createRect(r));\n });\n\n return group;\n }\n else {\n let rect = createRect(a);\n setAttributes(rect, {\n stroke: normalizeColor(a.color || '#f00'),\n fill: 'none'\n });\n\n return rect;\n }\n}\n\nfunction createRect(r) {\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n\n setAttributes(rect, {\n x: r.x,\n y: r.y,\n width: r.width,\n height: r.height\n });\n\n return rect;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Wrap each line of given text in a `` element and append these\n * lines to the given SVGTextElement\n *\n * @param {SVGTextElement} textElement A text element to hold the split text\n * @param {String} textContent String to render with line breaks\n */\nfunction insertLineBreaks(textElement, textContent) {\n const lines = (textContent || '').split('\\n');\n // can't use dy attribute here since we want empty lines to take up space as well,\n // so we will update y manually based on font size\n const x = textElement.getAttribute('x');\n let y = Number(textElement.getAttribute('y'));\n const size = Number(textElement.getAttribute('font-size'));\n for (const line of lines) {\n const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');\n tspan.setAttribute('y', y.toString());\n tspan.setAttribute('x', x);\n tspan.innerHTML = line;\n textElement.appendChild(tspan);\n\n y += size;\n }\n}\n\n/**\n * Create SVGTextElement from an annotation definition.\n * This is used for anntations of type `textbox`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGTextElement} A text to be rendered\n */\nexport default function renderText(a) {\n // Text should be rendered at 0 degrees relative to\n // document rotation\n let text = document.createElementNS('http://www.w3.org/2000/svg', 'text');\n setAttributes(text, {\n x: a.x,\n y: a.y,\n fill: normalizeColor(a.color || '#000'),\n fontSize: a.size,\n transform: `rotate(${a.rotation})`,\n style: 'white-space: pre'\n });\n\n insertLineBreaks(text, a.content);\n\n let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n g.appendChild(text);\n\n return g;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create an SVGCircleElement from an annotation definition.\n * This is used for annotations of type `circle`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement|SVGCircleElement} A circle to be rendered\n */\nexport default function renderCircle(a) {\n let circle = createCircle(a);\n let color = normalizeColor(a.color || '#f00');\n\n if (a.type === 'circle') {\n setAttributes(circle, {\n stroke: color,\n fill: 'none',\n 'stroke-width': 5\n });\n }\n if (a.type === 'emptycircle') {\n setAttributes(circle, {\n stroke: color,\n fill: 'none',\n 'stroke-width': 2\n });\n }\n\n if (a.type === 'fillcircle') {\n setAttributes(circle, {\n stroke: color,\n fill: color,\n 'stroke-width': 5\n });\n }\n\n return circle;\n}\n\nfunction createCircle(a) {\n let circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\n setAttributes(circle, {\n cx: a.cx,\n cy: a.cy,\n r: a.r\n });\n\n return circle;\n}\n","// Transform point by matrix\n//\nexport function applyTransform(p, m) {\n return [\n p[0] * m[0] + p[1] * m[2] + m[4],\n p[0] * m[1] + p[1] * m[3] + m[5]\n ];\n};\n\n// Transform point by matrix inverse\n//\nexport function applyInverseTransform(p, m) {\n let d = m[0] * m[3] - m[1] * m[2];\n return [\n (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d,\n (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d\n ];\n};\n\n// Concatenates two transformation matrices together and returns the result.\nexport function transform(m1, m2) {\n return [\n m1[0] * m2[0] + m1[2] * m2[1],\n m1[1] * m2[0] + m1[3] * m2[1],\n m1[0] * m2[2] + m1[2] * m2[3],\n m1[1] * m2[2] + m1[3] * m2[3],\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5]\n ];\n};\n\nexport function translate(m, x, y) {\n return [\n m[0],\n m[1],\n m[2],\n m[3],\n m[0] * x + m[2] * y + m[4],\n m[1] * x + m[3] * y + m[5]\n ];\n};\n\nexport function rotate(m, angle) {\n angle = angle * Math.PI / 180;\n\n let cosValue = Math.cos(angle);\n let sinValue = Math.sin(angle);\n\n return [\n m[0] * cosValue + m[2] * sinValue,\n m[1] * cosValue + m[3] * sinValue,\n m[0] * (-sinValue) + m[2] * cosValue,\n m[1] * (-sinValue) + m[3] * cosValue,\n m[4],\n m[5]\n ];\n};\n\nexport function scale(m, x, y) {\n return [\n m[0] * x,\n m[1] * x,\n m[2] * y,\n m[3] * y,\n m[4],\n m[5]\n ];\n};\n\nexport function makePoint(x, y, z) {\n return { x: x, y: y, z: z };\n};\n\nexport function makeVector(xcoord, ycoord, zcoord) {\n return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord };\n};\n\nexport function makeVectorFromPoints(pt1, pt2) {\n let xcoord = pt2.x - pt1.x;\n let ycoord = pt2.y - pt1.y;\n let zcoord = pt2.z - pt1.z;\n return makeVector(xcoord, ycoord, zcoord);\n};\n\nexport function addVector(pt, v) {\n return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord);\n};\n\nexport function multiplyVector(v, scalar) {\n return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar);\n};\n\nexport function magnitude(v) {\n return Math.sqrt(\n Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)\n );\n};\n\nexport function negateVector(v) {\n return multiplyVector(v, -1);\n};\n\nexport function unitVector(v) {\n let mag = magnitude(v);\n let xcoord = v.xcoord / mag;\n let ycoord = v.ycoord / mag;\n let zcoord = v.zcoord / mag;\n return makeVector(xcoord, ycoord, zcoord);\n};\n\nexport function crossProduct(u, v) {\n //\n // u X v = < u2*v3 - u3*v2,\n // u3*v1 - u1*v3,\n // u1*v2 - u2*v1 >\n let xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord;\n let ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord;\n let zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord;\n return makeVector(xcoord, ycoord, zcoord);\n};\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\nimport {\n makePoint, makeVector, makeVectorFromPoints,\n magnitude, unitVector, crossProduct,\n addVector, multiplyVector, negateVector\n} from '../utils/mathUtils';\n\n/**\n * Create SVGPathElement from an annotation definition.\n * This is used for anntations of type `drawing`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGPathElement} The path to be rendered\n */\nexport default function renderArrow(a) {\n let arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');\n\n if (a.lines.length === 2) {\n let p1 = a.lines[0];\n let p2 = a.lines[a.lines.length - 1];\n\n let arrowLength = 40;\n let pt0 = makePoint(p1[0], p1[1], 0);\n let pt1 = makePoint(p2[0], p2[1], 0);\n let x = makeVectorFromPoints(pt0, pt1);\n let unitX = unitVector(x);\n pt1 = addVector(pt0, multiplyVector(unitX, arrowLength));\n x = makeVectorFromPoints(pt0, pt1);\n let unitZ = makeVector(0, 0, 1);\n let unitY = unitVector(crossProduct(unitX, unitZ));\n let thickness = a.width || 10;\n\n let A = addVector(pt0, multiplyVector(unitY, thickness * 0.5));\n let B = addVector(A, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\n let C = addVector(B, multiplyVector(unitY, thickness));\n let D = pt1;\n let G = addVector(pt0, multiplyVector(negateVector(unitY), thickness * 0.5));\n let F = addVector(G, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\n let E = addVector(F, multiplyVector(negateVector(unitY), thickness));\n\n let points = '' +\n A.x + ',' + A.y + ' ' +\n B.x + ',' + B.y + ' ' +\n C.x + ',' + C.y + ' ' +\n D.x + ',' + D.y + ' ' +\n E.x + ',' + E.y + ' ' +\n F.x + ',' + F.y + ' ' +\n G.x + ',' + G.y;\n\n setAttributes(arrow, {\n points: points,\n stroke: normalizeColor(a.color || '#000'),\n fill: normalizeColor(a.color || '#000')\n });\n }\n\n return arrow;\n}\n","import renderLine from './renderLine';\nimport renderPath from './renderPath';\nimport renderPoint from './renderPoint';\nimport renderRect from './renderRect';\nimport renderText from './renderText';\nimport renderCircle from './renderCircle';\nimport renderArrow from './renderArrow';\n\nconst isFirefox = /firefox/i.test(navigator.userAgent);\n\n/**\n * Get the x/y translation to be used for transforming the annotations\n * based on the rotation of the viewport.\n *\n * @param {Object} viewport The viewport data from the page\n * @return {Object}\n */\nexport function getTranslation(viewport) {\n let x;\n let y;\n\n // Modulus 360 on the rotation so that we only\n // have to worry about four possible values.\n switch (viewport.rotation % 360) {\n case 0:\n x = y = 0;\n break;\n case 90:\n x = 0;\n y = (viewport.width / viewport.scale) * -1;\n break;\n case 180:\n x = (viewport.width / viewport.scale) * -1;\n y = (viewport.height / viewport.scale) * -1;\n break;\n case 270:\n x = (viewport.height / viewport.scale) * -1;\n y = 0;\n break;\n }\n\n return { x, y };\n}\n\n/**\n * Transform the rotation and scale of a node using SVG's native transform attribute.\n *\n * @param {Node} node The node to be transformed\n * @param {Object} viewport The page's viewport data\n * @return {Node}\n */\nfunction transform(node, viewport) {\n let trans = getTranslation(viewport);\n\n // Let SVG natively transform the element\n node.setAttribute('transform', `scale(${viewport.scale}) rotate(${viewport.rotation}) translate(${trans.x}, ${trans.y})`);\n\n // Manually adjust x/y for nested SVG nodes\n if (!isFirefox && node.nodeName.toLowerCase() === 'svg') {\n node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale);\n node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale);\n\n let x = parseInt(node.getAttribute('x', 10));\n let y = parseInt(node.getAttribute('y', 10));\n let width = parseInt(node.getAttribute('width'), 10);\n let height = parseInt(node.getAttribute('height'), 10);\n let path = node.querySelector('path');\n let svg = path.parentNode;\n\n // Scale width/height\n [node, svg, path, node.querySelector('rect')].forEach((n) => {\n n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale);\n n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale);\n });\n\n // Transform path but keep scale at 100% since it will be handled natively\n transform(path, Object.assign({}, viewport, { scale: 1 }));\n\n switch (viewport.rotation % 360) {\n case 90:\n node.setAttribute('x', viewport.width - y - width);\n node.setAttribute('y', x);\n svg.setAttribute('x', 1);\n svg.setAttribute('y', 0);\n break;\n case 180:\n node.setAttribute('x', viewport.width - x - width);\n node.setAttribute('y', viewport.height - y - height);\n svg.setAttribute('y', 2);\n break;\n case 270:\n node.setAttribute('x', y);\n node.setAttribute('y', viewport.height - x - height);\n svg.setAttribute('x', -1);\n svg.setAttribute('y', 0);\n break;\n }\n }\n\n return node;\n}\n\n/**\n * Append an annotation as a child of an SVG.\n *\n * @param {SVGElement} svg The SVG element to append the annotation to\n * @param {Object} annotation The annotation definition to render and append\n * @param {Object} viewport The page's viewport data\n * @return {SVGElement} A node that was created and appended by this function\n */\nexport function appendChild(svg, annotation, viewport) {\n if (!viewport) {\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\n }\n\n let child;\n switch (annotation.type) {\n case 'area':\n case 'highlight':\n child = renderRect(annotation);\n break;\n case 'circle':\n case 'fillcircle':\n case 'emptycircle':\n child = renderCircle(annotation);\n break;\n case 'strikeout':\n child = renderLine(annotation);\n break;\n case 'point':\n child = renderPoint(annotation);\n break;\n case 'textbox':\n child = renderText(annotation);\n break;\n case 'drawing':\n child = renderPath(annotation);\n break;\n case 'arrow':\n child = renderArrow(annotation);\n break;\n }\n\n // If no type was provided for an annotation it will result in node being null.\n // Skip appending/transforming if node doesn't exist.\n if (child) {\n // Set attributes\n child.setAttribute('data-pdf-annotate-id', annotation.uuid);\n child.setAttribute('aria-hidden', true);\n\n // Dynamically set any other attributes associated with annotation that is not related to drawing it\n Object.keys(annotation).filter((key) => {\n return ['color', 'x', 'y', 'cx', 'cy', 'color', 'documentId', 'lines', 'page',\n 'width', 'class', 'content', 'size', 'rotation', 'r'].indexOf(key) === -1;\n }).forEach((key) => {\n child.setAttribute(`data-pdf-annotate-${key}`, annotation[key]);\n });\n\n svg.appendChild(transform(child, viewport));\n }\n\n return child;\n}\n\n/**\n * Transform a child annotation of an SVG.\n *\n * @param {SVGElement} svg The SVG element with the child annotation\n * @param {Object} child The SVG child to transform\n * @param {Object} viewport The page's viewport data\n * @return {SVGElement} A node that was transformed by this function\n */\nexport function transformChild(svg, child, viewport) {\n if (!viewport) {\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\n }\n\n // If no type was provided for an annotation it will result in node being null.\n // Skip transforming if node doesn't exist.\n if (child) {\n child = transform(child, viewport);\n }\n\n return child;\n}\n\nexport default {\n /**\n * Get the x/y translation to be used for transforming the annotations\n * based on the rotation of the viewport.\n */\n getTranslation,\n\n /**\n * Append an SVG child for an annotation\n */\n appendChild,\n\n /**\n * Transform an existing SVG child\n */\n transformChild\n};\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGLineElements from an annotation definition.\n * This is used for anntations of type `strikeout`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement} A group of all lines to be rendered\n */\nexport default function renderLine(a) {\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n setAttributes(group, {\n stroke: normalizeColor(a.color || '#f00'),\n strokeWidth: 1\n });\n\n a.rectangles.forEach((r) => {\n let line = document.createElementNS('http://www.w3.org/2000/svg', 'line');\n\n setAttributes(line, {\n x1: r.x,\n y1: r.y,\n x2: r.x + r.width,\n y2: r.y\n });\n\n group.appendChild(line);\n });\n\n return group;\n}\n","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGPathElement from an annotation definition.\n * This is used for anntations of type `drawing`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGPathElement} The path to be rendered\n */\nexport default function renderPath(a) {\n let d = [];\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\n if (a.lines.length > 0) {\n d.push(`M${a.lines[0][0]} ${a.lines[0][1]}`);\n for (let i = 1, l = a.lines.length; i < l; i++) {\n let p1 = a.lines[i];\n let p2 = a.lines[i + 1];\n if (p2) {\n d.push(`L${p1[0]} ${p1[1]}`);\n }\n }\n }\n\n /*\n\n if(a.lines.length>2) {\n var p1 = a.lines[0];\n var p2 = a.lines[a.lines.length-1];\n\n var p3 = []; //arrow\n var p4 = [];\n var p0 = []; //arrow intersection\n\n if (p2) {\n var k = -(p2[0]-p1[0])/(p2[1]-p1[1]);\n\n var deltaX = 3;\n p0[0] = p1[0]+0.8*(p2[0]-p1[0]);\n p0[1] = p1[1]+0.8*(p2[1]-p1[1]);\n\n p3[0] = p0[0] + deltaX;\n p3[1] = p0[1] + k*deltaX;\n\n p4[0] = p0[0] - deltaX;\n p4[1] = p0[1] - k*deltaX;\n\n if(Math.abs(p2[1]-p1[1]) < 20) {\n\n p3[0] = p0[0] ;\n p3[1] = p0[1] + deltaX*1;\n\n p4[0] = p0[0] ;\n p4[1] = p0[1] - deltaX*1;\n\n }\n\n d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\n //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\n d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`);\n d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`);\n d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`);\n }\n } */\n\n setAttributes(path, {\n d: `${d.join(' ')}`, // `${d.join(' ')}Z`,\n stroke: normalizeColor(a.color || '#000'),\n strokeWidth: a.width || 1,\n fill: 'none'\n });\n\n return path;\n}\n","import { getTranslation } from '../render/appendChild';\nimport {\n applyTransform,\n applyInverseTransform,\n translate,\n rotate,\n scale\n} from '../utils/mathUtils';\n\nexport const BORDER_COLOR = '#00BFFF';\n\nconst userSelectStyleSheet = document.createElement('style');\nuserSelectStyleSheet.innerHTML = `\nbody {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n`;\n\nuserSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true');\n\n/**\n * Find the SVGElement that contains all the annotations for a page\n *\n * @param {Element} node An annotation within that container\n * @return {SVGElement} The container SVG or null if it can't be found\n */\nexport function findSVGContainer(node) {\n let parentNode = node;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n if (parentNode.nodeName.toUpperCase() === 'SVG' &&\n parentNode.getAttribute('data-pdf-annotate-container') === 'true') {\n return parentNode;\n }\n }\n\n return null;\n}\n\n/**\n * Find an SVGElement container at a given point\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @return {SVGElement} The container SVG or null if one can't be found\n */\nexport function findSVGAtPoint(x, y) {\n let elements = document.querySelectorAll('svg[data-pdf-annotate-container=\"true\"]');\n\n for (let i = 0, l = elements.length; i < l; i++) {\n let el = elements[i];\n let rect = el.getBoundingClientRect();\n\n if (pointIntersectsRect(x, y, rect)) {\n return el;\n }\n }\n\n return null;\n}\n\n/**\n * Find an Element that represents an annotation at a given point.\n *\n * IMPORTANT: Requires the annotation layer to be the top most element so\n * either use z-ordering or make it the leaf container.\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @return {Element} The annotation element or null if one can't be found\n */\nexport function findAnnotationAtPoint(x, y) {\n let el = null;\n let candidate = document.elementFromPoint(x, y);\n while (!el && candidate && candidate !== document) {\n let type = candidate.getAttribute('data-pdf-annotate-type');\n if (type) {\n el = candidate;\n }\n candidate = candidate.parentNode;\n }\n return el;\n}\n\n/**\n * Determine if a point intersects a rect\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Object} rect The points of a rect (likely from getBoundingClientRect)\n * @return {Boolean} True if a collision occurs, otherwise false\n */\nexport function pointIntersectsRect(x, y, rect) {\n return y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;\n}\n\n/**\n * Get the rect of an annotation element accounting for offset.\n *\n * @param {Element} el The element to get the rect of\n * @return {Object} The dimensions of the element\n */\nexport function getOffsetAnnotationRect(el) {\n let rect = el.getBoundingClientRect();\n let { width, height } = rect;\n let extraOffsetWidth = 0;\n let extraOffsetHeight = 0;\n if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) {\n let bbox = el.getBBox();\n extraOffsetWidth = (rect.width - bbox.width) / 2;\n extraOffsetHeight = (rect.height - bbox.height) / 2;\n width = bbox.width;\n height = bbox.height;\n }\n let { offsetLeft, offsetTop } = getOffset(el);\n return {\n top: rect.top - offsetTop + extraOffsetHeight,\n left: rect.left - offsetLeft + extraOffsetWidth,\n bottom: rect.bottom - offsetTop - extraOffsetHeight,\n right: rect.right - offsetLeft - extraOffsetWidth,\n width: width,\n height: height\n };\n}\n\n/**\n * Adjust scale from normalized scale (100%) to rendered scale.\n *\n * @param {SVGElement} svg The SVG to gather metadata from\n * @param {Object} rect A map of numeric values to scale\n * @return {Object} A copy of `rect` with values scaled up\n */\nexport function scaleUp(svg, rect) {\n let result = {};\n let { viewport } = getMetadata(svg);\n\n Object.keys(rect).forEach((key) => {\n result[key] = rect[key] * viewport.scale;\n });\n\n return result;\n}\n\nexport function convertToSvgRect(rect, svg, viewport) {\n let pt1 = [rect.x, rect.y];\n let pt2 = [rect.x + rect.width, rect.y + rect.height];\n\n pt1 = convertToSvgPoint(pt1, svg, viewport);\n pt2 = convertToSvgPoint(pt2, svg, viewport);\n\n return {\n x: Math.min(pt1[0], pt2[0]),\n y: Math.min(pt1[1], pt2[1]),\n width: Math.abs(pt2[0] - pt1[0]),\n height: Math.abs(pt2[1] - pt1[1])\n };\n}\n\nexport function convertToSvgPoint(pt, svg, viewport) {\n viewport = viewport || getMetadata(svg).viewport;\n\n let xform = [ 1, 0, 0, 1, 0, 0 ];\n xform = scale(xform, viewport.scale, viewport.scale);\n xform = rotate(xform, viewport.rotation);\n\n let offset = getTranslation(viewport);\n xform = translate(xform, offset.x, offset.y);\n\n return applyInverseTransform(pt, xform);\n}\n\nexport function convertToScreenPoint(pt, svg, viewport) {\n viewport = viewport || getMetadata(svg).viewport;\n\n let xform = [ 1, 0, 0, 1, 0, 0 ];\n xform = scale(xform, viewport.scale, viewport.scale);\n xform = rotate(xform, viewport.rotation);\n\n let offset = getTranslation(viewport);\n xform = translate(xform, offset.x, offset.y);\n\n return applyTransform(pt, xform);\n}\n\n/**\n * Adjust scale from rendered scale to a normalized scale (100%).\n *\n * @param {SVGElement} svg The SVG to gather metadata from\n * @param {Object} rect A map of numeric values to scale\n * @return {Object} A copy of `rect` with values scaled down\n */\nexport function scaleDown(svg, rect) {\n let result = {};\n let { viewport } = getMetadata(svg);\n\n Object.keys(rect).forEach((key) => {\n result[key] = rect[key] / viewport.scale;\n });\n\n return result;\n}\n\n/**\n * Get the scroll position of an element, accounting for parent elements\n *\n * @param {Element} el The element to get the scroll position for\n * @return {Object} The scrollTop and scrollLeft position\n */\nexport function getScroll(el) {\n let scrollTop = 0;\n let scrollLeft = 0;\n let parentNode = el;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n scrollTop += parentNode.scrollTop;\n scrollLeft += parentNode.scrollLeft;\n }\n\n return { scrollTop, scrollLeft };\n}\n\n/**\n * Get the offset position of an element, accounting for parent elements\n *\n * @param {Element} el The element to get the offset position for\n * @return {Object} The offsetTop and offsetLeft position\n */\nexport function getOffset(el) {\n let parentNode = el;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n if (parentNode.nodeName.toUpperCase() === 'SVG') {\n break;\n }\n }\n\n let rect = parentNode.getBoundingClientRect();\n\n return { offsetLeft: rect.left, offsetTop: rect.top };\n}\n\n/**\n * Disable user ability to select text on page\n */\nexport function disableUserSelect() {\n if (!userSelectStyleSheet.parentNode) {\n document.head.appendChild(userSelectStyleSheet);\n }\n}\n\n/**\n * Enable user ability to select text on page\n */\nexport function enableUserSelect() {\n if (userSelectStyleSheet.parentNode) {\n userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet);\n }\n}\n\n/**\n * Get the metadata for a SVG container\n *\n * @param {SVGElement} svg The SVG container to get metadata for\n */\nexport function getMetadata(svg) {\n return {\n documentId: svg.getAttribute('data-pdf-annotate-document'),\n pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10),\n viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'))\n };\n}\n","import EventEmitter from 'events';\nimport {\n findAnnotationAtPoint,\n findSVGAtPoint\n} from './utils';\n\nconst emitter = new EventEmitter();\n\nlet clickNode;\n\n/**\n * Handle document.click event\n *\n * @param {Event} e The DOM event to be handled\n */\ndocument.addEventListener('click', function handleDocumentClick(e) {\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\n\n // Emit annotation:blur if clickNode is no longer clicked\n if (clickNode && clickNode !== target) {\n emitter.emit('annotation:blur', clickNode);\n }\n\n // Emit annotation:click if target was clicked\n if (target) {\n emitter.emit('annotation:click', target);\n }\n\n clickNode = target;\n});\n\n// let mouseOverNode;\n// document.addEventListener('mousemove', function handleDocumentMousemove(e) {\n// let target = findAnnotationAtPoint(e.clientX, e.clientY);\n//\n// // Emit annotation:mouseout if target was mouseout'd\n// if (mouseOverNode && !target) {\n// emitter.emit('annotation:mouseout', mouseOverNode);\n// }\n//\n// // Emit annotation:mouseover if target was mouseover'd\n// if (target && mouseOverNode !== target) {\n// emitter.emit('annotation:mouseover', target);\n// }\n//\n// mouseOverNode = target;\n// });\n\nexport function fireEvent() { emitter.emit(...arguments); };\nexport function addEventListener() { emitter.on(...arguments); };\nexport function removeEventListener() { emitter.removeListener(...arguments); };\n","// Disable JSDoc as it cannot really deal with the odd way that the functions are defined\n/* eslint valid-jsdoc: 0 */\n\nimport abstractFunction from '../utils/abstractFunction';\nimport { fireEvent } from '../UI/event';\n\n// Adapter should never be invoked publicly\nexport default class StoreAdapter {\n /**\n * Create a new StoreAdapter instance\n *\n * @param {Object} [definition] The definition to use for overriding abstract methods\n */\n constructor(definition = {}) {\n // Copy each function from definition if it is a function we know about\n Object.keys(definition).forEach((key) => {\n if (typeof definition[key] === 'function' &&\n typeof this[key] === 'function') {\n this[key] = definition[key];\n }\n });\n }\n\n /**\n * Get all the annotations for a given document and page number.\n *\n * @param {String} documentId The ID for the document the annotations belong to\n * @param {Number} pageNumber The number of the page the annotations belong to\n * @return {Promise} Promise that returns with list of annotations for document and page\n */\n __getAnnotations(documentId, pageNumber) { abstractFunction('getAnnotations'); }\n get getAnnotations() { return this.__getAnnotations; }\n set getAnnotations(fn) {\n this.__getAnnotations = function getAnnotations(documentId, pageNumber) {\n return fn(...arguments).then((annotations) => {\n // TODO may be best to have this happen on the server\n if (annotations.annotations) {\n annotations.annotations.forEach((a) => {\n a.documentId = documentId;\n });\n }\n return annotations;\n });\n };\n }\n\n /**\n * Get the definition for a specific annotation.\n *\n * @param {String} documentId The ID for the document the annotation belongs to\n * @param {String} annotationId The ID for the annotation\n * @return {Promise} Promise that returns the requested annotation\n */\n getAnnotation(documentId, annotationId) { abstractFunction('getAnnotation'); }\n\n /**\n * Add an annotation\n *\n * @param {String} documentId The ID for the document to add the annotation to\n * @param {String} pageNumber The page number to add the annotation to\n * @param {Object} annotation The definition for the new annotation\n * @return {Promise} Promise that returns with the added annotation\n */\n __addAnnotation(documentId, pageNumber, annotation) { abstractFunction('addAnnotation'); }\n get addAnnotation() { return this.__addAnnotation; }\n set addAnnotation(fn) {\n this.__addAnnotation = function addAnnotation(documentId, pageNumber, annotation) {\n return fn(...arguments).then((annotation) => {\n fireEvent('annotation:add', documentId, pageNumber, annotation);\n return annotation;\n });\n };\n }\n\n /**\n * Edit an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} pageNumber the page number of the annotation\n * @param {Object} annotation The definition of the modified annotation\n * @return {Promise} Promise that returns with the edited annotation\n */\n __editAnnotation(documentId, pageNumber, annotation) { abstractFunction('editAnnotation'); }\n get editAnnotation() { return this.__editAnnotation; }\n set editAnnotation(fn) {\n this.__editAnnotation = function editAnnotation(documentId, annotationId, annotation) {\n return fn(...arguments).then((annotation) => {\n fireEvent('annotation:edit', documentId, annotationId, annotation);\n return annotation;\n });\n };\n }\n\n /**\n * Delete an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} annotationId The ID for the annotation\n * @return {Promise} Promise that returns with boolean if annotation was deleted\n */\n __deleteAnnotation(documentId, annotationId) { abstractFunction('deleteAnnotation'); }\n get deleteAnnotation() { return this.__deleteAnnotation; }\n set deleteAnnotation(fn) {\n this.__deleteAnnotation = function deleteAnnotation(documentId, annotationId) {\n return fn(...arguments).then((success) => {\n if (success) {\n fireEvent('annotation:delete', documentId, annotationId);\n }\n return success;\n });\n };\n }\n\n /**\n * Get all the comments for an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} annotationId The ID for the annotation\n * @return {Promise} Promise that returns with comments for annotation\n */\n getComments(documentId, annotationId) { abstractFunction('getComments'); }\n\n /**\n * Add a new comment\n *\n * @param {String} documentId The ID for the document\n * @param {String} annotationId The ID for the annotation\n * @param {Object} content The definition of the comment\n * @return {Promise} Promise that returns with the added comment\n */\n __addComment(documentId, annotationId, content) { abstractFunction('addComment'); }\n get addComment() { return this.__addComment; }\n set addComment(fn) {\n this.__addComment = function addComment(documentId, annotationId, content) {\n return fn(...arguments).then((comment) => {\n fireEvent('comment:add', documentId, annotationId, comment);\n return comment;\n });\n };\n }\n\n /**\n * Delete a comment\n *\n * @param {String} documentId The ID for the document\n * @param {String} commentId The ID for the comment\n * @return {Promise} Promise that returns with boolean if comment was deleted\n */\n __deleteComment(documentId, commentId) { abstractFunction('deleteComment'); }\n get deleteComment() { return this.__deleteComment; }\n set deleteComment(fn) {\n this.__deleteComment = function deleteComment(documentId, commentId) {\n return fn(...arguments).then((success) => {\n if (success) {\n fireEvent('comment:delete', documentId, commentId);\n }\n return success;\n });\n };\n }\n}\n","const REGEXP = /[xy]/g;\nconst PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nfunction replacement(c) {\n let r = Math.random() * 16 | 0;\n let v = c === 'x' ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n}\n\n/**\n * Generate a univierally unique identifier\n *\n * @return {String} A UUID\n */\nexport default function uuid() {\n return PATTERN.replace(REGEXP, replacement);\n}\n","import uuid from '../utils/uuid';\nimport StoreAdapter from './StoreAdapter';\n\n// StoreAdapter for working with localStorage\n// This is ideal for testing, examples, and prototyping\nexport default class LocalStoreAdapter extends StoreAdapter {\n constructor() {\n super({\n getAnnotations(documentId, pageNumber) {\n return new Promise((resolve, reject) => {\n let annotations = getAnnotations(documentId).filter((i) => {\n return i.page === pageNumber && i.class === 'Annotation';\n });\n\n resolve({\n documentId,\n pageNumber,\n annotations\n });\n });\n }\n });\n\n this.getAnnotation = (documentId, annotationId) => {\n return Promise.resolve(getAnnotations(documentId)[findAnnotation(documentId, annotationId)]);\n };\n\n this.addAnnotation = (documentId, pageNumber, annotation) => {\n return new Promise((resolve, reject) => {\n annotation.class = 'Annotation';\n annotation.uuid = uuid();\n annotation.page = pageNumber;\n\n let annotations = getAnnotations(documentId);\n annotations.push(annotation);\n updateAnnotations(documentId, annotations);\n\n resolve(annotation);\n });\n };\n\n this.editAnnotation = (documentId, annotationId, annotation) => {\n return new Promise((resolve, reject) => {\n let annotations = getAnnotations(documentId);\n annotations[findAnnotation(documentId, annotationId)] = annotation;\n updateAnnotations(documentId, annotations);\n resolve(annotation);\n });\n };\n\n this.deleteAnnotation = (documentId, annotationId) => {\n return new Promise((resolve, reject) => {\n let annotation = getAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\n if (!annotation) {\n return reject('Could not find annotation');\n }\n let index = findAnnotation(documentId, annotationId);\n if (index > -1) {\n let annotations = getAnnotations(documentId);\n annotations.splice(index, 1);\n updateAnnotations(documentId, annotations);\n }\n\n resolve(true);\n });\n };\n\n this.getComments = (documentId, annotationId) => {\n return new Promise((resolve, reject) => {\n resolve(getAnnotations(documentId).filter((i) => {\n return i.class === 'Comment' && i.annotation === annotationId;\n }));\n });\n };\n\n this.addComment = (documentId, annotationId, content) => {\n return new Promise((resolve, reject) => {\n let comment = {\n class: 'Comment',\n uuid: uuid(),\n annotation: annotationId,\n content: content\n };\n\n let annotations = getAnnotations(documentId);\n annotations.push(comment);\n updateAnnotations(documentId, annotations);\n\n resolve(comment);\n });\n };\n\n this.deleteComment = (documentId, commentId) => {\n return new Promise((resolve, reject) => {\n let comment = getAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\n if (!comment) {\n return reject('Could not find annotation');\n }\n let index = -1;\n let annotations = getAnnotations(documentId);\n for (let i = 0, l = annotations.length; i < l; i++) {\n if (annotations[i].uuid === commentId) {\n index = i;\n break;\n }\n }\n\n if (index > -1) {\n annotations.splice(index, 1);\n updateAnnotations(documentId, annotations);\n }\n\n resolve(true);\n });\n };\n }\n}\n\nfunction getAnnotations(documentId) {\n return JSON.parse(localStorage.getItem(`${documentId}/annotations`)) || [];\n}\n\nfunction updateAnnotations(documentId, annotations) {\n localStorage.setItem(`${documentId}/annotations`, JSON.stringify(annotations));\n}\n/**\n *\n * @param {String} documentId Document id of the annotation\n * @param {String} annotationId The id of the annotation\n *\n * This function finds all the annotation made by one user.\n *\n * @return {int} The index of the annotation in localstorage\n */\nfunction findAnnotation(documentId, annotationId) {\n let index = -1;\n let annotations = getAnnotations(documentId);\n for (let i = 0, l = annotations.length; i < l; i++) {\n if (annotations[i].uuid === annotationId) {\n index = i;\n break;\n }\n }\n return index;\n}\n","import uuid from '../utils/uuid';\nimport StoreAdapter from './StoreAdapter';\n\n// StoreAdapter for working with localStorage and associated user id\n// This is ideal for testing, examples, and prototyping\nexport default class LocalUserStoreAdapter extends StoreAdapter {\n constructor(userId = 'user', globalEdit = false) {\n super({\n getAnnotations(documentId, pageNumber) {\n return new Promise((resolve, reject) => {\n let annotations = getAllAnnotations(documentId).filter((i) => {\n return i.page === pageNumber && i.class === 'Annotation';\n });\n\n resolve({\n documentId,\n pageNumber,\n annotations\n });\n });\n }\n });\n\n this._userId = userId;\n this._globalEdit = globalEdit;\n\n this.getAnnotation = (documentId, annotationId) => {\n return Promise.resolve(getAnnotations(documentId, this._userId)[findAnnotation(documentId, this._userId, annotationId)]);\n };\n\n this.addAnnotation = (documentId, pageNumber, annotation) => {\n return new Promise((resolve, reject) => {\n annotation.class = 'Annotation';\n annotation.uuid = uuid();\n annotation.page = pageNumber;\n annotation.userId = this._userId;\n\n let annotations = getAnnotations(documentId, this._userId);\n annotations.push(annotation);\n updateAnnotations(documentId, this._userId, annotations);\n\n resolve(annotation);\n });\n };\n\n this.editAnnotation = (documentId, annotationId, annotation) => {\n return new Promise((resolve, reject) => {\n if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\n reject('Non-matching userId');\n }\n let annotations = getAnnotations(documentId, annotation.userId);\n annotations[findAnnotation(documentId, annotation.userId, annotationId)] = annotation;\n updateAnnotations(documentId, annotation.userId, annotations);\n resolve(annotation);\n });\n };\n\n this.deleteAnnotation = (documentId, annotationId) => {\n return new Promise((resolve, reject) => {\n let annotation = getAllAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\n if (!annotation) {\n return reject('Could not find annotation');\n }\n else if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\n return reject('Non-matching userId');\n }\n let index = findAnnotation(documentId, annotation.userId, annotationId);\n if (index > -1) {\n let annotations = getAnnotations(documentId, annotation.userId);\n annotations.splice(index, 1);\n updateAnnotations(documentId, annotation.userId, annotations);\n }\n\n resolve(true);\n });\n };\n\n this.getComments = (documentId, annotationId) => {\n return new Promise((resolve, reject) => {\n resolve(getAnnotations(documentId, this._userId).filter((i) => {\n return i.class === 'Comment' && i.annotation === annotationId;\n }));\n });\n };\n\n this.addComment = (documentId, annotationId, content) => {\n return new Promise((resolve, reject) => {\n let comment = {\n class: 'Comment',\n uuid: uuid(),\n annotation: annotationId,\n content: content,\n userId: this._userId\n };\n\n let annotations = getAnnotations(documentId, this._userId);\n annotations.push(comment);\n updateAnnotations(documentId, this._userId, annotations);\n\n resolve(comment);\n });\n };\n\n this.deleteComment = (documentId, commentId) => {\n return new Promise((resolve, reject) => {\n let comment = getAllAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\n if (!comment) {\n return reject('Could not find annotation');\n }\n else if (!this._globalEdit && comment.userId && comment.userId !== this._userId) {\n return reject('Non-matching userId');\n }\n let index = -1;\n let annotations = getAnnotations(documentId, comment.userId);\n for (let i = 0, l = annotations.length; i < l; i++) {\n if (annotations[i].uuid === commentId) {\n index = i;\n break;\n }\n }\n\n if (index > -1) {\n annotations.splice(index, 1);\n updateAnnotations(documentId, comment.userId, annotations);\n }\n\n resolve(true);\n });\n };\n }\n\n get userId() {\n return this._userId;\n }\n}\n\nfunction getAllAnnotations(documentId) {\n let all_annotations = [];\n let re = new RegExp(`${documentId}/(.*)/annotations`);\n for (let i = 0; i < localStorage.length; i++) {\n if (localStorage.key(i).search(re) > -1) {\n all_annotations.push(...JSON.parse(localStorage.getItem(localStorage.key(i))));\n }\n }\n return all_annotations;\n}\n\nfunction getAnnotations(documentId, userId) {\n return JSON.parse(localStorage.getItem(`${documentId}/${userId}/annotations`)) || [];\n}\n\nfunction updateAnnotations(documentId, userId, annotations) {\n localStorage.setItem(`${documentId}/${userId}/annotations`, JSON.stringify(annotations));\n}\n/**\n *\n * @param {String} documentId Document id of the annotation\n * @param {String} userId User id of the annotation\n * @param {String} annotationId The id of the annotation\n *\n * This function finds all the annotation made by one user.\n *\n * @return {int} The index of the annotation in localstorage\n */\nfunction findAnnotation(documentId, userId, annotationId) {\n let index = -1;\n let annotations = getAnnotations(documentId, userId);\n for (let i = 0, l = annotations.length; i < l; i++) {\n if (annotations[i].uuid === annotationId) {\n index = i;\n break;\n }\n }\n return index;\n}\n","export default {\n annotationLayerName: 'annotationLayer',\n textLayerName: 'textLayer',\n annotationSvgQuery: function() {\n return 'svg.' + this.annotationLayerName;\n },\n annotationClassQuery: function() {\n return '.' + this.annotationLayerName;\n },\n textClassQuery: function() {\n return '.' + this.textLayerName;\n }\n};\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport {\n addEventListener,\n removeEventListener\n} from './event';\nimport {\n BORDER_COLOR,\n disableUserSelect,\n enableUserSelect,\n findSVGContainer,\n findSVGAtPoint,\n getOffsetAnnotationRect,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet isDragging = false;\nlet overlay;\nlet dragOffsetX, dragOffsetY, dragStartX, dragStartY;\nconst OVERLAY_BORDER_SIZE = 3;\n\n/**\n * Create an overlay for editing an annotation.\n *\n * @param {Element} target The annotation element to apply overlay for\n */\nfunction createEditOverlay(target) {\n destroyEditOverlay();\n\n overlay = document.createElement('div');\n let anchor = document.createElement('a');\n let parentNode = findSVGContainer(target).parentNode;\n let id = target.getAttribute('data-pdf-annotate-id');\n let rect = getOffsetAnnotationRect(target);\n let styleLeft = rect.left - OVERLAY_BORDER_SIZE;\n let styleTop = rect.top - OVERLAY_BORDER_SIZE;\n\n overlay.setAttribute('id', 'pdf-annotate-edit-overlay');\n overlay.setAttribute('data-target-id', id);\n overlay.style.boxSizing = 'content-box';\n overlay.style.position = 'absolute';\n overlay.style.top = `${styleTop}px`;\n overlay.style.left = `${styleLeft}px`;\n overlay.style.width = `${rect.width}px`;\n overlay.style.height = `${rect.height}px`;\n overlay.style.border = `${OVERLAY_BORDER_SIZE}px solid ${BORDER_COLOR}`;\n overlay.style.borderRadius = `${OVERLAY_BORDER_SIZE}px`;\n overlay.style.zIndex = 20100;\n\n anchor.innerHTML = '×';\n anchor.setAttribute('href', 'javascript://');\n anchor.style.background = '#fff';\n anchor.style.borderRadius = '20px';\n anchor.style.border = '1px solid #bbb';\n anchor.style.color = '#bbb';\n anchor.style.fontSize = '16px';\n anchor.style.padding = '2px';\n anchor.style.textAlign = 'center';\n anchor.style.textDecoration = 'none';\n anchor.style.position = 'absolute';\n anchor.style.top = '-13px';\n anchor.style.right = '-13px';\n anchor.style.width = '25px';\n anchor.style.height = '25px';\n\n overlay.appendChild(anchor);\n parentNode.appendChild(overlay);\n document.addEventListener('click', handleDocumentClick);\n document.addEventListener('keyup', handleDocumentKeyup);\n document.addEventListener('mousedown', handleDocumentMousedown);\n anchor.addEventListener('click', deleteAnnotation);\n anchor.addEventListener('mouseover', () => {\n anchor.style.color = '#35A4DC';\n anchor.style.borderColor = '#999';\n anchor.style.boxShadow = '0 1px 1px #ccc';\n });\n anchor.addEventListener('mouseout', () => {\n anchor.style.color = '#bbb';\n anchor.style.borderColor = '#bbb';\n anchor.style.boxShadow = '';\n });\n overlay.addEventListener('mouseover', () => {\n if (!isDragging) { anchor.style.display = ''; }\n });\n overlay.addEventListener('mouseout', () => {\n anchor.style.display = 'none';\n });\n}\n\n/**\n * Destroy the edit overlay if it exists.\n */\nfunction destroyEditOverlay() {\n if (overlay) {\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n }\n\n document.removeEventListener('click', handleDocumentClick);\n document.removeEventListener('keyup', handleDocumentKeyup);\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n enableUserSelect();\n}\n\n/**\n * Delete currently selected annotation\n */\nfunction deleteAnnotation() {\n if (!overlay) {\n return;\n }\n\n let annotationId = overlay.getAttribute('data-target-id');\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let { documentId } = getMetadata(svg);\n\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n\n [...nodes].forEach((n) => {\n n.parentNode.removeChild(n);\n });\n });\n\n destroyEditOverlay();\n}\n\n/**\n * Handle document.click event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentClick(e) {\n if (!findSVGAtPoint(e.clientX, e.clientY)) { return; }\n\n // Remove current overlay\n let overlay = document.getElementById('pdf-annotate-edit-overlay');\n if (overlay) {\n if (isDragging || e.target === overlay) {\n return;\n }\n\n destroyEditOverlay();\n }\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {KeyboardEvent} e The DOM event that needs to be handled\n */\nfunction handleDocumentKeyup(e) {\n // keyCode is deprecated, so prefer the newer \"key\" method if possible\n let keyTest;\n if (e.key) {\n keyTest = e.key.toLowerCase() === 'delete' || e.key.toLowerCase() === 'backspace';\n }\n else {\n keyTest = e.keyCode === 8 || e.keyCode === 46;\n }\n if (overlay && keyTest &&\n e.target.nodeName.toLowerCase() !== 'textarea' &&\n e.target.nodeName.toLowerCase() !== 'input') {\n e.preventDefault();\n deleteAnnotation();\n }\n}\n\n/**\n * Handle document.mousedown event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMousedown(e) {\n if (e.target !== overlay) {\n return;\n }\n\n // Highlight and strikeout annotations are bound to text within the document.\n // It doesn't make sense to allow repositioning these types of annotations.\n let annotationId = overlay.getAttribute('data-target-id');\n let target = document.querySelector(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n let type = target.getAttribute('data-pdf-annotate-type');\n\n if (type === 'highlight' || type === 'strikeout') { return; }\n\n isDragging = true;\n dragOffsetX = e.clientX;\n dragOffsetY = e.clientY;\n dragStartX = overlay.offsetLeft;\n dragStartY = overlay.offsetTop;\n\n overlay.style.background = 'rgba(255, 255, 255, 0.7)';\n overlay.style.cursor = 'move';\n overlay.querySelector('a').style.display = 'none';\n\n document.addEventListener('mousemove', handleDocumentMousemove);\n document.addEventListener('mouseup', handleDocumentMouseup);\n disableUserSelect();\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMousemove(e) {\n let parentNode = overlay.parentNode;\n let rect = parentNode.getBoundingClientRect();\n let y = (dragStartY + (e.clientY - dragOffsetY));\n let x = (dragStartX + (e.clientX - dragOffsetX));\n let minY = 0;\n let maxY = rect.height;\n let minX = 0;\n let maxX = rect.width;\n\n if (y > minY && y + overlay.offsetHeight < maxY) {\n overlay.style.top = `${y}px`;\n }\n\n if (x > minX && x + overlay.offsetWidth < maxX) {\n overlay.style.left = `${x}px`;\n }\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMouseup(e) {\n let annotationId = overlay.getAttribute('data-target-id');\n let target = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n let type = target[0].getAttribute('data-pdf-annotate-type');\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let { documentId } = getMetadata(svg);\n\n overlay.querySelector('a').style.display = '';\n\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\n let attribX = 'x';\n let attribY = 'y';\n if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\n attribX = 'cx';\n attribY = 'cy';\n }\n\n if (type === 'point') {\n // Broken\n /*\n [...target].forEach((t, i) => {\n let moveTo = {\n x: overlay.offsetLeft + 3,\n y: overlay.offsetTop + 3\n };\n t.setAttribute(attribX, moveTo.x);\n t.setAttribute(attribY, moveTo.y);\n annotation[attribX] = moveTo.x;\n annotation[attribY] = moveTo.y;\n });\n */\n return;\n }\n else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\n let modelDelta = {\n x: modelEnd[0] - modelStart[0],\n y: modelEnd[1] - modelStart[1]\n };\n\n if (type === 'textbox') {\n target = [target[0].firstChild];\n }\n\n [...target].forEach((t, i) => {\n let modelX = parseInt(t.getAttribute(attribX), 10);\n let modelY = parseInt(t.getAttribute(attribY), 10);\n if (modelDelta.y !== 0) {\n modelY = modelY + modelDelta.y;\n\n t.setAttribute(attribY, modelY);\n if (annotation.rectangles && i < annotation.rectangles.length) {\n annotation.rectangles[i].y = modelY;\n }\n else if (annotation[attribY]) {\n annotation[attribY] = modelY;\n }\n }\n if (modelDelta.x !== 0) {\n modelX = modelX + modelDelta.x;\n\n t.setAttribute(attribX, modelX);\n if (annotation.rectangles && i < annotation.rectangles.length) {\n annotation.rectangles[i].x = modelX;\n }\n else if (annotation[attribX]) {\n annotation[attribX] = modelX;\n }\n }\n });\n }\n else if (type === 'strikeout') {\n return;\n // let { deltaX, deltaY } = getDelta('x1', 'y1');\n // [...target].forEach(target, (t, i) => {\n // if (deltaY !== 0) {\n // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY);\n // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY);\n // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10);\n // }\n // if (deltaX !== 0) {\n // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX);\n // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX);\n // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10);\n // }\n // });\n }\n else if (type === 'drawing' || type === 'arrow') {\n // Do nothing as currently broken\n /*\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\n let modelDelta = {\n x: modelEnd[0] - modelStart[0],\n y: modelEnd[1] - modelStart[1]\n };\n\n annotation.lines.forEach((line, i) => {\n let [x, y] = annotation.lines[i];\n annotation.lines[i][0] = x + modelDelta.x;\n annotation.lines[i][1] = y + modelDelta.y;\n });\n\n target[0].parentNode.removeChild(target[0]);\n appendChild(svg, annotation);\n */\n return;\n }\n\n PDFJSAnnotate.getStoreAdapter().editAnnotation(documentId, annotationId, annotation);\n });\n\n setTimeout(() => {\n isDragging = false;\n }, 0);\n\n overlay.style.background = '';\n overlay.style.cursor = '';\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n enableUserSelect();\n}\n\n/**\n * Handle annotation.click event\n *\n * @param {Element} e The annotation element that was clicked\n */\nfunction handleAnnotationClick(target) {\n createEditOverlay(target);\n}\n\n/**\n * Enable edit mode behavior.\n */\nexport function enableEdit() {\n if (_enabled) {\n return;\n }\n\n _enabled = true;\n addEventListener('annotation:click', handleAnnotationClick);\n};\n\n/**\n * Disable edit mode behavior.\n */\nexport function disableEdit() {\n destroyEditOverlay();\n\n if (!_enabled) {\n return;\n }\n\n _enabled = false;\n removeEventListener('annotation:click', handleAnnotationClick);\n};\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet _candraw = false;\nlet _penSize;\nlet _penColor;\nlet path;\nlet lines = [];\n\n/**\n * Handle document.touchdown or document.pointerdown event\n * @param {PointerEvent} e The DOM event to be handled\n */\nfunction handleDocumentPointerdown(e) {\n path = null;\n lines = [];\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n _candraw = true;\n e.preventDefault();\n}\n\n/**\n * Handle document.pointerup event\n *\n * @param {PointerEvent} e The DOM event to be handled\n */\nfunction handleDocumentPointerup(e) {\n saveToStorage(e.clientX, e.clientY);\n}\n\nfunction saveToStorage(x, y) {\n if (!_candraw) {\n return;\n }\n _candraw = false;\n let svg;\n if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {\n let { documentId, pageNumber } = getMetadata(svg);\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\n type: 'drawing',\n width: _penSize,\n color: _penColor,\n lines\n }).then((annotation) => {\n if (path) {\n svg.removeChild(path);\n }\n\n appendChild(svg, annotation);\n });\n }\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {PointerEvent} e The DOM event to be handled\n */\nfunction handleDocumentPointermove(e) {\n if (!findSVGAtPoint(e.clientX, e.clientY) || !_candraw) {\n return;\n }\n savePoint(e.clientX, e.clientY);\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {KeyboardEvent} e The DOM event to be handled\n * } e The DOM event to be handled\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n lines = null;\n path.parentNode.removeChild(path);\n document.removeEventListener('pointermove', handleDocumentPointermove);\n document.removeEventListener('pointerup', handleDocumentPointerup);\n }\n}\n\n/**\n * Save a point to the line being drawn.\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n */\nfunction savePoint(x, y) {\n let svg = findSVGAtPoint(x, y);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let point = convertToSvgPoint([\n x - rect.left,\n y - rect.top\n ], svg);\n point[0] = point[0].toFixed(2);\n point[1] = point[1].toFixed(2);\n lines.push(point);\n\n if (lines.length <= 1) {\n return;\n }\n\n if (path) {\n svg.removeChild(path);\n }\n\n path = appendChild(svg, {\n type: 'drawing',\n color: _penColor,\n width: _penSize,\n lines\n });\n}\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} penSize The size of the lines drawn by the pen, rounded to 2 decimal places\n * @param {String} penColor The color of the lines drawn by the pen\n */\nexport function setPen(penSize = 1, penColor = '000000') {\n _penSize = Math.round(parseFloat(penSize) * 1e2) / 1e2;\n _penColor = penColor;\n}\n\n/**\n * Return pen attributes of the pen\n *\n * @return {Object} Object with size and color\n */\nexport function getPen() {\n return {\n size: _penSize,\n color: _penColor\n };\n}\n\n/**\n * Enable the pen behavior\n */\nexport function enablePen() {\n if (_enabled) {\n return;\n }\n\n _enabled = true;\n // Chrome and Firefox has different behaviors with how pen works, so we need different events.\n document.addEventListener('pointerdown', handleDocumentPointerdown);\n document.addEventListener('pointermove', handleDocumentPointermove);\n document.addEventListener('pointerup', handleDocumentPointerup);\n\n document.addEventListener('keyup', handleDocumentKeyup);\n disableUserSelect();\n}\n\n/**\n * Disable the pen behavior\n */\nexport function disablePen() {\n if (!_enabled) {\n return;\n }\n\n _enabled = false;\n document.removeEventListener('pointerdown', handleDocumentPointerdown);\n document.removeEventListener('pointermove', handleDocumentPointermove);\n document.removeEventListener('pointerup', handleDocumentPointerup);\n\n document.removeEventListener('keyup', handleDocumentKeyup);\n enableUserSelect();\n}\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n findSVGContainer,\n getMetadata,\n convertToSvgPoint,\n convertToScreenPoint,\n findAnnotationAtPoint\n} from './utils';\n\nlet _enabled = false;\nlet _penSize;\nlet _penColor;\nlet path;\nlet lines;\nlet originY;\nlet originX;\n\n/**\n * Handle document.mousedown event\n */\nfunction handleDocumentMousedown(e) {\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\n if (target === null) {\n return;\n }\n\n let type = target.getAttribute('data-pdf-annotate-type');\n if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') {\n return;\n }\n\n let svg = findSVGContainer(target);\n let { documentId } = getMetadata(svg);\n let annotationId = target.getAttribute('data-pdf-annotate-id');\n\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\n if (annotation) {\n path = null;\n lines = [];\n\n let point = convertToScreenPoint([\n annotation.cx,\n annotation.cy\n ], svg);\n\n let rect = svg.getBoundingClientRect();\n\n originX = point[0] + rect.left;\n originY = point[1] + rect.top;\n\n document.addEventListener('mousemove', handleDocumentMousemove);\n document.addEventListener('mouseup', handleDocumentMouseup);\n }\n });\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentMouseup(e) {\n let svg;\n if (lines.length > 1 && (svg = findSVGAtPoint(e.clientX, e.clientY))) {\n let { documentId, pageNumber } = getMetadata(svg);\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\n type: 'arrow',\n width: _penSize,\n color: _penColor,\n lines\n }).then((annotation) => {\n if (path) {\n svg.removeChild(path);\n }\n\n appendChild(svg, annotation);\n });\n }\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentMousemove(e) {\n let x = lines.length === 0 ? originX : e.clientX;\n let y = lines.length === 0 ? originY : e.clientY;\n\n savePoint(x, y);\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n lines = null;\n path.parentNode.removeChild(path);\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n }\n}\n\n/**\n * Save a point to the line being drawn.\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n */\nfunction savePoint(x, y) {\n let svg = findSVGAtPoint(x, y);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let point = convertToSvgPoint([\n x - rect.left,\n y - rect.top\n ], svg);\n\n if (lines.length < 2) {\n lines.push(point);\n return;\n }\n else {\n lines[1] = point; // update end point\n }\n\n if (path) {\n svg.removeChild(path);\n }\n\n path = appendChild(svg, {\n type: 'arrow',\n color: _penColor,\n width: _penSize,\n lines\n });\n}\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} penSize The size of the lines drawn by the pen\n * @param {String} penColor The color of the lines drawn by the pen\n */\nexport function setArrow(penSize = 10, penColor = '0000FF') {\n _penSize = parseInt(penSize, 10);\n _penColor = penColor;\n}\n\n/**\n * Enable the pen behavior\n */\nexport function enableArrow() {\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mousedown', handleDocumentMousedown);\n document.addEventListener('keyup', handleDocumentKeyup);\n disableUserSelect();\n}\n\n/**\n * Disable the pen behavior\n */\nexport function disableArrow() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('keyup', handleDocumentKeyup);\n enableUserSelect();\n}\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport {\n findAnnotationAtPoint,\n getMetadata\n} from './utils';\n\nlet _canerase = false;\nlet previousPoint = null;\n\n/**\n *\n * @param {PointerEvent} e DOM event to handle\n */\nfunction handleDocumentDown(e) {\n _canerase = true;\n previousPoint = [e.clientX, e.clientY];\n}\n\n/**\n *\n * @param {PointerEvent} e DOM event to handle\n */\nfunction handleDocumentUp(e) {\n _canerase = false;\n erase(findAnnotationAtPoint(e.clientX, e.clientY));\n}\n\n/**\n *\n * @param {PointerEvent} e DOM event to handle\n */\nfunction handleDocumentMouseMove(e) {\n if (!_canerase) {\n return;\n }\n\n // This algorithm attempts to get the various points between the last\n // PointerEvent and this one\n let check = [];\n let diffX = Math.abs(previousPoint[0] - e.clientX);\n let diffY = Math.abs(previousPoint[1] - e.clientY);\n if (diffX >= 1 || diffY >= 1) {\n let maxSteps = Math.round(Math.max(diffX, diffY));\n let subStepSize = Math.min(diffX, diffY) / maxSteps;\n let smallerTest = diffX < diffY;\n let startPoint = [\n Math.min(previousPoint[0], e.clientX),\n Math.min(previousPoint[1], e.clientY)\n ];\n for (let i = 0; i < maxSteps; i++) {\n if (smallerTest) {\n check.push([Math.round(startPoint[0] + (subStepSize * i)), Math.round(startPoint[1] + i)]);\n }\n else {\n check.push([Math.round(startPoint[0] + i), Math.round(startPoint[1] + (subStepSize * i))]);\n }\n }\n }\n for (let point of check) {\n erase(findAnnotationAtPoint(point[0], point[1]));\n }\n previousPoint = [e.clientX, e.clientY];\n}\n\nfunction erase(target) {\n if (!_canerase) {\n return;\n }\n\n if (target) {\n let { documentId } = getMetadata(target.parentElement);\n let annotationId = target.getAttribute('data-pdf-annotate-id');\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n [...nodes].forEach((n) => {\n n.parentNode.removeChild(n);\n });\n });\n }\n}\n\nexport function enableEraser() {\n document.addEventListener('pointermove', handleDocumentMouseMove);\n document.addEventListener('pointerdown', handleDocumentDown);\n document.addEventListener('pointerup', handleDocumentUp);\n}\n\nexport function disableEraser() {\n document.removeEventListener('pointermove', handleDocumentMouseMove);\n document.removeEventListener('pointerdown', handleDocumentDown);\n document.removeEventListener('pointerup', handleDocumentUp);\n}\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n findSVGAtPoint,\n getMetadata,\n scaleDown\n} from './utils';\n\nlet _enabled = false;\nlet input;\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} The DOM event to be handled\n */\nfunction handleDocumentMouseup(e) {\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n\n input = document.createElement('input');\n input.setAttribute('id', 'pdf-annotate-point-input');\n input.setAttribute('placeholder', 'Enter comment');\n input.style.border = `3px solid ${BORDER_COLOR}`;\n input.style.borderRadius = '3px';\n input.style.position = 'absolute';\n input.style.top = `${e.clientY}px`;\n input.style.left = `${e.clientX}px`;\n\n input.addEventListener('blur', handleInputBlur);\n input.addEventListener('keyup', handleInputKeyup);\n\n document.body.appendChild(input);\n input.focus();\n}\n\n/**\n * Handle input.blur event\n */\nfunction handleInputBlur() {\n savePoint();\n}\n\n/**\n * Handle input.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleInputKeyup(e) {\n if (e.keyCode === 27) {\n closeInput();\n }\n else if (e.keyCode === 13) {\n savePoint();\n }\n}\n\n/**\n * Save a new point annotation from input\n */\nfunction savePoint() {\n if (input.value.trim().length > 0) {\n let clientX = parseInt(input.style.left, 10);\n let clientY = parseInt(input.style.top, 10);\n let content = input.value.trim();\n let svg = findSVGAtPoint(clientX, clientY);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let { documentId, pageNumber } = getMetadata(svg);\n let annotation = Object.assign({\n type: 'point'\n }, scaleDown(svg, {\n x: clientX - rect.left,\n y: clientY - rect.top\n }));\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\n .then((annotation) => {\n PDFJSAnnotate.getStoreAdapter().addComment(\n documentId,\n annotation.uuid,\n content\n );\n\n appendChild(svg, annotation);\n });\n }\n\n closeInput();\n}\n\n/**\n * Close the input element\n */\nfunction closeInput() {\n input.removeEventListener('blur', handleInputBlur);\n input.removeEventListener('keyup', handleInputKeyup);\n document.body.removeChild(input);\n input = null;\n}\n\n/**\n * Enable point annotation behavior\n */\nexport function enablePoint() {\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Disable point annotation behavior\n */\nexport function disablePoint() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n getMetadata,\n convertToSvgRect\n} from './utils';\n\nlet _enabled = false;\nlet _type;\nlet overlay;\nlet originY;\nlet originX;\n\n/**\n * Get the current window selection as rects\n *\n * @return {Array} An Array of rects\n */\nfunction getSelectionRects() {\n try {\n let selection = window.getSelection();\n let range = selection.getRangeAt(0);\n let rects = range.getClientRects();\n\n if (rects.length > 0 &&\n rects[0].width > 0 &&\n rects[0].height > 0) {\n return rects;\n }\n }\n catch (e) {}\n\n return null;\n}\n\n/**\n * Handle document.mousedown event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMousedown(e) {\n let svg;\n if (_type !== 'area' || !(svg = findSVGAtPoint(e.clientX, e.clientY))) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n originY = e.clientY;\n originX = e.clientX;\n\n overlay = document.createElement('div');\n overlay.style.position = 'absolute';\n overlay.style.top = `${originY - rect.top}px`;\n overlay.style.left = `${originX - rect.left}px`;\n overlay.style.border = `3px solid ${BORDER_COLOR}`;\n overlay.style.borderRadius = '3px';\n svg.parentNode.appendChild(overlay);\n\n document.addEventListener('mousemove', handleDocumentMousemove);\n disableUserSelect();\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMousemove(e) {\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let rect = svg.getBoundingClientRect();\n\n if (originX + (e.clientX - originX) < rect.right) {\n overlay.style.width = `${e.clientX - originX}px`;\n }\n\n if (originY + (e.clientY - originY) < rect.bottom) {\n overlay.style.height = `${e.clientY - originY}px`;\n }\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n let rects;\n if (_type !== 'area' && (rects = getSelectionRects())) {\n saveRect(_type, [...rects].map((r) => {\n return {\n top: r.top,\n left: r.left,\n width: r.width,\n height: r.height\n };\n }));\n }\n else if (_type === 'area' && overlay) {\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let rect = svg.getBoundingClientRect();\n saveRect(_type, [{\n top: parseInt(overlay.style.top, 10) + rect.top,\n left: parseInt(overlay.style.left, 10) + rect.left,\n width: parseInt(overlay.style.width, 10),\n height: parseInt(overlay.style.height, 10)\n }]);\n\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n enableUserSelect();\n }\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n let selection = window.getSelection();\n selection.removeAllRanges();\n if (overlay && overlay.parentNode) {\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n document.removeEventListener('mousemove', handleDocumentMousemove);\n }\n }\n}\n\n/**\n * Save a rect annotation\n *\n * @param {String} type The type of rect (area, highlight, strikeout)\n * @param {Array} rects The rects to use for annotation\n * @param {String} color The color of the rects\n */\nfunction saveRect(type, rects, color) {\n let svg = findSVGAtPoint(rects[0].left, rects[0].top);\n let annotation;\n\n if (!svg) {\n return;\n }\n\n let boundingRect = svg.getBoundingClientRect();\n\n if (!color) {\n if (type === 'highlight') {\n color = 'FFFF00';\n }\n else if (type === 'strikeout') {\n color = 'FF0000';\n }\n }\n\n // Initialize the annotation\n annotation = {\n type,\n color,\n rectangles: [...rects].map((r) => {\n let offset = 0;\n\n if (type === 'strikeout') {\n offset = r.height / 2;\n }\n\n return convertToSvgRect({\n y: (r.top + offset) - boundingRect.top,\n x: r.left - boundingRect.left,\n width: r.width,\n height: r.height\n }, svg);\n }).filter((r) => r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1)\n };\n\n // Short circuit if no rectangles exist\n if (annotation.rectangles.length === 0) {\n return;\n }\n\n // Special treatment for area as it only supports a single rect\n if (type === 'area') {\n let rect = annotation.rectangles[0];\n delete annotation.rectangles;\n annotation.x = rect.x;\n annotation.y = rect.y;\n annotation.width = rect.width;\n annotation.height = rect.height;\n }\n\n let { documentId, pageNumber } = getMetadata(svg);\n\n // Add the annotation\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n}\n\n/**\n * Enable rect behavior\n */\nexport function enableRect(type) {\n _type = type;\n\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n document.addEventListener('mousedown', handleDocumentMousedown);\n document.addEventListener('keyup', handleDocumentKeyup);\n}\n\n/**\n * Disable rect behavior\n */\nexport function disableRect() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('keyup', handleDocumentKeyup);\n}\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet _type;\nlet _circleRadius = 10;\nlet _circleColor = '0000FF';\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} circleRadius The radius of the circle\n * @param {String} circleColor The color of the circle\n */\nexport function setCircle(circleRadius = 10, circleColor = '0000FF') {\n _circleRadius = parseInt(circleRadius, 10);\n _circleColor = circleColor;\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n let svg = findSVGAtPoint(e.clientX, e.clientY);\n if (!svg) {\n return;\n }\n let rect = svg.getBoundingClientRect();\n saveCircle(svg, _type, {\n x: e.clientX - rect.left,\n y: e.clientY - rect.top\n }, _circleRadius, _circleColor);\n}\n\n/**\n * Save a circle annotation\n *\n * @param {SVGElement} svg\n * @param {String} type The type of circle (circle, emptycircle, fillcircle)\n * @param {Object} pt The point to use for annotation\n * @param {float} radius\n * @param {String} color The color of the rects\n */\nfunction saveCircle(svg, type, pt, radius, color) {\n // Initialize the annotation\n let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg);\n let annotation = {\n type,\n color,\n cx: svg_pt[0],\n cy: svg_pt[1],\n r: radius\n };\n\n let { documentId, pageNumber } = getMetadata(svg);\n\n // Add the annotation\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n}\n\n/**\n * Enable circle behavior\n */\nexport function enableCircle(type) {\n _type = type;\n\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Disable circle behavior\n */\nexport function disableCircle() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\nexport function addCircle(type, e) {\n let oldType = _type;\n _type = type;\n handleDocumentMouseup(e);\n _type = oldType;\n}\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet input;\nlet _textSize = localStorage.getItem(`text/size`) || 12;\nlet _textColor = localStorage.getItem(`text/color`) || '#000000';\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n if (!e.srcElement.classList.contains('annotationLayer')) {\n return;\n }\n input = document.createElement('textarea');\n input.setAttribute('id', 'pdf-annotate-text-input');\n input.setAttribute('placeholder', 'Enter text... SHIFT + ENTER for new line');\n input.style.border = `3px solid ${BORDER_COLOR}`;\n input.style.borderRadius = '3px';\n input.style.position = 'fixed';\n input.style.top = `${e.clientY}px`;\n input.style.left = `${e.clientX}px`;\n input.style.fontSize = `${_textSize}px`;\n input.style.zIndex = '41';\n input.addEventListener('blur', handleInputBlur);\n input.addEventListener('keyup', handleInputKeyup);\n\n document.body.appendChild(input);\n input.focus();\n}\n\n/**\n * Handle input.blur event\n */\nfunction handleInputBlur() {\n saveText();\n}\n\n/**\n * Handle input.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleInputKeyup(e) {\n if (e.keyCode === 27) {\n closeInput();\n }\n else if (e.keyCode === 13 && !e.shiftKey) {\n saveText();\n }\n}\n\n/**\n * Save a text annotation from input\n */\nfunction saveText() {\n let value = (input.value) ? input.value.replace(/ +$/, '') : '';\n if (value.length > 0) {\n let clientX = parseInt(input.style.left, 10);\n let clientY = parseInt(input.style.top, 10);\n let svg = findSVGAtPoint(clientX, clientY);\n if (!svg) {\n return;\n }\n let height = _textSize;\n let { documentId, pageNumber, viewport } = getMetadata(svg);\n let scale = 1 / viewport.scale;\n let rect = svg.getBoundingClientRect();\n let pt = convertToSvgPoint([\n clientX - rect.left,\n clientY - rect.top + height], svg, viewport);\n let annotation = {\n type: 'textbox',\n size: _textSize * scale,\n color: _textColor,\n content: value,\n x: pt[0],\n y: pt[1],\n rotation: -viewport.rotation\n };\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n }\n\n closeInput();\n}\n\n/**\n * Close the input\n */\nfunction closeInput() {\n if (input) {\n input.removeEventListener('blur', handleInputBlur);\n input.removeEventListener('keyup', handleInputKeyup);\n document.body.removeChild(input);\n input = null;\n }\n}\n\n/**\n * Set the text attributes\n *\n * @param {Number} textSize The size of the text\n * @param {String} textColor The color of the text\n */\nexport function setText(textSize = 12, textColor = '000000') {\n _textSize = parseInt(textSize, 10);\n _textColor = textColor;\n}\n\n/**\n * Enable text behavior\n */\nexport function enableText() {\n if (_enabled) {\n return;\n }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Disable text behavior\n */\nexport function disableText() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n","/**\n * Create a node that is only visible to screen readers\n *\n * @param {String} content The text content that should be read by screen reader\n * @param {String} [annotationId] The ID of the annotation assocaited\n * @return {Element} An Element that is only visible to screen readers\n */\nexport default function createScreenReaderOnly(content, annotationId) {\n let node = document.createElement('div');\n let text = document.createTextNode(content);\n node.appendChild(text);\n node.setAttribute('id', `pdf-annotate-screenreader-${annotationId}`);\n node.style.position = 'absolute';\n node.style.left = '-10000px';\n node.style.top = 'auto';\n node.style.width = '1px';\n node.style.height = '1px';\n node.style.overflow = 'hidden';\n return node;\n}\n","import config from '../config';\nimport {\n pointIntersectsRect,\n scaleUp,\n scaleDown\n} from '../UI/utils';\n\n/**\n * Insert an element at a point within the document.\n * This algorithm will only insert within an element amidst it's text content.\n *\n * @param {Element} el The element to be inserted\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page number to limit elements to\n * @param {Boolean} insertBefore Whether the element is to be inserted before or after x\n * @return {Boolean} True if element was able to be inserted, otherwise false\n */\nexport default function insertElementWithinElement(el, x, y, pageNumber, insertBefore) {\n const OFFSET_ADJUST = 2;\n\n // If inserting before adjust `x` by looking for element a few px to the right\n // Otherwise adjust a few px to the left\n // This is to allow a little tolerance by searching within the box, instead\n // of getting a false negative by testing right on the border.\n x = Math.max(x + (OFFSET_ADJUST * (insertBefore ? 1 : -1)), 0);\n\n let node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber);\n if (!node) {\n return false;\n }\n\n // Now that node has been found inverse the adjustment for `x`.\n // This is done to accomodate tolerance by cutting off on the outside of the\n // text boundary, instead of missing a character by cutting off within.\n x = x + (OFFSET_ADJUST * (insertBefore ? -1 : 1));\n\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let left = scaleDown(svg, {left: node.getBoundingClientRect().left}).left - svg.getBoundingClientRect().left;\n let temp = node.cloneNode(true);\n let head = temp.innerHTML.split('');\n let tail = [];\n\n // Insert temp off screen\n temp.style.position = 'absolute';\n temp.style.top = '-10000px';\n temp.style.left = '-10000px';\n document.body.appendChild(temp);\n\n while (head.length) {\n // Don't insert within HTML tags\n if (head[head.length - 1] === '>') {\n while (head.length) {\n tail.unshift(head.pop());\n if (tail[0] === '<') {\n break;\n }\n }\n }\n\n // Check if width of temp based on current head value satisfies x\n temp.innerHTML = head.join('');\n let width = scaleDown(svg, {width: temp.getBoundingClientRect().width}).width;\n if (left + width <= x) {\n break;\n }\n tail.unshift(head.pop());\n }\n\n // Update original node with new markup, including element to be inserted\n node.innerHTML = head.join('') + el.outerHTML + tail.join('');\n temp.parentNode.removeChild(temp);\n\n return true;\n}\n\n/**\n * Get a text layer element at a given point on a page\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page to limit elements to\n * @return {Element} First text layer element found at the point\n */\nfunction textLayerElementFromPoint(x, y, pageNumber) {\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let rect = svg.getBoundingClientRect();\n y = scaleUp(svg, {y}).y + rect.top;\n x = scaleUp(svg, {x}).x + rect.left;\n return [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' [data-canvas-width]')].filter((el) => {\n return pointIntersectsRect(x, y, el.getBoundingClientRect());\n })[0];\n}\n","import config from '../config';\nimport insertElementWithinElement from './insertElementWithinElement';\nimport { pointIntersectsRect, scaleUp } from '../UI/utils';\n\n/**\n * Insert an element at a point within the document.\n * This algorithm will try to insert between elements if possible.\n * It will however use `insertElementWithinElement` if it is more accurate.\n *\n * @param {Element} el The element to be inserted\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page number to limit elements to\n * @return {Boolean} True if element was able to be inserted, otherwise false\n */\nexport default function insertElementWithinChildren(el, x, y, pageNumber) {\n // Try and use most accurate method of inserting within an element\n if (insertElementWithinElement(el, x, y, pageNumber, true)) {\n return true;\n }\n\n // Fall back to inserting between elements\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let rect = svg.getBoundingClientRect();\n let nodes = [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' > div')];\n\n y = scaleUp(svg, {y}).y + rect.top;\n x = scaleUp(svg, {x}).x + rect.left;\n\n // Find the best node to insert before\n for (let i = 0, l = nodes.length; i < l; i++) {\n let n = nodes[i];\n let r = n.getBoundingClientRect();\n if (y <= r.top) {\n n.parentNode.insertBefore(el, n);\n return true;\n }\n }\n\n // If all else fails try to append to the bottom\n let textLayer = svg.parentNode.querySelector(config.textClassQuery());\n if (textLayer) {\n let textRect = textLayer.getBoundingClientRect();\n if (pointIntersectsRect(x, y, textRect)) {\n textLayer.appendChild(el);\n return true;\n }\n }\n\n return false;\n}\n","/**\n * Insert a comment into the DOM to be available by screen reader\n *\n * @param {Object} comment The comment to be inserted\n */\nexport default function insertScreenReaderComment(comment) {\n if (!comment) {\n return;\n }\n\n let list = document.querySelector(`#pdf-annotate-screenreader-${comment.annotation} ol`);\n if (list) {\n let item = document.createElement('li');\n item.setAttribute('id', `pdf-annotate-screenreader-comment-${comment.uuid}`);\n item.appendChild(document.createTextNode(`${comment.content}`));\n list.appendChild(item);\n }\n}\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport insertScreenReaderComment from './insertScreenReaderComment';\n\n/**\n * Insert the comments into the DOM to be available by screen reader\n *\n * Example output:\n *
\n *
Begin highlight 1
\n *
    \n *
  1. Foo
  2. \n *
  3. Bar
  4. \n *
  5. Baz
  6. \n *
  7. Qux
  8. \n *
\n *
\n *
Some highlighted text goes here...
\n *
End highlight 1
\n *\n * NOTE: `screenReaderOnly` is not a real class, just used for brevity\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The ID of the annotation\n * @param {Array} [comments] Optionally preloaded comments to be rendered\n * @return {Promise} Promise that once has comments, render them for screen reader\n */\nexport default function renderScreenReaderComments(documentId, annotationId, comments) {\n let promise;\n\n if (Array.isArray(comments)) {\n promise = Promise.resolve(comments);\n }\n else {\n promise = PDFJSAnnotate.getStoreAdapter().getComments(documentId, annotationId);\n }\n\n return promise.then((comments) => {\n // Node needs to be found by querying DOM as it may have been inserted as innerHTML\n // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`).\n let node = document.getElementById(`pdf-annotate-screenreader-${annotationId}`);\n if (node) {\n let list = document.createElement('ol');\n list.setAttribute('id', `pdf-annotate-screenreader-comment-list-${annotationId}`);\n list.setAttribute('aria-label', 'Comments');\n node.appendChild(list);\n comments.forEach(insertScreenReaderComment);\n }\n });\n}\n","import createScreenReaderOnly from './createScreenReaderOnly';\nimport insertElementWithinChildren from './insertElementWithinChildren';\nimport insertElementWithinElement from './insertElementWithinElement';\nimport renderScreenReaderComments from './renderScreenReaderComments';\n\n// Annotation types that support comments\nconst COMMENT_TYPES = ['highlight', 'point', 'area', 'circle', 'emptycircle', 'fillcircle'];\n\n/**\n * Insert a hint into the DOM for screen readers for a specific annotation.\n *\n * @param {Object} annotation The annotation to insert a hint for\n * @param {Number} num The number of the annotation out of all annotations of the same type\n */\nexport default function insertScreenReaderHint(annotation, num = 0) {\n switch (annotation.type) {\n case 'highlight':\n case 'strikeout':\n let rects = annotation.rectangles;\n let first = rects[0];\n let last = rects[rects.length - 1];\n\n insertElementWithinElement(\n createScreenReaderOnly(`Begin ${annotation.type} annotation ${num}`, annotation.uuid),\n first.x, first.y, annotation.page, true\n );\n\n insertElementWithinElement(\n createScreenReaderOnly(`End ${annotation.type} annotation ${num}`, `${annotation.uuid}-end`),\n last.x + last.width, last.y, annotation.page, false\n );\n break;\n\n case 'textbox':\n case 'point':\n let text = annotation.type === 'textbox' ? ` (content: ${annotation.content})` : '';\n\n insertElementWithinChildren(\n createScreenReaderOnly(`${annotation.type} annotation ${num}${text}`, annotation.uuid),\n annotation.x, annotation.y, annotation.page\n );\n break;\n\n case 'drawing':\n case 'area':\n let x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0];\n let y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1];\n\n insertElementWithinChildren(\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\n x, y, annotation.page\n );\n break;\n\n case 'circle':\n case 'fillcircle':\n case 'emptycircle':\n let x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0];\n let y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1];\n\n insertElementWithinChildren(\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\n x2, y2, annotation.page\n );\n break;\n }\n\n // Include comments in screen reader hint\n if (COMMENT_TYPES.includes(annotation.type)) {\n renderScreenReaderComments(annotation.documentId, annotation.uuid);\n }\n}\n","import renderScreenReaderHints from './renderScreenReaderHints';\nimport insertScreenReaderComment from './insertScreenReaderComment';\nimport renderScreenReaderComments from './renderScreenReaderComments';\nimport { addEventListener } from '../UI/event';\nimport PDFJSAnnotate from '../PDFJSAnnotate';\n\n/**\n * Initialize the event handlers for keeping screen reader hints synced with data\n */\nexport default function initEventHandlers() {\n addEventListener('annotation:add', (documentId, pageNumber, annotation) => {\n reorderAnnotationsByType(documentId, pageNumber, annotation.type);\n });\n addEventListener('annotation:edit', (documentId, annotationId, annotation) => {\n reorderAnnotationsByType(documentId, annotation.page, annotation.type);\n });\n addEventListener('annotation:delete', removeAnnotation);\n addEventListener('comment:add', insertComment);\n addEventListener('comment:delete', removeComment);\n}\n\n/**\n * Reorder the annotation numbers by annotation type\n *\n * @param {String} documentId The ID of the document\n * @param {Number} pageNumber The page number of the annotations\n * @param {Strig} type The annotation type\n */\nfunction reorderAnnotationsByType(documentId, pageNumber, type) {\n PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, pageNumber)\n .then((annotations) => {\n return annotations.annotations.filter((a) => {\n return a.type === type;\n });\n })\n .then((annotations) => {\n annotations.forEach((a) => {\n removeAnnotation(documentId, a.uuid);\n });\n\n return annotations;\n })\n .then(renderScreenReaderHints);\n}\n\n/**\n * Remove the screen reader hint for an annotation\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The Id of the annotation\n */\nfunction removeAnnotation(documentId, annotationId) {\n removeElementById(`pdf-annotate-screenreader-${annotationId}`);\n removeElementById(`pdf-annotate-screenreader-${annotationId}-end`);\n}\n\n/**\n * Insert a screen reader hint for a comment\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The ID of tha assocated annotation\n * @param {Object} comment The comment to insert a hint for\n */\nfunction insertComment(documentId, annotationId, comment) {\n let list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\n let promise;\n\n if (!list) {\n promise = renderScreenReaderComments(documentId, annotationId, []).then(() => {\n list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\n return true;\n });\n }\n else {\n promise = Promise.resolve(true);\n }\n\n promise.then(() => {\n insertScreenReaderComment(comment);\n });\n}\n\n/**\n * Remove a screen reader hint for a comment\n *\n * @param {String} documentId The ID of the document\n * @param {String} commentId The ID of the comment\n */\nfunction removeComment(documentId, commentId) {\n removeElementById(`pdf-annotate-screenreader-comment-${commentId}`);\n}\n\n/**\n * Remove an element from the DOM by it's ID if it exists\n *\n * @param {String} elementId The ID of the element to be removed\n */\nfunction removeElementById(elementId) {\n let el = document.getElementById(elementId);\n if (el) {\n el.parentNode.removeChild(el);\n }\n}\n","import insertScreenReaderHint from './insertScreenReaderHint';\nimport initEventHandlers from './initEventHandlers';\n\n// TODO This is not the right place for this to live\ninitEventHandlers();\n\n/**\n * Insert hints into the DOM for screen readers.\n *\n * @param {Array} annotations The annotations that hints are inserted for\n */\nexport default function renderScreenReaderHints(annotations) {\n annotations = Array.isArray(annotations) ? annotations : [];\n\n // Insert hints for each type\n Object.keys(SORT_TYPES).forEach((type) => {\n let sortBy = SORT_TYPES[type];\n annotations\n .filter((a) => a.type === type)\n .sort(sortBy)\n .forEach((a, i) => insertScreenReaderHint(a, i + 1));\n });\n}\n\n// Sort annotations first by y, then by x.\n// This allows hints to be injected in the order they appear,\n// which makes numbering them easier.\nfunction sortByPoint(a, b) {\n if (a.y < b.y) {\n return a.x - b.x;\n }\n else {\n return 1;\n }\n}\n\n// Sort annotation by it's first rectangle\nfunction sortByRectPoint(a, b) {\n return sortByPoint(a.rectangles[0], b.rectangles[0]);\n}\n\n// Sort annotation by it's first line\nfunction sortByLinePoint(a, b) {\n let lineA = a.lines[0];\n let lineB = b.lines[0];\n return sortByPoint(\n {x: lineA[0], y: lineA[1]},\n {x: lineB[0], y: lineB[1]}\n );\n}\n\n// Arrange supported types and associated sort methods\nconst SORT_TYPES = {\n 'highlight': sortByRectPoint,\n 'strikeout': sortByRectPoint,\n 'drawing': sortByLinePoint,\n 'textbox': sortByPoint,\n 'point': sortByPoint,\n 'area': sortByPoint\n};\n\n","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport renderScreenReaderHints from '../a11y/renderScreenReaderHints';\n\n// Template for creating a new page\nconst PAGE_TEMPLATE = `\n
\n
\n \n
\n
\n \n
\n`;\n\n/**\n * Create a new page to be appended to the DOM.\n *\n * @param {Number} pageNumber The page number that is being created\n * @return {HTMLElement}\n */\nexport function createPage(pageNumber) {\n let temp = document.createElement('div');\n temp.innerHTML = PAGE_TEMPLATE;\n\n let page = temp.children[0];\n let canvas = page.querySelector('canvas');\n\n page.setAttribute('id', `pageContainer${pageNumber}`);\n page.setAttribute('data-page-number', pageNumber);\n\n canvas.mozOpaque = true;\n canvas.setAttribute('id', `page${pageNumber}`);\n\n return page;\n}\n\n/**\n * Render a page that has already been created.\n *\n * @param {Number} pageNumber The page number to be rendered\n * @param {Object} renderOptions The options for rendering\n * @return {Promise} Settled once rendering has completed\n * A settled Promise will be either:\n * - fulfilled: [pdfPage, annotations]\n * - rejected: Error\n */\nexport function renderPage(pageNumber, renderOptions) {\n let {\n documentId,\n pdfDocument,\n scale,\n rotate\n } = renderOptions;\n\n const eventBus = new pdfjsViewer.EventBus();\n\n // Load the page and annotations\n return Promise.all([\n pdfDocument.getPage(pageNumber),\n PDFJSAnnotate.getAnnotations(documentId, pageNumber)\n ]).then(([pdfPage, annotations]) => {\n let page = document.getElementById(`pageContainer${pageNumber}`);\n let svg = page.querySelector(config.annotationClassQuery());\n let canvas = page.querySelector('.canvasWrapper canvas');\n let canvasContext = canvas.getContext('2d', {alpha: false});\n let totalRotation = (rotate + pdfPage.rotate) % 360;\n let viewport = pdfPage.getViewport({scale: scale, rotation: totalRotation});\n let transform = scalePage(pageNumber, viewport, canvasContext);\n\n // Render the page\n return Promise.all([\n pdfPage.render({ canvasContext, viewport, transform }).promise,\n PDFJSAnnotate.render(svg, viewport, annotations)\n ]).then(() => {\n // Text content is needed for a11y, but is also necessary for creating\n // highlight and strikeout annotations which require selecting text.\n return pdfPage.getTextContent({normalizeWhitespace: true}).then((textContent) => {\n return new Promise((resolve, reject) => {\n // Render text layer for a11y of text content\n let textLayer = page.querySelector(config.textClassQuery());\n let textLayerFactory = new pdfjsViewer.DefaultTextLayerFactory();\n let textLayerBuilder = textLayerFactory.createTextLayerBuilder(\n textLayer,\n pageNumber - 1,\n viewport,\n false,\n eventBus\n );\n textLayerBuilder.setTextContent(textContent);\n textLayerBuilder.render();\n\n // Enable a11y for annotations\n // Timeout is needed to wait for `textLayerBuilder.render`\n setTimeout(() => {\n try {\n renderScreenReaderHints(annotations.annotations);\n resolve();\n }\n catch (e) {\n reject(e);\n }\n });\n });\n });\n }).then(() => {\n // Indicate that the page was loaded\n page.setAttribute('data-loaded', 'true');\n\n return [pdfPage, annotations];\n });\n });\n}\n\n/**\n * Scale the elements of a page.\n *\n * @param {Number} pageNumber The page number to be scaled\n * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate))\n * @param {Object} context The canvas context that the PDF page is rendered to\n * @return {Array} The transform data for rendering the PDF page\n */\nfunction scalePage(pageNumber, viewport, context) {\n let page = document.getElementById(`pageContainer${pageNumber}`);\n let canvas = page.querySelector('.canvasWrapper canvas');\n let svg = page.querySelector(config.annotationClassQuery());\n let wrapper = page.querySelector('.canvasWrapper');\n let textLayer = page.querySelector(config.textClassQuery());\n let outputScale = getOutputScale(context);\n let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];\n let sfx = approximateFraction(outputScale.sx);\n let sfy = approximateFraction(outputScale.sy);\n\n // Adjust width/height for scale\n page.style.visibility = '';\n canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);\n canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);\n canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';\n canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';\n svg.setAttribute('width', viewport.width);\n svg.setAttribute('height', viewport.height);\n svg.style.width = `${viewport.width}px`;\n svg.style.height = `${viewport.height}px`;\n page.style.width = `${viewport.width}px`;\n page.style.height = `${viewport.height}px`;\n wrapper.style.width = `${viewport.width}px`;\n wrapper.style.height = `${viewport.height}px`;\n textLayer.style.width = `${viewport.width}px`;\n textLayer.style.height = `${viewport.height}px`;\n\n return transform;\n}\n\n/**\n * Approximates a float number as a fraction using Farey sequence (max order of 8).\n *\n * @param {Number} x Positive float number\n * @return {Array} Estimated fraction: the first array item is a numerator,\n * the second one is a denominator.\n */\nfunction approximateFraction(x) {\n // Fast path for int numbers or their inversions.\n if (Math.floor(x) === x) {\n return [x, 1];\n }\n\n const xinv = 1 / x;\n const limit = 8;\n if (xinv > limit) {\n return [1, limit];\n }\n else if (Math.floor(xinv) === xinv) {\n return [1, xinv];\n }\n\n const x_ = x > 1 ? xinv : x;\n\n // a/b and c/d are neighbours in Farey sequence.\n let a = 0; let b = 1; let c = 1; let d = 1;\n\n // Limit search to order 8.\n while (true) {\n // Generating next term in sequence (order of q).\n let p = a + c; let q = b + d;\n if (q > limit) {\n break;\n }\n if (x_ <= p / q) {\n c = p; d = q;\n }\n else {\n a = p; b = q;\n }\n }\n\n // Select closest of neighbours to x.\n if (x_ - a / b < c / d - x_) {\n return x_ === x ? [a, b] : [b, a];\n }\n else {\n return x_ === x ? [c, d] : [d, c];\n }\n}\n\nfunction getOutputScale(ctx) {\n let devicePixelRatio = window.devicePixelRatio || 1;\n let backingStoreRatio = ctx.webkitBackingStorePixelRatio ||\n ctx.mozBackingStorePixelRatio ||\n ctx.msBackingStorePixelRatio ||\n ctx.oBackingStorePixelRatio ||\n ctx.backingStorePixelRatio || 1;\n let pixelRatio = devicePixelRatio / backingStoreRatio;\n return {\n sx: pixelRatio,\n sy: pixelRatio,\n scaled: pixelRatio !== 1\n };\n}\n\nfunction roundToDivide(x, div) {\n let r = x % div;\n return r === 0 ? x : Math.round(x - r + div);\n}\n","import { addEventListener, removeEventListener, fireEvent } from './event';\nimport { disableEdit, enableEdit } from './edit';\nimport { disablePen, enablePen, setPen } from './pen';\nimport { disableArrow, enableArrow, setArrow } from './arrow';\nimport { disableEraser, enableEraser } from './eraser';\nimport { disablePoint, enablePoint } from './point';\nimport { disableRect, enableRect } from './rect';\nimport { disableCircle, enableCircle, setCircle, addCircle } from './circle';\nimport { disableText, enableText, setText } from './text';\nimport { createPage, renderPage } from './page';\n\nexport default {\n addEventListener,\n removeEventListener,\n fireEvent,\n\n disableEdit,\n enableEdit,\n\n disablePen,\n enablePen,\n setPen,\n\n disablePoint,\n enablePoint,\n\n disableRect,\n enableRect,\n\n disableCircle,\n enableCircle,\n setCircle,\n addCircle,\n\n disableArrow,\n enableArrow,\n setArrow,\n\n disableEraser,\n enableEraser,\n\n disableText,\n enableText,\n setText,\n\n createPage,\n renderPage\n};\n","import StoreAdapter from './adapter/StoreAdapter';\nimport LocalStoreAdapter from './adapter/LocalStoreAdapter';\nimport LocalUserStoreAdapter from './adapter/LocalUserStoreAdapter';\nimport render from './render';\nimport UI from './UI';\nimport config from './config';\nimport uuid from './utils/uuid';\nimport {\n findAnnotationAtPoint,\n findSVGContainer,\n convertToScreenPoint\n} from './UI/utils';\n\nexport default {\n findAnnotationAtPoint,\n findSVGContainer,\n convertToScreenPoint,\n\n /**\n * Abstract class that needs to be defined so PDFJSAnnotate\n * knows how to communicate with your server.\n */\n StoreAdapter,\n\n /**\n * Implementation of StoreAdapter that stores annotation data to localStorage.\n */\n LocalStoreAdapter,\n\n /**\n * Implementation of StoreAdapter that stores annotation data to localStorage particular\n * to a specific user\n */\n LocalUserStoreAdapter,\n\n /**\n * Abstract instance of StoreAdapter\n */\n __storeAdapter: new StoreAdapter(),\n\n /**\n * Getter for the underlying StoreAdapter property\n *\n * @return {StoreAdapter}\n */\n getStoreAdapter() {\n return this.__storeAdapter;\n },\n\n /**\n * Setter for the underlying StoreAdapter property\n *\n * @param {StoreAdapter} adapter The StoreAdapter implementation to be used.\n */\n setStoreAdapter(adapter) {\n // TODO this throws an error when bundled\n // if (!(adapter instanceof StoreAdapter)) {\n // throw new Error('adapter must be an instance of StoreAdapter');\n // }\n\n this.__storeAdapter = adapter;\n },\n\n /**\n * UI is a helper for instrumenting UI interactions for creating,\n * editing, and deleting annotations in the browser.\n */\n UI,\n\n /**\n * Render the annotations for a page in the PDF Document\n *\n * @param {SVGElement} svg The SVG element that annotations should be rendered to\n * @param {PageViewport} viewport The PDFPage.getViewport data\n * @param {Object} data The StoreAdapter.getAnnotations data\n * @return {Promise}\n */\n render,\n\n /**\n * Convenience method for getting annotation data\n *\n * @alias StoreAdapter.getAnnotations\n * @param {String} documentId The ID of the document\n * @param {String} pageNumber The page number\n * @return {Promise}\n */\n getAnnotations(documentId, pageNumber) {\n return this.getStoreAdapter().getAnnotations(...arguments);\n },\n\n config,\n\n uuid\n};\n","import { appendChild, transformChild } from './appendChild';\n\n/**\n * Render the response from PDFJSAnnotate.getStoreAdapter().getAnnotations to SVG\n *\n * @param {SVGElement} svg The SVG element to render the annotations to\n * @param {Object} viewport The page viewport data\n * @param {Object} data The response from PDFJSAnnotate.getStoreAdapter().getAnnotations\n * @return {Promise} Settled once rendering has completed\n * A settled Promise will be either:\n * - fulfilled: SVGElement\n * - rejected: Error\n */\nexport default function render(svg, viewport, data) {\n return new Promise((resolve, reject) => {\n // Reset the content of the SVG\n svg.setAttribute('data-pdf-annotate-container', true);\n svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport));\n svg.removeAttribute('data-pdf-annotate-document');\n svg.removeAttribute('data-pdf-annotate-page');\n\n // If there's no data nothing can be done\n if (!data) {\n svg.innerHTML = '';\n return resolve(svg);\n }\n\n svg.setAttribute('data-pdf-annotate-document', data.documentId);\n svg.setAttribute('data-pdf-annotate-page', data.pageNumber);\n\n // Make sure annotations is an array\n if (!Array.isArray(data.annotations) || data.annotations.length === 0) {\n return resolve(svg);\n }\n\n // Append or transform annotation to svg\n data.annotations.forEach((a) => {\n let node = svg.querySelector('[data-pdf-annotate-id=\"' + a.uuid + '\"]');\n if (node) {\n transformChild(svg, node, viewport);\n }\n else {\n appendChild(svg, a, viewport);\n }\n });\n\n resolve(svg);\n });\n}\n","import PDFJSAnnotate from './src/PDFJSAnnotate';\n\nexport default PDFJSAnnotate;\n"],"names":["root","factory","exports","module","define","amd","self","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","prototype","call","ownKeys","Object","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","value","EventEmitter","init","this","once","emitter","name","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","m","events","existing","warning","create","newListener","emit","unshift","push","length","warned","w","Error","String","count","console","warn","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","bind","_listeners","unwrap","evlistener","arr","ret","Array","i","unwrapListeners","arrayClone","listenerCount","n","copy","addEventListener","wrapListener","arg","removeEventListener","defineProperty","enumerable","get","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","error","er","message","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","key","keys","rawListeners","eventNames","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","getter","__esModule","d","a","definition","o","obj","prop","hasOwnProperty","r","Symbol","toStringTag","abstractFunction","UPPER_REGEX","BLACKLIST","keyCase","indexOf","replace","match","toLowerCase","setAttributes","node","attributes","forEach","setAttribute","REGEX_HASHLESS_HEX","normalizeColor","color","test","SIZE","D","createRect","rect","document","createElementNS","x","y","width","height","renderText","text","fill","fontSize","size","transform","rotation","style","textElement","textContent","_step","lines","split","getAttribute","_iterator","_createForOfIteratorHelper","s","done","line","tspan","toString","innerHTML","appendChild","e","f","insertLineBreaks","content","g","renderCircle","circle","cx","cy","createCircle","stroke","translate","rotate","angle","Math","PI","cosValue","cos","sinValue","sin","scale","makePoint","z","makeVector","xcoord","ycoord","zcoord","makeVectorFromPoints","pt1","pt2","addVector","pt","v","multiplyVector","scalar","magnitude","sqrt","pow","negateVector","unitVector","mag","renderArrow","u","arrow","p1","p2","pt0","unitX","unitZ","unitY","thickness","A","B","C","G","F","E","points","isFirefox","navigator","userAgent","getTranslation","viewport","trans","nodeName","parseInt","path","querySelector","svg","parentNode","assign","annotation","child","group","JSON","parse","fillOpacity","rectangles","renderRect","strokeWidth","x1","y1","x2","y2","outerSVG","innerSVG","viewBox","renderPoint","l","join","renderPath","uuid","filter","transformChild","BORDER_COLOR","userSelectStyleSheet","createElement","findSVGContainer","toUpperCase","findSVGAtPoint","elements","querySelectorAll","el","pointIntersectsRect","getBoundingClientRect","findAnnotationAtPoint","candidate","elementFromPoint","top","bottom","left","right","getOffsetAnnotationRect","extraOffsetWidth","extraOffsetHeight","tagName","getBBox","bbox","_getOffset","offsetLeft","offsetTop","getOffset","scaleUp","result","getMetadata","convertToSvgPoint","xform","p","offset","convertToScreenPoint","scaleDown","disableUserSelect","head","enableUserSelect","removeChild","documentId","pageNumber","clickNode","fireEvent","clientX","clientY","StoreAdapter","_this","_classCallCheck","__getAnnotations","fn","then","annotations","annotationId","__addAnnotation","__editAnnotation","__deleteAnnotation","success","__addComment","comment","commentId","__deleteComment","REGEXP","replacement","c","random","LocalStoreAdapter","_StoreAdapter","_callSuper","getAnnotations","page","getAnnotation","findAnnotation","addAnnotation","updateAnnotations","editAnnotation","deleteAnnotation","splice","getComments","addComment","class","deleteComment","_inherits","localStorage","getItem","setItem","stringify","LocalUserStoreAdapter","userId","globalEdit","getAllAnnotations","_userId","_globalEdit","all_annotations","re","RegExp","search","_toConsumableArray","annotationLayerName","textLayerName","annotationSvgQuery","annotationClassQuery","textClassQuery","overlay","dragOffsetX","dragOffsetY","dragStartX","dragStartY","_enabled","isDragging","OVERLAY_BORDER_SIZE","destroyEditOverlay","handleDocumentClick","handleDocumentKeyup","handleDocumentMousedown","handleDocumentMousemove","handleDocumentMouseup","config","PDFJSAnnotate","getStoreAdapter","getElementById","keyTest","keyCode","preventDefault","background","cursor","display","maxY","maxX","offsetHeight","offsetWidth","attribX","attribY","modelStart","modelEnd","modelDelta","firstChild","t","modelX","modelY","setTimeout","handleAnnotationClick","anchor","id","styleLeft","styleTop","boxSizing","border","borderRadius","zIndex","padding","textAlign","textDecoration","borderColor","boxShadow","createEditOverlay","_penSize","_penColor","_candraw","handleDocumentPointerdown","handleDocumentPointerup","_getMetadata","saveToStorage","handleDocumentPointermove","point","toFixed","savePoint","originY","originX","_getMetadata2","_canerase","previousPoint","handleDocumentDown","handleDocumentUp","erase","handleDocumentMouseMove","check","diffX","abs","diffY","maxSteps","round","max","subStepSize","min","smallerTest","startPoint","_i","_check","parentElement","input","handleInputBlur","handleInputKeyup","body","focus","closeInput","trim","_type","rects","window","getSelection","getRangeAt","getClientRects","getSelectionRects","saveRect","map","removeAllRanges","boundingRect","convertToSvgRect","_circleRadius","_circleColor","radius","svg_pt","saveCircle","_textSize","_textColor","srcElement","classList","contains","saveText","shiftKey","createScreenReaderOnly","createTextNode","overflow","insertElementWithinElement","insertBefore","textLayerElementFromPoint","temp","cloneNode","tail","outerHTML","insertElementWithinChildren","nodes","textLayer","insertScreenReaderComment","item","renderScreenReaderComments","comments","isArray","COMMENT_TYPES","reorderAnnotationsByType","removeAnnotation","renderScreenReaderHints","removeElementById","insertComment","removeComment","elementId","SORT_TYPES","sortBy","sort","num","first","last","includes","insertScreenReaderHint","sortByPoint","b","sortByRectPoint","lineA","lineB","PAGE_TEMPLATE","approximateFraction","floor","xinv","x_","q","roundToDivide","div","disableEdit","enableEdit","disablePen","enablePen","setPen","penSize","penColor","parseFloat","disablePoint","enablePoint","disableRect","enableRect","disableCircle","enableCircle","setCircle","circleColor","addCircle","oldType","disableArrow","enableArrow","setArrow","disableEraser","enableEraser","disableText","enableText","setText","textColor","createPage","children","canvas","mozOpaque","renderPage","renderOptions","pdfDocument","eventBus","pdfjsViewer","EventBus","all","getPage","_ref","_ref2","_slicedToArray","pdfPage","canvasContext","getContext","alpha","totalRotation","getViewport","wrapper","outputScale","ctx","devicePixelRatio","backingStoreRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","pixelRatio","sx","sy","scaled","sfx","sfy","visibility","scalePage","render","promise","getTextContent","normalizeWhitespace","textLayerBuilder","DefaultTextLayerFactory","createTextLayerBuilder","setTextContent","__storeAdapter","setStoreAdapter","adapter","UI","data","removeAttribute","_this$getStoreAdapter"],"sourceRoot":""} \ No newline at end of file