@leapfrog/interactive-canvas 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -171,37 +171,37 @@ export declare class InteractiveCanvas implements IInteractiveCanvas {
|
|
|
171
171
|
* @override
|
|
172
172
|
* @inheritDoc
|
|
173
173
|
*/
|
|
174
|
-
addImageObject(imageUrl: string):
|
|
174
|
+
addImageObject(imageUrl: string): Promise<IImage>;
|
|
175
175
|
/**
|
|
176
176
|
* @override
|
|
177
177
|
* @inheritDoc
|
|
178
178
|
*/
|
|
179
|
-
addTextObject():
|
|
179
|
+
addTextObject(): Promise<IText>;
|
|
180
180
|
/**
|
|
181
181
|
* @override
|
|
182
182
|
* @inheritDoc
|
|
183
183
|
*/
|
|
184
|
-
addRectangleObject():
|
|
184
|
+
addRectangleObject(): Promise<IRectangle>;
|
|
185
185
|
/**
|
|
186
186
|
* @override
|
|
187
187
|
* @inheritDoc
|
|
188
188
|
*/
|
|
189
|
-
addCutoffObject():
|
|
189
|
+
addCutoffObject(): Promise<ICutoff>;
|
|
190
190
|
/**
|
|
191
191
|
* @override
|
|
192
192
|
* @inheritDoc
|
|
193
193
|
*/
|
|
194
|
-
addBorderObject():
|
|
194
|
+
addBorderObject(): Promise<IBorder>;
|
|
195
195
|
/**
|
|
196
196
|
* @override
|
|
197
197
|
* @inheritDoc
|
|
198
198
|
*/
|
|
199
|
-
addVerticalRuleObject():
|
|
199
|
+
addVerticalRuleObject(): Promise<IVerticalRule>;
|
|
200
200
|
/**
|
|
201
201
|
* @override
|
|
202
202
|
* @inheritDoc
|
|
203
203
|
*/
|
|
204
|
-
addHorizontalRuleObject():
|
|
204
|
+
addHorizontalRuleObject(): Promise<IHorizontalRule>;
|
|
205
205
|
/**
|
|
206
206
|
* @override
|
|
207
207
|
* @inheritDoc
|
|
@@ -138,31 +138,31 @@ export interface IInteractiveCanvas {
|
|
|
138
138
|
* Add an image object to the canvas.
|
|
139
139
|
* @param imageUrl Url for image content.
|
|
140
140
|
*/
|
|
141
|
-
addImageObject(imageUrl: string):
|
|
141
|
+
addImageObject(imageUrl: string): Promise<IImage>;
|
|
142
142
|
/**
|
|
143
143
|
* Add a text object to the canvas.
|
|
144
144
|
*/
|
|
145
|
-
addTextObject():
|
|
145
|
+
addTextObject(): Promise<IText>;
|
|
146
146
|
/**
|
|
147
147
|
* Add a rectangle object to the canvas.
|
|
148
148
|
*/
|
|
149
|
-
addRectangleObject():
|
|
149
|
+
addRectangleObject(): Promise<IRectangle>;
|
|
150
150
|
/**
|
|
151
151
|
* Add a rectangle object to the canvas.
|
|
152
152
|
*/
|
|
153
|
-
addCutoffObject():
|
|
153
|
+
addCutoffObject(): Promise<ICutoff>;
|
|
154
154
|
/**
|
|
155
155
|
* Add a border object to the canvas.
|
|
156
156
|
*/
|
|
157
|
-
addBorderObject():
|
|
157
|
+
addBorderObject(): Promise<IBorder>;
|
|
158
158
|
/**
|
|
159
159
|
* Add a vertical rule object to the canvas.
|
|
160
160
|
*/
|
|
161
|
-
addVerticalRuleObject():
|
|
161
|
+
addVerticalRuleObject(): Promise<IVerticalRule>;
|
|
162
162
|
/**
|
|
163
163
|
* Add a horizontal rule object to the canvas.
|
|
164
164
|
*/
|
|
165
|
-
addHorizontalRuleObject():
|
|
165
|
+
addHorizontalRuleObject(): Promise<IHorizontalRule>;
|
|
166
166
|
/**
|
|
167
167
|
* Set the data used to prefill text into the canvas.
|
|
168
168
|
* @param data Prefill data.
|
|
@@ -30,5 +30,5 @@ var n,r,o,s,a,c,u,h,l,f,d,p,g,v,y,m,b,_,x,w,C,S=S||{version:"3.6.3"};if(e.fabric
|
|
|
30
30
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
31
31
|
* @license MIT
|
|
32
32
|
*/
|
|
33
|
-
var n=i(47),r=i(48),o=i(49);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,i){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,i);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(this,t)}return u(this,t,e,i)}function u(t,e,i,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,i,n){if(e.byteLength,i<0||e.byteLength<i)throw new RangeError("'offset' is out of bounds");if(e.byteLength<i+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===i&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,i):new Uint8Array(e,i,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=f(t,e);return t}(t,e,i,n):"string"==typeof e?function(t,e,i){"string"==typeof i&&""!==i||(i="utf8");if(!c.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(e,i),r=(t=a(t,n)).write(e,i);r!==n&&(t=t.slice(0,r));return t}(t,e,i):function(t,e){if(c.isBuffer(e)){var i=0|d(e.length);return 0===(t=a(t,i)).length||e.copy(t,0,0,i),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):f(t,e);if("Buffer"===e.type&&o(e.data))return f(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function l(t,e){if(h(e),t=a(t,e<0?0:0|d(e)),!c.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function f(t,e){var i=e.length<0?0:0|d(e.length);t=a(t,i);for(var n=0;n<i;n+=1)t[n]=255&e[n];return t}function d(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return Y(t).length;default:if(n)return U(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,i){var 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 E(this,e,i);case"utf8":case"utf-8":return O(this,e,i);case"ascii":return j(this,e,i);case"latin1":case"binary":return P(this,e,i);case"base64":return T(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,i){var 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),i=+i,isNaN(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=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var o,s=1,a=t.length,c=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;s=2,a/=2,c/=2,i/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(r){var h=-1;for(o=i;o<a;o++)if(u(t,o)===u(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===c)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(i+c>a&&(i=a-c),o=i;o>=0;o--){for(var l=!0,f=0;f<c;f++)if(u(t,o+f)!==u(e,f)){l=!1;break}if(l)return o}return-1}function b(t,e,i,n){i=Number(i)||0;var r=t.length-i;n?(n=Number(n))>r&&(n=r):n=r;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[i+s]=a}return s}function _(t,e,i,n){return N(U(e,t.length-i),t,i,n)}function x(t,e,i,n){return N(function(t){for(var e=[],i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}(e),t,i,n)}function w(t,e,i,n){return x(t,e,i,n)}function C(t,e,i,n){return N(Y(e),t,i,n)}function S(t,e,i,n){return N(function(t,e){for(var i,n,r,o=[],s=0;s<t.length&&!((e-=2)<0);++s)i=t.charCodeAt(s),n=i>>8,r=i%256,o.push(r),o.push(n);return o}(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 O(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r<i;){var o,s,a,c,u=t[r],h=null,l=u>239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(o=t[r+1]))&&(c=(31&u)<<6|63&o)>127&&(h=c);break;case 3:o=t[r+1],s=t[r+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:o=t[r+1],s=t[r+2],a=t[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),r+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return i}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,i){return u(null,t,e,i)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,i){return function(t,e,i,n){return h(e),e<=0?a(t,e):void 0!==i?"string"==typeof n?a(t,e).fill(i,n):a(t,e).fill(i):a(t,e)}(null,t,e,i)},c.allocUnsafe=function(t){return l(null,t)},c.allocUnsafeSlow=function(t){return l(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var i=t.length,n=e.length,r=0,o=Math.min(i,n);r<o;++r)if(t[r]!==e[r]){i=t[r],n=e[r];break}return i<n?-1:n<i?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var i;if(void 0===e)for(e=0,i=0;i<t.length;++i)e+=t[i].length;var n=c.allocUnsafe(e),r=0;for(i=0;i<t.length;++i){var s=t[i];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,r),r+=s.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)v(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,i,n,r){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");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;for(var o=(r>>>=0)-(n>>>=0),s=(i>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(n,r),h=t.slice(e,i),l=0;l<a;++l)if(u[l]!==h[l]){o=u[l],s=h[l];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},c.prototype.indexOf=function(t,e,i){return y(this,t,e,i,!0)},c.prototype.lastIndexOf=function(t,e,i){return y(this,t,e,i,!1)},c.prototype.write=function(t,e,i,n){if(void 0===e)n="utf8",i=this.length,e=0;else if(void 0===i&&"string"==typeof e)n=e,i=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(i)?(i|=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}var 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");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,i);case"utf8":case"utf-8":return _(this,t,e,i);case"ascii":return x(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return C(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function j(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;r<i;++r)n+=String.fromCharCode(127&t[r]);return n}function P(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;r<i;++r)n+=String.fromCharCode(t[r]);return n}function E(t,e,i){var n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);for(var r="",o=e;o<i;++o)r+=W(t[o]);return r}function k(t,e,i){for(var n=t.slice(e,i),r="",o=0;o<n.length;o+=2)r+=String.fromCharCode(n[o]+256*n[o+1]);return r}function A(t,e,i){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>i)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,i,n,r,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<o)throw new RangeError('"value" argument is out of bounds');if(i+n>t.length)throw new RangeError("Index out of range")}function M(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,o=Math.min(t.length-i,2);r<o;++r)t[i+r]=(e&255<<8*(n?r:1-r))>>>8*(n?r:1-r)}function I(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,o=Math.min(t.length-i,4);r<o;++r)t[i+r]=e>>>8*(n?r:3-r)&255}function F(t,e,i,n,r,o){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,o){return o||F(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,o){return o||F(t,0,i,8),r.write(t,e,i,n,52,8),i+8}c.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(i=this.subarray(t,e)).__proto__=c.prototype;else{var r=e-t;i=new c(r,void 0);for(var o=0;o<r;++o)i[o]=this[o+t]}return i},c.prototype.readUIntLE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t],r=1,o=0;++o<e&&(r*=256);)n+=this[t+o]*r;return n},c.prototype.readUIntBE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t+--e],r=1;e>0&&(r*=256);)n+=this[t+--e]*r;return n},c.prototype.readUInt8=function(t,e){return e||A(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||A(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||A(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t],r=1,o=0;++o<e&&(r*=256);)n+=this[t+o]*r;return n>=(r*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=e,r=1,o=this[t+--n];n>0&&(r*=256);)o+=this[t+--n]*r;return o>=(r*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||A(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||A(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(t,e){e||A(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(t,e){return e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||A(t,4,this.length),r.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||A(t,4,this.length),r.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||A(t,8,this.length),r.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||A(t,8,this.length),r.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||D(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,o=0;for(this[e]=255&t;++o<i&&(r*=256);)this[e+o]=t/r&255;return e+i},c.prototype.writeUIntBE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||D(this,t,e,i,Math.pow(2,8*i)-1,0);var r=i-1,o=1;for(this[e+r]=255&t;--r>=0&&(o*=256);)this[e+r]=t/o&255;return e+i},c.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):I(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);D(this,t,e,i,r-1,-r)}var o=0,s=1,a=0;for(this[e]=255&t;++o<i&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+i},c.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);D(this,t,e,i,r-1,-r)}var o=i-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+i},c.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):I(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,i){return R(this,t,e,!0,i)},c.prototype.writeFloatBE=function(t,e,i){return R(this,t,e,!1,i)},c.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},c.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},c.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-i&&(n=t.length-e+i);var r,o=n-i;if(this===t&&i<e&&e<n)for(r=o-1;r>=0;--r)t[r+e]=this[r+i];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(r=0;r<o;++r)t[r+e]=this[r+i];else Uint8Array.prototype.set.call(t,this.subarray(i,i+o),e);return o},c.prototype.fill=function(t,e,i,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),1===t.length){var r=t.charCodeAt(0);r<256&&(t=r)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;var o;if(e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(o=e;o<i;++o)this[o]=t;else{var s=c.isBuffer(t)?t:U(new c(t,n).toString()),a=s.length;for(o=0;o<i-e;++o)this[o+e]=s[o%a]}return this};var B=/[^+\/0-9A-Za-z-_]/g;function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function U(t,e){var i;e=e||1/0;for(var n=t.length,r=null,o=[],s=0;s<n;++s){if((i=t.charCodeAt(s))>55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&o.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&o.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;o.push(i)}else if(i<2048){if((e-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;o.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;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function Y(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(B,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,i,n){for(var r=0;r<n&&!(r+i>=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),s=n[0],a=n[1],c=new o(function(t,e,i){return 3*(e+i)/4-i}(0,s,a)),h=0,l=a>0?s-4:s;for(i=0;i<l;i+=4)e=r[t.charCodeAt(i)]<<18|r[t.charCodeAt(i+1)]<<12|r[t.charCodeAt(i+2)]<<6|r[t.charCodeAt(i+3)],c[h++]=e>>16&255,c[h++]=e>>8&255,c[h++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,c[h++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,c[h++]=e>>8&255,c[h++]=255&e);return c},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,o=[],s=0,a=i-r;s<a;s+=16383)o.push(h(t,s,s+16383>a?a:s+16383));1===r?(e=t[i-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)n[a]=s[a],r[s.charCodeAt(a)]=a;function u(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,i){for(var r,o,s=[],a=e;a<i;a+=3)r=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=r)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,c=(1<<a)-1,u=c>>1,h=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+t[e+l],l+=f,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=f,h-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,i,n,r,o){var s,a,c,u=8*o-r-1,h=(1<<u)-1,l=h>>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-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,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*c-1)*Math.pow(2,r),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),s=0));r>=8;t[i+d]=255&a,d+=p,a/=256,r-=8);for(s=s<<r|a,u+=r;u>0;t[i+d]=255&s,d+=p,s/=256,u-=8);t[i+d-p]|=128*g}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){},function(t,e){},function(t,e){},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ImageType=void 0,function(t){t.DEFAULT="DEFAULT",t.BACKGROUND="BACKGROUND",t.LOGO="LOGO",t.PHOTO="PHOTO"}(e.ImageType||(e.ImageType={}))}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r,o=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},a=this&&this.__spreadArrays||function(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n};n=[i,e,i(3),i(1),i(1),i(19),i(22),i(18),i(21),i(23),i(12),i(4),i(16),i(6),i(25),i(20),i(9),i(29),i(26),i(7),i(24)],void 0===(r=function(t,e,i,n,r,c,u,h,l,f,d,p,g,v,y,m,b,_,x,w,C){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InteractiveCanvas=void 0;var S=function(){function t(t,e){var n=this;this.devicePixelRatio=e,this.fontLibrary=new b.FontLibrary,this.dimensionChangeRejections$=new i.Subject,this.IMAGE_CAPTURE_COEFFICIENT=this.calculateImageCaptureCoefficient(),this.fabricCanvas=new C.fabric.Canvas(t),this.baseDimensions=new w.PixelCanvasDimensions(this.fabricCanvas.width,this.fabricCanvas.height);this.dimensions$=new i.BehaviorSubject(this.baseDimensions),this.dimensionRestrictions$=new i.BehaviorSubject({width:{min:1},height:{min:1}}),this.zoom$=new i.BehaviorSubject(1),this.profile$=new i.BehaviorSubject(new x.DefaultCanvasProfile),this.layoutManager$=new i.BehaviorSubject(new d.AdvancedLayoutManager(this)),this.backgroundColor$=new i.BehaviorSubject(this.fabricCanvas.backgroundColor),this.objects$=new i.BehaviorSubject([]),this.selection$=new i.BehaviorSubject(new T([])),this.fabricCanvas.on("selection:updated",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("selection:created",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("selection:cleared",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("text:editing:entered",(function(){return n.onTextEditing()})),this.fabricCanvas.on("text:editing:exited",(function(){return n.onTextEditing()})),this.fabricCanvas.on("text:changed",(function(){return n.onTextChange()})),this.fabricCanvas.stateful=!0,this.fabricCanvas.preserveObjectStacking=!0,this.fabricCanvas.perPixelTargetFind=!0,this.fabricCanvas.targetFindTolerance=10,this.setBackgroundColor("#FFFFFF")}return t.prototype.getFontLibrary=function(){return this.fontLibrary},t.prototype.getProfile=function(){return this.profile$.value},t.prototype.getProfile$=function(){return this.profile$},t.prototype.setProfile=function(t){this.profile$.next(t),this.onProfileChanged(t),this.redraw()},t.prototype.getLayoutManager=function(){return this.layoutManager$.value},t.prototype.getLayoutManager$=function(){return this.layoutManager$},t.prototype.setLayoutManager=function(t){t===p.LayoutManager.STANDARD?this.layoutManager$.next(new g.StandardLayoutManager(this)):this.layoutManager$.next(new d.AdvancedLayoutManager(this)),this.layoutManager$.value.onInit()},t.prototype.getBackgroundColor=function(){return this.backgroundColor$.value},t.prototype.getBackgroundColor$=function(){return this.backgroundColor$},t.prototype.setBackgroundColor=function(t){void 0===t&&(t="White"),this.fabricCanvas.setBackgroundColor(t,(function(){})),this.fabricCanvas.renderAll(),this.backgroundColor$.next(t)},t.prototype.getDimensions=function(){return this.dimensions$.value},t.prototype.getBaseDimensions=function(){return this.baseDimensions},t.prototype.getDimensions$=function(){return this.dimensions$},t.prototype.setDimensions=function(t){if(this.dimensionsExceedRestrictions(t))return console.debug("Requested canvas dimensions exceed current restrictions",t,this.dimensionRestrictions$.value),void this.dimensionChangeRejections$.next(t);this.updateCanvasDimensions(t,this.zoom$.value),this.dimensions$.next(t),this.onDimensionsChange(),this.notifyObjectListChanged()},t.prototype.setBaseDimensions=function(t){this.baseDimensions=t,this.setDimensions(t),this.notifyObjectListChanged()},t.prototype.getDimensionChangeRejections$=function(){return this.dimensionChangeRejections$},t.prototype.getDimensionsRestrictions=function(){return this.dimensionRestrictions$.value},t.prototype.getDimensionsRestrictions$=function(){return this.dimensionRestrictions$},t.prototype.setDimensionRestrictions=function(t){this.dimensionRestrictions$.next(t)},t.prototype.getMargin=function(){var t=this.getObjectsByTypeInternal(_.ObjectType.BORDER).map((function(t){return t.getStrokeWidth()})).reduce((function(t,e){return Math.max(t,e)}),0),e=this.getObjectsByTypeInternal(_.ObjectType.CUTOFF).map((function(t){return t.getStrokeWidth()})).reduce((function(t,e){return Math.max(t,e)}),0);return{top:t,right:t,bottom:Math.max(e,t),left:t}},t.prototype.getZoom=function(){return this.zoom$.value},t.prototype.getZoom$=function(){return this.zoom$},t.prototype.setZoom=function(t){this.updateCanvasDimensions(this.dimensions$.value,t),this.zoom$.next(t)},t.prototype.getObjects=function(){return this.objects$.value},t.prototype.getObjectsInternal=function(){return this.objects$.value},t.prototype.getObjectsByTypeInternal=function(t){return n(this.getObjectsInternal()).filter((function(e){return e.getType()===t})).value()},t.prototype.getObjectsByTypesInternal=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this.getObjectsInternal()).filter((function(e){return n(t).includes(e.getType())})).value()},t.prototype.getObjects$=function(){return this.objects$},t.prototype.removeObject=function(t){var e=this.findFabricObject(t.getId());this.fabricCanvas.remove(e),this.objects$.next(n(this.objects$.value).filter((function(e){return e.getId()!==t.getId()})).value()),this.onObjectListChange()},t.prototype.addImageObject=function(t){var e=this,n=new i.ReplaySubject(1),r=this.dimensions$.value.widthPx/2;return C.fabric.Image.fromURL(t,(function(t){var i=e.randomId(),o=1,s=o*t.width;s>r&&(o=r/s),t.set({id:i,scaleX:o,scaleY:o}),e.fabricCanvas.add(t);var a=new l.Image(e,t);e.trackNewObject(a),e.fabricCanvas.setActiveObject(t),e.syncObjectList(),n.next(a)}),{crossOrigin:"anonymous"}),n},t.prototype.addTextObject=function(){var t=this.profile$.value,e=this.randomId(),n=t.defaultFontSize,r=this.getDimensions().widthPx,o=this.getLowestTextPoint(),s={id:e,top:Math.min(o,this.getDimensions().heightPx-n),left:5,width:r-10,fill:t.defaultFontColor,fontSize:n,fontFamily:t.defaultFont,textAlign:t.defaultTextAlignment,multiLine:!0,lineHeight:t.defaultLineHeight,charSpacing:t.defaultCharacterSpacing},a=new C.fabric.Textbox("Text goes here",s);this.fabricCanvas.add(a);var c=new f.Text(this,a);return this.trackNewObject(c),this.fabricCanvas.setActiveObject(a),this.syncObjectList(),new i.BehaviorSubject(c)},t.prototype.addRectangleObject=function(){var t=this.getDimensions().widthPx,e=this.getDimensions().heightPx,n=t/2,r=e/2,o={id:this.randomId(),width:t/2,height:2,top:e/2-r/2,left:t/2-n/2,fill:"#000000"},s=new C.fabric.Rect(o);this.fabricCanvas.add(s);var a=new u.Rectangle(this,s);return this.trackNewObject(a),this.fabricCanvas.setActiveObject(s),this.syncObjectList(),new i.BehaviorSubject(a)},t.prototype.addCutoffObject=function(){var t=this.profile$.value,e=t.defaultCutoffWidth,n=this.getDimensions().widthPx,r=this.getDimensions().heightPx,o={id:this.randomId(),width:n,height:e,top:r-e,left:0,fill:t.defaultCutoffColor},s=new C.fabric.Rect(o);this.fabricCanvas.add(s);var a=new c.Cutoff(this,s);return this.trackNewObject(a),this.fabricCanvas.setActiveObject(s),this.syncObjectList(),new i.BehaviorSubject(a)},t.prototype.addBorderObject=function(){var t=this.profile$.value,e=t.defaultBorderWidth,n={id:this.randomId(),fill:null,stroke:t.defaultBorderColor,strokeWidth:e},r=new C.fabric.Rect(n);this.fabricCanvas.add(r);var o=new h.Border(this,r);return this.trackNewObject(o),this.fabricCanvas.setActiveObject(r),this.syncObjectList(),new i.BehaviorSubject(o)},t.prototype.addVerticalRuleObject=function(){var t={id:this.randomId(),width:2,height:10,top:0,left:0,fill:"#000000"},e=new C.fabric.Rect(t);this.fabricCanvas.add(e);var n=new y.VerticalRule(this,e);return this.trackNewObject(n),this.fabricCanvas.setActiveObject(e),this.syncObjectList(),new i.BehaviorSubject(n)},t.prototype.addHorizontalRuleObject=function(){var t={id:this.randomId(),width:10,height:2,top:0,left:0,fill:"#000000"},e=new C.fabric.Rect(t);this.fabricCanvas.add(e);var n=new m.HorizontalRule(this,e);return this.trackNewObject(n),this.fabricCanvas.setActiveObject(e),this.syncObjectList(),new i.BehaviorSubject(n)},t.prototype.setPrefillData=function(t){n(this.getObjectsByTypeInternal(_.ObjectType.TEXT)).each((function(e){var i=e.getPrefillType();null!==i&&e.setText(t[i]||"")}))},t.prototype.distributeObjectsVertically=function(){for(var t=this.getMargin(),e=this.getDimensions().heightPx,i=n(this.getObjectsByTypesInternal(_.ObjectType.TEXT,_.ObjectType.IMAGE)).sortBy((function(t){return t.getBoundingBox().top})).value(),r=n.reduce(i,(function(t,e){return t+e.getBoundingBox().height}),0),o=(e-t.top-t.bottom-r)/(i.length-1),s=t.top,a=0,c=i;a<c.length;a++){var u=c[a],h=u.getBoundingBox().height;u.setPosition({top:s}),u.setCoords(),s+=h+o}this.redraw()},t.prototype.getSelection=function(){return this.selection$.value},t.prototype.getSelection$=function(){return this.selection$},t.prototype.select=function(t){var e=this.findObject(t.getId());e?(this.fabricCanvas.setActiveObject(e.getFabricObjectInternal()),this.fabricCanvas.renderAll()):console.error("Attempted to select unknown object",t)},t.prototype.clearSelection=function(){this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll()},t.prototype.setMultiSelect=function(t){this.fabricCanvas.selection=t,this.fabricCanvas.selectionKey=t?"shiftKey":null},t.prototype.clear=function(){this.fabricCanvas.clear(),this.setBackgroundColor("#FFFFFF"),this.objects$.next([])},t.prototype.save=function(){var t=n(this.objects$.value).map((function(t){return t.persist()})).value(),e=this.fabricCanvas.toJSON(["id"]),i={dimensions:this.dimensions$.value,canvasJson:JSON.stringify(e),objects:t,backgroundColor:this.backgroundColor$.value};return console.debug("Saving canvas state",i),i},t.prototype.load=function(t){return o(this,void 0,void 0,(function(){var e,i=this;return s(this,(function(n){switch(n.label){case 0:return console.debug("Loading canvas state",t),this.setBaseDimensions(t.dimensions),null==t.canvasJson?[3,2]:(e=JSON.parse(t.canvasJson),[4,new Promise((function(t){i.fabricCanvas.loadFromJSON(e,(function(){return t()}))}))]);case 1:n.sent(),n.label=2;case 2:return this.setBackgroundColor(t.backgroundColor),this.bindFields(t.objects),this.removePersistedBullets(),this.layoutManager$.value.onInit(),[2]}}))}))},t.prototype.removePersistedBullets=function(){var t=this,e=this.fabricCanvas.getObjects();r.each(e,(function(e){"circle"===e.type&&t.removeFabricObject(e)}))},t.prototype.toSvg=function(){var t=this,e={width:r.round(this.dimensions$.value.widthMm,1)+"mm",height:r.round(this.dimensions$.value.heightMm,1)+"mm",suppressPreamble:!0,encoding:null};return this.executeWithNormalizedCanvas((function(){return t.fabricCanvas.toSVG(e)}))},t.prototype.toImage=function(){var t=this,e={format:"png",multiplier:this.IMAGE_CAPTURE_COEFFICIENT,enableRetinaScaling:!0};console.debug("Capturing canvas image",e);var i=this.executeWithNormalizedCanvas((function(){return t.fabricCanvas.toDataURL(e)}));return n.replace(i,/^data:.*;base64,/,"")},t.prototype.redraw=function(){this.fabricCanvas.renderAll()},t.prototype.syncObjectList=function(){var t=this,e=n(this.fabricCanvas.getObjects()).map((function(e){return t.findObject(e.id)})).filter((function(t){return void 0!==t})).value();this.objects$.next(e),this.onObjectListChange()},t.prototype.onTextChange=function(){this.layoutManager$.value.onTextChange()},t.prototype.onObjectListChange=function(){this.layoutManager$.value.onObjectListChange()},t.prototype.onDimensionsChange=function(){this.layoutManager$.value.onCanvasDimensionsChange()},t.prototype.onMarginChange=function(){this.layoutManager$.value.onMarginChange()},t.prototype.notifyObjectListChanged=function(){this.onObjectListChange()},t.prototype.removeFabricObject=function(t){this.fabricCanvas.remove(t)},t.prototype.bindFields=function(t){var e=this;console.debug("Binding fields",t);var i=n(t).flatMap((function(t){try{return[e.bindField(t)]}catch(e){return console.error("Could not bind field",e,t),[]}})).value();console.debug("Bound fields",i),this.objects$.next(i)},t.prototype.bindField=function(t){console.debug("Binding field",t);var e=this.findFabricObject(t.id);switch(t.type){case _.ObjectType.TEXT:return new f.Text(this,e,t);case _.ObjectType.RECTANGLE:return new u.Rectangle(this,e,t);case _.ObjectType.BORDER:return new h.Border(this,e,t);case _.ObjectType.CUTOFF:return new c.Cutoff(this,e,t);case _.ObjectType.IMAGE:case _.ObjectType.LIBRARY_IMAGE:return new l.Image(this,e,t);case _.ObjectType.HORIZONTAL_RULE:return new m.HorizontalRule(this,e,t);case _.ObjectType.VERTICAL_RULE:return new y.VerticalRule(this,e,t);default:throw new Error("Unknown field type: ["+t.type+"]")}},t.prototype.findFabricObject=function(t){var e=this.fabricCanvas.getObjects(),i=n.find(e,(function(e){return e.id==t}));if(!i)throw new Error("Cannot find fabric object with id ["+t+"]");return i},t.prototype.findObject=function(t){return n.find(this.objects$.value,(function(e){return e.getId()==t}))},t.prototype.executeWithNormalizedCanvas=function(t){var e;this.updateCanvasDimensions(this.dimensions$.value,1);try{e=t()}finally{this.updateCanvasDimensions(this.dimensions$.value,this.zoom$.value)}return e},t.prototype.updateCanvasDimensions=function(t,e){var i=t.widthPx*e,n=t.heightPx*e;console.debug("Updating canvas dimensions: zoom: "+e+", width: "+i+", height: "+n),this.fabricCanvas.setZoom(e),this.fabricCanvas.setDimensions({width:i,height:n})},t.prototype.calculateImageCaptureCoefficient=function(){var t=this.devicePixelRatio||1;return n.round(2/t,3)},t.prototype.onProfileChanged=function(t){this.setMultiSelect(t.allowMultiSelect),this.layoutManager$.value.onProfileChange(t),console.debug("Canvas profile set",t)},t.prototype.onFabricSelectionChanged=function(){var t=this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());console.debug("Selection changed",t),this.selection$.next(new T(t)),this.enterTextSelectionModeIfRequired()},t.prototype.onTextEditing=function(){var t=this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());this.selection$.next(new T(t))},t.prototype.getFieldByCanvasObject=function(t){return t?n.find(this.objects$.value,(function(e){return e.getId()==t.id})):null},t.prototype.getFieldsByCanvasObject=function(t){var e=this;return n(t).map((function(t){return e.getFieldByCanvasObject(t)})).reject((function(t){return!t})).value()},t.prototype.randomId=function(){var t=Math.floor(999*Math.random())+0;return(new Date).getTime()+""+t},t.prototype.getLowestTextPoint=function(){return n(this.objects$.value).filter((function(t){return t.getType()===_.ObjectType.TEXT})).map((function(t){return t.getDimensions().top.px+t.getDimensions().height.px})).reduce((function(t,e){return Math.max(t,e)}),0)},t.prototype.trackNewObject=function(t){this.objects$.next(a(this.objects$.value,[t]))},t.prototype.enterTextSelectionModeIfRequired=function(){(this.profile$.value.enterTextEditImmediatelyOnSelect||this.layoutManager$.value.enterTextEditImmediatelyOnSelect)&&(this.selection$.value&&this.selection$.value.objects[0]&&this.selection$.value.objects[0].getType()===_.ObjectType.TEXT&&this.selection$.value.objects[0].enterEditing())},t.prototype.dimensionsExceedRestrictions=function(t){var e=this.dimensionRestrictions$.value;return null!=v.oc(e).height.min()&&t.height<v.oc(e).height.min()||null!=v.oc(e).height.max()&&t.height>v.oc(e).height.max()||null!=v.oc(e).width.min()&&t.width<v.oc(e).width.min()||null!=v.oc(e).width.max()&&t.width>v.oc(e).width.max()||null!=v.oc(e).volume.min()&&t.height*t.width<v.oc(e).volume.min()||null!=v.oc(e).volume.max()&&t.height*t.width>v.oc(e).volume.max()},t}();e.InteractiveCanvas=S;var T=function(t){this.objects=t,this.empty=this.objects.length<1;var e=this.objects[0];this.isText=e&&e.getType()===_.ObjectType.TEXT&&e.isEditing()}}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)}])}));
|
|
33
|
+
var n=i(47),r=i(48),o=i(49);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,i){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,i);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(this,t)}return u(this,t,e,i)}function u(t,e,i,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,i,n){if(e.byteLength,i<0||e.byteLength<i)throw new RangeError("'offset' is out of bounds");if(e.byteLength<i+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===i&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,i):new Uint8Array(e,i,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=f(t,e);return t}(t,e,i,n):"string"==typeof e?function(t,e,i){"string"==typeof i&&""!==i||(i="utf8");if(!c.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(e,i),r=(t=a(t,n)).write(e,i);r!==n&&(t=t.slice(0,r));return t}(t,e,i):function(t,e){if(c.isBuffer(e)){var i=0|d(e.length);return 0===(t=a(t,i)).length||e.copy(t,0,0,i),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):f(t,e);if("Buffer"===e.type&&o(e.data))return f(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function l(t,e){if(h(e),t=a(t,e<0?0:0|d(e)),!c.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function f(t,e){var i=e.length<0?0:0|d(e.length);t=a(t,i);for(var n=0;n<i;n+=1)t[n]=255&e[n];return t}function d(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return Y(t).length;default:if(n)return U(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,i){var 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 E(this,e,i);case"utf8":case"utf-8":return O(this,e,i);case"ascii":return j(this,e,i);case"latin1":case"binary":return P(this,e,i);case"base64":return T(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,i){var 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),i=+i,isNaN(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=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var o,s=1,a=t.length,c=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;s=2,a/=2,c/=2,i/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(r){var h=-1;for(o=i;o<a;o++)if(u(t,o)===u(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===c)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(i+c>a&&(i=a-c),o=i;o>=0;o--){for(var l=!0,f=0;f<c;f++)if(u(t,o+f)!==u(e,f)){l=!1;break}if(l)return o}return-1}function b(t,e,i,n){i=Number(i)||0;var r=t.length-i;n?(n=Number(n))>r&&(n=r):n=r;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[i+s]=a}return s}function _(t,e,i,n){return N(U(e,t.length-i),t,i,n)}function x(t,e,i,n){return N(function(t){for(var e=[],i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}(e),t,i,n)}function w(t,e,i,n){return x(t,e,i,n)}function C(t,e,i,n){return N(Y(e),t,i,n)}function S(t,e,i,n){return N(function(t,e){for(var i,n,r,o=[],s=0;s<t.length&&!((e-=2)<0);++s)i=t.charCodeAt(s),n=i>>8,r=i%256,o.push(r),o.push(n);return o}(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 O(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r<i;){var o,s,a,c,u=t[r],h=null,l=u>239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(o=t[r+1]))&&(c=(31&u)<<6|63&o)>127&&(h=c);break;case 3:o=t[r+1],s=t[r+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:o=t[r+1],s=t[r+2],a=t[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),r+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return i}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,i){return u(null,t,e,i)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,i){return function(t,e,i,n){return h(e),e<=0?a(t,e):void 0!==i?"string"==typeof n?a(t,e).fill(i,n):a(t,e).fill(i):a(t,e)}(null,t,e,i)},c.allocUnsafe=function(t){return l(null,t)},c.allocUnsafeSlow=function(t){return l(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var i=t.length,n=e.length,r=0,o=Math.min(i,n);r<o;++r)if(t[r]!==e[r]){i=t[r],n=e[r];break}return i<n?-1:n<i?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var i;if(void 0===e)for(e=0,i=0;i<t.length;++i)e+=t[i].length;var n=c.allocUnsafe(e),r=0;for(i=0;i<t.length;++i){var s=t[i];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,r),r+=s.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)v(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,i,n,r){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");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;for(var o=(r>>>=0)-(n>>>=0),s=(i>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(n,r),h=t.slice(e,i),l=0;l<a;++l)if(u[l]!==h[l]){o=u[l],s=h[l];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},c.prototype.indexOf=function(t,e,i){return y(this,t,e,i,!0)},c.prototype.lastIndexOf=function(t,e,i){return y(this,t,e,i,!1)},c.prototype.write=function(t,e,i,n){if(void 0===e)n="utf8",i=this.length,e=0;else if(void 0===i&&"string"==typeof e)n=e,i=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(i)?(i|=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}var 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");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,i);case"utf8":case"utf-8":return _(this,t,e,i);case"ascii":return x(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return C(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function j(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;r<i;++r)n+=String.fromCharCode(127&t[r]);return n}function P(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;r<i;++r)n+=String.fromCharCode(t[r]);return n}function E(t,e,i){var n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);for(var r="",o=e;o<i;++o)r+=W(t[o]);return r}function k(t,e,i){for(var n=t.slice(e,i),r="",o=0;o<n.length;o+=2)r+=String.fromCharCode(n[o]+256*n[o+1]);return r}function A(t,e,i){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>i)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,i,n,r,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<o)throw new RangeError('"value" argument is out of bounds');if(i+n>t.length)throw new RangeError("Index out of range")}function M(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,o=Math.min(t.length-i,2);r<o;++r)t[i+r]=(e&255<<8*(n?r:1-r))>>>8*(n?r:1-r)}function I(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,o=Math.min(t.length-i,4);r<o;++r)t[i+r]=e>>>8*(n?r:3-r)&255}function F(t,e,i,n,r,o){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,o){return o||F(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,o){return o||F(t,0,i,8),r.write(t,e,i,n,52,8),i+8}c.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(i=this.subarray(t,e)).__proto__=c.prototype;else{var r=e-t;i=new c(r,void 0);for(var o=0;o<r;++o)i[o]=this[o+t]}return i},c.prototype.readUIntLE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t],r=1,o=0;++o<e&&(r*=256);)n+=this[t+o]*r;return n},c.prototype.readUIntBE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t+--e],r=1;e>0&&(r*=256);)n+=this[t+--e]*r;return n},c.prototype.readUInt8=function(t,e){return e||A(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||A(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||A(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t],r=1,o=0;++o<e&&(r*=256);)n+=this[t+o]*r;return n>=(r*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=e,r=1,o=this[t+--n];n>0&&(r*=256);)o+=this[t+--n]*r;return o>=(r*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||A(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||A(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(t,e){e||A(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(t,e){return e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||A(t,4,this.length),r.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||A(t,4,this.length),r.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||A(t,8,this.length),r.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||A(t,8,this.length),r.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||D(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,o=0;for(this[e]=255&t;++o<i&&(r*=256);)this[e+o]=t/r&255;return e+i},c.prototype.writeUIntBE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||D(this,t,e,i,Math.pow(2,8*i)-1,0);var r=i-1,o=1;for(this[e+r]=255&t;--r>=0&&(o*=256);)this[e+r]=t/o&255;return e+i},c.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):I(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);D(this,t,e,i,r-1,-r)}var o=0,s=1,a=0;for(this[e]=255&t;++o<i&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+i},c.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);D(this,t,e,i,r-1,-r)}var o=i-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+i},c.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):I(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,i){return R(this,t,e,!0,i)},c.prototype.writeFloatBE=function(t,e,i){return R(this,t,e,!1,i)},c.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},c.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},c.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-i&&(n=t.length-e+i);var r,o=n-i;if(this===t&&i<e&&e<n)for(r=o-1;r>=0;--r)t[r+e]=this[r+i];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(r=0;r<o;++r)t[r+e]=this[r+i];else Uint8Array.prototype.set.call(t,this.subarray(i,i+o),e);return o},c.prototype.fill=function(t,e,i,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),1===t.length){var r=t.charCodeAt(0);r<256&&(t=r)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;var o;if(e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(o=e;o<i;++o)this[o]=t;else{var s=c.isBuffer(t)?t:U(new c(t,n).toString()),a=s.length;for(o=0;o<i-e;++o)this[o+e]=s[o%a]}return this};var B=/[^+\/0-9A-Za-z-_]/g;function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function U(t,e){var i;e=e||1/0;for(var n=t.length,r=null,o=[],s=0;s<n;++s){if((i=t.charCodeAt(s))>55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&o.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&o.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;o.push(i)}else if(i<2048){if((e-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;o.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;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function Y(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(B,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,i,n){for(var r=0;r<n&&!(r+i>=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),s=n[0],a=n[1],c=new o(function(t,e,i){return 3*(e+i)/4-i}(0,s,a)),h=0,l=a>0?s-4:s;for(i=0;i<l;i+=4)e=r[t.charCodeAt(i)]<<18|r[t.charCodeAt(i+1)]<<12|r[t.charCodeAt(i+2)]<<6|r[t.charCodeAt(i+3)],c[h++]=e>>16&255,c[h++]=e>>8&255,c[h++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,c[h++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,c[h++]=e>>8&255,c[h++]=255&e);return c},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,o=[],s=0,a=i-r;s<a;s+=16383)o.push(h(t,s,s+16383>a?a:s+16383));1===r?(e=t[i-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)n[a]=s[a],r[s.charCodeAt(a)]=a;function u(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,i){for(var r,o,s=[],a=e;a<i;a+=3)r=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=r)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,c=(1<<a)-1,u=c>>1,h=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+t[e+l],l+=f,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=f,h-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,i,n,r,o){var s,a,c,u=8*o-r-1,h=(1<<u)-1,l=h>>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-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,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*c-1)*Math.pow(2,r),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),s=0));r>=8;t[i+d]=255&a,d+=p,a/=256,r-=8);for(s=s<<r|a,u+=r;u>0;t[i+d]=255&s,d+=p,s/=256,u-=8);t[i+d-p]|=128*g}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){},function(t,e){},function(t,e){},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ImageType=void 0,function(t){t.DEFAULT="DEFAULT",t.BACKGROUND="BACKGROUND",t.LOGO="LOGO",t.PHOTO="PHOTO"}(e.ImageType||(e.ImageType={}))}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r,o=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},a=this&&this.__spreadArrays||function(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n};n=[i,e,i(3),i(1),i(1),i(19),i(22),i(18),i(21),i(23),i(12),i(4),i(16),i(6),i(25),i(20),i(9),i(29),i(26),i(7),i(24)],void 0===(r=function(t,e,i,n,r,c,u,h,l,f,d,p,g,v,y,m,b,_,x,w,C){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InteractiveCanvas=void 0;var S=function(){function t(t,e){var n=this;this.devicePixelRatio=e,this.fontLibrary=new b.FontLibrary,this.dimensionChangeRejections$=new i.Subject,this.IMAGE_CAPTURE_COEFFICIENT=this.calculateImageCaptureCoefficient(),this.fabricCanvas=new C.fabric.Canvas(t),this.baseDimensions=new w.PixelCanvasDimensions(this.fabricCanvas.width,this.fabricCanvas.height);this.dimensions$=new i.BehaviorSubject(this.baseDimensions),this.dimensionRestrictions$=new i.BehaviorSubject({width:{min:1},height:{min:1}}),this.zoom$=new i.BehaviorSubject(1),this.profile$=new i.BehaviorSubject(new x.DefaultCanvasProfile),this.layoutManager$=new i.BehaviorSubject(new d.AdvancedLayoutManager(this)),this.backgroundColor$=new i.BehaviorSubject(this.fabricCanvas.backgroundColor),this.objects$=new i.BehaviorSubject([]),this.selection$=new i.BehaviorSubject(new T([])),this.fabricCanvas.on("selection:updated",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("selection:created",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("selection:cleared",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("text:editing:entered",(function(){return n.onTextEditing()})),this.fabricCanvas.on("text:editing:exited",(function(){return n.onTextEditing()})),this.fabricCanvas.on("text:changed",(function(){return n.onTextChange()})),this.fabricCanvas.stateful=!0,this.fabricCanvas.preserveObjectStacking=!0,this.fabricCanvas.perPixelTargetFind=!0,this.fabricCanvas.targetFindTolerance=10,this.setBackgroundColor("#FFFFFF")}return t.prototype.getFontLibrary=function(){return this.fontLibrary},t.prototype.getProfile=function(){return this.profile$.value},t.prototype.getProfile$=function(){return this.profile$},t.prototype.setProfile=function(t){this.profile$.next(t),this.onProfileChanged(t),this.redraw()},t.prototype.getLayoutManager=function(){return this.layoutManager$.value},t.prototype.getLayoutManager$=function(){return this.layoutManager$},t.prototype.setLayoutManager=function(t){t===p.LayoutManager.STANDARD?this.layoutManager$.next(new g.StandardLayoutManager(this)):this.layoutManager$.next(new d.AdvancedLayoutManager(this)),this.layoutManager$.value.onInit()},t.prototype.getBackgroundColor=function(){return this.backgroundColor$.value},t.prototype.getBackgroundColor$=function(){return this.backgroundColor$},t.prototype.setBackgroundColor=function(t){void 0===t&&(t="White"),this.fabricCanvas.setBackgroundColor(t,(function(){})),this.fabricCanvas.renderAll(),this.backgroundColor$.next(t)},t.prototype.getDimensions=function(){return this.dimensions$.value},t.prototype.getBaseDimensions=function(){return this.baseDimensions},t.prototype.getDimensions$=function(){return this.dimensions$},t.prototype.setDimensions=function(t){if(this.dimensionsExceedRestrictions(t))return console.debug("Requested canvas dimensions exceed current restrictions",t,this.dimensionRestrictions$.value),void this.dimensionChangeRejections$.next(t);this.updateCanvasDimensions(t,this.zoom$.value),this.dimensions$.next(t),this.onDimensionsChange(),this.notifyObjectListChanged()},t.prototype.setBaseDimensions=function(t){this.baseDimensions=t,this.setDimensions(t),this.notifyObjectListChanged()},t.prototype.getDimensionChangeRejections$=function(){return this.dimensionChangeRejections$},t.prototype.getDimensionsRestrictions=function(){return this.dimensionRestrictions$.value},t.prototype.getDimensionsRestrictions$=function(){return this.dimensionRestrictions$},t.prototype.setDimensionRestrictions=function(t){this.dimensionRestrictions$.next(t)},t.prototype.getMargin=function(){var t=this.getObjectsByTypeInternal(_.ObjectType.BORDER).map((function(t){return t.getStrokeWidth()})).reduce((function(t,e){return Math.max(t,e)}),0),e=this.getObjectsByTypeInternal(_.ObjectType.CUTOFF).map((function(t){return t.getStrokeWidth()})).reduce((function(t,e){return Math.max(t,e)}),0);return{top:t,right:t,bottom:Math.max(e,t),left:t}},t.prototype.getZoom=function(){return this.zoom$.value},t.prototype.getZoom$=function(){return this.zoom$},t.prototype.setZoom=function(t){this.updateCanvasDimensions(this.dimensions$.value,t),this.zoom$.next(t)},t.prototype.getObjects=function(){return this.objects$.value},t.prototype.getObjectsInternal=function(){return this.objects$.value},t.prototype.getObjectsByTypeInternal=function(t){return n(this.getObjectsInternal()).filter((function(e){return e.getType()===t})).value()},t.prototype.getObjectsByTypesInternal=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this.getObjectsInternal()).filter((function(e){return n(t).includes(e.getType())})).value()},t.prototype.getObjects$=function(){return this.objects$},t.prototype.removeObject=function(t){var e=this.findFabricObject(t.getId());this.fabricCanvas.remove(e),this.objects$.next(n(this.objects$.value).filter((function(e){return e.getId()!==t.getId()})).value()),this.onObjectListChange()},t.prototype.addImageObject=function(t){return o(this,void 0,void 0,(function(){var e,i,n=this;return s(this,(function(r){switch(r.label){case 0:return 2,e=this.dimensions$.value.widthPx/2,i={crossOrigin:"anonymous"},[4,new Promise((function(r){C.fabric.Image.fromURL(t,(function(t){var i=n.randomId(),o=1,s=o*t.width;s>e&&(o=e/s),t.set({id:i,scaleX:o,scaleY:o}),n.fabricCanvas.add(t);var a=new l.Image(n,t);n.trackNewObject(a),n.fabricCanvas.setActiveObject(t),n.syncObjectList(),r(a)}),i)}))];case 1:return[2,r.sent()]}}))}))},t.prototype.addTextObject=function(){return o(this,void 0,void 0,(function(){var t,e,i,n,r,o,a,c,u;return s(this,(function(s){return t=this.profile$.value,e=this.randomId(),i=t.defaultFontSize,n=this.getDimensions().widthPx,r=this.getLowestTextPoint(),o=Math.min(r,this.getDimensions().heightPx-i),a={id:e,top:o,left:5,width:n-10,fill:t.defaultFontColor,fontSize:i,fontFamily:t.defaultFont,textAlign:t.defaultTextAlignment,multiLine:!0,lineHeight:t.defaultLineHeight,charSpacing:t.defaultCharacterSpacing},c=new C.fabric.Textbox("Text goes here",a),this.fabricCanvas.add(c),u=new f.Text(this,c),this.trackNewObject(u),this.fabricCanvas.setActiveObject(c),this.syncObjectList(),[2,u]}))}))},t.prototype.addRectangleObject=function(){return o(this,void 0,void 0,(function(){var t,e,i,n,r,o,a;return s(this,(function(s){return t=this.getDimensions().widthPx,e=this.getDimensions().heightPx,i=t/2,n=e/2,r={id:this.randomId(),width:t/2,height:2,top:e/2-n/2,left:t/2-i/2,fill:"#000000"},o=new C.fabric.Rect(r),this.fabricCanvas.add(o),a=new u.Rectangle(this,o),this.trackNewObject(a),this.fabricCanvas.setActiveObject(o),this.syncObjectList(),[2,a]}))}))},t.prototype.addCutoffObject=function(){return o(this,void 0,void 0,(function(){var t,e,i,n,r,o,a;return s(this,(function(s){return t=this.profile$.value,e=t.defaultCutoffWidth,i=this.getDimensions().widthPx,n=this.getDimensions().heightPx,r={id:this.randomId(),width:i,height:e,top:n-e,left:0,fill:t.defaultCutoffColor},o=new C.fabric.Rect(r),this.fabricCanvas.add(o),a=new c.Cutoff(this,o),this.trackNewObject(a),this.fabricCanvas.setActiveObject(o),this.syncObjectList(),[2,a]}))}))},t.prototype.addBorderObject=function(){return o(this,void 0,void 0,(function(){var t,e,i,n,r;return s(this,(function(o){return t=this.profile$.value,e=t.defaultBorderWidth,i={id:this.randomId(),fill:null,stroke:t.defaultBorderColor,strokeWidth:e},n=new C.fabric.Rect(i),this.fabricCanvas.add(n),r=new h.Border(this,n),this.trackNewObject(r),this.fabricCanvas.setActiveObject(n),this.syncObjectList(),[2,r]}))}))},t.prototype.addVerticalRuleObject=function(){return o(this,void 0,void 0,(function(){var t,e,i;return s(this,(function(n){return t={id:this.randomId(),width:2,height:10,top:0,left:0,fill:"#000000"},e=new C.fabric.Rect(t),this.fabricCanvas.add(e),i=new y.VerticalRule(this,e),this.trackNewObject(i),this.fabricCanvas.setActiveObject(e),this.syncObjectList(),[2,i]}))}))},t.prototype.addHorizontalRuleObject=function(){return o(this,void 0,void 0,(function(){var t,e,i;return s(this,(function(n){return t={id:this.randomId(),width:10,height:2,top:0,left:0,fill:"#000000"},e=new C.fabric.Rect(t),this.fabricCanvas.add(e),i=new m.HorizontalRule(this,e),this.trackNewObject(i),this.fabricCanvas.setActiveObject(e),this.syncObjectList(),[2,i]}))}))},t.prototype.setPrefillData=function(t){n(this.getObjectsByTypeInternal(_.ObjectType.TEXT)).each((function(e){var i=e.getPrefillType();null!==i&&e.setText(t[i]||"")}))},t.prototype.distributeObjectsVertically=function(){for(var t=this.getMargin(),e=this.getDimensions().heightPx,i=n(this.getObjectsByTypesInternal(_.ObjectType.TEXT,_.ObjectType.IMAGE)).sortBy((function(t){return t.getBoundingBox().top})).value(),r=n.reduce(i,(function(t,e){return t+e.getBoundingBox().height}),0),o=(e-t.top-t.bottom-r)/(i.length-1),s=t.top,a=0,c=i;a<c.length;a++){var u=c[a],h=u.getBoundingBox().height;u.setPosition({top:s}),u.setCoords(),s+=h+o}this.redraw()},t.prototype.getSelection=function(){return this.selection$.value},t.prototype.getSelection$=function(){return this.selection$},t.prototype.select=function(t){var e=this.findObject(t.getId());e?(this.fabricCanvas.setActiveObject(e.getFabricObjectInternal()),this.fabricCanvas.renderAll()):console.error("Attempted to select unknown object",t)},t.prototype.clearSelection=function(){this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll()},t.prototype.setMultiSelect=function(t){this.fabricCanvas.selection=t,this.fabricCanvas.selectionKey=t?"shiftKey":null},t.prototype.clear=function(){this.fabricCanvas.clear(),this.setBackgroundColor("#FFFFFF"),this.objects$.next([])},t.prototype.save=function(){var t=n(this.objects$.value).map((function(t){return t.persist()})).value(),e=this.fabricCanvas.toJSON(["id"]),i={dimensions:this.dimensions$.value,canvasJson:JSON.stringify(e),objects:t,backgroundColor:this.backgroundColor$.value};return console.debug("Saving canvas state",i),i},t.prototype.load=function(t){return o(this,void 0,void 0,(function(){var e,i=this;return s(this,(function(n){switch(n.label){case 0:return console.debug("Loading canvas state",t),this.setBaseDimensions(t.dimensions),null==t.canvasJson?[3,2]:(e=JSON.parse(t.canvasJson),[4,new Promise((function(t){i.fabricCanvas.loadFromJSON(e,(function(){return t()}))}))]);case 1:n.sent(),n.label=2;case 2:return this.setBackgroundColor(t.backgroundColor),this.bindFields(t.objects),this.removePersistedBullets(),this.layoutManager$.value.onInit(),[2]}}))}))},t.prototype.removePersistedBullets=function(){var t=this,e=this.fabricCanvas.getObjects();r.each(e,(function(e){"circle"===e.type&&t.removeFabricObject(e)}))},t.prototype.toSvg=function(){var t=this,e={width:r.round(this.dimensions$.value.widthMm,1)+"mm",height:r.round(this.dimensions$.value.heightMm,1)+"mm",suppressPreamble:!0,encoding:null};return this.executeWithNormalizedCanvas((function(){return t.fabricCanvas.toSVG(e)}))},t.prototype.toImage=function(){var t=this,e={format:"png",multiplier:this.IMAGE_CAPTURE_COEFFICIENT,enableRetinaScaling:!0};console.debug("Capturing canvas image",e);var i=this.executeWithNormalizedCanvas((function(){return t.fabricCanvas.toDataURL(e)}));return n.replace(i,/^data:.*;base64,/,"")},t.prototype.redraw=function(){this.fabricCanvas.renderAll()},t.prototype.syncObjectList=function(){var t=this,e=n(this.fabricCanvas.getObjects()).map((function(e){return t.findObject(e.id)})).filter((function(t){return void 0!==t})).value();this.objects$.next(e),this.onObjectListChange()},t.prototype.onTextChange=function(){this.layoutManager$.value.onTextChange()},t.prototype.onObjectListChange=function(){this.layoutManager$.value.onObjectListChange()},t.prototype.onDimensionsChange=function(){this.layoutManager$.value.onCanvasDimensionsChange()},t.prototype.onMarginChange=function(){this.layoutManager$.value.onMarginChange()},t.prototype.notifyObjectListChanged=function(){this.onObjectListChange()},t.prototype.removeFabricObject=function(t){this.fabricCanvas.remove(t)},t.prototype.bindFields=function(t){var e=this;console.debug("Binding fields",t);var i=n(t).flatMap((function(t){try{return[e.bindField(t)]}catch(e){return console.error("Could not bind field",e,t),[]}})).value();console.debug("Bound fields",i),this.objects$.next(i)},t.prototype.bindField=function(t){console.debug("Binding field",t);var e=this.findFabricObject(t.id);switch(t.type){case _.ObjectType.TEXT:return new f.Text(this,e,t);case _.ObjectType.RECTANGLE:return new u.Rectangle(this,e,t);case _.ObjectType.BORDER:return new h.Border(this,e,t);case _.ObjectType.CUTOFF:return new c.Cutoff(this,e,t);case _.ObjectType.IMAGE:case _.ObjectType.LIBRARY_IMAGE:return new l.Image(this,e,t);case _.ObjectType.HORIZONTAL_RULE:return new m.HorizontalRule(this,e,t);case _.ObjectType.VERTICAL_RULE:return new y.VerticalRule(this,e,t);default:throw new Error("Unknown field type: ["+t.type+"]")}},t.prototype.findFabricObject=function(t){var e=this.fabricCanvas.getObjects(),i=n.find(e,(function(e){return e.id==t}));if(!i)throw new Error("Cannot find fabric object with id ["+t+"]");return i},t.prototype.findObject=function(t){return n.find(this.objects$.value,(function(e){return e.getId()==t}))},t.prototype.executeWithNormalizedCanvas=function(t){var e;this.updateCanvasDimensions(this.dimensions$.value,1);try{e=t()}finally{this.updateCanvasDimensions(this.dimensions$.value,this.zoom$.value)}return e},t.prototype.updateCanvasDimensions=function(t,e){var i=t.widthPx*e,n=t.heightPx*e;console.debug("Updating canvas dimensions: zoom: "+e+", width: "+i+", height: "+n),this.fabricCanvas.setZoom(e),this.fabricCanvas.setDimensions({width:i,height:n})},t.prototype.calculateImageCaptureCoefficient=function(){var t=this.devicePixelRatio||1;return n.round(2/t,3)},t.prototype.onProfileChanged=function(t){this.setMultiSelect(t.allowMultiSelect),this.layoutManager$.value.onProfileChange(t),console.debug("Canvas profile set",t)},t.prototype.onFabricSelectionChanged=function(){var t=this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());console.debug("Selection changed",t),this.selection$.next(new T(t)),this.enterTextSelectionModeIfRequired()},t.prototype.onTextEditing=function(){var t=this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());this.selection$.next(new T(t))},t.prototype.getFieldByCanvasObject=function(t){return t?n.find(this.objects$.value,(function(e){return e.getId()==t.id})):null},t.prototype.getFieldsByCanvasObject=function(t){var e=this;return n(t).map((function(t){return e.getFieldByCanvasObject(t)})).reject((function(t){return!t})).value()},t.prototype.randomId=function(){var t=Math.floor(999*Math.random())+0;return(new Date).getTime()+""+t},t.prototype.getLowestTextPoint=function(){return n(this.objects$.value).filter((function(t){return t.getType()===_.ObjectType.TEXT})).map((function(t){return t.getDimensions().top.px+t.getDimensions().height.px})).reduce((function(t,e){return Math.max(t,e)}),0)},t.prototype.trackNewObject=function(t){this.objects$.next(a(this.objects$.value,[t]))},t.prototype.enterTextSelectionModeIfRequired=function(){(this.profile$.value.enterTextEditImmediatelyOnSelect||this.layoutManager$.value.enterTextEditImmediatelyOnSelect)&&(this.selection$.value&&this.selection$.value.objects[0]&&this.selection$.value.objects[0].getType()===_.ObjectType.TEXT&&this.selection$.value.objects[0].enterEditing())},t.prototype.dimensionsExceedRestrictions=function(t){var e=this.dimensionRestrictions$.value;return null!=v.oc(e).height.min()&&t.height<v.oc(e).height.min()||null!=v.oc(e).height.max()&&t.height>v.oc(e).height.max()||null!=v.oc(e).width.min()&&t.width<v.oc(e).width.min()||null!=v.oc(e).width.max()&&t.width>v.oc(e).width.max()||null!=v.oc(e).volume.min()&&t.height*t.width<v.oc(e).volume.min()||null!=v.oc(e).volume.max()&&t.height*t.width>v.oc(e).volume.max()},t}();e.InteractiveCanvas=S;var T=function(t){this.objects=t,this.empty=this.objects.length<1;var e=this.objects[0];this.isText=e&&e.getType()===_.ObjectType.TEXT&&e.isEditing()}}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)}])}));
|
|
34
34
|
//# sourceMappingURL=interactive-canvas.js.map
|