From ef5926e185a5b902a1b6846c9f387ea1772c25bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fa=CC=81bio=20Madeira?= Date: Thu, 7 Nov 2024 10:29:33 +0000 Subject: [PATCH 1/6] cicd: updates setup for github actions --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c6dd84..62f83f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: jdispatcher-viewers on: [push] jobs: check: - runs-on: node:18.20-alpine3.19 + runs-on: ubuntu-latest steps: #---------------------------------------------- # Check-out repo and set-up python @@ -17,6 +17,10 @@ jobs: #---------------------------------------------- # Try a "clean" install (without forcing dependencies) #---------------------------------------------- + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18.20' - name: Clean install run: npm install --dry-run #---------------------------------------------- From a712f173b9311119708e5d1549710222b41a548a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fa=CC=81bio=20Madeira?= Date: Thu, 7 Nov 2024 10:39:11 +0000 Subject: [PATCH 2/6] cicd: fix install commands for ubuntu --- .github/workflows/build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62f83f2..12a6ba1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,9 @@ jobs: # Install Canvas/Fabric dependencies #---------------------------------------------- - name: Install Canvas/Fabric Dependencies - run: apk add --no-cache build-base g++ cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev + run: | + sudo apt update && apt install -y build-essential \ + g++ libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev #---------------------------------------------- # Try a "clean" install (without forcing dependencies) #---------------------------------------------- @@ -29,7 +31,8 @@ jobs: - name: Check lockfile run: | - npm install --force - - git ls-files -m | grep -q package-lock.json && { echo "WARNING - Lock file is outdated!" && exit 1; } + - git ls-files -m | grep -q package-lock.json \ + && { echo "WARNING - Lock file is outdated!" && exit 1; } - exit 0 #---------------------------------------------- # Run npm audit From 842ed6df8d459dc4a4029f543b447e58cae74d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fa=CC=81bio=20Madeira?= Date: Thu, 7 Nov 2024 10:40:36 +0000 Subject: [PATCH 3/6] cicd: bugfix --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12a6ba1..8e4134d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,8 @@ jobs: #---------------------------------------------- - name: Install Canvas/Fabric Dependencies run: | - sudo apt update && apt install -y build-essential \ + sudo apt update + sudo apt install -y build-essential \ g++ libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev #---------------------------------------------- # Try a "clean" install (without forcing dependencies) From ce13dface745c406b4169627f1ae2e8c107a7137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fa=CC=81bio=20Madeira?= Date: Thu, 7 Nov 2024 10:42:32 +0000 Subject: [PATCH 4/6] cicd: bugfix commands --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e4134d..ec3947d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,10 +31,10 @@ jobs: #---------------------------------------------- - name: Check lockfile run: | - - npm install --force - - git ls-files -m | grep -q package-lock.json \ + npm install --force + git ls-files -m | grep -q package-lock.json \ && { echo "WARNING - Lock file is outdated!" && exit 1; } - - exit 0 + exit 0 #---------------------------------------------- # Run npm audit #---------------------------------------------- From 795f5d328a74a7238a27f1c62d582a4828487a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fa=CC=81bio=20Madeira?= Date: Thu, 7 Nov 2024 10:47:00 +0000 Subject: [PATCH 5/6] chore: update package-lock.json --- package-lock.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package-lock.json b/package-lock.json index f54f3ff..9c1e05f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,9 @@ "stream": "^0.0.2", "xml-js": "^1.6.11" }, + "bin": { + "jdispatcher-viewers": "bin/app.js" + }, "devDependencies": { "@types/jest": "^29.5.14", "@typescript-eslint/eslint-plugin": "^5.62.0", From 4d80117e557f0ebc06bddb12a6a8128f09f686d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fa=CC=81bio=20Madeira?= Date: Thu, 7 Nov 2024 10:49:43 +0000 Subject: [PATCH 6/6] build: add new build and bump version in the index.html --- bin/custom-types.js | 6 ++++ dist/jd_viewers_0.0.11.bundle.min.js | 2 ++ ...d_viewers_0.0.11.bundle.min.js.LICENSE.txt | 32 +++++++++++++++++++ index.html | 2 +- package-lock.json | 4 +-- package.json | 2 +- 6 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 dist/jd_viewers_0.0.11.bundle.min.js create mode 100644 dist/jd_viewers_0.0.11.bundle.min.js.LICENSE.txt diff --git a/bin/custom-types.js b/bin/custom-types.js index 7777c75..43153c9 100644 --- a/bin/custom-types.js +++ b/bin/custom-types.js @@ -20,3 +20,9 @@ export const objectDefaults = { export const textDefaults = { ...objectDefaults }; export const rectDefaults = { ...objectDefaults }; export const lineDefaults = { ...objectDefaults }; +export function toPositiveNumber(value) { + if (value < 0) { + throw new Error(`${value} is not a positive number`); + } + return value; +} diff --git a/dist/jd_viewers_0.0.11.bundle.min.js b/dist/jd_viewers_0.0.11.bundle.min.js new file mode 100644 index 0000000..3eb2e1d --- /dev/null +++ b/dist/jd_viewers_0.0.11.bundle.min.js @@ -0,0 +1,2 @@ +/*! For license information please see jd_viewers_0.0.11.bundle.min.js.LICENSE.txt */ +(()=>{var t={526:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,s=a(t),o=s[0],h=s[1],c=new r(function(t,e,i){return 3*(e+i)/4-i}(0,o,h)),l=0,u=h>0?o-4:o;for(i=0;i>16&255,c[l++]=e>>8&255,c[l++]=255&e;return 2===h&&(e=n[t.charCodeAt(i)]<<2|n[t.charCodeAt(i+1)]>>4,c[l++]=255&e),1===h&&(e=n[t.charCodeAt(i)]<<10|n[t.charCodeAt(i+1)]<<4|n[t.charCodeAt(i+2)]>>2,c[l++]=e>>8&255,c[l++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,r=n%3,s=[],o=16383,a=0,c=n-r;ac?c:a+o));return 1===r?(e=t[n-1],s.push(i[e>>2]+i[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],s.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"=")),s.join("")};for(var i=[],n=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)i[o]=s[o],n[s.charCodeAt(o)]=o;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function h(t,e,n){for(var r,s,o=[],a=e;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},38:(t,e)=>{"use strict";var i="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},n="undefined"!=typeof window&&void 0!==window.document,r="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;"object"===("undefined"==typeof self?"undefined":i(self))&&self.constructor&&self.constructor.name,"undefined"!=typeof window&&"nodejs"===window.name||"undefined"!=typeof navigator&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")),"undefined"!=typeof Deno&&void 0!==Deno.version&&Deno.version.deno;e.Bd=n,e.Ll=r},287:(t,e,i)=>{"use strict";const n=i(526),r=i(251),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return+t!=t&&(t=0),h.alloc(+t)},e.INSPECT_MAX_BYTES=50;const o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,i){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return c(t,e,i)}function c(t,e,i){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const i=0|g(t,e);let n=a(i);const r=n.write(t,e);return r!==i&&(n=n.slice(0,r)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return d(t,e,i);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return d(t,e,i);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return h.from(n,e,i);const r=function(t){if(h.isBuffer(t)){const e=0|p(t.length),i=a(e);return 0===i.length||t.copy(i,0,0,e),i}return void 0!==t.length?"number"!=typeof t.length||K(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return l(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),i=a(e);for(let n=0;n=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const i=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return V(t).length;default:if(r)return n?-1:Y(t).length;e=(""+e).toLowerCase(),r=!0}}function m(t,e,i){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,i);case"utf8":case"utf-8":return E(this,e,i);case"ascii":return P(this,e,i);case"latin1":case"binary":return A(this,e,i);case"base64":return T(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function y(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),K(i=+i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:b(t,e,i,n,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):b(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function b(t,e,i,n,r){let s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){let n=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=e.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function T(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function E(t,e,i){i=Math.min(t.length,i);const n=[];let r=e;for(;r239?4:e>223?3:e>191?2:1;if(r+o<=i){let i,n,a,h;switch(o){case 1:e<128&&(s=e);break;case 2:i=t[r+1],128==(192&i)&&(h=(31&e)<<6|63&i,h>127&&(s=h));break;case 3:i=t[r+1],n=t[r+2],128==(192&i)&&128==(192&n)&&(h=(15&e)<<12|(63&i)<<6|63&n,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:i=t[r+1],n=t[r+2],a=t[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(h=(15&e)<<18|(63&i)<<12|(63&n)<<6|63&a,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(t){const e=t.length;if(e<=O)return String.fromCharCode.apply(String,t);let i="",n=0;for(;nn.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(n,r)):Uint8Array.prototype.set.call(n,e,r);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,r)}r+=e.length}return n},h.byteLength=g,h.prototype._isBuffer=!0,h.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;ei&&(t+=" ... "),""},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(t,e,i,n,r){if(q(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0);const a=Math.min(s,o),c=this.slice(n,r),l=t.slice(e,i);for(let t=0;t>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}const r=this.length-e;if((void 0===i||i>r)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return _(this,t,e,i);case"utf8":case"utf-8":return x(this,t,e,i);case"ascii":case"latin1":case"binary":return S(this,t,e,i);case"base64":return C(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const O=4096;function P(t,e,i){let n="";i=Math.min(t.length,i);for(let r=e;rn)&&(i=n);let r="";for(let n=e;ni)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function F(t,e,i,n,r){U(e,n,r,t,i,7);let s=Number(e&BigInt(4294967295));t[i++]=s,s>>=8,t[i++]=s,s>>=8,t[i++]=s,s>>=8,t[i++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[i++]=o,o>>=8,t[i++]=o,o>>=8,t[i++]=o,o>>=8,t[i++]=o,i}function L(t,e,i,n,r){U(e,n,r,t,i,7);let s=Number(e&BigInt(4294967295));t[i+7]=s,s>>=8,t[i+6]=s,s>>=8,t[i+5]=s,s>>=8,t[i+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[i+3]=o,o>>=8,t[i+2]=o,o>>=8,t[i+1]=o,o>>=8,t[i]=o,i+8}function M(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function R(t,e,i,n,s){return e=+e,i>>>=0,s||M(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function B(t,e,i,n,s){return e=+e,i>>>=0,s||M(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){const i=this.length;(t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e>>=0,e>>>=0,i||j(t,e,this.length);let n=this[t],r=1,s=0;for(;++s>>=0,e>>>=0,i||j(t,e,this.length);let n=this[t+--e],r=1;for(;e>0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||j(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||j(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||j(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||j(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||j(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=J((function(t){H(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||G(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,r=this[++t]+256*this[++t]+65536*this[++t]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||G(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],r=this[++t]*2**24+65536*this[++t]+256*this[++t]+i;return(BigInt(n)<>>=0,e>>>=0,i||j(t,e,this.length);let n=this[t],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||j(t,e,this.length);let n=e,r=1,s=this[t+--n];for(;n>0&&(r*=256);)s+=this[t+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return t>>>=0,e||j(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||j(t,2,this.length);const i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){t>>>=0,e||j(t,2,this.length);const i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||j(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||j(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=J((function(t){H(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||G(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(i<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||G(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||j(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||j(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||j(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||j(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||I(this,t,e,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[e]=255&t;++s>>=0,i>>>=0,n||I(this,t,e,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[e+r]=255&t;--r>=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=J((function(t,e=0){return F(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=J((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);I(this,t,e,i,n-1,-n)}let r=0,s=1,o=0;for(this[e]=255&t;++r>>=0,!n){const n=Math.pow(2,8*i-1);I(this,t,e,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[e+r]=255&t;--r>=0&&(s*=256);)t<0&&0===o&&0!==this[e+r+1]&&(o=1),this[e+r]=(t/s|0)-o&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=J((function(t,e=0){return F(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=J((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,i){return R(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return R(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return B(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return B(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(r=e;r=n+4;i-=3)e=`_${t.slice(i-3,i)}${e}`;return`${t.slice(0,i)}${e}`}function U(t,e,i,n,r,s){if(t>i||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${e}${n} and <= ${i}${n}`,new W.ERR_OUT_OF_RANGE("value",r,t)}!function(t,e,i){H(e,"offset"),void 0!==t[e]&&void 0!==t[e+i]||G(e,t.length-(i+1))}(n,r,s)}function H(t,e){if("number"!=typeof t)throw new W.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,i){if(Math.floor(t)!==t)throw H(t,i),new W.ERR_OUT_OF_RANGE(i||"offset","an integer",t);if(e<0)throw new W.ERR_BUFFER_OUT_OF_BOUNDS;throw new W.ERR_OUT_OF_RANGE(i||"offset",`>= ${i?1:0} and <= ${e}`,t)}N("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),N("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),N("ERR_OUT_OF_RANGE",(function(t,e,i){let n=`The value of "${t}" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=z(String(i)):"bigint"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=z(r)),r+="n"),n+=` It must be ${e}. Received ${r}`,n}),RangeError);const X=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let i;e=e||1/0;const n=t.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function V(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function $(t,e,i,n){let r;for(r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function K(t){return t!=t}const Q=function(){const t="0123456789abcdef",e=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)e[n+r]=t[i]+t[r]}return e}();function J(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},995:t=>{function e(t){if(t)return function(t){for(var i in e.prototype)t[i]=e.prototype[i];return t}(t)}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},e.prototype.once=function(t,e){var i=this;function n(){i.off(t,n),e.apply(this,arguments)}return this._callbacks=this._callbacks||{},n.fn=e,this.on(t,n),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i,n=this._callbacks[t];if(!n)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var r=0;r{var n,r,s,o,a,h,c,l,u,f,d,p,g,m,v,y,b,_,x,S,C,w,T=T||{version:"5.4.0"};if(e.fabric=T,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?T.document=document:T.document=document.implementation.createHTMLDocument(""),T.window=window;else{var E=new(i(574).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;T.document=E.document,T.jsdomImplForWrapper=i(748).implForWrapper,T.nodeCanvas=i(246).Canvas,T.window=E,DOMParser=T.window.DOMParser}function O(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var s=i.height-n.height;r.drawImage(i,0,s,n.width,n.height,0,0,n.width,n.height)}function P(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,s=n*r*4,o=new Uint8Array(this.imageBuffer,0,s),a=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,o);var h=new ImageData(a,n,r);i.putImageData(h,0,0)}T.isTouchSupported="ontouchstart"in T.window||"ontouchstart"in T.document||T.window&&T.window.navigator&&T.window.navigator.maxTouchPoints>0,T.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,T.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],T.DPI=96,T.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",T.commaWsp="(?:\\s+,?\\s*|,\\s*)",T.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,T.reNonWord=/[ \n\.,;!\?\-]/,T.fontPaths={},T.iMatrix=[1,0,0,1,0,0],T.svgNS="http://www.w3.org/2000/svg",T.perfLimitSizeTotal=2097152,T.maxCacheSideLimit=4096,T.minCacheSideLimit=256,T.charWidthsCache={},T.textureSize=2048,T.disableStyleCopyPaste=!1,T.enableGLFiltering=!0,T.devicePixelRatio=T.window.devicePixelRatio||T.window.webkitDevicePixelRatio||T.window.mozDevicePixelRatio||1,T.browserShadowBlurConstant=1,T.arcToSegmentsCache={},T.boundsOfCurveCache={},T.cachesBoundsOfCurve=!0,T.forceGLPutImageData=!1,T.initFilterBackend=function(){return T.enableGLFiltering&&T.isWebglSupported&&T.isWebglSupported(T.textureSize)?(console.log("max texture size: "+T.maxTextureSize),new T.WebglFilterBackend({tileSize:T.textureSize})):T.Canvas2dFilterBackend?new T.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=T),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:T.util.array.fill(i,!1)}}function e(t,e){var i=function(){e.apply(this,arguments),this.off(t,i)}.bind(this);this.on(t,i)}T.Observable={fire:function(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n-1||!!e&&this._objects.some((function(e){return"function"==typeof e.contains&&e.contains(t,!0)}))},complexity:function(){return this._objects.reduce((function(t,e){return t+(e.complexity?e.complexity():0)}),0)}},T.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof T.Gradient||this.set(e,new T.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof T.Pattern?i&&i():this.set(e,new T.Pattern(t,i))},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},n=e,r=Math.sqrt,s=Math.atan2,o=Math.pow,a=Math.PI/180,h=Math.PI/2,T.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/h){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/h){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*a},radiansToDegrees:function(t){return t/a},rotatePoint:function(t,e,i){var n=new T.Point(t.x-e.x,t.y-e.y),r=T.util.rotateVector(n,i);return new T.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=T.util.sin(e),n=T.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},createVector:function(t,e){return new T.Point(e.x-t.x,e.y-t.y)},calcAngleBetweenVectors:function(t,e){return Math.acos((t.x*e.x+t.y*e.y)/(Math.hypot(t.x,t.y)*Math.hypot(e.x,e.y)))},getHatVector:function(t){return new T.Point(t.x,t.y).multiply(1/Math.hypot(t.x,t.y))},getBisector:function(t,e,i){var n=T.util.createVector(t,e),r=T.util.createVector(t,i),s=T.util.calcAngleBetweenVectors(n,r),o=s*(0===T.util.calcAngleBetweenVectors(T.util.rotateVector(n,s),r)?1:-1)/2;return{vector:T.util.getHatVector(T.util.rotateVector(n,o)),angle:s}},projectStrokeOnPoints:function(t,e,i){var n=[],r=e.strokeWidth/2,s=e.strokeUniform?new T.Point(1/e.scaleX,1/e.scaleY):new T.Point(1,1),o=function(t){var e=r/Math.hypot(t.x,t.y);return new T.Point(t.x*e*s.x,t.y*e*s.y)};return t.length<=1||t.forEach((function(a,h){var c,l,u=new T.Point(a.x,a.y);0===h?(l=t[h+1],c=i?o(T.util.createVector(l,u)).addEquals(u):t[t.length-1]):h===t.length-1?(c=t[h-1],l=i?o(T.util.createVector(c,u)).addEquals(u):t[0]):(c=t[h-1],l=t[h+1]);var f,d,p=T.util.getBisector(u,c,l),g=p.vector,m=p.angle;if("miter"===e.strokeLineJoin&&(f=-r/Math.sin(m/2),d=new T.Point(g.x*f*s.x,g.y*f*s.y),Math.hypot(d.x,d.y)/r<=e.strokeMiterLimit))return n.push(u.add(d)),void n.push(u.subtract(d));f=-r*Math.SQRT2,d=new T.Point(g.x*f*s.x,g.y*f*s.y),n.push(u.add(d)),n.push(u.subtract(d))})),n},transformPoint:function(t,e,i){return i?new T.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new T.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,s=!0,o=t.getImageData(e,i,2*n||1,2*n||1),a=o.data.length;for(r=3;r0&&(T.util.hasStyleChanged(r,h,!0)?s.push({start:n,end:n+1,style:h}):s[s.length-1].end++),r=h||{}}else n+=i[o].length;return s},stylesFromArray:function(t,e){if(!Array.isArray(t))return t;for(var i=e.split("\n"),n=-1,r=0,s={},o=0;o=r?s-r:2*Math.PI-(r-s)}function s(t,e,i){for(var s=i[1],o=i[2],a=i[3],h=i[4],c=i[5],l=function(t,e,i,s,o,a,h){var c=Math.PI,l=h*c/180,u=T.util.sin(l),f=T.util.cos(l),d=0,p=0,g=-f*t*.5-u*e*.5,m=-f*e*.5+u*t*.5,v=(i=Math.abs(i))*i,y=(s=Math.abs(s))*s,b=m*m,_=g*g,x=v*y-v*b-y*_,S=0;if(x<0){var C=Math.sqrt(1-x/(v*y));i*=C,s*=C}else S=(o===a?-1:1)*Math.sqrt(x/(v*b+y*_));var w=S*i*m/s,E=-S*s*g/i,O=f*w-u*E+.5*t,P=u*w+f*E+.5*e,A=r(1,0,(g-w)/i,(m-E)/s),k=r((g-w)/i,(m-E)/s,(-g-w)/i,(-m-E)/s);0===a&&k>0?k-=2*c:1===a&&k<0&&(k+=2*c);for(var D=Math.ceil(Math.abs(k/c*2)),j=[],I=k/D,F=8/3*Math.sin(I/4)*Math.sin(I/4)/Math.sin(I/2),L=A+I,M=0;MS)for(var w=1,E=g.length;w2;for(e=e||0,c&&(a=t[2].xt[i-2].x?1:r.x===t[i-2].x?0:-1,h=r.y>t[i-2].y?1:r.y===t[i-2].y?0:-1),n.push(["L",r.x+a*e,r.y+h*e]),n},T.util.getPathSegmentsInfo=f,T.util.getBoundsOfCurve=function(e,i,n,r,s,o,a,h){var c;if(T.cachesBoundsOfCurve&&(c=t.call(arguments),T.boundsOfCurveCache[c]))return T.boundsOfCurveCache[c];var l,u,f,d,p,g,m,v,y=Math.sqrt,b=Math.min,_=Math.max,x=Math.abs,S=[],C=[[],[]];u=6*e-12*n+6*s,l=-3*e+9*n-9*s+3*a,f=3*n-3*e;for(var w=0;w<2;++w)if(w>0&&(u=6*i-12*r+6*o,l=-3*i+9*r-9*o+3*h,f=3*r-3*i),x(l)<1e-12){if(x(u)<1e-12)continue;0<(d=-f/u)&&d<1&&S.push(d)}else(m=u*u-4*f*l)<0||(0<(p=(-u+(v=y(m)))/(2*l))&&p<1&&S.push(p),0<(g=(-u-v)/(2*l))&&g<1&&S.push(g));for(var E,O,P,A=S.length,k=A;A--;)E=(P=1-(d=S[A]))*P*P*e+3*P*P*d*n+3*P*d*d*s+d*d*d*a,C[0][A]=E,O=P*P*P*i+3*P*P*d*r+3*P*d*d*o+d*d*d*h,C[1][A]=O;C[0][k]=e,C[1][k]=i,C[0][k+1]=a,C[1][k+1]=h;var D=[{x:b.apply(null,C[0]),y:b.apply(null,C[1])},{x:_.apply(null,C[0]),y:_.apply(null,C[1])}];return T.cachesBoundsOfCurve&&(T.boundsOfCurveCache[c]=D),D},T.util.getPointOnPath=function(t,e,i){i||(i=f(t));for(var n=0;e-i[n].length>0&&n1e-4;)i=h(s),r=s,(n=o(c.x,c.y,i.x,i.y))+a>e?(s-=l,l/=2):(c=i,s+=l,a+=n);return i.angle=u(r),i}(s,e)}},T.util.transformPath=function(t,e,i){return i&&(e=T.util.multiplyTransformMatrices(e,[1,0,0,1,-i.x,-i.y])),t.map((function(t){for(var i=t.slice(0),n={},r=1;r=e}))}}}(),function(){function t(e,i,n){if(n)if(!T.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var r=0,s=i.length;r57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}T.util.string={camelize:function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")},graphemeSplit:function(e){var i,n=0,r=[];for(n=0;n-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function r(){}function s(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}T.util.createClass=function(){var i=null,o=t.call(arguments,0);function a(){this.initialize.apply(this,arguments)}"function"==typeof o[0]&&(i=o.shift()),a.superclass=i,a.subclasses=[],i&&(r.prototype=i.prototype,a.prototype=new r,i.subclasses.push(a));for(var h=0,c=o.length;h-1||"touch"===t.pointerType},f="string"==typeof(u=T.document.createElement("div")).style.opacity,d="string"==typeof u.style.filter,p=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,g=function(t){return t},f?g=function(t,e){return t.style.opacity=e,t}:d&&(g=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),p.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(p,e)):i.filter+=" alpha(opacity="+100*e+")",t}),T.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?g(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)if("opacity"===n)g(t,e[n]);else{var r="float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n;i.setProperty(r,e[n])}return t},function(){var t,e,i,n,r=Array.prototype.slice,s=function(t){return r.call(t,0)};try{t=s(T.document.childNodes)instanceof Array}catch(t){}function o(t,e){var i=T.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function a(t){for(var e=0,i=0,n=T.document.documentElement,r=T.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===T.document?(e=r.scrollLeft||n.scrollLeft||0,i=r.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}t||(s=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),e=T.document.defaultView&&T.document.defaultView.getComputedStyle?function(t,e){var i=T.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},i=T.document.documentElement.style,n="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"",T.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=T.util.falseFunction),n?t.style[n]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},T.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),n?t.style[n]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},T.util.setImageSmoothing=function(t,e){t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=e},T.util.getById=function(t){return"string"==typeof t?T.document.getElementById(t):t},T.util.toArray=s,T.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},T.util.makeElement=o,T.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=o(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},T.util.getScrollLeftTop=a,T.util.getElementOffset=function(t){var i,n,r=t&&t.ownerDocument,s={left:0,top:0},o={left:0,top:0},h={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return o;for(var c in h)o[h[c]]+=parseInt(e(t,c),10)||0;return i=r.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),n=a(t),{left:s.left+n.left-(i.clientLeft||0)+o.left,top:s.top+n.top-(i.clientTop||0)+o.top}},T.util.getNodeCanvas=function(t){var e=T.jsdomImplForWrapper(t);return e._canvas||e._image},T.util.cleanUpJsdomNode=function(t){if(T.isLikelyNode){var e=T.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}T.util.request=function(e,i){i||(i={});var n=i.method?i.method.toUpperCase():"GET",r=i.onComplete||function(){},s=new T.window.XMLHttpRequest,o=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(r(s),s.onreadystatechange=t)},"GET"===n&&(o=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(n,e,!0),"POST"!==n&&"PUT"!==n||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(o),s}}(),T.log=console.log,T.warn=console.warn,function(){var t=T.util.object.extend,e=T.util.object.clone,i=[];function n(){return!1}function r(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}T.util.object.extend(i,{cancelAll:function(){var t=this.splice(0);return t.forEach((function(t){t.cancel()})),t},cancelByCanvas:function(t){if(!t)return[];var e=this.filter((function(e){return"object"==typeof e.target&&e.target.canvas===t}));return e.forEach((function(t){t.cancel()})),e},cancelByTarget:function(t){var e=this.findAnimationsByTarget(t);return e.forEach((function(t){t.cancel()})),e},findAnimationIndex:function(t){return this.indexOf(this.findAnimation(t))},findAnimation:function(t){return this.find((function(e){return e.cancel===t}))},findAnimationsByTarget:function(t){return t?this.filter((function(e){return e.target===t})):[]}});var s=T.window.requestAnimationFrame||T.window.webkitRequestAnimationFrame||T.window.mozRequestAnimationFrame||T.window.oRequestAnimationFrame||T.window.msRequestAnimationFrame||function(t){return T.window.setTimeout(t,1e3/60)},o=T.window.cancelAnimationFrame||T.window.clearTimeout;function a(){return s.apply(T.window,arguments)}T.util.animate=function(i){i||(i={});var s,o=!1,h=function(){var t=T.runningAnimations.indexOf(s);return t>-1&&T.runningAnimations.splice(t,1)[0]};return s=t(e(i),{cancel:function(){return o=!0,h()},currentValue:"startValue"in i?i.startValue:0,completionRate:0,durationRate:0}),T.runningAnimations.push(s),a((function(t){var e,c=t||+new Date,l=i.duration||500,u=c+l,f=i.onChange||n,d=i.abort||n,p=i.onComplete||n,g=i.easing||r,m="startValue"in i&&i.startValue.length>0,v="startValue"in i?i.startValue:0,y="endValue"in i?i.endValue:100,b=i.byValue||(m?v.map((function(t,e){return y[e]-v[e]})):y-v);i.onStart&&i.onStart(),function t(i){var n=(e=i||+new Date)>u?l:e-c,r=n/l,_=m?v.map((function(t,e){return g(n,v[e],b[e],l)})):g(n,v,b,l),x=m?Math.abs((_[0]-v[0])/b[0]):Math.abs((_-v)/b);if(s.currentValue=m?_.slice():_,s.completionRate=x,s.durationRate=r,!o){if(!d(_,x,r))return e>u?(s.currentValue=m?y.slice():y,s.completionRate=1,s.durationRate=1,f(m?y.slice():y,1,1),p(y,1,1),void h()):(f(_,x,r),void a(t));h()}}(c)})),s.cancel},T.util.requestAnimFrame=a,T.util.cancelAnimFrame=function(){return o.apply(T.window,arguments)},T.runningAnimations=i}(),function(){function t(t,e,i){var n="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return(n+=","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1))+")"}T.util.animateColor=function(e,i,n,r){var s=new T.Color(e).getSource(),o=new T.Color(i).getSource(),a=r.onComplete,h=r.onChange;return r=r||{},T.util.animate(T.util.object.extend(r,{duration:n||500,startValue:s,endValue:o,byValue:o,easing:function(e,i,n,s){return t(i,n,r.colorEasing?r.colorEasing(e,s):1-Math.cos(e/s*(Math.PI/2)))},onComplete:function(e,i,n){if(a)return a(t(o,o,0),i,n)},onChange:function(e,i,n){if(h){if(Array.isArray(e))return h(t(e,e,0),i,n);h(e,i,n)}}}))}}(),function(){function t(t,e,i,n){return t-1&&l>-1&&l-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t||"font"===t)return i;if("imageSmoothing"===t)return"optimizeQuality"===i;a=h?i.map(s):s(i,r)}}else i="";return!h&&isNaN(a)?i:a}function d(t){return new RegExp("^("+t.join("|")+")\\b","i")}function p(t,e){var i,n,r,s,o=[];for(r=0,s=e.length;r1;)h.shift(),c=e.util.multiplyTransformMatrices(c,h[0]);return c}}();var y=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function b(t){if(!e.svgViewBoxElementsRegEx.test(t.nodeName))return{};var i,n,r,o,a,h,c=t.getAttribute("viewBox"),l=1,u=1,f=t.getAttribute("width"),d=t.getAttribute("height"),p=t.getAttribute("x")||0,g=t.getAttribute("y")||0,m=t.getAttribute("preserveAspectRatio")||"",v=!c||!(c=c.match(y)),b=!f||!d||"100%"===f||"100%"===d,_=v&&b,x={},S="",C=0,w=0;if(x.width=0,x.height=0,x.toBeParsed=_,v&&(p||g)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(S=" translate("+s(p)+" "+s(g)+") ",a=(t.getAttribute("transform")||"")+S,t.setAttribute("transform",a),t.removeAttribute("x"),t.removeAttribute("y")),_)return x;if(v)return x.width=s(f),x.height=s(d),x;if(i=-parseFloat(c[1]),n=-parseFloat(c[2]),r=parseFloat(c[3]),o=parseFloat(c[4]),x.minX=i,x.minY=n,x.viewBoxWidth=r,x.viewBoxHeight=o,b?(x.width=r,x.height=o):(x.width=s(f),x.height=s(d),l=x.width/r,u=x.height/o),"none"!==(m=e.util.parsePreserveAspectRatioAttribute(m)).alignX&&("meet"===m.meetOrSlice&&(u=l=l>u?u:l),"slice"===m.meetOrSlice&&(u=l=l>u?l:u),C=x.width-r*l,w=x.height-o*l,"Mid"===m.alignX&&(C/=2),"Mid"===m.alignY&&(w/=2),"Min"===m.alignX&&(C=0),"Min"===m.alignY&&(w=0)),1===l&&1===u&&0===i&&0===n&&0===p&&0===g)return x;if((p||g)&&"#document"!==t.parentNode.nodeName&&(S=" translate("+s(p)+" "+s(g)+") "),a=S+" matrix("+l+" 0 0 "+u+" "+(i*l+C)+" "+(n*u+w)+") ","svg"===t.nodeName){for(h=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)h.appendChild(t.firstChild);t.appendChild(h)}else(h=t).removeAttribute("x"),h.removeAttribute("y"),a=h.getAttribute("transform")+a;return h.setAttribute("transform",a),x}function _(t,e){var i="xlink:href",n=v(t,e.getAttribute(i).slice(1));if(n&&n.getAttribute(i)&&_(t,n),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){n&&!e.hasAttribute(t)&&n.hasAttribute(t)&&e.setAttribute(t,n.getAttribute(t))})),!e.children.length)for(var r=n.cloneNode(!0);r.firstChild;)e.appendChild(r.firstChild);e.removeAttribute(i)}e.parseSVGDocument=function(t,i,r,s){if(t){!function(t){for(var i=p(t,["use","svg:use"]),n=0;i.length&&nt.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,s){var o,a=(s.x-r.x)*(t.y-r.y)-(s.y-r.y)*(t.x-r.x),h=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),c=(s.y-r.y)*(n.x-t.x)-(s.x-r.x)*(n.y-t.y);if(0!==c){var l=a/c,u=h/c;0<=l&&l<=1&&0<=u&&u<=1?(o=new i("Intersection")).appendPoint(new e.Point(t.x+l*(n.x-t.x),t.y+l*(n.y-t.y))):o=new i}else o=new i(0===a||0===h?"Coincident":"Parallel");return o},e.Intersection.intersectLinePolygon=function(t,e,n){var r,s,o,a,h=new i,c=n.length;for(a=0;a0&&(h.status="Intersection"),h},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,s=t.length;for(n=0;n0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var s=n.min(r),o=n.max(r),a=new e.Point(o.x,s.y),h=new e.Point(s.x,o.y),c=i.intersectLinePolygon(s,a,t),l=i.intersectLinePolygon(a,o,t),u=i.intersectLinePolygon(o,h,t),f=i.intersectLinePolygon(h,s,t),d=new i;return d.appendPoints(c.points),d.appendPoints(l.points),d.appendPoints(u.points),d.appendPoints(f.points),d.points.length>0&&(d.status="Intersection"),d})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,s,o,a=e.util.array.max([t,i,n]),h=e.util.array.min([t,i,n]);if(o=(a+h)/2,a===h)r=s=0;else{var c=a-h;switch(s=o>.5?c/(2-a-h):c/(a+h),a){case t:r=(i-n)/c+(i0)-(t<0)||+t};function d(t,e){var i=t.angle+u(Math.atan2(e.y,e.x))+360;return Math.round(i%360/45)}function p(t,i){var n=i.transform.target,r=n.canvas,s=e.util.object.clone(i);s.target=n,r&&r.fire("object:"+t,s),n.fire(t,i)}function g(t,e){var i=e.canvas,n=t[i.uniScaleKey];return i.uniformScaling&&!n||!i.uniformScaling&&n}function m(t){return t.originX===c&&t.originY===c}function v(t,e,i){var n=t.lockScalingX,r=t.lockScalingY;return!((!n||!r)&&(e||!n&&!r||!i)&&(!n||"x"!==e)&&(!r||"y"!==e))}function y(t,e,i,n){return{e:t,transform:e,pointer:{x:i,y:n}}}function b(t){return function(e,i,n,r){var s=i.target,o=s.getCenterPoint(),a=s.translateToOriginPoint(o,i.originX,i.originY),h=t(e,i,n,r);return s.setPositionByOrigin(a,i.originX,i.originY),h}}function _(t,e){return function(i,n,r,s){var o=e(i,n,r,s);return o&&p(t,y(i,n,r,s)),o}}function x(t,i,n,r,s){var o=t.target,a=o.controls[t.corner],h=o.canvas.getZoom(),c=o.padding/h,l=o.toLocalPoint(new e.Point(r,s),i,n);return l.x>=c&&(l.x-=c),l.x<=-c&&(l.x+=c),l.y>=c&&(l.y-=c),l.y<=c&&(l.y+=c),l.x-=a.offsetX,l.y-=a.offsetY,l}function S(t){return t.flipX!==t.flipY}function C(t,e,i,n,r){if(0!==t[e]){var s=r/t._getTransformedDimensions()[n]*t[i];t.set(i,s)}}function w(t,e,i,n){var r,c=e.target,l=c._getTransformedDimensions(0,c.skewY),f=x(e,e.originX,e.originY,i,n),d=Math.abs(2*f.x)-l.x,p=c.skewX;d<2?r=0:(r=u(Math.atan2(d/c.scaleX,l.y/c.scaleY)),e.originX===s&&e.originY===h&&(r=-r),e.originX===a&&e.originY===o&&(r=-r),S(c)&&(r=-r));var g=p!==r;if(g){var m=c._getTransformedDimensions().y;c.set("skewX",r),C(c,"skewY","scaleY","y",m)}return g}function T(t,e,i,n){var r,c=e.target,l=c._getTransformedDimensions(c.skewX,0),f=x(e,e.originX,e.originY,i,n),d=Math.abs(2*f.y)-l.y,p=c.skewY;d<2?r=0:(r=u(Math.atan2(d/c.scaleY,l.x/c.scaleX)),e.originX===s&&e.originY===h&&(r=-r),e.originX===a&&e.originY===o&&(r=-r),S(c)&&(r=-r));var g=p!==r;if(g){var m=c._getTransformedDimensions().x;c.set("skewY",r),C(c,"skewX","scaleX","x",m)}return g}function E(t,e,i,n,r){r=r||{};var s,o,a,h,c,u,d=e.target,p=d.lockScalingX,y=d.lockScalingY,b=r.by,_=g(t,d),S=v(d,b,_),C=e.gestureScale;if(S)return!1;if(C)o=e.scaleX*C,a=e.scaleY*C;else{if(s=x(e,e.originX,e.originY,i,n),c="y"!==b?f(s.x):1,u="x"!==b?f(s.y):1,e.signX||(e.signX=c),e.signY||(e.signY=u),d.lockScalingFlip&&(e.signX!==c||e.signY!==u))return!1;if(h=d._getTransformedDimensions(),_&&!b){var w=Math.abs(s.x)+Math.abs(s.y),T=e.original,E=w/(Math.abs(h.x*T.scaleX/d.scaleX)+Math.abs(h.y*T.scaleY/d.scaleY));o=T.scaleX*E,a=T.scaleY*E}else o=Math.abs(s.x*d.scaleX/h.x),a=Math.abs(s.y*d.scaleY/h.y);m(e)&&(o*=2,a*=2),e.signX!==c&&"y"!==b&&(e.originX=l[e.originX],o*=-1,e.signX=c),e.signY!==u&&"x"!==b&&(e.originY=l[e.originY],a*=-1,e.signY=u)}var O=d.scaleX,P=d.scaleY;return b?("x"===b&&d.set("scaleX",o),"y"===b&&d.set("scaleY",a)):(!p&&d.set("scaleX",o),!y&&d.set("scaleY",a)),O!==d.scaleX||P!==d.scaleY}r.scaleCursorStyleHandler=function(t,e,n){var r=g(t,n),s="";if(0!==e.x&&0===e.y?s="x":0===e.x&&0!==e.y&&(s="y"),v(n,s,r))return"not-allowed";var o=d(n,e);return i[o]+"-resize"},r.skewCursorStyleHandler=function(t,e,i){var r="not-allowed";if(0!==e.x&&i.lockSkewingY)return r;if(0!==e.y&&i.lockSkewingX)return r;var s=d(i,e)%4;return n[s]+"-resize"},r.scaleSkewCursorStyleHandler=function(t,e,i){return t[i.canvas.altActionKey]?r.skewCursorStyleHandler(t,e,i):r.scaleCursorStyleHandler(t,e,i)},r.rotationWithSnapping=_("rotating",b((function(t,e,i,n){var r=e,s=r.target,o=s.translateToOriginPoint(s.getCenterPoint(),r.originX,r.originY);if(s.lockRotation)return!1;var a,h=Math.atan2(r.ey-o.y,r.ex-o.x),c=Math.atan2(n-o.y,i-o.x),l=u(c-h+r.theta);if(s.snapAngle>0){var f=s.snapAngle,d=s.snapThreshold||f,p=Math.ceil(l/f)*f,g=Math.floor(l/f)*f;Math.abs(l-g)0?s:a:(l>0&&(r=u===o?s:a),l<0&&(r=u===o?a:s),S(h)&&(r=r===s?a:s)),e.originX=r,_("skewing",b(w))(t,e,i,n))},r.skewHandlerY=function(t,e,i,n){var r,a=e.target,l=a.skewY,u=e.originX;return!a.lockSkewingY&&(0===l?r=x(e,c,c,i,n).y>0?o:h:(l>0&&(r=u===s?o:h),l<0&&(r=u===s?h:o),S(a)&&(r=r===o?h:o)),e.originY=r,_("skewing",b(T))(t,e,i,n))},r.dragHandler=function(t,e,i,n){var r=e.target,s=i-e.offsetX,o=n-e.offsetY,a=!r.get("lockMovementX")&&r.left!==s,h=!r.get("lockMovementY")&&r.top!==o;return a&&r.set("left",s),h&&r.set("top",o),(a||h)&&p("moving",y(t,e,i,n)),a||h},r.scaleOrSkewActionName=function(t,e,i){var n=t[i.canvas.altActionKey];return 0===e.x?n?"skewX":"scaleY":0===e.y?n?"skewY":"scaleX":void 0},r.rotationStyleHandler=function(t,e,i){return i.lockRotation?"not-allowed":e.cursorStyle},r.fireEvent=p,r.wrapWithFixedAnchor=b,r.wrapWithFireEvent=_,r.getLocalPoint=x,e.controlsUtils=r}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians,n=e.controlsUtils;n.renderCircleControl=function(t,e,i,n,r){n=n||{};var s,o=this.sizeX||n.cornerSize||r.cornerSize,a=this.sizeY||n.cornerSize||r.cornerSize,h=void 0!==n.transparentCorners?n.transparentCorners:r.transparentCorners,c=h?"stroke":"fill",l=!h&&(n.cornerStrokeColor||r.cornerStrokeColor),u=e,f=i;t.save(),t.fillStyle=n.cornerColor||r.cornerColor,t.strokeStyle=n.cornerStrokeColor||r.cornerStrokeColor,o>a?(s=o,t.scale(1,a/o),f=i*o/a):a>o?(s=a,t.scale(o/a,1),u=e*a/o):s=o,t.lineWidth=1,t.beginPath(),t.arc(u,f,s/2,0,2*Math.PI,!1),t[c](),l&&t.stroke(),t.restore()},n.renderSquareControl=function(t,e,n,r,s){r=r||{};var o=this.sizeX||r.cornerSize||s.cornerSize,a=this.sizeY||r.cornerSize||s.cornerSize,h=void 0!==r.transparentCorners?r.transparentCorners:s.transparentCorners,c=h?"stroke":"fill",l=!h&&(r.cornerStrokeColor||s.cornerStrokeColor),u=o/2,f=a/2;t.save(),t.fillStyle=r.cornerColor||s.cornerColor,t.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor,t.lineWidth=1,t.translate(e,n),t.rotate(i(s.angle)),t[c+"Rect"](-u,-f,o,a),l&&t.strokeRect(-u,-f,o,a),t.restore()}}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Control=function(t){for(var e in t)this[e]=t[e]},e.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(t,e){return e.cursorStyle},getActionName:function(t,e){return e.actionName},getVisibility:function(t,e){var i=t._controlsVisibility;return i&&void 0!==i[e]?i[e]:this.visible},setVisibility:function(t){this.visible=t},positionHandler:function(t,i){return e.util.transformPoint({x:this.x*t.x+this.offsetX,y:this.y*t.y+this.offsetY},i)},calcCornerCoords:function(t,i,n,r,s){var o,a,h,c,l=s?this.touchSizeX:this.sizeX,u=s?this.touchSizeY:this.sizeY;if(l&&u&&l!==u){var f=Math.atan2(u,l),d=Math.sqrt(l*l+u*u)/2,p=f-e.util.degreesToRadians(t),g=Math.PI/2-f-e.util.degreesToRadians(t);o=d*e.util.cos(p),a=d*e.util.sin(p),h=d*e.util.cos(g),c=d*e.util.sin(g)}else d=.7071067812*(l&&u?l:i),p=e.util.degreesToRadians(45-t),o=h=d*e.util.cos(p),a=c=d*e.util.sin(p);return{tl:{x:n-c,y:r-h},tr:{x:n+o,y:r-a},bl:{x:n-o,y:r+a},br:{x:n+c,y:r+h}}},render:function(t,i,n,r,s){"circle"===((r=r||{}).cornerStyle||s.cornerStyle)?e.controlsUtils.renderCircleControl.call(this,t,i,n,r,s):e.controlsUtils.renderSquareControl.call(this,t,i,n,r,s)}}}(e),function(){function t(t,e){var i,n,r,s,o=t.getAttribute("style"),a=t.getAttribute("offset")||0;if(a=(a=parseFloat(a)/(/%$/.test(a)?100:1))<0?0:a>1?1:a,o){var h=o.split(/\s*;\s*/);for(""===h[h.length-1]&&h.pop(),s=h.length;s--;){var c=h[s].split(/\s*:\s*/),l=c[0].trim(),u=c[1].trim();"stop-color"===l?i=u:"stop-opacity"===l&&(r=u)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),n=(i=new T.Color(i)).getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=n*e,{offset:a,color:i.toRgb(),opacity:r}}var e=T.util.object.clone;T.Gradient=T.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach((function(e){i[e]=t[e]})),this.id?this.id+="_"+T.Object.__uid++:this.id=T.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new T.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return T.util.populateWithProperties(this,e,t),e},toSVG:function(t,i){var n,r,s,o,a=e(this.coords,!0),h=(i=i||{},e(this.colorStops,!0)),c=a.r1>a.r2,l=this.gradientTransform?this.gradientTransform.concat():T.iMatrix.concat(),u=-this.offsetX,f=-this.offsetY,d=!!i.additionalTransform,p="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(h.sort((function(t,e){return t.offset-e.offset})),"objectBoundingBox"===p?(u/=t.width,f/=t.height):(u+=t.width/2,f+=t.height/2),"path"===t.type&&"percentage"!==this.gradientUnits&&(u-=t.pathOffset.x,f-=t.pathOffset.y),l[4]-=u,l[5]-=f,o='id="SVGID_'+this.id+'" gradientUnits="'+p+'"',o+=' gradientTransform="'+(d?i.additionalTransform+" ":"")+T.util.matrixToSVG(l)+'" ',"linear"===this.type?s=["\n']:"radial"===this.type&&(s=["\n']),"radial"===this.type){if(c)for((h=h.concat()).reverse(),n=0,r=h.length;n0){var m=g/Math.max(a.r1,a.r2);for(n=0,r=h.length;n\n')}return s.push("linear"===this.type?"\n":"\n"),s.join("")},toLive:function(t){var e,i,n,r=T.util.object.clone(this.coords);if(this.type){for("linear"===this.type?e=t.createLinearGradient(r.x1,r.y1,r.x2,r.y2):"radial"===this.type&&(e=t.createRadialGradient(r.x1,r.y1,r.r1,r.x2,r.y2,r.r2)),i=0,n=this.colorStops.length;i1?1:s,isNaN(s)&&(s=1);var o,a,h,c,l=e.getElementsByTagName("stop"),u="userSpaceOnUse"===e.getAttribute("gradientUnits")?"pixels":"percentage",f=e.getAttribute("gradientTransform")||"",d=[],p=0,g=0;for("linearGradient"===e.nodeName||"LINEARGRADIENT"===e.nodeName?(o="linear",a=function(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}(e)):(o="radial",a=function(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}(e)),h=l.length;h--;)d.push(t(l[h],s));return c=T.parseTransformAttribute(f),function(t,e,i,n){var r,s;Object.keys(e).forEach((function(t){"Infinity"===(r=e[t])?s=1:"-Infinity"===r?s=0:(s=parseFloat(e[t],10),"string"==typeof r&&/^(\d+\.\d+)%|(\d+)%$/.test(r)&&(s*=.01,"pixels"===n&&("x1"!==t&&"x2"!==t&&"r2"!==t||(s*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(s*=i.viewBoxHeight||i.height)))),e[t]=s}))}(0,a,r,u),"pixels"===u&&(p=-i.left,g=-i.top),new T.Gradient({id:e.getAttribute("id"),type:o,coords:a,colorStops:d,gradientUnits:u,gradientTransform:c,offsetX:p,offsetY:g})}})}(),function(){"use strict";var t=T.util.toFixed;T.Pattern=T.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=T.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else{var i=this;this.source=T.util.createImage(),T.util.loadImage(t.source,(function(t,n){i.source=t,e&&e(i,n)}),null,this.crossOrigin)}},toObject:function(e){var i,n,r=T.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?i=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(i=this.source.toDataURL()),n={type:"pattern",source:i,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:t(this.offsetX,r),offsetY:t(this.offsetY,r),patternTransform:this.patternTransform?this.patternTransform.concat():null},T.util.populateWithProperties(this,n,e),n},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,n=e.height/t.height,r=this.offsetX/t.width,s=this.offsetY/t.height,o="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(n=1,s&&(n+=Math.abs(s))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1,r&&(i+=Math.abs(r))),e.src?o=e.src:e.toDataURL&&(o=e.toDataURL()),'\n\n\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e=this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}})}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),n=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(n[1],10)||0,offsetY:parseFloat(n[2],10)||0,blur:parseFloat(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var n=40,r=40,s=e.Object.NUM_FRACTION_DIGITS,o=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),a=new e.Color(this.color);return t.width&&t.height&&(n=100*i((Math.abs(o.x)+this.blur)/t.width,s)+20,r=100*i((Math.abs(o.y)+this.blur)/t.height,s)+20),t.flipX&&(o.x*=-1),t.flipY&&(o.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach((function(e){this[e]!==i[e]&&(t[e]=this[e])}),this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/)}(e),function(){"use strict";if(T.StaticCanvas)T.warn("fabric.StaticCanvas is already defined.");else{var t=T.util.object.extend,e=T.util.getElementOffset,i=T.util.removeFromArray,n=T.util.toFixed,r=T.util.transformPoint,s=T.util.invertTransform,o=T.util.getNodeCanvas,a=T.util.createCanvasElement,h=new Error("Could not initialize `canvas` element");T.StaticCanvas=T.util.createClass(T.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:T.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return T.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,T.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=T.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},__setBgOverlayImage:function(t,e,i,n){return"string"==typeof e?T.util.loadImage(e,(function(e,r){if(e){var s=new T.Image(e,n);this[t]=s,s.canvas=this}i&&i(e,r)}),this,n&&n.crossOrigin):(n&&e.setOptions(n),this[t]=e,e&&(e.canvas=this),i&&i(e,!1)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=a();if(!t)throw h;if(t.style||(t.style={}),void 0===t.getContext)throw h;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=T.util.getById(t)||this._createCanvasElement(),T.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var n in e=e||{},t)i=t[n],e.cssOnly||(this._setBackstoreDimension(n,t[n]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(n,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,n,r=this._activeObject,s=this.backgroundImage,o=this.overlayImage;for(this.viewportTransform=t,i=0,n=this._objects.length;i\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push(""),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('\n','\n')},_setSVGHeader:function(t,e){var i,r=e.width||this.width,s=e.height||this.height,o='viewBox="0 0 '+this.width+" "+this.height+'" ',a=T.Object.NUM_FRACTION_DIGITS;e.viewBox?o='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,o='viewBox="'+n(-i[4]/i[0],a)+" "+n(-i[5]/i[3],a)+" "+n(this.width/i[0],a)+" "+n(this.height/i[3],a)+'" '),t.push("\n',"Created with Fabric.js ",T.version,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+T.Object.__uid++,'\n'+this.clipPath.toClipPathSVG(t.reviver)+"\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map((function(e){var i=t[e+"Color"];if(i&&i.toLive){var n=t[e+"Vpt"],r=t.viewportTransform,s={width:t.width/(n?r[0]:1),height:t.height/(n?r[3]:1)};return i.toSVG(s,{additionalTransform:n?T.util.matrixToSVG(r):""})}})).join("")},createSVGFontFacesMarkup:function(){var t,e,i,n,r,s,o,a,h="",c={},l=T.fontPaths,u=[];for(this._objects.forEach((function t(e){u.push(e),e._objects&&e._objects.forEach(t)})),o=0,a=u.length;o',"\n",h,"","\n"].join("")),h},_setSVGObjects:function(t,e){var i,n,r,s=this._objects;for(n=0,r=s.length;n\n")}else t.push('\n")},sendToBack:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=(r=s._objects).length;e--;)n=r[e],i(this._objects,n),this._objects.unshift(n);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(r=s._objects,e=0;e0+c&&(o=s-1,i(this._objects,r),this._objects.splice(o,0,r)),c++;else 0!==(s=this._objects.indexOf(t))&&(o=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var n,r;if(i){for(n=e,r=e-1;r>=0;--r)if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e-1;return n},bringForward:function(t,e){if(!t)return this;var n,r,s,o,a,h=this._activeObject,c=0;if(t===h&&"activeSelection"===t.type)for(n=(a=h._objects).length;n--;)r=a[n],(s=this._objects.indexOf(r))"}}),t(T.StaticCanvas.prototype,T.Observable),t(T.StaticCanvas.prototype,T.Collection),t(T.StaticCanvas.prototype,T.DataURLExporter),t(T.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=a();if(!e||!e.getContext)return null;var i=e.getContext("2d");return i&&"setLineDash"===t?void 0!==i.setLineDash:null}}),T.StaticCanvas.prototype.toJSON=T.StaticCanvas.prototype.toObject,T.isLikelyNode&&(T.StaticCanvas.prototype.createPNGStream=function(){var t=o(this.lowerCanvasEl);return t&&t.createPNGStream()},T.StaticCanvas.prototype.createJPEGStream=function(t){var e=o(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}}(),T.BaseBrush=T.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,n=t.getZoom();t&&t._isRetinaScaling()&&(n*=T.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*n,i.shadowOffsetX=e.offsetX*n,i.shadowOffsetY=e.offsetY*n}},needsFullRender:function(){return new T.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0},_isOutSideCanvas:function(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}),T.PencilBrush=T.util.createClass(T.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(t){this.canvas=t,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(t,e,i){var n=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,n.x,n.y),n},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._captureDrawingPath(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,n=i.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(r,i[n-2],i[n-1],!0),r.stroke(),r.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new T.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1])||(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),0))},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(t){var e=new T.Point(t.x,t.y);return this._addPoint(e)},_render:function(t){var e,i,n=this._points[0],r=this._points[1];if(t=t||this.canvas.contextTop,this._saveAndTransform(t),t.beginPath(),2===this._points.length&&n.x===r.x&&n.y===r.y){var s=this.width/1e3;n=new T.Point(n.x,n.y),r=new T.Point(r.x,r.y),n.x-=s,r.x+=s}for(t.moveTo(n.x,n.y),e=1,i=this._points.length;e=r&&(o=t[i],a.push(o));return a.push(t[s]),a},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(t))this.canvas.requestRenderAll();else{var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}}),T.CircleBrush=T.util.createClass(T.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,n=this.points;for(this._saveAndTransform(i),t=0,e=n.length;t0&&!this.preserveObjectStacking){e=[],i=[];for(var r=0,s=this._objects.length;r1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),n=T.util.invertTransform(i),r=this.restorePointerVpt(e);return T.util.transformPoint(r,n)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var n=this._normalizePointer(t,{x:e,y:i}),r=Math.max(t.cacheTranslationX+n.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+n.y*t.zoomY,0);return T.util.isTransparent(t._cacheContext,Math.round(r),Math.round(s),this.targetFindTolerance)}var o=this.contextCache,a=t.selectionBackgroundColor,h=this.viewportTransform;return t.selectionBackgroundColor="",this.clearContext(o),o.save(),o.transform(h[0],h[1],h[2],h[3],h[4],h[5]),t.render(o),o.restore(),t.selectionBackgroundColor=a,T.util.isTransparent(o,e,i,this.targetFindTolerance)},_isSelectionKeyPressed:function(t){return Array.isArray(this.selectionKey)?!!this.selectionKey.find((function(e){return!0===t[e]})):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),n=this._activeObject;return!e||e&&n&&i.length>1&&-1===i.indexOf(e)&&n!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&n&&n!==e},_shouldCenterTransform:function(t,e,i){var n;if(t)return"scale"===e||"scaleX"===e||"scaleY"===e||"resizing"===e?n=this.centeredScaling||t.centeredScaling:"rotate"===e&&(n=this.centeredRotation||t.centeredRotation),n?!i:i},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i,n){if(!e||!t)return"drag";var r=n.controls[e];return r.getActionName(i,r,n)},_setupCurrentTransform:function(t,i,n){if(i){var r=this.getPointer(t),s=i.__corner,o=i.controls[s],a=n&&s?o.getActionHandler(t,i,o):T.controlsUtils.dragHandler,h=this._getActionFromCorner(n,s,t,i),c=this._getOriginFromCorner(i,s),l=t[this.centeredKey],u={target:i,action:h,actionHandler:a,corner:s,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:c.x,originY:c.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:e(i.angle),width:i.width*i.scaleX,shiftKey:t.shiftKey,altKey:l,original:T.util.saveObjectTransform(i)};this._shouldCenterTransform(i,h,l)&&(u.originX="center",u.originY="center"),u.original.originX=c.x,u.original.originY=c.y,this._currentTransform=u,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var e=this._groupSelector,i=new T.Point(e.ex,e.ey),n=T.util.transformPoint(i,this.viewportTransform),r=new T.Point(e.ex+e.left,e.ey+e.top),s=T.util.transformPoint(r,this.viewportTransform),o=Math.min(n.x,s.x),a=Math.min(n.y,s.y),h=Math.max(n.x,s.x),c=Math.max(n.y,s.y),l=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(o,a,h-o,c-a)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,o+=l,a+=l,h-=l,c-=l,T.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(o,a,h-o,c-a))},findTarget:function(t,e){if(!this.skipTargetFind){var n,r,s=this.getPointer(t,!0),o=this._activeObject,a=this.getActiveObjects(),h=i(t),c=a.length>1&&!e||1===a.length;if(this.targets=[],c&&o._findTargetCorner(s,h))return o;if(a.length>1&&!e&&o===this._searchPossibleTargets([o],s))return o;if(1===a.length&&o===this._searchPossibleTargets([o],s)){if(!this.preserveObjectStacking)return o;n=o,r=this.targets,this.targets=[]}var l=this._searchPossibleTargets(this._objects,s);return t[this.altSelectionKey]&&l&&n&&l!==n&&(l=n,this.targets=r),l}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&e.containsPoint(t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,n,r=t.length;r--;){var s=t[r],o=s.group?this._normalizePointer(s.group,e):e;if(this._checkTarget(o,s,e)){(i=t[r]).subTargetCheck&&i instanceof T.Group&&(n=this._searchPossibleTargets(i._objects,e))&&this.targets.push(n);break}}return i},restorePointerVpt:function(t){return T.util.transformPoint(t,T.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var n,r=t(e),s=this.upperCanvasEl,o=s.getBoundingClientRect(),a=o.width||0,h=o.height||0;a&&h||("top"in o&&"bottom"in o&&(h=Math.abs(o.top-o.bottom)),"right"in o&&"left"in o&&(a=Math.abs(o.right-o.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,i||(r=this.restorePointerVpt(r));var c=this.getRetinaScaling();return 1!==c&&(r.x/=c,r.y/=c),n=0===a||0===h?{width:1,height:1}:{width:s.width/a,height:s.height/h},{x:r.x*n.width,y:r.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),T.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=T.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),T.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),T.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;T.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,T.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?"activeSelection"===t.type&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,n=this.getActiveObjects(),r=[],s=[];t.forEach((function(t){-1===n.indexOf(t)&&(i=!0,t.fire("deselected",{e,target:t}),s.push(t))})),n.forEach((function(n){-1===t.indexOf(n)&&(i=!0,n.fire("selected",{e,target:n}),r.push(n))})),t.length>0&&n.length>0?i&&this.fire("selection:updated",{e,selected:r,deselected:s}):n.length>0?this.fire("selection:created",{e,selected:r}):t.length>0&&this.fire("selection:cleared",{e,deselected:s})},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return this._activeObject!==t&&!!this._discardActiveObject(e,t)&&!t.onSelect({e})&&(this._activeObject=t,!0)},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(t){T.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,T.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(t),r=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,n),r},_realizeGroupTransformOnObject:function(t){if(t.group&&"activeSelection"===t.group.type&&this._activeObject===t.group){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach((function(i){e[i]=t[i]})),T.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,n)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),T.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),T.StaticCanvas)"prototype"!==n&&(T.Canvas[n]=T.StaticCanvas[n])}(),function(){var t=T.util.addListener,e=T.util.removeListener,i={passive:!1};function n(t,e){return t.button&&t.button===e-1}T.util.object.extend(T.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(t,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var n=this.upperCanvasEl,r=this._getEventPrefix();t(T.window,"resize",this._onResize),t(n,r+"down",this._onMouseDown),t(n,r+"move",this._onMouseMove,i),t(n,r+"out",this._onMouseOut),t(n,r+"enter",this._onMouseEnter),t(n,"wheel",this._onMouseWheel),t(n,"contextmenu",this._onContextMenu),t(n,"dblclick",this._onDoubleClick),t(n,"dragover",this._onDragOver),t(n,"dragenter",this._onDragEnter),t(n,"dragleave",this._onDragLeave),t(n,"drop",this._onDrop),this.enablePointerEvents||t(n,"touchstart",this._onTouchStart,i),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](n,"gesture",this._onGesture),eventjs[e](n,"drag",this._onDrag),eventjs[e](n,"orientation",this._onOrientationChange),eventjs[e](n,"shake",this._onShake),eventjs[e](n,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(e,"remove");var t=this._getEventPrefix();e(T.document,t+"up",this._onMouseUp),e(T.document,"touchend",this._onTouchEnd,i),e(T.document,t+"move",this._onMouseMove,i),e(T.document,"touchmove",this._onMouseMove,i)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach((function(e){i.fire("mouse:out",{target:e,e:t}),e&&e.fire("mouseout",{e:t})})),this._hoveredTargets=[]},_onMouseEnter:function(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onDrop:function(t){return this._simpleEventHandler("drop:before",t),this._simpleEventHandler("drop",t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(n){n.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(n)),this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();t(T.document,"touchend",this._onTouchEnd,i),t(T.document,"touchmove",this._onMouseMove,i),e(r,s+"down",this._onMouseDown)},_onMouseDown:function(n){this.__onMouseDown(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();e(r,s+"move",this._onMouseMove,i),t(T.document,s+"up",this._onMouseUp),t(T.document,s+"move",this._onMouseMove,i)},_onTouchEnd:function(n){if(!(n.touches.length>0)){this.__onMouseUp(n),this._resetTransformEventData(),this.mainTouchId=null;var r=this._getEventPrefix();e(T.document,"touchend",this._onTouchEnd,i),e(T.document,"touchmove",this._onMouseMove,i);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((function(){t(s.upperCanvasEl,r+"down",s._onMouseDown),s._willAddMouseDown=0}),400)}},_onMouseUp:function(n){this.__onMouseUp(n),this._resetTransformEventData();var r=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(n)&&(e(T.document,s+"up",this._onMouseUp),e(T.document,s+"move",this._onMouseMove,i),t(r,s+"move",this._onMouseMove,i))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!(!!e!=!!t||e&&t&&e!==t)||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i=this._currentTransform,r=this._groupSelector,s=!1,o=!r||0===r.left&&0===r.top;if(this._cacheTransformEventData(t),e=this._target,this._handleEvent(t,"up:before"),n(t,3))this.fireRightClick&&this._handleEvent(t,"up",3,o);else{if(n(t,2))return this.fireMiddleClick&&this._handleEvent(t,"up",2,o),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(t);else if(this._isMainEvent(t)){if(i&&(this._finalizeCurrentTransform(t),s=i.actionPerformed),!o){var a=e===this._activeObject;this._maybeGroupObjects(t),s||(s=this._shouldRender(e)||!a&&e===this._activeObject)}var h,c;if(e){if(h=e._findTargetCorner(this.getPointer(t,!0),T.util.isTouchEvent(t)),e.selectable&&e!==this._activeObject&&"up"===e.activeOn)this.setActiveObject(e,t),s=!0;else{var l=e.controls[h],u=l&&l.getMouseUpHandler(t,e,l);u&&u(t,i,(c=this.getPointer(t)).x,c.y)}e.isMoving=!1}if(i&&(i.target!==e||i.corner!==h)){var f=i.target&&i.target.controls[i.corner],d=f&&f.getMouseUpHandler(t,e,l);c=c||this.getPointer(t),d&&d(t,i,c.x,c.y)}this._setCursorFromEvent(t,e),this._handleEvent(t,"up",1,o),this._groupSelector=null,this._currentTransform=null,e&&(e.__corner=0),s?this.requestRenderAll():o||this.renderTop()}}},_simpleEventHandler:function(t,e){var i=this.findTarget(e),n=this.targets,r={e,target:i,subTargets:n};if(this.fire(t,r),i&&i.fire(t,r),!n)return i;for(var s=0;s1&&(e=new T.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(t){for(var e,i=[],n=this._groupSelector.ex,r=this._groupSelector.ey,s=n+this._groupSelector.left,o=r+this._groupSelector.top,a=new T.Point(v(n,s),v(r,o)),h=new T.Point(y(n,s),y(r,o)),c=!this.selectionFullyContained,l=n===s&&r===o,u=this._objects.length;u--&&!((e=this._objects[u])&&e.selectable&&e.visible&&(c&&e.intersectsWithRect(a,h,!0)||e.isContainedWithinRect(a,h,!0)||c&&e.containsPoint(a,null,!0)||c&&e.containsPoint(h,null,!0))&&(i.push(e),l)););return i.length>1&&(i=i.filter((function(e){return!e.onSelect({e:t})}))),i},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}}),T.util.object.extend(T.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,n=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),r=this.toCanvasElement(n,t);return T.util.toDataURL(r,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,n=(e.height||this.height)*t,r=this.getZoom(),s=this.width,o=this.height,a=r*t,h=this.viewportTransform,c=(h[4]-(e.left||0))*t,l=(h[5]-(e.top||0))*t,u=this.interactive,f=[a,0,0,a,c,l],d=this.enableRetinaScaling,p=T.util.createCanvasElement(),g=this.contextTop;return p.width=i,p.height=n,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=f,this.width=i,this.height=n,this.calcViewportBoundaries(),this.renderCanvas(p.getContext("2d"),this._objects),this.viewportTransform=h,this.width=s,this.height=o,this.calcViewportBoundaries(),this.interactive=u,this.enableRetinaScaling=d,this.contextTop=g,p}}),T.util.object.extend(T.StaticCanvas.prototype,{loadFromJSON:function(t,e,i){if(t){var n="string"==typeof t?JSON.parse(t):T.util.object.clone(t),r=this,s=n.clipPath,o=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete n.clipPath,this._enlivenObjects(n.objects,(function(t){r.clear(),r._setBgOverlay(n,(function(){s?r._enlivenObjects([s],(function(i){r.clipPath=i[0],r.__setupCanvas.call(r,n,t,o,e)})):r.__setupCanvas.call(r,n,t,o,e)}))}),i),this}},__setupCanvas:function(t,e,i,n){var r=this;e.forEach((function(t,e){r.insertAt(t,e)})),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),n&&n()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var n=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,n),this.__setBgOverlay("overlayImage",t.overlayImage,i,n),this.__setBgOverlay("backgroundColor",t.background,i,n),this.__setBgOverlay("overlayColor",t.overlay,i,n)}else e&&e()},__setBgOverlay:function(t,e,i,n){var r=this;if(!e)return i[t]=!0,void(n&&n());"backgroundImage"===t||"overlayImage"===t?T.util.enlivenObjects([e],(function(e){r[t]=e[0],i[t]=!0,n&&n()})):this["set"+T.util.string.capitalize(t,!0)](e,(function(){i[t]=!0,n&&n()}))},_enlivenObjects:function(t,e,i){t&&0!==t.length?T.util.enlivenObjects(t,(function(t){e&&e(t)}),null,i):e&&e([])},_toDataURL:function(t,e){this.clone((function(i){e(i.toDataURL(t))}))},_toDataURLWithMultiplier:function(t,e,i){this.clone((function(n){i(n.toDataURLWithMultiplier(t,e))}))},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData((function(e){e.loadFromJSON(i,(function(){t&&t(e)}))}))},cloneWithoutData:function(t){var e=T.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new T.Canvas(e);this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,(function(){i.renderAll(),t&&t(i)})),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.string.capitalize,o=e.util.degreesToRadians,a=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:a,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,n=t.width,r=t.height,s=e.maxCacheSideLimit,o=e.minCacheSideLimit;if(n<=s&&r<=s&&n*r<=i)return nl&&(t.zoomX/=n/l,t.width=l,t.capped=!0),r>u&&(t.zoomY/=r/u,t.height=u,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,n=e.y*t.scaleY/this.scaleY;return{width:i+2,height:n+2,zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:n}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var i=t._currentTransform.target,n=t._currentTransform.action;if(this===i&&n.slice&&"scale"===n.slice(0,5))return!1}var r,s,o=this._cacheCanvas,a=this._limitCacheSize(this._getCacheCanvasDimensions()),h=e.minCacheSideLimit,c=a.width,l=a.height,u=a.zoomX,f=a.zoomY,d=c!==this.cacheWidth||l!==this.cacheHeight,p=this.zoomX!==u||this.zoomY!==f,g=d||p,m=0,v=0,y=!1;if(d){var b=this._cacheCanvas.width,_=this._cacheCanvas.height,x=c>b||l>_;y=x||(c<.9*b||l<.9*_)&&b>h&&_>h,x&&!a.capped&&(c>h||l>h)&&(m=.1*c,v=.1*l)}return this instanceof e.Text&&this.path&&(g=!0,y=!0,m+=this.getHeightOfLine(0)*this.zoomX,v+=this.getHeightOfLine(0)*this.zoomY),!!g&&(y?(o.width=Math.ceil(c+m),o.height=Math.ceil(l+v)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,o.width,o.height)),r=a.x/2,s=a.y/2,this.cacheTranslationX=Math.round(o.width/2-r)+r,this.cacheTranslationY=Math.round(o.height/2-s)+s,this.cacheWidth=c,this.cacheHeight=l,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(u,f),this.zoomX=u,this.zoomY=f,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.clipPath&&!this.clipPath.excludeFromExport&&(n.clipPath=this.clipPath.toObject(t),n.clipPath.inverted=this.clipPath.inverted,n.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,n,t),this.includeDefaultValues||(n=this._removeDefaultValues(n)),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach((function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],Array.isArray(t[e])&&Array.isArray(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])})),t},toString:function(){return"#"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var t=e.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(t.scaleX),scaleY:Math.abs(t.scaleY)}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var n=this.canvas.getZoom(),r=this.canvas.getRetinaScaling();e*=n*r,i*=n*r}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var n="scaleX"===t||"scaleY"===t,r=this[t]!==i,s=!1;return n&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,r&&(s=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,s&&this.group.set("dirty",!0)):s&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t,i){if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var n=e.util.invertTransform(this.calcTransformMatrix());t.transform(n[0],n[1],n[2],n[3],n[4],n[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath),this.fill=i,this.stroke=n},_drawClipPath:function(t,e){e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t,e))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){var i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,i.toLive?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)},_setFillStyles:function(t,e){var i=e.fill;i&&(i.toLive?(t.fillStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,e.fill)):t.fillStyle=i)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),t.setLineDash(e))},_renderControls:function(t,i){var n,r,s,a=this.getViewportTransform(),h=this.calcTransformMatrix();r=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,s=void 0!==i.hasControls?i.hasControls:this.hasControls,h=e.util.multiplyTransformMatrices(a,h),n=e.util.qrDecompose(h),t.save(),t.translate(n.translateX,n.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(n.angle-=180),t.rotate(o(this.group?n.angle:this.angle)),i.forActiveSelection||this.group?r&&this.drawBordersInGroup(t,n,i):r&&this.drawBorders(t,i),s&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,n=this.shadow,r=this.canvas,s=r&&r.viewportTransform[0]||1,o=r&&r.viewportTransform[3]||1;i=n.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),r&&r._isRetinaScaling()&&(s*=e.devicePixelRatio,o*=e.devicePixelRatio),t.shadowColor=n.color,t.shadowBlur=n.blur*e.browserShadowBlurConstant*(s+o)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=n.offsetX*s*i.scaleX,t.shadowOffsetY=n.offsetY*o*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,n=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,n,r):t.transform(1,0,0,1,n,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&this.group){var e=this.getObjectScaling();t.scale(1/e.scaleX,1/e.scaleY)}else this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}},_applyPatternForTransformedGradient:function(t,i){var n,r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=e.util.createCanvasElement(),o=this.canvas.getRetinaScaling(),a=r.x/this.scaleX/o,h=r.y/this.scaleY/o;s.width=Math.ceil(a),s.height=Math.ceil(h),(n=s.getContext("2d")).beginPath(),n.moveTo(0,0),n.lineTo(a,0),n.lineTo(a,h),n.lineTo(0,h),n.closePath(),n.translate(a/2,h/2),n.scale(r.zoomX/this.scaleX/o,r.zoomY/this.scaleY/o),this._applyPatternGradientTransform(n,i),n.fillStyle=i.toLive(t),n.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(o*this.scaleX/r.zoomX,o*this.scaleY/r.zoomY),t.strokeStyle=n.createPattern(s,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var n=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(n,t):e.Object._fromObject("Object",n,t)},cloneAsImage:function(t,i){var n=this.toCanvasElement(i);return t&&t(new e.Image(n)),this},toCanvasElement:function(t){t||(t={});var i=e.util,n=i.saveObjectTransform(this),r=this.group,s=this.shadow,o=Math.abs,a=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var h,c,l,u,f=e.util.createCanvasElement(),d=this.getBoundingRect(!0,!0),p=this.shadow,g={x:0,y:0};p&&(c=p.blur,h=p.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),g.x=2*Math.round(o(p.offsetX)+c)*o(h.scaleX),g.y=2*Math.round(o(p.offsetY)+c)*o(h.scaleY)),l=d.width+g.x,u=d.height+g.y,f.width=Math.ceil(l),f.height=Math.ceil(u);var m=new e.StaticCanvas(f,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(m.width/2,m.height/2),"center","center");var v=this.canvas;m.add(this);var y=m.toCanvasElement(a||1,t);return this.shadow=s,this.set("canvas",v),r&&(this.group=r),this.set(n).setCoords(),m._objects=[],m.dispose(),m=null,y},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var n=new e.Point(i.x,i.y),r=this._getLeftTopCoords();return this.angle&&(n=e.util.rotatePoint(n,r,o(-this.angle))),{x:n.x-r.x,y:n.y-r.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){e.runningAnimations&&e.runningAnimations.cancelByTarget(this)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object.ENLIVEN_PROPS=["clipPath"],e.Object._fromObject=function(t,i,r,s){var o=e[t];i=n(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],(function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjectEnlivables(i,i,(function(){var t=s?new o(i[s],i):new o(i);r&&r(t)}))}))},e.Object.__uid=0)}(e),b=T.util.degreesToRadians,_={left:-.5,center:0,right:.5},x={top:-.5,center:0,bottom:.5},T.util.object.extend(T.Object.prototype,{translateToGivenOrigin:function(t,e,i,n,r){var s,o,a,h=t.x,c=t.y;return"string"==typeof e?e=_[e]:e-=.5,"string"==typeof n?n=_[n]:n-=.5,"string"==typeof i?i=x[i]:i-=.5,"string"==typeof r?r=x[r]:r-=.5,o=r-i,((s=n-e)||o)&&(a=this._getTransformedDimensions(),h=t.x+s*a.x,c=t.y+o*a.y),new T.Point(h,c)},translateToCenterPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,e,i,"center","center");return this.angle?T.util.rotatePoint(n,t,b(this.angle)):n},translateToOriginPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,"center","center",e,i);return this.angle?T.util.rotatePoint(n,t,b(this.angle)):n},getCenterPoint:function(){var t=new T.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(t,e,i){var n,r,s=this.getCenterPoint();return n=void 0!==e&&void 0!==i?this.translateToGivenOrigin(s,"center","center",e,i):new T.Point(this.left,this.top),r=new T.Point(t.x,t.y),this.angle&&(r=T.util.rotatePoint(r,s,-b(this.angle))),r.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var n=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(n,this.originX,this.originY);this.set("left",r.x),this.set("top",r.y)},adjustPosition:function(t){var e,i,n=b(this.angle),r=this.getScaledWidth(),s=T.util.cos(n)*r,o=T.util.sin(n)*r;e="string"==typeof this.originX?_[this.originX]:this.originX-.5,i="string"==typeof t?_[t]:t-.5,this.left+=s*(i-e),this.top+=o*(i-e),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var t=T.util,e=t.degreesToRadians,i=t.multiplyTransformMatrices,n=t.transformPoint;t.object.extend(T.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(t,e){return e?t?this.calcACoords():this.calcLineCoords():(this.aCoords&&this.lineCoords||this.setCoords(!0),t?this.aCoords:this.lineCoords)},getCoords:function(t,e){return i=this._getCoords(t,e),[new T.Point(i.tl.x,i.tl.y),new T.Point(i.tr.x,i.tr.y),new T.Point(i.br.x,i.br.y),new T.Point(i.bl.x,i.bl.y)];var i},intersectsWithRect:function(t,e,i,n){var r=this.getCoords(i,n);return"Intersection"===T.Intersection.intersectPolygonRectangle(r,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===T.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var n=this.getCoords(e,i),r=e?t.aCoords:t.lineCoords,s=0,o=t._getImageLines(r);s<4;s++)if(!t.containsPoint(n[s],o))return!1;return!0},isContainedWithinRect:function(t,e,i,n){var r=this.getBoundingRect(i,n);return r.left>=t.x&&r.left+r.width<=e.x&&r.top>=t.y&&r.top+r.height<=e.y},containsPoint:function(t,e,i,n){var r=this._getCoords(i,n),s=(e=e||this._getImageLines(r),this._findCrossPoints(t,e));return 0!==s&&s%2==1},isOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.getCoords(!0,t).some((function(t){return t.x<=i.x&&t.x>=e.x&&t.y<=i.y&&t.y>=e.y}))||!!this.intersectsWithRect(e,i,!0,t)||this._containsCenterOfCanvas(e,i,t)},_containsCenterOfCanvas:function(t,e,i){var n={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(n,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this.getCoords(!0,t).every((function(t){return(t.x>=i.x||t.x<=e.x)&&(t.y>=i.y||t.y<=e.y)}))&&this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,n,r,s=0;for(var o in e)if(!((r=e[o]).o.y=t.y&&r.d.y>=t.y||(r.o.x===r.d.x&&r.o.x>=t.x?n=r.o.x:(i=(r.d.y-r.o.y)/(r.d.x-r.o.x),n=-(t.y-0*t.x-(r.o.y-i*r.o.x))/(0-i)),n>=t.x&&(s+=1),2!==s)))break;return s},getBoundingRect:function(e,i){var n=this.getCoords(e,i);return t.makeBoundingBoxFromPoints(n)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}).reviver,n=e.additionalTransform||"",r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,n,r=(e=e||{}).noStyle,s=e.reviver,o=r?"":'style="'+this.getSvgStyles()+'" ',a=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",h=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",l=h&&h.absolutePositioned,u=this.stroke,f=this.fill,d=this.shadow,p=[],g=t.indexOf("COMMON_PARTS"),m=e.additionalTransform;return h&&(h.clipPathId="CLIPPATH_"+T.Object.__uid++,n='\n'+h.toClipPathSVG(s)+"\n"),l&&p.push("\n"),p.push("\n"),i=[o,c,r?"":this.addPaintOrder()," ",m?'transform="'+m+'" ':""].join(""),t[g]=i,f&&f.toLive&&p.push(f.toSVG(this)),u&&u.toLive&&p.push(u.toSVG(this)),d&&p.push(d.toSVG(this)),h&&p.push(n),p.push(t.join("")),p.push("\n"),l&&p.push("\n"),s?s(p.join("")):p.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=T.util.object.extend,e="stateProperties";function i(e,i,n){var r={};n.forEach((function(t){r[t]=e[t]})),t(e[i],r,!0)}function n(t,e,i){if(t===e)return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(var r=0,s=t.length;r=0;h--)if(r=a[h],this.isControlVisible(r)&&(n=this._getImageLines(e?this.oCoords[r].touchCorner:this.oCoords[r].corner),0!==(i=this._findCrossPoints({x:s,y:o},n))&&i%2==1))return this.__corner=r,r;return!1},forEachControl:function(t){for(var e in this.controls)t(this.controls[e],e,this)},_setCornerCoords:function(){var t=this.oCoords;for(var e in t){var i=this.controls[e];t[e].corner=i.calcCornerCoords(this.angle,this.cornerSize,t[e].x,t[e].y,!1),t[e].touchCorner=i.calcCornerCoords(this.angle,this.touchCornerSize,t[e].x,t[e].y,!0)}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;e.save();var i=this.getCenterPoint(),n=this._calculateCurrentDimensions(),r=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/r[0],1/r[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore(),this},drawBorders:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),n=this.borderScaleFactor,r=i.x+n,s=i.y+n,o=void 0!==e.hasControls?e.hasControls:this.hasControls,a=!1;return t.save(),t.strokeStyle=e.borderColor||this.borderColor,this._setLineDash(t,e.borderDashArray||this.borderDashArray),t.strokeRect(-r/2,-s/2,r,s),o&&(t.beginPath(),this.forEachControl((function(e,i,n){e.withConnection&&e.getVisibility(n,i)&&(a=!0,t.moveTo(e.x*r,e.y*s),t.lineTo(e.x*r+e.offsetX,e.y*s+e.offsetY))})),a&&t.stroke()),t.restore(),this},drawBordersInGroup:function(t,e,i){i=i||{};var n=T.util.sizeAfterTransform(this.width,this.height,e),r=this.strokeWidth,s=this.strokeUniform,o=this.borderScaleFactor,a=n.x+r*(s?this.canvas.getZoom():e.scaleX)+o,h=n.y+r*(s?this.canvas.getZoom():e.scaleY)+o;return t.save(),this._setLineDash(t,i.borderDashArray||this.borderDashArray),t.strokeStyle=i.borderColor||this.borderColor,t.strokeRect(-a/2,-h/2,a,h),t.restore(),this},drawControls:function(t,e){e=e||{},t.save();var i,n,r=1;return this.canvas&&(r=this.canvas.getRetinaScaling()),t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=e.cornerColor||this.cornerColor,this.transparentCorners||(t.strokeStyle=e.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(t,e.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(i=this.group.calcTransformMatrix()),this.forEachControl((function(r,s,o){n=o.oCoords[s],r.getVisibility(o,s)&&(i&&(n=T.util.transformPoint(n,i)),r.render(t,n.x,n.y,e,o))})),t.restore(),this},isControlVisible:function(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)},setControlVisible:function(t,e){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e,this},setControlsVisibility:function(t){for(var e in t||(t={}),t)this.setControlVisible(e,t[e]);return this},onDeselect:function(){},onSelect:function(){}})}(),T.util.object.extend(T.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxCenterObjectV:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),s.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}})},fxRemove:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,s=this;return T.util.animate({target:this,startValue:t.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){t.set("opacity",e),s.requestRenderAll(),r()},onComplete:function(){s.remove(t),n()}})}}),T.util.object.extend(T.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[],n=[];for(t in arguments[0])i.push(t);for(var r=0,s=i.length;r-1||r&&s.colorProperties.indexOf(r[1])>-1,a=r?this.get(r[0])[r[1]]:this.get(t);"from"in i||(i.from=a),o||(e=~e.indexOf("=")?a+parseFloat(e.replace("=","")):parseFloat(e));var h={target:this,startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(t,e,n){return i.abort.call(s,t,e,n)},onChange:function(e,o,a){r?s[r[0]][r[1]]=e:s.set(t,e),n||i.onChange&&i.onChange(e,o,a)},onComplete:function(t,e,r){n||(s.setCoords(),i.onComplete&&i.onComplete(t,e,r))}};return o?T.util.animateColor(h.startValue,h.endValue,h.duration,h):T.util.animate(h)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r={x1:1,x2:1,y1:1,y2:1};function s(t,e){var i=t.origin,n=t.axis1,r=t.axis2,s=t.dimension,o=e.nearest,a=e.center,h=e.farthest;return function(){switch(this.get(i)){case o:return Math.min(this.get(n),this.get(r));case a:return Math.min(this.get(n),this.get(r))+.5*this.get(s);case h:return Math.max(this.get(n),this.get(r))}}}e.Line?e.warn("fabric.Line is already defined"):(e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:e.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==r[t]&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t){t.beginPath();var e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;var i=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,n=e*this.height*.5;return{x1:i,x2:t*this.width*-.5,y1:n,y2:e*this.height*-.5}},_toSVG:function(){var t=this.calcLinePoints();return["\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,n,r){r=r||{};var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),o=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];n(new e.Line(o,i(s,r)))},e.Line.fromObject=function(t,i){var r=n(t,!0);r.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",r,(function(t){delete t.points,i&&i(t)}),"points")})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians;e.Circle?e.warn("fabric.Circle is already defined."):(e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=(this.endAngle-this.startAngle)%360;if(0===n)t=["\n'];else{var r=i(this.startAngle),s=i(this.endAngle),o=this.radius;t=['180?"1":"0")+" 1"," "+e.util.cos(s)*o+" "+e.util.sin(s)*o,'" ',"COMMON_PARTS"," />\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var n,r=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(n=r)&&n.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");r.left=(r.left||0)-r.radius,r.top=(r.top||0)-r.radius,i(new e.Circle(r))},e.Circle.fromObject=function(t,i){e.Object._fromObject("Circle",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_toSVG:function(){var t=this.width/2,e=this.height/2;return["']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=2*Math.PI;e.Ellipse?e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,i(new e.Ellipse(n))},e.Ellipse.fromObject=function(t,i){e.Object._fromObject("Ellipse",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Rect?e.warn("fabric.Rect is already defined"):(e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,r=this.height,s=-this.width/2,o=-this.height/2,a=0!==e||0!==i,h=.4477152502;t.beginPath(),t.moveTo(s+e,o),t.lineTo(s+n-e,o),a&&t.bezierCurveTo(s+n-h*e,o,s+n,o+h*i,s+n,o+i),t.lineTo(s+n,o+r-i),a&&t.bezierCurveTo(s+n,o+r-h*i,s+n-h*e,o+r,s+n-e,o+r),t.lineTo(s+e,o+r),a&&t.bezierCurveTo(s+h*e,o+r,s,o+r-h*i,s,o+r-i),t.lineTo(s,o+i),a&&t.bezierCurveTo(s,o+h*i,s+h*e,o,s+e,o),t.closePath(),this._renderPaintInOrder(t)},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,n,r){if(!t)return n(null);r=r||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0,s.top=s.top||0,s.height=s.height||0,s.width=s.width||0;var o=new e.Rect(i(r?e.util.object.clone(r):{},s));o.visible=o.visible&&o.width>0&&o.height>0,n(o)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.array.min,r=e.util.array.max,s=e.util.toFixed,o=e.util.projectStrokeOnPoints;e.Polyline?e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_projectStrokeOnPoints:function(){return o(this.points,this,!0)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t),n=this.exactBoundingBox?this.strokeWidth:0;this.width=i.width-n,this.height=i.height-n,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2+n/2,y:i.top-this.strokeWidth/2+n/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2+n/2,y:i.top+this.height/2+n/2}},_calcDimensions:function(){var t=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,e=n(t,"x")||0,i=n(t,"y")||0;return{left:e,top:i,width:(r(t,"x")||0)-e,height:(r(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,n=this.pathOffset.y,r=e.Object.NUM_FRACTION_DIGITS,o=0,a=this.points.length;o\n']},commonRender:function(t){var e,i=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-r);for(var s=0;s"},toObject:function(t){return r(this.callSuper("toObject",t),{path:this.path.map((function(t){return t.slice()}))})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+o(-this.pathOffset.x,t)+", "+o(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var t,r,s=[],o=[],a=0,h=0,c=0,l=0,u=0,f=this.path.length;u"},addWithUpdate:function(t){var i=!!this.group;return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(i&&e.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,i?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var n=this._objects.length;if(this.useSetOnGroup)for(;n--;)this._objects[n].setOnGroup(t,i);if("canvas"===t)for(;n--;)this._objects[n]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,n=this._objects.filter((function(t){return!t.excludeFromExport})).map((function(e){var n=e.includeDefaultValues;e.includeDefaultValues=i;var r=e.toObject(t);return e.includeDefaultValues=n,r})),r=e.Object.prototype.toObject.call(this,t);return r.objects=n,r},toDatalessObject:function(t){var i,n=this.sourcePath;if(n)i=n;else{var r=this.includeDefaultValues;i=this._objects.map((function(e){var i=e.includeDefaultValues;e.includeDefaultValues=r;var n=e.toDatalessObject(t);return e.includeDefaultValues=i,n}))}var s=e.Object.prototype.toDatalessObject.call(this,t);return s.objects=i,s},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t)for(var i=0,n=this._objects.length;i\n"],i=0,n=this._objects.length;i\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,n=this._objects.length;i"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,void 0===(i=i||{}).hasControls&&(i.hasControls=!1),i.forActiveSelection=!0;for(var n=0,r=this._objects.length;n\n','\t\n',"\n"),o=' clip-path="url(#imageCrop_'+h+')" '}if(this.imageSmoothing||(a='" image-rendering="optimizeSpeed'),i.push("\t\n"),this.stroke||this.strokeDashArray){var c=this.fill;this.fill=null,t=["\t\n'],this.fill=c}return"fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return T.util.loadImage(t,(function(t,n){this.setElement(t,i),this._setWidthHeight(),e&&e(this,n)}),this,i&&i.crossOrigin),this},toString:function(){return'#'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.scaleX,r=i.scaleY,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||n>e&&r>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,void(this._lastScaleY=r);T.filterBackend||(T.filterBackend=T.initFilterBackend());var o=T.util.createCanvasElement(),a=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,h=s.width,c=s.height;o.width=h,o.height=c,this._element=o,this._lastScaleX=t.scaleX=n,this._lastScaleY=t.scaleY=r,T.filterBackend.applyFilters([t],s,h,c,this._element,a),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter((function(t){return t&&!t.isNeutralState()})),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(this._element===this._originalElement){var r=T.util.createCanvasElement();r.width=i,r.height=n,this._element=r,this._filteredEl=r}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1;return T.filterBackend||(T.filterBackend=T.initFilterBackend()),T.filterBackend.applyFilters(t,this._originalElement,i,n,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(t){T.util.setImageSmoothing(t,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},drawCacheOnCanvas:function(t){T.util.setImageSmoothing(t,this.imageSmoothing),T.Object.prototype.drawCacheOnCanvas.call(this,t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element;if(e){var i=this._filterScalingX,n=this._filterScalingY,r=this.width,s=this.height,o=Math.min,a=Math.max,h=a(this.cropX,0),c=a(this.cropY,0),l=e.naturalWidth||e.width,u=e.naturalHeight||e.height,f=h*i,d=c*n,p=o(r*i,l-f),g=o(s*n,u-d),m=-r/2,v=-s/2,y=o(r,l/i-h),b=o(s,u/n-c);e&&t.drawImage(e,f,d,p,g,m,v,y,b)}},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(T.util.getById(t),e),T.util.addClass(this.getElement(),T.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t)},_initFilters:function(t,e){t&&t.length?T.util.enlivenObjects(t,(function(t){e&&e(t)}),"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=T.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,n=this._element.height,r=1,s=1,o=0,a=0,h=0,c=0,l=this.width,u=this.height,f={width:l,height:u};return!e||"none"===e.alignX&&"none"===e.alignY?(r=l/i,s=u/n):("meet"===e.meetOrSlice&&(t=(l-i*(r=s=T.util.findScaleToFit(this._element,f)))/2,"Min"===e.alignX&&(o=-t),"Max"===e.alignX&&(o=t),t=(u-n*s)/2,"Min"===e.alignY&&(a=-t),"Max"===e.alignY&&(a=t)),"slice"===e.meetOrSlice&&(t=i-l/(r=s=T.util.findScaleToCover(this._element,f)),"Mid"===e.alignX&&(h=t/2),"Max"===e.alignX&&(h=t),t=n-u/s,"Mid"===e.alignY&&(c=t/2),"Max"===e.alignY&&(c=t),i=l/r,n=u/s)),{width:i,height:n,scaleX:r,scaleY:s,offsetLeft:o,offsetTop:a,cropX:h,cropY:c}}}),T.Image.CSS_CANVAS="canvas-img",T.Image.prototype.getSvgSrc=T.Image.prototype.getSrc,T.Image.fromObject=function(t,e){var i=T.util.object.clone(t);T.util.loadImage(i.src,(function(t,n){n?e&&e(null,!0):T.Image.prototype._initFilters.call(i,i.filters,(function(n){i.filters=n||[],T.Image.prototype._initFilters.call(i,[i.resizeFilter],(function(n){i.resizeFilter=n[0],T.util.enlivenObjectEnlivables(i,i,(function(){var n=new T.Image(t,i);e(n,!1)}))}))}))}),null,i.crossOrigin)},T.Image.fromURL=function(t,e,i){T.util.loadImage(t,(function(t,n){e&&e(new T.Image(t,i),n)}),null,i&&i.crossOrigin)},T.Image.ATTRIBUTE_NAMES=T.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),T.Image.fromElement=function(t,i,n){var r=T.parseAttributes(t,T.Image.ATTRIBUTE_NAMES);T.Image.fromURL(r["xlink:href"],i,e(n?T.util.object.clone(n):{},r))})}(e),T.util.object.extend(T.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,n=t.onChange||e,r=this;return T.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){r.rotate(t),n()},onComplete:function(){r.setCoords(),i()}})}}),T.util.object.extend(T.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){"use strict";function t(t,e){var i="precision "+e+" float;\nvoid main(){}",n=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(n,i),t.compileShader(n),!!t.getShaderParameter(n,t.COMPILE_STATUS)}function e(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}T.isWebglSupported=function(e){if(T.isLikelyNode)return!1;e=e||T.WebglFilterBackend.prototype.tileSize;var i=document.createElement("canvas"),n=i.getContext("webgl")||i.getContext("experimental-webgl"),r=!1;if(n){T.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),r=T.maxTextureSize>=e;for(var s=["highp","mediump","lowp"],o=0;o<3;o++)if(t(n,s[o])){T.webGlPrecision=s[o];break}}return this.isSupported=r,r},T.WebglFilterBackend=e,e.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,n=void 0!==window.performance;try{new ImageData(1,1),i=!0}catch(t){i=!1}var r="undefined"!=typeof ArrayBuffer,s="undefined"!=typeof Uint8ClampedArray;if(n&&i&&r&&s){var o=T.util.createCanvasElement(),a=new ArrayBuffer(t*e*4);if(T.forceGLPutImageData)return this.imageBuffer=a,void(this.copyGLTo2D=P);var h,c,l={imageBuffer:a,destinationWidth:t,destinationHeight:e,targetCanvas:o};o.width=t,o.height=e,h=window.performance.now(),O.call(l,this.gl,l),c=window.performance.now()-h,h=window.performance.now(),P.call(l,this.gl,l),c>window.performance.now()-h?(this.imageBuffer=a,this.copyGLTo2D=P):this.copyGLTo2D=O}},createWebGLCanvas:function(t,e){var i=T.util.createCanvasElement();i.width=t,i.height=e;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},r=i.getContext("webgl",n);r||(r=i.getContext("experimental-webgl",n)),r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)},applyFilters:function(t,e,i,n,r,s){var o,a=this.gl;s&&(o=this.getCachedTexture(s,e));var h={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:n,destinationWidth:i,destinationHeight:n,context:a,sourceTexture:this.createTexture(a,i,n,!o&&e),targetTexture:this.createTexture(a,i,n),originalTexture:o||this.createTexture(a,i,n,!o&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},c=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,c),t.forEach((function(t){t&&t.applyTo(h)})),function(t){var e=t.targetCanvas,i=e.width,n=e.height,r=t.destinationWidth,s=t.destinationHeight;i===r&&n===s||(e.width=r,e.height=s)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(c),r.getContext("2d").setTransform(1,0,0,1,0,0),h},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,n,r){var s=t.createTexture();return t.bindTexture(t.TEXTURE_2D,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r||t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r||t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),s},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:O,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var n=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);n&&(e.renderer=n.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}}(),function(){"use strict";var t=function(){};function e(){}T.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,n,r){var s=r.getContext("2d");s.drawImage(e,0,0,i,n);var o={sourceWidth:i,sourceHeight:n,imageData:s.getImageData(0,0,i,n),originalEl:e,originalImageData:s.getImageData(0,0,i,n),canvasEl:r,ctx:s,filterBackend:this};return t.forEach((function(t){t.applyTo(o)})),o.imageData.width===i&&o.imageData.height===n||(r.width=o.imageData.width,r.height=o.imageData.height),s.putImageData(o.imageData,0,0),o}}}(),T.Image=T.Image||{},T.Image.filters=T.Image.filters||{},T.Image.filters.BaseFilter=T.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==T.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+T.webGlPrecision+" float"));var n=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var r=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(r));var s=t.createProgram();if(t.attachShader(s,n),t.attachShader(s,r),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(s));var o=this.getAttributeLocations(t,s),a=this.getUniformLocations(t,s)||{};return a.uStepW=t.getUniformLocation(s,"uStepW"),a.uStepH=t.getUniformLocation(s,"uStepH"),{program:s,attributeLocations:o,uniformLocations:a}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var n=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,n=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,t.sourceWidth===e&&t.sourceHeight===i||(n.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(n,e,i)),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t.targetTexture,0)):(n.bindFramebuffer(n.FRAMEBUFFER,null),n.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=T.Image.filters[this.type].prototype;if(t){if(Array.isArray(e[t])){for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0}return e[t]===this[t]}return!1},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),T.Image.filters.BaseFilter.fromObject=function(t,e){var i=new T.Image.filters[t.type](t);return e&&e(i),i},function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.ColorMatrix=n(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,n,r,s,o=t.imageData.data,a=o.length,h=this.matrix,c=this.colorsOnly;for(s=0;s=_||o<0||o>=b||(h=4*(a*b+o),c=m[d*v+f],e+=g[h]*c,i+=g[h+1]*c,n+=g[h+2]*c,C||(r+=g[h+3]*c));S[s]=e,S[s+1]=i,S[s+2]=n,S[s+3]=C?g[s+3]:r}t.imageData=x},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Grayscale=n(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,n=t.imageData.data,r=n.length,s=this.mode;for(e=0;ec[0]&&r>c[1]&&s>c[2]&&n 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,n,r,s,o,a,h,c=t.imageData.data,l=c.length,u=1-this.alpha;i=(h=new e.Color(this.color).getSource())[0]*this.alpha,n=h[1]*this.alpha,r=h[2]*this.alpha;for(var f=0;f=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;var i=(e*=Math.PI)/t;return a(e)/e*a(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;var r,s=e.width,a=e.height,h=o(s*i),c=o(a*n);"sliceHack"===this.resizeType?r=this.sliceByTwo(t,s,a,h,c):"hermite"===this.resizeType?r=this.hermiteFastResize(t,s,a,h,c):"bilinear"===this.resizeType?r=this.bilinearFiltering(t,s,a,h,c):"lanczos"===this.resizeType&&(r=this.lanczosResize(t,s,a,h,c)),t.imageData=r},sliceByTwo:function(t,i,r,s,o){var a,h,c=t.imageData,l=.5,u=!1,f=!1,d=i*l,p=r*l,g=e.filterBackend.resources,m=0,v=0,y=i,b=0;for(g.sliceByTwo||(g.sliceByTwo=document.createElement("canvas")),((a=g.sliceByTwo).width<1.5*i||a.height=e)){j=n(1e3*s(w-x.x)),_[j]||(_[j]={});for(var F=S.y-b;F<=S.y+b;F++)F<0||F>=o||(I=n(1e3*s(F-x.y)),_[j][I]||(_[j][I]=d(r(i(j*m,2)+i(I*v,2))/1e3)),(T=_[j][I])>0&&(O+=T,P+=T*l[E=4*(F*e+w)],A+=T*l[E+1],k+=T*l[E+2],D+=T*l[E+3]))}f[E=4*(C*a+h)]=P/O,f[E+1]=A/O,f[E+2]=k/O,f[E+3]=D/O}return++h1&&I<-1||(b=2*I*I*I-3*I*I+1)>0&&(T+=b*d[3+(j=4*(D+O*e))],x+=b,d[j+3]<255&&(b=b*d[j+3]/250),S+=b*d[j],C+=b*d[j+1],w+=b*d[j+2],_+=b)}g[y]=S/_,g[y+1]=C/_,g[y+2]=w/_,g[y+3]=T/x}return p},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Contrast=n(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i=t.imageData.data,n=i.length,r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(e=0;e1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Gamma=n(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,n=this.gamma,r=i.length,s=1/n[0],o=1/n[1],a=1/n[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,r=256;e'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){var e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom"}t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;et&&(t=n)}return t},_renderTextLine:function(t,e,i,n,r,s){this._renderChars(t,e,i,n,r,s)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,n,r,s,o,a,h=t.fillStyle,c=this._getLeftOffset(),l=this._getTopOffset(),u=0,f=0,d=this.path,p=0,g=this._textLines.length;p=0:ia?u%=a:u<0&&(u+=a),this._setGraphemeOnPath(u,s,o),u+=s.kernedWidth}return{width:h,numOfSpaces:0}},_setGraphemeOnPath:function(t,i,n){var r=t+i.kernedWidth/2,s=this.path,o=e.util.getPointOnPath(s.path,r,s.segmentsInfo);i.renderLeft=o.x-n.x,i.renderTop=o.y-n.y,i.angle=o.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(t,e,i,n,r){var s,o=this.getCompleteStyleDeclaration(e,i),a=n?this.getCompleteStyleDeclaration(e,i-1):{},h=this._measureChar(t,o,n,a),c=h.kernedWidth,l=h.width;0!==this.charSpacing&&(l+=s=this._getWidthOfCharSpacing(),c+=s);var u={width:l,left:0,height:o.fontSize,kernedWidth:c,deltaY:o.deltaY};if(i>0&&!r){var f=this.__charBounds[e][i-1];u.left=f.left+f.width+h.kernedWidth-h.width}return u},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),n=1,r=e.length;n0){var O=y+s+u;"rtl"===this.direction&&(O=this.width-O-f),c&&v&&(t.fillStyle=v,t.fillRect(O,l+S*n+o,f,this.fontSize/15)),u=d.left,f=d.width,c=p,v=m,n=r,o=a}else f+=d.kernedWidth;O=y+s+u,"rtl"===this.direction&&(O=this.width-O-f),t.fillStyle=m,p&&m&&t.fillRect(O,l+S*n+o,f-x,this.fontSize/15),b+=i}else b+=i;t.restore()}},_getFontDeclaration:function(t,i){var n=t||this,r=this.fontFamily,s=e.Text.genericFonts.indexOf(r.toLowerCase())>-1,o=void 0===r||r.indexOf("'")>-1||r.indexOf(",")>-1||r.indexOf('"')>-1||s?n.fontFamily:'"'+n.fontFamily+'"';return[e.isLikelyNode?n.fontWeight:n.fontStyle,e.isLikelyNode?n.fontStyle:n.fontWeight,i?this.CACHE_FONT_SIZE+"px":n.fontSize+"px",o].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),n=new Array(i.length),r=["\n"],s=[],o=0;o-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}T.IText=T.util.createClass(T.Text,T.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:n.left,topOffset:n.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,n,r,s=0,o=0,a=this.get2DCursorLocation(t);n=a.charIndex,i=a.lineIndex;for(var h=0;h0?o:0)},"rtl"===this.direction&&(r.left*=-1),this.cursorOffsetCache=r,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,s=this.getValueOfPropertyAt(n,r,"fontSize"),o=this.scaleX*this.canvas.getZoom(),a=this.cursorWidth/o,h=t.topOffset,c=this.getValueOfPropertyAt(n,r,"deltaY");h+=(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-s*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.cursorColor||this.getValueOfPropertyAt(n,r,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-a/2,h+t.top+c,a,s)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,n=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=-1!==this.textAlign.indexOf("justify"),s=this.get2DCursorLocation(i),o=this.get2DCursorLocation(n),a=s.lineIndex,h=o.lineIndex,c=s.charIndex<0?0:s.charIndex,l=o.charIndex<0?0:o.charIndex,u=a;u<=h;u++){var f,d=this._getLineLeftOffset(u)||0,p=this.getHeightOfLine(u),g=0,m=0;if(u===a&&(g=this.__charBounds[a][c].left),u>=a&&u1)&&(p/=this.lineHeight);var y=t.left+d+g,b=m-g,_=p,x=0;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",_=1,x=p):e.fillStyle=this.selectionColor,"rtl"===this.direction&&(y=this.width-y-b),e.fillRect(y,t.top+t.topOffset+x,b,_),t.topOffset+=f}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),T.IText.fromObject=function(e,i){var n=T.util.stylesFromArray(e.styles,e.text),r=Object.assign({},e,{styles:n});if(delete r.path,t(r),r.styles)for(var s in r.styles)for(var o in r.styles[s])t(r.styles[s][o]);T.Object._fromObject("IText",r,(function(t){e.path?T.Object._fromObject("Path",e.path,(function(e){t.set("path",e),i(t)}),"path"):i(t)}),"text")}}(),S=T.util.object.clone,T.util.object.extend(T.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",(function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))}))},initRemovedHandler:function(){var t=this;this.on("removed",(function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],T.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))}))},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.__isMousedown=!1}))},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,n){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){r.isAborted||t[n]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout((function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")}),100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout((function(){e._tick()}),i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i0&&nthis.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var n=i.slice(0,t),r=T.util.string.graphemeSplit(n).length;if(t===e)return{selectionStart:r,selectionEnd:r};var s=i.slice(t,e);return{selectionStart:r,selectionEnd:r+T.util.string.graphemeSplit(s).length}},fromGraphemeToStringSelection:function(t,e,i){var n=i.slice(0,t).join("").length;return t===e?{selectionStart:n,selectionEnd:n}:{selectionStart:n,selectionEnd:n+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),n=i.lineIndex,r=i.charIndex,s=this.getValueOfPropertyAt(n,r,"fontSize")*this.lineHeight,o=e.leftOffset,a=this.calcTransformMatrix(),h={x:e.left+o,y:e.top+e.topOffset+s},c=this.canvas.getRetinaScaling(),l=this.canvas.upperCanvasEl,u=l.width/c,f=l.height/c,d=u-s,p=f-s,g=l.clientWidth/u,m=l.clientHeight/f;return h=T.util.transformPoint(h,a),(h=T.util.transformPoint(h,this.canvas.viewportTransform)).x*=g,h.y*=m,h.x<0&&(h.x=0),h.x>d&&(h.x=d),h.y<0&&(h.y=0),h.y>p&&(h.y=p),h.x+=this.canvas._offset.left,h.y+=this.canvas._offset.top,{left:h.x+"px",top:h.y+"px",fontSize:s+"px",charHeight:s}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text,e=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,n,r=this.get2DCursorLocation(t,!0),s=this.get2DCursorLocation(e,!0),o=r.lineIndex,a=r.charIndex,h=s.lineIndex,c=s.charIndex;if(o!==h){if(this.styles[o])for(i=a;i=c&&(n[l-f]=n[u],delete n[u])}},shiftLineStyles:function(t,e){var i=S(this.styles);for(var n in this.styles){var r=parseInt(n,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(t,e,i,n){var r,s={},o=!1,a=this._unwrappedTextLines[t].length,h=a===e;for(var c in i||(i=1),this.shiftLineStyles(t,i),this.styles[t]&&(r=this.styles[t][0===e?e:e-1]),this.styles[t]){var l=parseInt(c,10);l>=e&&(o=!0,s[l-e]=this.styles[t][c],h&&0===e||delete this.styles[t][c])}var u=!1;for(o&&!h&&(this.styles[t+i]=s,u=!0),(u||a>e)&&i--;i>0;)n&&n[i-1]?this.styles[t+i]={0:S(n[i-1])}:r?this.styles[t+i]={0:S(r)}:delete this.styles[t+i],i--;this._forceClearCache=!0},insertCharStyleObject:function(t,e,i,n){this.styles||(this.styles={});var r=this.styles[t],s=r?S(r):{};for(var o in i||(i=1),s){var a=parseInt(o,10);a>=e&&(r[a+i]=s[a],s[a-i]||delete r[a])}if(this._forceClearCache=!0,n)for(;i--;)Object.keys(n[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=S(n[i]));else if(r)for(var h=r[e?e-1:1];h&&i--;)this.styles[t][e+i]=S(h)},insertNewStyleBlock:function(t,e,i){for(var n=this.get2DCursorLocation(e,!0),r=[0],s=0,o=0;o0&&(this.insertCharStyleObject(n.lineIndex,n.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),s&&this.insertNewlineStyleObject(n.lineIndex,n.charIndex+r[0],s),o=1;o0?this.insertCharStyleObject(n.lineIndex+o,0,r[o],i):i&&this.styles[n.lineIndex+o]&&i[0]&&(this.styles[n.lineIndex+o][0]=i[0]),i=i&&i.slice(r[o]+1);r[o]>0&&this.insertCharStyleObject(n.lineIndex+o,0,r[o],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&it?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}}),T.util.object.extend(T.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(t.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,!(!this.editable||this.group||t.transform&&t.transform.actionPerformed||t.e.button&&1!==t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,n,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e,i=this.getLocalPointer(t),n=0,r=0,s=0,o=0,a=0,h=0,c=this._textLines.length;h0&&(o+=this._textLines[h-1].length+this.missingNewlineOffset(h-1));r=this._getLineLeftOffset(a)*this.scaleX,e=this._textLines[a],"rtl"===this.direction&&(i.x=this.width*this.scaleX-i.x+r);for(var l=0,u=e.length;ls||o<0?0:1);return this.flipX&&(a=r-a),a>this._text.length&&(a=this._text.length),a}}),T.util.object.extend(T.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=T.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: "+t.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):T.document.body.appendChild(this.hiddenTextarea),T.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),T.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),T.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),T.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),T.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),T.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),T.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(T.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){var e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,n,r,s,o,a=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,h=this._text.length,c=a.length,l=c-h,u=this.selectionStart,f=this.selectionEnd,d=u!==f;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var p=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),g=u>p.selectionStart;d?(i=this._text.slice(u,f),l+=f-u):c0&&(n+=(i=this.__charBounds[t][e-1]).left+i.width),n},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var s=n.charIndex,o=this._getWidthBeforeCursor(r,s),a=this._getIndexOnLine(r+1,o);return this._textLines[r].slice(s).length+a+1+this.missingNewlineOffset(r)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;var s=n.charIndex,o=this._getWidthBeforeCursor(r,s),a=this._getIndexOnLine(r-1,o),h=this._textLines[r].slice(0,s),c=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+a-h.length+(1-c)},_getIndexOnLine:function(t,e){for(var i,n,r=this._textLines[t],s=this._getLineLeftOffset(t),o=0,a=0,h=r.length;ae){n=!0;var c=s-i,l=s,u=Math.abs(c-e);o=Math.abs(l-e)=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var n;if(t.altKey)n=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;n=this["findLineBoundary"+i](this[e])}if(void 0!==n&&this[e]!==n)return this[e]=n,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,n){void 0===n&&(n=i),n>i&&this.removeStyleFromTo(i,n);var r=T.util.string.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[].concat(this._text.slice(0,i),r,this._text.slice(n)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),C=T.util.toFixed,w=/ +/g,T.util.object.extend(T.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),'\t\t",t.textSpans.join(""),"\n"]},_getSVGTextAndBg:function(t,e){var i,n=[],r=[],s=t;this._setSVGBg(r);for(var o=0,a=this._textLines.length;o",T.util.string.escapeXml(t),""].join("")},_setSVGTextLineText:function(t,e,i,n){var r,s,o,a,h,c=this.getHeightOfLine(e),l=-1!==this.textAlign.indexOf("justify"),u="",f=0,d=this._textLines[e];n+=c*(1-this._fontSizeFraction)/this.lineHeight;for(var p=0,g=d.length-1;p<=g;p++)h=p===g||this.charSpacing,u+=d[p],o=this.__charBounds[e][p],0===f?(i+=o.kernedWidth-o.width,f+=o.width):f+=o.kernedWidth,l&&!h&&this._reSpaceAndTab.test(d[p])&&(h=!0),h||(r=r||this.getCompleteStyleDeclaration(e,p),s=this.getCompleteStyleDeclaration(e,p+1),h=T.util.hasStyleChanged(r,s,!0)),h&&(a=this._getStyleDeclaration(e,p)||{},t.push(this._createTextCharSpan(u,a,i,n)),u="",r=s,i+=f,f=0)},_pushTextBgRect:function(t,e,i,n,r,s){var o=T.Object.NUM_FRACTION_DIGITS;t.push("\t\t\n')},_setSVGTextLineBg:function(t,e,i,n){for(var r,s,o=this._textLines[e],a=this.getHeightOfLine(e)/this.lineHeight,h=0,c=0,l=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),u=0,f=o.length;uthis.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,n=0,r={},s=0;s0?(i=0,n++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[n])&&s>0&&(i++,n++),r[s]={line:e,offset:i},n+=t.graphemeLines[s].length,i+=t.graphemeLines[s].length;return r},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[i];n&&(i=n.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,n=0,r=!1,s=this._styleMap[t],o=this._styleMap[t+1];for(var a in s&&(t=s.line,n=s.offset),o&&(r=o.line===t,e=o.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var h in i[a])if(h>=n&&(!r||hn&&!m?(a.push(h),h=[],s=d,m=!0):s+=v,m||o||h.push(f),h=h.concat(l),p=o?0:this._measureWord([f],i,u),u++,m=!1,d>g&&(g=d);return y&&a.push(h),g+r>this.dynamicMinWidth&&(this.dynamicMinWidth=g-v+r),a},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),n=this._wrapText(i.lines,this.width),r=new Array(n.length),s=0;s{e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,l=-7,u=i?r-1:0,f=i?-1:1,d=t[e+u];for(u+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+t[e+u],u+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+t[e+u],u+=f,l-=8);if(0===s)s=1-c;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=c}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,c=8*s-r-1,l=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+u>=1?f/h:f*Math.pow(2,1-u))*h>=2&&(o++,h/=2),o+u>=l?(a=0,o=l):o+u>=1?(a=(e*h-1)*Math.pow(2,r),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=p,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=p,o/=256,c-=8);t[i+d-p]|=128*g}},895:(t,e,i)=>{var n=i(399),r=/\s+/g,s=/%[\dA-F]{2}/g,o=/"/g;function a(t){switch(t){case"%20":return" ";case"%3D":return"=";case"%3A":return":";case"%2F":return"/";default:return t.toLowerCase()}}function h(t){if("string"!=typeof t)throw new TypeError("Expected a string, but received "+typeof t);var e,i;return 65279===t.charCodeAt(0)&&(t=t.slice(1)),"data:image/svg+xml,"+function(t){return encodeURIComponent(t).replace(s,a)}((i=t,e=i.trim().replace(r," "),Object.keys(n).forEach((function(t){n[t].test(e)&&(e=e.replace(n[t],t))})),e).replace(o,"'"))}h.toSrcset=function(t){return h(t).replace(/ /g,"%20")},t.exports=h},399:t=>{t.exports={aqua:/#00ffff(ff)?(?!\w)|#0ff(f)?(?!\w)/gi,azure:/#f0ffff(ff)?(?!\w)/gi,beige:/#f5f5dc(ff)?(?!\w)/gi,bisque:/#ffe4c4(ff)?(?!\w)/gi,black:/#000000(ff)?(?!\w)|#000(f)?(?!\w)/gi,blue:/#0000ff(ff)?(?!\w)|#00f(f)?(?!\w)/gi,brown:/#a52a2a(ff)?(?!\w)/gi,coral:/#ff7f50(ff)?(?!\w)/gi,cornsilk:/#fff8dc(ff)?(?!\w)/gi,crimson:/#dc143c(ff)?(?!\w)/gi,cyan:/#00ffff(ff)?(?!\w)|#0ff(f)?(?!\w)/gi,darkblue:/#00008b(ff)?(?!\w)/gi,darkcyan:/#008b8b(ff)?(?!\w)/gi,darkgrey:/#a9a9a9(ff)?(?!\w)/gi,darkred:/#8b0000(ff)?(?!\w)/gi,deeppink:/#ff1493(ff)?(?!\w)/gi,dimgrey:/#696969(ff)?(?!\w)/gi,gold:/#ffd700(ff)?(?!\w)/gi,green:/#008000(ff)?(?!\w)/gi,grey:/#808080(ff)?(?!\w)/gi,honeydew:/#f0fff0(ff)?(?!\w)/gi,hotpink:/#ff69b4(ff)?(?!\w)/gi,indigo:/#4b0082(ff)?(?!\w)/gi,ivory:/#fffff0(ff)?(?!\w)/gi,khaki:/#f0e68c(ff)?(?!\w)/gi,lavender:/#e6e6fa(ff)?(?!\w)/gi,lime:/#00ff00(ff)?(?!\w)|#0f0(f)?(?!\w)/gi,linen:/#faf0e6(ff)?(?!\w)/gi,maroon:/#800000(ff)?(?!\w)/gi,moccasin:/#ffe4b5(ff)?(?!\w)/gi,navy:/#000080(ff)?(?!\w)/gi,oldlace:/#fdf5e6(ff)?(?!\w)/gi,olive:/#808000(ff)?(?!\w)/gi,orange:/#ffa500(ff)?(?!\w)/gi,orchid:/#da70d6(ff)?(?!\w)/gi,peru:/#cd853f(ff)?(?!\w)/gi,pink:/#ffc0cb(ff)?(?!\w)/gi,plum:/#dda0dd(ff)?(?!\w)/gi,purple:/#800080(ff)?(?!\w)/gi,red:/#ff0000(ff)?(?!\w)|#f00(f)?(?!\w)/gi,salmon:/#fa8072(ff)?(?!\w)/gi,seagreen:/#2e8b57(ff)?(?!\w)/gi,seashell:/#fff5ee(ff)?(?!\w)/gi,sienna:/#a0522d(ff)?(?!\w)/gi,silver:/#c0c0c0(ff)?(?!\w)/gi,skyblue:/#87ceeb(ff)?(?!\w)/gi,snow:/#fffafa(ff)?(?!\w)/gi,tan:/#d2b48c(ff)?(?!\w)/gi,teal:/#008080(ff)?(?!\w)/gi,thistle:/#d8bfd8(ff)?(?!\w)/gi,tomato:/#ff6347(ff)?(?!\w)/gi,violet:/#ee82ee(ff)?(?!\w)/gi,wheat:/#f5deb3(ff)?(?!\w)/gi,white:/#ffffff(ff)?(?!\w)|#fff(f)?(?!\w)/gi}},861:(t,e,i)=>{var n=i(287),r=n.Buffer;function s(t,e){for(var i in t)e[i]=t[i]}function o(t,e,i){return r(t,e,i)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(s(n,e),e.Buffer=o),o.prototype=Object.create(r.prototype),s(r,o),o.from=function(t,e,i){if("number"==typeof t)throw new TypeError("Argument must not be a number");return r(t,e,i)},o.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=r(t);return void 0!==e?"string"==typeof i?n.fill(e,i):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},43:(t,e,i)=>{!function(t){t.parser=function(t,e){return new r(t,e)},t.SAXParser=r,t.SAXStream=o,t.createStream=function(t,e){return new o(t,e)},t.MAX_BUFFER_LENGTH=65536;var e,n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function r(e,i){if(!(this instanceof r))return new r(e,i);var s=this;!function(t){for(var e=0,i=n.length;e"===s?(O(i,"onsgmldeclaration",i.sgmlDecl),i.sgmlDecl="",i.state=w.TEXT):v(s)?(i.state=w.SGML_DECL_QUOTED,i.sgmlDecl+=s):i.sgmlDecl+=s;continue;case w.SGML_DECL_QUOTED:s===i.q&&(i.state=w.SGML_DECL,i.q=""),i.sgmlDecl+=s;continue;case w.DOCTYPE:">"===s?(i.state=w.TEXT,O(i,"ondoctype",i.doctype),i.doctype=!0):(i.doctype+=s,"["===s?i.state=w.DOCTYPE_DTD:v(s)&&(i.state=w.DOCTYPE_QUOTED,i.q=s));continue;case w.DOCTYPE_QUOTED:i.doctype+=s,s===i.q&&(i.q="",i.state=w.DOCTYPE);continue;case w.DOCTYPE_DTD:"]"===s?(i.doctype+=s,i.state=w.DOCTYPE):"<"===s?(i.state=w.OPEN_WAKA,i.startTagPosition=i.position):v(s)?(i.doctype+=s,i.state=w.DOCTYPE_DTD_QUOTED,i.q=s):i.doctype+=s;continue;case w.DOCTYPE_DTD_QUOTED:i.doctype+=s,s===i.q&&(i.state=w.DOCTYPE_DTD,i.q="");continue;case w.COMMENT:"-"===s?i.state=w.COMMENT_ENDING:i.comment+=s;continue;case w.COMMENT_ENDING:"-"===s?(i.state=w.COMMENT_ENDED,i.comment=A(i.opt,i.comment),i.comment&&O(i,"oncomment",i.comment),i.comment=""):(i.comment+="-"+s,i.state=w.COMMENT);continue;case w.COMMENT_ENDED:">"!==s?(j(i,"Malformed comment"),i.comment+="--"+s,i.state=w.COMMENT):i.doctype&&!0!==i.doctype?i.state=w.DOCTYPE_DTD:i.state=w.TEXT;continue;case w.CDATA:"]"===s?i.state=w.CDATA_ENDING:i.cdata+=s;continue;case w.CDATA_ENDING:"]"===s?i.state=w.CDATA_ENDING_2:(i.cdata+="]"+s,i.state=w.CDATA);continue;case w.CDATA_ENDING_2:">"===s?(i.cdata&&O(i,"oncdata",i.cdata),O(i,"onclosecdata"),i.cdata="",i.state=w.TEXT):"]"===s?i.cdata+="]":(i.cdata+="]]"+s,i.state=w.CDATA);continue;case w.PROC_INST:"?"===s?i.state=w.PROC_INST_ENDING:m(s)?i.state=w.PROC_INST_BODY:i.procInstName+=s;continue;case w.PROC_INST_BODY:if(!i.procInstBody&&m(s))continue;"?"===s?i.state=w.PROC_INST_ENDING:i.procInstBody+=s;continue;case w.PROC_INST_ENDING:">"===s?(O(i,"onprocessinginstruction",{name:i.procInstName,body:i.procInstBody}),i.procInstName=i.procInstBody="",i.state=w.TEXT):(i.procInstBody+="?"+s,i.state=w.PROC_INST_BODY);continue;case w.OPEN_TAG:b(d,s)?i.tagName+=s:(I(i),">"===s?M(i):"/"===s?i.state=w.OPEN_TAG_SLASH:(m(s)||j(i,"Invalid character in tag name"),i.state=w.ATTRIB));continue;case w.OPEN_TAG_SLASH:">"===s?(M(i,!0),R(i)):(j(i,"Forward-slash in opening tag not followed by >"),i.state=w.ATTRIB);continue;case w.ATTRIB:if(m(s))continue;">"===s?M(i):"/"===s?i.state=w.OPEN_TAG_SLASH:b(f,s)?(i.attribName=s,i.attribValue="",i.state=w.ATTRIB_NAME):j(i,"Invalid attribute name");continue;case w.ATTRIB_NAME:"="===s?i.state=w.ATTRIB_VALUE:">"===s?(j(i,"Attribute without value"),i.attribValue=i.attribName,L(i),M(i)):m(s)?i.state=w.ATTRIB_NAME_SAW_WHITE:b(d,s)?i.attribName+=s:j(i,"Invalid attribute name");continue;case w.ATTRIB_NAME_SAW_WHITE:if("="===s)i.state=w.ATTRIB_VALUE;else{if(m(s))continue;j(i,"Attribute without value"),i.tag.attributes[i.attribName]="",i.attribValue="",O(i,"onattribute",{name:i.attribName,value:""}),i.attribName="",">"===s?M(i):b(f,s)?(i.attribName=s,i.state=w.ATTRIB_NAME):(j(i,"Invalid attribute name"),i.state=w.ATTRIB)}continue;case w.ATTRIB_VALUE:if(m(s))continue;v(s)?(i.q=s,i.state=w.ATTRIB_VALUE_QUOTED):(i.opt.unquotedAttributeValues||k(i,"Unquoted attribute value"),i.state=w.ATTRIB_VALUE_UNQUOTED,i.attribValue=s);continue;case w.ATTRIB_VALUE_QUOTED:if(s!==i.q){"&"===s?i.state=w.ATTRIB_VALUE_ENTITY_Q:i.attribValue+=s;continue}L(i),i.q="",i.state=w.ATTRIB_VALUE_CLOSED;continue;case w.ATTRIB_VALUE_CLOSED:m(s)?i.state=w.ATTRIB:">"===s?M(i):"/"===s?i.state=w.OPEN_TAG_SLASH:b(f,s)?(j(i,"No whitespace between attributes"),i.attribName=s,i.attribValue="",i.state=w.ATTRIB_NAME):j(i,"Invalid attribute name");continue;case w.ATTRIB_VALUE_UNQUOTED:if(!y(s)){"&"===s?i.state=w.ATTRIB_VALUE_ENTITY_U:i.attribValue+=s;continue}L(i),">"===s?M(i):i.state=w.ATTRIB;continue;case w.CLOSE_TAG:if(i.tagName)">"===s?R(i):b(d,s)?i.tagName+=s:i.script?(i.script+=""===s?R(i):j(i,"Invalid characters in closing tag");continue;case w.TEXT_ENTITY:case w.ATTRIB_VALUE_ENTITY_Q:case w.ATTRIB_VALUE_ENTITY_U:var l,u;switch(i.state){case w.TEXT_ENTITY:l=w.TEXT,u="textNode";break;case w.ATTRIB_VALUE_ENTITY_Q:l=w.ATTRIB_VALUE_QUOTED,u="attribValue";break;case w.ATTRIB_VALUE_ENTITY_U:l=w.ATTRIB_VALUE_UNQUOTED,u="attribValue"}if(";"===s){var x=B(i);i.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(x)?(i.entity="",i.state=l,i.write(x)):(i[u]+=x,i.entity="",i.state=l)}else b(i.entity.length?g:p,s)?i.entity+=s:(j(i,"Invalid character in entity name"),i[u]+="&"+i.entity+s,i.entity="",i.state=l);continue;default:throw new Error(i,"Unknown state: "+i.state)}return i.position>=i.bufferCheckPosition&&function(e){for(var i=Math.max(t.MAX_BUFFER_LENGTH,10),r=0,s=0,o=n.length;si)switch(n[s]){case"textNode":P(e);break;case"cdata":O(e,"oncdata",e.cdata),e.cdata="";break;case"script":O(e,"onscript",e.script),e.script="";break;default:k(e,"Max buffer length exceeded: "+n[s])}r=Math.max(r,a)}var h=t.MAX_BUFFER_LENGTH-r;e.bufferCheckPosition=h+e.position}(i),i},resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var t;P(t=this),""!==t.cdata&&(O(t,"oncdata",t.cdata),t.cdata=""),""!==t.script&&(O(t,"onscript",t.script),t.script="")}};try{e=i(789).Stream}catch(t){e=function(){}}e||(e=function(){});var s=t.EVENTS.filter((function(t){return"error"!==t&&"end"!==t}));function o(t,i){if(!(this instanceof o))return new o(t,i);e.apply(this),this._parser=new r(t,i),this.writable=!0,this.readable=!0;var n=this;this._parser.onend=function(){n.emit("end")},this._parser.onerror=function(t){n.emit("error",t),n._parser.error=null},this._decoder=null,s.forEach((function(t){Object.defineProperty(n,"on"+t,{get:function(){return n._parser["on"+t]},set:function(e){if(!e)return n.removeAllListeners(t),n._parser["on"+t]=e,e;n.on(t,e)},enumerable:!0,configurable:!1})}))}o.prototype=Object.create(e.prototype,{constructor:{value:o}}),o.prototype.write=function(t){if("function"==typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(t)){if(!this._decoder){var e=i(141).I;this._decoder=new e("utf8")}t=this._decoder.write(t)}return this._parser.write(t.toString()),this.emit("data",t),!0},o.prototype.end=function(t){return t&&t.length&&this.write(t),this._parser.end(),!0},o.prototype.on=function(t,i){var n=this;return n._parser["on"+t]||-1===s.indexOf(t)||(n._parser["on"+t]=function(){var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);e.splice(0,0,t),n.emit.apply(n,e)}),e.prototype.on.call(n,t,i)};var a="[CDATA[",h="DOCTYPE",c="http://www.w3.org/XML/1998/namespace",l="http://www.w3.org/2000/xmlns/",u={xml:c,xmlns:l},f=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,d=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,p=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,g=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function m(t){return" "===t||"\n"===t||"\r"===t||"\t"===t}function v(t){return'"'===t||"'"===t}function y(t){return">"===t||m(t)}function b(t,e){return t.test(e)}function _(t,e){return!b(t,e)}var x,S,C,w=0;for(var T in t.STATE={BEGIN:w++,BEGIN_WHITESPACE:w++,TEXT:w++,TEXT_ENTITY:w++,OPEN_WAKA:w++,SGML_DECL:w++,SGML_DECL_QUOTED:w++,DOCTYPE:w++,DOCTYPE_QUOTED:w++,DOCTYPE_DTD:w++,DOCTYPE_DTD_QUOTED:w++,COMMENT_STARTING:w++,COMMENT:w++,COMMENT_ENDING:w++,COMMENT_ENDED:w++,CDATA:w++,CDATA_ENDING:w++,CDATA_ENDING_2:w++,PROC_INST:w++,PROC_INST_BODY:w++,PROC_INST_ENDING:w++,OPEN_TAG:w++,OPEN_TAG_SLASH:w++,ATTRIB:w++,ATTRIB_NAME:w++,ATTRIB_NAME_SAW_WHITE:w++,ATTRIB_VALUE:w++,ATTRIB_VALUE_QUOTED:w++,ATTRIB_VALUE_CLOSED:w++,ATTRIB_VALUE_UNQUOTED:w++,ATTRIB_VALUE_ENTITY_Q:w++,ATTRIB_VALUE_ENTITY_U:w++,CLOSE_TAG:w++,CLOSE_TAG_SAW_WHITE:w++,SCRIPT:w++,SCRIPT_ENDING:w++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach((function(e){var i=t.ENTITIES[e],n="number"==typeof i?String.fromCharCode(i):i;t.ENTITIES[e]=n})),t.STATE)t.STATE[t.STATE[T]]=T;function E(t,e,i){t[e]&&t[e](i)}function O(t,e,i){t.textNode&&P(t),E(t,e,i)}function P(t){t.textNode=A(t.opt,t.textNode),t.textNode&&E(t,"ontext",t.textNode),t.textNode=""}function A(t,e){return t.trim&&(e=e.trim()),t.normalize&&(e=e.replace(/\s+/g," ")),e}function k(t,e){return P(t),t.trackPosition&&(e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c),e=new Error(e),t.error=e,E(t,"onerror",e),t}function D(t){return t.sawRoot&&!t.closedRoot&&j(t,"Unclosed root tag"),t.state!==w.BEGIN&&t.state!==w.BEGIN_WHITESPACE&&t.state!==w.TEXT&&k(t,"Unexpected end"),P(t),t.c="",t.closed=!0,E(t,"onend"),r.call(t,t.strict,t.opt),t}function j(t,e){if("object"!=typeof t||!(t instanceof r))throw new Error("bad call to strictFail");t.strict&&k(t,e)}function I(t){t.strict||(t.tagName=t.tagName[t.looseCase]());var e=t.tags[t.tags.length-1]||t,i=t.tag={name:t.tagName,attributes:{}};t.opt.xmlns&&(i.ns=e.ns),t.attribList.length=0,O(t,"onopentagstart",i)}function F(t,e){var i=t.indexOf(":")<0?["",t]:t.split(":"),n=i[0],r=i[1];return e&&"xmlns"===t&&(n="xmlns",r=""),{prefix:n,local:r}}function L(t){if(t.strict||(t.attribName=t.attribName[t.looseCase]()),-1!==t.attribList.indexOf(t.attribName)||t.tag.attributes.hasOwnProperty(t.attribName))t.attribName=t.attribValue="";else{if(t.opt.xmlns){var e=F(t.attribName,!0),i=e.prefix,n=e.local;if("xmlns"===i)if("xml"===n&&t.attribValue!==c)j(t,"xml: prefix must be bound to "+c+"\nActual: "+t.attribValue);else if("xmlns"===n&&t.attribValue!==l)j(t,"xmlns: prefix must be bound to "+l+"\nActual: "+t.attribValue);else{var r=t.tag,s=t.tags[t.tags.length-1]||t;r.ns===s.ns&&(r.ns=Object.create(s.ns)),r.ns[n]=t.attribValue}t.attribList.push([t.attribName,t.attribValue])}else t.tag.attributes[t.attribName]=t.attribValue,O(t,"onattribute",{name:t.attribName,value:t.attribValue});t.attribName=t.attribValue=""}}function M(t,e){if(t.opt.xmlns){var i=t.tag,n=F(t.tagName);i.prefix=n.prefix,i.local=n.local,i.uri=i.ns[n.prefix]||"",i.prefix&&!i.uri&&(j(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),i.uri=n.prefix);var r=t.tags[t.tags.length-1]||t;i.ns&&r.ns!==i.ns&&Object.keys(i.ns).forEach((function(e){O(t,"onopennamespace",{prefix:e,uri:i.ns[e]})}));for(var s=0,o=t.attribList.length;s",t.tagName="",void(t.state=w.SCRIPT);O(t,"onscript",t.script),t.script=""}var e=t.tags.length,i=t.tagName;t.strict||(i=i[t.looseCase]());for(var n=i;e--&&t.tags[e].name!==n;)j(t,"Unexpected close tag");if(e<0)return j(t,"Unmatched closing tag: "+t.tagName),t.textNode+="",void(t.state=w.TEXT);t.tagName=i;for(var r=t.tags.length;r-- >e;){var s=t.tag=t.tags.pop();t.tagName=t.tag.name,O(t,"onclosetag",t.tagName);var o={};for(var a in s.ns)o[a]=s.ns[a];var h=t.tags[t.tags.length-1]||t;t.opt.xmlns&&s.ns!==h.ns&&Object.keys(s.ns).forEach((function(e){var i=s.ns[e];O(t,"onclosenamespace",{prefix:e,uri:i})}))}0===e&&(t.closedRoot=!0),t.tagName=t.attribValue=t.attribName="",t.attribList.length=0,t.state=w.TEXT}function B(t){var e,i=t.entity,n=i.toLowerCase(),r="";return t.ENTITIES[i]?t.ENTITIES[i]:t.ENTITIES[n]?t.ENTITIES[n]:("#"===(i=n).charAt(0)&&("x"===i.charAt(1)?(i=i.slice(2),r=(e=parseInt(i,16)).toString(16)):(i=i.slice(1),r=(e=parseInt(i,10)).toString(10))),i=i.replace(/^0+/,""),isNaN(e)||r.toLowerCase()!==i?(j(t,"Invalid character entity"),"&"+t.entity+";"):String.fromCodePoint(e))}function W(t,e){"<"===e?(t.state=w.OPEN_WAKA,t.startTagPosition=t.position):m(e)||(j(t,"Non-whitespace before first tag."),t.textNode=e,t.state=w.TEXT)}function N(t,e){var i="";return e1114111||S(o)!==o)throw RangeError("Invalid code point: "+o);o<=65535?i.push(o):(t=55296+((o-=65536)>>10),e=o%1024+56320,i.push(t,e)),(n+1===r||i.length>16384)&&(s+=x.apply(null,i),i.length=0)}return s},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:C,configurable:!0,writable:!0}):String.fromCodePoint=C)}(e)},789:(t,e,i)=>{var n=i(995);function r(){n.call(this)}r.prototype=new n,t.exports=r,r.Stream=r,r.prototype.pipe=function(t,e){var i=this;function n(e){t.writable&&!1===t.write(e)&&i.pause&&i.pause()}function r(){i.readable&&i.resume&&i.resume()}i.on("data",n),t.on("drain",r),t._isStdio||e&&!1===e.end||(i.on("end",o),i.on("close",a));var s=!1;function o(){s||(s=!0,t.end())}function a(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){if(c(),!this.hasListeners("error"))throw t}function c(){i.off("data",n),t.off("drain",r),i.off("end",o),i.off("close",a),i.off("error",h),t.off("error",h),i.off("end",c),i.off("close",c),t.off("end",c),t.off("close",c)}return i.on("error",h),t.on("error",h),i.on("end",c),i.on("close",c),t.on("end",c),t.on("close",c),t.emit("pipe",i),t}},141:(t,e,i)=>{"use strict";var n=i(861).Buffer,r=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===r||!r(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=h,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=u,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,i=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var n=i.charCodeAt(i.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function l(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function u(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.I=s,s.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i=0?(r>0&&(t.lastNeed=r-1),r):--n=0?(r>0&&(t.lastNeed=r-2),r):--n=0?(r>0&&(2===r?r=0:t.lastNeed=r-3),r):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var n=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},79:(t,e,i)=>{"use strict";var n=i(895),r=i.n(n),s=i(38),o=i(676);const a={0:[255,64,64],.25:[255,255,64],.5:[64,255,64],.75:[64,255,255],1:[64,64,255],keys:[0,.25,.5,.75,1]},h={0:[0,0,0],40:[0,32,233],50:[117,234,76],80:[219,61,233],200:[219,51,36],keys:[0,40,50,80,200]};function c(t){let e=0;return 1===t.length?e=2.5:2===t.length?e=10:3===t.length?e=15.5:4===t.length?e=21:5===t.length?e=29:6===t.length?e=35:7===t.length?e=41:8===t.length&&(e=47),e}function l(t,e,i,n,r){return(i*n-r)/(t+e)}function u(t,e,i,n,r,s,o){const a=l(t,e,t,n,r);return[s+o,s+a-o,s+a+r+o,s+a+r+l(t,e,i,n,r)-o]}function f(t,e,i,n,r,s){const o=t+n*(e-t)/i+s;return[o,t+r*(e-t)/i-s-o]}var d;!function(t){t.fixed="fixed",t.dynamic="dynamic",t.ncbiblast="ncbiblast",t.blasterjs="blasterjs"}(d||(d={}));const p={value:"",required:!0,minLength:35,maxLength:60,pattern:/([a-z_])*-([A-Z0-9])*-\d*-\d*-\d*-(np2|p1m|p2m)$/},g={selectable:!1,evented:!1,objectCaching:!1},m={...g},v={...g},y={...g};function b(t,e,i){const n=i.keys;if(n.length!=e.length)throw Error("Color Scheme and Gradient Steps should have matching lengths!");if(t+0===0)return`rgb(${i[n[0]].join(",")})`;{const i=e[0],n=e[1],r=e[2],s=e[3],o=e[4];let a;if(t=e[1]&&t=e[2]&&t=e[3]&&t=e[4]?`rgb(${i[n[4]].join(",")})`:"rgb(192,192,192)"}function x(t,e,i,n){let r=[];if(n===d.fixed)r=[0,Math.pow(10,-1),Math.pow(10,0),Math.pow(10,1),Math.pow(10,2)];else if(n===d.dynamic)if(e<1e-304){const t=-304;r=[0,Math.pow(10,t),Math.pow(10,t/2),Math.pow(10,t/4),Math.pow(10,t/8)]}else if(t<1){const n=Math.log10(e);if(e<=1){let s,o,a;if(0===t&&i>0)s=Math.log10(i)-1;else{const e=Math.log10(t);s=e+(n-e)/2}o=s+(n-s)/2,a=o+(n-o)/2,r=[t,Math.pow(10,s),Math.pow(10,o),Math.pow(10,a),e]}else{const n=Math.log10(i)-Math.log10(e);r=Math.abs(n)<=2?[t,1,(2+e)/3,(2+2*e)/3,e]:Math.abs(n)<=4?[t,Math.pow(10,n/2),1,(e+1)/2,e]:[t,Math.pow(10,n/2),Math.pow(10,n/4),1,e]}}else r=[t,(3*t+e)/4,(t+e)/2,(t+3*e)/4,e];else r=n===d.ncbiblast?[0,40,50,80,200]:[0,1e-5,.01,1,100];return r}function S(t){let e;return e="Pfam"==t?"rgb(211,47,47)":"SUPERFAMILY"==t?"rgb(171,71,188)":"SMART"==t?"rgb(106,27,154)":"HAMAP"==t?"rgb(57,73,171)":"PANTHER"==t?"rgb(33,150,243)":"PRODOM"==t?"rgb(0,188,212)":"PROSITE profiles"==t?"rgb(0,150,136)":"CDD"==t?"rgb(76,175,80)":"CATH-Gene3D"==t?"rgb(205,220,57)":"PIRSF"==t?"rgb(255,235,59)":"PRINTS"==t?"rgb(255,193,7)":"TIGRFAMs"==t?"rgb(255,112,67)":"SFLD"==t?"rgb(121,85,72)":"PROSITE patterns"==t?"rgb(55,71,79)":"rgb(128,128,128)",e}var C=i(990);class w{constructor(t){this.element=t}getFabricCanvas(){const t={defaultCursor:"default",moveCursor:"default",hoverCursor:"default"};this.staticCanvas?this.canvas=new o.fabric.StaticCanvas(this.element,t):this.canvas=new o.fabric.Canvas(this.element,t)}setFrameSize(){this.canvas.setWidth(this.canvasWidth),this.canvas.setHeight(this.canvasHeight)}renderCanvas(){this.canvas.renderAll()}}class T{constructor(){this.values=new Map}get(t){if(this.values.has(t))return this.values.get(t)}put(t,e){this.values.has(t)||this.values.set(t,e)}delete(t){this.values.has(t)&&this.values.delete(t)}}function E(t){return t<1e-4||t>1e4?t.toExponential(2):Number.isInteger(t)?t+".0":function(t){return Math.floor(t)===t?0:t.toString().split(".")[1].length||0}(t)>3?t.toFixed(3).toString():t.toString()}async function O(t,e="json"){return await fetch(t).then((i=>{if(!i.ok)throw new Error(`Could not retrieve data from ${t}`);if("json"!==e)return i.text();try{return i.json()}catch(e){throw new Error(`Could not decode JSON data from ${t}`)}})).catch((t=>console.log(t)))}function P(t,e){return t}function A(t){const e=t.split("-")[0];return"mock_jobid-I20200317-103136-0485-5599422-np2"===t?"https://raw.githubusercontent.com/ebi-jdispatcher/jdispatcher-viewers/master/src/testdata/ncbiblast.json":t.endsWith("-np2")?`https://wwwdev.ebi.ac.uk/Tools/services/rest/${e}/result/${t}/json`:`https://www.ebi.ac.uk/Tools/services/rest/${e}/result/${t}/json`}function k(t,e=!1){let i=!0;return t.required&&(i=i&&0!==t.value.trim().length),t.minLength&&(i=i&&t.value.trim().length>=t.minLength),t.maxLength&&(i=i&&t.value.trim().length<=t.maxLength),t.pattern&&(i=i&&t.pattern.test(t.value.trim())),e&&(i?console.log(`JobId "${t.value}" is valid!`):console.log(`JobId "${t.value}" is not valid!`)),i}function D(t){const e={...p};return e.value=t,e.value.startsWith("http")||e.value.includes("/")||e.value.includes("./")||!k(e)||(t=A(t)),t}function j(t,e=30){const i=function(t,e=30){let i="";for(const n of t.hits.slice(0,e))i+=""===i?`${n.hit_acc}`:`,${n.hit_acc}`;return i}(t,e);return function(t){return`https://www.ebi.ac.uk/Tools/dbfetch/dbfetch?db=iprmc;id=${t};format=iprmcxml;style=raw`}(i)}function I(t,e=30){return function(t,e){let i=0,n={};for(const r of t.interpromatch[0].protein)if(i++,i<=e){let t=[],e={};for(const i of r.match){let n={};if(void 0!==i.ipr){const r=`${F(i._attributes.dbname)}_${i.ipr[0]._attributes.id}`;t.includes(r)||t.push(r),r in e||(e[r]=[]),n={id:i.ipr[0]._attributes.id,name:i.ipr[0]._attributes.name,dbname:F(i._attributes.dbname),type:i.ipr[0]._attributes.type,altid:i._attributes.id,altname:i._attributes.name,status:i._attributes.status,model:i._attributes.model,evd:i._attributes.evd,start:Number(i.lcn[0]._attributes.start),end:Number(i.lcn[0]._attributes.end),fragments:i.lcn[0]._attributes.fragments,score:i.lcn[0]._attributes.fragments},e[r].push(n)}else{const r=`${F(i._attributes.dbname)}_${i._attributes.id}`;t.includes(r)||t.push(r),r in e||(e[r]=[]),n={id:i._attributes.id,name:i._attributes.name,dbname:F(i._attributes.dbname),status:i._attributes.status,model:i._attributes.model,evd:i._attributes.evd,type:"Unclassified",start:Number(i.lcn[0]._attributes.start),end:Number(i.lcn[0]._attributes.end),fragments:i.lcn[0]._attributes.fragments,score:i.lcn[0]._attributes.fragments},e[r].push(n)}}n[r._attributes.id]={id:r._attributes.id,name:r._attributes.name,length:Number(r._attributes.length),matches:t.sort(),match:e}}return n}(function(t){try{return JSON.parse((0,C.xml2json)(t,{compact:!0,spaces:2,alwaysArray:!0}))}catch(t){return console.log("Cannot parse the resulting Dbfetch response (likely not formatted XML)!"),{}}}(t),e)}function F(t){let e="Unclassified";return"IPR"===(t=t.toUpperCase())||"INTERPRO"===t?e="InterPro":"CATHGENE3D"===t||"CATH-GENE3D"===t||"GENE3D"===t?e="CATH-Gene3D":"CDD"===t?e="CDD":"PANTHER"===t?e="PANTHER":"HAMAP"===t?e="HAMAP":"PFAM"===t?e="Pfam":"PIRSF"===t?e="PIRSF":"PRINTS"===t?e="PRINTS":"PROSITE PROFILES"===t||"PROSITE_PROFILES"===t||"PROFILE"===t?e="PROSITE profiles":"PROSITE PATTERNS"===t||"PROSITE_PATTERNS"===t||"PROSITE"===t?e="PROSITE patterns":"SFLD"===t?e="SFLD":"SMART"===t?e="SMART":"SUPERFAMILY"===t||"SSF"===t?e="SUPERFAMILY":"TIGERFAMS"===t?e="TIGRFAMs":"PRODOM"===t&&(e="PRODOM"),e}function L(t,e){let i="";return t.startsWith("IPR")?i=`https://www.ebi.ac.uk/interpro/entry/InterPro/${t}`:"CATH-Gene3D"===e?i=`https://www.ebi.ac.uk/interpro/entry/cathgene3d/${t}`:"CDD"===e?i=`https://www.ebi.ac.uk/interpro/entry/cdd/${t}`:"PANTHER"===e?i=`https://www.ebi.ac.uk/interpro/entry/panther/${t}`:"HAMAP"===e?i=`https://www.ebi.ac.uk/interpro/entry/hamap/${t}`:"Pfam"===e?i=`https://www.ebi.ac.uk/interpro/entry/pfam/${t}`:"PIRSF"===e?i=`https://www.ebi.ac.uk/interpro/entry/pirsf/${t}`:"PRINTS"===e?i=`https://www.ebi.ac.uk/interpro/entry/prints/${t}`:"PROSITE profiles"===e?i=`https://www.ebi.ac.uk/interpro/entry/profile/${t}`:"PROSITE patterns"===e?i=`https://www.ebi.ac.uk/interpro/entry/prosite/${t}`:"SFLD"===e?i=`https://www.ebi.ac.uk/interpro/entry/sfld/${t}`:"SMART"===e?i=`https://www.ebi.ac.uk/interpro/entry/smart/${t}`:"SUPERFAMILY"===e?i=`https://www.ebi.ac.uk/interpro/entry/ssf/${t}`:"TIGRFAMs"===e?i=`https://www.ebi.ac.uk/interpro/entry/tigrfams/${t}`:"PRODOM"===e&&(i=`https://www.ebi.ac.uk/interpro/entry/prodom/${t}`),i}function M(t,e,i){const n=i,r={...m};r.fontWeight="bold",r.fontSize=e.fontSize+1,r.top=i,r.left=5;const s=t.program,a=t.version,h=new o.fabric.Text(`${s} (version: ${a})`,r);let c=[];for(const e of t.dbs)c.push(e.name);const l=c.join(", ");r.fontWeight="normal",r.fontSize=e.fontSize,i+=15,r.top=i;const u=new o.fabric.Text(`Database(s): ${l}`,r);i+=15,r.top=i;const f=new o.fabric.Text("Sequence: ",r),d=t.query_len;i+=15,r.top=i;const p=new o.fabric.Text(`Length: ${d}`,r),v=t.start;r.top=n,r.left=e.canvasWidth-135;const y=new o.fabric.Text(`${v}`,r),b=t.end;r.top=n+15;const _=new o.fabric.Text(`${b}`,r);return new o.fabric.Group([h,u,f,p,y,_],g)}function R(t,e,i){const n=t.query_def,r={...m};return r.fontFamily="Menlo",r.fontSize=e.fontSize-2,r.evented=!0,r.top=i-15,r.left=57.5,[new o.fabric.Text(`${n}`,r),r]}function B(t,e,i){const n={...y};n.top=i,n.stroke="black",n.strokeWidth=e.strokeWidth;const r=[t.startQueryPixels,i,t.endQueryPixels,i];n.left=t.startQueryPixels;const s=new o.fabric.Line(r,n),a=[t.startQueryPixels,i-3,t.startQueryPixels,i+3];n.top=i-2;const h=new o.fabric.Line(a,n),c=[t.endQueryPixels,i-3,t.endQueryPixels,i+3];n.left=t.endQueryPixels;const l=new o.fabric.Line(c,n),u=[t.startSubjPixels,i,t.endSubjPixels,i];n.top=i,n.left=t.startSubjPixels;const f=new o.fabric.Line(u,n),d=[t.startSubjPixels,i-3,t.startSubjPixels,i+3];n.top=i-2;const p=new o.fabric.Line(d,n),m=[t.endSubjPixels,i-3,t.endSubjPixels,i+3];n.left=t.endSubjPixels;const v=new o.fabric.Line(m,n);return new o.fabric.Group([s,f,h,l,p,v],g)}function W(t,e,i){const n={...y};n.top=i,n.stroke="black",n.strokeWidth=e.strokeWidth;const r=[t.startPixels,i,t.endPixels,i];n.left=t.startPixels;const s=new o.fabric.Line(r,n),a=[t.startPixels,i-3,t.startPixels,i+3];n.top=i-2;const h=new o.fabric.Line(a,n),c=[t.endPixels,i-3,t.endPixels,i+3];n.left=t.endPixels;const l=new o.fabric.Line(c,n);return new o.fabric.Group([s,h,l],g)}function N(t,e,i){const n={...y};n.top=i,n.stroke="black",n.strokeWidth=e.strokeWidth,n.strokeDashArray=e.strokeDashArray;const r=[t.startPixels,i,t.endPixels,i];return n.left=t.startPixels,new o.fabric.Line(r,n)}function z(t,e,i){const n={...m};n.fontSize=e.fontSize,n.top=i,n.left=t.startPixels-2.5;const r=new o.fabric.Text(`${t.start}`,n);let s=c(`${t.end}`);n.left=t.endPixels-s;const a=new o.fabric.Text(`${t.end}`,n);return new o.fabric.Group([r,a],g)}function U(t,e){const i={...m};return i.fontWeight="bold",i.fontSize=t.fontSize+1,i.top=e,i.left=t.contentWidth/2,i.fill="red",new o.fabric.Text("--------------------No hits found--------------------",i)}function H(t,e,i,n){const r={...m};r.fontFamily="Menlo",r.fontSize=i.fontSize-2,r.top=n-2;const s=" ".repeat(t-(e.hit_db.length+e.hit_id.length)),a=new o.fabric.Text(s,r);let h=`${e.hit_db}:${e.hit_id} ${e.hit_desc}`,c=`${s}${e.hit_db}:${e.hit_id} ${e.hit_desc}`;return c.length>40&&(h=(c.slice(0,38)+"...").slice(s.length)),r.left=10+6*s.length,r.evented=!0,[a,new o.fabric.Text(h,r),r]}function G(t,e,i,n){const r={...m};return r.fontSize=i.fontSize,r.top=n,r.left=i.contentWidth/2,r.fill="red",new o.fabric.Text(`This hit contains ${t} alignments, but only the first ${e} are displayed!`,r)}function X(t,e,i,n){const r={...m};let s;return r.fontSize=i.fontSize,r.top=n-15,r.textAlign="center",r.left=t,s=i.colorScheme===d.ncbiblast?new o.fabric.Text(E(e.hsp_bit_score),r):new o.fabric.Text(E(e.hsp_expect),r),s}function Y(t,e,i,n,r,s){const a={...v};a.evented=!0,a.top=r,a.fill=s,a.rx=5,a.ry=5,a.top=r-15,a.left=t,a.width=e,a.height=10;const h=new o.fabric.Rect(a);return a.top=r-15,a.left=i,a.width=n,a.height=10,[h,new o.fabric.Rect(a)]}function V(t,e){const i={...m};return i.fontSize=t.fontSize+1,i.fontWeight="bold",i.top=e,i.left=t.scaleLabelWidth,new o.fabric.Text("Scale Type:",i)}function $(t,e){const i={...m};i.fontSize=t.fontSize+1,i.top=e,i.left=t.scaleLabelWidth;const n={...m};n.fontSize=t.fontSize+12,n.fill="grey",n.evented=!0,n.top=e-8,n.left=t.scaleLabelWidth;const r={...n},s={...n};let a;a=t.colorScheme===d.dynamic?"☒":"☐",t.colorScheme===d.dynamic&&(n.fill="black"),n.left+=80;const h=new o.fabric.Text(a,n);i.left+=100;const c=new o.fabric.Text("Dynamic (E-value: min to max)",i);a=t.colorScheme===d.fixed?"☒":"☐",t.colorScheme===d.fixed&&(r.fill="black"),r.left+=290;const l=new o.fabric.Text(a,r);i.left+=210;const u=new o.fabric.Text("Fixed (E-value: 0.0 to 100.0)",i);a=t.colorScheme===d.ncbiblast?"☒":"☐",t.colorScheme===d.ncbiblast&&(s.fill="black"),s.left+=480;const f=new o.fabric.Text(a,s);return i.left+=190,[h,c,n,l,u,r,f,new o.fabric.Text("NCBI BLAST+ (Bit score: <40 to ≥200)",i),s]}function q(t,e){const i={...m};let n;return i.fontSize=t.fontSize+1,i.top=e,n=t.colorScheme===d.ncbiblast?"Bit score":"E-value",t.colorScheme===d.ncbiblast?i.left=t.scaleLabelWidth-56:i.left=t.scaleLabelWidth-50,new o.fabric.Text(`${n}`,i)}function K(t,e){const i={...v};i.top=e,i.left=t.scaleLabelWidth,i.width=t.scaleWidth,i.height=15;const n=new o.fabric.Rect(i);var r,s;return t.colorScheme===d.ncbiblast?(r=n,s=t.scaleWidth,r.set("fill",new o.fabric.Gradient({type:"linear",coords:{x1:0,y1:0,x2:s,y2:0},colorStops:[{offset:0,color:`rgb(${h[0].join(",")})`},{offset:.199999,color:`rgb(${h[0].join(",")})`},{offset:.2,color:`rgb(${h[40].join(",")})`},{offset:.399999,color:`rgb(${h[40].join(",")})`},{offset:.4,color:`rgb(${h[50].join(",")})`},{offset:.599999,color:`rgb(${h[50].join(",")})`},{offset:.6,color:`rgb(${h[80].join(",")})`},{offset:.799999,color:`rgb(${h[80].join(",")})`},{offset:.8,color:`rgb(${h[200].join(",")})`},{offset:1,color:`rgb(${h[200].join(",")})`}]}))):function(t,e,i){t.set("fill",new o.fabric.Gradient({type:"linear",coords:{x1:0,y1:0,x2:i,y2:0},colorStops:[{offset:0,color:`rgb(${a[0].join(",")})`},{offset:.25,color:`rgb(${a[.25].join(",")})`},{offset:.5,color:`rgb(${a[.5].join(",")})`},{offset:.75,color:`rgb(${a[.75].join(",")})`},{offset:1,color:`rgb(${a[1].join(",")})`}]}))}(n,0,t.scaleWidth),n}function Q(t,e,i,n,r,s,a){const h={...y};h.top=a,h.stroke="black",h.strokeWidth=s.strokeWidth;const c=[t,a,r,a];h.left=t;const l=new o.fabric.Line(c,h),u=[t,a,t,a+4],f=new o.fabric.Line(u,h),d=[e,a,e,a+4];h.left=e;const p=new o.fabric.Line(d,h),m=[i,a,i,a+4];h.left=i;const v=new o.fabric.Line(m,h),b=[n,a,n,a+4];h.left=n;const _=new o.fabric.Line(b,h),x=[r,a,r,a+4];h.left=r;const S=new o.fabric.Line(x,h);return new o.fabric.Group([l,f,p,v,_,S],g)}function J(t,e,i,n,r,s,a,h){const c={...y};c.top=h,c.stroke="black",c.strokeWidth=a.strokeWidth;const l=[t,h,s,h];c.left=t;const u=new o.fabric.Line(l,c),f=[t,h,t,h+4],d=new o.fabric.Line(f,c),p=[e,h,e,h+4];c.left=e;const m=new o.fabric.Line(p,c),v=[i,h,i,h+4];c.left=i;const b=new o.fabric.Line(v,c),_=[n,h,n,h+4];c.left=n;const x=new o.fabric.Line(_,c),S=[r,h,r,h+4];c.left=r;const C=new o.fabric.Line(S,c),w=[s,h,s,h+4];c.left=s;const T=new o.fabric.Line(w,c);return new o.fabric.Group([u,d,m,b,x,C,T],g)}function Z(t,e,i,n){const r={...m};r.top=n,r.fontSize=i.fontSize;let s=`<${t[1]}`;r.left=i.scaleLabelWidth+e-3*s.length-72;const a=new o.fabric.Text(s,r);s=`${t[1]} - ${t[2]}`,r.left=i.scaleLabelWidth+2*e-3*s.length-72;const h=new o.fabric.Text(s,r);s=`${t[2]} - ${t[3]}`,r.left=i.scaleLabelWidth+3*e-3*s.length-72;const c=new o.fabric.Text(s,r);s=`${t[3]} - ${t[4]}`,r.left=i.scaleLabelWidth+4*e-3*s.length-72;const l=new o.fabric.Text(s,r);s=`≥${t[4]}`,r.left=i.scaleLabelWidth+i.scaleWidth-3*s.length-72;const u=new o.fabric.Text(s,r);return new o.fabric.Group([a,h,c,l,u],g)}function tt(t,e,i,n){const r={...m};r.top=n,r.fontSize=i.fontSize,r.left=i.scaleLabelWidth-3*E(t[0]).length;const s=new o.fabric.Text(E(t[0]),r);r.left=i.scaleLabelWidth+e-3*E(t[1]).length;const a=new o.fabric.Text(E(t[1]),r);r.left=i.scaleLabelWidth+2*e-3*E(t[2]).length;const h=new o.fabric.Text(E(t[2]),r);r.left=i.scaleLabelWidth+3*e-3*E(t[3]).length;const c=new o.fabric.Text(E(t[3]),r);r.left=i.scaleLabelWidth+i.scaleWidth-3*E(t[4]).length;const l=new o.fabric.Text(E(t[4]),r);return new o.fabric.Group([s,a,h,c,l],g)}function et(t,e){const i={...m};return i.fontSize=t.fontSize,i.evented=!0,i.top=e,i.left=225,[new o.fabric.Text("European Bioinformatics Institute 2006-2024. EBI is an Outstation of the European Molecular Biology Laboratory.",i),i]}function it(t){return new o.fabric.Rect({selectable:!1,evented:!1,objectCaching:!1,top:0,left:0,width:t.canvasWidth-1,height:t.canvasHeight-1,strokeWidth:1,stroke:"lightseagreen",fill:"transparent"})}function nt(t,e,i){const n={...m};n.fontSize=t.fontSize,n.top=e,n.left=t.contentWidth/2,n.fill="red";const r=`This is a partial representation of the result, only the first ${i} hits are displayed!`;return new o.fabric.Text(`${r}`,n)}function rt(t,e,i,n,r){const s={...v};return s.fill=n,s.opacity=.5,s.rx=5,s.ry=5,s.top=i+15,s.left=t,s.width=e,s.height=r,new o.fabric.Rect(s)}function st(t,e,i){const n={...m};n.fontFamily="Menlo",n.fontSize=e.fontSize-2,n.top=i-5;const r=" ".repeat(40-t.length),s=new o.fabric.Text(r,n);let a=`${t}`,h=`${r}${t}`;return h.length>40&&(a=(h.slice(0,38)+"...").slice(r.length)),n.left=12+6*r.length,n.evented=!0,[s,new o.fabric.Text(a,n),n]}function ot(t,e,i,n){const r={...v};return r.evented=!0,r.top=i,r.fill=n,r.rx=5,r.ry=5,r.top=i-15,r.left=t,r.width=e,r.height=10,r.stroke="black",r.strokeWidth=.5,new o.fabric.Rect(r)}function at(t,e,i,n,r,s){t.on("mouseover",(a=>{if(a.target){a.target.set("hoverCursor","pointer"),a.target.setOptions(e),a.target.setOptions({underline:!0});const h=function(t,e,i,n,r){const s={...m};let a;if(s.fontSize=n.fontSize+1,s.originX="left",s.originY="top",s.top=5,s.left=5,e.length>150&&(e=e.slice(0,150)+"..."),""!==e){const t=6.3*e.length,n=6.3*i.length;s.width=t>n?t+5:n+5,a=new o.fabric.Text(`${e}\n${i}`,s)}else{const t=6.3*i.length;s.width=t+5,a=new o.fabric.Text(`${i}`,s)}const h={...v};h.fill="white",h.stroke="lightseagreen",h.strokeWidth=.5,h.rx=5,h.ry=5,h.originX="left",h.originY="top",h.width=a.width+10,h.height=a.height+10,h.opacity=.95;const c=new o.fabric.Rect(h),l=new o.fabric.Group([c,a],{selectable:!1,evented:!1,objectCaching:!1,visible:!0,top:r,originX:"left"});return l.left=t+10,l}(+t.left,i,n,r,+t.top+15);s.canvas.add(h),s.canvas.renderAll(),h.visible=!1}}))}function ht(t,e,i){t.on("mousedown",(t=>{t.target&&(window.open(e,"_blank"),i.canvas.renderAll())}))}function ct(t,e,i){t.on("mouseout",(t=>{t.target&&(t.target.setOptions(e),t.target.setOptions({underline:!1}),i.canvas.renderAll())}))}function lt(t,e,i,n,r,s,a,h){t.on("mouseover",(c=>{if(c.target){let l;c.target.set("hoverCursor","pointer"),l="hsp_hit_from"in s?function(t,e,i,n,r,s,a){const h={...m};let c;h.fontSize=s.fontSize+1,h.textAlign="left",h.originX="top",h.originY="top",h.top=5,c=s.colorScheme===d.ncbiblast?`Start: ${i}\nEnd: ${n}\nBit score: ${E(r.hsp_bit_score)}`:`Start: ${i}\nEnd: ${n}\nE-value: ${E(r.hsp_expect)}`;const l=new o.fabric.Text(c,h),u={...v};u.fill="white",u.stroke="lightseagreen",u.rx=5,u.ry=5,u.originX="top",u.originY="top",u.width=140,u.height=60,u.opacity=.95;const f=new o.fabric.Rect(u);return new o.fabric.Group([f,l],{selectable:!1,evented:!1,objectCaching:!1,visible:!1,top:a,left:t+e/2})}(e,i,n,r,s,a,t.top+5):function(t,e,i,n,r,s,a){const h={...m};h.fontSize=s.fontSize+1,h.textAlign="left",h.originX="top",h.originY="top",h.top=5,h.left=10,h.width=200;let c=`Start: ${i}\nEnd: ${n}\nDatabase: ${r.dbname}\n`;void 0!==r.altid&&void 0!==r.altname?c+=`ID: ${r.altid}\nName: ${r.altname}\nType: ${r.type}\nIPR ID: ${r.id}\nIPR Name: ${r.name}\n`:c+=`ID: ${r.id}\nName: ${r.name}\nType: ${r.type}\n`;const l=new o.fabric.Textbox(c,h),u={...v};u.fill="white",u.stroke="lightseagreen",u.rx=5,u.ry=5,u.originX="top",u.originY="top",u.width=l.width+40,u.height=l.height,u.opacity=.95;const f=new o.fabric.Rect(u);return new o.fabric.Group([f,l],{selectable:!1,evented:!1,objectCaching:!1,visible:!1,top:a,left:t+e/2})}(e,i,n,r,s,a,t.top+5),h.canvas.add(l),l.set({visible:!0}),t.bringToFront(),l.bringToFront(),h.canvas.renderAll(),l.set({visible:!1})}}))}function ut(t,e){t.on("mouseout",(t=>{t.target&&e.canvas.renderAll()}))}function ft(t,e,i){t.on("mouseover",(t=>{t.target&&(t.target.set("hoverCursor","pointer"),t.target.setOptions(e),t.target.setOptions({fill:"black"}),i.canvas.renderAll())}))}function dt(t,e,i){t.on("mousedown",(t=>{t.target&&i.colorScheme!=e&&(i.colorScheme=e,i.render())}))}function pt(t,e,i,n){t.on("mouseout",(t=>{t.target&&(t.target.setOptions(e),n.colorScheme!=i&&t.target.setOptions({fill:"grey"}),n.canvas.renderAll())}))}let gt=new T;class mt extends w{constructor(t,e,i){super(t),this.dataObj=e,this.topPadding=0,this.queryLen=0,this.subjLen=0,this.gradientSteps=[],this.queryFactor=1,this.subjFactor=1,null!=i.canvasWidth?this.canvasWidth=i.canvasWidth:this.canvasWidth=1e3,null!=i.canvasHeight?this.canvasHeight=i.canvasHeight:this.canvasHeight=110,null!=i.contentWidth?this.contentWidth=i.contentWidth:this.contentWidth=65.5*this.canvasWidth/100,null!=i.contentScoringWidth?this.contentScoringWidth=i.contentScoringWidth:this.contentScoringWidth=7*this.canvasWidth/100,null!=i.contentLabelWidth?this.contentLabelWidth=i.contentLabelWidth:this.contentLabelWidth=26.5*this.canvasWidth/100,null!=i.scaleWidth?this.scaleWidth=i.scaleWidth:this.scaleWidth=75*this.canvasWidth/100,null!=i.scaleLabelWidth?this.scaleLabelWidth=i.scaleLabelWidth:this.scaleLabelWidth=20*this.canvasWidth/100,null!=i.marginWidth?this.marginWidth=i.marginWidth:this.marginWidth=.15*this.canvasWidth/100,null!=i.colorScheme?this.colorScheme=i.colorScheme:this.colorScheme=d.dynamic,null!=i.numberHits?this.numberHits=i.numberHits:this.numberHits=100,null!=i.numberHsps?this.numberHsps=i.numberHsps:this.numberHsps=10,null!=i.logSkippedHsps?this.logSkippedHsps=i.logSkippedHsps:this.logSkippedHsps=!0,null!=i.fontSize?this.fontSize=i.fontSize:this.fontSize=12,null!=i.fontWeigth?this.fontWeigth=i.fontWeigth:this.fontWeigth="normal",null!=i.fontFamily?this.fontFamily=i.fontFamily:this.fontFamily="Times New Roman",null!=i.canvasWrapperStroke?this.canvasWrapperStroke=i.canvasWrapperStroke:this.canvasWrapperStroke=!1,null!=i.staticCanvas?this.staticCanvas=i.staticCanvas:this.staticCanvas=!1,this.getFabricCanvas()}render(){this.loadInitalProperties(),this.loadInitialCoords(),this.canvas.clear(),this.drawHeaderGroup(),this.drawContentGroup(),this.drawFooterGroup(),this.wrapCanvas(),this.setFrameSize(),this.renderCanvas()}loadInitalProperties(){this.queryLen=this.dataObj.query_len;for(const t of this.dataObj.hits.slice(0,this.numberHits))t.hit_len>this.subjLen&&(this.subjLen=t.hit_len);const t=this.queryLen/this.subjLen,e=this.subjLen/this.queryLen;t>8&&(this.subjFactor=.5*this.queryLen/this.subjLen),e>8&&(this.queryFactor=.5*this.subjLen/this.queryLen)}loadInitialCoords(){this.startQueryPixels=gt.get("startQueryPixels"),this.endQueryPixels=gt.get("endQueryPixels"),this.startSubjPixels=gt.get("startSubjPixels"),this.endSubjPixels=gt.get("endSubjPixels"),this.startEvalPixels=gt.get("startEvalPixels"),this.startQueryPixels||this.endQueryPixels||this.startSubjPixels||this.endSubjPixels||this.startEvalPixels||([this.startQueryPixels,this.endQueryPixels,this.startSubjPixels,this.endSubjPixels]=u(this.queryLen*this.queryFactor,this.subjLen*this.subjFactor,this.subjLen*this.subjFactor,this.contentWidth,this.contentScoringWidth,this.contentLabelWidth,this.marginWidth),this.startEvalPixels=this.endQueryPixels+2*this.marginWidth,gt.put("startQueryPixels",this.startQueryPixels),gt.put("endQueryPixels",this.endQueryPixels),gt.put("startSubjPixels",this.startSubjPixels),gt.put("endSubjPixels",this.endSubjPixels),gt.put("startEvalPixels",this.startEvalPixels))}drawHeaderGroup(){let t,e,i;this.topPadding=2,t=gt.get("textHeaderGroup"),t||(t=M(this.dataObj,{fontSize:this.fontSize,canvasWidth:this.canvasWidth},this.topPadding),gt.put("textHeaderGroup",t)),this.canvas.add(t),this.topPadding+=45,e=gt.get("textHeaderLink"),i=gt.get("textHeaderLink_textSeqObj"),e||([e,i]=R(this.dataObj,{fontSize:this.fontSize},this.topPadding),gt.put("textHeaderLink",e),gt.put("textHeaderLink_textSeqObj",i)),this.canvas.add(e),this.staticCanvas||null!==this.dataObj.query_url&&""!==this.dataObj.query_url&&(at(e,i,this.dataObj.query_def,this.dataObj.query_url,{fontSize:this.fontSize},this),ht(e,this.dataObj.query_url,this),ct(e,i,this))}drawContentGroup(){if(this.dataObj.hits.length>0){let t,e,i;this.topPadding+=25,t=gt.get("textContentHeaderGroup"),t||(t=function(t,e,i){const n={...m};n.fontWeight="bold",n.fontSize=e.fontSize+1,n.top=i+2,n.textAlign="center";const r=l(t.queryLen,t.subjLen,t.queryLen,e.contentWidth,e.contentScoringWidth),s=l(t.queryLen,t.subjLen,t.subjLen,e.contentWidth,e.contentScoringWidth);n.left=t.startQueryPixels;const a=new o.fabric.Text("Sequence Match",n);let h;a.width=r,n.left=t.startEvalPixels,h=e.colorScheme===d.ncbiblast?new o.fabric.Text("Bit score",n):new o.fabric.Text("E-value",n),h.width=e.contentScoringWidth,n.left=t.startSubjPixels;const c=new o.fabric.Text("Subject Match",n);return c.width=s,new o.fabric.Group([a,h,c],g)}({queryLen:this.queryLen*this.queryFactor,subjLen:this.subjLen*this.subjFactor,startQueryPixels:this.startQueryPixels,startEvalPixels:this.startEvalPixels,startSubjPixels:this.startSubjPixels},{contentWidth:this.contentWidth,contentScoringWidth:this.contentScoringWidth,fontSize:this.fontSize,colorScheme:this.colorScheme},this.topPadding),gt.put("textContentHeaderGroup",t)),this.canvas.add(t),this.topPadding+=20,e=gt.get("lineTrackGroup"),e||(e=B({startQueryPixels:this.startQueryPixels,endQueryPixels:this.endQueryPixels,startSubjPixels:this.startSubjPixels,endSubjPixels:this.endSubjPixels},{strokeWidth:2},this.topPadding),gt.put("lineTrackGroup",e)),this.canvas.add(e),this.topPadding+=5,i=gt.get("textContentFooterGroup"),i||(i=function(t,e,i){const n={...m};n.fontSize=e.fontSize,n.top=i,n.left=t.startQueryPixels-2.5;const r=new o.fabric.Text("1",n);let s=c(`${t.queryLen}`);n.left=t.endQueryPixels-s;const a=new o.fabric.Text(`${t.queryLen}`,n);n.left=t.startSubjPixels-2.5;const h=new o.fabric.Text("1",n);s=c(`${t.subjLen}`),n.left=t.endSubjPixels-s;const l=new o.fabric.Text(`${t.subjLen}`,n);return new o.fabric.Group([r,a,h,l],g)}({queryLen:this.queryLen,subjLen:this.subjLen,startQueryPixels:this.startQueryPixels,endQueryPixels:this.endQueryPixels,startSubjPixels:this.startSubjPixels,endSubjPixels:this.endSubjPixels},{fontSize:this.fontSize},this.topPadding),gt.put("textContentFooterGroup",i)),this.canvas.add(i),this.topPadding+=25,this.drawDynamicContentGroup(),this.topPadding+=20,this.drawColorScaleGroup()}else{this.topPadding+=20;const t=U({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding);this.canvas.add(t)}}drawDynamicContentGroup(){let t=0,e=0;for(const i of this.dataObj.hits.slice(0,this.numberHits))i.hit_len>t&&(t=i.hit_len),i.hit_db.length+i.hit_id.length>e&&(e=i.hit_db.length+i.hit_id.length);let i=Number.MAX_VALUE,n=0,r=Number.MAX_VALUE;for(const t of this.dataObj.hits.slice(0,this.numberHits))for(const e of t.hit_hsps)this.colorScheme===d.ncbiblast?(e.hsp_bit_scoren&&(n=e.hsp_bit_score),e.hsp_bit_score0&&(r=e.hsp_bit_score)):(e.hsp_expectn&&(n=e.hsp_expect),e.hsp_expect0&&(r=e.hsp_expect));this.colorScheme,d.ncbiblast,this.gradientSteps=x(i,n,r,this.colorScheme);let s=0;for(const t of this.dataObj.hits){if(s++,!(s<=this.numberHits)){let t;this.topPadding+=20,t=gt.get("supressText"),t||(t=nt({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding,this.numberHits),gt.put("supressText",t)),t.top=this.topPadding,this.canvas.add(t),this.topPadding+=20;break}{let i=0;const n=t.hit_hsps.length;let r,s,o;[s,o,r]=H(e,t,{fontSize:this.fontSize},this.topPadding),this.canvas.add(s),this.canvas.add(o),this.staticCanvas||(at(o,r,t.hit_def,t.hit_url,{fontSize:this.fontSize},this),ht(o,t.hit_url,this),ct(o,r,this));for(const e of t.hit_hsps){if(i++,!(i<=this.numberHsps)){if(!0===this.logSkippedHsps){let t;t=gt.get("hspTextNotice"),t||(t=G(n,this.numberHsps,{fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding),gt.put("hspTextNotice",t)),this.canvas.add(t),this.topPadding+=20}break}{const i=t.hit_len;let n,r,s,o;[n,r,s,o]=u(this.queryLen*this.queryFactor,this.subjLen*this.subjFactor,i,this.contentWidth,this.contentScoringWidth,this.contentLabelWidth,this.marginWidth),this.topPadding+=5;const c=B({startQueryPixels:n,endQueryPixels:r,startSubjPixels:s,endSubjPixels:o},{strokeWidth:1},this.topPadding);let l,p,g,m,v,y,x,S,C,w,T;this.canvas.add(c),"-1"===e.hsp_query_frame?(v=e.hsp_query_to,y=e.hsp_query_from):(v=e.hsp_query_from,y=e.hsp_query_to),"-1"===e.hsp_hit_frame?(x=e.hsp_hit_to,S=e.hsp_hit_from):(x=e.hsp_hit_from,S=e.hsp_hit_to),[l,p]=f(n,r,this.queryLen,v,y,this.marginWidth),[g,m]=f(s,o,i,x,S,this.marginWidth),C=this.colorScheme===d.ncbiblast?_(e.hsp_bit_score,this.gradientSteps,h):b(e.hsp_expect,this.gradientSteps,a),this.topPadding+=10,[w,T]=Y(l,p,g,m,this.topPadding,C),this.canvas.add(w),this.canvas.add(T);const E=X(this.startEvalPixels,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this.topPadding);E.width=this.contentScoringWidth,this.canvas.add(E),this.staticCanvas||(lt(w,l,p,v,y,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this),ut(w,this),lt(T,g,m,x,S,e,{fontSize:this.fontSize,colorScheme:this.colorScheme},this),ut(T,this))}}}}}drawColorScaleGroup(){const t=V({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);let e,i,n,r,s,o,a,h,c;this.canvas.add(t),[r,s,e,o,a,i,h,c,n]=$({colorScheme:this.colorScheme,fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding),this.canvas.add(r),this.canvas.add(s),this.staticCanvas||(ft(r,e,this),pt(r,e,d.dynamic,this),dt(r,d.dynamic,this)),this.canvas.add(o),this.canvas.add(a),this.staticCanvas||(ft(o,i,this),pt(o,i,d.fixed,this),dt(o,d.fixed,this)),this.canvas.add(h),this.canvas.add(c),this.staticCanvas||(ft(h,n,this),pt(h,n,d.ncbiblast,this),dt(h,d.ncbiblast,this)),this.topPadding+=25;const l=q({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);this.canvas.add(l);const u=K({scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);if(this.canvas.add(u),this.colorScheme===d.ncbiblast){const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/5;this.topPadding+=15;const e=J(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+4*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=Z(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}else{const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/4;this.topPadding+=15;const e=Q(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=tt(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}}drawFooterGroup(){let t,e;this.topPadding+=30,t=gt.get("copyrightText"),e=gt.get("copyrightText_textFooterObj"),t||e||([t,e]=et({fontSize:this.fontSize},this.topPadding),gt.put("copyrightText",t),gt.put("copyrightText_textFooterObj",e)),this.canvas.add(t)}wrapCanvas(){if(this.topPadding+=20,this.canvasHeight=this.topPadding,this.canvasWrapperStroke){const t=it({canvasWidth:this.canvasWidth,canvasHeight:this.canvasHeight});this.canvas.add(t)}}}const vt=["PRODOM","CATH-Gene3D","CDD","PANTHER","HAMAP","Pfam","PIRSF","PRINTS","PROSITE profiles","PROSITE patterns","SFLD","SMART","SUPERFAMILY","TIGRFAMs"];function yt(t,e,i,n,r,s){let a,h,c,l;t.domainDatabaseList.includes(e)?t.currentDomainDatabase=e:t.currentDomainDatabase=void 0,t.currentDomainDatabaseDisabled=!1,i.includes(e)||(t.currentDomainDatabaseDisabled=!0),[c,l,a,h]=function(t,e,i,n){const r={...v};r.top=e,r.left=i,r.height=15,r.width=15,r.evented=!0;const s={...m};return s.fontSize=t.fontSize+1,s.top=e,s.left=i+20,t.currentDisabled?(s.fill="grey",r.fill="white",r.stroke="grey"):void 0!==t.currentDomainDatabase?(r.fill=S(t.currentDomainDatabase),r.stroke="black"):(r.fill="white",r.stroke="grey"),[new o.fabric.Rect(r),new o.fabric.Text(n,s),r,r]}({currentDomainDatabase:t.currentDomainDatabase,currentDisabled:t.currentDomainDatabaseDisabled,fontSize:s.fontSize},n,r,e),t.canvas.add(c),t.canvas.add(l),s.staticCanvas||(function(t,e,i,n){t.on("mouseover",(t=>{if(t.target){t.target.set("hoverCursor","pointer"),t.target.setOptions(e);let r=!1;n.uniqueDomainDatabases.includes(i)||(r=!0),r?(t.target.setOptions({fill:"white",stroke:"grey"}),t.target.set("hoverCursor","default")):n.domainDatabaseList.includes(i)?(t.target.setOptions({opacity:.5,stroke:"grey"}),t.target.set("hoverCursor","pointer")):(t.target.setOptions({stroke:"black"}),t.target.set("hoverCursor","pointer")),n.canvas.renderAll()}}))}(c,a,e,t),function(t,e,i,n){t.on("mouseout",(t=>{if(t.target){let r=!1;n.uniqueDomainDatabases.includes(i)||(r=!0),n.domainDatabaseList.includes(i)?r?t.target.setOptions({stroke:"grey",fill:"white"}):(t.target.setOptions(e),t.target.setOptions({opacity:1,stroke:"black"})):t.target.setOptions({stroke:"grey",fill:"white"}),n.canvas.renderAll()}}))}(c,a,e,t),function(t,e,i){t.on("mousedown",(t=>{if(t.target)if(!i.domainDatabaseList.includes(e)&&i.uniqueDomainDatabases.includes(e))i.domainDatabaseList.push(e),i.currentDomainDatabase=e,i.render();else if(i.uniqueDomainDatabases.includes(e)){const t=i.domainDatabaseList.indexOf(e);t>-1&&i.domainDatabaseList.splice(t,1),i.currentDomainDatabase=void 0,i.render()}}))}(c,e,t))}let bt=new T;class _t extends w{constructor(t,e,i,n,r=vt){super(t),this.sssDataObj=e,this.iprmcDataObj=i,this.domainDatabaseList=r,this.topPadding=0,this.queryStart=0,this.queryEnd=0,this.gradientSteps=[],this.uniqueDomainDatabases=[],this.currentDomainDatabaseDisabled=!1,null!=n.canvasWidth?this.canvasWidth=n.canvasWidth:this.canvasWidth=1e3,null!=n.canvasHeight?this.canvasHeight=n.canvasHeight:this.canvasHeight=110,null!=n.contentWidth?this.contentWidth=n.contentWidth:this.contentWidth=72.5*this.canvasWidth/100,null!=n.contentLabelWidth?this.contentLabelWidth=n.contentLabelWidth:this.contentLabelWidth=26.5*this.canvasWidth/100,null!=n.contentLabelLeftWidth?this.contentLabelLeftWidth=n.contentLabelLeftWidth:this.contentLabelLeftWidth=8.25*this.canvasWidth/100,null!=n.scaleWidth?this.scaleWidth=n.scaleWidth:this.scaleWidth=75*this.canvasWidth/100,null!=n.scaleLabelWidth?this.scaleLabelWidth=n.scaleLabelWidth:this.scaleLabelWidth=20*this.canvasWidth/100,null!=n.marginWidth?this.marginWidth=n.marginWidth:this.marginWidth=.15*this.canvasWidth/100,null!=n.colorScheme?this.colorScheme=n.colorScheme:this.colorScheme=d.dynamic,null!=n.numberHits?this.numberHits=n.numberHits:this.numberHits=30,null!=n.fontSize?this.fontSize=n.fontSize:this.fontSize=12,null!=n.fontWeigth?this.fontWeigth=n.fontWeigth:this.fontWeigth="normal",null!=n.fontFamily?this.fontFamily=n.fontFamily:this.fontFamily="Times New Roman",null!=n.canvasWrapperStroke?this.canvasWrapperStroke=n.canvasWrapperStroke:this.canvasWrapperStroke=!1,null!=n.staticCanvas?this.staticCanvas=n.staticCanvas:this.staticCanvas=!1,this.getFabricCanvas()}render(){this.loadIPRMCProperties(),this.loadInitalProperties(),this.loadInitialCoords(),this.canvas.clear(),this.drawHeaderGroup(),this.drawContentGroup(),this.drawFooterGroup(),this.wrapCanvas(),this.setFrameSize(),this.renderCanvas()}loadInitalProperties(){this.queryStart=1,this.queryEnd=this.sssDataObj.query_len}loadInitialCoords(){var t,e,i;this.startPixels=bt.get("startPixels"),this.endPixels=bt.get("endPixels"),this.startPixels||this.endPixels||([this.startPixels,this.endPixels]=(t=this.contentWidth,[(e=this.contentLabelWidth)+(i=this.marginWidth),e+t-i]),bt.put("startPixels",this.startPixels),bt.put("endPixels",this.endPixels))}loadIPRMCProperties(){if(null!=this.sssDataObj){if(this.uniqueDomainDatabases=bt.get("uniqueDomainDatabases"),!this.uniqueDomainDatabases){let t=[];for(const e of this.sssDataObj.hits.slice(0,this.numberHits))t.push(e.hit_acc);this.uniqueDomainDatabases=function(t,e){const i=[];for(const n of e)for(const e of t[`${n}`].matches)i.push(e.split("_")[0]);return i.filter(((t,e,i)=>i.indexOf(t)===e))}(this.iprmcDataObj,t),bt.put("uniqueDomainDatabases",this.uniqueDomainDatabases)}for(const t of this.domainDatabaseList)if(!this.uniqueDomainDatabases.includes(F(t))){const e=this.domainDatabaseList.indexOf(t);e>-1&&this.domainDatabaseList.splice(e,1)}}}drawHeaderGroup(){let t,e,i;this.topPadding=2,t=bt.get("textHeaderGroup"),t||(t=M(this.sssDataObj,{fontSize:this.fontSize,canvasWidth:this.canvasWidth},this.topPadding),bt.put("textHeaderGroup",t)),this.canvas.add(t),this.topPadding+=45,e=bt.get("textHeaderLink"),i=bt.get("textHeaderLink_textSeqObj"),e||([e,i]=R(this.sssDataObj,{fontSize:this.fontSize},this.topPadding),bt.put("textHeaderLink",e),bt.put("textHeaderLink_textSeqObj",i)),this.canvas.add(e),this.staticCanvas||null!=this.sssDataObj.query_url&&""!==this.sssDataObj.query_url&&(at(e,i,this.sssDataObj.query_def,this.sssDataObj.query_url,{fontSize:this.fontSize},this),ht(e,this.sssDataObj.query_url,this),ct(e,i,this))}drawContentGroup(){let t;if(this.topPadding+=25,t=bt.get("titleText"),t||(t=function(t,e){const i={...m};return i.fontWeight="bold",i.fontSize=t.fontSize+2,i.top=e,i.left=350,new o.fabric.Text("Fast Family and Domain Prediction by InterPro",i)}({fontSize:this.fontSize+1},this.topPadding),bt.put("titleText",t)),this.canvas.add(t),this.sssDataObj.hits.length>0)this.topPadding+=35,this.drawPredictionsGroup(),this.topPadding+=50,this.drawDynamicContentGroup(),this.drawColorScaleGroup();else{this.topPadding+=20;const t=U({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding);this.canvas.add(t)}}drawPredictionsGroup(){let t;t=bt.get("pfLabelText"),t||(t=function(t,e){const i={...m};return i.fontSize=t.fontSize+1,i.fontWeight="bold",i.top=e,i.left=t.scaleLabelWidth-10,new o.fabric.Text("Select your database:",i)}({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth-50},this.topPadding),bt.put("pfLabelText",t)),this.canvas.add(t),yt(this,"Pfam",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+190,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"SUPERFAMILY",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+260,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"SMART",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+390,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"HAMAP",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+480,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"PANTHER",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+570,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"PRODOM",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+680,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"PROSITE profiles",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+770,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),this.topPadding+=30,yt(this,"CDD",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+190,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"CATH-Gene3D",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+260,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"PIRSF",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+390,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"PRINTS",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+480,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"TIGRFAMs",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+570,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"SFLD",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+680,{fontSize:this.fontSize,staticCanvas:this.staticCanvas}),yt(this,"PROSITE patterns",this.uniqueDomainDatabases,this.topPadding,this.contentLabelLeftWidth+770,{fontSize:this.fontSize,staticCanvas:this.staticCanvas})}drawDynamicContentGroup(){let t=0;for(const e of this.sssDataObj.hits.slice(0,this.numberHits))e.hit_db.length+e.hit_id.length>t&&(t=e.hit_db.length+e.hit_id.length);let e=Number.MAX_VALUE,i=0,n=Number.MAX_VALUE;for(const t of this.sssDataObj.hits.slice(0,this.numberHits))for(const r of t.hit_hsps)this.colorScheme===d.ncbiblast?(r.hsp_bit_scorei&&(i=r.hsp_bit_score),r.hsp_bit_score0&&(n=r.hsp_bit_score)):(r.hsp_expecti&&(i=r.hsp_expect),r.hsp_expect0&&(n=r.hsp_expect));this.colorScheme,d.ncbiblast,this.gradientSteps=x(e,i,n,this.colorScheme);let r=0;for(const e of this.sssDataObj.hits){if(r++,!(r<=this.numberHits)){let t;t=bt.get("supressText"),t||(t=nt({fontSize:this.fontSize,contentWidth:this.contentWidth},this.topPadding,this.numberHits),bt.put("supressText",t)),t.top=this.topPadding,this.canvas.add(t),this.topPadding+=40;break}{let i,n,r;[n,r,i]=H(t,e,{fontSize:this.fontSize},this.topPadding),this.canvas.add(n),this.canvas.add(r),this.staticCanvas||(at(r,i,e.hit_def,e.hit_url,{fontSize:this.fontSize},this),ht(r,e.hit_url,this),ct(r,i,this));const s=W({startPixels:this.startPixels,endPixels:this.endPixels},{strokeWidth:1},this.topPadding);this.canvas.add(s),this.topPadding+=5;const o=z({start:this.queryStart,end:e.hit_len,startPixels:this.startPixels,endPixels:this.endPixels},{fontSize:this.fontSize},this.topPadding);this.canvas.add(o),this.topPadding+=15;let c="white",l=0,u=0;for(const t of e.hit_hsps){"-1"===t.hsp_hit_frame?(l=t.hsp_hit_to,u=t.hsp_hit_from):(l=t.hsp_hit_from,u=t.hsp_hit_to),c=this.colorScheme===d.ncbiblast?_(t.hsp_bit_score,this.gradientSteps,h):b(t.hsp_expect,this.gradientSteps,a);break}let p=0,g=0;[p,g]=f(this.startPixels,this.endPixels,e.hit_len,l,u,this.marginWidth);let m=0,v=this.topPadding-15;if(e.hit_acc in this.iprmcDataObj&&void 0!==this.iprmcDataObj[e.hit_acc].matches)for(const t of this.iprmcDataObj[e.hit_acc].matches){const i=F(this.iprmcDataObj[e.hit_acc].match[t][0].dbname);if(this.domainDatabaseList.includes(i)){this.topPadding+=15,m+=15;let n,r,s,o=N({startPixels:this.startPixels,endPixels:this.endPixels},{strokeWidth:1,strokeDashArray:[1,5]},this.topPadding);this.canvas.add(o),o.sendToBack(),[r,s,n]=st(t.split("_")[1]+" ►",{fontSize:this.fontSize},this.topPadding),this.canvas.add(r),this.canvas.add(s);const a=L(t.split("_")[1],i);this.staticCanvas||(at(s,n,"",a,{fontSize:this.fontSize},this),ht(s,a,this),ct(s,n,this));for(const i of this.iprmcDataObj[e.hit_acc].match[t]){let t=i.start,n=i.end,r=0,s=0;[r,s]=f(this.startPixels,this.endPixels,e.hit_len,t,n,this.marginWidth);const o=ot(r,s,this.topPadding+10,S(i.dbname));this.canvas.add(o),this.staticCanvas||(lt(o,r,s,t,n,i,{fontSize:this.fontSize},this),ut(o,this))}}}m+=15;const y=rt(p,g,v,c,m);this.canvas.add(y),y.sendToBack(),this.topPadding+=40}}}drawColorScaleGroup(){const t=V({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);let e,i,n,r,s,o,a,h,c;this.canvas.add(t),[r,s,e,o,a,i,h,c,n]=$({colorScheme:this.colorScheme,fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth},this.topPadding),this.canvas.add(r),this.canvas.add(s),this.staticCanvas||(ft(r,e,this),pt(r,e,d.dynamic,this),dt(r,d.dynamic,this)),this.canvas.add(o),this.canvas.add(a),this.staticCanvas||(ft(o,i,this),pt(o,i,d.fixed,this),dt(o,d.fixed,this)),this.canvas.add(h),this.canvas.add(c),this.staticCanvas||(ft(h,n,this),pt(h,n,d.ncbiblast,this),dt(h,d.ncbiblast,this)),this.topPadding+=25;const l=q({fontSize:this.fontSize,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);this.canvas.add(l);const u=K({scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth,colorScheme:this.colorScheme},this.topPadding);if(this.canvas.add(u),this.colorScheme===d.ncbiblast){const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/5;this.topPadding+=15;const e=J(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+4*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=Z(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}else{const t=(this.scaleLabelWidth+this.scaleWidth-this.scaleLabelWidth)/4;this.topPadding+=15;const e=Q(this.scaleLabelWidth,this.scaleLabelWidth+t,this.scaleLabelWidth+2*t,this.scaleLabelWidth+3*t,this.scaleLabelWidth+this.scaleWidth,{strokeWidth:1},this.topPadding);this.canvas.add(e),this.topPadding+=5;const i=tt(this.gradientSteps,t,{fontSize:this.fontSize,scaleWidth:this.scaleWidth,scaleLabelWidth:this.scaleLabelWidth},this.topPadding);this.canvas.add(i)}}drawFooterGroup(){let t,e;this.topPadding+=30,[t,e]=et({fontSize:this.fontSize},this.topPadding),this.canvas.add(t)}wrapCanvas(){if(this.topPadding+=20,this.canvasHeight=this.topPadding,this.canvasWrapperStroke){const t=it({canvasWidth:this.canvasWidth,canvasHeight:this.canvasHeight});this.canvas.add(t)}}}const xt=window,St=xt.ShadowRoot&&(void 0===xt.ShadyCSS||xt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ct=Symbol(),wt=new WeakMap;class Tt{constructor(t,e,i){if(this._$cssResult$=!0,i!==Ct)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(St&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=wt.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&wt.set(e,t))}return t}toString(){return this.cssText}}const Et=St?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new Tt("string"==typeof t?t:t+"",void 0,Ct))(e)})(t):t;var Ot;const Pt=window,At=Pt.trustedTypes,kt=At?At.emptyScript:"",Dt=Pt.reactiveElementPolyfillSupport,jt={toAttribute(t,e){switch(e){case Boolean:t=t?kt:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},It=(t,e)=>e!==t&&(e==e||t==t),Ft={attribute:!0,type:String,converter:jt,reflect:!1,hasChanged:It},Lt="finalized";class Mt extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const n=this._$Ep(i,e);void 0!==n&&(this._$Ev.set(n,i),t.push(n))})),t}static createProperty(t,e=Ft){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const r=this[t];this[e]=n,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Ft}static finalize(){if(this.hasOwnProperty(Lt))return!1;this[Lt]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(Et(t))}else void 0!==t&&e.push(Et(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{St?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),n=xt.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=Ft){var n;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==(null===(n=i.converter)||void 0===n?void 0:n.toAttribute)?i.converter:jt).toAttribute(e,i.type);this._$El=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$El=null}}_$AK(t,e){var i;const n=this.constructor,r=n._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=n.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:jt;this._$El=r,this[r]=s.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let n=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||It)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var Rt;Mt[Lt]=!0,Mt.elementProperties=new Map,Mt.elementStyles=[],Mt.shadowRootOptions={mode:"open"},null==Dt||Dt({ReactiveElement:Mt}),(null!==(Ot=Pt.reactiveElementVersions)&&void 0!==Ot?Ot:Pt.reactiveElementVersions=[]).push("1.6.3");const Bt=window,Wt=Bt.trustedTypes,Nt=Wt?Wt.createPolicy("lit-html",{createHTML:t=>t}):void 0,zt="$lit$",Ut=`lit$${(Math.random()+"").slice(9)}$`,Ht="?"+Ut,Gt=`<${Ht}>`,Xt=document,Yt=()=>Xt.createComment(""),Vt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,$t=Array.isArray,qt="[ \t\n\f\r]",Kt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qt=/-->/g,Jt=/>/g,Zt=RegExp(`>|${qt}(?:([^\\s"'>=/]+)(${qt}*=${qt}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),te=/'/g,ee=/"/g,ie=/^(?:script|style|textarea|title)$/i,ne=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),re=ne(1),se=(ne(2),Symbol.for("lit-noChange")),oe=Symbol.for("lit-nothing"),ae=new WeakMap,he=Xt.createTreeWalker(Xt,129,null,!1);function ce(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Nt?Nt.createHTML(e):e}const le=(t,e)=>{const i=t.length-1,n=[];let r,s=2===e?"":"",o=Kt;for(let e=0;e"===h[0]?(o=null!=r?r:Kt,c=-1):void 0===h[1]?c=-2:(c=o.lastIndex-h[2].length,a=h[1],o=void 0===h[3]?Zt:'"'===h[3]?ee:te):o===ee||o===te?o=Zt:o===Qt||o===Jt?o=Kt:(o=Zt,r=void 0);const u=o===Zt&&t[e+1].startsWith("/>")?" ":"";s+=o===Kt?i+Gt:c>=0?(n.push(a),i.slice(0,c)+zt+i.slice(c)+Ut+u):i+Ut+(-2===c?(n.push(void 0),e):u)}return[ce(t,s+(t[i]||"")+(2===e?"":"")),n]};class ue{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let r=0,s=0;const o=t.length-1,a=this.parts,[h,c]=le(t,e);if(this.el=ue.createElement(h,i),he.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(n=he.nextNode())&&a.length0){n.textContent=Wt?Wt.emptyScript:"";for(let i=0;i$t(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==oe&&Vt(this._$AH)?this._$AA.nextSibling.data=t:this.$(Xt.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=ue.createElement(ce(n.h,n.h[0]),this.options)),n);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(i);else{const t=new de(r,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=ae.get(t.strings);return void 0===e&&ae.set(t.strings,e=new ue(t)),e}T(t){$t(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const r of t)n===e.length?e.push(i=new pe(this.k(Yt()),this.k(Yt()),this,this.options)):i=e[n],i._$AI(r),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=oe}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,n){const r=this.strings;let s=!1;if(void 0===r)t=fe(this,t,e,0),s=!Vt(t)||t!==this._$AH&&t!==se,s&&(this._$AH=t);else{const n=t;let o,a;for(t=r[0],o=0;o{var n,r;const s=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:e;let o=s._$litPart$;if(void 0===o){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=o=new pe(e.insertBefore(Yt(),t),t,void 0,null!=i?i:{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return se}}we.finalized=!0,we._$litElement$=!0,null===(Se=globalThis.litElementHydrateSupport)||void 0===Se||Se.call(globalThis,{LitElement:we});const Te=globalThis.litElementPolyfillSupport;null==Te||Te({LitElement:we}),(null!==(Ce=globalThis.litElementVersions)&&void 0!==Ce?Ce:globalThis.litElementVersions=[]).push("3.3.3");const Ee=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){customElements.define(t,e)}}})(t,e),Oe=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function Pe(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):Oe(t,e)}var Ae;null===(Ae=window.HTMLSlotElement)||void 0===Ae||Ae.prototype.assignedElements;var ke=function(t,e,i,n){var r,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o};let De=class extends we{constructor(){super(),this.data="",this.colorScheme="dynamic",this.numberHits=100,this.numberHsps=10,this.logSkippedHsps=!0,this.canvasWrapperStroke=!0}async render(){const t={colorScheme:this.colorScheme,numberHits:this.numberHits,numberHsps:this.numberHsps,logSkippedHsps:this.logSkippedHsps,canvasWrapperStroke:this.canvasWrapperStroke};if(null===document.getElementById("canvas")){const t=document.createElement("div");t.id="canvas-wrapper";const e=document.createElement("canvas");e.id="canvas",t.appendChild(e),document.body.appendChild(t)}const e=D(this.data),i=P(await O(e));return new mt("canvas",i,t).render(),re`${this.canvasDivTemplate}`}get canvasDivTemplate(){return re``}};ke([Pe({type:String})],De.prototype,"data",void 0),ke([Pe({type:String})],De.prototype,"colorScheme",void 0),ke([Pe({type:Number})],De.prototype,"numberHits",void 0),ke([Pe({type:Number})],De.prototype,"numberHsps",void 0),ke([Pe({type:Boolean})],De.prototype,"logSkippedHsps",void 0),ke([Pe({type:Boolean})],De.prototype,"canvasWrapperStroke",void 0),De=ke([Ee("jd-visual-output")],De);var je=function(t,e,i,n){var r,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o};let Ie=class extends we{constructor(){super(),this.data="",this.colorScheme="dynamic",this.numberHits=30,this.canvasWrapperStroke=!0}async render(){const t={colorScheme:this.colorScheme,numberHits:this.numberHits,canvasWrapperStroke:this.canvasWrapperStroke};if(null===document.getElementById("canvas")){const t=document.createElement("div");t.id="canvas-wrapper";const e=document.createElement("canvas");e.id="canvas",t.appendChild(e),document.body.appendChild(t)}const e=D(this.data),i=P(await O(e));let n;n="mock_jobid-I20200317-103136-0485-5599422-np2"===this.data?"https://raw.githubusercontent.com/ebi-jdispatcher/jdispatcher-viewers/master/src/testdata/iprmc.xml":j(i);const r=P(I(await O(n,"xml")));return new _t("canvas",i,r,t).render(),re` ${this.canvasDivTemplate} `}get canvasDivTemplate(){return re``}};je([Pe({type:String})],Ie.prototype,"data",void 0),je([Pe({type:String})],Ie.prototype,"colorScheme",void 0),je([Pe({type:Number})],Ie.prototype,"numberHits",void 0),je([Pe({type:Boolean})],Ie.prototype,"canvasWrapperStroke",void 0),Ie=je([Ee("jd-functional-predictions")],Ie);class Fe{constructor(){this.listener=()=>{},this.jobIds=[],this.submitterName=""}static getInstance(){return this.instance||(this.instance=new Fe),this.instance}addListener(t){this.listener=t}addCanvas(t,e,i){0!==this.jobIds.length&&this.jobIds.includes(t)&&i===this.submitterName||(this.submitterName=i,this.jobIds.push(t),this.canvasInstance={jobId:t,data:e,submitter:i},this.listener(this.canvasInstance))}}const Le=Fe.getInstance();class Me{constructor(){if(this.jobId="",this.templateElement=document.getElementById("input-jobid"),this.hostElement=document.getElementById("jd-viewers-app"),null!==this.templateElement){const t=document.importNode(this.templateElement.content,!0);this.element=t.firstElementChild,this.jobIdElement=this.element.querySelector("#jobid"),this.submitListener(),this.renderForm()}}submitListener(){this.element.addEventListener("submit",this.submitHandler)}renderForm(){this.hostElement.insertAdjacentElement("afterbegin",this.element)}submitHandler(t){t.preventDefault();const e=t,i=this.jobIdElement.value.trim();let n={...p};n.value=i,k(n)?"mock_jobid-I20200317-103136-0485-5599422-np2"===i?Le.addCanvas(i,"testdata/ncbiblast.json",e.submitter.name.trim()):Le.addCanvas(i,i,e.submitter.name.trim()):alert("The jobId provided is not valid!")}}!function(t,e,i,n){var r,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);s>3&&o&&Object.defineProperty(e,i,o)}([function(t,e,i){const n=i.value;return{configurable:!0,get(){return n.bind(this)}}}],Me.prototype,"submitHandler",null),new Me,new class{constructor(){if(this.templateElement=document.getElementById("jd-viewers-output"),this.hostElement=document.getElementById("jd-viewers-app"),null!==this.templateElement){const t=document.importNode(this.templateElement.content,!0);this.elementCanvas=t.firstElementChild,Le.addListener((t=>{this.canvasInstance=t,this.renderCanvas()}))}}async renderCanvas(){let t;this.hostElement.insertAdjacentElement("beforeend",this.elementCanvas);const e=D(this.canvasInstance.data),i=P(await O(e));if("visual-output"===this.canvasInstance.submitter)t=new mt("canvas",i,{colorScheme:d.dynamic,numberHits:100,numberHsps:10,logSkippedHsps:!0,canvasWrapperStroke:!0}),t.render();else if("functional-predictions"===this.canvasInstance.submitter){let e;e="mock_jobid-I20200317-103136-0485-5599422-np2"===this.canvasInstance.jobId?"testdata/iprmc.xml":j(i);const n=P(I(await O(e,"xml")));t=new _t("canvas",i,n,{colorScheme:d.dynamic,numberHits:30,canvasWrapperStroke:!0}),t.render()}document.getElementById("btn-svg").onclick=function(){document.getElementById("svg").src=r()(t.canvas.toSVG().toString());const e=document.getElementById("canvas-wrapper");e.parentNode?.removeChild(e)},document.getElementById("btn-png").onclick=function(){const e=document.getElementById("png");e.src=t.canvas.toDataURL({format:"png",enableRetinaScaling:!0,withoutTransform:!0}).toString(),e.width=t.canvas.getWidth();const i=document.getElementById("canvas-wrapper");i.parentNode?.removeChild(i)}}},t=i.hmd(t),s.Bd&&(window.VisualOutput=mt,window.FunctionalPredictions=_t,window.validateJobId=k,window.svgToMiniDataURI=r(),window.fetchData=O,window.dataAsType=P,window.getJdispatcherJsonURL=A,window.validateSubmittedJobIdInput=D,window.validateSubmittedDbfetchInput=j,window.getIPRMCDataModelFlatFromXML=I,window.ColorSchemeEnum=d),s.Ll&&(t.exports={VisualOutput:mt,FunctionalPredictions:_t,validateJobId:k,svgToMiniDataURI:r(),fetchData:O,dataAsType:P,getJdispatcherJsonURL:A,validateSubmittedJobIdInput:D,validateSubmittedDbfetchInput:j,getIPRMCDataModelFlatFromXML:I,ColorSchemeEnum:d})},740:t=>{t.exports={isArray:function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}}},990:(t,e,i)=>{var n=i(538),r=i(3),s=i(348),o=i(433);t.exports={xml2js:n,xml2json:r,js2xml:s,json2xml:o}},348:(t,e,i)=>{var n,r,s=i(193),o=i(740).isArray;function a(t,e,i){return(!i&&t.spaces?"\n":"")+Array(e+1).join(t.spaces)}function h(t,e,i){if(e.ignoreAttributes)return"";"attributesFn"in e&&(t=e.attributesFn(t,r,n));var s,o,h,c,l=[];for(s in t)t.hasOwnProperty(s)&&null!==t[s]&&void 0!==t[s]&&(c=e.noQuotesForNativeAttributes&&"string"!=typeof t[s]?"":'"',o=(o=""+t[s]).replace(/"/g,"""),h="attributeNameFn"in e?e.attributeNameFn(s,o,r,n):s,l.push(e.spaces&&e.indentAttributes?a(e,i+1,!1):" "),l.push(h+"="+c+("attributeValueFn"in e?e.attributeValueFn(o,s,r,n):o)+c));return t&&Object.keys(t).length&&e.spaces&&e.indentAttributes&&l.push(a(e,i,!1)),l.join("")}function c(t,e,i){return n=t,r="xml",e.ignoreDeclaration?"":""}function l(t,e,i){if(e.ignoreInstruction)return"";var s;for(s in t)if(t.hasOwnProperty(s))break;var o="instructionNameFn"in e?e.instructionNameFn(s,t[s],r,n):s;if("object"==typeof t[s])return n=t,r=o,"";var a=t[s]?t[s]:"";return"instructionFn"in e&&(a=e.instructionFn(a,s,r,n)),""}function u(t,e){return e.ignoreComment?"":"\x3c!--"+("commentFn"in e?e.commentFn(t,r,n):t)+"--\x3e"}function f(t,e){return e.ignoreCdata?"":""+("cdataFn"in e?e.cdataFn(t,r,n):t.replace("","]]]]>>"))+""}function d(t,e){return e.ignoreDoctype?"":""}function p(t,e){return e.ignoreText?"":(t=(t=(t=""+t).replace(/&/g,"&")).replace(/&/g,"&").replace(//g,">"),"textFn"in e?e.textFn(t,r,n):t)}function g(t,e,i,s){return t.reduce((function(t,o){var c=a(e,i,s&&!t);switch(o.type){case"element":return t+c+function(t,e,i){n=t,r=t.name;var s=[],o="elementNameFn"in e?e.elementNameFn(t.name,t):t.name;s.push("<"+o),t[e.attributesKey]&&s.push(h(t[e.attributesKey],e,i));var a=t[e.elementsKey]&&t[e.elementsKey].length||t[e.attributesKey]&&"preserve"===t[e.attributesKey]["xml:space"];return a||(a="fullTagEmptyElementFn"in e?e.fullTagEmptyElementFn(t.name,t):e.fullTagEmptyElement),a?(s.push(">"),t[e.elementsKey]&&t[e.elementsKey].length&&(s.push(g(t[e.elementsKey],e,i+1)),n=t,r=t.name),s.push(e.spaces&&function(t,e){var i;if(t.elements&&t.elements.length)for(i=0;i")):s.push("/>"),s.join("")}(o,e,i);case"comment":return t+c+u(o[e.commentKey],e);case"doctype":return t+c+d(o[e.doctypeKey],e);case"cdata":return t+(e.indentCdata?c:"")+f(o[e.cdataKey],e);case"text":return t+(e.indentText?c:"")+p(o[e.textKey],e);case"instruction":var m={};return m[o[e.nameKey]]=o[e.attributesKey]?o:o[e.instructionKey],t+(e.indentInstruction?c:"")+l(m,e,i)}}),"")}function m(t,e,i){var n;for(n in t)if(t.hasOwnProperty(n))switch(n){case e.parentKey:case e.attributesKey:break;case e.textKey:if(e.indentText||i)return!0;break;case e.cdataKey:if(e.indentCdata||i)return!0;break;case e.instructionKey:if(e.indentInstruction||i)return!0;break;case e.doctypeKey:case e.commentKey:default:return!0}return!1}function v(t,e,i,s,o){n=t,r=e;var c="elementNameFn"in i?i.elementNameFn(e,t):e;if(null==t||""===t)return"fullTagEmptyElementFn"in i&&i.fullTagEmptyElementFn(e,t)||i.fullTagEmptyElement?"<"+c+">":"<"+c+"/>";var l=[];if(e){if(l.push("<"+c),"object"!=typeof t)return l.push(">"+p(t,i)+""),l.join("");t[i.attributesKey]&&l.push(h(t[i.attributesKey],i,s));var u=m(t,i,!0)||t[i.attributesKey]&&"preserve"===t[i.attributesKey]["xml:space"];if(u||(u="fullTagEmptyElementFn"in i?i.fullTagEmptyElementFn(e,t):i.fullTagEmptyElement),!u)return l.push("/>"),l.join("");l.push(">")}return l.push(y(t,i,s+1,!1)),n=t,r=e,e&&l.push((o?a(i,s,!1):"")+""),l.join("")}function y(t,e,i,n){var r,s,h,g=[];for(s in t)if(t.hasOwnProperty(s))for(h=o(t[s])?t[s]:[t[s]],r=0;r{var n=i(348);t.exports=function(t,e){t instanceof Buffer&&(t=t.toString());var i=null;if("string"==typeof t)try{i=JSON.parse(t)}catch(t){throw new Error("The JSON structure is invalid")}else i=t;return n(i,e)}},193:(t,e,i)=>{var n=i(740).isArray;t.exports={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){t in e&&"boolean"==typeof e[t]||(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||"number"!=typeof t.spaces&&"string"!=typeof t.spaces)&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){"alwaysArray"in t&&("boolean"==typeof t.alwaysArray||n(t.alwaysArray))||(t.alwaysArray=!1)},ensureKeyExists:function(t,e){t+"Key"in e&&"string"==typeof e[t+"Key"]||(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}}},538:(t,e,i)=>{var n,r,s=i(43),o=i(193),a=i(740).isArray;function h(t){var e=Number(t);if(!isNaN(e))return e;var i=t.toLowerCase();return"true"===i||"false"!==i&&t}function c(t,e){var i;if(n.compact){if(!r[n[t+"Key"]]&&(a(n.alwaysArray)?-1!==n.alwaysArray.indexOf(n[t+"Key"]):n.alwaysArray)&&(r[n[t+"Key"]]=[]),r[n[t+"Key"]]&&!a(r[n[t+"Key"]])&&(r[n[t+"Key"]]=[r[n[t+"Key"]]]),t+"Fn"in n&&"string"==typeof e&&(e=n[t+"Fn"](e,r)),"instruction"===t&&("instructionFn"in n||"instructionNameFn"in n))for(i in e)if(e.hasOwnProperty(i))if("instructionFn"in n)e[i]=n.instructionFn(e[i],i,r);else{var s=e[i];delete e[i],e[n.instructionNameFn(i,s,r)]=s}a(r[n[t+"Key"]])?r[n[t+"Key"]].push(e):r[n[t+"Key"]]=e}else{r[n.elementsKey]||(r[n.elementsKey]=[]);var o={};if(o[n.typeKey]=t,"instruction"===t){for(i in e)if(e.hasOwnProperty(i))break;o[n.nameKey]="instructionNameFn"in n?n.instructionNameFn(i,e,r):i,n.instructionHasAttributes?(o[n.attributesKey]=e[i][n.attributesKey],"instructionFn"in n&&(o[n.attributesKey]=n.instructionFn(o[n.attributesKey],i,r))):("instructionFn"in n&&(e[i]=n.instructionFn(e[i],i,r)),o[n.instructionKey]=e[i])}else t+"Fn"in n&&(e=n[t+"Fn"](e,r)),o[n[t+"Key"]]=e;n.addParent&&(o[n.parentKey]=r),r[n.elementsKey].push(o)}}function l(t){var e;if("attributesFn"in n&&t&&(t=n.attributesFn(t,r)),(n.trim||"attributeValueFn"in n||"attributeNameFn"in n||n.nativeTypeAttributes)&&t)for(e in t)if(t.hasOwnProperty(e)&&(n.trim&&(t[e]=t[e].trim()),n.nativeTypeAttributes&&(t[e]=h(t[e])),"attributeValueFn"in n&&(t[e]=n.attributeValueFn(t[e],e,r)),"attributeNameFn"in n)){var i=t[e];delete t[e],t[n.attributeNameFn(e,t[e],r)]=i}return t}function u(t){var e={};if(t.body&&("xml"===t.name.toLowerCase()||n.instructionHasAttributes)){for(var i,s=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;null!==(i=s.exec(t.body));)e[i[1]]=i[2]||i[3]||i[4];e=l(e)}if("xml"===t.name.toLowerCase()){if(n.ignoreDeclaration)return;r[n.declarationKey]={},Object.keys(e).length&&(r[n.declarationKey][n.attributesKey]=e),n.addParent&&(r[n.declarationKey][n.parentKey]=r)}else{if(n.ignoreInstruction)return;n.trim&&(t.body=t.body.trim());var o={};n.instructionHasAttributes&&Object.keys(e).length?(o[t.name]={},o[t.name][n.attributesKey]=e):o[t.name]=t.body,c("instruction",o)}}function f(t,e){var i;if("object"==typeof t&&(e=t.attributes,t=t.name),e=l(e),"elementNameFn"in n&&(t=n.elementNameFn(t,r)),n.compact){var s;if(i={},!n.ignoreAttributes&&e&&Object.keys(e).length)for(s in i[n.attributesKey]={},e)e.hasOwnProperty(s)&&(i[n.attributesKey][s]=e[s]);!(t in r)&&(a(n.alwaysArray)?-1!==n.alwaysArray.indexOf(t):n.alwaysArray)&&(r[t]=[]),r[t]&&!a(r[t])&&(r[t]=[r[t]]),a(r[t])?r[t].push(i):r[t]=i}else r[n.elementsKey]||(r[n.elementsKey]=[]),(i={})[n.typeKey]="element",i[n.nameKey]=t,!n.ignoreAttributes&&e&&Object.keys(e).length&&(i[n.attributesKey]=e),n.alwaysChildren&&(i[n.elementsKey]=[]),r[n.elementsKey].push(i);i[n.parentKey]=r,r=i}function d(t){n.ignoreText||(t.trim()||n.captureSpacesBetweenElements)&&(n.trim&&(t=t.trim()),n.nativeType&&(t=h(t)),n.sanitize&&(t=t.replace(/&/g,"&").replace(//g,">")),c("text",t))}function p(t){n.ignoreComment||(n.trim&&(t=t.trim()),c("comment",t))}function g(t){var e=r[n.parentKey];n.addParent||delete r[n.parentKey],r=e}function m(t){n.ignoreCdata||(n.trim&&(t=t.trim()),c("cdata",t))}function v(t){n.ignoreDoctype||(t=t.replace(/^ /,""),n.trim&&(t=t.trim()),c("doctype",t))}function y(t){t.note=t}t.exports=function(t,e){var i=s.parser(!0,{}),a={};if(r=a,n=function(t){return n=o.copyOptions(t),o.ensureFlagExists("ignoreDeclaration",n),o.ensureFlagExists("ignoreInstruction",n),o.ensureFlagExists("ignoreAttributes",n),o.ensureFlagExists("ignoreText",n),o.ensureFlagExists("ignoreComment",n),o.ensureFlagExists("ignoreCdata",n),o.ensureFlagExists("ignoreDoctype",n),o.ensureFlagExists("compact",n),o.ensureFlagExists("alwaysChildren",n),o.ensureFlagExists("addParent",n),o.ensureFlagExists("trim",n),o.ensureFlagExists("nativeType",n),o.ensureFlagExists("nativeTypeAttributes",n),o.ensureFlagExists("sanitize",n),o.ensureFlagExists("instructionHasAttributes",n),o.ensureFlagExists("captureSpacesBetweenElements",n),o.ensureAlwaysArrayExists(n),o.ensureKeyExists("declaration",n),o.ensureKeyExists("instruction",n),o.ensureKeyExists("attributes",n),o.ensureKeyExists("text",n),o.ensureKeyExists("comment",n),o.ensureKeyExists("cdata",n),o.ensureKeyExists("doctype",n),o.ensureKeyExists("type",n),o.ensureKeyExists("name",n),o.ensureKeyExists("elements",n),o.ensureKeyExists("parent",n),o.checkFnExists("doctype",n),o.checkFnExists("instruction",n),o.checkFnExists("cdata",n),o.checkFnExists("comment",n),o.checkFnExists("text",n),o.checkFnExists("instructionName",n),o.checkFnExists("elementName",n),o.checkFnExists("attributeName",n),o.checkFnExists("attributeValue",n),o.checkFnExists("attributes",n),n}(e),i.opt={strictEntities:!0},i.onopentag=f,i.ontext=d,i.oncomment=p,i.onclosetag=g,i.onerror=y,i.oncdata=m,i.ondoctype=v,i.onprocessinginstruction=u,i.write(t).close(),a[n.elementsKey]){var h=a[n.elementsKey];delete a[n.elementsKey],a[n.elementsKey]=h,delete a.text}return a}},3:(t,e,i)=>{var n=i(193),r=i(538);t.exports=function(t,e){var i,s,o;return i=function(t){var e=n.copyOptions(t);return n.ensureSpacesExists(e),e}(e),s=r(t,i),o="compact"in i&&i.compact?"_parent":"parent",("addParent"in i&&i.addParent?JSON.stringify(s,(function(t,e){return t===o?"_":e}),i.spaces):JSON.stringify(s,null,i.spaces)).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}},574:()=>{},748:()=>{},246:()=>{}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var s=e[n]={id:n,loaded:!1,exports:{}};return t[n](s,s.exports,i),s.loaded=!0,s.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i(79)})(); \ No newline at end of file diff --git a/dist/jd_viewers_0.0.11.bundle.min.js.LICENSE.txt b/dist/jd_viewers_0.0.11.bundle.min.js.LICENSE.txt new file mode 100644 index 0000000..c6c264b --- /dev/null +++ b/dist/jd_viewers_0.0.11.bundle.min.js.LICENSE.txt @@ -0,0 +1,32 @@ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + +/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ + +/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */ + +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ + +/*! safe-buffer. MIT License. Feross Aboukhadijeh */ + +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */ diff --git a/index.html b/index.html index 3d09da5..66b6500 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ jdistpatcher-viewers - + diff --git a/package-lock.json b/package-lock.json index 9c1e05f..cfb942f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ebi-jdispatcher/jdispatcher-viewers", - "version": "0.0.10", + "version": "0.0.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@ebi-jdispatcher/jdispatcher-viewers", - "version": "0.0.10", + "version": "0.0.11", "license": "Apache-2.0", "dependencies": { "@types/browser-or-node": "^1.3.2", diff --git a/package.json b/package.json index 7055422..94fab36 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ebi-jdispatcher/jdispatcher-viewers", "description": "Interactive Visual Output and Functional Prediction visualizations", - "version": "0.0.10", + "version": "0.0.11", "module": "./dist/jd_viewers.bundle.js", "exports": "./bin/jd-viewers-cli.js", "main": "./bin/jd-viewers-cli.js",