| 1 |
- !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],r):r(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CanvasPicker={}),t.window.G)}(this,(function(t,r){"use strict";function n(){n=function(){return t};var t={},r=Object.prototype,e=r.hasOwnProperty,i=Object.defineProperty||function(t,r,n){t[r]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function f(t,r,n){return Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,n){return t[r]=n}}function s(t,r,n,e){var o=Object.create((r&&r.prototype instanceof p?r:p).prototype),a=new A(e||[]);return i(o,"_invoke",{value:P(t,n,a)}),o}function h(t,r,n){try{return{type:"normal",arg:t.call(r,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var l={};function p(){}function v(){}function d(){}var y={};f(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(k([])));m&&m!==r&&e.call(m,a)&&(y=m);var x=d.prototype=p.prototype=Object.create(y);function M(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function b(t,r){function n(i,o,a,u){var c=h(t[i],t,o);if("throw"!==c.type){var f=c.arg,s=f.value;return s&&"object"==typeof s&&e.call(s,"__await")?r.resolve(s.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):r.resolve(s).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var o;i(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,i){n(t,e,r,i)}))}return o=o?o.then(i,i):i()}})}function P(t,r,n){var e="suspendedStart";return function(i,o){if("executing"===e)throw Error("Generator is already running");if("completed"===e){if("throw"===i)throw o;return E()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=w(a,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===e)throw e="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);e="executing";var c=h(t,r,n);if("normal"===c.type){if(e=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(e="completed",n.method="throw",n.arg=c.arg)}}}function w(t,r){var n=r.method,e=t.iterator[n];if(void 0===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=void 0,w(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var i=h(e,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,l;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function S(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function L(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function k(t){if(t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return v.prototype=d,i(x,"constructor",{value:d,configurable:!0}),i(d,"constructor",{value:v,configurable:!0}),v.displayName=f(d,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===v||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,f(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},M(b.prototype),f(b.prototype,u,(function(){return this})),t.AsyncIterator=b,t.async=function(r,n,e,i,o){void 0===o&&(o=Promise);var a=new b(s(r,n,e,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},M(x),f(x,c,"Generator"),f(x,a,(function(){return this})),f(x,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=Object(t),n=[];for(var e in r)n.push(e);return n.reverse(),function t(){for(;n.length;){var e=n.pop();if(e in r)return t.value=e,t.done=!1,t}return t.done=!0,t}},t.values=k,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,e){return a.type="throw",a.arg=t,r.next=n,e&&(r.method="next",r.arg=void 0),!!e}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var u=e.call(o,"catchLoc"),c=e.call(o,"finallyLoc");if(u&&c){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&e.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===t||"continue"===t)&&r>=o.tryLoc&&o.finallyLoc>=r&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),l},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),L(n),l}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc===t){var e=n.completion;if("throw"===e.type){var i=e.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}function e(t,r,n,e,i,o,a){try{var u=t[o](a),c=u.value}catch(t){return void n(t)}u.done?r(c):Promise.resolve(c).then(e,i)}function i(t,r){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},i(t,r)}function o(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=Array(r);r>n;n++)e[n]=t[n];return e}function a(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return o(t,r);var n=Object.prototype.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)?o(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var e=0;return function(){return t.length>e?{done:!1,value:t[e++]}:{done:!0}}}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 u="undefined"!=typeof Float32Array?Float32Array:Array;function c(){var t=new u(3);return u!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function f(t,r,n,e){return t[0]=r,t[1]=n,t[2]=e,t}Math.hypot||(Math.hypot=function(){for(var t=0,r=arguments.length;r--;)t+=arguments[r]*arguments[r];return Math.sqrt(t)});var s;s=c();!function(){var t,r=(t=new u(2),u!=Float32Array&&(t[0]=0,t[1]=0),t)}();var h,l=c(),p=c(),v=c(),d=(h=new u(16),u!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[11]=0,h[12]=0,h[13]=0,h[14]=0),h[0]=1,h[5]=1,h[10]=1,h[15]=1,h),y=function(){function t(){var t=this;this.context=void 0,this.runtime=void 0,this.isHit=function(n,e,i,o){var a=t.context.pointInPathPickerFactory[n.nodeName];if(a){var u=function(t,r){var n=r[0],e=r[1],i=r[2],o=r[3],a=r[4],u=r[5],c=r[6],f=r[7],s=r[8],h=r[9],l=r[10],p=r[11],v=r[12],d=r[13],y=r[14],g=r[15],m=n*u-e*a,x=n*c-i*a,M=n*f-o*a,b=e*c-i*u,P=e*f-o*u,w=i*f-o*c,S=s*d-h*v,L=s*y-l*v,A=s*g-p*v,k=h*y-l*d,E=h*g-p*d,O=l*g-p*y,F=m*O-x*E+M*k+b*A-P*L+w*S;return F?(t[0]=(u*O-c*E+f*k)*(F=1/F),t[1]=(i*E-e*O-o*k)*F,t[2]=(d*w-y*P+g*b)*F,t[3]=(l*P-h*w-p*b)*F,t[4]=(c*A-a*O-f*L)*F,t[5]=(n*O-i*A+o*L)*F,t[6]=(y*M-v*w-g*x)*F,t[7]=(s*w-l*M+p*x)*F,t[8]=(a*E-u*A+f*S)*F,t[9]=(e*A-n*E-o*S)*F,t[10]=(v*P-d*M+g*m)*F,t[11]=(h*M-s*P-p*m)*F,t[12]=(u*L-a*k-c*S)*F,t[13]=(n*k-e*L+i*S)*F,t[14]=(d*x-v*b-y*m)*F,t[15]=(s*b-h*x+l*m)*F,t):null}(d,i),c=function(t,r,n){var e=r[0],i=r[1],o=r[2],a=n[3]*e+n[7]*i+n[11]*o+n[15];return t[0]=(n[0]*e+n[4]*i+n[8]*o+n[12])/(a=a||1),t[1]=(n[1]*e+n[5]*i+n[9]*o+n[13])/a,t[2]=(n[2]*e+n[6]*i+n[10]*o+n[14])/a,t}(p,f(v,e[0],e[1],0),u),s=n.getGeometryBounds().halfExtents,h=n.parsedStyle.anchor;if(c[0]+=(h&&h[0]||0)*s[0]*2,c[1]+=(h&&h[1]||0)*s[1]*2,a(n,new r.Point(c[0],c[1]),o,t.isPointInPath,t.context,t.runtime))return!0}return!1},this.isPointInPath=function(r,n){var e=t.runtime.offscreenCanvas.getOrCreateContext(t.context.config.offscreenCanvas),i=t.context.pathGeneratorFactory[r.nodeName];return i&&(e.beginPath(),i(e,r.parsedStyle),e.closePath()),e.isPointInPath(n.x,n.y)}}var i=t.prototype;return i.apply=function(r,i){var o,a=this,u=r.renderingService,c=r.renderingContext;this.context=r,this.runtime=i;var f=null===(o=c.root)||void 0===o?void 0:o.ownerDocument;u.hooks.pick.tapPromise(t.tag,function(){var t,r=(t=n().mark((function t(r){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a.pick(f,r));case 1:case"end":return t.stop()}}),t)})),function(){var r=this,n=arguments;return new Promise((function(i,o){var a=t.apply(r,n);function u(t){e(a,i,o,u,c,"next",t)}function c(t){e(a,i,o,u,c,"throw",t)}u(void 0)}))});return function(t){return r.apply(this,arguments)}}()),u.hooks.pickSync.tap(t.tag,(function(t){return a.pick(f,t)}))},i.pick=function(t,n){for(var e,i=n.topmost,o=n.position,u=f(l,o.x,o.y,0),c=[],s=a(t.elementsFromBBox(u[0],u[1],u[0],u[1]));!(e=s()).done;){var h=e.value,p=h.getWorldTransform();if(this.isHit(h,u,p,!1)){var v=r.findClosestClipPathTarget(h);if(v){var d=v.parsedStyle.clipPath;if(this.isHit(d,u,d.getWorldTransform(),!0)){if(i)return n.picked=[h],n;c.push(h)}}else{if(i)return n.picked=[h],n;c.push(h)}}}return n.picked=c,n},t}();function g(t,r,n,e){var i=t-n,o=r-e;return Math.sqrt(i*i+o*o)}function m(t,r){return.001>Math.abs(t-r)}function x(t,r){var n=Math.min.apply(Math,t),e=Math.min.apply(Math,r);return{x:n,y:e,width:Math.max.apply(Math,t)-n,height:Math.max.apply(Math,r)-e}}function M(t){return(t+2*Math.PI)%(2*Math.PI)}y.tag="CanvasPicker";var b={box:function(t,r,n,e){return x([t,n],[r,e])},length:function(t,r,n,e){return g(t,r,n,e)},pointAt:function(t,r,n,e,i){return{x:(1-i)*t+i*n,y:(1-i)*r+i*e}},pointDistance:function(t,r,n,e,i,o){var a=(n-t)*(i-t)+(e-r)*(o-r);return 0>a?g(t,r,i,o):a>(n-t)*(n-t)+(e-r)*(e-r)?g(n,e,i,o):this.pointToLine(t,r,n,e,i,o)},pointToLine:function(t,r,n,e,i,o){var a=[n-t,e-r];if(function(t,r){return t[0]===r[0]&&t[1]===r[1]}(a,[0,0]))return Math.sqrt((i-t)*(i-t)+(o-r)*(o-r));var u=[-a[1],a[0]];return function(t,r){var n=r[0],e=r[1],i=n*n+e*e;i>0&&(i=1/Math.sqrt(i)),t[0]=r[0]*i,t[1]=r[1]*i}(u,u),Math.abs(function(t,r){return t[0]*r[0]+t[1]*r[1]}([i-t,o-r],u))},tangentAngle:function(t,r,n,e){return Math.atan2(e-r,n-t)}};function P(t,r,n,e,i,o){var a=-1,u=1/0,c=[n,e],f=20;o&&o>200&&(f=o/10);for(var s=1/f,h=s/10,l=0;f>=l;l++){var p=l*s,v=[i.apply(void 0,t.concat([p])),i.apply(void 0,r.concat([p]))],d=g(c[0],c[1],v[0],v[1]);u>d&&(a=p,u=d)}if(0===a)return{x:t[0],y:r[0]};if(1===a){var y=t.length;return{x:t[y-1],y:r[y-1]}}u=1/0;for(var m=0;32>m&&1e-4<=h;m++){var x=a-h,M=a+h,b=[i.apply(void 0,t.concat([x])),i.apply(void 0,r.concat([x]))],P=g(c[0],c[1],b[0],b[1]);if(x>=0&&u>P)a=x,u=P;else{var w=[i.apply(void 0,t.concat([M])),i.apply(void 0,r.concat([M]))],S=g(c[0],c[1],w[0],w[1]);1>=M&&u>S?(a=M,u=S):h*=.5}}return{x:i.apply(void 0,t.concat([a])),y:i.apply(void 0,r.concat([a]))}}function w(t,r,n,e){var i=1-e;return i*i*t+2*e*i*r+e*e*n}function S(t,r,n){var e=t+n-2*r;if(m(e,0))return[.5];var i=(t-r)/e;return i>1||0>i?[]:[i]}function L(t,r,n,e){return 2*(1-e)*(r-t)+2*e*(n-r)}function A(t,r,n,e,i,o,a){var u=w(t,n,i,a),c=w(r,e,o,a),f=b.pointAt(t,r,n,e,a),s=b.pointAt(n,e,i,o,a);return[[t,r,f.x,f.y,u,c],[u,c,s.x,s.y,i,o]]}function k(t,r,n,e,i,o,a){if(0===a)return(g(t,r,n,e)+g(n,e,i,o)+g(t,r,i,o))/2;var u=A(t,r,n,e,i,o,.5),c=u[0],f=u[1];return c.push(a-1),f.push(a-1),k.apply(void 0,c)+k.apply(void 0,f)}var E={box:function(t,r,n,e,i,o){var a=S(t,n,i)[0],u=S(r,e,o)[0],c=[t,i],f=[r,o];return void 0!==a&&c.push(w(t,n,i,a)),void 0!==u&&f.push(w(r,e,o,u)),x(c,f)},length:function(t,r,n,e,i,o){return k(t,r,n,e,i,o,3)},nearestPoint:function(t,r,n,e,i,o,a,u){return P([t,n,i],[r,e,o],a,u,w)},pointDistance:function(t,r,n,e,i,o,a,u){var c=this.nearestPoint(t,r,n,e,i,o,a,u);return g(c.x,c.y,a,u)},interpolationAt:w,pointAt:function(t,r,n,e,i,o,a){return{x:w(t,n,i,a),y:w(r,e,o,a)}},divide:function(t,r,n,e,i,o,a){return A(t,r,n,e,i,o,a)},tangentAngle:function(t,r,n,e,i,o,a){var u=L(t,n,i,a),c=L(r,e,o,a);return M(Math.atan2(c,u))}};function O(t,r,n,e,i){var o=1-i;return o*o*o*t+3*r*i*o*o+3*n*i*i*o+e*i*i*i}function F(t,r,n,e,i){var o=1-i;return 3*(o*o*(r-t)+2*o*i*(n-r)+i*i*(e-n))}function I(t,r,n,e){var i,o,a,u=-3*t+9*r-9*n+3*e,c=6*t-12*r+6*n,f=3*r-3*t,s=[];if(m(u,0))m(c,0)||0>(i=-f/c)||i>1||s.push(i);else{var h=c*c-4*u*f;m(h,0)?s.push(-c/(2*u)):h>0&&(o=(-c-(a=Math.sqrt(h)))/(2*u),0>(i=(-c+a)/(2*u))||i>1||s.push(i),0>o||o>1||s.push(o))}return s}function T(t,r,n,e,i,o,a,u,c){var f=O(t,n,i,a,c),s=O(r,e,o,u,c),h=b.pointAt(t,r,n,e,c),l=b.pointAt(n,e,i,o,c),p=b.pointAt(i,o,a,u,c),v=b.pointAt(h.x,h.y,l.x,l.y,c),d=b.pointAt(l.x,l.y,p.x,p.y,c);return[[t,r,h.x,h.y,v.x,v.y,f,s],[f,s,d.x,d.y,p.x,p.y,a,u]]}function C(t,r,n,e,i,o,a,u,c){if(0===c)return function(t,r){for(var n=0,e=t.length,i=0;e>i;i++)n+=g(t[i],r[i],t[(i+1)%e],r[(i+1)%e]);return n/2}([t,n,i,a],[r,e,o,u]);var f=T(t,r,n,e,i,o,a,u,.5),s=[].concat(f[0],[c-1]),h=[].concat(f[1],[c-1]);return C.apply(void 0,s)+C.apply(void 0,h)}var j={extrema:I,box:function(t,r,n,e,i,o,a,u){for(var c=[t,a],f=[r,u],s=I(t,n,i,a),h=I(r,e,o,u),l=0;s.length>l;l++)c.push(O(t,n,i,a,s[l]));for(var p=0;h.length>p;p++)f.push(O(r,e,o,u,h[p]));return x(c,f)},length:function(t,r,n,e,i,o,a,u){return C(t,r,n,e,i,o,a,u,3)},nearestPoint:function(t,r,n,e,i,o,a,u,c,f,s){return P([t,n,i,a],[r,e,o,u],c,f,O,s)},pointDistance:function(t,r,n,e,i,o,a,u,c,f,s){var h=this.nearestPoint(t,r,n,e,i,o,a,u,c,f,s);return g(h.x,h.y,c,f)},interpolationAt:O,pointAt:function(t,r,n,e,i,o,a,u,c){return{x:O(t,n,i,a,c),y:O(r,e,o,u,c)}},divide:function(t,r,n,e,i,o,a,u,c){return T(t,r,n,e,i,o,a,u,c)},tangentAngle:function(t,r,n,e,i,o,a,u,c){var f=F(t,n,i,a,c),s=F(r,e,o,u,c);return M(Math.atan2(s,f))}};function _(t,r,n,e){var i=t-n,o=r-e;return Math.sqrt(i*i+o*o)}function G(t,r,n,e,i,o){return!(t>i||i>t+n||r>o||o>r+e)}function W(t,r,n,e,i,o,a,u){var c=(Math.atan2(u-r,a-t)+2*Math.PI)%(2*Math.PI),f={x:t+n*Math.cos(c),y:r+n*Math.sin(c)};return _(f.x,f.y,a,u)<=o/2}function H(t,r,n,e,i,o,a){var u=i/2;return!(Math.min(t,n)-u>o||o>Math.max(t,n)+u||Math.min(r,e)-u>a||a>Math.max(r,e)+u)&&b.pointToLine(t,r,n,e,o,a)<=i/2}function N(t,r,n,e,i){var o=t.length;if(2>o)return!1;for(var a=0;o-1>a;a++){if(H(t[a][0],t[a][1],t[a+1][0],t[a+1][1],r,n,e))return!0}if(i){var u=t[0],c=t[o-1];if(H(u[0],u[1],c[0],c[1],r,n,e))return!0}return!1}var q=1e-6;function D(t){return q>Math.abs(t)?0:0>t?-1:1}function R(t,r,n){return!((n[0]-t[0])*(r[1]-t[1])!=(r[0]-t[0])*(n[1]-t[1])||Math.min(t[0],r[0])>n[0]||n[0]>Math.max(t[0],r[0])||Math.min(t[1],r[1])>n[1]||n[1]>Math.max(t[1],r[1]))}function Y(t,r,n){var e=!1,i=t.length;if(2>=i)return!1;for(var o=0;i>o;o++){var a=t[o],u=t[(o+1)%i];if(R(a,u,[r,n]))return!0;D(a[1]-n)>0!=D(u[1]-n)>0&&0>D(r-(n-a[1])*(a[0]-u[0])/(a[1]-u[1])-a[0])&&(e=!e)}return e}function X(t,r,n){for(var e=!1,i=0;t.length>i;i++){if(e=Y(t[i],r,n))break}return e}function B(t,n,e){var i=t.parsedStyle,o=i.r,a=i.fill,u=i.stroke,c=i.pointerEvents,f=((i.lineWidth||0)+(i.increasedLineWidthForHitTesting||0))/2,s=_(o,o,n.x,n.y),h=r.isFillOrStrokeAffected(c,a,u),l=h[0],p=h[1];return l&&p||e?o+f>=s:l?o>=s:!!p&&(s>=o-f&&o+f>=s)}function U(t,r,n,e){return t/(n*n)+r/(e*e)}function Q(t,n,e){var i=t.parsedStyle,o=i.rx,a=i.ry,u=i.lineWidth,c=i.increasedLineWidthForHitTesting,f=n.x,s=n.y,h=r.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),l=h[0],p=h[1],v=((u||0)+(c||0))/2,d=(f-o)*(f-o),y=(s-a)*(s-a);return l&&p||e?1>=U(d,y,o+v,a+v):l?1>=U(d,y,o,a):!!p&&(U(d,y,o-v,a-v)>=1&&1>=U(d,y,o+v,a+v))}function Z(t,n,e){var i=t.parsedStyle,o=i.x1,a=i.y1,u=i.x2,c=i.y2,f=i.lineWidth,s=i.increasedLineWidthForHitTesting,h=i.defX,l=void 0===h?0:h,p=i.defY,v=void 0===p?0:p;return!(!r.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke)[1]&&!e||!f)&&H(o,a,u,c,(f||0)+(s||0),n.x+l,n.y+v)}function $(t,r,n){return{x:t*Math.cos(n)-r*Math.sin(n),y:t*Math.sin(n)+r*Math.cos(n)}}function z(t,r,n,e,i,o,a,u,c,f){var s,h,l,p,v,d=t,y=r,g=n,m=e,x=u,M=c,b=120*Math.PI/180,P=Math.PI/180*(+i||0),w=[];if(f)h=f[0],l=f[1],p=f[2],v=f[3];else{y=(s=$(d,y,-P)).y;var S=((d=s.x)-(x=(s=$(x,M,-P)).x))/2,L=(y-(M=s.y))/2,A=S*S/(g*g)+L*L/(m*m);A>1&&(g*=A=Math.sqrt(A),m*=A);var k=g*g,E=m*m,O=(o===a?-1:1)*Math.sqrt(Math.abs((k*E-k*L*L-E*S*S)/(k*L*L+E*S*S)));p=O*g*L/m+(d+x)/2,h=Math.asin(((y-(v=O*-m*S/g+(y+M)/2))/m*1e9>>0)/1e9),l=Math.asin(((M-v)/m*1e9>>0)/1e9),0>(h=p>d?Math.PI-h:h)&&(h=2*Math.PI+h),0>(l=p>x?Math.PI-l:l)&&(l=2*Math.PI+l),a&&h>l&&(h-=2*Math.PI),!a&&l>h&&(l-=2*Math.PI)}var F=l-h;if(Math.abs(F)>b){var I=l,T=x,C=M;w=z(x=p+g*Math.cos(l=h+b*(a&&l>h?1:-1)),M=v+m*Math.sin(l),g,m,i,0,a,T,C,[l,I,p,v])}F=l-h;var j=Math.cos(h),_=Math.sin(h),G=Math.cos(l),W=Math.sin(l),H=Math.tan(F/4),N=4/3*g*H,q=4/3*m*H,D=[d,y],R=[d+N*_,y-q*j],Y=[x+N*W,M-q*G],X=[x,M];if(R[0]=2*D[0]-R[0],R[1]=2*D[1]-R[1],f)return R.concat(Y,X,w);for(var B=[],U=0,Q=(w=R.concat(Y,X,w)).length;Q>U;U+=1)B[U]=U%2?$(w[U-1],w[U],P).y:$(w[U],w[U+1],P).x;return B}function J(t,n,e,i,o,a){var u=t.parsedStyle,c=u.lineWidth,f=u.increasedLineWidthForHitTesting,s=u.defX,h=void 0===s?0:s,l=u.defY,p=void 0===l?0:l,v=u.path,d=v.segments,y=v.hasArc,g=v.polylines,m=v.polygons,x=r.isFillOrStrokeAffected(u.pointerEvents,(null==m?void 0:m.length)&&u.fill,u.stroke),M=x[0],b=x[1],P=r.getOrCalculatePathTotalLength(t),w=!1;return M||e?w=y?i(t,n):X(m,n.x+h,n.y+p)||X(g,n.x+h,n.y+p):((b||e)&&(w=function(t,r,n,e,i){for(var o=!1,a=r/2,u=0;t.length>u;u++){var c=t[u],f=c.currentPoint,s=c.params,h=c.prePoint,l=c.box;if(!l||G(l.x-a,l.y-a,l.width+r,l.height+r,n,e))switch(c.command){case"L":case"Z":if(o=H(h[0],h[1],f[0],f[1],r,n,e))return!0;break;case"Q":if(o=r/2>=E.pointDistance(h[0],h[1],s[1],s[2],s[3],s[4],n,e))return!0;break;case"C":if(o=r/2>=j.pointDistance(h[0],h[1],s[1],s[2],s[3],s[4],s[5],s[6],n,e,i))return!0;break;case"A":c.cubicParams||(c.cubicParams=z(h[0],h[1],s[1],s[2],s[3],s[4],s[5],s[6],s[7],void 0));for(var p=c.cubicParams,v=h,d=0;p.length>d;d+=6){var y=j.pointDistance(v[0],v[1],p[d],p[d+1],p[d+2],p[d+3],p[d+4],p[d+5],n,e,i);if(v=[p[d+4],p[d+5]],o=r/2>=y)return!0}}}return o}(d,(c||0)+(f||0),n.x+h,n.y+p,P)),w)}function K(t,n,e){var i=t.parsedStyle,o=i.lineWidth,a=i.increasedLineWidthForHitTesting,u=i.points,c=i.defX,f=void 0===c?0:c,s=i.defY,h=void 0===s?0:s,l=r.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),p=l[0],v=!1;return(l[1]||e)&&(v=N(u.points,(o||0)+(a||0),n.x+f,n.y+h,!0)),v||!p&&!e||(v=Y(u.points,n.x+f,n.y+h)),v}function V(t,n,e){var i=t.parsedStyle,o=i.lineWidth,a=i.increasedLineWidthForHitTesting,u=i.points,c=i.defX,f=void 0===c?0:c,s=i.defY,h=void 0===s?0:s;return!(!r.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke)[1]&&!e||!o)&&N(u.points,(o||0)+(a||0),n.x+f,n.y+h,!1)}function tt(t,n,e,i,o){var a=t.parsedStyle,u=a.radius,c=a.lineWidth,f=a.increasedLineWidthForHitTesting,s=a.width,h=a.height,l=r.isFillOrStrokeAffected(a.pointerEvents,a.fill,a.stroke),p=l[0],v=l[1],d=(c||0)+(f||0);if(u&&u.some((function(t){return 0!==t}))){var y=!1;return(v||e)&&(y=function(t,r,n,e,i,o,a,u){var c=i[0],f=i[1],s=i[2],h=i[3];return H(t+c,r,t+n-f,r,o,a,u)||H(t+n,r+f,t+n,r+e-s,o,a,u)||H(t+n-s,r+e,t+h,r+e,o,a,u)||H(t,r+e-h,t,r+c,o,a,u)||W(t+n-f,r+f,f,0,0,o,a,u)||W(t+n-s,r+e-s,s,0,0,o,a,u)||W(t+h,r+e-h,h,0,0,o,a,u)||W(t+c,r+c,c,0,0,o,a,u)}(0,0,s,h,u.map((function(t){return r=t,n=0,e=Math.min(Math.abs(s)/2,Math.abs(h)/2),n>r?n:r>e?e:r;var r,n,e})),d,n.x,n.y)),y||!p&&!e||(y=i(t,n)),y}var g=d/2;return p&&v||e?G(0-g,0-g,s+g,h+g,n.x,n.y):p?G(0,0,s,h,n.x,n.y):!!v&&function(t,r,n,e,i,o,a){var u=i/2;return G(t-u,r-u,n,i,o,a)||G(t+n-u,r-u,i,e,o,a)||G(t+u,r+e-u,n,i,o,a)||G(t-u,r+u,i,e,o,a)}(0,0,s,h,d,n.x,n.y)}function rt(t,n,e,i,o,a){var u=t.parsedStyle,c=u.width,f=u.height;if("non-transparent-pixel"===u.pointerEvents){var s=o.config.offscreenCanvas,h=a.offscreenCanvas.getOrCreateCanvas(s),l=a.offscreenCanvas.getOrCreateContext(s,{willReadFrequently:!0});return h.width=c,h.height=f,o.defaultStyleRendererFactory[r.Shape.IMAGE].render(l,t.parsedStyle,t,void 0,void 0,void 0),l.getImageData(n.x,n.y,1,1).data.every((function(t){return 0!==t}))}return!0}var nt=function(t){var n,e;function o(){for(var r,n=arguments.length,e=Array(n),i=0;n>i;i++)e[i]=arguments[i];return(r=t.call.apply(t,[this].concat(e))||this).name="canvas-picker",r}(n=o).prototype=Object.create((e=t).prototype),n.prototype.constructor=n,i(n,e);var a=o.prototype;return a.init=function(){var t,n=((t={})[r.Shape.CIRCLE]=B,t[r.Shape.ELLIPSE]=Q,t[r.Shape.RECT]=tt,t[r.Shape.LINE]=Z,t[r.Shape.POLYLINE]=V,t[r.Shape.POLYGON]=K,t[r.Shape.PATH]=J,t[r.Shape.TEXT]=function(){return!0},t[r.Shape.GROUP]=null,t[r.Shape.IMAGE]=rt,t[r.Shape.HTML]=null,t[r.Shape.MESH]=null,t);this.context.pointInPathPickerFactory=n,this.addRenderingPlugin(new y)},a.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},o}(r.AbstractRendererPlugin);t.Plugin=nt,Object.defineProperty(t,"__esModule",{value:!0})}));
|