// source --> https://itbac.eu/wp-content/plugins/learnpress-certificates/assets/dist/js/frontend/certificates-new.min.js?ver=4.2.1 
(()=>{var t,e,r,i,n={6320(t){"use strict";var e={single_source_shortest_paths:function(t,r,i){var n={},s={};s[r]=0;var o,a,h,l,c,u,f,d=e.PriorityQueue.make();for(d.push(r,0);!d.empty();)for(h in a=(o=d.pop()).value,l=o.cost,c=t[a]||{})c.hasOwnProperty(h)&&(u=l+c[h],f=s[h],(void 0===s[h]||f>u)&&(s[h]=u,d.push(h,u),n[h]=a));if(void 0!==i&&void 0===s[i]){var p=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(p)}return n},extract_shortest_path_from_predecessor_list:function(t,e){for(var r=[],i=e;i;)r.push(i),t[i],i=t[i];return r.reverse(),r},find_path:function(t,r,i){var n=e.single_source_shortest_paths(t,r,i);return e.extract_shortest_path_from_predecessor_list(n,i)},PriorityQueue:{make:function(t){var r,i=e.PriorityQueue,n={};for(r in t=t||{},i)i.hasOwnProperty(r)&&(n[r]=i[r]);return n.queue=[],n.sorter=t.sorter||i.default_sorter,n},default_sorter:function(t,e){return t.cost-e.cost},push:function(t,e){var r={value:t,cost:e};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};t.exports=e},7583(t,e,r){const i=r(1333),n=r(157),s=r(7899),o=r(6756);function a(t,e,r,s,o){const a=[].slice.call(arguments,1),h=a.length,l="function"==typeof a[h-1];if(!l&&!i())throw new Error("Callback required as last argument");if(!l){if(h<1)throw new Error("Too few arguments provided");return 1===h?(r=e,e=s=void 0):2!==h||e.getContext||(s=r,r=e,e=void 0),new Promise(function(i,o){try{const o=n.create(r,s);i(t(o,e,s))}catch(t){o(t)}})}if(h<2)throw new Error("Too few arguments provided");2===h?(o=r,r=e,e=s=void 0):3===h&&(e.getContext&&void 0===o?(o=s,s=void 0):(o=s,s=r,r=e,e=void 0));try{const i=n.create(r,s);o(null,t(i,e,s))}catch(t){o(t)}}e.create=n.create,e.toCanvas=a.bind(null,s.render),e.toDataURL=a.bind(null,s.renderToDataURL),e.toString=a.bind(null,function(t,e,r){return o.render(t,r)})},1333(t){t.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}},6421(t,e,r){const i=r(6886).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const e=Math.floor(t/7)+2,r=i(t),n=145===r?26:2*Math.ceil((r-13)/(2*e-2)),s=[r-7];for(let t=1;t<e-1;t++)s[t]=s[t-1]-n;return s.push(6),s.reverse()},e.getPositions=function(t){const r=[],i=e.getRowColCoords(t),n=i.length;for(let t=0;t<n;t++)for(let e=0;e<n;e++)0===t&&0===e||0===t&&e===n-1||t===n-1&&0===e||r.push([i[t],i[e]]);return r}},1433(t,e,r){const i=r(208),n=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function s(t){this.mode=i.ALPHANUMERIC,this.data=t}s.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let r=45*n.indexOf(this.data[e]);r+=n.indexOf(this.data[e+1]),t.put(r,11)}this.data.length%2&&t.put(n.indexOf(this.data[e]),6)},t.exports=s},9899(t){function e(){this.buffer=[],this.length=0}e.prototype={get:function(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(let r=0;r<e;r++)this.putBit(1==(t>>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=e},8820(t){function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}e.prototype.set=function(t,e,r,i){const n=t*this.size+e;this.data[n]=r,i&&(this.reservedBit[n]=!0)},e.prototype.get=function(t,e){return this.data[t*this.size+e]},e.prototype.xor=function(t,e,r){this.data[t*this.size+e]^=r},e.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]},t.exports=e},5822(t,e,r){const i=r(208);function n(t){this.mode=i.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let e=0,r=this.data.length;e<r;e++)t.put(this.data[e],8)},t.exports=n},7518(t,e,r){const i=r(9953),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],s=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(t,e){switch(e){case i.L:return n[4*(t-1)+0];case i.M:return n[4*(t-1)+1];case i.Q:return n[4*(t-1)+2];case i.H:return n[4*(t-1)+3];default:return}},e.getTotalCodewordsCount=function(t,e){switch(e){case i.L:return s[4*(t-1)+0];case i.M:return s[4*(t-1)+1];case i.Q:return s[4*(t-1)+2];case i.H:return s[4*(t-1)+3];default:return}}},9953(t,e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2},e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},e.from=function(t,r){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch(t){return r}}},7756(t,e,r){const i=r(6886).getSymbolSize;e.getPositions=function(t){const e=i(t);return[[0,0],[e-7,0],[0,e-7]]}},4565(t,e,r){const i=r(6886),n=i.getBCHDigit(1335);e.getEncodedBits=function(t,e){const r=t.bit<<3|e;let s=r<<10;for(;i.getBCHDigit(s)-n>=0;)s^=1335<<i.getBCHDigit(s)-n;return 21522^(r<<10|s)}},2731(t,e){const r=new Uint8Array(512),i=new Uint8Array(256);!function(){let t=1;for(let e=0;e<255;e++)r[e]=t,i[t]=e,t<<=1,256&t&&(t^=285);for(let t=255;t<512;t++)r[t]=r[t-255]}(),e.log=function(t){if(t<1)throw new Error("log("+t+")");return i[t]},e.exp=function(t){return r[t]},e.mul=function(t,e){return 0===t||0===e?0:r[i[t]+i[e]]}},4861(t,e,r){const i=r(208),n=r(6886);function s(t){this.mode=i.KANJI,this.data=t}s.getBitsLength=function(t){return 13*t},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let r=n.toSJIS(this.data[e]);if(r>=33088&&r<=40956)r-=33088;else{if(!(r>=57408&&r<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");r-=49472}r=192*(r>>>8&255)+(255&r),t.put(r,13)}},t.exports=s},1332(t,e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};function r(t,r,i){switch(t){case e.Patterns.PATTERN000:return(r+i)%2==0;case e.Patterns.PATTERN001:return r%2==0;case e.Patterns.PATTERN010:return i%3==0;case e.Patterns.PATTERN011:return(r+i)%3==0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(i/3))%2==0;case e.Patterns.PATTERN101:return r*i%2+r*i%3==0;case e.Patterns.PATTERN110:return(r*i%2+r*i%3)%2==0;case e.Patterns.PATTERN111:return(r*i%3+(r+i)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(t){const e=t.size;let r=0,i=0,n=0,s=null,o=null;for(let a=0;a<e;a++){i=n=0,s=o=null;for(let h=0;h<e;h++){let e=t.get(a,h);e===s?i++:(i>=5&&(r+=i-5+3),s=e,i=1),e=t.get(h,a),e===o?n++:(n>=5&&(r+=n-5+3),o=e,n=1)}i>=5&&(r+=i-5+3),n>=5&&(r+=n-5+3)}return r},e.getPenaltyN2=function(t){const e=t.size;let r=0;for(let i=0;i<e-1;i++)for(let n=0;n<e-1;n++){const e=t.get(i,n)+t.get(i,n+1)+t.get(i+1,n)+t.get(i+1,n+1);4!==e&&0!==e||r++}return 3*r},e.getPenaltyN3=function(t){const e=t.size;let r=0,i=0,n=0;for(let s=0;s<e;s++){i=n=0;for(let o=0;o<e;o++)i=i<<1&2047|t.get(s,o),o>=10&&(1488===i||93===i)&&r++,n=n<<1&2047|t.get(o,s),o>=10&&(1488===n||93===n)&&r++}return 40*r},e.getPenaltyN4=function(t){let e=0;const r=t.data.length;for(let i=0;i<r;i++)e+=t.data[i];return 10*Math.abs(Math.ceil(100*e/r/5)-10)},e.applyMask=function(t,e){const i=e.size;for(let n=0;n<i;n++)for(let s=0;s<i;s++)e.isReserved(s,n)||e.xor(s,n,r(t,s,n))},e.getBestMask=function(t,r){const i=Object.keys(e.Patterns).length;let n=0,s=1/0;for(let o=0;o<i;o++){r(o),e.applyMask(o,t);const i=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),i<s&&(s=i,n=o)}return n}},208(t,e,r){const i=r(1878),n=r(7044);e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(t,e){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!i.isValid(e))throw new Error("Invalid version: "+e);return e>=1&&e<10?t.ccBits[0]:e<27?t.ccBits[1]:t.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},e.isValid=function(t){return t&&t.bit&&t.ccBits},e.from=function(t,r){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(t){return r}}},4357(t,e,r){const i=r(208);function n(t){this.mode=i.NUMERIC,this.data=t.toString()}n.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){let e,r,i;for(e=0;e+3<=this.data.length;e+=3)r=this.data.substr(e,3),i=parseInt(r,10),t.put(i,10);const n=this.data.length-e;n>0&&(r=this.data.substr(e),i=parseInt(r,10),t.put(i,3*n+1))},t.exports=n},4713(t,e,r){const i=r(2731);e.mul=function(t,e){const r=new Uint8Array(t.length+e.length-1);for(let n=0;n<t.length;n++)for(let s=0;s<e.length;s++)r[n+s]^=i.mul(t[n],e[s]);return r},e.mod=function(t,e){let r=new Uint8Array(t);for(;r.length-e.length>=0;){const t=r[0];for(let n=0;n<e.length;n++)r[n]^=i.mul(e[n],t);let n=0;for(;n<r.length&&0===r[n];)n++;r=r.slice(n)}return r},e.generateECPolynomial=function(t){let r=new Uint8Array([1]);for(let n=0;n<t;n++)r=e.mul(r,new Uint8Array([1,i.exp(n)]));return r}},157(t,e,r){const i=r(6886),n=r(9953),s=r(9899),o=r(8820),a=r(6421),h=r(7756),l=r(1332),c=r(7518),u=r(4764),f=r(1427),d=r(4565),p=r(208),g=r(9801);function m(t,e,r){const i=t.size,n=d.getEncodedBits(e,r);let s,o;for(s=0;s<15;s++)o=1==(n>>s&1),s<6?t.set(s,8,o,!0):s<8?t.set(s+1,8,o,!0):t.set(i-15+s,8,o,!0),s<8?t.set(8,i-s-1,o,!0):s<9?t.set(8,15-s-1+1,o,!0):t.set(8,15-s-1,o,!0);t.set(i-8,8,1,!0)}function v(t,e,r,n){let d;if(Array.isArray(t))d=g.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");{let i=e;if(!i){const e=g.rawSplit(t);i=f.getBestVersionForData(e,r)}d=g.fromString(t,i||40)}}const v=f.getBestVersionForData(d,r);if(!v)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<v)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+v+".\n")}else e=v;const y=function(t,e,r){const n=new s;r.forEach(function(e){n.put(e.mode.bit,4),n.put(e.getLength(),p.getCharCountIndicator(e.mode,t)),e.write(n)});const o=8*(i.getSymbolTotalCodewords(t)-c.getTotalCodewordsCount(t,e));for(n.getLengthInBits()+4<=o&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(0);const a=(o-n.getLengthInBits())/8;for(let t=0;t<a;t++)n.put(t%2?17:236,8);return function(t,e,r){const n=i.getSymbolTotalCodewords(e),s=n-c.getTotalCodewordsCount(e,r),o=c.getBlocksCount(e,r),a=o-n%o,h=Math.floor(n/o),l=Math.floor(s/o),f=l+1,d=h-l,p=new u(d);let g=0;const m=new Array(o),v=new Array(o);let y=0;const b=new Uint8Array(t.buffer);for(let t=0;t<o;t++){const e=t<a?l:f;m[t]=b.slice(g,g+e),v[t]=p.encode(m[t]),g+=e,y=Math.max(y,e)}const w=new Uint8Array(n);let _,x,S=0;for(_=0;_<y;_++)for(x=0;x<o;x++)_<m[x].length&&(w[S++]=m[x][_]);for(_=0;_<d;_++)for(x=0;x<o;x++)w[S++]=v[x][_];return w}(n,t,e)}(e,r,d),b=i.getSymbolSize(e),w=new o(b);return function(t,e){const r=t.size,i=h.getPositions(e);for(let e=0;e<i.length;e++){const n=i[e][0],s=i[e][1];for(let e=-1;e<=7;e++)if(!(n+e<=-1||r<=n+e))for(let i=-1;i<=7;i++)s+i<=-1||r<=s+i||(e>=0&&e<=6&&(0===i||6===i)||i>=0&&i<=6&&(0===e||6===e)||e>=2&&e<=4&&i>=2&&i<=4?t.set(n+e,s+i,!0,!0):t.set(n+e,s+i,!1,!0))}}(w,e),function(t){const e=t.size;for(let r=8;r<e-8;r++){const e=r%2==0;t.set(r,6,e,!0),t.set(6,r,e,!0)}}(w),function(t,e){const r=a.getPositions(e);for(let e=0;e<r.length;e++){const i=r[e][0],n=r[e][1];for(let e=-2;e<=2;e++)for(let r=-2;r<=2;r++)-2===e||2===e||-2===r||2===r||0===e&&0===r?t.set(i+e,n+r,!0,!0):t.set(i+e,n+r,!1,!0)}}(w,e),m(w,r,0),e>=7&&function(t,e){const r=t.size,i=f.getEncodedBits(e);let n,s,o;for(let e=0;e<18;e++)n=Math.floor(e/3),s=e%3+r-8-3,o=1==(i>>e&1),t.set(n,s,o,!0),t.set(s,n,o,!0)}(w,e),function(t,e){const r=t.size;let i=-1,n=r-1,s=7,o=0;for(let a=r-1;a>0;a-=2)for(6===a&&a--;;){for(let r=0;r<2;r++)if(!t.isReserved(n,a-r)){let i=!1;o<e.length&&(i=1==(e[o]>>>s&1)),t.set(n,a-r,i),s--,-1===s&&(o++,s=7)}if(n+=i,n<0||r<=n){n-=i,i=-i;break}}}(w,y),isNaN(n)&&(n=l.getBestMask(w,m.bind(null,w,r))),l.applyMask(n,w),m(w,r,n),{modules:w,version:e,errorCorrectionLevel:r,maskPattern:n,segments:d}}e.create=function(t,e){if(void 0===t||""===t)throw new Error("No input text");let r,s,o=n.M;return void 0!==e&&(o=n.from(e.errorCorrectionLevel,n.M),r=f.from(e.version),s=l.from(e.maskPattern),e.toSJISFunc&&i.setToSJISFunction(e.toSJISFunc)),v(t,r,o,s)}},4764(t,e,r){const i=r(4713);function n(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}n.prototype.initialize=function(t){this.degree=t,this.genPoly=i.generateECPolynomial(this.degree)},n.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const r=i.mod(e,this.genPoly),n=this.degree-r.length;if(n>0){const t=new Uint8Array(this.degree);return t.set(r,n),t}return r},t.exports=n},7044(t,e){const r="[0-9]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+")(?:.|[\r\n]))+";e.KANJI=new RegExp(i,"g"),e.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),e.BYTE=new RegExp(n,"g"),e.NUMERIC=new RegExp(r,"g"),e.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const s=new RegExp("^"+i+"$"),o=new RegExp("^"+r+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");e.testKanji=function(t){return s.test(t)},e.testNumeric=function(t){return o.test(t)},e.testAlphanumeric=function(t){return a.test(t)}},9801(t,e,r){const i=r(208),n=r(4357),s=r(1433),o=r(5822),a=r(4861),h=r(7044),l=r(6886),c=r(6320);function u(t){return unescape(encodeURIComponent(t)).length}function f(t,e,r){const i=[];let n;for(;null!==(n=t.exec(r));)i.push({data:n[0],index:n.index,mode:e,length:n[0].length});return i}function d(t){const e=f(h.NUMERIC,i.NUMERIC,t),r=f(h.ALPHANUMERIC,i.ALPHANUMERIC,t);let n,s;return l.isKanjiModeEnabled()?(n=f(h.BYTE,i.BYTE,t),s=f(h.KANJI,i.KANJI,t)):(n=f(h.BYTE_KANJI,i.BYTE,t),s=[]),e.concat(r,n,s).sort(function(t,e){return t.index-e.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function p(t,e){switch(e){case i.NUMERIC:return n.getBitsLength(t);case i.ALPHANUMERIC:return s.getBitsLength(t);case i.KANJI:return a.getBitsLength(t);case i.BYTE:return o.getBitsLength(t)}}function g(t,e){let r;const h=i.getBestModeForData(t);if(r=i.from(e,h),r!==i.BYTE&&r.bit<h.bit)throw new Error('"'+t+'" cannot be encoded with mode '+i.toString(r)+".\n Suggested mode is: "+i.toString(h));switch(r!==i.KANJI||l.isKanjiModeEnabled()||(r=i.BYTE),r){case i.NUMERIC:return new n(t);case i.ALPHANUMERIC:return new s(t);case i.KANJI:return new a(t);case i.BYTE:return new o(t)}}e.fromArray=function(t){return t.reduce(function(t,e){return"string"==typeof e?t.push(g(e,null)):e.data&&t.push(g(e.data,e.mode)),t},[])},e.fromString=function(t,r){const n=function(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];switch(n.mode){case i.NUMERIC:e.push([n,{data:n.data,mode:i.ALPHANUMERIC,length:n.length},{data:n.data,mode:i.BYTE,length:n.length}]);break;case i.ALPHANUMERIC:e.push([n,{data:n.data,mode:i.BYTE,length:n.length}]);break;case i.KANJI:e.push([n,{data:n.data,mode:i.BYTE,length:u(n.data)}]);break;case i.BYTE:e.push([{data:n.data,mode:i.BYTE,length:u(n.data)}])}}return e}(d(t,l.isKanjiModeEnabled())),s=function(t,e){const r={},n={start:{}};let s=["start"];for(let o=0;o<t.length;o++){const a=t[o],h=[];for(let t=0;t<a.length;t++){const l=a[t],c=""+o+t;h.push(c),r[c]={node:l,lastCount:0},n[c]={};for(let t=0;t<s.length;t++){const o=s[t];r[o]&&r[o].node.mode===l.mode?(n[o][c]=p(r[o].lastCount+l.length,l.mode)-p(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),n[o][c]=p(l.length,l.mode)+4+i.getCharCountIndicator(l.mode,e))}}s=h}for(let t=0;t<s.length;t++)n[s[t]].end=0;return{map:n,table:r}}(n,r),o=c.find_path(s.map,"start","end"),a=[];for(let t=1;t<o.length-1;t++)a.push(s.table[o[t]].node);return e.fromArray(a.reduce(function(t,e){const r=t.length-1>=0?t[t.length-1]:null;return r&&r.mode===e.mode?(t[t.length-1].data+=e.data,t):(t.push(e),t)},[]))},e.rawSplit=function(t){return e.fromArray(d(t,l.isKanjiModeEnabled()))}},6886(t,e){let r;const i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},e.getSymbolTotalCodewords=function(t){return i[t]},e.getBCHDigit=function(t){let e=0;for(;0!==t;)e++,t>>>=1;return e},e.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');r=t},e.isKanjiModeEnabled=function(){return void 0!==r},e.toSJIS=function(t){return r(t)}},1878(t,e){e.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}},1427(t,e,r){const i=r(6886),n=r(7518),s=r(9953),o=r(208),a=r(1878),h=i.getBCHDigit(7973);function l(t,e){return o.getCharCountIndicator(t,e)+4}function c(t,e){let r=0;return t.forEach(function(t){const i=l(t.mode,e);r+=i+t.getBitsLength()}),r}e.from=function(t,e){return a.isValid(t)?parseInt(t,10):e},e.getCapacity=function(t,e,r){if(!a.isValid(t))throw new Error("Invalid QR Code version");void 0===r&&(r=o.BYTE);const s=8*(i.getSymbolTotalCodewords(t)-n.getTotalCodewordsCount(t,e));if(r===o.MIXED)return s;const h=s-l(r,t);switch(r){case o.NUMERIC:return Math.floor(h/10*3);case o.ALPHANUMERIC:return Math.floor(h/11*2);case o.KANJI:return Math.floor(h/13);case o.BYTE:default:return Math.floor(h/8)}},e.getBestVersionForData=function(t,r){let i;const n=s.from(r,s.M);if(Array.isArray(t)){if(t.length>1)return function(t,r){for(let i=1;i<=40;i++)if(c(t,i)<=e.getCapacity(i,r,o.MIXED))return i}(t,n);if(0===t.length)return 1;i=t[0]}else i=t;return function(t,r,i){for(let n=1;n<=40;n++)if(r<=e.getCapacity(n,i,t))return n}(i.mode,i.getLength(),n)},e.getEncodedBits=function(t){if(!a.isValid(t)||t<7)throw new Error("Invalid QR Code version");let e=t<<12;for(;i.getBCHDigit(e)-h>=0;)e^=7973<<i.getBCHDigit(e)-h;return t<<12|e}},7899(t,e,r){const i=r(2726);e.render=function(t,e,r){let n=r,s=e;void 0!==n||e&&e.getContext||(n=e,e=void 0),e||(s=function(){try{return document.createElement("canvas")}catch(t){throw new Error("You need to specify a canvas element")}}()),n=i.getOptions(n);const o=i.getImageWidth(t.modules.size,n),a=s.getContext("2d"),h=a.createImageData(o,o);return i.qrToImageData(h.data,t,n),function(t,e,r){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=r,e.width=r,e.style.height=r+"px",e.style.width=r+"px"}(a,s,o),a.putImageData(h,0,0),s},e.renderToDataURL=function(t,r,i){let n=i;void 0!==n||r&&r.getContext||(n=r,r=void 0),n||(n={});const s=e.render(t,r,n),o=n.type||"image/png",a=n.rendererOpts||{};return s.toDataURL(o,a.quality)}},6756(t,e,r){const i=r(2726);function n(t,e){const r=t.a/255,i=e+'="'+t.hex+'"';return r<1?i+" "+e+'-opacity="'+r.toFixed(2).slice(1)+'"':i}function s(t,e,r){let i=t+e;return void 0!==r&&(i+=" "+r),i}e.render=function(t,e,r){const o=i.getOptions(e),a=t.modules.size,h=t.modules.data,l=a+2*o.margin,c=o.color.light.a?"<path "+n(o.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",u="<path "+n(o.color.dark,"stroke")+' d="'+function(t,e,r){let i="",n=0,o=!1,a=0;for(let h=0;h<t.length;h++){const l=Math.floor(h%e),c=Math.floor(h/e);l||o||(o=!0),t[h]?(a++,h>0&&l>0&&t[h-1]||(i+=o?s("M",l+r,.5+c+r):s("m",n,0),n=0,o=!1),l+1<e&&t[h+1]||(i+=s("h",a),a=0)):n++}return i}(h,a,o.margin)+'"/>',f='viewBox="0 0 '+l+" "+l+'"',d='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+f+' shape-rendering="crispEdges">'+c+u+"</svg>\n";return"function"==typeof r&&r(null,d),d}},2726(t,e){function r(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");let e=t.slice().replace("#","").split("");if(e.length<3||5===e.length||e.length>8)throw new Error("Invalid hex color: "+t);3!==e.length&&4!==e.length||(e=Array.prototype.concat.apply([],e.map(function(t){return[t,t]}))),6===e.length&&e.push("F","F");const r=parseInt(e.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:255&r,hex:"#"+e.slice(0,6).join("")}}e.getOptions=function(t){t||(t={}),t.color||(t.color={});const e=void 0===t.margin||null===t.margin||t.margin<0?4:t.margin,i=t.width&&t.width>=21?t.width:void 0,n=t.scale||4;return{width:i,scale:i?4:n,margin:e,color:{dark:r(t.color.dark||"#000000ff"),light:r(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},e.getScale=function(t,e){return e.width&&e.width>=t+2*e.margin?e.width/(t+2*e.margin):e.scale},e.getImageWidth=function(t,r){const i=e.getScale(t,r);return Math.floor((t+2*r.margin)*i)},e.qrToImageData=function(t,r,i){const n=r.modules.size,s=r.modules.data,o=e.getScale(n,i),a=Math.floor((n+2*i.margin)*o),h=i.margin*o,l=[i.color.light,i.color.dark];for(let e=0;e<a;e++)for(let r=0;r<a;r++){let c=4*(e*a+r),u=i.color.light;e>=h&&r>=h&&e<a-h&&r<a-h&&(u=l[s[Math.floor((e-h)/o)*n+Math.floor((r-h)/o)]?1:0]),t[c++]=u.r,t[c++]=u.g,t[c++]=u.b,t[c]=u.a}}},2284(t,e,r){"use strict";function i(t){return 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},i(t)}r.d(e,{A:()=>i})}},s={};function o(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return n[t].call(r.exports,r,r.exports,o),r.exports}o.m=n,e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,o.t=function(r,i){if(1&i&&(r=this(r)),8&i)return r;if("object"==typeof r&&r){if(4&i&&r.__esModule)return r;if(16&i&&"function"==typeof r.then)return r}var n=Object.create(null);o.r(n);var s={};t=t||[null,e({}),e([]),e(e)];for(var a=2&i&&r;("object"==typeof a||"function"==typeof a)&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach(t=>s[t]=()=>r[t]);return s.default=()=>r,o.d(n,s),n},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=t=>Promise.all(Object.keys(o.f).reduce((e,r)=>(o.f[r](t,e),e),[])),o.u=t=>t+".min.js",o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r={},i="learnpress-certificates:",o.l=(t,e,n,s)=>{if(r[t])r[t].push(e);else{var a,h;if(void 0!==n)for(var l=document.getElementsByTagName("script"),c=0;c<l.length;c++){var u=l[c];if(u.getAttribute("src")==t||u.getAttribute("data-webpack")==i+n){a=u;break}}a||(h=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",i+n),a.src=t),r[t]=[e];var f=(e,i)=>{a.onerror=a.onload=null,clearTimeout(d);var n=r[t];if(delete r[t],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach(t=>t(i)),e)return e(i)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=f.bind(null,a.onerror),a.onload=f.bind(null,a.onload),h&&document.head.appendChild(a)}},o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;globalThis.importScripts&&(t=globalThis.location+"");var e=globalThis.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=r[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t+"../"})(),(()=>{var t={304:0};o.f.j=(e,r)=>{var i=o.o(t,e)?t[e]:void 0;if(0!==i)if(i)r.push(i[2]);else{var n=new Promise((r,n)=>i=t[e]=[r,n]);r.push(i[2]=n);var s=o.p+o.u(e),a=new Error;o.l(s,r=>{if(o.o(t,e)&&(0!==(i=t[e])&&(t[e]=void 0),i)){var n=r&&("load"===r.type?"missing":r.type),s=r&&r.target&&r.target.src;a.message="Loading chunk "+e+" failed.\n("+n+": "+s+")",a.name="ChunkLoadError",a.type=n,a.request=s,i[1](a)}},"chunk-"+e,e)}};var e=(e,r)=>{var i,n,[s,a,h]=r,l=0;if(s.some(e=>0!==t[e])){for(i in a)o.o(a,i)&&(o.m[i]=a[i]);h&&h(o)}for(e&&e(r);l<s.length;l++)n=s[l],o.o(t,n)&&t[n]&&t[n][0](),t[n]=0},r=globalThis.webpackChunklearnpress_certificates=globalThis.webpackChunklearnpress_certificates||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))})(),(()=>{"use strict";function t(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class e{constructor(){t(this,"browserShadowBlurConstant",1),t(this,"DPI",96),t(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),t(this,"perfLimitSizeTotal",2097152),t(this,"maxCacheSideLimit",4096),t(this,"minCacheSideLimit",256),t(this,"disableStyleCopyPaste",!1),t(this,"enableGLFiltering",!0),t(this,"textureSize",4096),t(this,"forceGLPutImageData",!1),t(this,"cachesBoundsOfCurve",!1),t(this,"fontPaths",{}),t(this,"NUM_FRACTION_DIGITS",4)}}const r=new class extends e{constructor(t){super(),this.configure(t)}configure(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,t)}addFonts(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.fontPaths={...this.fontPaths,...t}}removeFonts(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(t=>{delete this.fontPaths[t]})}clearFonts(){this.fontPaths={}}restoreDefaults(t){const r=new e,i=(null==t?void 0:t.reduce((t,e)=>(t[e]=r[e],t),{}))||r;this.configure(i)}},i=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return console[t]("fabric",...r)};class n extends Error{constructor(t,e){super(`fabric: ${t}`,e)}}class s extends n{constructor(t){super(`${t} 'options.signal' is in 'aborted' state`)}}class a{}class h extends a{testPrecision(t,e){const r=`precision ${e} float;\nvoid main(){}`,i=t.createShader(t.FRAGMENT_SHADER);return!!i&&(t.shaderSource(i,r),t.compileShader(i),!!t.getShaderParameter(i,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(t=>this.testPrecision(e,t)),e.getExtension("WEBGL_lose_context").loseContext(),i("log",`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const l={};let c;const u=()=>c||(c={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new h,dispose(){},copyPasteData:l}),f=()=>u().document,d=()=>u().window,p=()=>{var t;return Math.max(null!==(t=r.devicePixelRatio)&&void 0!==t?t:d().devicePixelRatio,1)},g=new class{constructor(){t(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(t){let{fontFamily:e,fontStyle:r,fontWeight:i}=t;e=e.toLowerCase();const n=this.charWidthsCache;n.has(e)||n.set(e,new Map);const s=n.get(e),o=`${r.toLowerCase()}_${(i+"").toLowerCase()}`;return s.has(o)||s.set(o,new Map),s.get(o)}clearFontCache(t){t?this.charWidthsCache.delete((t||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(t){const{perfLimitSizeTotal:e}=r,i=Math.sqrt(e*t);return[Math.floor(i),Math.floor(e/i)]}},m="7.2.0";function v(){}const y=Math.PI/2,b=Math.PI/4,w=2*Math.PI,_=Math.PI/180,x=Object.freeze([1,0,0,1,0,0]),S=16,C=.4477152502,A="center",k="left",L="top",T="bottom",P="right",N="none",O=/\r?\n/,E="moving",M="scaling",D="rotating",F="rotate",j="skewing",I="resizing",B="modifyPoly",R="modifyPath",z="changed",U="scale",q="scaleX",W="scaleY",H="skewX",V="skewY",Y="fill",X="stroke",G="modified",$="ltr",K="rtl",J="normal",Z="json",Q="svg",tt=new class{constructor(){this[Z]=new Map,this[Q]=new Map}has(t){return this[Z].has(t)}getClass(t){const e=this[Z].get(t);if(!e)throw new n(`No class registered for ${t}`);return e}setClass(t,e){e?this[Z].set(e,t):(this[Z].set(t.type,t),this[Z].set(t.type.toLowerCase(),t))}getSVGClass(t){return this[Q].get(t)}setSVGClass(t,e){this[Q].set(null!=e?e:t.type.toLowerCase(),t)}},et=new class extends Array{remove(t){const e=this.indexOf(t);e>-1&&this.splice(e,1)}cancelAll(){const t=this.splice(0);return t.forEach(t=>t.abort()),t}cancelByCanvas(t){if(!t)return[];const e=this.filter(e=>{var r;return e.target===t||"object"==typeof e.target&&(null===(r=e.target)||void 0===r?void 0:r.canvas)===t});return e.forEach(t=>t.abort()),e}cancelByTarget(t){if(!t)return[];const e=this.filter(e=>e.target===t);return e.forEach(t=>t.abort()),e}};class rt{constructor(){t(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),"object"==typeof t)return Object.entries(t).forEach(t=>{let[e,r]=t;this.on(e,r)}),()=>this.off(t);if(e){const r=t;return this.__eventListeners[r]||(this.__eventListeners[r]=[]),this.__eventListeners[r].push(e),()=>this.off(r,e)}return()=>!1}once(t,e){if("object"==typeof t){const e=[];return Object.entries(t).forEach(t=>{let[r,i]=t;e.push(this.once(r,i))}),()=>e.forEach(t=>t())}if(e){const r=this.on(t,function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];e.call(this,...i),r()});return r}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const r=this.__eventListeners[t],i=r.indexOf(e);i>-1&&r.splice(i,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(void 0===t)for(const t in this.__eventListeners)this._removeEventListener(t);else"object"==typeof t?Object.entries(t).forEach(t=>{let[e,r]=t;this._removeEventListener(e,r)}):this._removeEventListener(t,e)}fire(t,e){var r;if(!this.__eventListeners)return;const i=null===(r=this.__eventListeners[t])||void 0===r?void 0:r.concat();if(i)for(let t=0;t<i.length;t++)i[t].call(this,e||{})}}const it=(t,e)=>{const r=t.indexOf(e);return-1!==r&&t.splice(r,1),t},nt=t=>{if(0===t)return 1;switch(Math.abs(t)/y){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},st=t=>{if(0===t)return 0;const e=t/y,r=Math.sign(t);switch(e){case 1:return r;case 2:return 0;case 3:return-r}return Math.sin(t)};class ot{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new ot(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new ot(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new ot(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new ot(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new ot(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new ot(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new ot(this.x/t.x,this.y/t.y)}scalarDivide(t){return new ot(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new ot(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)}midPointFrom(t){return this.lerp(t)}min(t){return new ot(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new ot(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return`${this.x},${this.y}`}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,r=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=r}clone(){return new ot(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:at;const r=st(t),i=nt(t),n=this.subtract(e);return new ot(n.x*i-n.y*r,n.x*r+n.y*i).add(e)}transform(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new ot(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const at=new ot(0,0),ht=t=>!!t&&Array.isArray(t._objects);function lt(e){class r extends e{constructor(){super(...arguments),t(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const i=this._objects.push(...e);return e.forEach(t=>this._onObjectAdded(t)),i}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return this._objects.splice(t,0,...r),r.forEach(t=>this._onObjectAdded(t)),this._objects.length}remove(){const t=this._objects,e=[];for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return i.forEach(r=>{const i=t.indexOf(r);-1!==i&&(t.splice(i,1),e.push(r),this._onObjectRemoved(r))}),e}forEachObject(t){this.getObjects().forEach((e,r,i)=>t(e,r,i))}getObjects(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return 0===e.length?[...this._objects]:this._objects.filter(t=>t.isType(...e))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,e){return!!this._objects.includes(t)||!!e&&this._objects.some(e=>e instanceof r&&e.contains(t,!0))}complexity(){return this._objects.reduce((t,e)=>t+(e.complexity?e.complexity():0),0)}sendObjectToBack(t){return!(!t||t===this._objects[0]||(it(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),0))}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1]||(it(this._objects,t),this._objects.push(t),this._onStackOrderChanged(t),0))}sendObjectBackwards(t,e){if(!t)return!1;const r=this._objects.indexOf(t);if(0!==r){const i=this.findNewLowerIndex(t,r,e);return it(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}bringObjectForward(t,e){if(!t)return!1;const r=this._objects.indexOf(t);if(r!==this._objects.length-1){const i=this.findNewUpperIndex(t,r,e);return it(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(it(this._objects,t),this._objects.splice(e,0,t),this._onStackOrderChanged(t),!0)}findNewLowerIndex(t,e,r){let i;if(r){i=e;for(let r=e-1;r>=0;--r)if(t.isOverlapping(this._objects[r])){i=r;break}}else i=e-1;return i}findNewUpperIndex(t,e,r){let i;if(r){i=e;for(let r=e+1;r<this._objects.length;++r)if(t.isOverlapping(this._objects[r])){i=r;break}}else i=e+1;return i}collectObjects(t){let{left:e,top:r,width:i,height:n}=t,{includeIntersecting:s=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=[],a=new ot(e,r),h=a.add(new ot(i,n));for(let t=this._objects.length-1;t>=0;t--){const e=this._objects[t];e.selectable&&e.visible&&(s&&e.intersectsWithRect(a,h)||e.isContainedWithinRect(a,h)||s&&e.containsPoint(a)||s&&e.containsPoint(h))&&o.push(e)}return o}}return r}class ct extends rt{_setOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this}get(t){return this[t]}}function ut(t){return d().requestAnimationFrame(t)}function ft(t){return d().cancelAnimationFrame(t)}let dt=0;const pt=()=>dt++,gt=()=>{const t=f().createElement("canvas");if(!t||void 0===t.getContext)throw new n("Failed to create `canvas` element");return t},mt=()=>f().createElement("img"),vt=t=>{const e=gt();return e.width=t.width,e.height=t.height,e},yt=(t,e,r)=>t.toDataURL(`image/${e}`,r),bt=(t,e,r)=>new Promise((i,n)=>{t.toBlob(i,`image/${e}`,r)}),wt=t=>t*_,_t=t=>t/_,xt=t=>t.every((t,e)=>t===x[e]),St=(t,e,r)=>new ot(t).transform(e,r),Ct=t=>{const e=1/(t[0]*t[3]-t[1]*t[2]),r=[e*t[3],-e*t[1],-e*t[2],e*t[0],0,0],{x:i,y:n}=new ot(t[4],t[5]).transform(r,!0);return r[4]=-i,r[5]=-n,r},At=(t,e,r)=>[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],r?0:t[0]*e[4]+t[2]*e[5]+t[4],r?0:t[1]*e[4]+t[3]*e[5]+t[5]],kt=(t,e)=>t.reduceRight((t,r)=>r&&t?At(r,t,e):r||t,void 0)||x.concat(),Lt=t=>{let[e,r]=t;return Math.atan2(r,e)},Tt=t=>{const e=Lt(t),r=Math.pow(t[0],2)+Math.pow(t[1],2),i=Math.sqrt(r),n=(t[0]*t[3]-t[2]*t[1])/i,s=Math.atan2(t[0]*t[2]+t[1]*t[3],r);return{angle:_t(e),scaleX:i,scaleY:n,skewX:_t(s),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},Pt=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function Nt(){let{angle:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{x:e=0,y:r=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=wt(t),n=nt(i),s=st(i);return[n,s,-s,n,e?e-(n*e-s*r):0,r?r-(s*e+n*r):0]}const Ot=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},Et=t=>Math.tan(wt(t)),Mt=t=>[1,0,Et(t),1,0,0],Dt=t=>[1,Et(t),0,1,0,0],Ft=t=>{let{scaleX:e=1,scaleY:r=1,flipX:i=!1,flipY:n=!1,skewX:s=0,skewY:o=0}=t,a=Ot(i?-e:e,n?-r:r);return s&&(a=At(a,Mt(s),!0)),o&&(a=At(a,Dt(o),!0)),a},jt=t=>{const{translateX:e=0,translateY:r=0,angle:i=0}=t;let n=Pt(e,r);i&&(n=At(n,Nt({angle:i})));const s=Ft(t);return xt(s)||(n=At(n,s)),n},It=function(t){let{signal:e,crossOrigin:r=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(i,o){if(e&&e.aborted)return o(new s("loadImage"));const a=mt();let h;e&&(h=function(t){a.src="",o(t)},e.addEventListener("abort",h,{once:!0}));const l=function(){a.onload=a.onerror=null,h&&(null==e||e.removeEventListener("abort",h)),i(a)};t?(a.onload=l,a.onerror=function(){h&&(null==e||e.removeEventListener("abort",h)),o(new n(`Error loading ${a.src}`))},r&&(a.crossOrigin=r),a.src=t):l()})},Bt=function(t){let{signal:e,reviver:r=v}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((i,n)=>{const s=[];e&&e.addEventListener("abort",n,{once:!0}),Promise.all(t.map(t=>tt.getClass(t.type).fromObject(t,{signal:e}).then(e=>(r(t,e),s.push(e),e)))).then(i).catch(t=>{s.forEach(t=>{t.dispose&&t.dispose()}),n(t)}).finally(()=>{e&&e.removeEventListener("abort",n)})})},Rt=function(t){let{signal:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((r,i)=>{const n=[];e&&e.addEventListener("abort",i,{once:!0});const s=Object.values(t).map(t=>t&&t.type&&tt.has(t.type)?Bt([t],{signal:e}).then(t=>{let[e]=t;return n.push(e),e}):t),o=Object.keys(t);Promise.all(s).then(t=>t.reduce((t,e,r)=>(t[o[r]]=e,t),{})).then(r).catch(t=>{n.forEach(t=>{t.dispose&&t.dispose()}),i(t)}).finally(()=>{e&&e.removeEventListener("abort",i)})})},zt=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce((e,r)=>(r in t&&(e[r]=t[r]),e),{})},Ut=(t,e)=>Object.keys(t).reduce((r,i)=>(e(t[i],i,t)&&(r[i]=t[i]),r),{}),qt=(t,e)=>parseFloat(Number(t).toFixed(e)),Wt=t=>"matrix("+t.map(t=>qt(t,r.NUM_FRACTION_DIGITS)).join(" ")+")",Ht=t=>!!t&&void 0!==t.toLive,Vt=t=>!!t&&"function"==typeof t.toObject,Yt=t=>!!t&&void 0!==t.offsetX&&"source"in t,Xt=t=>!!t&&"multiSelectionStacking"in t;function Gt(t){const e=t&&$t(t);let r=0,i=0;if(!t||!e)return{left:r,top:i};let n=t;const s=e.documentElement,o=e.body||{scrollLeft:0,scrollTop:0};for(;n&&(n.parentNode||n.host)&&(n=n.parentNode||n.host,n===e?(r=o.scrollLeft||s.scrollLeft||0,i=o.scrollTop||s.scrollTop||0):(r+=n.scrollLeft||0,i+=n.scrollTop||0),1!==n.nodeType||"fixed"!==n.style.position););return{left:r,top:i}}const $t=t=>t.ownerDocument||null,Kt=t=>{var e;return(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||null},Jt=function(t,e,r){let{width:i,height:n}=r,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;t.width=i,t.height=n,s>1&&(t.setAttribute("width",(i*s).toString()),t.setAttribute("height",(n*s).toString()),e.scale(s,s))},Zt=(t,e)=>{let{width:r,height:i}=e;r&&(t.style.width="number"==typeof r?`${r}px`:r),i&&(t.style.height="number"==typeof i?`${i}px`:i)};function Qt(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=N,t}class te{constructor(e){t(this,"_originalCanvasStyle",void 0),t(this,"lower",void 0);const r=this.createLowerCanvas(e);this.lower={el:r,ctx:r.getContext("2d")}}createLowerCanvas(t){const e=(r=t)&&void 0!==r.getContext?t:t&&f().getElementById(t)||gt();var r;if(e.hasAttribute("data-fabric"))throw new n("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:r}=t;const{el:i}=this.lower;i.classList.remove("lower-canvas"),i.removeAttribute("data-fabric"),i.setAttribute("width",`${e}`),i.setAttribute("height",`${r}`),i.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:r,ctx:i}=this.lower;Jt(r,i,t,e)}setCSSDimensions(t){Zt(this.lower.el,t)}calcOffset(){return function(t){var e;const r=t&&$t(t),i={left:0,top:0};if(!r)return i;const n=(null===(e=Kt(t))||void 0===e?void 0:e.getComputedStyle(t,null))||{};i.left+=parseInt(n.borderLeftWidth,10)||0,i.top+=parseInt(n.borderTopWidth,10)||0,i.left+=parseInt(n.paddingLeft,10)||0,i.top+=parseInt(n.paddingTop,10)||0;let s={left:0,top:0};const o=r.documentElement;void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect());const a=Gt(t);return{left:s.left+a.left-(o.clientLeft||0)+i.left,top:s.top+a.top-(o.clientTop||0)+i.top}}(this.lower.el)}dispose(){u().dispose(this.lower.el),delete this.lower}}const ee={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...x],patternQuality:"best"},re=t=>t.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let ie;const ne=t=>{if(ie||ie||(ie="Intl"in d()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),ie){const e=ie.segment(t);return Array.from(e).map(t=>{let{segment:e}=t;return e})}return se(t)},se=t=>{const e=[];for(let r,i=0;i<t.length;i++)!1!==(r=oe(t,i))&&e.push(r);return e},oe=(t,e)=>{const r=t.charCodeAt(e);if(isNaN(r))return"";if(r<55296||r>57343)return t.charAt(e);if(55296<=r&&r<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";const r=t.charCodeAt(e+1);if(56320>r||r>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";const i=t.charCodeAt(e-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1};var ae=Object.freeze({__proto__:null,capitalize:function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return`${t.charAt(0).toUpperCase()}${e?t.slice(1):t.slice(1).toLowerCase()}`},escapeXml:re,graphemeSplit:ne});class he extends(lt(ct)){get lowerCanvasEl(){var t;return null===(t=this.elements.lower)||void 0===t?void 0:t.el}get contextContainer(){var t;return null===(t=this.elements.lower)||void 0===t?void 0:t.ctx}static getDefaults(){return he.ownDefaults}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new te(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];const n=super.insertAt(t,...r);return r.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(i("warn","Canvas is trying to add an object that belongs to a different canvas.\nResulting to default behavior: removing object from previous canvas and adding to new canvas"),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?p():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:r=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e){const e={width:this.width,height:this.height,...t};this.elements.setDimensions(e,this.getRetinaScaling()),this.hasLostContext=!0,this.width=e.width,this.height=e.height}r||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const r=t,i=[...this.viewportTransform],n=St(t,Ct(i));i[0]=e,i[3]=e;const s=St(n,i);i[4]+=r.x-s.x,i[5]+=r.y-s.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new ot(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new ot(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=ut(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,r=Ct(this.viewportTransform),i=St({x:0,y:0},r),n=St({x:t,y:e},r),s=i.min(n),o=i.max(n);return this.vptCoords={tl:s,tr:new ot(o.x,s.y),bl:new ot(s.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(ft(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const r=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality=this.patternQuality,this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const r=this.viewportTransform;t.save(),t.transform(...r),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let r=0,i=e.length;r<i;++r)e[r]&&e[r].render(t)}_renderBackgroundOrOverlay(t,e){const r=this[`${e}Color`],i=this[`${e}Image`],n=this.viewportTransform,s=this[`${e}Vpt`];if(!r&&!i)return;const o=Ht(r);if(r){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=o?r.toLive(t):r,s&&t.transform(...n),o){t.transform(1,0,0,1,r.offsetX||0,r.offsetY||0);const e=r.gradientTransform||r.patternTransform;e&&t.transform(...e)}t.fill(),t.restore()}if(i){t.save();const{skipOffscreen:e}=this;this.skipOffscreen=s,s&&t.transform(...n),i.render(t),this.skipOffscreen=e,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenterPoint(){return new ot(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new ot(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new ot(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new ot(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new ot(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return St(this.getCenterPoint(),Ct(this.viewportTransform))}_centerObject(t,e){t.setXY(e,A,A),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const r=this.clipPath,i=r&&!r.excludeFromExport?this._toObject(r,t,e):null;return{version:m,...zt(this,e),objects:this._objects.filter(t=>!t.excludeFromExport).map(r=>this._toObject(r,t,e)),...this.__serializeBgOverlay(t,e),...i?{clipPath:i}:null}}_toObject(t,e,r){let i;this.includeDefaultValues||(i=t.includeDefaultValues,t.includeDefaultValues=!1);const n=t[e](r);return this.includeDefaultValues||(t.includeDefaultValues=!!i),n}__serializeBgOverlay(t,e){const r={},i=this.backgroundImage,n=this.overlayImage,s=this.backgroundColor,o=this.overlayColor;return Ht(s)?s.excludeFromExport||(r.background=s.toObject(e)):s&&(r.background=s),Ht(o)?o.excludeFromExport||(r.overlay=o.toObject(e)):o&&(r.overlay=o),i&&!i.excludeFromExport&&(r.backgroundImage=this._toObject(i,t,e)),n&&!n.excludeFromExport&&(r.overlayImage=this._toObject(n,t,e)),r}toSVG(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const r=[];var i;return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push(`<g clip-path="url(#${re(null!==(i=this.clipPath.clipPathId)&&void 0!==i?i:"")})" >\n`),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push("</g>\n"),this._setSVGBgOverlayColor(r,"overlay"),this._setSVGBgOverlayImage(r,"overlayImage",e),r.push("</svg>"),r.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')}_setSVGHeader(t,e){const i=e.width||`${this.width}`,n=e.height||`${this.height}`,s=r.NUM_FRACTION_DIGITS,o=e.viewBox;let a;if(o)a=`viewBox="${o.x} ${o.y} ${o.width} ${o.height}" `;else if(this.svgViewportTransformation){const t=this.viewportTransform;a=`viewBox="${qt(-t[4]/t[0],s)} ${qt(-t[5]/t[3],s)} ${qt(this.width/t[0],s)} ${qt(this.height/t[3],s)}" `}else a=`viewBox="0 0 ${this.width} ${this.height}" `;t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',n,'" ',a,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",m,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"</defs>\n")}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId=`CLIPPATH_${pt()}`,`<clipPath id="${e.clipPathId}" >\n${e.toClipPathSVG(t.reviver)}</clipPath>\n`):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this[`${t}Color`];if(Ht(e)){const r=this[`${t}Vpt`],i=this.viewportTransform,n={isType:()=>!1,width:this.width/(r?i[0]:1),height:this.height/(r?i[3]:1)};return e.toSVG(n,{additionalTransform:r?Wt(i):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=r.fontPaths;this._objects.forEach(function e(r){t.push(r),ht(r)&&r._objects.forEach(e)}),t.forEach(t=>{if(!(r=t)||"function"!=typeof r._renderText)return;var r;const{styles:n,fontFamily:s}=t;!e[s]&&i[s]&&(e[s]=!0,n&&Object.values(n).forEach(t=>{Object.values(t).forEach(t=>{let{fontFamily:r=""}=t;!e[r]&&i[r]&&(e[r]=!0)})}))});const n=Object.keys(e).map(t=>`\t\t@font-face {\n\t\t\tfont-family: '${t}';\n\t\t\tsrc: url('${i[t]}');\n\t\t}\n`).join("");return n?`\t<style type="text/css"><![CDATA[\n${n}]]></style>\n`:""}_setSVGObjects(t,e){this.forEachObject(r=>{r.excludeFromExport||this._setSVGObject(t,r,e)})}_setSVGObject(t,e,r){t.push(e.toSVG(r))}_setSVGBgOverlayImage(t,e,r){const i=this[e];i&&!i.excludeFromExport&&i.toSVG&&t.push(i.toSVG(r))}_setSVGBgOverlayColor(t,e){const r=this[`${e}Color`];if(r)if(Ht(r)){const i=r.repeat||"",n=this.width,s=this.height,o=this[`${e}Vpt`]?Wt(Ct(this.viewportTransform)):"";t.push(`<rect transform="${o} translate(${n/2},${s/2})" x="${r.offsetX-n/2}" y="${r.offsetY-s/2}" width="${"repeat-y"!==i&&"no-repeat"!==i||!Yt(r)?n:r.source.width}" height="${"repeat-x"!==i&&"no-repeat"!==i||!Yt(r)?s:r.source.height}" fill="url(#SVGID_${r.id})"></rect>\n`)}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',r,'"',"></rect>\n")}loadFromJSON(t,e){let{signal:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new n("`json` is undefined"));const{objects:i=[],...s}="string"==typeof t?JSON.parse(t):t,{backgroundImage:o,background:a,overlayImage:h,overlay:l,clipPath:c}=s,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Bt(i,{reviver:e,signal:r}),Rt({backgroundImage:o,backgroundColor:a,overlayImage:h,overlayColor:l,clipPath:c},{signal:r})]).then(t=>{let[e,r]=t;return this.clear(),this.add(...e),this.set(s),this.set(r),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=vt(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:i=1,enableRetinaScaling:n=!1}=t,s=i*(n?this.getRetinaScaling():1);return yt(this.toCanvasElement(s,t),e,r)}toBlob(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{format:e="png",quality:r=1,multiplier:i=1,enableRetinaScaling:n=!1}=t,s=i*(n?this.getRetinaScaling():1);return bt(this.toCanvasElement(s,t),e,r)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,{width:e,height:r,left:i,top:n,filter:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=(e||this.width)*t,a=(r||this.height)*t,h=this.getZoom(),l=this.width,c=this.height,u=this.skipControlsDrawing,f=h*t,d=this.viewportTransform,p=[f,0,0,f,(d[4]-(i||0))*t,(d[5]-(n||0))*t],g=this.enableRetinaScaling,m=vt({width:o,height:a}),v=s?this._objects.filter(t=>s(t)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=p,this.width=o,this.height=a,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),v),this.viewportTransform=d,this.width=l,this.height=c,this.calcViewportBoundaries(),this.enableRetinaScaling=g,this.skipControlsDrawing=u,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),et.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const r=()=>{this.destroy(),t(!0)};r.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=r:r()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(t=>t.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return`#<Canvas (${this.complexity()}): { objects: ${this._objects.length} }>`}}t(he,"ownDefaults",ee);const le=["touchstart","touchmove","touchend"],ce=t=>{const e=Gt(t.target),r=function(t){const e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new ot(r.clientX+e.left,r.clientY+e.top)},ue=t=>le.includes(t.type)||"touch"===t.pointerType,fe=t=>{t.preventDefault(),t.stopPropagation()},de=t=>{let e=0,r=0,i=0,n=0;for(let s=0,o=t.length;s<o;s++){const{x:o,y:a}=t[s];(o>i||!s)&&(i=o),(o<e||!s)&&(e=o),(a>n||!s)&&(n=a),(a<r||!s)&&(r=a)}return{left:e,top:r,width:i-e,height:n-r}},pe=(t,e)=>ge(t,At(e,t.calcOwnMatrix())),ge=(t,e)=>{const{translateX:r,translateY:i,scaleX:n,scaleY:s,...o}=Tt(e),a=new ot(r,i);t.flipX=!1,t.flipY=!1,Object.assign(t,o),t.set({scaleX:n,scaleY:s}),t.setPositionByOrigin(a,A,A)},me=t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},ve=t=>({scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}),ye=(t,e,r)=>{const i=t/2,n=e/2,s=[new ot(-i,-n),new ot(i,-n),new ot(-i,n),new ot(i,n)].map(t=>t.transform(r)),o=de(s);return new ot(o.width,o.height)},be=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:x;return At(Ct(arguments.length>1&&void 0!==arguments[1]?arguments[1]:x),t)},we=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:x;return t.transform(be(e,r))},_e=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:x;return t.transform(be(e,r),!0)},xe=(t,e,r)=>{const i=be(e,r);return ge(t,At(i,t.calcOwnMatrix())),i},Se={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Ce=t=>"string"==typeof t?Se[t]:t-.5,Ae=new ot(1,0),ke=new ot,Le=(t,e)=>t.rotate(e),Te=(t,e)=>new ot(e).subtract(t),Pe=t=>t.distanceFrom(ke),Ne=(t,e)=>Math.atan2(De(t,e),Fe(t,e)),Oe=t=>Ne(Ae,t),Ee=t=>t.eq(ke)?t:t.scalarDivide(Pe(t)),Me=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Ee(new ot(-t.y,t.x).scalarMultiply(e?1:-1))},De=(t,e)=>t.x*e.y-t.y*e.x,Fe=(t,e)=>t.x*e.x+t.y*e.y,je=(t,e,r)=>{if(t.eq(e)||t.eq(r))return!0;const i=De(e,r),n=De(e,t),s=De(r,t);return i>=0?n>=0&&s<=0:!(n<=0&&s>=0)},Ie="not-allowed";function Be(t){return Ce(t.originX)===Ce(A)&&Ce(t.originY)===Ce(A)}function Re(t){return.5-Ce(t)}const ze=(t,e)=>t[e],Ue=(t,e,r,i)=>({e:t,transform:e,pointer:new ot(r,i)});function qe(t,e,r){const i=r,n=we(t.getCenterPoint(),t.canvas.viewportTransform,void 0),s=Oe(Te(n,i))+w;return Math.round(s%w/b)}function We(t,e,r,i,n){var s;let{target:o,corner:a}=t;const h=o.controls[a],l=(null===(s=o.canvas)||void 0===s?void 0:s.getZoom())||1,c=o.padding/l,u=function(t,e,r,i){const n=t.getRelativeCenterPoint(),s=void 0!==r&&void 0!==i?t.translateToGivenOrigin(n,A,A,r,i):new ot(t.left,t.top);return(t.angle?e.rotate(-wt(t.angle),n):e).subtract(s)}(o,new ot(i,n),e,r);return u.x>=c&&(u.x-=c),u.x<=-c&&(u.x+=c),u.y>=c&&(u.y-=c),u.y<=c&&(u.y+=c),u.x-=h.offsetX,u.y-=h.offsetY,u}const He=t=>t.replace(/\s+/g," "),Ve={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},Ye=(t,e,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t),Xe=(t,e,r,i)=>{t/=255,e/=255,r/=255;const n=Math.max(t,e,r),s=Math.min(t,e,r);let o,a;const h=(n+s)/2;if(n===s)o=a=0;else{const i=n-s;switch(a=h>.5?i/(2-n-s):i/(n+s),n){case t:o=(e-r)/i+(e<r?6:0);break;case e:o=(r-t)/i+2;break;case r:o=(t-e)/i+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*h),i]},Ge=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},$e=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),Ke=t=>{let[e,r,i,n=1]=t;const s=Math.round(.3*e+.59*r+.11*i);return[s,s,s,n]};class Je{constructor(e){if(t(this,"isUnrecognised",!1),e)if(e instanceof Je)this.setSource([...e._source]);else if(Array.isArray(e)){const[t,r,i,n=1]=e;this.setSource([t,r,i,n])}else this.setSource(this._tryParsingColor(e));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Ve&&(t=Ve[t]),"transparent"===t?[255,255,255,0]:Je.sourceFromHex(t)||Je.sourceFromRgb(t)||Je.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,r]=this.getSource();return`rgb(${t},${e},${r})`}toRgba(){return`rgba(${this.getSource().join(",")})`}toHsl(){const[t,e,r]=Xe(...this.getSource());return`hsl(${t},${e}%,${r}%)`}toHsla(){const[t,e,r,i]=Xe(...this.getSource());return`hsla(${t},${e}%,${r}%,${i})`}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,r,i]=this.getSource();return`${$e(t)}${$e(e)}${$e(r)}${$e(Math.round(255*i))}`}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Ke(this.getSource())),this}toBlackWhite(t){const[e,,,r]=Ke(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,r]),this}overlayWith(t){t instanceof Je||(t=new Je(t));const e=this.getSource(),r=t.getSource(),[i,n,s]=e.map((t,e)=>Math.round(.5*t+.5*r[e]));return this.setSource([i,n,s,e[3]]),this}static fromRgb(t){return Je.fromRgba(t)}static fromRgba(t){return new Je(Je.sourceFromRgb(t))}static sourceFromRgb(t){const e=He(t).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(e){const[t,r,i]=e.slice(1,4).map(t=>{const e=parseFloat(t);return t.endsWith("%")?Math.round(2.55*e):e});return[t,r,i,Ge(e[4])]}}static fromHsl(t){return Je.fromHsla(t)}static fromHsla(t){return new Je(Je.sourceFromHsl(t))}static sourceFromHsl(t){const e=He(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!e)return;const r=(Je.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,n=parseFloat(e[3])/100;let s,o,a;if(0===i)s=o=a=n;else{const t=n<=.5?n*(i+1):n+i-n*i,e=2*n-t;s=Ye(e,t,r+1/3),o=Ye(e,t,r),a=Ye(e,t,r-1/3)}return[Math.round(255*s),Math.round(255*o),Math.round(255*a),Ge(e[4])]}static fromHex(t){return new Je(Je.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let r;r=e.length<=4?e.split("").map(t=>t+t):e.match(/.{2}/g);const[i,n,s,o=255]=r.map(t=>parseInt(t,16));return[i,n,s,o/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),r=parseFloat(e);return e.includes("rad")?_t(r):e.includes("turn")?360*r:r}}const Ze=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:S;const i=/\D{0,2}$/.exec(t),n=parseFloat(t),s=r.DPI;switch(null==i?void 0:i[0]){case"mm":return n*s/25.4;case"cm":return n*s/2.54;case"in":return n*s;case"pt":return n*s/72;case"pc":return n*s/72*12;case"em":return n*e;default:return n}},Qe=t=>{const[e,r]=t.trim().split(" "),[i,n]=(s=e)&&s!==N?[s.slice(1,4),s.slice(5,8)]:s===N?[s,s]:["Mid","Mid"];var s;return{meetOrSlice:r||"meet",alignX:i,alignY:n}},tr=function(t,e){let r,i,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e)if(e.toLive)r=`url(#SVGID_${re(e.id)})`;else{const t=new Je(e),n=t.getAlpha();r=t.toRgb(),1!==n&&(i=n.toString())}else r="none";return n?`${t}: ${r}; ${i?`${t}-opacity: ${i}; `:""}`:`${t}="${r}" ${i?`${t}-opacity="${i}" `:""}`};class er{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):N,n=this.strokeDashOffset?this.strokeDashOffset:"0",s=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",h=void 0!==this.opacity?this.opacity:"1",l=this.visible?"":" visibility: hidden;",c=t?"":this.getSvgFilter(),u=tr(Y,this.fill);return[tr(X,this.stroke),"stroke-width: ",r,"; ","stroke-dasharray: ",i,"; ","stroke-linecap: ",s,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",a,"; ",u,"fill-rule: ",e,"; ","opacity: ",h,";",c,l].map(t=>re(t)).join("")}getSvgFilter(){return this.shadow?`filter: url(#SVGID_${re(this.shadow.id)});`:""}getSvgCommons(){return[this.id?`id="${re(String(this.id))}" `:"",this.clipPath?`clip-path="url(#${this.clipPath.clipPathId})" `:""].join("")}getSvgTransform(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const r=t?this.calcTransformMatrix():this.calcOwnMatrix();return`transform="${Wt(r)}${e}" `}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:r=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=i,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:r,withShadow:i,additionalTransform:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=e?"":`style="${this.getSvgStyles()}" `,o=i?`style="${this.getSvgFilter()}" `:"",a=this.clipPath,h=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",l=a&&a.absolutePositioned,c=this.stroke,u=this.fill,f=this.shadow,d=[],p=t.indexOf("COMMON_PARTS");let g;a&&(a.clipPathId=`CLIPPATH_${pt()}`,g=`<clipPath id="${a.clipPathId}" >\n${a.toClipPathSVG(r)}</clipPath>\n`),l&&d.push("<g ",o,this.getSvgCommons()," >\n"),d.push("<g ",this.getSvgTransform(!1),l?"":o+this.getSvgCommons()," >\n");const m=[s,h,e?"":this.addPaintOrder()," ",n?`transform="${n}" `:""].join("");return t[p]=m,Ht(u)&&d.push(u.toSVG(this)),Ht(c)&&d.push(c.toSVG(this)),f&&d.push(f.toSVG(this)),a&&d.push(g),d.push(t.join("")),d.push("</g>\n"),l&&d.push("</g>\n"),r?r(d.join("")):d.join("")}addPaintOrder(){return this.paintFirst!==Y?` paint-order="${re(this.paintFirst)}" `:""}}function rr(t){return new RegExp("^("+t.join("|")+")\\b","i")}const ir="textDecorationThickness",nr=["fontSize","fontWeight","fontFamily","fontStyle"],sr=["underline","overline","linethrough"],or=[...nr,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],ar=[...or,...sr,"textBackgroundColor","direction",ir],hr=[...nr,...sr,X,"strokeWidth",Y,"deltaY","textBackgroundColor",ir],lr={_reNewline:O,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:J,fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:k,fontStyle:J,lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:k,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:$,CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[ir]:66.667},cr="justify",ur="justify-left",fr="justify-right",dr="justify-center",pr=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,gr=String.raw`(?:\s*,?\s+|\s*,\s*)`,mr=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+pr+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+pr+"))?\\s+(.*)"),vr={cx:k,x:k,r:"radius",cy:L,y:L,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":ir},yr="font-size",br="clip-path",wr=(rr(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),rr(["symbol","image","marker","pattern","view","svg"]),rr(["symbol","g","a","svg","clipPath","defs"])),_r=(new RegExp(String.raw`^\s*(${pr})${gr}(${pr})${gr}(${pr})${gr}(${pr})\s*$`),"(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?"),xr=new RegExp("(?:\\s|^)"+_r+_r+"("+pr+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class Sr{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e="string"==typeof t?Sr.parseShadow(t):t;Object.assign(this,Sr.ownDefaults,e),this.id=pt()}static parseShadow(t){const e=t.trim(),[,r=0,i=0,n=0]=(xr.exec(e)||[]).map(t=>parseFloat(t)||0);return{color:(e.replace(xr,"")||"rgb(0,0,0)").trim(),offsetX:r,offsetY:i,blur:n}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=Le(new ot(this.offsetX,this.offsetY),wt(-t.angle)),i=r.NUM_FRACTION_DIGITS,n=new Je(this.color);let s=40,o=40;return t.width&&t.height&&(s=100*qt((Math.abs(e.x)+this.blur)/t.width,i)+20,o=100*qt((Math.abs(e.y)+this.blur)/t.height,i)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),`<filter id="SVGID_${re(this.id)}" y="-${o}%" height="${100+2*o}%" x="-${s}%" width="${100+2*s}%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="${qt(this.blur?this.blur/2:0,i)}"></feGaussianBlur>\n\t<feOffset dx="${qt(e.x,i)}" dy="${qt(e.y,i)}" result="oBlur" ></feOffset>\n\t<feFlood flood-color="${n.toRgb()}" flood-opacity="${n.getAlpha()}"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n`}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=Sr.ownDefaults;return this.includeDefaultValues?t:Ut(t,(t,r)=>t!==e[r])}static async fromObject(t){return new this(t)}}t(Sr,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),t(Sr,"type","shadow"),tt.setClass(Sr,"shadow");const Cr=(t,e,r)=>Math.max(t,Math.min(e,r)),Ar=[L,k,q,W,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",H,V],kr=[Y,X,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Lr={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:A,originY:A,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Y,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},Tr=(t,e,r,i)=>(t<Math.abs(e)?(t=e,i=r/4):i=0===e&&0===t?r/w*Math.asin(1):r/w*Math.asin(e/t),{a:t,c:e,p:r,s:i}),Pr=(t,e,r,i,n)=>t*Math.pow(2,10*(i-=1))*Math.sin((i*n-e)*w/r),Nr=(t,e,r,i)=>-r*Math.cos(t/i*y)+r+e,Or=(t,e,r,i)=>(t/=i)<1/2.75?r*(7.5625*t*t)+e:t<2/2.75?r*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?r*(7.5625*(t-=2.25/2.75)*t+.9375)+e:r*(7.5625*(t-=2.625/2.75)*t+.984375)+e,Er=(t,e,r,i)=>r-Or(i-t,0,r,i)+e;var Mr=Object.freeze({__proto__:null,defaultEasing:Nr,easeInBack:function(t,e,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return r*(t/=i)*t*((n+1)*t-n)+e},easeInBounce:Er,easeInCirc:(t,e,r,i)=>-r*(Math.sqrt(1-(t/=i)*t)-1)+e,easeInCubic:(t,e,r,i)=>r*(t/i)**3+e,easeInElastic:(t,e,r,i)=>{const n=r;let s=0;if(0===t)return e;if(1===(t/=i))return e+r;s||(s=.3*i);const{a:o,s:a,p:h}=Tr(n,r,s,1.70158);return-Pr(o,a,h,t,i)+e},easeInExpo:(t,e,r,i)=>0===t?e:r*2**(10*(t/i-1))+e,easeInOutBack:function(t,e,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return(t/=i/2)<1?r/2*(t*t*((1+(n*=1.525))*t-n))+e:r/2*((t-=2)*t*((1+(n*=1.525))*t+n)+2)+e},easeInOutBounce:(t,e,r,i)=>t<i/2?.5*Er(2*t,0,r,i)+e:.5*Or(2*t-i,0,r,i)+.5*r+e,easeInOutCirc:(t,e,r,i)=>(t/=i/2)<1?-r/2*(Math.sqrt(1-t**2)-1)+e:r/2*(Math.sqrt(1-(t-=2)*t)+1)+e,easeInOutCubic:(t,e,r,i)=>(t/=i/2)<1?r/2*t**3+e:r/2*((t-2)**3+2)+e,easeInOutElastic:(t,e,r,i)=>{const n=r;let s=0;if(0===t)return e;if(2==(t/=i/2))return e+r;s||(s=i*(.3*1.5));const{a:o,s:a,p:h,c:l}=Tr(n,r,s,1.70158);return t<1?-.5*Pr(o,a,h,t,i)+e:o*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*w/h)*.5+l+e},easeInOutExpo:(t,e,r,i)=>0===t?e:t===i?e+r:(t/=i/2)<1?r/2*2**(10*(t-1))+e:r/2*-(2**(-10*--t)+2)+e,easeInOutQuad:(t,e,r,i)=>(t/=i/2)<1?r/2*t**2+e:-r/2*(--t*(t-2)-1)+e,easeInOutQuart:(t,e,r,i)=>(t/=i/2)<1?r/2*t**4+e:-r/2*((t-=2)*t**3-2)+e,easeInOutQuint:(t,e,r,i)=>(t/=i/2)<1?r/2*t**5+e:r/2*((t-2)**5+2)+e,easeInOutSine:(t,e,r,i)=>-r/2*(Math.cos(Math.PI*t/i)-1)+e,easeInQuad:(t,e,r,i)=>r*(t/=i)*t+e,easeInQuart:(t,e,r,i)=>r*(t/=i)*t**3+e,easeInQuint:(t,e,r,i)=>r*(t/i)**5+e,easeInSine:(t,e,r,i)=>-r*Math.cos(t/i*y)+r+e,easeOutBack:function(t,e,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return r*((t=t/i-1)*t*((n+1)*t+n)+1)+e},easeOutBounce:Or,easeOutCirc:(t,e,r,i)=>r*Math.sqrt(1-(t=t/i-1)*t)+e,easeOutCubic:(t,e,r,i)=>r*((t/i-1)**3+1)+e,easeOutElastic:(t,e,r,i)=>{const n=r;let s=0;if(0===t)return e;if(1===(t/=i))return e+r;s||(s=.3*i);const{a:o,s:a,p:h,c:l}=Tr(n,r,s,1.70158);return o*2**(-10*t)*Math.sin((t*i-a)*w/h)+l+e},easeOutExpo:(t,e,r,i)=>t===i?e+r:r*-(2**(-10*t/i)+1)+e,easeOutQuad:(t,e,r,i)=>-r*(t/=i)*(t-2)+e,easeOutQuart:(t,e,r,i)=>-r*((t=t/i-1)*t**3-1)+e,easeOutQuint:(t,e,r,i)=>r*((t/i-1)**5+1)+e,easeOutSine:(t,e,r,i)=>r*Math.sin(t/i*y)+e});const Dr=()=>!1;class Fr{constructor(e){let{startValue:r,byValue:i,duration:n=500,delay:s=0,easing:o=Nr,onStart:a=v,onChange:h=v,onComplete:l=v,abort:c=Dr,target:u}=e;t(this,"_state","pending"),t(this,"durationProgress",0),t(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=n,this.delay=s,this.easing=o,this._onStart=a,this._onChange=h,this._onComplete=l,this._abort=c,this.target=u,this.startValue=r,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return"aborted"===this._state||"completed"===this._state}start(){const t=t=>{"pending"===this._state&&(this.startTime=t||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>ut(t),this.delay):ut(t)}tick(t){const e=(t||+new Date)-this.startTime,r=Math.min(e,this.duration);this.durationProgress=r/this.duration;const{value:i,valueProgress:n}=this.calculate(r);this.value=Object.freeze(i),this.valueProgress=n,"aborted"!==this._state&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),ut(this.tick)))}register(){et.push(this)}unregister(){et.remove(this)}abort(){this._state="aborted",this.unregister()}}class jr extends Fr{constructor(t){let{startValue:e=0,endValue:r=100,...i}=t;super({...i,startValue:e,byValue:r-e})}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}class Ir extends Fr{constructor(t){let{startValue:e=[0],endValue:r=[100],...i}=t;super({...i,startValue:e,byValue:r.map((t,r)=>t-e[r])})}calculate(t){const e=this.startValue.map((e,r)=>this.easing(t,e,this.byValue[r],this.duration,r));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Br=(t,e,r,i)=>e+r*(1-Math.cos(t/i*y)),Rr=t=>t&&((e,r,i)=>t(new Je(e).toRgba(),r,i));class zr extends Fr{constructor(t){let{startValue:e,endValue:r,easing:i=Br,onChange:n,onComplete:s,abort:o,...a}=t;const h=new Je(e).getSource(),l=new Je(r).getSource();super({...a,startValue:h,byValue:l.map((t,e)=>t-h[e]),easing:i,onChange:Rr(n),onComplete:Rr(s),abort:Rr(o)})}calculate(t){const[e,r,i,n]=this.startValue.map((e,r)=>this.easing(t,e,this.byValue[r],this.duration,r)),s=[...[e,r,i].map(Math.round),Cr(0,n,1)];return{value:s,valueProgress:s.map((t,e)=>0!==this.byValue[e]?Math.abs((t-this.startValue[e])/this.byValue[e]):0).find(t=>0!==t)||0}}}function Ur(t){const e=(t=>Array.isArray(t.startValue)||Array.isArray(t.endValue))(t)?new Ir(t):new jr(t);return e.start(),e}function qr(t){const e=new zr(t);return e.start(),e}class Wr{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.points=this.points.concat(e.filter(t=>!this.includes(t))),this}static isPointContained(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e.eq(r))return t.eq(e);if(e.x===r.x)return t.x===e.x&&(i||t.y>=Math.min(e.y,r.y)&&t.y<=Math.max(e.y,r.y));if(e.y===r.y)return t.y===e.y&&(i||t.x>=Math.min(e.x,r.x)&&t.x<=Math.max(e.x,r.x));{const n=Te(e,r),s=Te(e,t).divide(n);return i?Math.abs(s.x)===Math.abs(s.y):s.x===s.y&&s.x>=0&&s.x<=1}}static isPointInPolygon(t,e){const r=new ot(t).setX(Math.min(t.x-1,...e.map(t=>t.x)));let i=0;for(let n=0;n<e.length;n++){const s=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,r);if(s.includes(t))return!0;i+=Number("Intersection"===s.status)}return i%2==1}static intersectLineLine(t,e,r,i){let n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];const o=e.x-t.x,a=e.y-t.y,h=i.x-r.x,l=i.y-r.y,c=t.x-r.x,u=t.y-r.y,f=h*u-l*c,d=o*u-a*c,p=l*o-h*a;if(0!==p){const e=f/p,r=d/p;return(n||0<=e&&e<=1)&&(s||0<=r&&r<=1)?new Wr("Intersection").append(new ot(t.x+e*o,t.y+e*a)):new Wr}if(0===f||0===d){const o=n||s||Wr.isPointContained(t,r,i)||Wr.isPointContained(e,r,i)||Wr.isPointContained(r,t,e)||Wr.isPointContained(i,t,e);return new Wr(o?"Coincident":void 0)}return new Wr("Parallel")}static intersectSegmentLine(t,e,r,i){return Wr.intersectLineLine(t,e,r,i,!1,!0)}static intersectSegmentSegment(t,e,r,i){return Wr.intersectLineLine(t,e,r,i,!1,!1)}static intersectLinePolygon(t,e,r){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const n=new Wr,s=r.length;for(let o,a,h,l=0;l<s;l++){if(o=r[l],a=r[(l+1)%s],h=Wr.intersectLineLine(t,e,o,a,i,!1),"Coincident"===h.status)return h;n.append(...h.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,r){return Wr.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){const r=new Wr,i=t.length,n=[];for(let s=0;s<i;s++){const o=t[s],a=t[(s+1)%i],h=Wr.intersectSegmentPolygon(o,a,e);"Coincident"===h.status?(n.push(h),r.append(o,a)):r.append(...h.points)}return n.length>0&&n.length===t.length?new Wr("Coincident"):(r.points.length>0&&(r.status="Intersection"),r)}static intersectPolygonRectangle(t,e,r){const i=e.min(r),n=e.max(r),s=new ot(n.x,i.y),o=new ot(i.x,n.y);return Wr.intersectPolygonPolygon(t,[i,s,n,o])}}class Hr extends ct{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?St(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=St(t,Ct(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new ot(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.originX,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.originY;this.setPositionByOrigin(t,e,r)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:r,bl:i}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,r,i];if(this.group){const t=this.group.calcTransformMatrix();return n.map(e=>St(e,t))}return n}intersectsWithRect(t,e){return"Intersection"===Wr.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){const e=Wr.intersectPolygonPolygon(this.getCoords(),t.getCoords());return"Intersection"===e.status||"Coincident"===e.status||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:r,top:i,width:n,height:s}=this.getBoundingRect();return r>=t.x&&r+n<=e.x&&i>=t.y&&i+s<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return Wr.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(r=>r.x<=e.x&&r.x>=t.x&&r.y<=e.y&&r.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.intersectsWithRect(t,e)||this.getCoords().every(r=>(r.x>=e.x||r.x<=t.x)&&(r.y>=e.y||r.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return de(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(q,t),this._set(W,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?_t(Lt(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.viewportTransform)||x.concat()}calcACoords(){const t=Nt({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),i=Pt(e,r),n=At(i,t),s=this._getTransformedDimensions(),o=s.x/2,a=s.y/2;return{tl:St({x:-o,y:-a},n),tr:St({x:o,y:-a},n),bl:St({x:-o,y:a},n),br:St({x:o,y:a},n)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Ce(this.originX),Ce(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const r=this.transformMatrixKey(t),i=this.matrixCache;return i&&i.key.every((t,e)=>t===r[e])?i.value:(this.group&&(e=At(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:r,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key.every((e,r)=>e===t[r]))return e.value;const r=this.getRelativeCenterPoint(),i={angle:this.angle,translateX:r.x,translateY:r.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=jt(i);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new ot(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth,...t},r=e.strokeWidth;let i=r,n=0;this.strokeUniform&&(i=0,n=r);const s=e.width+i,o=e.height+i;let a;return a=0===e.skewX&&0===e.skewY?new ot(s*e.scaleX,o*e.scaleY):ye(s,o,Ft(e)),a.scalarAdd(n)}translateToGivenOrigin(t,e,r,i,n){let s=t.x,o=t.y;const a=Ce(i)-Ce(e),h=Ce(n)-Ce(r);if(a||h){const t=this._getTransformedDimensions();s+=a*t.x,o+=h*t.y}return new ot(s,o)}translateToCenterPoint(t,e,r){if(e===A&&r===A)return t;const i=this.translateToGivenOrigin(t,e,r,A,A);return this.angle?i.rotate(wt(this.angle),t):i}translateToOriginPoint(t,e,r){const i=this.translateToGivenOrigin(t,A,A,e,r);return this.angle?i.rotate(wt(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?St(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new ot(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.getPositionByOrigin(t,e)}getPositionByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,r){const i=this.translateToCenterPoint(t,e,r),n=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.getPositionByOrigin(k,L)}positionByLeftTop(t){return this.setPositionByOrigin(t,k,L)}}let Vr=class e extends Hr{static getDefaults(){return e.ownDefaults}get type(){const t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){i("warn","Setting type has no effect",t)}constructor(r){super(),t(this,"_cacheContext",null),Object.assign(this,e.ownDefaults),this.setOptions(r)}_createCacheCanvas(){this._cacheCanvas=gt(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,n=r.maxCacheSideLimit,s=r.minCacheSideLimit;if(e<=n&&i<=n&&e*i<=r.perfLimitSizeTotal)return e<s&&(t.width=s),i<s&&(t.height=s),t;const o=e/i,[a,h]=g.limitDimsByArea(o),l=Cr(s,a,n),c=Cr(s,h,n);return e>l&&(t.zoomX/=e/l,t.width=l,t.capped=!0),i>c&&(t.zoomY/=i/c,t.height=c,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),r=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:Math.ceil(r+2),height:Math.ceil(i+2),zoomX:t.x,zoomY:t.y,x:r,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:r,height:i,zoomX:n,zoomY:s,x:o,y:a}=this._limitCacheSize(this._getCacheCanvasDimensions()),h=r!==t.width||i!==t.height,l=this.zoomX!==n||this.zoomY!==s;if(!t||!e)return!1;if(h||l){r!==t.width||i!==t.height?(t.width=r,t.height=i):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const h=o/2,l=a/2;return this.cacheTranslationX=Math.round(t.width/2-h)+h,this.cacheTranslationY=Math.round(t.height/2-l)+l,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(n,s),this.zoomX=n,this.zoomY=s,!0}return!1}setOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,r=this.calcTransformMatrix(!e);t.transform(r[0],r[1],r[2],r[3],r[4],r[5])}getObjectScaling(){if(!this.group)return new ot(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Tt(this.calcTransformMatrix());return new ot(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),r=this.getCanvasRetinaScaling();return t.scalarMultiply(e*r)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:0===t?1e-4:t}_set(t,e){t!==q&&t!==W||(e=this._constrainScale(e)),t===q&&e<0?(this.flipX=!this.flipX,e*=-1):"scaleY"===t&&e<0?(this.flipY=!this.flipY,e*=-1):"shadow"!==t||!e||e instanceof Sr||(e=new Sr(e));const r=this[t]!==e;return this[t]=e,r&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||r&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible}render(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.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:n}=this,{width:s,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:n,width:s,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return!!this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth}hasFill(){return!!this.fill&&"transparent"!==this.fill}needsItsOwnCache(){return!!(this.paintFirst===X&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)}drawClipPathOnCache(t,e,r){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0),t.restore()}drawObject(t,e,r){const i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this.fire("before:render",{ctx:t}),this._render(t),this._drawClipPath(t,this.clipPath,r),this.fill=i,this.stroke=n}createClipPathLayer(t,e){const r=vt(e),i=r.getContext("2d");if(i.translate(e.cacheTranslationX,e.cacheTranslationY),i.scale(e.zoomX,e.zoomY),t._cacheCanvas=r,e.parentClipPaths.forEach(t=>{t.transform(i)}),e.parentClipPaths.push(t),t.absolutePositioned){const t=Ct(this.calcTransformMatrix());i.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return t.transform(i),t.drawObject(i,!0,e),r}_drawClipPath(t,e,r){if(!e)return;e._transformDone=!0;const i=this.createClipPathLayer(e,r);this.drawClipPathOnCache(t,e,i)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,r=this._cacheContext;return!(!e||!r||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&r&&!t&&(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const r=e.stroke;r&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,Ht(r)?"percentage"===r.gradientUnits||r.gradientTransform||r.patternTransform?this._applyPatternForTransformedGradient(t,r):(t.strokeStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:r}=e;r&&(Ht(r)?(t.fillStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.fillStyle=r)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&0!==e.length&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,n=this.getCanvasRetinaScaling(),[s,,,o]=(null==i?void 0:i.viewportTransform)||x,a=s*n,h=o*n,l=e.nonScaling?new ot(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*r.browserShadowBlurConstant*(a+h)*(l.x+l.y)/4,t.shadowOffsetX=e.offsetX*a*l.x,t.shadowOffsetY=e.offsetY*h*l.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!Ht(e))return{offsetX:0,offsetY:0};const r=e.gradientTransform||e.patternTransform,i=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,i,n):t.transform(1,0,0,1,i,n),r&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),{offsetX:i,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===X?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var r;const i=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),s=i.x/this.scaleX/n,o=i.y/this.scaleY/n,a=vt({width:Math.ceil(s),height:Math.ceil(o)}),h=a.getContext("2d");h&&(h.beginPath(),h.moveTo(0,0),h.lineTo(s,0),h.lineTo(s,o),h.lineTo(0,o),h.closePath(),h.translate(s/2,o/2),h.scale(i.zoomX/this.scaleX/n,i.zoomY/this.scaleY/n),this._applyPatternGradientTransform(h,e),h.fillStyle=e.toLive(t),h.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/i.zoomX,n*this.scaleY/i.zoomY),t.strokeStyle=null!==(r=h.createPattern(a,"no-repeat"))&&void 0!==r?r:"")}_findCenterFromElement(){return new ot(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(tt.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=ve(this),r=this.group,i=this.shadow,n=Math.abs,s=t.enableRetinaScaling?p():1,o=(t.multiplier||1)*s,a=t.canvasProvider||(t=>new he(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&me(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&xe(this,this.getViewportTransform()),this.setCoords();const h=gt(),l=this.getBoundingRect(),c=this.shadow,u=new ot;if(c){const t=c.blur,e=c.nonScaling?new ot(1,1):this.getObjectScaling();u.x=2*Math.round(n(c.offsetX)+t)*n(e.x),u.y=2*Math.round(n(c.offsetY)+t)*n(e.y)}const f=l.width+u.x,d=l.height+u.y;h.width=Math.ceil(f),h.height=Math.ceil(d);const g=a(h);"jpeg"===t.format&&(g.backgroundColor="#fff"),this.setPositionByOrigin(new ot(g.width/2,g.height/2),A,A);const m=this.canvas;g._objects=[this],this.set("canvas",g),this.setCoords();const v=g.toCanvasElement(o||1,t);return this.set("canvas",m),this.shadow=i,r&&(this.group=r),this.set(e),this.setCoords(),g._objects=[],g.destroy(),v}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return yt(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return bt(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:r,originY:i}=this;if(e){const{x:t,y:e}=this.getRelativeCenterPoint();this.originX=A,this.originY=A,this.left=t,this.top=e}if(this.set("angle",t),e){const{x:t,y:e}=this.getPositionByOrigin(r,i);this.left=t,this.top=e,this.originX=r,this.originY=i}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){et.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&u().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((t,r)=>{let[i,n]=r;return t[i]=this._animate(i,n,e),t},{})}_animate(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=t.split("."),n=this.constructor.colorProperties.includes(i[i.length-1]),{abort:s,startValue:o,onChange:a,onComplete:h}=r,l={...r,target:this,startValue:null!=o?o:i.reduce((t,e)=>t[e],this),endValue:e,abort:null==s?void 0:s.bind(this),onChange:(t,e,r)=>{i.reduce((e,r,n)=>(n===i.length-1&&(e[r]=t),e[r]),this),a&&a(t,e,r)},onComplete:(t,e,r)=>{this.setCoords(),h&&h(t,e,r)}};return n?qr(l):Ur(l)}isDescendantOf(t){const{parent:e,group:r}=this;return e===t||r===t||!!e&&e.isDescendantOf(t)||!!r&&r!==e&&r.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do{e=e.parent,e&&t.push(e)}while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),r=t.getAncestors();if(0===e.length&&r.length>0&&this===r[r.length-1])return{fork:[],otherFork:[t,...r.slice(0,r.length-1)],common:[this]};for(let i,n=0;n<e.length;n++){if(i=e[n],i===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let s=0;s<r.length;s++){if(this===r[s])return{fork:[],otherFork:[t,...r.slice(0,s)],common:[this,...e]};if(i===r[s])return{fork:[this,...e.slice(0,n)],otherFork:[t,...r.slice(0,s)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...r],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const r=e.common[0]||this.canvas;if(!r)return;const i=e.fork.pop(),n=e.otherFork.pop(),s=r._objects.indexOf(i),o=r._objects.indexOf(n);return s>-1&&s>o}toObject(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(e.customProperties,this.constructor.customProperties||[]);let i;const n=r.NUM_FRACTION_DIGITS,{clipPath:s,fill:o,stroke:a,shadow:h,strokeDashArray:l,left:c,top:u,originX:f,originY:d,width:p,height:g,strokeWidth:v,strokeLineCap:y,strokeDashOffset:b,strokeLineJoin:w,strokeUniform:_,strokeMiterLimit:x,scaleX:S,scaleY:C,angle:A,flipX:k,flipY:L,opacity:T,visible:P,backgroundColor:N,fillRule:O,paintFirst:E,globalCompositeOperation:M,skewX:D,skewY:F}=this;s&&!s.excludeFromExport&&(i=s.toObject(t.concat("inverted","absolutePositioned")));const j=t=>qt(t,n),I={...zt(this,t),type:this.constructor.type,version:m,originX:f,originY:d,left:j(c),top:j(u),width:j(p),height:j(g),fill:Vt(o)?o.toObject():o,stroke:Vt(a)?a.toObject():a,strokeWidth:j(v),strokeDashArray:l?l.concat():l,strokeLineCap:y,strokeDashOffset:b,strokeLineJoin:w,strokeUniform:_,strokeMiterLimit:j(x),scaleX:j(S),scaleY:j(C),angle:j(A),flipX:k,flipY:L,opacity:j(T),shadow:h?h.toObject():h,visible:P,backgroundColor:N,fillRule:O,paintFirst:E,globalCompositeOperation:M,skewX:j(D),skewY:j(F),...i?{clipPath:i}:null};return this.includeDefaultValues?I:this._removeDefaultValues(I)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Ut(t,(t,e)=>{if(e===k||e===L||"type"===e)return!0;const i=r[e];return t!==i&&!(Array.isArray(t)&&Array.isArray(i)&&0===t.length&&0===i.length)})}toString(){return`#<${this.constructor.type}>`}static _fromObject(t){let{type:e,...r}=t,{extraParam:i,...n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Rt(r,n).then(t=>i?(delete t[i],new this(r[i],t)):new this(t))}static fromObject(t,e){return this._fromObject(t,e)}};t(Vr,"stateProperties",Ar),t(Vr,"cacheProperties",kr),t(Vr,"ownDefaults",Lr),t(Vr,"type","FabricObject"),t(Vr,"colorProperties",[Y,X,"backgroundColor"]),t(Vr,"customProperties",[]),tt.setClass(Vr),tt.setClass(Vr,"object");const Yr=(t,e)=>{var r;const{transform:{target:i}}=e;null===(r=i.canvas)||void 0===r||r.fire(`object:${t}`,{...e,target:i}),i.fire(t,e)},Xr=(t,e,r)=>(i,n,s,o)=>{const a=e(i,n,s,o);return a&&Yr(t,{...Ue(i,n,s,o),...r}),a};function Gr(t){return(e,r,i,n)=>{const{target:s,originX:o,originY:a}=r,h=s.getPositionByOrigin(o,a),l=t(e,r,i,n);return s.setPositionByOrigin(h,r.originX,r.originY),l}}const $r=(t,e,r,i)=>(n,s,o,a)=>{const h=We(s,s.originX,s.originY,o,a)[r],l=Ce(s[e]);if(0===l||l>0&&h<0||l<0&&h>0){const{target:e}=s,r=e.strokeWidth/(e.strokeUniform?e[i]:1),n=Be(s)?2:1,o=e[t],a=Math.abs(h*n/e[i])-r;return e.set(t,Math.max(a,1)),o!==e[t]}return!1},Kr=$r("width","originX","x","scaleX"),Jr=$r("height","originY","y","scaleY"),Zr=Xr(I,Gr(Kr)),Qr=Xr(I,Gr(Jr));function ti(t,e,r,i,n){t.save();const{stroke:s,xSize:o,ySize:a,opName:h}=this.commonRenderProps(t,e,r,n,i);let l=o;o>a?t.scale(1,a/o):a>o&&(l=a,t.scale(o/a,1)),t.beginPath(),t.arc(0,0,l/2,0,w,!1),t[h](),s&&t.stroke(),t.restore()}function ei(t,e,r,i,n){t.save();const{stroke:s,xSize:o,ySize:a,opName:h}=this.commonRenderProps(t,e,r,n,i),l=o/2,c=a/2;t[`${h}Rect`](-l,-c,o,a),s&&t.strokeRect(-l,-c,o,a),t.restore()}class ri{constructor(e){t(this,"visible",!0),t(this,"actionName",U),t(this,"angle",0),t(this,"x",0),t(this,"y",0),t(this,"offsetX",0),t(this,"offsetY",0),t(this,"sizeX",0),t(this,"sizeY",0),t(this,"touchSizeX",0),t(this,"touchSizeY",0),t(this,"cursorStyle","crosshair"),t(this,"withConnection",!1),Object.assign(this,e)}getTransformAnchorPoint(){var t;return null!==(t=this.transformAnchorPoint)&&void 0!==t?t:new ot(.5-this.x,.5-this.y)}shouldActivate(t,e,r,i){var n;let{tl:s,tr:o,br:a,bl:h}=i;return(null===(n=e.canvas)||void 0===n?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&&Wr.isPointInPolygon(r,[s,o,a,h])}getActionHandler(t,e,r){return this.actionHandler}getMouseDownHandler(t,e,r){return this.mouseDownHandler}getMouseUpHandler(t,e,r){return this.mouseUpHandler}cursorStyleHandler(t,e,r,i){return e.cursorStyle}getActionName(t,e,r){return e.actionName}getVisibility(t,e){var r,i;return null!==(r=null===(i=t._controlsVisibility)||void 0===i?void 0:i[e])&&void 0!==r?r:this.visible}setVisibility(t,e,r){this.visible=t}positionHandler(t,e,r,i){return new ot(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,i,n,s){const o=kt([Pt(r,i),Nt({angle:t}),Ot((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new ot(-.5,-.5).transform(o),tr:new ot(.5,-.5).transform(o),br:new ot(.5,.5).transform(o),bl:new ot(-.5,.5).transform(o)}}commonRenderProps(t,e,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const{cornerSize:s,cornerColor:o,transparentCorners:a,cornerStrokeColor:h}=n,l=s||i.cornerSize,c=this.sizeX||l,u=this.sizeY||l,f=void 0!==a?a:i.transparentCorners,d=f?X:Y,p=h||i.cornerStrokeColor,g=!f&&!!p;return t.fillStyle=o||i.cornerColor||"",t.strokeStyle=p||"",t.translate(e,r),t.rotate(wt(i.getTotalAngle())),{stroke:g,xSize:c,ySize:u,transparentCorners:f,opName:d}}render(t,e,r,i,n){"circle"===((i=i||{}).cornerStyle||n.cornerStyle)?ti.call(this,t,e,r,i,n):ei.call(this,t,e,r,i,n)}}const ii=(t,e,r)=>r.lockRotation?Ie:e.cursorStyle,ni=Xr(D,Gr((t,e,r,i)=>{let{target:n,ex:s,ey:o,theta:a,originX:h,originY:l}=e;const c=n.getPositionByOrigin(h,l);if(ze(n,"lockRotation"))return!1;const u=Math.atan2(o-c.y,s-c.x),f=Math.atan2(i-c.y,r-c.x);let d=_t(f-u+a);if(n.snapAngle&&n.snapAngle>0){const t=n.snapAngle,e=n.snapThreshold||t,r=Math.ceil(d/t)*t,i=Math.floor(d/t)*t;Math.abs(d-i)<e?d=i:Math.abs(d-r)<e&&(d=r)}d<0&&(d=360+d),d%=360;const p=n.angle!==d;return n.angle=d,p}));function si(t,e){const r=e.canvas,i=t[r.uniScaleKey];return r.uniformScaling&&!i||!r.uniformScaling&&i}function oi(t,e,r){const i=ze(t,"lockScalingX"),n=ze(t,"lockScalingY");if(i&&n)return!0;if(!e&&(i||n)&&r)return!0;if(i&&"x"===e)return!0;if(n&&"y"===e)return!0;const{width:s,height:o,strokeWidth:a}=t;return 0===s&&0===a&&"y"!==e||0===o&&0===a&&"x"!==e}const ai=["e","se","s","sw","w","nw","n","ne","e"],hi=(t,e,r,i)=>{const n=si(t,r);if(oi(r,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",n))return Ie;const s=qe(r,0,i);return`${ai[s]}-resize`};function li(t,e,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s=e.target,o=n.by,a=si(t,s);let h,l,c,u,f,d;if(oi(s,o,a))return!1;if(e.gestureScale)l=e.scaleX*e.gestureScale,c=e.scaleY*e.gestureScale;else{if(h=We(e,e.originX,e.originY,r,i),f="y"!==o?Math.sign(h.x||e.signX||1):1,d="x"!==o?Math.sign(h.y||e.signY||1):1,e.signX||(e.signX=f),e.signY||(e.signY=d),ze(s,"lockScalingFlip")&&(e.signX!==f||e.signY!==d))return!1;if(u=s._getTransformedDimensions(),a&&!o){const t=Math.abs(h.x)+Math.abs(h.y),{original:r}=e,i=t/(Math.abs(u.x*r.scaleX/s.scaleX)+Math.abs(u.y*r.scaleY/s.scaleY));l=r.scaleX*i,c=r.scaleY*i}else l=Math.abs(h.x*s.scaleX/u.x),c=Math.abs(h.y*s.scaleY/u.y);Be(e)&&(l*=2,c*=2),e.signX!==f&&"y"!==o&&(e.originX=Re(e.originX),l*=-1,e.signX=f),e.signY!==d&&"x"!==o&&(e.originY=Re(e.originY),c*=-1,e.signY=d)}const p=s.scaleX,g=s.scaleY;return o?("x"===o&&s.set(q,l),"y"===o&&s.set(W,c)):(!ze(s,"lockScalingX")&&s.set(q,l),!ze(s,"lockScalingY")&&s.set(W,c)),p!==s.scaleX||g!==s.scaleY}const ci=Xr(M,Gr((t,e,r,i)=>li(t,e,r,i))),ui=Xr(M,Gr((t,e,r,i)=>li(t,e,r,i,{by:"x"}))),fi=Xr(M,Gr((t,e,r,i)=>li(t,e,r,i,{by:"y"}))),di={x:{counterAxis:"y",scale:q,skew:H,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:W,skew:V,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},pi=["ns","nesw","ew","nwse"],gi=(t,e,r,i)=>{if(0!==e.x&&ze(r,"lockSkewingY"))return Ie;if(0!==e.y&&ze(r,"lockSkewingX"))return Ie;const n=qe(r,0,i)%4;return`${pi[n]}-resize`};function mi(t,e,r,i,n){const{target:s}=r,{counterAxis:o,origin:a,lockSkewing:h,skew:l,flip:c}=di[t];if(ze(s,h))return!1;const{origin:u,flip:f}=di[o],d=Ce(r[u])*(s[f]?-1:1),p=-Math.sign(d)*(s[c]?-1:1),g=-(0===s[l]&&We(r,A,A,i,n)[t]>0||s[l]>0?1:-1)*p*.5+.5,m=Xr(j,Gr((e,r,i,n)=>function(t,e,r){let{target:i,ex:n,ey:s,skewingSide:o,...a}=e;const{skew:h}=di[t],l=r.subtract(new ot(n,s)).divide(new ot(i.scaleX,i.scaleY))[t],c=i[h],u=a[h],f=Math.tan(wt(u)),d="y"===t?i._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:i._getTransformedDimensions({scaleX:1,scaleY:1}).y,p=2*l*o/Math.max(d,1)+f,g=_t(Math.atan(p));i.set(h,g);const m=c!==i[h];if(m&&"y"===t){const{skewX:t,scaleX:e}=i,r=i._getTransformedDimensions({skewY:c}),n=i._getTransformedDimensions(),s=0!==t?r.x/n.x:1;1!==s&&i.set(q,s*e)}return m}(t,r,new ot(i,n))));return m(e,{...r,[a]:g,skewingSide:p},i,n)}const vi=(t,e,r,i)=>mi("x",t,e,r,i),yi=(t,e,r,i)=>mi("y",t,e,r,i);function bi(t,e){return t[e.canvas.altActionKey]}const wi=(t,e,r)=>{const i=bi(t,r);return 0===e.x?i?H:W:0===e.y?i?V:q:""},_i=(t,e,r,i)=>bi(t,r)?gi(0,e,r,i):hi(t,e,r,i),xi=(t,e,r,i)=>bi(t,e.target)?yi(t,e,r,i):ui(t,e,r,i),Si=(t,e,r,i)=>bi(t,e.target)?vi(t,e,r,i):fi(t,e,r,i),Ci=()=>({ml:new ri({x:-.5,y:0,cursorStyleHandler:_i,actionHandler:xi,getActionName:wi}),mr:new ri({x:.5,y:0,cursorStyleHandler:_i,actionHandler:xi,getActionName:wi}),mb:new ri({x:0,y:.5,cursorStyleHandler:_i,actionHandler:Si,getActionName:wi}),mt:new ri({x:0,y:-.5,cursorStyleHandler:_i,actionHandler:Si,getActionName:wi}),tl:new ri({x:-.5,y:-.5,cursorStyleHandler:hi,actionHandler:ci}),tr:new ri({x:.5,y:-.5,cursorStyleHandler:hi,actionHandler:ci}),bl:new ri({x:-.5,y:.5,cursorStyleHandler:hi,actionHandler:ci}),br:new ri({x:.5,y:.5,cursorStyleHandler:hi,actionHandler:ci}),mtr:new ri({x:0,y:-.5,actionHandler:ni,cursorStyleHandler:ii,offsetY:-40,withConnection:!0,actionName:F})}),Ai=()=>({mr:new ri({x:.5,y:0,actionHandler:Zr,cursorStyleHandler:_i,actionName:I}),ml:new ri({x:-.5,y:0,actionHandler:Zr,cursorStyleHandler:_i,actionName:I})}),ki=()=>({...Ci(),...Ai()});class Li extends Vr{static getDefaults(){return{...super.getDefaults(),...Li.ownDefaults}}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Li.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Ci()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,r=e.target,i=e.action;if(this===r&&i&&i.startsWith(U))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const r=Object.entries(this.oCoords);for(let i=r.length-1;i>=0;i--){const[n,s]=r[i],o=this.controls[n];if(o.shouldActivate(n,this,t,e?s.touchCorner:s.corner))return this.__corner=n,{key:n,control:o,coord:this.oCoords[n]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),r=Pt(e.x,e.y),i=Nt({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=At(r,i),s=At(t,n),o=At(s,[1/t[0],0,0,1/t[3],0,0]),a=this.group?Tt(this.calcTransformMatrix()):void 0;a&&(a.scaleX=Math.abs(a.scaleX),a.scaleY=Math.abs(a.scaleY));const h=this._calculateCurrentDimensions(a),l={};return this.forEachControl((t,e)=>{const r=t.positionHandler(h,o,this,t);l[e]=Object.assign(r,this._calcCornerCoords(t,r))}),l}_calcCornerCoords(t,e){const r=this.getTotalAngle();return{corner:t.calcCornerCoords(r,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(r,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),r=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(wt(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-r.x/2,-r.y/2,r.x,r.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray,...r};t.save(),t.strokeStyle=i.borderColor,this._setLineDash(t,i.borderDashArray),this.strokeBorders(t,e),i.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{hasBorders:r,hasControls:i}=this,n={hasBorders:r,hasControls:i,...e},s=this.getViewportTransform(),o=n.hasBorders,a=n.hasControls,h=At(s,this.calcTransformMatrix()),l=Tt(h);t.save(),t.translate(l.translateX,l.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(l.angle-=180),t.rotate(wt(this.group?l.angle:this.angle)),o&&this.drawBorders(t,l,e),a&&this.drawControls(t,e),t.restore()}drawBorders(t,e,r){let i;if(r&&r.forActiveSelection||this.group){const t=ye(this.width,this.height,Ft(e)),r=this.isStrokeAccountedForInDimensions()?at:(this.strokeUniform?(new ot).scalarAdd(this.canvas?this.canvas.getZoom():1):new ot(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);i=t.add(r).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else i=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,i,r)}drawControlsConnectingLines(t,e){let r=!1;t.beginPath(),this.forEachControl((i,n)=>{i.withConnection&&i.getVisibility(this,n)&&(r=!0,t.moveTo(i.x*e.x,i.y*e.y),t.lineTo(i.x*e.x+i.offsetX,i.y*e.y+i.offsetY))}),r&&t.stroke()}drawControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.save();const r=this.getCanvasRetinaScaling(),{cornerStrokeColor:i,cornerDashArray:n,cornerColor:s}=this,o={cornerStrokeColor:i,cornerDashArray:n,cornerColor:s,...e};t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=o.cornerColor,this.transparentCorners||(t.strokeStyle=o.cornerStrokeColor),this._setLineDash(t,o.cornerDashArray),this.forEachControl((e,r)=>{if(e.getVisibility(this,r)){const i=this.oCoords[r];e.render(t,i.x,i.y,o,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.entries(t).forEach(t=>{let[e,r]=t;return this.setControlVisible(e,r)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const r=this.canvas.viewportTransform;e.save(),e.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this.transform(e);const i=this.width+4,n=this.height+4;return e.clearRect(-i/2,-n/2,i,n),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Ti(t,e){return e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{"constructor"!==r&&Object.defineProperty(t.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))})}),t}t(Li,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Pi extends Li{}Ti(Pi,[er]),tt.setClass(Pi),tt.setClass(Pi,"object");const Ni=(t,e,r,i)=>{const n=2*(i=Math.round(i))+1,{data:s}=t.getImageData(e-i,r-i,n,n);for(let t=3;t<s.length;t+=4)if(s[t]>0)return!1;return!0};class Oi{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new ot(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new ot(1/this.options.scaleX,1/this.options.scaleY):new ot(1,1)}createSideVector(t,e){const r=Te(t,e);return this.options.strokeUniform?r.multiply(this.scale):r}projectOrthogonally(t,e,r){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,r)))}isSkewed(){return 0!==this.options.skewX||0!==this.options.skewY}applySkew(t){const e=new ot(t);return e.y+=e.x*Math.tan(wt(this.options.skewY)),e.x+=e.y*Math.tan(wt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Ei=new ot;class Mi extends Oi{static getOrthogonalRotationFactor(t,e){const r=e?Ne(t,e):Oe(t);return Math.abs(r)<y?-1:1}constructor(e,r,i,n){super(n),t(this,"AB",void 0),t(this,"AC",void 0),t(this,"alpha",void 0),t(this,"bisector",void 0),this.A=new ot(e),this.B=new ot(r),this.C=new ot(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=Ne(this.AB,this.AC),this.bisector=Ee(Le(this.AB.eq(Ei)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),n=Me(i),s=Mi.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,r*s)}projectBevel(){const t=[];return(this.alpha%w===0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){const t=[],e=Math.abs(this.alpha),r=1/Math.sin(e/2),i=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*r),n=this.options.strokeUniform?Pe(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Pe(i)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const r=[],i=new ot(Mi.getOrthogonalRotationFactor(this.bisector),Mi.getOrthogonalRotationFactor(new ot(this.bisector.y,this.bisector.x)));return[new ot(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new ot(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(i=>{je(i,t,e)&&r.push(this.A.add(i))}),r}projectRoundWithSkew(t,e){const r=[],{skewX:i,skewY:n,scaleX:s,scaleY:o,strokeUniform:a}=this.options,h=new ot(Math.tan(wt(i)),Math.tan(wt(n))),l=this.strokeProjectionMagnitude,c=a?l/o/Math.sqrt(1/o**2+1/s**2*h.y**2):l/Math.sqrt(1+h.y**2),u=new ot(Math.sqrt(Math.max(l**2-c**2,0)),c),f=a?l/Math.sqrt(1+h.x**2*(1/o)**2/(1/s+1/s*h.x*h.y)**2):l/Math.sqrt(1+h.x**2/(1+h.x*h.y)**2),d=new ot(f,Math.sqrt(Math.max(l**2-f**2,0)));return[d,d.scalarMultiply(-1),u,u.scalarMultiply(-1)].map(t=>this.applySkew(a?t.multiply(this.strokeUniformScalar):t)).forEach(i=>{je(i,t,e)&&r.push(this.applySkew(this.A).add(i))}),r}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%w===0,r=this.applySkew(this.A),i=t[e?0:2].subtract(r),n=t[e?1:0].subtract(r),s=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),o=De(i,s)>0,a=o?i:n,h=o?n:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(a,h)):t.push(...this.projectRoundNoSkew(a,h)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class Di extends Oi{constructor(t,e,r){super(r),this.A=new ot(t),this.T=new ot(e)}calcOrthogonalProjection(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e);return this.scaleUnitVector(Me(i),r)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new ot(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new Mi(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new ot(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),r=this.scaleUnitVector(Ee(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(r);t.push(i.add(e),i.subtract(e))}return t.map(t=>this.applySkew(t))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const Fi=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=[];if(0===t.length)return i;const n=t.reduce((t,e)=>(t[t.length-1].eq(e)||t.push(new ot(e)),t),[new ot(t[0])]);if(1===n.length)r=!0;else if(!r){const t=n[0],e=((t,e)=>{for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1})(n,e=>!e.eq(t));n.splice(e+1)}return n.forEach((t,n,s)=>{let o,a;0===n?(a=s[1],o=r?t:s[s.length-1]):n===s.length-1?(o=s[n-1],a=r?t:s[0]):(o=s[n-1],a=s[n+1]),r&&1===s.length?i.push(...new Di(t,t,e).project()):!r||0!==n&&n!==s.length-1?i.push(...new Mi(t,o,a,e).project()):i.push(...new Di(t,0===n?a:o,e).project())}),i},ji=t=>{const e={};return Object.keys(t).forEach(r=>{e[r]={},Object.keys(t[r]).forEach(i=>{e[r][i]={...t[r][i]}})}),e},Ii=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.textDecorationThickness!==e.textDecorationThickness||t.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||r&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},Bi=(t,e)=>{const r=e.split("\n"),i=[];let n=-1,s={};t=ji(t);for(let e=0;e<r.length;e++){const o=ne(r[e]);if(t[e])for(let r=0;r<o.length;r++){n++;const o=t[e][r];o&&Object.keys(o).length>0&&(Ii(s,o,!0)?i.push({start:n,end:n+1,style:o}):i[i.length-1].end++),s=o||{}}else n+=o.length,s={}}return i},Ri=(t,e)=>{if(!Array.isArray(t))return ji(t);const r=e.split(O),i={};let n=-1,s=0;for(let e=0;e<r.length;e++){const o=ne(r[e]);for(let r=0;r<o.length;r++)n++,t[s]&&t[s].start<=n&&n<t[s].end&&(i[e]=i[e]||{},i[e][r]={...t[s].style},n===t[s].end-1&&s++)}return i},zi=["display","transform",Y,"fill-opacity","fill-rule","opacity",X,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function Ui(t,e){const r=t.nodeName,i=t.getAttribute("class"),n=t.getAttribute("id"),s="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+r,"i"),e=e.replace(o,""),n&&e.length&&(o=new RegExp("#"+n+s,"i"),e=e.replace(o,"")),i&&e.length){const t=i.split(" ");for(let r=t.length;r--;)o=new RegExp("\\."+t[r]+s,"i"),e=e.replace(o,"")}return 0===e.length}function qi(t,e){let r=!0;const i=Ui(t,e.pop());return i&&e.length&&(r=function(t,e){let r,i=!0;for(;t.parentElement&&1===t.parentElement.nodeType&&e.length;)i&&(r=e.pop()),i=Ui(t=t.parentElement,r);return 0===e.length}(t,e)),i&&r&&0===e.length}function Wi(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={};for(const i in e)qi(t,i.split(" "))&&(r={...r,...e[i]});return r}const Hi=t=>{var e;return null!==(e=vr[t])&&void 0!==e?e:t},Vi=new RegExp(`(${pr})`,"gi"),Yi=`(${pr})`,Xi=String.raw`(skewX)\(${Yi}\)`,Gi=String.raw`(skewY)\(${Yi}\)`,$i=String.raw`(rotate)\(${Yi}(?: ${Yi} ${Yi})?\)`,Ki=String.raw`(scale)\(${Yi}(?: ${Yi})?\)`,Ji=String.raw`(translate)\(${Yi}(?: ${Yi})?\)`,Zi=`(?:${String.raw`(matrix)\(${Yi} ${Yi} ${Yi} ${Yi} ${Yi} ${Yi}\)`}|${Ji}|${$i}|${Ki}|${Xi}|${Gi})`,Qi=`(?:${Zi}*)`,tn=String.raw`^\s*(?:${Qi}?)\s*$`,en=new RegExp(tn),rn=new RegExp(Zi),nn=new RegExp(Zi,"g");function sn(t){const e=[];if(!(t=(t=>He(t.replace(Vi," $1 ").replace(/,/gi," ")))(t).replace(/\s*([()])\s*/gi,"$1"))||t&&!en.test(t))return[...x];for(const r of t.matchAll(nn)){const t=rn.exec(r[0]);if(!t)continue;let i=x;const n=t.filter(t=>!!t),[,s,...o]=n,[a,h,l,c,u,f]=o.map(t=>parseFloat(t));switch(s){case"translate":i=Pt(a,h);break;case F:i=Nt({angle:a},{x:h,y:l});break;case U:i=Ot(a,h);break;case H:i=Mt(a);break;case V:i=Dt(a);break;case"matrix":i=[a,h,l,c,u,f]}e.push(i)}return kt(e)}function on(t,e,r,i){const n=Array.isArray(e);let s,o=e;if(t!==Y&&t!==X||e!==N){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o=e===N?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=r&&r.transformMatrix?At(r.transformMatrix,sn(e)):sn(e);else if("visible"===t)o=e!==N&&"hidden"!==e,r&&!1===r.visible&&(o=!1);else if("opacity"===t)o=parseFloat(e),r&&void 0!==r.opacity&&(o*=r.opacity);else if("textAnchor"===t)o="start"===e?k:"end"===e?P:A;else if("charSpacing"===t||t===ir)s=Ze(e,i)/i*1e3;else if("paintFirst"===t){const t=e.indexOf(Y),r=e.indexOf(X);o=Y,(t>-1&&r>-1&&r<t||-1===t&&r>-1)&&(o=X)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;s=n?e.map(Ze):Ze(e,i)}}else o="";return!n&&isNaN(s)?o:s}function an(t){const e={},r=t.getAttribute("style");return r?("string"==typeof r?function(t,e){t.replace(/;\s*$/,"").split(";").forEach(t=>{if(!t)return;const[r,i]=t.split(":");e[r.trim().toLowerCase()]=i.trim()})}(r,e):function(t,e){Object.entries(t).forEach(t=>{let[r,i]=t;void 0!==i&&(e[r.toLowerCase()]=i)})}(r,e),e):e}const hn={stroke:"strokeOpacity",fill:"fillOpacity"};function ln(t,e,r){if(!t)return{};let i,n={},s=S;t.parentNode&&wr.test(t.parentNode.nodeName)&&(n=ln(t.parentElement,e,r),n.fontSize&&(i=s=Ze(n.fontSize)));const o={...e.reduce((e,r)=>{const i=t.getAttribute(r);return i&&(e[r]=i),e},{}),...Wi(t,r),...an(t)};o[br]&&t.setAttribute(br,o[br]),o[yr]&&(i=Ze(o[yr],s),o[yr]=`${i}`);const a={};for(const t in o){const e=Hi(t),r=on(e,o[t],n,i);a[e]=r}a&&a.font&&function(t,e){const r=t.match(mr);if(!r)return;const i=r[1],n=r[3],s=r[4],o=r[5],a=r[6];i&&(e.fontStyle=i),n&&(e.fontWeight=isNaN(parseFloat(n))?n:parseFloat(n)),s&&(e.fontSize=Ze(s)),a&&(e.fontFamily=a),o&&(e.lineHeight=o===J?1:o)}(a.font,a);const h={...n,...a};return wr.test(t.nodeName)?h:function(t){const e=Pi.getDefaults();return Object.entries(hn).forEach(r=>{let[i,n]=r;if(void 0===t[n]||""===t[i])return;if(void 0===t[i]){if(!e[i])return;t[i]=e[i]}if(0===t[i].indexOf("url("))return;const s=new Je(t[i]);t[i]=s.setAlpha(qt(s.getAlpha()*t[n],2)).toRgba()}),t}(h)}const cn=["rx","ry"];class un extends Pi{static getDefaults(){return{...super.getDefaults(),...un.ownDefaults}}constructor(t){super(),Object.assign(this,un.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:r}=this,i=-e/2,n=-r/2,s=this.rx?Math.min(this.rx,e/2):0,o=this.ry?Math.min(this.ry,r/2):0,a=0!==s||0!==o;t.beginPath(),t.moveTo(i+s,n),t.lineTo(i+e-s,n),a&&t.bezierCurveTo(i+e-C*s,n,i+e,n+C*o,i+e,n+o),t.lineTo(i+e,n+r-o),a&&t.bezierCurveTo(i+e,n+r-C*o,i+e-C*s,n+r,i+e-s,n+r),t.lineTo(i+s,n+r),a&&t.bezierCurveTo(i+C*s,n+r,i,n+r-C*o,i,n+r-o),t.lineTo(i,n+o),a&&t.bezierCurveTo(i,n+C*o,i+C*s,n,i+s,n),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...cn,...t])}_toSVG(){const{width:t,height:e,rx:r,ry:i}=this;return["<rect ","COMMON_PARTS",`x="${-t/2}" y="${-e/2}" rx="${re(r)}" ry="${re(i)}" width="${re(t)}" height="${re(e)}" />\n`]}static async fromElement(t,e,r){const{left:i=0,top:n=0,width:s=0,height:o=0,visible:a=!0,...h}=ln(t,this.ATTRIBUTE_NAMES,r);return new this({...e,...h,left:i,top:n,width:s,height:o,visible:Boolean(a&&s&&o)})}}t(un,"type","Rect"),t(un,"cacheProperties",[...kr,...cn]),t(un,"ownDefaults",{rx:0,ry:0}),t(un,"ATTRIBUTE_NAMES",[...zi,"x","y","rx","ry","width","height"]),tt.setClass(un),tt.setSVGClass(un);const fn="initialization",dn="added",pn="removed",gn="imperative",mn=(t,e)=>{const{strokeUniform:r,strokeWidth:i,width:n,height:s,group:o}=e,a=o&&o!==t?be(o.calcTransformMatrix(),t.calcTransformMatrix()):null,h=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),l=!e.isStrokeAccountedForInDimensions(),c=r&&l?_e(new ot(i,i),void 0,t.calcTransformMatrix()):at,u=!r&&l?i:0,f=ye(n+u,s+u,kt([a,e.calcOwnMatrix()],!0)).add(c).scalarDivide(2);return[h.subtract(f),h.add(f)]};class vn{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:i}=t;return e===fn||e===gn||!!r&&i!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==fn&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:r,target:i}=e;if(r===gn&&e.overrides)return e.overrides;if(0===t.length)return;const{left:n,top:s,width:o,height:a}=de(t.map(t=>mn(i,t)).reduce((t,e)=>t.concat(e),[])),h=new ot(o,a),l=new ot(n,s).add(h.scalarDivide(2));if(r===fn){const t=this.getInitialSize(e,{size:h,center:l});return{center:l,relativeCorrection:new ot(0,0),size:t}}return{center:l.transform(i.calcOwnMatrix()),size:h}}}t(vn,"type","strategy");class yn extends vn{shouldPerformLayout(t){return!0}}t(yn,"type","fit-content"),tt.setClass(yn);const bn="layoutManager";class wn{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new yn;t(this,"strategy",void 0),this.strategy=e,this._subscriptions=new Map}performLayout(t){const e={bubbles:!0,strategy:this.strategy,...t,prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}};this.onBeforeLayout(e);const r=this.getLayoutResult(e);r&&this.commitLayout(e,r),this.onAfterLayout(e,r),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:r}=e;return[G,E,I,D,M,j,z,B,R].map(e=>t.on(e,t=>this.performLayout(e===G?{type:"object_modified",trigger:e,e:t,target:r}:{type:"object_modifying",trigger:e,e:t,target:r})))}subscribe(t,e){this.unsubscribe(t,e);const r=this.attachHandlers(t,e);this._subscriptions.set(t,r)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(t=>t()),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach(e=>this.unsubscribe(e,t))}subscribeTargets(t){t.targets.forEach(e=>this.subscribe(e,t))}onBeforeLayout(t){const{target:e,type:r}=t,{canvas:i}=e;if(r===fn||r===dn?this.subscribeTargets(t):r===pn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),i&&i.fire("object:layout:before",{target:e,context:t}),r===gn&&t.deep){const{strategy:r,...i}=t;e.forEachObject(t=>t.layoutManager&&t.layoutManager.performLayout({...i,bubbles:!1,target:t}))}}getLayoutResult(t){const{target:e,strategy:r,type:i}=t,n=r.calcLayoutResult(t,e.getObjects());if(!n)return;const s=i===fn?new ot:e.getRelativeCenterPoint(),{center:o,correction:a=new ot,relativeCorrection:h=new ot}=n,l=s.subtract(o).add(a).transform(i===fn?x:Ct(e.calcOwnMatrix()),!0).add(h);return{result:n,prevCenter:s,nextCenter:o,offset:l}}commitLayout(t,e){const{target:r}=t,{result:{size:i},nextCenter:n}=e;var s,o;r.set({width:i.x,height:i.y}),this.layoutObjects(t,e),t.type===fn?r.set({left:null!==(s=t.x)&&void 0!==s?s:n.x+i.x*Ce(r.originX),top:null!==(o=t.y)&&void 0!==o?o:n.y+i.y*Ce(r.originY)}):(r.setPositionByOrigin(n,A,A),r.setCoords(),r.set("dirty",!0))}layoutObjects(t,e){const{target:r}=t;r.forEachObject(i=>{i.group===r&&this.layoutObject(t,e,i)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,r.clipPath)}layoutObject(t,e,r){let{offset:i}=e;r.set({left:r.left+i.x,top:r.top+i.y})}onAfterLayout(t,e){const{target:r,strategy:i,bubbles:n,prevStrategy:s,...o}=t,{canvas:a}=r;r.fire("layout:after",{context:t,result:e}),a&&a.fire("object:layout:after",{context:t,result:e,target:r});const h=r.parent;n&&null!=h&&h.layoutManager&&((o.path||(o.path=[])).push(r),h.layoutManager.performLayout({...o,target:h})),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(t=>t.forEach(t=>t())),t.clear()}toObject(){return{type:bn,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}tt.setClass(wn,bn);class xn extends wn{performLayout(){}}class Sn extends(lt(Pi)){static getDefaults(){return{...super.getDefaults(),...Sn.ownDefaults}}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),t(this,"_activeObjects",[]),t(this,"__objectSelectionTracker",void 0),t(this,"__objectSelectionDisposer",void 0),Object.assign(this,Sn.ownDefaults),this.setOptions(r),this.groupInit(e,r)}groupInit(t,e){var r;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(t=>{this.enterGroup(t,!1)}),this.layoutManager=null!==(r=e.layoutManager)&&void 0!==r?r:new wn,this.layoutManager.performLayout({type:fn,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(i("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(i("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((t,e,r)=>this.canEnterGroup(t)&&r.indexOf(t)===e)}add(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];const i=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...i);return this._onAfterObjectsChange(dn,i),n}insertAt(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];const n=this._filterObjectsBeforeEnteringGroup(r),s=super.insertAt(t,...n);return this._onAfterObjectsChange(dn,n),s}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(pn,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const r=this[t];return super._set(t,e),"canvas"===t&&r!==e&&(this._objects||[]).forEach(r=>{r._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:r}=e;const i=this._activeObjects;if(t)i.push(r),this._set("dirty",!0);else if(i.length>0){const t=i.indexOf(r);t>-1&&(i.splice(t,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&ge(t,At(Ct(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const r=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();r&&(r===t||t.isDescendantOf(r))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(ge(t,At(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const r=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;r>-1&&this._activeObjects.splice(r,1)}shouldCache(){const t=Pi.prototype.shouldCache.call(this);if(t)for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return this.ownCaching=!1,!1;return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,r){this._renderBackground(t);for(let e=0;e<this._objects.length;e++){var i;const r=this._objects[e];null!==(i=this.canvas)&&void 0!==i&&i.preserveObjectStacking&&r.group!==this?(t.save(),t.transform(...Ct(this.calcTransformMatrix())),r.render(t),t.restore()):r.group===this&&r.render(t)}this._drawClipPath(t,this.clipPath,r)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout({target:this,type:gn,...t})}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const r=this.includeDefaultValues;return this._objects.filter(function(t){return!t.excludeFromExport}).map(function(i){const n=i.includeDefaultValues;i.includeDefaultValues=r;const s=i[t||"toObject"](e);return i.includeDefaultValues=n,s})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.layoutManager.toObject();return{...super.toObject(["subTargetCheck","interactive",...t]),..."fit-content"!==e.strategy||this.includeDefaultValues?{layoutManager:e}:{},objects:this.__serializeObjects("toObject",t)}}toString(){return`#<Group: (${this.complexity()})>`}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(t=>{this._watchObject(!1,t),t.dispose()}),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=un.prototype._toSVG.call(this),r=e.indexOf("COMMON_PARTS");e[r]='for="group" ';const i=e.join("");return t?t(i):i}_toSVG(t){const e=["<g ","COMMON_PARTS"," >\n"],r=this._createSVGBgRect(t);r&&e.push("\t\t",r);for(let r=0;r<this._objects.length;r++)e.push("\t\t",this._objects[r].toSVG(t));return e.push("</g>\n"),e}getSvgStyles(){const t=void 0!==this.opacity&&1!==this.opacity?`opacity: ${re(this.opacity)};`:"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],r=this._createSVGBgRect(t);r&&e.push("\t",r);for(let r=0;r<this._objects.length;r++)e.push("\t",this._objects[r].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:r,objects:i=[],layoutManager:n,...s}=t;return Promise.all([Bt(i,e),Rt(s,e)]).then(t=>{let[e,r]=t;const i=new this(e,{...s,...r,layoutManager:new xn});if(n){const t=tt.getClass(n.type),e=tt.getClass(n.strategy);i.layoutManager=new t(new e)}else i.layoutManager=new wn;return i.layoutManager.subscribeTargets({type:fn,target:i,targets:i.getObjects()}),i.setCoords(),i})}}t(Sn,"type","Group"),t(Sn,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),tt.setClass(Sn);const Cn=(t,e)=>Math.min(e.width/t.width,e.height/t.height),An=(t,e)=>Math.max(e.width/t.width,e.height/t.height),kn="\\s*,?\\s*",Ln=`${kn}(${pr})`,Tn=`${Ln}${Ln}${Ln}${kn}([01])${kn}([01])${Ln}${Ln}`,Pn={m:"l",M:"L"},Nn=(t,e,r,i,n,s,o,a,h,l,c)=>{const u=nt(t),f=st(t),d=nt(e),p=st(e),g=r*n*d-i*s*p+o,m=i*n*d+r*s*p+a;return["C",l+h*(-r*n*f-i*s*u),c+h*(-i*n*f+r*s*u),g+h*(r*n*p+i*s*d),m+h*(i*n*p-r*s*d),g,m]},On=(t,e,r,i)=>{const n=Math.atan2(e,t),s=Math.atan2(i,r);return s>=n?s-n:2*Math.PI-(n-s)};function En(t,e,i,n,s,o,a,h){let l;if(r.cachesBoundsOfCurve&&(l=[...arguments].join(),g.boundsOfCurveCache[l]))return g.boundsOfCurveCache[l];const c=Math.sqrt,u=Math.abs,f=[],d=[[0,0],[0,0]];let p=6*t-12*i+6*s,m=-3*t+9*i-9*s+3*a,v=3*i-3*t;for(let t=0;t<2;++t){if(t>0&&(p=6*e-12*n+6*o,m=-3*e+9*n-9*o+3*h,v=3*n-3*e),u(m)<1e-12){if(u(p)<1e-12)continue;const t=-v/p;0<t&&t<1&&f.push(t);continue}const r=p*p-4*v*m;if(r<0)continue;const i=c(r),s=(-p+i)/(2*m);0<s&&s<1&&f.push(s);const a=(-p-i)/(2*m);0<a&&a<1&&f.push(a)}let y=f.length;const b=y,w=jn(t,e,i,n,s,o,a,h);for(;y--;){const{x:t,y:e}=w(f[y]);d[0][y]=t,d[1][y]=e}d[0][b]=t,d[1][b]=e,d[0][b+1]=a,d[1][b+1]=h;const _=[new ot(Math.min(...d[0]),Math.min(...d[1])),new ot(Math.max(...d[0]),Math.max(...d[1]))];return r.cachesBoundsOfCurve&&(g.boundsOfCurveCache[l]=_),_}const Mn=(t,e,r)=>{let[i,n,s,o,a,h,l,c]=r;const u=((t,e,r,i,n,s,o)=>{if(0===r||0===i)return[];let a=0,h=0,l=0;const c=Math.PI,u=o*_,f=st(u),d=nt(u),p=.5*(-d*t-f*e),g=.5*(-d*e+f*t),m=r**2,v=i**2,y=g**2,b=p**2,w=m*v-m*y-v*b;let x=Math.abs(r),S=Math.abs(i);if(w<0){const t=Math.sqrt(1-w/(m*v));x*=t,S*=t}else l=(n===s?-1:1)*Math.sqrt(w/(m*y+v*b));const C=l*x*g/S,A=-l*S*p/x,k=d*C-f*A+.5*t,L=f*C+d*A+.5*e;let T=On(1,0,(p-C)/x,(g-A)/S),P=On((p-C)/x,(g-A)/S,(-p-C)/x,(-g-A)/S);0===s&&P>0?P-=2*c:1===s&&P<0&&(P+=2*c);const N=Math.ceil(Math.abs(P/c*2)),O=[],E=P/N,M=8/3*Math.sin(E/4)*Math.sin(E/4)/Math.sin(E/2);let D=T+E;for(let t=0;t<N;t++)O[t]=Nn(T,D,d,f,x,S,k,L,M,a,h),a=O[t][5],h=O[t][6],T=D,D+=E;return O})(l-t,c-e,n,s,a,h,o);for(let r=0,i=u.length;r<i;r++)u[r][1]+=t,u[r][2]+=e,u[r][3]+=t,u[r][4]+=e,u[r][5]+=t,u[r][6]+=e;return u},Dn=t=>{let e=0,r=0,i=0,n=0;const s=[];let o,a=0,h=0;for(const l of t){const t=[...l];let c;switch(t[0]){case"l":t[1]+=e,t[2]+=r;case"L":e=t[1],r=t[2],c=["L",e,r];break;case"h":t[1]+=e;case"H":e=t[1],c=["L",e,r];break;case"v":t[1]+=r;case"V":r=t[1],c=["L",e,r];break;case"m":t[1]+=e,t[2]+=r;case"M":e=t[1],r=t[2],i=t[1],n=t[2],c=["M",e,r];break;case"c":t[1]+=e,t[2]+=r,t[3]+=e,t[4]+=r,t[5]+=e,t[6]+=r;case"C":a=t[3],h=t[4],e=t[5],r=t[6],c=["C",t[1],t[2],a,h,e,r];break;case"s":t[1]+=e,t[2]+=r,t[3]+=e,t[4]+=r;case"S":"C"===o?(a=2*e-a,h=2*r-h):(a=e,h=r),e=t[3],r=t[4],c=["C",a,h,t[1],t[2],e,r],a=c[3],h=c[4];break;case"q":t[1]+=e,t[2]+=r,t[3]+=e,t[4]+=r;case"Q":a=t[1],h=t[2],e=t[3],r=t[4],c=["Q",a,h,e,r];break;case"t":t[1]+=e,t[2]+=r;case"T":"Q"===o?(a=2*e-a,h=2*r-h):(a=e,h=r),e=t[1],r=t[2],c=["Q",a,h,e,r];break;case"a":t[6]+=e,t[7]+=r;case"A":Mn(e,r,t).forEach(t=>s.push(t)),e=t[6],r=t[7];break;case"z":case"Z":e=i,r=n,c=["Z"]}c?(s.push(c),o=c[0]):o=""}return s},Fn=(t,e,r,i)=>Math.sqrt((r-t)**2+(i-e)**2),jn=(t,e,r,i,n,s,o,a)=>h=>{const l=h**3,c=(t=>3*t**2*(1-t))(h),u=(t=>3*t*(1-t)**2)(h),f=(t=>(1-t)**3)(h);return new ot(o*l+n*c+r*u+t*f,a*l+s*c+i*u+e*f)},In=t=>t**2,Bn=t=>2*t*(1-t),Rn=t=>(1-t)**2,zn=(t,e,r,i,n,s,o,a)=>h=>{const l=In(h),c=Bn(h),u=Rn(h),f=3*(u*(r-t)+c*(n-r)+l*(o-n)),d=3*(u*(i-e)+c*(s-i)+l*(a-s));return Math.atan2(d,f)},Un=(t,e,r,i,n,s)=>o=>{const a=In(o),h=Bn(o),l=Rn(o);return new ot(n*a+r*h+t*l,s*a+i*h+e*l)},qn=(t,e,r,i,n,s)=>o=>{const a=1-o,h=2*(a*(r-t)+o*(n-r)),l=2*(a*(i-e)+o*(s-i));return Math.atan2(l,h)},Wn=(t,e,r)=>{let i=new ot(e,r),n=0;for(let e=1;e<=100;e+=1){const r=t(e/100);n+=Fn(i.x,i.y,r.x,r.y),i=r}return n},Hn=t=>{let e,r,i=0,n=0,s=0,o=0,a=0;const h=[];for(const l of t){const t={x:n,y:s,command:l[0],length:0};switch(l[0]){case"M":r=t,r.x=o=n=l[1],r.y=a=s=l[2];break;case"L":r=t,r.length=Fn(n,s,l[1],l[2]),n=l[1],s=l[2];break;case"C":e=jn(n,s,l[1],l[2],l[3],l[4],l[5],l[6]),r=t,r.iterator=e,r.angleFinder=zn(n,s,l[1],l[2],l[3],l[4],l[5],l[6]),r.length=Wn(e,n,s),n=l[5],s=l[6];break;case"Q":e=Un(n,s,l[1],l[2],l[3],l[4]),r=t,r.iterator=e,r.angleFinder=qn(n,s,l[1],l[2],l[3],l[4]),r.length=Wn(e,n,s),n=l[3],s=l[4];break;case"Z":r=t,r.destX=o,r.destY=a,r.length=Fn(n,s,o,a),n=o,s=a}i+=r.length,h.push(r)}return h.push({length:i,x:n,y:s}),h},Vn=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Hn(t),i=0;for(;e-r[i].length>0&&i<r.length-2;)e-=r[i].length,i++;const n=r[i],s=e/n.length,o=t[i];switch(n.command){case"M":return{x:n.x,y:n.y,angle:0};case"Z":return{...new ot(n.x,n.y).lerp(new ot(n.destX,n.destY),s),angle:Math.atan2(n.destY-n.y,n.destX-n.x)};case"L":return{...new ot(n.x,n.y).lerp(new ot(o[1],o[2]),s),angle:Math.atan2(o[2]-n.y,o[1]-n.x)};case"C":case"Q":return((t,e)=>{let r,i=0,n=0,s={x:t.x,y:t.y},o={...s},a=.01,h=0;const l=t.iterator,c=t.angleFinder;for(;n<e&&a>1e-4;)o=l(i),h=i,r=Fn(s.x,s.y,o.x,o.y),r+n>e?(i-=a,a/=2):(s=o,i+=a,n+=r);return{...o,angle:c(h)}})(n,e)}},Yn=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Xn=new RegExp(Tn,"g"),Gn=new RegExp(pr,"gi"),$n={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Kn=t=>{var e;const r=[],i=null!==(e=t.match(Yn))&&void 0!==e?e:[];for(const t of i){const e=t[0];if("z"===e||"Z"===e){r.push([e]);continue}const i=$n[e.toLowerCase()];let n=[];if("a"===e||"A"===e){Xn.lastIndex=0;for(let e=null;e=Xn.exec(t);)n.push(...e.slice(1))}else n=t.match(Gn)||[];for(let t=0;t<n.length;t+=i){const s=new Array(i),o=Pn[e];s[0]=t>0&&o?o:e;for(let e=0;e<i;e++)s[e+1]=parseFloat(n[t+e]);r.push(s)}}return r},Jn=(t,e)=>t.map(t=>t.map((t,r)=>0===r||void 0===e?t:qt(t,e)).join(" ")).join(" ");function Zn(t,e){const r=t.style;r&&Object.entries(e).forEach(t=>{let[e,i]=t;return r.setProperty(e,i)})}Object.freeze({__proto__:null,addTransformToObject:pe,animate:Ur,animateColor:qr,applyTransformToObject:ge,calcAngleBetweenVectors:Ne,calcDimensionsMatrix:Ft,calcPlaneChangeMatrix:be,calcVectorRotation:Oe,cancelAnimFrame:ft,capValue:Cr,composeMatrix:jt,copyCanvasElement:t=>{var e;const r=vt(t);return null===(e=r.getContext("2d"))||void 0===e||e.drawImage(t,0,0),r},cos:nt,createCanvasElement:gt,createImage:mt,createRotateMatrix:Nt,createScaleMatrix:Ot,createSkewXMatrix:Mt,createSkewYMatrix:Dt,createTranslateMatrix:Pt,createVector:Te,crossProduct:De,degreesToRadians:wt,dotProduct:Fe,ease:Mr,enlivenObjectEnlivables:Rt,enlivenObjects:Bt,findScaleToCover:An,findScaleToFit:Cn,getBoundsOfCurve:En,getOrthonormalVector:Me,getPathSegmentsInfo:Hn,getPointOnPath:Vn,getPointer:ce,getRandomInt:(t,e)=>Math.floor(Math.random()*(e-t+1))+t,getRegularPolygonPath:(t,e)=>{const r=2*Math.PI/t;let i=-y;t%2==0&&(i+=r/2);const n=new Array(t+1);for(let s=0;s<t;s++){const t=s*r+i,{x:o,y:a}=new ot(nt(t),st(t)).scalarMultiply(e);n[s]=[0===s?"M":"L",o,a]}return n[t]=["Z"],n},getSmoothPathFromPoints:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new ot(t[0]),i=new ot(t[1]),n=1,s=0;const o=[],a=t.length,h=a>2;let l;for(h&&(n=t[2].x<i.x?-1:t[2].x===i.x?0:1,s=t[2].y<i.y?-1:t[2].y===i.y?0:1),o.push(["M",r.x-n*e,r.y-s*e]),l=1;l<a;l++){if(!r.eq(i)){const t=r.midPointFrom(i);o.push(["Q",r.x,r.y,t.x,t.y])}r=t[l],l+1<t.length&&(i=t[l+1])}return h&&(n=r.x>t[l-2].x?1:r.x===t[l-2].x?0:-1,s=r.y>t[l-2].y?1:r.y===t[l-2].y?0:-1),o.push(["L",r.x+n*e,r.y+s*e]),o},getSvgAttributes:t=>{const e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":return e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);case"radialGradient":return e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);case"stop":return e.concat(["offset","stop-color","stop-opacity"])}return e},getUnitVector:Ee,groupSVGElements:(t,e)=>t&&1===t.length?t[0]:new Sn(t,e),hasStyleChanged:Ii,invertTransform:Ct,isBetweenVectors:je,isIdentityMatrix:xt,isTouchEvent:ue,isTransparent:Ni,joinPath:Jn,loadImage:It,magnitude:Pe,makeBoundingBoxFromPoints:de,makePathSimpler:Dn,matrixToSVG:Wt,mergeClipPaths:(t,e)=>{var r;let i=t,n=e;i.inverted&&!n.inverted&&(i=e,n=t),xe(n,null===(r=n.group)||void 0===r?void 0:r.calcTransformMatrix(),i.calcTransformMatrix());const s=i.inverted&&n.inverted;return s&&(i.inverted=n.inverted=!1),new Sn([i],{clipPath:n,inverted:s})},multiplyTransformMatrices:At,multiplyTransformMatrixArray:kt,parsePath:Kn,parsePreserveAspectRatioAttribute:Qe,parseUnit:Ze,pick:zt,projectStrokeOnPoints:Fi,qrDecompose:Tt,radiansToDegrees:_t,removeFromArray:it,removeTransformFromObject:(t,e)=>{const r=Ct(e),i=At(r,t.calcOwnMatrix());ge(t,i)},removeTransformMatrixForSvgParsing:(t,e)=>{let r=t._findCenterFromElement();t.transformMatrix&&((t=>{if(t.transformMatrix){const{scaleX:e,scaleY:r,angle:i,skewX:n}=Tt(t.transformMatrix);t.flipX=!1,t.flipY=!1,t.set(q,e),t.set(W,r),t.angle=i,t.skewX=n,t.skewY=0}})(t),r=r.transform(t.transformMatrix)),delete t.transformMatrix,e&&(t.scaleX*=e.scaleX,t.scaleY*=e.scaleY,t.cropX=e.cropX,t.cropY=e.cropY,r.x+=e.offsetLeft,r.y+=e.offsetTop,t.width=e.width,t.height=e.height),t.setPositionByOrigin(r,A,A)},requestAnimFrame:ut,resetObjectTransform:me,rotateVector:Le,saveObjectTransform:ve,sendObjectToPlane:xe,sendPointToPlane:we,sendVectorToPlane:_e,sin:st,sizeAfterTransform:ye,string:ae,stylesFromArray:Ri,stylesToArray:Bi,toBlob:bt,toDataURL:yt,toFixed:qt,transformPath:(t,e,r)=>(r&&(e=At(e,[1,0,0,1,-r.x,-r.y])),t.map(t=>{const r=[...t];for(let i=1;i<t.length-1;i+=2){const{x:n,y:s}=St({x:t[i],y:t[i+1]},e);r[i]=n,r[i+1]=s}return r})),transformPoint:St});class Qn extends te{constructor(e){let{allowTouchScrolling:r=!1,containerClass:i=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),t(this,"upper",void 0),t(this,"container",void 0);const{el:n}=this.lower,s=this.createUpperCanvas();this.upper={el:s,ctx:s.getContext("2d")},this.applyCanvasStyle(n,{allowTouchScrolling:r}),this.applyCanvasStyle(s,{allowTouchScrolling:r,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),n.parentNode&&n.parentNode.replaceChild(o,n),o.append(n,s),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=gt();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=f().createElement("div");return t.setAttribute("data-fabric","wrapper"),Zn(t,{position:"relative"}),Qt(t),t}applyCanvasStyle(t,e){const{styles:r,allowTouchScrolling:i}=e;Zn(t,{...r,"touch-action":i?"manipulation":N}),Qt(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:r,ctx:i}=this.upper;Jt(r,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Zt(this.upper.el,t),Zt(this.container,t)}cleanupDOM(t){const e=this.container,{el:r}=this.lower,{el:i}=this.upper;super.cleanupDOM(t),e.removeChild(i),e.removeChild(r),e.parentNode&&e.parentNode.replaceChild(r,e)}dispose(){super.dispose(),u().dispose(this.upper.el),delete this.upper,delete this.container}}const ts=(t,e,r,i)=>{const{target:n,offsetX:s,offsetY:o}=e,a=r-s,h=i-o,l=!ze(n,"lockMovementX")&&n.left!==a,c=!ze(n,"lockMovementY")&&n.top!==h;return l&&n.set(k,a),c&&n.set(L,h),(l||c)&&Yr(E,Ue(t,e,r,i)),l||c},es=B,rs=t=>function(e,r,i){const{points:n,pathOffset:s}=i;return new ot(n[t]).subtract(s).transform(At(i.getViewportTransform(),i.calcTransformMatrix()))},is=(t,e,r,i)=>{const{target:n,pointIndex:s}=e,o=n,a=we(new ot(r,i),void 0,o.calcOwnMatrix());return o.points[s]=a.add(o.pathOffset),o.setDimensions(),o.set("dirty",!0),!0},ns=(t,e)=>function(r,i,n,s){const o=i.target,a=new ot(o.points[(t>0?t:o.points.length)-1]),h=a.subtract(o.pathOffset).transform(o.calcOwnMatrix()),l=e(r,{...i,pointIndex:t},n,s),c=a.subtract(o.pathOffset).transform(o.calcOwnMatrix()).subtract(h);return o.left-=c.x,o.top-=c.y,l},ss=t=>Xr(es,ns(t,is)),os=(t,e,r)=>{const{path:i,pathOffset:n}=t,s=i[e];return new ot(s[r]-n.x,s[r+1]-n.y).transform(At(t.getViewportTransform(),t.calcTransformMatrix()))};function as(t,e,r){const{commandIndex:i,pointIndex:n}=this;return os(r,i,n)}function hs(t,e,r,i){const{target:n}=e,{commandIndex:s,pointIndex:o}=this,a=((t,e,r,i,n)=>{const{path:s,pathOffset:o}=t,a=s[(i>0?i:s.length)-1],h=new ot(a[n],a[n+1]),l=h.subtract(o).transform(t.calcOwnMatrix()),c=we(new ot(e,r),void 0,t.calcOwnMatrix());s[i][n]=c.x+o.x,s[i][n+1]=c.y+o.y,t.setDimensions();const u=h.subtract(t.pathOffset).transform(t.calcOwnMatrix()).subtract(l);return t.left-=u.x,t.top-=u.y,t.set("dirty",!0),!0})(n,r,i,s,o);return Yr(this.actionName,{...Ue(t,e,r,i),commandIndex:s,pointIndex:o}),a}class ls extends ri{constructor(t){super(t)}render(t,e,r,i,n){const s={...i,cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill};super.render(t,e,r,s,n)}}class _n extends ls{constructor(t){super(t)}render(t,e,r,i,n){const{path:s}=n,{commandIndex:o,pointIndex:a,connectToCommandIndex:h,connectToPointIndex:l}=this;t.save(),t.strokeStyle=this.controlStroke,this.connectionDashArray&&t.setLineDash(this.connectionDashArray);const[c]=s[o],u=os(n,h,l);if("Q"===c){const i=os(n,o,a+2);t.moveTo(i.x,i.y),t.lineTo(e,r)}else t.moveTo(e,r);t.lineTo(u.x,u.y),t.stroke(),t.restore(),super.render(t,e,r,i,n)}}const cs=(t,e,r,i,n,s)=>new(r?_n:ls)({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:as,actionHandler:hs,connectToCommandIndex:n,connectToPointIndex:s,...i,...r?i.controlPointStyle:i.pointStyle});Object.freeze({__proto__:null,changeHeight:Qr,changeObjectHeight:Jr,changeObjectWidth:Kr,changeWidth:Zr,createObjectDefaultControls:Ci,createPathControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={};let i="M";return t.path.forEach((t,n)=>{const s=t[0];switch("Z"!==s&&(r[`c_${n}_${s}`]=cs(n,t.length-2,!1,e)),s){case"C":r[`c_${n}_C_CP_1`]=cs(n,1,!0,e,n-1,(t=>"C"===t?5:"Q"===t?3:1)(i)),r[`c_${n}_C_CP_2`]=cs(n,3,!0,e,n,5);break;case"Q":r[`c_${n}_Q_CP_1`]=cs(n,1,!0,e,n,3)}i=s}),r},createPolyActionHandler:ss,createPolyControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={};for(let i=0;i<("number"==typeof t?t:t.points.length);i++)r[`p${i}`]=new ri({actionName:es,positionHandler:rs(i),actionHandler:ss(i),...e});return r},createPolyPositionHandler:rs,createResizeControls:Ai,createTextboxDefaultControls:ki,dragHandler:ts,factoryPolyActionHandler:ns,getLocalPoint:We,polyActionHandler:is,renderCircleControl:ti,renderSquareControl:ei,rotationStyleHandler:ii,rotationWithSnapping:ni,scaleCursorStyleHandler:hi,scaleOrSkewActionName:wi,scaleSkewCursorStyleHandler:_i,scalingEqually:ci,scalingX:ui,scalingXOrSkewingY:xi,scalingY:fi,scalingYOrSkewingX:Si,skewCursorStyleHandler:gi,skewHandlerX:vi,skewHandlerY:yi,wrapWithFireEvent:Xr,wrapWithFixedAnchor:Gr});class us extends he{constructor(){super(...arguments),t(this,"_hoveredTargets",[]),t(this,"_currentTransform",null),t(this,"_groupSelector",null),t(this,"contextTopDirty",!1)}static getDefaults(){return{...super.getDefaults(),...us.ownDefaults}}get upperCanvasEl(){var t;return null===(t=this.elements.upper)||void 0===t?void 0:t.el}get contextTop(){var t;return null===(t=this.elements.upper)||void 0===t?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Qn(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter(e=>!e.group&&e!==t).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(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(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),r=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=r,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,r){const i=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+i,-r+i),n.transform(...this.viewportTransform);const s=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(n),t.selectionBackgroundColor=s,n.restore();const o=Math.round(i*this.getRetinaScaling());return Ni(n,o,o,o)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(e=>!!e&&!0===t[e]):t[e])}_shouldClearSelection(t,e){const r=this.getActiveObjects(),i=this._activeObject;return!!(!e||e&&i&&r.length>1&&-1===r.indexOf(e)&&i!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&i&&i!==e)}_shouldCenterTransform(t,e,r){if(!t)return;let i;return e===U||e===q||e===W||e===I?i=this.centeredScaling||t.centeredScaling:e===F&&(i=this.centeredRotation||t.centeredRotation),i?!r:r}_getOriginFromCorner(t,e){const r=e?t.controls[e].getTransformAnchorPoint():{x:t.originX,y:t.originY};return e?(["ml","tl","bl"].includes(e)?r.x=P:["mr","tr","br"].includes(e)&&(r.x=k),["tl","mt","tr"].includes(e)?r.y=T:["bl","mb","br"].includes(e)&&(r.y=L),r):r}_setupCurrentTransform(t,e,r){var i;const n=e.group?we(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:s="",control:o}=e.getActiveControl()||{},a=r&&o?null===(i=o.getActionHandler(t,e,o))||void 0===i?void 0:i.bind(o):ts,h=((t,e,r,i)=>{if(!e||!t)return"drag";const n=i.controls[e];return n.getActionName(r,n,i)})(r,s,t,e),l=t[this.centeredKey],c=this._shouldCenterTransform(e,h,l)?{x:A,y:A}:this._getOriginFromCorner(e,s),{scaleX:u,scaleY:f,skewX:d,skewY:p,left:g,top:m,angle:v,width:y,height:b,cropX:w,cropY:_}=e,x={target:e,action:h,actionHandler:a,actionPerformed:!1,corner:s,scaleX:u,scaleY:f,skewX:d,skewY:p,offsetX:n.x-g,offsetY:n.y-m,originX:c.x,originY:c.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:wt(v),width:y,height:b,shiftKey:t.shiftKey,altKey:l,original:{...ve(e),originX:c.x,originY:c.y,cropX:w,cropY:_}};this._currentTransform=x,this.fire("before:transform",{e:t,transform:x})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:r,deltaX:i,deltaY:n}=this._groupSelector,s=new ot(e,r).transform(this.viewportTransform),o=new ot(e+i,r+n).transform(this.viewportTransform),a=this.selectionLineWidth/2;let h=Math.min(s.x,o.x),l=Math.min(s.y,o.y),c=Math.max(s.x,o.x),u=Math.max(s.y,o.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(h,l,c-h,u-l)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,h+=a,l+=a,c-=a,u-=a,Pi.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(h,l,c-h,u-l))}findTarget(t){if(this._targetInfo)return this._targetInfo;if(this.skipTargetFind)return{subTargets:[],currentSubTargets:[]};const e=this.getScenePoint(t),r=this._activeObject,i=this.getActiveObjects(),n=this.searchPossibleTargets(this._objects,e),{subTargets:s,container:o,target:a}=n,h={...n,currentSubTargets:s,currentContainer:o,currentTarget:a};if(!r)return h;const l={...this.searchPossibleTargets([r],e),currentSubTargets:s,currentContainer:o,currentTarget:a};if(r.findControl(this.getViewportPoint(t),ue(t)))return{...l,target:r};if(l.target){if(i.length>1)return l;if(!this.preserveObjectStacking)return l;if(this.preserveObjectStacking&&t[this.altSelectionKey])return l}return h}_pointIsInObjectSelectionArea(t,e){let r=t.getCoords();const i=this.getZoom(),n=t.padding/i;if(n){const[t,e,i,s]=r,o=Math.atan2(e.y-t.y,e.x-t.x),a=nt(o)*n,h=st(o)*n,l=a+h,c=a-h;r=[new ot(t.x-c,t.y-l),new ot(e.x+l,e.y-c),new ot(i.x+c,i.y+l),new ot(s.x-l,s.y+c)]}return Wr.isPointInPolygon(e,r)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,e)){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;{const r=e.transform(this.viewportTransform);if(!this.isTargetTransparent(t,r.x,r.y))return!0}}return!1}_searchPossibleTargets(t,e,r){let i=t.length;for(;i--;){const n=t[i];if(this._checkTarget(n,e)){if(ht(n)&&n.subTargetCheck){const{target:t}=this._searchPossibleTargets(n._objects,e,r);t&&r.push(t)}return{target:n,subTargets:r}}}return{subTargets:[]}}searchPossibleTargets(t,e){const r=this._searchPossibleTargets(t,e,[]);r.container=r.target;const{container:i,subTargets:n}=r;if(i&&ht(i)&&i.interactive&&n[0]){for(let t=n.length-1;t>0;t--){const e=n[t];if(!ht(e)||!e.interactive)return r.target=e,r}return r.target=n[0],r}return r}getViewportPoint(t){return this._viewportPoint?this._viewportPoint:this._getPointerImpl(t,!0)}getScenePoint(t){return this._scenePoint?this._scenePoint:this._getPointerImpl(t)}_getPointerImpl(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=this.upperCanvasEl,i=r.getBoundingClientRect();let n=ce(t),s=i.width||0,o=i.height||0;s&&o||(L in i&&T in i&&(o=Math.abs(i.top-i.bottom)),P in i&&k in i&&(s=Math.abs(i.right-i.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,e||(n=we(n,void 0,this.viewportTransform));const a=this.getRetinaScaling();1!==a&&(n.x/=a,n.y/=a);const h=0===s||0===o?new ot(1,1):new ot(r.width/s,r.height/o);return n.multiply(h)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=gt(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Xt(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let r=!1,i=!1;const n=this.getActiveObjects(),s=[],o=[];t.forEach(t=>{n.includes(t)||(r=!0,t.fire("deselected",{e,target:t}),o.push(t))}),n.forEach(i=>{t.includes(i)||(r=!0,i.fire("selected",{e,target:i}),s.push(i))}),t.length>0&&n.length>0?(i=!0,r&&this.fire("selection:updated",{e,selected:s,deselected:o})):n.length>0?(i=!0,this.fire("selection:created",{e,selected:s})):t.length>0&&(i=!0,this.fire("selection:cleared",{e,deselected:o})),i&&(this._objectsToRender=void 0)}setActiveObject(t,e){const r=this.getActiveObjects(),i=this._setActiveObject(t,e);return this._fireSelectionEvents(r,e),i}_setActiveObject(t,e){const r=this._activeObject;return!(r===t||!this._discardActiveObject(e,t)&&this._activeObject||t.onSelect({e})||(this._activeObject=t,Xt(t)&&r!==t&&t.set("canvas",this),t.setCoords(),0))}_discardActiveObject(t,e){const r=this._activeObject;return!!r&&!r.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===r&&this.endCurrentTransform(t),Xt(r)&&r===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),r=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[r]});const i=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),i}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,r=e.target,i={e:t,target:r,transform:e,action:e.action};r._scaling&&(r._scaling=!1),r.setCoords(),e.actionPerformed&&(this.fire("object:modified",i),r.fire(G,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Xt(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,r){const i=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,r);return t.set(i),n}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Xt(e)&&this._activeObject===e){const r=zt(t,["angle","flipX","flipY",k,q,W,H,V,L]);return pe(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(i)}}t(us,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!0,fireRightClick:!0,fireMiddleClick:!0,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!0});class fs{constructor(e){t(this,"targets",[]),t(this,"__disposer",void 0);const r=()=>{const{hiddenTextarea:t}=e.getActiveObject()||{};t&&t.focus()},i=e.upperCanvasEl;i.addEventListener("click",r),this.__disposer=()=>i.removeEventListener("click",r)}exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),it(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;(null===(e=this.target)||void 0===e?void 0:e.isEditing)&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const ds={passive:!1},ps=(t,e)=>({viewportPoint:t.getViewportPoint(e),scenePoint:t.getScenePoint(e)}),gs=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return t.addEventListener(...r)},ms=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return t.removeEventListener(...r)},vs={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class ys extends us{constructor(e){super(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),t(this,"_isClick",void 0),t(this,"textEditingManager",new fs(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(t=>{this[t]=this[t].bind(this)}),this.addOrRemove(gs)}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=this.upperCanvasEl,i=this._getEventPrefix();t(Kt(r),"resize",this._onResize),t(r,i+"down",this._onMouseDown),t(r,`${i}move`,this._onMouseMove,ds),t(r,`${i}out`,this._onMouseOut),t(r,`${i}enter`,this._onMouseEnter),t(r,"wheel",this._onMouseWheel,{passive:!1}),t(r,"contextmenu",this._onContextMenu),e||(t(r,"click",this._onClick),t(r,"dblclick",this._onClick)),t(r,"dragstart",this._onDragStart),t(r,"dragend",this._onDragEnd),t(r,"dragover",this._onDragOver),t(r,"dragenter",this._onDragEnter),t(r,"dragleave",this._onDragLeave),t(r,"drop",this._onDrop),this.enablePointerEvents||t(r,"touchstart",this._onTouchStart,ds)}removeListeners(){this.addOrRemove(ms);const t=this._getEventPrefix(),e=$t(this.upperCanvasEl);ms(e,`${t}up`,this._onMouseUp),ms(e,"touchend",this._onTouchEnd,ds),ms(e,`${t}move`,this._onMouseMove,ds),ms(e,"touchmove",this._onMouseMove,ds),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_onMouseOut(t){const e=this._hoveredTarget,r={e:t,...ps(this,t)};this.fire("mouse:out",{...r,target:e}),this._hoveredTarget=void 0,e&&e.fire("mouseout",{...r}),this._hoveredTargets.forEach(t=>{this.fire("mouse:out",{...r,target:t}),t&&t.fire("mouseout",{...r})}),this._hoveredTargets=[]}_onMouseEnter(t){const{target:e}=this.findTarget(t);this._currentTransform||e||(this.fire("mouse:over",{e:t,...ps(this,t)}),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const r={e:t,target:e};return this.fire("dragstart",r),e.fire("dragstart",r),void gs(this.upperCanvasEl,"drag",this._onDragProgress)}fe(t)}_renderDragEffects(t,e,r){let i=!1;const n=this._dropTarget;n&&n!==e&&n!==r&&(n.clearContextTop(),i=!0),null==e||e.clearContextTop(),r!==e&&(null==r||r.clearContextTop());const s=this.contextTop;s.save(),s.transform(...this.viewportTransform),e&&(s.save(),e.transform(s),e.renderDragSourceEffect(t),s.restore(),i=!0),r&&(s.save(),r.transform(s),r.renderDropTargetEffect(t),s.restore(),i=!0),s.restore(),i&&(this.contextTopDirty=!0)}_onDragEnd(t){const{currentSubTargets:e}=this.findTarget(t),r=!!t.dataTransfer&&t.dataTransfer.dropEffect!==N,i=r?this._activeObject:void 0,n={e:t,target:this._dragSource,subTargets:e,dragSource:this._dragSource,didDrop:r,dropTarget:i};ms(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",n),this._dragSource&&this._dragSource.fire("dragend",n),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}_onDragOver(t){const e="dragover",{currentContainer:r,currentSubTargets:i}=this.findTarget(t),n=this._dragSource,s={e:t,target:r,subTargets:i,dragSource:n,canDrop:!1,dropTarget:void 0};let o;this.fire(e,s),this._fireEnterLeaveEvents(t,r,s),r&&(r.canDrop(t)&&(o=r),r.fire(e,s));for(let r=0;r<i.length;r++){const n=i[r];n.canDrop(t)&&(o=n),n.fire(e,s)}this._renderDragEffects(t,n,o),this._dropTarget=o}_onDragEnter(t){const{currentContainer:e,currentSubTargets:r}=this.findTarget(t),i={e:t,target:e,subTargets:r,dragSource:this._dragSource};this.fire("dragenter",i),this._fireEnterLeaveEvents(t,e,i)}_onDragLeave(t){const{currentSubTargets:e}=this.findTarget(t),r={e:t,target:this._draggedoverTarget,subTargets:e,dragSource:this._dragSource};this.fire("dragleave",r),this._fireEnterLeaveEvents(t,void 0,r),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this._hoveredTargets=[]}_onDrop(t){const{currentContainer:e,currentSubTargets:r}=this.findTarget(t),i=this._basicEventHandler("drop:before",{e:t,target:e,subTargets:r,dragSource:this._dragSource,...ps(this,t)});i.didDrop=!1,i.dropTarget=void 0,this._basicEventHandler("drop",i),this.fire("drop:after",i)}_onContextMenu(t){const{target:e,subTargets:r}=this.findTarget(t),i=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:r});return this.stopContextMenu&&fe(t),this._basicEventHandler("contextmenu",i),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),2==e&&"dblclick"===t.type&&this._handleEvent(t,"dblclick"),3==e&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}fireEventFromPointerEvent(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._cacheTransformEventData(t);const{target:n,subTargets:s}=this.findTarget(t),o={e:t,target:n,subTargets:s,...ps(this,t),transform:this._currentTransform,...i};this.fire(e,o),n&&n.fire(r,o);for(let t=0;t<s.length;t++)s[t]!==n&&s[t].fire(r,o);this._resetTransformEventData()}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){this._cacheTransformEventData(t);let e=!this.allowTouchScrolling;const r=this._activeObject;void 0===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t);const{target:i}=this.findTarget(t);(this.isDrawingMode||r&&i===r)&&(e=!0),e&&t.preventDefault();const n=this.upperCanvasEl,s=this._getEventPrefix(),o=$t(n);gs(o,"touchend",this._onTouchEnd,ds),e&&gs(o,"touchmove",this._onMouseMove,ds),ms(n,`${s}down`,this._onMouseDown),this._resetTransformEventData()}_onMouseDown(t){this._cacheTransformEventData(t),this.__onMouseDown(t);const e=this.upperCanvasEl,r=this._getEventPrefix();ms(e,`${r}move`,this._onMouseMove,ds);const i=$t(e);gs(i,`${r}up`,this._onMouseUp),gs(i,`${r}move`,this._onMouseMove,ds),this._resetTransformEventData()}_onTouchEnd(t){if(t.touches.length>0)return;this._cacheTransformEventData(t),this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),r=$t(this.upperCanvasEl);ms(r,"touchend",this._onTouchEnd,ds),ms(r,"touchmove",this._onMouseMove,ds),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{gs(this.upperCanvasEl,`${e}down`,this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this._cacheTransformEventData(t),this.__onMouseUp(t);const e=this.upperCanvasEl,r=this._getEventPrefix();if(this._isMainEvent(t)){const t=$t(this.upperCanvasEl);ms(t,`${r}up`,this._onMouseUp),ms(t,`${r}move`,this._onMouseMove,ds),gs(e,`${r}move`,this._onMouseMove,ds)}this._resetTransformEventData()}_onMouseMove(t){this._cacheTransformEventData(t);const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t),this._resetTransformEventData()}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._handleEvent(t,"up:before");const r=this._currentTransform,i=this._isClick,{target:n}=this.findTarget(t),{button:s}=t;if(s)return void((this.fireMiddleClick&&1===s||this.fireRightClick&&2===s)&&this._handleEvent(t,"up"));if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let o,a,h=!1;if(r&&(this._finalizeCurrentTransform(t),h=r.actionPerformed),!i){const e=n===this._activeObject;this.handleSelection(t),h||(h=this._shouldRender(n)||!e&&n===this._activeObject)}if(n){const e=n.findControl(this.getViewportPoint(t),ue(t)),{key:i,control:s}=e||{};if(a=i,n.selectable&&n!==this._activeObject&&"up"===n.activeOn)this.setActiveObject(n,t),h=!0;else if(s){const e=s.getMouseUpHandler(t,n,s);e&&(o=this.getScenePoint(t),e.call(s,t,r,o.x,o.y))}n.isMoving=!1}if(r&&(r.target!==n||r.corner!==a)){const e=r.target&&r.target.controls[r.corner],i=e&&e.getMouseUpHandler(t,r.target,e);o=o||this.getScenePoint(t),i&&i.call(e,t,r,o.x,o.y)}this._setCursorFromEvent(t,n),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,n&&(n.__corner=void 0),h?this.requestRenderAll():i||null!==(e=this._activeObject)&&void 0!==e&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:r,subTargets:i=[]}=e;this.fire(t,e),r&&r.fire(t,e);for(let n=0;n<i.length;n++)i[n]!==r&&i[n].fire(t,e);return e}_handleEvent(t,e,r){const{target:i,subTargets:n}=this.findTarget(t),s={e:t,target:i,subTargets:n,...ps(this,t),transform:this._currentTransform,..."down:before"===e||"down"===e?r:{}};"up:before"!==e&&"up"!==e||(s.isClick=this._isClick),this.fire(`mouse:${e}`,s),i&&i.fire(`mouse${e}`,s);for(let t=0;t<n.length;t++)n[t]!==i&&n[t].fire(`mouse${e}`,s)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._handleEvent(t,"down:before");let{target:e}=this.findTarget(t),r=!!e&&e===this._activeObject;const{button:i}=t;if(i)return void((this.fireMiddleClick&&1===i||this.fireRightClick&&2===i)&&this._handleEvent(t,"down",{alreadySelected:r}));if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t))return;if(this._currentTransform)return;let n=this._shouldRender(e),s=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,s=!0,n=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const e=this.getScenePoint(t);this._groupSelector={x:e.x,y:e.y,deltaY:0,deltaX:0}}if(r=!!e&&e===this._activeObject,e){e.selectable&&"down"===e.activeOn&&this.setActiveObject(e,t);const i=e.findControl(this.getViewportPoint(t),ue(t));if(e===this._activeObject&&(i||!s)){this._setupCurrentTransform(t,e,r);const n=i?i.control:void 0,s=this.getScenePoint(t),o=n&&n.getMouseDownHandler(t,e,n);o&&o.call(n,t,this._currentTransform,s.x,s.y)}}n&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:r}),n&&this.requestRenderAll()}_resetTransformEventData(){this._targetInfo=this._viewportPoint=this._scenePoint=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._viewportPoint=this.getViewportPoint(t),this._scenePoint=we(this._viewportPoint,void 0,this.viewportTransform),this._targetInfo=this.findTarget(t),this._currentTransform&&(this._targetInfo.target=this._currentTransform.target)}__onMouseMove(t){if(this._isClick=!1,this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const r=this.getScenePoint(t);e.deltaX=r.x-e.x,e.deltaY=r.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const{target:e}=this.findTarget(t);this._setCursorFromEvent(t,e),this._fireOverOutEvents(t,e)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move")}_fireOverOutEvents(t,e){const{_hoveredTarget:r,_hoveredTargets:i}=this,{subTargets:n}=this.findTarget(t),s=Math.max(i.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:r,fireCanvas:!0});for(let o=0;o<s;o++)n[o]===e||i[o]&&i[o]===r||this.fireSyntheticInOutEvents("mouse",{e:t,target:n[o],oldTarget:i[o]});this._hoveredTarget=e,this._hoveredTargets=n}_fireEnterLeaveEvents(t,e,r){const i=this._draggedoverTarget,n=this._hoveredTargets,{subTargets:s}=this.findTarget(t),o=Math.max(n.length,s.length);this.fireSyntheticInOutEvents("drag",{...r,target:e,oldTarget:i,fireCanvas:!0});for(let t=0;t<o;t++)this.fireSyntheticInOutEvents("drag",{...r,target:s[t],oldTarget:n[t]});this._draggedoverTarget=e}fireSyntheticInOutEvents(t,e){let{target:r,oldTarget:i,fireCanvas:n,e:s,...o}=e;const{targetIn:a,targetOut:h,canvasIn:l,canvasOut:c}=vs[t],u=i!==r;if(i&&u){const t={...o,e:s,target:i,nextTarget:r,...ps(this,s)};n&&this.fire(c,t),i.fire(h,t)}if(r&&u){const t={...o,e:s,target:r,previousTarget:i,...ps(this,s)};n&&this.fire(l,t),r.fire(a,t)}}_transformObject(t){const e=this.getScenePoint(t),r=this._currentTransform,i=r.target,n=i.group?we(e,void 0,i.group.calcTransformMatrix()):e;r.shiftKey=t.shiftKey,r.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,r,n),r.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,r){const{action:i,actionHandler:n,target:s}=e,o=!!n&&n(t,e,r.x,r.y);o&&s.setCoords(),"drag"===i&&o&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||o}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let r=e.hoverCursor||this.hoverCursor;const i=Xt(this._activeObject)?this._activeObject:null,n=(!i||e.group!==i)&&e.findControl(this.getViewportPoint(t));if(n){const{control:r,coord:i}=n;this.setCursor(r.cursorStyleHandler(t,r,e,i))}else{if(e.subTargetCheck){const{subTargets:e}=this.findTarget(t);e.concat().reverse().forEach(t=>{r=t.hoverCursor||r})}this.setCursor(r)}}handleMultiSelection(t,e){const r=this._activeObject,i=Xt(r);if(r&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(r!==e||i)&&(i||!e.isDescendantOf(r)&&!r.isDescendantOf(e))&&!e.onSelect({e:t})&&!r.getActiveControl()){if(i){const i=r.getObjects();let n=[];if(e===r){const r=this.getScenePoint(t);let s=this.searchPossibleTargets(i,r);if(s.target?(e=s.target,n=s.subTargets):(s=this.searchPossibleTargets(this._objects,r),e=s.target,n=s.subTargets),!e||!e.selectable)return!1}e.group===r?(r.remove(e),this._hoveredTarget=e,this._hoveredTargets=n,1===r.size()&&this._setActiveObject(r.item(0),t)):(r.multiSelectAdd(e),this._hoveredTarget=r,this._hoveredTargets=n),this._fireSelectionEvents(i,t)}else{r.isEditing&&r.exitEditing();const i=new(tt.getClass("ActiveSelection"))([],{canvas:this});i.multiSelectAdd(r,e),this._hoveredTarget=i,this._setActiveObject(i,t),this._fireSelectionEvents([r],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:r,deltaX:i,deltaY:n}=this._groupSelector,s=new ot(e,r),o=s.add(new ot(i,n)),a=s.min(o),h=s.max(o).subtract(a),l=this.collectObjects({left:a.x,top:a.y,width:h.x,height:h.y},{includeIntersecting:!this.selectionFullyContained}),c=s.eq(o)?l[0]?[l[0]]:[]:l.length>1?l.filter(e=>!e.onSelect({e:t})).reverse():l;if(1===c.length)this.setActiveObject(c[0],t);else if(c.length>1){const e=tt.getClass("ActiveSelection");this.setActiveObject(new e(c,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:r}=this.elements;r.ctx=void 0;const i=super.toCanvasElement(t,e);return r.ctx=r.el.getContext("2d"),i}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const bs={x1:0,y1:0,x2:0,y2:0},ws={...bs,r1:0,r2:0},_s=(t,e)=>isNaN(t)&&"number"==typeof e?e:t;function xs(t){return t&&/%$/.test(t)&&Number.isFinite(parseFloat(t))}function Ss(t,e){const r="number"==typeof t?t:"string"==typeof t?parseFloat(t)/(xs(t)?100:1):NaN;return Cr(0,_s(r,e),1)}const Cs=/\s*;\s*/,As=/\s*:\s*/;function ks(t,e){let r,i;const n=t.getAttribute("style");if(n){const t=n.split(Cs);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){const[n,s]=t[e].split(As).map(t=>t.trim());"stop-color"===n?r=s:"stop-opacity"===n&&(i=s)}}r=r||t.getAttribute("stop-color")||"rgb(0,0,0)",i=_s(parseFloat(i||t.getAttribute("stop-opacity")||""),1);const s=new Je(r);return s.setAlpha(s.getAlpha()*i*e),{offset:Ss(t.getAttribute("offset"),0),color:s.toRgba()}}function Ls(t,e){const r=[],i=t.getElementsByTagName("stop"),n=Ss(e,1);for(let t=i.length;t--;)r.push(ks(i[t],n));return r}function Ts(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function Ps(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function Ns(t,e){return t.getAttribute(e)}function Os(t,e){return function(t,e){let r,{width:i,height:n,gradientUnits:s}=e;return Object.entries(t).reduce((t,e)=>{let[o,a]=e;if("Infinity"===a)r=1;else if("-Infinity"===a)r=0;else{const t="string"==typeof a;r=t?parseFloat(a):a,t&&xs(a)&&(r*=.01,"pixels"===s&&("x1"!==o&&"x2"!==o&&"r2"!==o||(r*=i),"y1"!==o&&"y2"!==o||(r*=n)))}return t[o]=r,t},{})}("linear"===Ts(t)?function(t){return{x1:Ns(t,"x1")||0,y1:Ns(t,"y1")||0,x2:Ns(t,"x2")||"100%",y2:Ns(t,"y2")||0}}(t):function(t){return{x1:Ns(t,"fx")||Ns(t,"cx")||"50%",y1:Ns(t,"fy")||Ns(t,"cy")||"50%",r1:0,x2:Ns(t,"cx")||"50%",y2:Ns(t,"cy")||"50%",r2:Ns(t,"r")||"50%"}}(t),{...e,gradientUnits:Ps(t)})}class Es{constructor(t){const{type:e="linear",gradientUnits:r="pixels",coords:i={},colorStops:n=[],offsetX:s=0,offsetY:o=0,gradientTransform:a,id:h}=t||{};Object.assign(this,{type:e,gradientUnits:r,coords:{..."radial"===e?ws:bs,...i},colorStops:n,offsetX:s,offsetY:o,gradientTransform:a,id:h?`${h}_${pt()}`:pt()})}addColorStop(t){for(const e in t)this.colorStops.push({offset:parseFloat(e),color:t[e]});return this}toObject(t){return{...zt(this,t),type:this.type,coords:{...this.coords},colorStops:this.colorStops.map(t=>({...t})),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0}}toSVG(t){let{additionalTransform:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=[],i=this.gradientTransform?this.gradientTransform.concat():x.concat(),n="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",s=this.colorStops.map(t=>({...t})).sort((t,e)=>t.offset-e.offset);let o=-this.offsetX,a=-this.offsetY;var h;"objectBoundingBox"===n?(o/=t.width,a/=t.height):(o+=t.width/2,a+=t.height/2),(h=t)&&"function"==typeof h._renderPathCommands&&"percentage"!==this.gradientUnits&&(o-=t.pathOffset.x,a-=t.pathOffset.y),i[4]-=o,i[5]-=a;const l=[`id="SVGID_${re(String(this.id))}"`,`gradientUnits="${n}"`,`gradientTransform="${e?e+" ":""}${Wt(i)}"`,""].join(" "),c=t=>parseFloat(String(t));if("linear"===this.type){const{x1:t,y1:e,x2:i,y2:n}=this.coords,s=c(t),o=c(e),a=c(i),h=c(n);r.push("<linearGradient ",l,' x1="',s,'" y1="',o,'" x2="',a,'" y2="',h,'">\n')}else if("radial"===this.type){const{x1:t,y1:e,x2:i,y2:n,r1:o,r2:a}=this.coords,h=c(t),u=c(e),f=c(i),d=c(n),p=c(o),g=c(a),m=p>g;r.push("<radialGradient ",l,' cx="',m?h:f,'" cy="',m?u:d,'" r="',m?p:g,'" fx="',m?f:h,'" fy="',m?d:u,'">\n'),m&&(s.reverse(),s.forEach(t=>{t.offset=1-t.offset}));const v=Math.min(p,g);if(v>0){const t=v/Math.max(p,g);s.forEach(e=>{e.offset+=t*(1-e.offset)})}}return s.forEach(t=>{let{color:e,offset:i}=t;r.push(`<stop offset="${100*i}%" style="stop-color:${e};"/>\n`)}),r.push("linear"===this.type?"</linearGradient>":"</radialGradient>","\n"),r.join("")}toLive(t){const{x1:e,y1:r,x2:i,y2:n,r1:s,r2:o}=this.coords,a="linear"===this.type?t.createLinearGradient(e,r,i,n):t.createRadialGradient(e,r,s,i,n,o);return this.colorStops.forEach(t=>{let{color:e,offset:r}=t;a.addColorStop(r,e)}),a}static async fromObject(t){const{colorStops:e,gradientTransform:r}=t;return new this({...t,colorStops:e?e.map(t=>({...t})):void 0,gradientTransform:r?[...r]:void 0})}static fromElement(t,e,r){const i=Ps(t),n=e._findCenterFromElement();return new this({id:t.getAttribute("id")||void 0,type:Ts(t),coords:Os(t,{width:r.viewBoxWidth||r.width,height:r.viewBoxHeight||r.height}),colorStops:Ls(t,r.opacity),gradientUnits:i,gradientTransform:sn(t.getAttribute("gradientTransform")||""),..."pixels"===i?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}})}}t(Es,"type","Gradient"),tt.setClass(Es,"gradient"),tt.setClass(Es,"linear"),tt.setClass(Es,"radial");class Ms{get type(){return"pattern"}set type(t){i("warn","Setting type has no effect",t)}constructor(e){t(this,"repeat","repeat"),t(this,"offsetX",0),t(this,"offsetY",0),t(this,"crossOrigin",""),this.id=pt(),Object.assign(this,e)}isImageSource(){return!!this.source&&"string"==typeof this.source.src}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&0!==this.source.naturalWidth&&0!==this.source.naturalHeight)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return{...zt(this,t),type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:qt(this.offsetX,r.NUM_FRACTION_DIGITS),offsetY:qt(this.offsetY,r.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG(t){let{width:e,height:r}=t;const{source:i,repeat:n,id:s}=this,o=_s(this.offsetX/e,0),a=_s(this.offsetY/r,0),h="repeat-y"===n||"no-repeat"===n?1+Math.abs(o||0):_s(i.width/e,0),l="repeat-x"===n||"no-repeat"===n?1+Math.abs(a||0):_s(i.height/r,0);return[`<pattern id="SVGID_${re(s)}" x="${o}" y="${a}" width="${h}" height="${l}">`,`<image x="0" y="0" width="${i.width}" height="${i.height}" xlink:href="${re(this.sourceToString())}"></image>`,"</pattern>",""].join("\n")}static async fromObject(t,e){let{type:r,source:i,patternTransform:n,...s}=t;const o=await It(i,{...e,crossOrigin:s.crossOrigin});return new this({...s,patternTransform:n&&n.slice(0),source:o})}}t(Ms,"type","Pattern"),tt.setClass(Ms),tt.setClass(Ms,"pattern");class Ds extends Pi{constructor(t){let{path:e,left:r,top:i,...n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,Ds.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),"number"==typeof r&&this.set(k,r),"number"==typeof i&&this.set(L,i)}_setPath(t,e){this.path=Dn(Array.isArray(t)?t:Kn(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new ot(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,r=-this.pathOffset.y;t.beginPath();for(const i of this.path)switch(i[0]){case"L":t.lineTo(i[1]+e,i[2]+r);break;case"M":t.moveTo(i[1]+e,i[2]+r);break;case"C":t.bezierCurveTo(i[1]+e,i[2]+r,i[3]+e,i[4]+r,i[5]+e,i[6]+r);break;case"Q":t.quadraticCurveTo(i[1]+e,i[2]+r,i[3]+e,i[4]+r);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return`#<Path (${this.complexity()}): { "top": ${this.top}, "left": ${this.left} }>`}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{...super.toObject(t),path:this.path.map(t=>t.slice())}}toDatalessObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){return["<path ","COMMON_PARTS",`d="${Jn(this.path,r.NUM_FRACTION_DIGITS)}" stroke-linecap="round" />\n`]}_getOffsetTransform(){const t=r.NUM_FRACTION_DIGITS;return` translate(${qt(-this.pathOffset.x,t)}, ${qt(-this.pathOffset.y,t)})`}toClipPathSVG(t){const e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:r,pathOffset:i}=this._calcDimensions();this.set({width:e,height:r,pathOffset:i}),t&&this.setPositionByOrigin(i,A,A)}_calcBoundsFromPath(){const t=[];let e=0,r=0,i=0,n=0;for(const s of this.path)switch(s[0]){case"L":i=s[1],n=s[2],t.push({x:e,y:r},{x:i,y:n});break;case"M":i=s[1],n=s[2],e=i,r=n;break;case"C":t.push(...En(i,n,s[1],s[2],s[3],s[4],s[5],s[6])),i=s[5],n=s[6];break;case"Q":t.push(...En(i,n,s[1],s[2],s[1],s[2],s[3],s[4])),i=s[3],n=s[4];break;case"Z":i=e,n=r}return de(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return{...t,pathOffset:new ot(t.left+t.width/2,t.top+t.height/2)}}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,r){const{d:i,...n}=ln(t,this.ATTRIBUTE_NAMES,r);return new this(i,{...n,...e,left:void 0,top:void 0})}}t(Ds,"type","Path"),t(Ds,"cacheProperties",[...kr,"path","fillRule"]),t(Ds,"ATTRIBUTE_NAMES",[...zi,"d"]),tt.setClass(Ds),tt.setSVGClass(Ds);const Fs=["radius","startAngle","endAngle","counterClockwise"];class js extends Pi{static getDefaults(){return{...super.getDefaults(),...js.ownDefaults}}constructor(t){super(),Object.assign(this,js.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),"radius"===t&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,wt(this.startAngle),wt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(q)}getRadiusY(){return this.get("radius")*this.get(W)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...Fs,...t])}_toSVG(){const{radius:t,startAngle:e,endAngle:r}=this,i=(r-e)%360;if(0===i)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',`${re(t)}`,'" />\n'];{const n=wt(e),s=wt(r),o=nt(n)*t,a=st(n)*t,h=nt(s)*t,l=st(s)*t;return[`<path d="M ${o} ${a} A ${t} ${t} 0 ${i>180?1:0} ${this.counterClockwise?0:1} ${h} ${l}" `,"COMMON_PARTS"," />\n"]}}static async fromElement(t,e,r){const{left:i=0,top:n=0,radius:s=0,...o}=ln(t,this.ATTRIBUTE_NAMES,r);return new this({...o,radius:s,left:i-s,top:n-s})}static fromObject(t){return super._fromObject(t)}}t(js,"type","Circle"),t(js,"cacheProperties",[...kr,...Fs]),t(js,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),t(js,"ATTRIBUTE_NAMES",["cx","cy","r",...zi]),tt.setClass(js),tt.setSVGClass(js);const Is=["x1","x2","y1","y2"];class Bs extends Pi{constructor(){let[t,e,r,i]=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,Bs.ownDefaults),this.setOptions(n),this.x1=t,this.x2=r,this.y1=e,this.y2=i,this._setWidthHeight();const{left:s,top:o}=n;"number"==typeof s&&this.set(k,s),"number"==typeof o&&this.set(L,o)}_setWidthHeight(){const{x1:t,y1:e,x2:r,y2:i}=this;this.width=Math.abs(r-t),this.height=Math.abs(i-e);const{left:n,top:s,width:o,height:a}=de([{x:t,y:e},{x:r,y:i}]),h=new ot(n+o/2,s+a/2);this.setPositionByOrigin(h,A,A)}_set(t,e){return super._set(t,e),Is.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const r=t.strokeStyle;var i;Ht(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=null!==(i=this.stroke)&&void 0!==i?i:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=r}_findCenterFromElement(){return new ot((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{...super.toObject(t),...this.calcLinePoints()}}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:r,y2:i,width:n,height:s}=this,o=t<=e?-.5:.5,a=r<=i?-.5:.5;return{x1:o*n,x2:o*-n,y1:a*s,y2:a*-s}}_toSVG(){const{x1:t,x2:e,y1:r,y2:i}=this.calcLinePoints();return["<line ","COMMON_PARTS",`x1="${t}" y1="${r}" x2="${e}" y2="${i}" />\n`]}static async fromElement(t,e,r){const{x1:i=0,y1:n=0,x2:s=0,y2:o=0,...a}=ln(t,this.ATTRIBUTE_NAMES,r);return new this([i,n,s,o],a)}static fromObject(t){let{x1:e,y1:r,x2:i,y2:n,...s}=t;return this._fromObject({...s,points:[e,r,i,n]},{extraParam:"points"})}}t(Bs,"type","Line"),t(Bs,"cacheProperties",[...kr,...Is]),t(Bs,"ATTRIBUTE_NAMES",zi.concat(Is)),tt.setClass(Bs),tt.setSVGClass(Bs);class Rs extends Pi{static getDefaults(){return{...super.getDefaults(),...Rs.ownDefaults}}constructor(t){super(),Object.assign(this,Rs.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,r),t.lineTo(0,-r),t.lineTo(e,r),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',`${-t} ${e},0 ${-e},${t} ${e}`,'" />']}}t(Rs,"type","Triangle"),t(Rs,"ownDefaults",{width:100,height:100}),tt.setClass(Rs),tt.setSVGClass(Rs);const zs=["rx","ry"];class Us extends Pi{static getDefaults(){return{...super.getDefaults(),...Us.ownDefaults}}constructor(t){super(),Object.assign(this,Us.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._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(){return this.get("rx")*this.get(q)}getRy(){return this.get("ry")*this.get(W)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...zs,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",`cx="0" cy="0" rx="${re(this.rx)}" ry="${re(this.ry)}" />\n`]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,w,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){const i=ln(t,this.ATTRIBUTE_NAMES,r);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}}t(Us,"type","Ellipse"),t(Us,"cacheProperties",[...kr,...zs]),t(Us,"ownDefaults",{rx:0,ry:0}),t(Us,"ATTRIBUTE_NAMES",[...zi,"cx","cy","rx","ry"]),tt.setClass(Us),tt.setSVGClass(Us);const qs={exactBoundingBox:!1};class Ws extends Pi{static getDefaults(){return{...super.getDefaults(),...Ws.ownDefaults}}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),t(this,"strokeDiff",void 0),Object.assign(this,Ws.ownDefaults),this.setOptions(r),this.points=e;const{left:i,top:n}=r;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof i&&this.set(k,i),"number"==typeof n&&this.set(L,n)}isOpen(){return!0}_projectStrokeOnPoints(t){return Fi(this.points,t,this.isOpen())}_calcDimensions(t){t={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth,...t||{}};const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(t=>t.projectedPoint):this.points;if(0===e.length)return{left:0,top:0,width:0,height:0,pathOffset:new ot,strokeOffset:new ot,strokeDiff:new ot};const r=de(e),i=Ft({...t,scaleX:1,scaleY:1}),n=de(this.points.map(t=>St(t,i,!0))),s=new ot(this.scaleX,this.scaleY);let o=r.left+r.width/2,a=r.top+r.height/2;return this.exactBoundingBox&&(o-=a*Math.tan(wt(this.skewX)),a-=o*Math.tan(wt(this.skewY))),{...r,pathOffset:new ot(o,a),strokeOffset:new ot(n.left,n.top).subtract(new ot(r.left,r.top)).multiply(s),strokeDiff:new ot(r.width,r.height).subtract(new ot(n.width,n.height)).multiply(s)}}_findCenterFromElement(){const t=de(this.points);return new ot(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:r,width:i,height:n,pathOffset:s,strokeOffset:o,strokeDiff:a}=this._calcDimensions();this.set({width:i,height:n,pathOffset:s,strokeOffset:o,strokeDiff:a}),t&&this.setPositionByOrigin(new ot(e+i/2,r+n/2),A,A)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new ot(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.exactBoundingBox){let s;if(Object.keys(t).some(t=>this.strokeUniform||this.constructor.layoutProperties.includes(t))){var e,r;const{width:i,height:n}=this._calcDimensions(t);s=new ot(null!==(e=t.width)&&void 0!==e?e:i,null!==(r=t.height)&&void 0!==r?r:n)}else{var i,n;s=new ot(null!==(i=t.width)&&void 0!==i?i:this.width,null!==(n=t.height)&&void 0!==n?n:this.height)}return s.multiply(new ot(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const r=this.initialized&&this[t]!==e,i=super._set(t,e);return this.exactBoundingBox&&r&&((t===q||t===W)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),i}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{...super.toObject(t),points:this.points.map(t=>{let{x:e,y:r}=t;return{x:e,y:r}})}}_toSVG(){const t=this.pathOffset.x,e=this.pathOffset.y,i=r.NUM_FRACTION_DIGITS,n=this.points.map(r=>{let{x:n,y:s}=r;return`${qt(n-t,i)},${qt(s-e,i)}`}).join(" ");return[`<${re(this.constructor.type).toLowerCase()} `,"COMMON_PARTS",`points="${n}" />\n`]}_render(t){const e=this.points.length,r=this.pathOffset.x,i=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-r,this.points[0].y-i);for(let n=0;n<e;n++){const e=this.points[n];t.lineTo(e.x-r,e.y-i)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,r){const i=function(t){if(!t)return[];const e=t.replace(/,/g," ").trim().split(/\s+/),r=[];for(let t=0;t<e.length;t+=2)r.push({x:parseFloat(e[t]),y:parseFloat(e[t+1])});return r}(t.getAttribute("points")),{left:n,top:s,...o}=ln(t,this.ATTRIBUTE_NAMES,r);return new this(i,{...o,...e})}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}t(Ws,"ownDefaults",qs),t(Ws,"type","Polyline"),t(Ws,"layoutProperties",[H,V,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),t(Ws,"cacheProperties",[...kr,"points"]),t(Ws,"ATTRIBUTE_NAMES",[...zi]),tt.setClass(Ws),tt.setSVGClass(Ws);class Hs extends Ws{isOpen(){return!1}}t(Hs,"ownDefaults",qs),t(Hs,"type","Polygon"),tt.setClass(Hs),tt.setSVGClass(Hs);class Vs extends Pi{isEmptyStyles(t){if(!this.styles)return!0;if(void 0!==t&&!this.styles[t])return!0;const e=void 0===t?this.styles:{line:this.styles[t]};for(const t in e)for(const r in e[t])for(const i in e[t][r])return!1;return!0}styleHas(t,e){if(!this.styles)return!1;if(void 0!==e&&!this.styles[e])return!1;const r=void 0===e?this.styles:{0:this.styles[e]};for(const e in r)for(const i in r[e])if(void 0!==r[e][i][t])return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let r,i,n=0,s=!0,o=0;for(const o in e){r=0;for(const a in e[o]){const h=e[o][a]||{};n++,void 0!==h[t]?(i?h[t]!==i&&(s=!1):i=h[t],h[t]===this[t]&&delete h[t]):s=!1,0!==Object.keys(h).length?r++:delete e[o][a]}0===r&&delete e[o]}for(let t=0;t<this._textLines.length;t++)o+=this._textLines[t].length;s&&n===o&&(this[t]=i,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let r,i,n;for(i in e){for(n in r=e[i],r)delete r[n][t],0===Object.keys(r[n]).length&&delete r[n];0===Object.keys(r).length&&delete e[i]}}_extendStyles(t,e){const{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t);this._getLineStyle(r)||this._setLineStyle(r);const n=Ut({...this._getStyleDeclaration(r,i),...e},t=>void 0!==t);this._setStyleDeclaration(r,i,n)}getSelectionStyles(t,e,r){const i=[];for(let n=t;n<(e||t);n++)i.push(this.getStyleAtPosition(n,r));return i}getStyleAtPosition(t,e){const{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(r,i):this._getStyleDeclaration(r,i)}setSelectionStyles(t,e,r){for(let i=e;i<(r||e);i++)this._extendStyles(i,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var r;const i=this.styles&&this.styles[t];return i&&null!==(r=i[e])&&void 0!==r?r:{}}getCompleteStyleDeclaration(t,e){return{...zt(this,this.constructor._styleProperties),...this._getStyleDeclaration(t,e)}}_setStyleDeclaration(t,e,r){this.styles[t][e]=r}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}t(Vs,"_styleProperties",hr);const Ys=/  +/g,Xs=/"/g;function Gs(t,e,i,n,s){return`\t\t${function(t,e){let{left:i,top:n,width:s,height:o}=e,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r.NUM_FRACTION_DIGITS;const h=tr(Y,t,!1),[l,c,u,f]=[i,n,s,o].map(t=>qt(t,a));return`<rect ${h} x="${l}" y="${c}" width="${u}" height="${f}"></rect>`}(t,{left:e,top:i,width:n,height:s})}\n`}let $s;class Ks extends Vs{static getDefaults(){return{...super.getDefaults(),...Ks.ownDefaults}}constructor(e,r){super(),t(this,"__charBounds",[]),Object.assign(this,Ks.ownDefaults),this.setOptions(r),this.styles||(this.styles={}),this.text=e,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Hn(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(cr)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,r,i,n,s,o;for(let a=0,h=this._textLines.length;a<h;a++)if((this.textAlign===cr||a!==h-1&&!this.isEndOfWrapping(a))&&(i=0,n=this._textLines[a],e=this.getLineWidth(a),e<this.width&&(o=this.textLines[a].match(this._reSpacesAndTabs)))){r=o.length,t=(this.width-e)/r;for(let e=0;e<=n.length;e++)s=this.__charBounds[a][e],this._reSpaceAndTab.test(n[e])?(s.width+=t,s.kernedWidth+=t,s.left+=i,i+=t):s.left+=i}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const r=e?this._unwrappedTextLines:this._textLines;let i;for(i=0;i<r.length;i++){if(t<=r[i].length)return{lineIndex:i,charIndex:t};t-=r[i].length+this.missingNewlineOffset(i,e)}return{lineIndex:i-1,charIndex:r[i-1].length<t?r[i-1].length:t}}toString(){return`#<Text (${this.complexity()}): { "text": "${this.text}", "fontFamily": "${this.fontFamily}" }>`}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const 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(t){this.paintFirst===X?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,r){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case A:t.textBaseline="middle";break;case"ascender":t.textBaseline=L;break;case"descender":t.textBaseline=T}t.font=this._getFontDeclaration(e,r)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,r=this._textLines.length;e<r;e++){const r=this.getLineWidth(e);r>t&&(t=r)}return t}_renderTextLine(t,e,r,i,n,s){this._renderChars(t,e,r,i,n,s)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,r=this._getLeftOffset();let i=this._getTopOffset();for(let e=0,n=this._textLines.length;e<n;e++){const n=this.getHeightOfLine(e);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",e)){i+=n;continue}const s=this._textLines[e].length,o=this._getLineLeftOffset(e);let a,h,l=0,c=0,u=this.getValueOfPropertyAt(e,0,"textBackgroundColor");const f=this.getHeightOfLineImpl(e);for(let n=0;n<s;n++){const s=this.__charBounds[e][n];h=this.getValueOfPropertyAt(e,n,"textBackgroundColor"),this.path?(t.save(),t.translate(s.renderLeft,s.renderTop),t.rotate(s.angle),t.fillStyle=h,h&&t.fillRect(-s.width/2,-f*(1-this._fontSizeFraction),s.width,f),t.restore()):h!==u?(a=r+o+c,this.direction===K&&(a=this.width-a-l),t.fillStyle=u,u&&t.fillRect(a,i,l,f),c=s.left,l=s.width,u=h):l+=s.kernedWidth}h&&!this.path&&(a=r+o+c,this.direction===K&&(a=this.width-a-l),t.fillStyle=h,t.fillRect(a,i,l,f)),i+=n}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,r,i){const n=g.getFontCache(e),s=this._getFontDeclaration(e),o=r?r+t:t,a=r&&s===this._getFontDeclaration(i),h=e.fontSize/this.CACHE_FONT_SIZE;let l,c,u,f;if(r&&n.has(r)&&(u=n.get(r)),n.has(t)&&(f=l=n.get(t)),a&&n.has(o)&&(c=n.get(o),f=c-u),void 0===l||void 0===u||void 0===c){const i=function(){if(!$s){const t=vt({width:0,height:0});$s=t.getContext("2d")}return $s}();this._setTextStyles(i,e,!0),void 0===l&&(f=l=i.measureText(t).width,n.set(t,l)),void 0===u&&a&&r&&(u=i.measureText(r).width,n.set(r,u)),a&&void 0===c&&(c=i.measureText(o).width,n.set(o,c),f=c-u)}return{width:l*h,kernedWidth:f*h}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,r,i=0;const n=this.pathSide===P,s=this.path,o=this._textLines[t],a=o.length,h=new Array(a);this.__charBounds[t]=h;for(let n=0;n<a;n++){const s=o[n];r=this._getGraphemeBox(s,t,n,e),h[n]=r,i+=r.kernedWidth,e=s}if(h[a]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},s&&s.segmentsInfo){let t=0;const e=s.segmentsInfo[s.segmentsInfo.length-1].length;switch(this.textAlign){case k:t=n?e-i:0;break;case A:t=(e-i)/2;break;case P:t=n?0:e-i}t+=this.pathStartOffset*(n?-1:1);for(let i=n?a-1:0;n?i>=0:i<a;n?i--:i++)r=h[i],t>e?t%=e:t<0&&(t+=e),this._setGraphemeOnPath(t,r),t+=r.kernedWidth}return{width:i,numOfSpaces:0}}_setGraphemeOnPath(t,e){const r=t+e.kernedWidth/2,i=this.path,n=Vn(i.path,r,i.segmentsInfo);e.renderLeft=n.x-i.pathOffset.x,e.renderTop=n.y-i.pathOffset.y,e.angle=n.angle+(this.pathSide===P?Math.PI:0)}_getGraphemeBox(t,e,r,i,n){const s=this.getCompleteStyleDeclaration(e,r),o=i?this.getCompleteStyleDeclaration(e,r-1):{},a=this._measureChar(t,s,i,o);let h,l=a.kernedWidth,c=a.width;0!==this.charSpacing&&(h=this._getWidthOfCharSpacing(),c+=h,l+=h);const u={width:c,left:0,height:s.fontSize,kernedWidth:l,deltaY:s.deltaY};if(r>0&&!n){const t=this.__charBounds[e][r-1];u.left=t.left+t.width+a.kernedWidth-a.width}return u}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let r=this.getHeightOfChar(t,0);for(let e=1,i=this._textLines[t].length;e<i;e++)r=Math.max(this.getHeightOfChar(t,e),r);return e[t]=r*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,r=this._textLines.length;e<r;e++)t+=e===r-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction===$?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let r=0;const i=this._getLeftOffset(),n=this._getTopOffset();for(let s=0,o=this._textLines.length;s<o;s++)this._renderTextLine(e,t,this._textLines[s],i+this._getLineLeftOffset(s),n+r+this.getHeightOfLineImpl(s),s),r+=this.getHeightOfLine(s);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Y))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,r,i,n,s){const o=this.textAlign.includes(cr),a=this.path,h=!o&&0===this.charSpacing&&this.isEmptyStyles(s)&&!a,l=this.direction===$,c=this.direction===$?1:-1,u=e.direction;let f,d,p,g,m,v="",y=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",l?$:K),e.direction=l?$:K,e.textAlign=l?k:P),n-=this.getHeightOfLineImpl(s)*this._fontSizeFraction,h)return this._renderChar(t,e,s,0,r.join(""),i,n),void e.restore();for(let h=0,l=r.length-1;h<=l;h++)g=h===l||this.charSpacing||a,v+=r[h],p=this.__charBounds[s][h],0===y?(i+=c*(p.kernedWidth-p.width),y+=p.width):y+=p.kernedWidth,o&&!g&&this._reSpaceAndTab.test(r[h])&&(g=!0),g||(f=f||this.getCompleteStyleDeclaration(s,h),d=this.getCompleteStyleDeclaration(s,h+1),g=Ii(f,d,!1)),g&&(a?(e.save(),e.translate(p.renderLeft,p.renderTop),e.rotate(p.angle),this._renderChar(t,e,s,h,v,-y/2,0),e.restore()):(m=i,this._renderChar(t,e,s,h,v,m,n)),v="",f=d,i+=c*y,y=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,i=vt({width:e,height:r}),n=i.getContext("2d");return i.width=e,i.height=r,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,r),n.lineTo(0,r),n.closePath(),n.translate(e/2,r/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(i,"no-repeat")}handleFiller(t,e,r){let i,n;return Ht(r)?"percentage"===r.gradientUnits||r.gradientTransform||r.patternTransform?(i=-this.width/2,n=-this.height/2,t.translate(i,n),t[e]=this._applyPatternGradientTransformText(r),{offsetX:i,offsetY:n}):(t[e]=r.toLive(t),this._applyPatternGradientTransform(t,r)):(t[e]=r,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:r,strokeWidth:i}=e;return t.lineWidth=i,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",r)}_setFillStyles(t,e){let{fill:r}=e;return this.handleFiller(t,"fillStyle",r)}_renderChar(t,e,r,i,n,s,o){const a=this._getStyleDeclaration(r,i),h=this.getCompleteStyleDeclaration(r,i),l="fillText"===t&&h.fill,c="strokeText"===t&&h.stroke&&h.strokeWidth;if(c||l){if(e.save(),e.font=this._getFontDeclaration(h),a.textBackgroundColor&&this._removeShadow(e),a.deltaY&&(o+=a.deltaY),l){const t=this._setFillStyles(e,h);e.fillText(n,s-t.offsetX,o-t.offsetY)}if(c){const t=this._setStrokeStyles(e,h);e.strokeText(n,s-t.offsetX,o-t.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,r){const i=this.get2DCursorLocation(t,!0),n=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"fontSize"),s=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"deltaY"),o={fontSize:n*r.size,deltaY:s+n*r.baseline};this.setSelectionStyles(o,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),r=this.width-e,i=this.textAlign,n=this.direction,s=this.isEndOfWrapping(t);let o=0;return i===cr||i===dr&&!s||i===fr&&!s||i===ur&&!s?0:(i===A&&(o=r/2),i===P&&(o=r),i===dr&&(o=r/2),i===fr&&(o=r),n===K&&(i===P||i===fr?o=0:i===k||i===ur?o=-r:i!==A&&i!==dr||(o=-r/2)),o)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(void 0!==this.__lineWidths[t])return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,r){var i;return null!==(i=this._getStyleDeclaration(t,e)[r])&&void 0!==i?i:this[r]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let r=this._getTopOffset();const i=this._getLeftOffset(),n=this.path,s=this._getWidthOfCharSpacing(),o="linethrough"===e?.5:"overline"===e?1:0,a=this.offsets[e];for(let h=0,l=this._textLines.length;h<l;h++){const l=this.getHeightOfLine(h);if(!this[e]&&!this.styleHas(e,h)){r+=l;continue}const c=this._textLines[h],u=l/this.lineHeight,f=this._getLineLeftOffset(h);let d=0,p=0,g=this.getValueOfPropertyAt(h,0,e),m=this.getValueOfPropertyAt(h,0,Y),v=this.getValueOfPropertyAt(h,0,ir),y=g,b=m,w=v;const _=r+u*(1-this._fontSizeFraction);let x=this.getHeightOfChar(h,0),S=this.getValueOfPropertyAt(h,0,"deltaY");for(let r=0,s=c.length;r<s;r++){const s=this.__charBounds[h][r];y=this.getValueOfPropertyAt(h,r,e),b=this.getValueOfPropertyAt(h,r,Y),w=this.getValueOfPropertyAt(h,r,ir);const l=this.getHeightOfChar(h,r),c=this.getValueOfPropertyAt(h,r,"deltaY");if(n&&y&&b){const e=this.fontSize*w/1e3;t.save(),t.fillStyle=m,t.translate(s.renderLeft,s.renderTop),t.rotate(s.angle),t.fillRect(-s.kernedWidth/2,a*l+c-o*e,s.kernedWidth,e),t.restore()}else if((y!==g||b!==m||l!==x||w!==v||c!==S)&&p>0){const e=this.fontSize*v/1e3;let r=i+f+d;this.direction===K&&(r=this.width-r-p),g&&m&&v&&(t.fillStyle=m,t.fillRect(r,_+a*x+S-o*e,p,e)),d=s.left,p=s.width,g=y,v=w,m=b,x=l,S=c}else p+=s.kernedWidth}let C=i+f+d;this.direction===K&&(C=this.width-C-p),t.fillStyle=b;const A=this.fontSize*w/1e3;y&&b&&w&&t.fillRect(C,_+a*x+S-o*A,p-s,A),r+=l}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:r=this.fontWeight,fontSize:i=this.fontSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;const s=t.includes("'")||t.includes('"')||t.includes(",")||Ks.genericFonts.includes(t.toLowerCase())?t:`"${t}"`;return[e,r,`${n?this.CACHE_FONT_SIZE:i}px`,s].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return ne(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),r=new Array(e.length),i=["\n"];let n=[];for(let t=0;t<e.length;t++)r[t]=this.graphemeSplit(e[t]),n=n.concat(r[t],i);return n.pop(),{_unwrappedLines:r,lines:e,graphemeText:n,graphemeLines:r}}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{...super.toObject([...ar,...t]),styles:Bi(this.styles,this.text),...this.path?{path:this.path.toObject()}:{}}}set(t,e){const{textLayoutProperties:r}=this.constructor;super.set(t,e);let i=!1,n=!1;if("object"==typeof t)for(const e in t)"path"===e&&this.setPathInfo(),i=i||r.includes(e),n=n||"path"===e;else i=r.includes(t),n="path"===t;return n&&this.setPathInfo(),i&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,r){const i=ln(t,Ks.ATTRIBUTE_NAMES,r),{textAnchor:n=k,textDecoration:s="",dx:o=0,dy:a=0,top:h=0,left:l=0,fontSize:c=S,strokeWidth:u=1,...f}={...e,...i},d=new this(He(t.textContent||"").trim(),{left:l+o,top:h+a,underline:s.includes("underline"),overline:s.includes("overline"),linethrough:s.includes("line-through"),strokeWidth:0,fontSize:c,...f}),p=d.getScaledHeight()/d.height,g=((d.height+d.strokeWidth)*d.lineHeight-d.height)*p,m=d.getScaledHeight()+g;let v=0;return n===A&&(v=d.getScaledWidth()/2),n===P&&(v=d.getScaledWidth()),d.set({left:d.left-v,top:d.top-(m-d.fontSize*(.07+d._fontSizeFraction))/d.lineHeight,strokeWidth:u}),d}static fromObject(t){return this._fromObject({...t,styles:Ri(t.styles||{},t.text)},{extraParam:"text"})}}t(Ks,"textLayoutProperties",or),t(Ks,"cacheProperties",[...kr,...ar]),t(Ks,"ownDefaults",lr),t(Ks,"type","Text"),t(Ks,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),t(Ks,"ATTRIBUTE_NAMES",zi.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Ti(Ks,[class extends er{_toSVG(){const t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){const e=this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0}),r=this.path;return r?e+r._createBaseSVGMarkup(r._toSVG(),{reviver:t,withShadow:!0,additionalTransform:Wt(this.calcOwnMatrix())}):e}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(t){let{textBgRects:e,textSpans:r}=t;const i=this.getSvgTextDecoration(this);return[e.join(""),'\t\t<text xml:space="preserve" ',`font-family="${re(this.fontFamily.replace(Xs,"'"))}" `,`font-size="${re(this.fontSize)}" `,this.fontStyle?`font-style="${re(this.fontStyle)}" `:"",this.fontWeight?`font-weight="${re(this.fontWeight)}" `:"",i?`text-decoration="${i}" `:"","rtl"===this.direction?'direction="rtl" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",r.join(""),"</text>\n"]}_getSVGTextAndBg(t,e){const r=[],i=[];let n,s=t;this.backgroundColor&&i.push(Gs(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let t=0,o=this._textLines.length;t<o;t++)n=this._getLineLeftOffset(t),"rtl"===this.direction&&(n+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",t))&&this._setSVGTextLineBg(i,t,e+n,s),this._setSVGTextLineText(r,t,e+n,s),s+=this.getHeightOfLine(t);return{textSpans:r,textBgRects:i}}_createTextCharSpan(t,e,i,n,s){const o=r.NUM_FRACTION_DIGITS,a=this.getSvgSpanStyles(e,t!==t.trim()||!!t.match(Ys)),h=a?`style="${a}"`:"",l=e.deltaY,c=l?` dy="${qt(l,o)}" `:"",{angle:u,renderLeft:f,renderTop:d,width:p}=s;let g="";if(void 0!==f){const t=p/2;u&&(g=` rotate="${qt(_t(u),o)}"`);const e=Nt({angle:_t(u)});e[4]=f,e[5]=d;const r=new ot(-t,0).transform(e);i=r.x,n=r.y}return`<tspan x="${qt(i,o)}" y="${qt(n,o)}" ${c}${g}${h}>${re(t)}</tspan>`}_setSVGTextLineText(t,e,r,i){const n=this.getHeightOfLine(e),s=this.textAlign.includes(cr),o=this._textLines[e];let a,h,l,c,u,f="",d=0;i+=n*(1-this._fontSizeFraction)/this.lineHeight;for(let n=0,p=o.length-1;n<=p;n++)u=n===p||this.charSpacing||this.path,f+=o[n],l=this.__charBounds[e][n],0===d?(r+=l.kernedWidth-l.width,d+=l.width):d+=l.kernedWidth,s&&!u&&this._reSpaceAndTab.test(o[n])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(e,n),h=this.getCompleteStyleDeclaration(e,n+1),u=Ii(a,h,!0)),u&&(c=this._getStyleDeclaration(e,n),t.push(this._createTextCharSpan(f,c,r,i,l)),f="",a=h,"rtl"===this.direction?r-=d:r+=d,d=0)}_setSVGTextLineBg(t,e,r,i){const n=this._textLines[e],s=this.getHeightOfLine(e)/this.lineHeight;let o,a=0,h=0,l=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let c=0;c<n.length;c++){const{left:n,width:u,kernedWidth:f}=this.__charBounds[e][c];o=this.getValueOfPropertyAt(e,c,"textBackgroundColor"),o!==l?(l&&t.push(Gs(l,r+h,i,a,s)),h=n,a=u,l=o):a+=f}o&&t.push(Gs(l,r+h,i,a,s))}getSvgStyles(t){return`${super.getSvgStyles(t)} text-decoration-thickness: ${qt(this.textDecorationThickness*this.getObjectScaling().y/10,r.NUM_FRACTION_DIGITS)}%; white-space: pre;`}getSvgSpanStyles(t,e){const{fontFamily:i,strokeWidth:n,stroke:s,fill:o,fontSize:a,fontStyle:h,fontWeight:l,textDecorationThickness:c,linethrough:u,overline:f,underline:d}=t,p=this.getSvgTextDecoration({underline:null!=d?d:this.underline,overline:null!=f?f:this.overline,linethrough:null!=u?u:this.linethrough}),g=c||this.textDecorationThickness;return[s?tr(X,s):"",n?`stroke-width: ${re(n)}; `:"",i?`font-family: ${i.includes("'")||i.includes('"')?re(i):`'${re(i)}'`}; `:"",a?`font-size: ${re(a)}px; `:"",h?`font-style: ${re(h)}; `:"",l?`font-weight: ${re(l)}; `:"",p?`text-decoration: ${p}; text-decoration-thickness: ${qt(g*this.getObjectScaling().y/10,r.NUM_FRACTION_DIGITS)}%; `:"",o?tr(Y,o):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(t){return["overline","underline","line-through"].filter(e=>t[e.replace("-","")]).join(" ")}}]),tt.setClass(Ks),tt.setSVGClass(Ks);class Js{constructor(e){t(this,"target",void 0),t(this,"__mouseDownInPlace",!1),t(this,"__dragStartFired",!1),t(this,"__isDraggingOver",!1),t(this,"__dragStartSelection",void 0),t(this,"__dragImageDisposer",void 0),t(this,"_dispose",void 0),this.target=e;const r=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{r.forEach(t=>t()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,r=e.getSelectionStartFromPointer(t);return e.isEditing&&r>=e.selectionStart&&r<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var r;let{selectionStart:i,selectionEnd:n}=e;const s=this.target,o=s.canvas,a=new ot(s.flipX?-1:1,s.flipY?-1:1),h=s._getCursorBoundaries(i),l=new ot(h.left+h.leftOffset,h.top+h.topOffset).multiply(a).transform(s.calcTransformMatrix()),c=o.getScenePoint(t).subtract(l),u=s.getCanvasRetinaScaling(),f=s.getBoundingRect(),d=l.subtract(new ot(f.left,f.top)),p=o.viewportTransform,g=d.add(c).transform(p,!0),m=s.backgroundColor,v=ji(s.styles);s.backgroundColor="";const y={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};s.setSelectionStyles(y,0,i),s.setSelectionStyles(y,n,s.text.length),s.dirty=!0;const b=s.toCanvasElement({enableRetinaScaling:o.enableRetinaScaling,viewportTransform:!0});s.backgroundColor=m,s.styles=v,s.dirty=!0,Zn(b,{position:"fixed",left:-b.width+"px",border:N,width:b.width/u+"px",height:b.height/u+"px"}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{b.remove()},$t(t.target||this.target.hiddenTextarea).body.appendChild(b),null===(r=t.dataTransfer)||void 0===r||r.setDragImage(b,g.x,g.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,r=this.isActive();if(r&&t.dataTransfer){const r=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},i=e._text.slice(r.selectionStart,r.selectionEnd).join(""),n={text:e.text,value:i,...r};t.dataTransfer.setData("text/plain",i),t.dataTransfer.setData("application/fabric",JSON.stringify({value:i,styles:e.getSelectionStyles(r.selectionStart,r.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,n)}return e.abortCursorAnimation(),r}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),r=this.__dragStartSelection;return e<r.selectionStart||e>r.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const r=this.targetCanDrop(e);!this.__isDraggingOver&&r&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,r=this.targetCanDrop(e);!this.__isDraggingOver&&r?this.__isDraggingOver=!0:this.__isDraggingOver&&!r&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:r}=t,i=r.defaultPrevented;this.__isDraggingOver=!1,r.preventDefault();let n=null===(e=r.dataTransfer)||void 0===e?void 0:e.getData("text/plain");if(n&&!i){const e=this.target,i=e.canvas;let s=e.getSelectionStartFromPointer(r);const{styles:o}=r.dataTransfer.types.includes("application/fabric")?JSON.parse(r.dataTransfer.getData("application/fabric")):{},a=n[Math.max(0,n.length-1)],h=0;if(this.__dragStartSelection){const t=this.__dragStartSelection.selectionStart,r=this.__dragStartSelection.selectionEnd;s>t&&s<=r?s=t:s>r&&(s-=r-t),e.removeChars(t,r),delete this.__dragStartSelection}e._reNewline.test(a)&&(e._reNewline.test(e._text[s])||s===e._text.length)&&(n=n.trimEnd()),t.didDrop=!0,t.dropTarget=e,e.insertChars(n,o,s),i.setActiveObject(e),e.enterEditing(r),e.selectionStart=Math.min(s+h,e._text.length),e.selectionEnd=Math.min(e.selectionStart+n.length,e._text.length),e.hiddenTextarea.value=e.text,e._updateTextarea(),e.hiddenTextarea.focus(),e.fire(z,{index:s+h,action:"drop"}),i.fire("text:changed",{target:e}),i.contextTopDirty=!0,i.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var r;const t=this.target,i=this.target.canvas,{selectionStart:n,selectionEnd:s}=this.__dragStartSelection,o=(null===(r=e.dataTransfer)||void 0===r?void 0:r.dropEffect)||N;o===N?(t.selectionStart=n,t.selectionEnd=s,t._updateTextarea(),t.hiddenTextarea.focus()):(t.clearContextTop(),"move"===o&&(t.removeChars(n,s),t.selectionStart=t.selectionEnd=n,t.hiddenTextarea&&(t.hiddenTextarea.value=t.text),t._updateTextarea(),t.fire(z,{index:n,action:"dragend"}),i.fire("text:changed",{target:t}),i.requestRenderAll()),t.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Zs=/[ \n\.,;!\?\-]/;class Qs extends Ks{constructor(){super(...arguments),t(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:r,delay:i,onComplete:n}=t;return Ur({startValue:this._currentCursorOpacity,endValue:e,duration:r,delay:i,onComplete:n,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:t=>{this._currentCursorOpacity=t,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;null===(t=this._currentTickCompleteState)||void 0===t||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,r=t-1;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r--;for(;/\S/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findWordBoundaryRight(t){let e=0,r=t;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r++;for(;/\S/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}findLineBoundaryLeft(t){let e=0,r=t-1;for(;!/\n/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findLineBoundaryRight(t){let e=0,r=t;for(;!/\n/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}searchWordBoundary(t,e){const r=this._text;let i=t>0&&this._reSpace.test(r[t])&&(-1===e||!O.test(r[t-1]))?t-1:t,n=r[i];for(;i>0&&i<r.length&&!Zs.test(n);)i+=e,n=r[i];return-1===e&&Zs.test(n)&&i++,i}selectWord(t){t=null!=t?t:this.selectionStart;const e=this.searchWordBoundary(t,-1),r=Math.max(e,this.searchWordBoundary(t,1));this.selectionStart=e,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){t=null!=t?t:this.selectionStart;const e=this.findLineBoundaryLeft(t),r=this.findLineBoundaryRight(t);this.selectionStart=e,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;$t(e).activeElement!==e&&e.focus();const r=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;(r===this.__selectionStartOnMouseDown&&i!==n||i!==r&&n!==r)&&(r>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=r):(this.selectionStart=r,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){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(t,e,r){const i=r.slice(0,t),n=this.graphemeSplit(i).length;if(t===e)return{selectionStart:n,selectionEnd:n};const s=r.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(s).length}}fromGraphemeToStringSelection(t,e,r){const i=r.slice(0,t).join("").length;return t===e?{selectionStart:i,selectionEnd:i}:{selectionStart:i,selectionEnd:i+r.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){const{hiddenTextarea:t,direction:e,textAlign:r,inCompositionMode:i}=this;if(!t)return;const n=r!==cr?r.replace("justify-",""):e===$?k:P,s=this.getPositionByOrigin(n,"top");this.cursorOffsetCache={},this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setPositionByOrigin(s,n,"top"),this.setCoords();const o=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=o.selectionEnd,i||(this.selectionStart=o.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),r=this.get2DCursorLocation(t),i=r.lineIndex,n=r.charIndex,s=this.getValueOfPropertyAt(i,n,"fontSize")*this.lineHeight,o=e.leftOffset,a=this.getCanvasRetinaScaling(),h=this.canvas.upperCanvasEl,l=h.width/a,c=h.height/a,u=l-s,f=c-s,d=new ot(e.left+o,e.top+e.topOffset+s).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new ot(h.clientWidth/l,h.clientHeight/c));return d.x<0&&(d.x=0),d.x>u&&(d.x=u),d.y<0&&(d.y=0),d.y>f&&(d.y=f),d.x+=this.canvas._offset.left,d.y+=this.canvas._offset.top,{left:`${d.x}px`,top:`${d.y}px`,fontSize:`${s}px`,charHeight:s}}_saveEditingProps(){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(){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.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}exitEditingImpl(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(G),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:s}=this.get2DCursorLocation(e,!0);if(r!==n){if(this.styles[r])for(let t=i;t<this._unwrappedTextLines[r].length;t++)delete this.styles[r][t];if(this.styles[n])for(let t=s;t<this._unwrappedTextLines[n].length;t++){const e=this.styles[n][t];e&&(this.styles[r]||(this.styles[r]={}),this.styles[r][i+t-s]=e)}for(let t=r+1;t<=n;t++)delete this.styles[t];this.shiftLineStyles(n,r-n)}else if(this.styles[r]){const t=this.styles[r],e=s-i;for(let e=i;e<s;e++)delete t[e];for(const i in this.styles[r]){const r=parseInt(i,10);r>=s&&(t[r-e]=t[i],delete t[i])}}}shiftLineStyles(t,e){const r=Object.assign({},this.styles);for(const i in this.styles){const n=parseInt(i,10);n>t&&(this.styles[n+e]=r[n],r[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,r,i){const n={},s=this._unwrappedTextLines[t].length,o=s===e;let a=!1;r||(r=1),this.shiftLineStyles(t,r);const h=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(const r in this.styles[t]){const i=parseInt(r,10);i>=e&&(a=!0,n[i-e]=this.styles[t][r],o&&0===e||delete this.styles[t][r])}let l=!1;for(a&&!o&&(this.styles[t+r]=n,l=!0),(l||s>e)&&r--;r>0;)i&&i[r-1]?this.styles[t+r]={0:{...i[r-1]}}:h?this.styles[t+r]={0:{...h}}:delete this.styles[t+r],r--;this._forceClearCache=!0}insertCharStyleObject(t,e,r,i){this.styles||(this.styles={});const n=this.styles[t],s=n?{...n}:{};r||(r=1);for(const t in s){const i=parseInt(t,10);i>=e&&(n[i+r]=s[i],s[i-r]||delete n[i])}if(this._forceClearCache=!0,i){for(;r--;)Object.keys(i[r]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+r]={...i[r]});return}if(!n)return;const o=n[e?e-1:1];for(;o&&r--;)this.styles[t][e+r]={...o}}insertNewStyleBlock(t,e,r){const i=this.get2DCursorLocation(e,!0),n=[0];let s,o=0;for(let e=0;e<t.length;e++)"\n"===t[e]?(o++,n[o]=0):n[o]++;for(n[0]>0&&(this.insertCharStyleObject(i.lineIndex,i.charIndex,n[0],r),r=r&&r.slice(n[0]+1)),o&&this.insertNewlineStyleObject(i.lineIndex,i.charIndex+n[0],o),s=1;s<o;s++)n[s]>0?this.insertCharStyleObject(i.lineIndex+s,0,n[s],r):r&&this.styles[i.lineIndex+s]&&r[0]&&(this.styles[i.lineIndex+s][0]=r[0]),r=r&&r.slice(n[s]+1);n[s]>0&&this.insertCharStyleObject(i.lineIndex+s,0,n[s],r)}removeChars(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r;i>r&&this.removeStyleFromTo(r,i);const n=this.graphemeSplit(t);this.insertNewStyleBlock(n,r,e),this._text=[...this._text.slice(0,r),...n,...this._text.slice(i)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,r){r<=t?(e===t?this._selectionDirection=k:this._selectionDirection===P&&(this._selectionDirection=k,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===P?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=P:this._selectionDirection===k&&(this._selectionDirection=P,this.selectionStart=e),this.selectionEnd=r)}}class to extends Qs{initHiddenTextarea(){const t=this.canvas&&$t(this.canvas.getElement())||f(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map(t=>{let[r,i]=t;return e.setAttribute(r,i)});const{top:r,left:i,fontSize:n}=this._calcTextareaPosition();e.style.cssText=`position: absolute; top: ${r}; left: ${i}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${n};`,(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(t=>{let[r,i]=t;return e.addEventListener(r,this[i].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const 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(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(t){const e=this.fromPaste,{value:i,selectionStart:n,selectionEnd:s}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(z),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void o();const a=this._splitTextIntoLines(i).graphemeText,h=this._text.length,l=a.length,c=this.selectionStart,f=this.selectionEnd,d=c!==f;let p,g,m,v,y=l-h;const b=this.fromStringToGraphemeSelection(n,s,i),w=c>b.selectionStart;d?(g=this._text.slice(c,f),y+=f-c):l<h&&(g=w?this._text.slice(f+y,f):this._text.slice(c,c-y));const _=a.slice(b.selectionEnd-y,b.selectionEnd);if(g&&g.length&&(_.length&&(p=this.getSelectionStyles(c,c+1,!1),p=_.map(()=>p[0])),d?(m=c,v=f):w?(m=f-g.length,v=f):(m=f,v=f+g.length),this.removeStyleFromTo(m,v)),_.length){const{copyPasteData:t}=u();e&&_.join("")===t.copiedText&&!r.disableStyleCopyPaste&&(p=t.copiedTextStyle),this.insertNewStyleBlock(_,c,p)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:r,selectionEnd:i}=e;this.compositionStart=r,this.compositionEnd=i,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=u();t.copiedText=this.getSelectedText(),r.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let r,i=this._getLineLeftOffset(t);return e>0&&(r=this.__charBounds[t][e-1],i+=r.left+r.width),i}getDownCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(r),n=i.lineIndex;if(n===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-r;const s=i.charIndex,o=this._getWidthBeforeCursor(n,s),a=this._getIndexOnLine(n+1,o);return this._textLines[n].slice(s).length+a+1+this.missingNewlineOffset(n)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const r=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(r),n=i.lineIndex;if(0===n||t.metaKey||33===t.keyCode)return-r;const s=i.charIndex,o=this._getWidthBeforeCursor(n,s),a=this._getIndexOnLine(n-1,o),h=this._textLines[n].slice(0,s),l=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+a-h.length+(1-l)}_getIndexOnLine(t,e){const r=this._textLines[t];let i,n,s=this._getLineLeftOffset(t),o=0;for(let a=0,h=r.length;a<h;a++)if(i=this.__charBounds[t][a].width,s+=i,s>e){n=!0;const t=s-i,r=s,h=Math.abs(t-e);o=Math.abs(r-e)<h?a:a-1;break}return n||(o=r.length-1),o}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const r=this[`get${t}CursorOffset`](e,this._selectionDirection===P);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),0!==r){const t=this.text.length;this.selectionStart=Cr(0,this.selectionStart,t),this.selectionEnd=Cr(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===k?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t}moveCursorLeft(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)}_move(t,e,r){let i;if(t.altKey)i=this[`findWordBoundary${r}`](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===r?-1:1,!0;i=this[`findLineBoundary${r}`](this[e])}return void 0!==i&&this[e]!==i&&(this[e]=i,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=k,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===P&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=k,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const r=`moveCursor${t}${e.shiftKey?"WithShift":"WithoutShift"}`;this._currentCursorOpacity=1,this[r](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===k&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=P,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=P,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const eo=t=>!!t.button;class ro extends to{constructor(){super(...arguments),t(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new Js(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:r}=t;this.canvas&&this.editable&&!eo(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),r&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=r||this.isEditing)))}mouseUpHandler(t){let{e,transform:r}=t;const i=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const t=this.canvas._activeObject;if(t&&t!==this)return}!this.editable||this.group&&!this.group.interactive||r&&r.actionPerformed||eo(e)||i||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),r=this.selectionStart,i=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(r,i,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ct(this.calcTransformMatrix())).add(new ot(-this._getLeftOffset(),-this._getTopOffset()));let r=0,i=0,n=0;for(let t=0;t<this._textLines.length&&r<=e.y;t++)r+=this.getHeightOfLine(t),n=t,t>0&&(i+=this._textLines[t-1].length+this.missingNewlineOffset(t-1));let s=Math.abs(this._getLineLeftOffset(n));const o=this._textLines[n].length,a=this.__charBounds[n];for(let t=0;t<o;t++){const r=s+a[t].kernedWidth;if(e.x<=r){Math.abs(e.x-r)<=Math.abs(e.x-s)&&i++;break}s=r,i++}return Math.min(this.flipX?o-i:i,this._text.length)}}const io="moveCursorUp",no="moveCursorDown",so="moveCursorLeft",oo="moveCursorRight",ao="exitEditing",ho=(t,e)=>{const r=e.getRetinaScaling();t.setTransform(r,0,0,r,0,0);const i=e.viewportTransform;t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},lo={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,keysMap:{9:ao,27:ao,33:io,34:no,35:oo,36:so,37:so,38:io,39:oo,40:no},keysMapRtl:{9:ao,27:ao,33:io,34:no,35:so,36:oo,37:oo,38:io,39:so,40:no},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"},_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1};class co extends ro{static getDefaults(){return{...super.getDefaults(),...co.ownDefaults}}get type(){const t=super.type;return"itext"===t?"i-text":t}constructor(t,e){super(t,{...co.ownDefaults,...e}),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):("canvas"===t&&(this.canvas instanceof ys&&this.canvas.textEditingManager.remove(this),e instanceof ys&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart||0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionEnd,r=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,r)}setSelectionStyles(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionStart||0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,r)}get2DCursorLocation(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const r=super.toCanvasElement(t);return this.isEditing=e,r}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),r=this.findAncestorsWithClipPath(),i=r.length>0;let n,s=t;if(i){n=vt(t.canvas),s=n.getContext("2d"),ho(s,this.canvas);const e=this.calcTransformMatrix();s.transform(e[0],e[1],e[2],e[3],e[4],e[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(s,e):this.renderCursor(s,e),i)for(const e of r){const r=e.clipPath,i=vt(t.canvas),n=i.getContext("2d");if(ho(n,this.canvas),!r.absolutePositioned){const t=e.calcTransformMatrix();n.transform(t[0],t[1],t[2],t[3],t[4],t[5])}r.transform(n),r.drawObject(n,!0,{}),this.drawClipPathOnCache(s,r,i)}i&&(t.setTransform(1,0,0,1,0,0),t.drawImage(n,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const r=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:r,top:i,leftOffset:n.left,topOffset:n.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,r=0;const{charIndex:i,lineIndex:n}=this.get2DCursorLocation(t),{textAlign:s,direction:o}=this;for(let t=0;t<n;t++)e+=this.getHeightOfLine(t);const a=this._getLineLeftOffset(n),h=this.__charBounds[n][i];h&&(r=h.left),0!==this.charSpacing&&i===this._textLines[n].length&&(r-=this._getWidthOfCharSpacing());let l=a+(r>0?r:0);return o===K&&(s===P||s===cr||s===fr?l*=-1:s===k||s===ur?l=a-(r>0?r:0):s!==A&&s!==dr||(l=a-(r>0?r:0))),{top:e,left:l}}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getCursorBoundaries(t);const r=this.get2DCursorLocation(t),i=r.lineIndex,n=r.charIndex>0?r.charIndex-1:0,s=this.getValueOfPropertyAt(i,n,"fontSize"),o=this.getObjectScaling().x*this.canvas.getZoom(),a=this.cursorWidth/o,h=this.getValueOfPropertyAt(i,n,"deltaY"),l=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(i)/this.lineHeight-s*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(i,n,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-a/2,top:l+e.top+h,width:a,height:s}}_renderCursor(t,e,r){const{color:i,opacity:n,left:s,top:o,width:a,height:h}=this.getCursorRenderingData(r,e);t.fillStyle=i,t.globalAlpha=n,t.fillRect(s,o,a,h)}renderSelection(t,e){const r={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,r,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,r){const{textAlign:i,direction:n}=this,s=e.selectionStart,o=e.selectionEnd,a=i.includes(cr),h=this.get2DCursorLocation(s),l=this.get2DCursorLocation(o),c=h.lineIndex,u=l.lineIndex,f=h.charIndex<0?0:h.charIndex,d=l.charIndex<0?0:l.charIndex;for(let e=c;e<=u;e++){const s=this._getLineLeftOffset(e)||0;let o=this.getHeightOfLine(e),h=0,l=0,p=0;if(e===c&&(l=this.__charBounds[c][f].left),e>=c&&e<u)p=a&&!this.isEndOfWrapping(e)?this.width:this.getLineWidth(e)||5;else if(e===u)if(0===d)p=this.__charBounds[u][d].left;else{const t=this._getWidthOfCharSpacing();p=this.__charBounds[u][d-1].left+this.__charBounds[u][d-1].width-t}h=o,(this.lineHeight<1||e===u&&this.lineHeight>1)&&(o/=this.lineHeight);let g=r.left+s+l,m=o,v=0;const y=p-l;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",m=1,v=o):t.fillStyle=this.selectionColor,n===K&&(i===P||i===cr||i===fr?g=this.width-g-y:i===k||i===ur?g=r.left+s-p:i!==A&&i!==dr||(g=r.left+s-p)),t.fillRect(g,r.top+r.topOffset+v,y,m),r.topOffset+=h}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Y)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}t(co,"ownDefaults",lo),t(co,"type","IText"),tt.setClass(co),tt.setClass(co,"i-text");class uo extends co{static getDefaults(){return{...super.getDefaults(),...uo.ownDefaults}}constructor(t,e){super(t,{...uo.ownDefaults,...e})}static createControls(){return{controls:ki()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(cr)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,r=0,i=0;const n={};for(let s=0;s<t.graphemeLines.length;s++)"\n"===t.graphemeText[i]&&s>0?(r=0,i++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[i])&&s>0&&(r++,i++),n[s]={line:e,offset:r},i+=t.graphemeLines[s].length,r+=t.graphemeLines[s].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const t=this._styleMap[e];t&&(e=t.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,r=0,i=t+1,n=!1;const s=this._styleMap[t],o=this._styleMap[t+1];s&&(t=s.line,r=s.offset),o&&(i=o.line,n=i===t,e=o.offset);const a=void 0===t?this.styles:{line:this.styles[t]};for(const t in a)for(const i in a[t]){const s=parseInt(i,10);if(s>=r&&(!n||s<e))for(const e in a[t][i])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const r=this._styleMap[t];if(!r)return{};t=r.line,e=r.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,r){const i=this._styleMap[t];super._setStyleDeclaration(i.line,i.offset+e,r)}_deleteStyleDeclaration(t,e){const r=this._styleMap[t];super._deleteStyleDeclaration(r.line,r.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const r=this.getGraphemeDataForRender(t),i=[];for(let t=0;t<r.wordsData.length;t++)i.push(...this._wrapLine(t,e,r));return this.isWrapping=!1,i}getGraphemeDataForRender(t){const e=this.splitByGrapheme,r=e?"":" ";let i=0;return{wordsData:t.map((t,n)=>{let s=0;const o=e?this.graphemeSplit(t):this.wordSplit(t);return 0===o.length?[{word:[],width:0}]:o.map(t=>{const o=e?[t]:this.graphemeSplit(t),a=this._measureWord(o,n,s);return i=Math.max(a,i),s+=o.length+r.length,{word:o,width:a}})}),largestWordWidth:i}}_measureWord(t,e){let r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=0;for(let s=0,o=t.length;s<o;s++)n+=this._getGraphemeBox(t[s],e,s+i,r,!0).kernedWidth,r=t[s];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,r){let{largestWordWidth:i,wordsData:n}=r,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const o=this._getWidthOfCharSpacing(),a=this.splitByGrapheme,h=[],l=a?"":" ";let c=0,u=[],f=0,d=0,p=!0;e-=s;const g=Math.max(e,i,this.dynamicMinWidth),m=n[t];let v;for(f=0,v=0;v<m.length;v++){const{word:e,width:r}=m[v];f+=e.length,c+=d+r-o,c>g&&!p?(h.push(u),u=[],c=r,p=!0):c+=o,p||a||u.push(l),u=u.concat(e),d=a?0:this._measureWord([l],t,f),f++,p=!1}return v&&h.push(u),i+s>this.dynamicMinWidth&&(this.dynamicMinWidth=i-o+s),h}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),r=this._wrapText(e.lines,this.width),i=new Array(r.length);for(let t=0;t<r.length;t++)i[t]=r[t].join("");return e.lines=i,e.graphemeLines=r,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const r=parseInt(e,10);if(this._textLines[r]){const r=this._styleMap[e].line;t.set(`${r}`,!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}t(uo,"type","Textbox"),t(uo,"textLayoutProperties",[...co.textLayoutProperties,"width"]),t(uo,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),tt.setClass(uo);class fo extends vn{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:r}=t,{clipPath:i,group:n}=r;if(!i||!this.shouldPerformLayout(t))return;const{width:s,height:o}=de(mn(r,i)),a=new ot(s,o);if(i.absolutePositioned)return{center:we(i.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:a};{const n=i.getRelativeCenterPoint().transform(r.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:r=new ot,correction:i=new ot}=this.calcBoundingBox(e,t)||{};return{center:r.add(n),correction:i.subtract(n),size:a}}return{center:r.getRelativeCenterPoint().add(n),size:a}}}}t(fo,"type","clip-path"),tt.setClass(fo);class po extends vn{getInitialSize(t,e){let{target:r}=t,{size:i}=e;return new ot(r.width||i.x,r.height||i.y)}}t(po,"type","fixed"),tt.setClass(po);class go extends wn{subscribeTargets(t){const e=t.target;t.targets.reduce((t,e)=>(e.parent&&t.add(e.parent),t),new Set).forEach(t=>{t.layoutManager.subscribeTargets({target:t,targets:[e]})})}unsubscribeTargets(t){const e=t.target,r=e.getObjects();t.targets.reduce((t,e)=>(e.parent&&t.add(e.parent),t),new Set).forEach(t=>{!r.some(e=>e.parent===t)&&t.layoutManager.unsubscribeTargets({target:t,targets:[e]})})}}class mo extends Sn{static getDefaults(){return{...super.getDefaults(),...mo.ownDefaults}}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,mo.ownDefaults),this.setOptions(e);const{left:r,top:i,layoutManager:n}=e;this.groupInit(t,{left:r,top:i,layoutManager:null!=n?n:new go})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];"selection-order"===this.multiSelectionStacking?this.add(...e):e.forEach(t=>{const e=this._objects.findIndex(e=>e.isInFrontOf(t)),r=-1===e?this.size():e;this.insertAt(r,t)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(i("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const r=new Set;e.forEach(t=>{const{parent:e}=t;e&&r.add(e)}),t===pn?r.forEach(t=>{t._onAfterObjectsChange(dn,e)}):r.forEach(t=>{t._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return`#<ActiveSelection: (${this.complexity()})>`}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,r){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const i={hasControls:!1,...r,forActiveSelection:!0};for(let e=0;e<this._objects.length;e++)this._objects[e]._renderControls(t,i);super._renderControls(t,e),t.restore()}}t(mo,"type","ActiveSelection"),t(mo,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),tt.setClass(mo),tt.setClass(mo,"activeSelection");class vo{constructor(){t(this,"resources",{})}applyFilters(t,e,r,i,n){const s=n.getContext("2d",{willReadFrequently:!0,desynchronized:!0});if(!s)return;s.drawImage(e,0,0,r,i);const o={sourceWidth:r,sourceHeight:i,imageData:s.getImageData(0,0,r,i),originalEl:e,originalImageData:s.getImageData(0,0,r,i),canvasEl:n,ctx:s,filterBackend:this};t.forEach(t=>{t.applyTo(o)});const{imageData:a}=o;return a.width===r&&a.height===i||(n.width=a.width,n.height=a.height),s.putImageData(a,0,0),o}}class yo{constructor(){let{tileSize:e=r.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),t(this,"resources",{}),this.tileSize=e,this.setupGLContext(e,e),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const r=vt({width:t,height:e}),i=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});i&&(i.clearColor(0,0,0,0),this.canvas=r,this.gl=i)}applyFilters(t,e,r,i,n,s){const o=this.gl,a=n.getContext("2d");if(!o||!a)return;let h;s&&(h=this.getCachedTexture(s,e));const l={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:r,sourceHeight:i,destinationWidth:r,destinationHeight:i,context:o,sourceTexture:this.createTexture(o,r,i,h?void 0:e),targetTexture:this.createTexture(o,r,i),originalTexture:h||this.createTexture(o,r,i,h?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},c=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,c),t.forEach(t=>{t&&t.applyTo(l)}),function(t){const e=t.targetCanvas,r=e.width,i=e.height,n=t.destinationWidth,s=t.destinationHeight;r===n&&i===s||(e.width=n,e.height=s)}(l),this.copyGLTo2D(o,l),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(l.sourceTexture),o.deleteTexture(l.targetTexture),o.deleteFramebuffer(c),a.setTransform(1,0,0,1,0,0),l}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,r,i,n){const{NEAREST:s,TEXTURE_2D:o,RGBA:a,UNSIGNED_BYTE:h,CLAMP_TO_EDGE:l,TEXTURE_MAG_FILTER:c,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:f,TEXTURE_WRAP_T:d}=t,p=t.createTexture();return t.bindTexture(o,p),t.texParameteri(o,c,n||s),t.texParameteri(o,u,n||s),t.texParameteri(o,f,l),t.texParameteri(o,d,l),i?t.texImage2D(o,0,a,a,h,i):t.texImage2D(o,0,a,e,r,0,a,h,null),p}getCachedTexture(t,e,r){const{textureCache:i}=this;if(i[t])return i[t];{const n=this.createTexture(this.gl,e.width,e.height,e,r);return n&&(i[t]=n),n}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const r=t.canvas,i=e.targetCanvas,n=i.getContext("2d");if(!n)return;n.translate(0,i.height),n.scale(1,-1);const s=r.height-i.height;n.drawImage(r,0,s,i.width,i.height,0,0,i.width,i.height)}copyGLTo2DPutImageData(t,e){const r=e.targetCanvas.getContext("2d"),i=e.destinationWidth,n=e.destinationHeight,s=i*n*4;if(!r)return;const o=new Uint8Array(this.imageBuffer,0,s),a=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,i,n,t.RGBA,t.UNSIGNED_BYTE,o);const h=new ImageData(a,i,n);r.putImageData(h,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const r=t.getExtension("WEBGL_debug_renderer_info");if(r){const i=t.getParameter(r.UNMASKED_RENDERER_WEBGL),n=t.getParameter(r.UNMASKED_VENDOR_WEBGL);i&&(e.renderer=i.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}let bo;function wo(){return!bo&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(bo=function(){const{WebGLProbe:t}=u();return t.queryWebGL(gt()),r.enableGLFiltering&&t.isSupported(r.textureSize)?new yo({tileSize:r.textureSize}):new vo}()),bo}const _o=["cropX","cropY"];class xo extends Pi{static getDefaults(){return{...super.getDefaults(),...xo.ownDefaults}}constructor(e,r){super(),t(this,"_lastScaleX",1),t(this,"_lastScaleY",1),t(this,"_filterScalingX",1),t(this,"_filterScalingY",1),this.filters=[],Object.assign(this,xo.ownDefaults),this.setOptions(r),this.cacheKey=`texture${pt()}`,this.setElement("string"==typeof e?(this.canvas&&$t(this.canvas.getElement())||f()).getElementById(e):e,r)}getElement(){return this._element}setElement(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._element=t,this._originalElement=t,this._setWidthHeight(e),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=wo(!1);e instanceof yo&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(t=>{const e=this[t];e&&u().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||0===this.strokeWidth)return;const e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,-r),t.lineTo(e,-r),t.lineTo(e,r),t.lineTo(-e,r),t.lineTo(-e,-r),t.closePath()}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=[];return this.filters.forEach(t=>{t&&e.push(t.toObject())}),{...super.toObject([..._o,...t]),src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e,...this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{}}}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,r=-this.width/2,i=-this.height/2;let n=[],s=[],o="",a="";if(!e)return[];if(this.hasCrop()){const t=pt();n.push('<clipPath id="imageCrop_'+t+'">\n','\t<rect x="'+r+'" y="'+i+'" width="'+re(this.width)+'" height="'+re(this.height)+'" />\n',"</clipPath>\n"),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push("\t<image ","COMMON_PARTS",`xlink:href="${re(this.getSrc(!0))}" x="${r-this.cropX}" y="${i-this.cropY}" width="${e.width||e.naturalWidth}" height="${e.height||e.naturalHeight}"${a}${o}></image>\n`),this.stroke||this.strokeDashArray){const t=this.fill;this.fill=null,s=[`\t<rect x="${r}" y="${i}" width="${re(this.width)}" height="${re(this.height)}" style="${this.getSvgStyles()}" />\n`],this.fill=t}return n=this.paintFirst!==Y?n.concat(s,t):n.concat(t,s),n}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return It(t,{crossOrigin:e,signal:r}).then(t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)})}toString(){return`#<Image: { src: "${this.getSrc()}" }>`}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,r=this.getTotalObjectScaling(),i=r.x,n=r.y,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||i>e&&n>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=i,void(this._lastScaleY=n);const o=vt(s),{width:a,height:h}=s;this._element=o,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=n,wo().applyFilters([t],s,a,h,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.filters||[];if(t=t.filter(t=>t&&!t.isNeutralState()),this.set("dirty",!0),this.removeTexture(`${this.cacheKey}_filtered`),0===t.length)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,r=e.naturalWidth||e.width,i=e.naturalHeight||e.height;if(this._element===this._originalElement){const t=vt({width:r,height:i});this._element=t,this._filteredEl=t}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,r,i),this._lastScaleX=1,this._lastScaleY=1);wo().applyFilters(t,this._originalElement,r,i,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)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const r=this._filterScalingX,i=this._filterScalingY,n=this.width,s=this.height,o=Math.max(this.cropX,0),a=Math.max(this.cropY,0),h=e.naturalWidth||e.width,l=e.naturalHeight||e.height,c=o*r,u=a*i,f=Math.min(n*r,h-c),d=Math.min(s*i,l-u),p=-n/2,g=-s/2,m=Math.min(n,h/r-o),v=Math.min(s,l/i-a);e&&t.drawImage(e,c,u,f,d,p,g,m,v)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=this.getOriginalSize();this.width=t||r.width,this.height=e||r.height}parsePreserveAspectRatioAttribute(){const t=Qe(this.preserveAspectRatio||""),e=this.width,r=this.height,i={width:e,height:r};let n,s=this._element.width,o=this._element.height,a=1,h=1,l=0,c=0,u=0,f=0;return!t||t.alignX===N&&t.alignY===N?(a=e/s,h=r/o):("meet"===t.meetOrSlice&&(a=h=Cn(this._element,i),n=(e-s*a)/2,"Min"===t.alignX&&(l=-n),"Max"===t.alignX&&(l=n),n=(r-o*h)/2,"Min"===t.alignY&&(c=-n),"Max"===t.alignY&&(c=n)),"slice"===t.meetOrSlice&&(a=h=An(this._element,i),n=s-e/a,"Mid"===t.alignX&&(u=n/2),"Max"===t.alignX&&(u=n),n=o-r/h,"Mid"===t.alignY&&(f=n/2),"Max"===t.alignY&&(f=n),s=e/a,o=r/h)),{width:s,height:o,scaleX:a,scaleY:h,offsetLeft:l,offsetTop:c,cropX:u,cropY:f}}static fromObject(t,e){let{filters:r,resizeFilter:i,src:n,crossOrigin:s,type:o,...a}=t;return Promise.all([It(n,{...e,crossOrigin:s}),r&&Bt(r,e),i?Bt([i],e):[],Rt(a,e)]).then(t=>{let[e,r=[],[i],s={}]=t;return new this(e,{...a,src:n,filters:r,resizeFilter:i,...s})})}static fromURL(t){let{crossOrigin:e=null,signal:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return It(t,{crossOrigin:e,signal:r}).then(t=>new this(t,i))}static async fromElement(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;const n=ln(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(n["xlink:href"]||n.href,e,n).catch(t=>(i("log","Unable to parse Image",t),null))}}t(xo,"type","Image"),t(xo,"cacheProperties",[...kr,..._o]),t(xo,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),t(xo,"ATTRIBUTE_NAMES",[...zi,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),tt.setClass(xo),tt.setSVGClass(xo),rr(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const So=t=>void 0!==t.webgl,Co="precision highp float",Ao=`\n    ${Co};\n    varying vec2 vTexCoord;\n    uniform sampler2D uTexture;\n    void main() {\n      gl_FragColor = texture2D(uTexture, vTexCoord);\n    }`,ko=new RegExp(Co,"g");class Lo{get type(){return this.constructor.type}constructor(){let{type:t,...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,this.constructor.defaults,e)}getFragmentSource(){return Ao}getVertexSource(){return"\n    attribute vec2 aPosition;\n    varying vec2 vTexCoord;\n    void main() {\n      vTexCoord = aPosition;\n      gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n    }"}createProgram(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getFragmentSource(),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:i="highp"}}=u();"highp"!==i&&(e=e.replace(ko,Co.replace("highp",i)));const s=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!s||!o||!a)throw new n("Vertex, fragment shader or program creation error");if(t.shaderSource(s,r),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new n(`Vertex shader compile error for ${this.type}: ${t.getShaderInfoLog(s)}`);if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new n(`Fragment shader compile error for ${this.type}: ${t.getShaderInfoLog(o)}`);if(t.attachShader(a,s),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new n(`Shader link error for "${this.type}" ${t.getProgramInfoLog(a)}`);const h=this.getUniformLocations(t,a)||{};return h.uStepW=t.getUniformLocation(a,"uStepW"),h.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:h}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const r=this.constructor.uniformLocations,i={};for(let n=0;n<r.length;n++)i[r[n]]=t.getUniformLocation(e,r[n]);return i}sendAttributeData(t,e,r){const i=e.aPosition,n=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const r=t.destinationWidth,i=t.destinationHeight;t.sourceWidth===r&&t.sourceHeight===i||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,r,i)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){So(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,r=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(r.program),this.sendAttributeData(e,r.attributeLocations,t.aPosition),e.uniform1f(r.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(r.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,r.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,r){t.activeTexture(r),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:r}=t,i=vt({width:e,height:r});t.helpLayer=i}}toObject(){const t=Object.keys(this.constructor.defaults||{});return{type:this.type,...t.reduce((t,e)=>(t[e]=this[e],t),{})}}toJSON(){return this.toObject()}static async fromObject(t,e){let{type:r,...i}=t;return new this(i)}}t(Lo,"type","BaseFilter"),t(Lo,"uniformLocations",[]);const To={multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",difference:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"\n    if (uColor.r < 0.5) {\n      gl_FragColor.r *= 2.0 * uColor.r;\n    } else {\n      gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n    }\n    if (uColor.g < 0.5) {\n      gl_FragColor.g *= 2.0 * uColor.g;\n    } else {\n      gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n    }\n    if (uColor.b < 0.5) {\n      gl_FragColor.b *= 2.0 * uColor.b;\n    } else {\n      gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n    }\n    ",tint:"\n    gl_FragColor.rgb *= (1.0 - uColor.a);\n    gl_FragColor.rgb += uColor.rgb;\n    "};class Po extends Lo{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return`\n      precision highp float;\n      uniform sampler2D uTexture;\n      uniform vec4 uColor;\n      varying vec2 vTexCoord;\n      void main() {\n        vec4 color = texture2D(uTexture, vTexCoord);\n        gl_FragColor = color;\n        if (color.a > 0.0) {\n          ${To[this.mode]}\n        }\n      }\n      `}applyTo2d(t){let{imageData:{data:e}}=t;const r=new Je(this.color).getSource(),i=this.alpha,n=r[0]*i,s=r[1]*i,o=r[2]*i,a=1-i;for(let t=0;t<e.length;t+=4){const r=e[t],i=e[t+1],h=e[t+2];let l,c,u;switch(this.mode){case"multiply":l=r*n/255,c=i*s/255,u=h*o/255;break;case"screen":l=255-(255-r)*(255-n)/255,c=255-(255-i)*(255-s)/255,u=255-(255-h)*(255-o)/255;break;case"add":l=r+n,c=i+s,u=h+o;break;case"difference":l=Math.abs(r-n),c=Math.abs(i-s),u=Math.abs(h-o);break;case"subtract":l=r-n,c=i-s,u=h-o;break;case"darken":l=Math.min(r,n),c=Math.min(i,s),u=Math.min(h,o);break;case"lighten":l=Math.max(r,n),c=Math.max(i,s),u=Math.max(h,o);break;case"overlay":l=n<128?2*r*n/255:255-2*(255-r)*(255-n)/255,c=s<128?2*i*s/255:255-2*(255-i)*(255-s)/255,u=o<128?2*h*o/255:255-2*(255-h)*(255-o)/255;break;case"exclusion":l=n+r-2*n*r/255,c=s+i-2*s*i/255,u=o+h-2*o*h/255;break;case"tint":l=n+r*a,c=s+i*a,u=o+h*a}e[t]=l,e[t+1]=c,e[t+2]=u}}sendUniformData(t,e){const r=new Je(this.color).getSource();r[0]=this.alpha*r[0]/255,r[1]=this.alpha*r[1]/255,r[2]=this.alpha*r[2]/255,r[3]=this.alpha,t.uniform4fv(e.uColor,r)}}t(Po,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),t(Po,"type","BlendColor"),t(Po,"uniformLocations",["uColor"]),tt.setClass(Po);const No={multiply:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform sampler2D uImage;\n    uniform vec4 uColor;\n    varying vec2 vTexCoord;\n    varying vec2 vTexCoord2;\n    void main() {\n      vec4 color = texture2D(uTexture, vTexCoord);\n      vec4 color2 = texture2D(uImage, vTexCoord2);\n      color.rgba *= color2.rgba;\n      gl_FragColor = color;\n    }\n    ",mask:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform sampler2D uImage;\n    uniform vec4 uColor;\n    varying vec2 vTexCoord;\n    varying vec2 vTexCoord2;\n    void main() {\n      vec4 color = texture2D(uTexture, vTexCoord);\n      vec4 color2 = texture2D(uImage, vTexCoord2);\n      color.a = color2.a;\n      gl_FragColor = color;\n    }\n    "};class Oo extends Lo{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return No[this.mode]}getVertexSource(){return"\n    attribute vec2 aPosition;\n    varying vec2 vTexCoord;\n    varying vec2 vTexCoord2;\n    uniform mat3 uTransformMatrix;\n    void main() {\n      vTexCoord = aPosition;\n      vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n      gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n    }\n    "}applyToWebGL(t){const e=t.context,r=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,r,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:r}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/r,1]}applyTo2d(t){let{imageData:{data:e,width:r,height:i},filterBackend:{resources:n}}=t;const s=this.image;n.blendImage||(n.blendImage=gt());const o=n.blendImage,a=o.getContext("2d");o.width!==r||o.height!==i?(o.width=r,o.height=i):a.clearRect(0,0,r,i),a.setTransform(s.scaleX,0,0,s.scaleY,s.left,s.top),a.drawImage(s.getElement(),0,0,r,i);const h=a.getImageData(0,0,r,i).data;for(let t=0;t<e.length;t+=4){const r=e[t],i=e[t+1],n=e[t+2],s=e[t+3],o=h[t],a=h[t+1],l=h[t+2],c=h[t+3];switch(this.mode){case"multiply":e[t]=r*o/255,e[t+1]=i*a/255,e[t+2]=n*l/255,e[t+3]=s*c/255;break;case"mask":e[t+3]=c}}}sendUniformData(t,e){const r=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,r)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject(t,e){let{type:r,image:i,...n}=t;return xo.fromObject(i,e).then(t=>new this({...n,image:t}))}}t(Oo,"type","BlendImage"),t(Oo,"defaults",{mode:"multiply",alpha:1}),t(Oo,"uniformLocations",["uTransformMatrix","uImage"]),tt.setClass(Oo);class Eo extends Lo{getFragmentSource(){return"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform vec2 uDelta;\n    varying vec2 vTexCoord;\n    const float nSamples = 15.0;\n    vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n    float random(vec3 scale) {\n      /* use the fragment position for a different seed per-pixel */\n      return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n    }\n    void main() {\n      vec4 color = vec4(0.0);\n      float totalC = 0.0;\n      float totalA = 0.0;\n      float offset = random(v3offset);\n      for (float t = -nSamples; t <= nSamples; t++) {\n        float percent = (t + offset - 0.5) / nSamples;\n        vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);\n        float weight = 1.0 - abs(percent);\n        float alpha = weight * sample.a;\n        color.rgb += sample.rgb * alpha;\n        color.a += alpha;\n        totalA += weight;\n        totalC += alpha;\n      }\n      gl_FragColor.rgb = color.rgb / totalC;\n      gl_FragColor.a = color.a / totalA;\n    }\n  "}applyTo(t){So(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:r,height:i}}=t;this.aspectRatio=r/i,this.horizontal=!0;let n=this.getBlurValue()*r;const s=new Uint8ClampedArray(e),o=4*r;for(let t=0;t<e.length;t+=4){let r=0,i=0,a=0,h=0,l=0;const c=t-t%o,u=c+o;for(let s=-14;s<15;s++){const o=s/15,f=4*Math.floor(n*o),d=1-Math.abs(o);let p=t+f;p<c?p=c:p>u&&(p=u);const g=e[p+3]*d;r+=e[p]*g,i+=e[p+1]*g,a+=e[p+2]*g,h+=g,l+=d}s[t]=r/h,s[t+1]=i/h,s[t+2]=a/h,s[t+3]=h/l}this.horizontal=!1,n=this.getBlurValue()*i;for(let t=0;t<s.length;t+=4){let r=0,i=0,a=0,h=0,l=0;const c=t%o,u=s.length-o+c;for(let e=-14;e<15;e++){const f=e/15,d=Math.floor(n*f)*o,p=1-Math.abs(f);let g=t+d;g<c?g=c:g>u&&(g=u);const m=s[g+3]*p;r+=s[g]*m,i+=s[g+1]*m,a+=s[g+2]*m,h+=m,l+=p}e[t]=r/h,e[t+1]=i/h,e[t+2]=a/h,e[t+3]=h/l}}sendUniformData(t,e){const r=this.chooseRightDelta();t.uniform2fv(e.uDelta,r)}isNeutralState(){return 0===this.blur}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:r}=this;return e?r>1&&(t=1/r):r<1&&(t=r),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}t(Eo,"type","Blur"),t(Eo,"defaults",{blur:0}),t(Eo,"uniformLocations",["uDelta"]),tt.setClass(Eo);class Mo extends Lo{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uBrightness;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    color.rgb += uBrightness;\n    gl_FragColor = color;\n  }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.round(255*this.brightness);for(let t=0;t<e.length;t+=4)e[t]+=r,e[t+1]+=r,e[t+2]+=r}isNeutralState(){return 0===this.brightness}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}t(Mo,"type","Brightness"),t(Mo,"defaults",{brightness:0}),t(Mo,"uniformLocations",["uBrightness"]),tt.setClass(Mo);const Do={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Fo extends Lo{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  varying vec2 vTexCoord;\n  uniform mat4 uColorMatrix;\n  uniform vec4 uConstants;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    color *= uColorMatrix;\n    color += uConstants;\n    gl_FragColor = color;\n  }"}applyTo2d(t){const e=t.imageData.data,r=this.matrix,i=this.colorsOnly;for(let t=0;t<e.length;t+=4){const n=e[t],s=e[t+1],o=e[t+2];if(e[t]=n*r[0]+s*r[1]+o*r[2]+255*r[4],e[t+1]=n*r[5]+s*r[6]+o*r[7]+255*r[9],e[t+2]=n*r[10]+s*r[11]+o*r[12]+255*r[14],!i){const i=e[t+3];e[t]+=i*r[3],e[t+1]+=i*r[8],e[t+2]+=i*r[13],e[t+3]=n*r[15]+s*r[16]+o*r[17]+i*r[18]+255*r[19]}}}sendUniformData(t,e){const r=this.matrix,i=[r[0],r[1],r[2],r[3],r[5],r[6],r[7],r[8],r[10],r[11],r[12],r[13],r[15],r[16],r[17],r[18]],n=[r[4],r[9],r[14],r[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,i),t.uniform4fv(e.uConstants,n)}toObject(){return{...super.toObject(),matrix:[...this.matrix]}}}function jo(e,r){var i;const n=(t(i=class extends Fo{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",e),t(i,"defaults",{colorsOnly:!1,matrix:r}),i);return tt.setClass(n,e),n}t(Fo,"type","ColorMatrix"),t(Fo,"defaults",Do),t(Fo,"uniformLocations",["uColorMatrix","uConstants"]),tt.setClass(Fo);const Io=jo("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),Bo=jo("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),Ro=jo("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),zo=jo("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),Uo=jo("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),qo=jo("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Wo=jo("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Ho extends Lo{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){So(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach(e=>{e.applyTo(t)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(t=>t.toObject())}}isNeutralState(){return!this.subFilters.some(t=>!t.isNeutralState())}static fromObject(t,e){return Promise.all((t.subFilters||[]).map(t=>tt.getClass(t.type).fromObject(t,e))).then(t=>new this({subFilters:t}))}}t(Ho,"type","Composed"),tt.setClass(Ho);class Vo extends Lo{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uContrast;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\n    color.rgb = contrastF * (color.rgb - 0.5) + 0.5;\n    gl_FragColor = color;\n  }"}isNeutralState(){return 0===this.contrast}applyTo2d(t){let{imageData:{data:e}}=t;const r=Math.floor(255*this.contrast),i=259*(r+255)/(255*(259-r));for(let t=0;t<e.length;t+=4)e[t]=i*(e[t]-128)+128,e[t+1]=i*(e[t+1]-128)+128,e[t+2]=i*(e[t+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}t(Vo,"type","Contrast"),t(Vo,"defaults",{contrast:0}),t(Vo,"uniformLocations",["uContrast"]),tt.setClass(Vo);const Yo={Convolute_3_1:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[9];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 0);\n      for (float h = 0.0; h < 3.0; h+=1.0) {\n        for (float w = 0.0; w < 3.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\n          color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n        }\n      }\n      gl_FragColor = color;\n    }\n    ",Convolute_3_0:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[9];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 1);\n      for (float h = 0.0; h < 3.0; h+=1.0) {\n        for (float w = 0.0; w < 3.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\n          color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n        }\n      }\n      float alpha = texture2D(uTexture, vTexCoord).a;\n      gl_FragColor = color;\n      gl_FragColor.a = alpha;\n    }\n    ",Convolute_5_1:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[25];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 0);\n      for (float h = 0.0; h < 5.0; h+=1.0) {\n        for (float w = 0.0; w < 5.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n          color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n        }\n      }\n      gl_FragColor = color;\n    }\n    ",Convolute_5_0:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[25];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 1);\n      for (float h = 0.0; h < 5.0; h+=1.0) {\n        for (float w = 0.0; w < 5.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n          color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n        }\n      }\n      float alpha = texture2D(uTexture, vTexCoord).a;\n      gl_FragColor = color;\n      gl_FragColor.a = alpha;\n    }\n    ",Convolute_7_1:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[49];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 0);\n      for (float h = 0.0; h < 7.0; h+=1.0) {\n        for (float w = 0.0; w < 7.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n          color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n        }\n      }\n      gl_FragColor = color;\n    }\n    ",Convolute_7_0:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[49];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 1);\n      for (float h = 0.0; h < 7.0; h+=1.0) {\n        for (float w = 0.0; w < 7.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n          color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n        }\n      }\n      float alpha = texture2D(uTexture, vTexCoord).a;\n      gl_FragColor = color;\n      gl_FragColor.a = alpha;\n    }\n    ",Convolute_9_1:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[81];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 0);\n      for (float h = 0.0; h < 9.0; h+=1.0) {\n        for (float w = 0.0; w < 9.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n          color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n        }\n      }\n      gl_FragColor = color;\n    }\n    ",Convolute_9_0:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[81];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 1);\n      for (float h = 0.0; h < 9.0; h+=1.0) {\n        for (float w = 0.0; w < 9.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n          color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n        }\n      }\n      float alpha = texture2D(uTexture, vTexCoord).a;\n      gl_FragColor = color;\n      gl_FragColor.a = alpha;\n    }\n    "};class Xo extends Lo{getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${this.opaque?1:0}`}getFragmentSource(){return Yo[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,r=e.data,i=this.matrix,n=Math.round(Math.sqrt(i.length)),s=Math.floor(n/2),o=e.width,a=e.height,h=t.ctx.createImageData(o,a),l=h.data,c=this.opaque?1:0;let u,f,d,p,g,m,v,y,b,w,_,x,S;for(_=0;_<a;_++)for(w=0;w<o;w++){for(g=4*(_*o+w),u=0,f=0,d=0,p=0,S=0;S<n;S++)for(x=0;x<n;x++)v=_+S-s,m=w+x-s,v<0||v>=a||m<0||m>=o||(y=4*(v*o+m),b=i[S*n+x],u+=r[y]*b,f+=r[y+1]*b,d+=r[y+2]*b,c||(p+=r[y+3]*b));l[g]=u,l[g+1]=f,l[g+2]=d,l[g+3]=c?r[g+3]:p}t.imageData=h}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return{...super.toObject(),opaque:this.opaque,matrix:[...this.matrix]}}}t(Xo,"type","Convolute"),t(Xo,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),t(Xo,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),tt.setClass(Xo);const Go="Gamma";class $o extends Lo{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform vec3 uGamma;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    vec3 correction = (1.0 / uGamma);\n    color.r = pow(color.r, correction.r);\n    color.g = pow(color.g, correction.g);\n    color.b = pow(color.b, correction.b);\n    gl_FragColor = color;\n    gl_FragColor.rgb *= color.a;\n  }\n"}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.gamma,i=1/r[0],n=1/r[1],s=1/r[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const o=this.rgbValues;for(let t=0;t<256;t++)o.r[t]=255*Math.pow(t/255,i),o.g[t]=255*Math.pow(t/255,n),o.b[t]=255*Math.pow(t/255,s);for(let t=0;t<e.length;t+=4)e[t]=o.r[e[t]],e[t+1]=o.g[e[t+1]],e[t+2]=o.b[e[t+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return 1===t[0]&&1===t[1]&&1===t[2]}toObject(){return{type:Go,gamma:this.gamma.concat()}}}t($o,"type",Go),t($o,"defaults",{gamma:[1,1,1]}),t($o,"uniformLocations",["uGamma"]),tt.setClass($o);const Ko={average:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = texture2D(uTexture, vTexCoord);\n      float average = (color.r + color.b + color.g) / 3.0;\n      gl_FragColor = vec4(average, average, average, color.a);\n    }\n    ",lightness:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform int uMode;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 col = texture2D(uTexture, vTexCoord);\n      float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\n      gl_FragColor = vec4(average, average, average, col.a);\n    }\n    ",luminosity:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform int uMode;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 col = texture2D(uTexture, vTexCoord);\n      float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\n      gl_FragColor = vec4(average, average, average, col.a);\n    }\n    "};class Jo extends Lo{applyTo2d(t){let{imageData:{data:e}}=t;for(let t,r=0;r<e.length;r+=4){const i=e[r],n=e[r+1],s=e[r+2];switch(this.mode){case"average":t=(i+n+s)/3;break;case"lightness":t=(Math.min(i,n,s)+Math.max(i,n,s))/2;break;case"luminosity":t=.21*i+.72*n+.07*s}e[r+2]=e[r+1]=e[r]=t}}getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return Ko[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}t(Jo,"type","Grayscale"),t(Jo,"defaults",{mode:"average"}),t(Jo,"uniformLocations",["uMode"]),tt.setClass(Jo);const Zo={...Do,rotation:0};class Qo extends Fo{calculateMatrix(){const t=this.rotation*Math.PI,e=nt(t),r=st(t),i=1/3,n=Math.sqrt(i)*r,s=1-e;this.matrix=[e+s/3,i*s-n,i*s+n,0,0,i*s+n,e+i*s,i*s-n,0,0,i*s-n,i*s+n,e+i*s,0,0,0,0,0,1,0]}isNeutralState(){return 0===this.rotation}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}t(Qo,"type","HueRotation"),t(Qo,"defaults",Zo),tt.setClass(Qo);class ta extends Lo{applyTo2d(t){let{imageData:{data:e}}=t;for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2],this.alpha&&(e[t+3]=255-e[t+3])}getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform int uInvert;\n  uniform int uAlpha;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    if (uInvert == 1) {\n      if (uAlpha == 1) {\n        gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);\n      } else {\n        gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n      }\n    } else {\n      gl_FragColor = color;\n    }\n  }\n"}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}t(ta,"type","Invert"),t(ta,"defaults",{alpha:!1,invert:!0}),t(ta,"uniformLocations",["uInvert","uAlpha"]),tt.setClass(ta);class ea extends Lo{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uStepH;\n  uniform float uNoise;\n  uniform float uSeed;\n  varying vec2 vTexCoord;\n  float rand(vec2 co, float seed, float vScale) {\n    return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n  }\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\n    gl_FragColor = color;\n  }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const r=this.noise;for(let t=0;t<e.length;t+=4){const i=(.5-Math.random())*r;e[t]+=i,e[t+1]+=i,e[t+2]+=i}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return 0===this.noise}}t(ea,"type","Noise"),t(ea,"defaults",{noise:0}),t(ea,"uniformLocations",["uNoise","uSeed"]),tt.setClass(ea);class ra extends Lo{applyTo2d(t){let{imageData:{data:e,width:r,height:i}}=t;for(let t=0;t<i;t+=this.blocksize)for(let n=0;n<r;n+=this.blocksize){const s=4*t*r+4*n,o=e[s],a=e[s+1],h=e[s+2],l=e[s+3];for(let s=t;s<Math.min(t+this.blocksize,i);s++)for(let t=n;t<Math.min(n+this.blocksize,r);t++){const i=4*s*r+4*t;e[i]=o,e[i+1]=a,e[i+2]=h,e[i+3]=l}}}isNeutralState(){return 1===this.blocksize}getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uBlocksize;\n  uniform float uStepW;\n  uniform float uStepH;\n  varying vec2 vTexCoord;\n  void main() {\n    float blockW = uBlocksize * uStepW;\n    float blockH = uBlocksize * uStepH;\n    int posX = int(vTexCoord.x / blockW);\n    int posY = int(vTexCoord.y / blockH);\n    float fposX = float(posX);\n    float fposY = float(posY);\n    vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\n    vec4 color = texture2D(uTexture, squareCoords);\n    gl_FragColor = color;\n  }\n"}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}t(ra,"type","Pixelate"),t(ra,"defaults",{blocksize:4}),t(ra,"uniformLocations",["uBlocksize"]),tt.setClass(ra);class ia extends Lo{getFragmentSource(){return"\nprecision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\n  gl_FragColor = texture2D(uTexture, vTexCoord);\n  if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\n    gl_FragColor.a = 0.0;\n  }\n}\n"}applyTo2d(t){let{imageData:{data:e}}=t;const r=255*this.distance,i=new Je(this.color).getSource(),n=[i[0]-r,i[1]-r,i[2]-r],s=[i[0]+r,i[1]+r,i[2]+r];for(let t=0;t<e.length;t+=4){const r=e[t],i=e[t+1],o=e[t+2];r>n[0]&&i>n[1]&&o>n[2]&&r<s[0]&&i<s[1]&&o<s[2]&&(e[t+3]=0)}}sendUniformData(t,e){const r=new Je(this.color).getSource(),i=this.distance,n=[0+r[0]/255-i,0+r[1]/255-i,0+r[2]/255-i,1],s=[r[0]/255+i,r[1]/255+i,r[2]/255+i,1];t.uniform4fv(e.uLow,n),t.uniform4fv(e.uHigh,s)}}t(ia,"type","RemoveColor"),t(ia,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),t(ia,"uniformLocations",["uLow","uHigh"]),tt.setClass(ia);class na extends Lo{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return`${this.type}_${t}`}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,r=this.getFilterWindow(),i=new Array(r);for(let n=1;n<=r;n++)i[n-1]=t(n*e);return i}generateShader(t){const e=new Array(t);for(let r=1;r<=t;r++)e[r-1]=`${r}.0 * uDelta`;return`\n      precision highp float;\n      uniform sampler2D uTexture;\n      uniform vec2 uDelta;\n      varying vec2 vTexCoord;\n      uniform float uTaps[${t}];\n      void main() {\n        vec4 color = texture2D(uTexture, vTexCoord);\n        float sum = 1.0;\n        ${e.map((t,e)=>`\n              color += texture2D(uTexture, vTexCoord + ${t}) * uTaps[${e}] + texture2D(uTexture, vTexCoord - ${t}) * uTaps[${e}];\n              sum += 2.0 * uTaps[${e}];\n            `).join("\n")}\n        gl_FragColor = color / sum;\n      }\n    `}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){So(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return 1===this.scaleX&&1===this.scaleY}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;const r=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(r)/r}}applyTo2d(t){const e=t.imageData,r=this.scaleX,i=this.scaleY;this.rcpScaleX=1/r,this.rcpScaleY=1/i;const n=e.width,s=e.height,o=Math.round(n*r),a=Math.round(s*i);let h;h="sliceHack"===this.resizeType?this.sliceByTwo(t,n,s,o,a):"hermite"===this.resizeType?this.hermiteFastResize(t,n,s,o,a):"bilinear"===this.resizeType?this.bilinearFiltering(t,n,s,o,a):"lanczos"===this.resizeType?this.lanczosResize(t,n,s,o,a):new ImageData(o,a),t.imageData=h}sliceByTwo(t,e,r,i,n){const s=t.imageData,o=.5;let a=!1,h=!1,l=e*o,c=r*o;const u=t.filterBackend.resources;let f=0,d=0;const p=e;let g=0;u.sliceByTwo||(u.sliceByTwo=gt());const m=u.sliceByTwo;(m.width<1.5*e||m.height<r)&&(m.width=1.5*e,m.height=r);const v=m.getContext("2d");for(v.clearRect(0,0,1.5*e,r),v.putImageData(s,0,0),i=Math.floor(i),n=Math.floor(n);!a||!h;)e=l,r=c,i<Math.floor(l*o)?l=Math.floor(l*o):(l=i,a=!0),n<Math.floor(c*o)?c=Math.floor(c*o):(c=n,h=!0),v.drawImage(m,f,d,e,r,p,g,l,c),f=p,d=g,g+=c;return v.getImageData(f,d,i,n)}lanczosResize(t,e,r,i,n){const s=t.imageData.data,o=t.ctx.createImageData(i,n),a=o.data,h=this.lanczosCreate(this.lanczosLobes),l=this.rcpScaleX,c=this.rcpScaleY,u=2/this.rcpScaleX,f=2/this.rcpScaleY,d=Math.ceil(l*this.lanczosLobes/2),p=Math.ceil(c*this.lanczosLobes/2),g={},m={x:0,y:0},v={x:0,y:0};return function t(y){let b,w,_,x,S,C,A,k,L,T,P;for(m.x=(y+.5)*l,v.x=Math.floor(m.x),b=0;b<n;b++){for(m.y=(b+.5)*c,v.y=Math.floor(m.y),S=0,C=0,A=0,k=0,L=0,w=v.x-d;w<=v.x+d;w++)if(!(w<0||w>=e)){T=Math.floor(1e3*Math.abs(w-m.x)),g[T]||(g[T]={});for(let t=v.y-p;t<=v.y+p;t++)t<0||t>=r||(P=Math.floor(1e3*Math.abs(t-m.y)),g[T][P]||(g[T][P]=h(Math.sqrt(Math.pow(T*u,2)+Math.pow(P*f,2))/1e3)),_=g[T][P],_>0&&(x=4*(t*e+w),S+=_,C+=_*s[x],A+=_*s[x+1],k+=_*s[x+2],L+=_*s[x+3]))}x=4*(b*i+y),a[x]=C/S,a[x+1]=A/S,a[x+2]=k/S,a[x+3]=L/S}return++y<i?t(y):o}(0)}bilinearFiltering(t,e,r,i,n){let s,o,a,h,l,c,u,f,d,p,g,m,v,y=0;const b=this.rcpScaleX,w=this.rcpScaleY,_=4*(e-1),x=t.imageData.data,S=t.ctx.createImageData(i,n),C=S.data;for(u=0;u<n;u++)for(f=0;f<i;f++)for(l=Math.floor(b*f),c=Math.floor(w*u),d=b*f-l,p=w*u-c,v=4*(c*e+l),g=0;g<4;g++)s=x[v+g],o=x[v+4+g],a=x[v+_+g],h=x[v+_+4+g],m=s*(1-d)*(1-p)+o*d*(1-p)+a*p*(1-d)+h*d*p,C[y++]=m;return S}hermiteFastResize(t,e,r,i,n){const s=this.rcpScaleX,o=this.rcpScaleY,a=Math.ceil(s/2),h=Math.ceil(o/2),l=t.imageData.data,c=t.ctx.createImageData(i,n),u=c.data;for(let t=0;t<n;t++)for(let r=0;r<i;r++){const n=4*(r+t*i);let c=0,f=0,d=0,p=0,g=0,m=0,v=0;const y=(t+.5)*o;for(let i=Math.floor(t*o);i<(t+1)*o;i++){const t=Math.abs(y-(i+.5))/h,n=(r+.5)*s,o=t*t;for(let t=Math.floor(r*s);t<(r+1)*s;t++){let r=Math.abs(n-(t+.5))/a;const s=Math.sqrt(o+r*r);s>1&&s<-1||(c=2*s*s*s-3*s*s+1,c>0&&(r=4*(t+i*e),v+=c*l[r+3],d+=c,l[r+3]<255&&(c=c*l[r+3]/250),p+=c*l[r],g+=c*l[r+1],m+=c*l[r+2],f+=c))}}u[n]=p/f,u[n+1]=g/f,u[n+2]=m/f,u[n+3]=v/d}return c}}t(na,"type","Resize"),t(na,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),t(na,"uniformLocations",["uDelta","uTaps"]),tt.setClass(na);class sa extends Lo{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uSaturation;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    float rgMax = max(color.r, color.g);\n    float rgbMax = max(rgMax, color.b);\n    color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\n    color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\n    color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\n    gl_FragColor = color;\n  }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.saturation;for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],s=e[t+2],o=Math.max(i,n,s);e[t]+=o!==i?(o-i)*r:0,e[t+1]+=o!==n?(o-n)*r:0,e[t+2]+=o!==s?(o-s)*r:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return 0===this.saturation}}t(sa,"type","Saturation"),t(sa,"defaults",{saturation:0}),t(sa,"uniformLocations",["uSaturation"]),tt.setClass(sa);class oa extends Lo{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uVibrance;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    float max = max(color.r, max(color.g, color.b));\n    float avg = (color.r + color.g + color.b) / 3.0;\n    float amt = (abs(max - avg) * 2.0) * uVibrance;\n    color.r += max != color.r ? (max - color.r) * amt : 0.00;\n    color.g += max != color.g ? (max - color.g) * amt : 0.00;\n    color.b += max != color.b ? (max - color.b) * amt : 0.00;\n    gl_FragColor = color;\n  }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const r=-this.vibrance;for(let t=0;t<e.length;t+=4){const i=e[t],n=e[t+1],s=e[t+2],o=Math.max(i,n,s),a=(i+n+s)/3,h=2*Math.abs(o-a)/255*r;e[t]+=o!==i?(o-i)*h:0,e[t+1]+=o!==n?(o-n)*h:0,e[t+2]+=o!==s?(o-s)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return 0===this.vibrance}}t(oa,"type","Vibrance"),t(oa,"defaults",{vibrance:0}),t(oa,"uniformLocations",["uVibrance"]),tt.setClass(oa),Object.freeze({__proto__:null,BaseFilter:Lo,BlackWhite:Wo,BlendColor:Po,BlendImage:Oo,Blur:Eo,Brightness:Mo,Brownie:Io,ColorMatrix:Fo,Composed:Ho,Contrast:Vo,Convolute:Xo,Gamma:$o,Grayscale:Jo,HueRotation:Qo,Invert:ta,Kodachrome:Ro,Noise:ea,Pixelate:ra,Polaroid:Uo,RemoveColor:ia,Resize:na,Saturation:sa,Sepia:qo,Technicolor:zo,Vibrance:oa,Vintage:Bo});var aa=o(2284),ha=Uint8Array,la=Uint16Array,ca=Int32Array,ua=new ha([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fa=new ha([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),da=new ha([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pa=function(t,e){for(var r=new la(31),i=0;i<31;++i)r[i]=e+=1<<t[i-1];var n=new ca(r[30]);for(i=1;i<30;++i)for(var s=r[i];s<r[i+1];++s)n[s]=s-r[i]<<5|i;return{b:r,r:n}},ga=pa(ua,2),ma=ga.b,va=ga.r;ma[28]=258,va[258]=28;for(var ya=pa(fa,0),ba=(ya.b,ya.r),wa=new la(32768),_a=0;_a<32768;++_a){var xa=(43690&_a)>>1|(21845&_a)<<1;xa=(61680&(xa=(52428&xa)>>2|(13107&xa)<<2))>>4|(3855&xa)<<4,wa[_a]=((65280&xa)>>8|(255&xa)<<8)>>1}var Sa=function(t,e,r){for(var i=t.length,n=0,s=new la(e);n<i;++n)t[n]&&++s[t[n]-1];var o,a=new la(e);for(n=1;n<e;++n)a[n]=a[n-1]+s[n-1]<<1;if(r){o=new la(1<<e);var h=15-e;for(n=0;n<i;++n)if(t[n])for(var l=n<<4|t[n],c=e-t[n],u=a[t[n]-1]++<<c,f=u|(1<<c)-1;u<=f;++u)o[wa[u]>>h]=l}else for(o=new la(i),n=0;n<i;++n)t[n]&&(o[n]=wa[a[t[n]-1]++]>>15-t[n]);return o},Ca=new ha(288);for(_a=0;_a<144;++_a)Ca[_a]=8;for(_a=144;_a<256;++_a)Ca[_a]=9;for(_a=256;_a<280;++_a)Ca[_a]=7;for(_a=280;_a<288;++_a)Ca[_a]=8;var Aa=new ha(32);for(_a=0;_a<32;++_a)Aa[_a]=5;var ka=Sa(Ca,9,0),La=Sa(Aa,5,0),Ta=function(t){return(t+7)/8|0},Pa=function(t,e,r){r<<=7&e;var i=e/8|0;t[i]|=r,t[i+1]|=r>>8},Na=function(t,e,r){r<<=7&e;var i=e/8|0;t[i]|=r,t[i+1]|=r>>8,t[i+2]|=r>>16},Oa=function(t,e){for(var r=[],i=0;i<t.length;++i)t[i]&&r.push({s:i,f:t[i]});var n=r.length,s=r.slice();if(!n)return{t:Ba,l:0};if(1==n){var o=new ha(r[0].s+1);return o[r[0].s]=1,{t:o,l:1}}r.sort(function(t,e){return t.f-e.f}),r.push({s:-1,f:25001});var a=r[0],h=r[1],l=0,c=1,u=2;for(r[0]={s:-1,f:a.f+h.f,l:a,r:h};c!=n-1;)a=r[r[l].f<r[u].f?l++:u++],h=r[l!=c&&r[l].f<r[u].f?l++:u++],r[c++]={s:-1,f:a.f+h.f,l:a,r:h};var f=s[0].s;for(i=1;i<n;++i)s[i].s>f&&(f=s[i].s);var d=new la(f+1),p=Ea(r[c-1],d,0);if(p>e){i=0;var g=0,m=p-e,v=1<<m;for(s.sort(function(t,e){return d[e.s]-d[t.s]||t.f-e.f});i<n;++i){var y=s[i].s;if(!(d[y]>e))break;g+=v-(1<<p-d[y]),d[y]=e}for(g>>=m;g>0;){var b=s[i].s;d[b]<e?g-=1<<e-d[b]++-1:++i}for(;i>=0&&g;--i){var w=s[i].s;d[w]==e&&(--d[w],++g)}p=e}return{t:new ha(d),l:p}},Ea=function(t,e,r){return-1==t.s?Math.max(Ea(t.l,e,r+1),Ea(t.r,e,r+1)):e[t.s]=r},Ma=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new la(++e),i=0,n=t[0],s=1,o=function(t){r[i++]=t},a=1;a<=e;++a)if(t[a]==n&&a!=e)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=t[a]}return{c:r.subarray(0,i),n:e}},Da=function(t,e){for(var r=0,i=0;i<e.length;++i)r+=t[i]*e[i];return r},Fa=function(t,e,r){var i=r.length,n=Ta(e+2);t[n]=255&i,t[n+1]=i>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var s=0;s<i;++s)t[n+s+4]=r[s];return 8*(n+4+i)},ja=function(t,e,r,i,n,s,o,a,h,l,c){Pa(e,c++,r),++n[256];for(var u=Oa(n,15),f=u.t,d=u.l,p=Oa(s,15),g=p.t,m=p.l,v=Ma(f),y=v.c,b=v.n,w=Ma(g),_=w.c,x=w.n,S=new la(19),C=0;C<y.length;++C)++S[31&y[C]];for(C=0;C<_.length;++C)++S[31&_[C]];for(var A=Oa(S,7),k=A.t,L=A.l,T=19;T>4&&!k[da[T-1]];--T);var P,N,O,E,M=l+5<<3,D=Da(n,Ca)+Da(s,Aa)+o,F=Da(n,f)+Da(s,g)+o+14+3*T+Da(S,k)+2*S[16]+3*S[17]+7*S[18];if(h>=0&&M<=D&&M<=F)return Fa(e,c,t.subarray(h,h+l));if(Pa(e,c,1+(F<D)),c+=2,F<D){P=Sa(f,d,0),N=f,O=Sa(g,m,0),E=g;var j=Sa(k,L,0);for(Pa(e,c,b-257),Pa(e,c+5,x-1),Pa(e,c+10,T-4),c+=14,C=0;C<T;++C)Pa(e,c+3*C,k[da[C]]);c+=3*T;for(var I=[y,_],B=0;B<2;++B){var R=I[B];for(C=0;C<R.length;++C){var z=31&R[C];Pa(e,c,j[z]),c+=k[z],z>15&&(Pa(e,c,R[C]>>5&127),c+=R[C]>>12)}}}else P=ka,N=Ca,O=La,E=Aa;for(C=0;C<a;++C){var U=i[C];if(U>255){Na(e,c,P[257+(z=U>>18&31)]),c+=N[z+257],z>7&&(Pa(e,c,U>>23&31),c+=ua[z]);var q=31&U;Na(e,c,O[q]),c+=E[q],q>3&&(Na(e,c,U>>5&8191),c+=fa[q])}else Na(e,c,P[U]),c+=N[U]}return Na(e,c,P[256]),c+N[256]},Ia=new ca([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ba=new ha(0),Ra=function(t,e,r,i,n,s){var o=s.z||t.length,a=new ha(i+o+5*(1+Math.ceil(o/7e3))+n),h=a.subarray(i,a.length-n),l=s.l,c=7&(s.r||0);if(e){c&&(h[0]=s.r>>3);for(var u=Ia[e-1],f=u>>13,d=8191&u,p=(1<<r)-1,g=s.p||new la(32768),m=s.h||new la(p+1),v=Math.ceil(r/3),y=2*v,b=function(e){return(t[e]^t[e+1]<<v^t[e+2]<<y)&p},w=new ca(25e3),_=new la(288),x=new la(32),S=0,C=0,A=s.i||0,k=0,L=s.w||0,T=0;A+2<o;++A){var P=b(A),N=32767&A,O=m[P];if(g[N]=O,m[P]=N,L<=A){var E=o-A;if((S>7e3||k>24576)&&(E>423||!l)){c=ja(t,h,0,w,_,x,C,k,T,A-T,c),k=S=C=0,T=A;for(var M=0;M<286;++M)_[M]=0;for(M=0;M<30;++M)x[M]=0}var D=2,F=0,j=d,I=N-O&32767;if(E>2&&P==b(A-I))for(var B=Math.min(f,E)-1,R=Math.min(32767,A),z=Math.min(258,E);I<=R&&--j&&N!=O;){if(t[A+D]==t[A+D-I]){for(var U=0;U<z&&t[A+U]==t[A+U-I];++U);if(U>D){if(D=U,F=I,U>B)break;var q=Math.min(I,U-2),W=0;for(M=0;M<q;++M){var H=A-I+M&32767,V=H-g[H]&32767;V>W&&(W=V,O=H)}}}I+=(N=O)-(O=g[N])&32767}if(F){w[k++]=268435456|va[D]<<18|ba[F];var Y=31&va[D],X=31&ba[F];C+=ua[Y]+fa[X],++_[257+Y],++x[X],L=A+D,++S}else w[k++]=t[A],++_[t[A]]}}for(A=Math.max(A,L);A<o;++A)w[k++]=t[A],++_[t[A]];c=ja(t,h,l,w,_,x,C,k,T,A-T,c),l||(s.r=7&c|h[c/8|0]<<3,c-=7,s.h=m,s.p=g,s.i=A,s.w=L)}else{for(A=s.w||0;A<o+l;A+=65535){var G=A+65535;G>=o&&(h[c/8|0]=l,G=o),c=Fa(h,c+1,t.subarray(A,G))}s.i=o}return function(t,e,r){return(null==e||e<0)&&(e=0),(null==r||r>t.length)&&(r=t.length),new ha(t.subarray(e,r))}(a,0,i+Ta(c)+n)},za=function(){var t=1,e=0;return{p:function(r){for(var i=t,n=e,s=0|r.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)n+=i+=r[o];i=(65535&i)+15*(i>>16),n=(65535&n)+15*(n>>16)}t=i,e=n},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(e%=65521))<<8|e>>8}}},Ua=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8};function qa(t,e){e||(e={});var r=za();r.p(t);var i=function(t,e,r,i,n){if(!n&&(n={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),o=new ha(s.length+t.length);o.set(s),o.set(t,s.length),t=o,n.w=s.length}return Ra(t,null==e.level?6:e.level,null==e.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,r,i,n)}(t,e,e.dictionary?6:2,4);return function(t,e){var r=e.level,i=0==r?0:r<6?1:9==r?3:2;if(t[0]=120,t[1]=i<<6|(e.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,e.dictionary){var n=za();n.p(e.dictionary),Ua(t,2,n.d())}}(i,e),Ua(i,i.length-4,r.d()),i}var Wa="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wa.decode(Ba,{stream:!0})}catch(e){}function Ha(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function Va(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,s,o,a=[],h=!0,l=!1;try{if(s=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;h=!1}else for(;!(h=(i=s.call(r)).done)&&(a.push(i.value),a.length!==e);h=!0);}catch(t){l=!0,n=t}finally{try{if(!h&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(l)throw n}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ha(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ha(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ya(t,e="utf8"){return new TextDecoder(e).decode(t)}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;const Xa=new TextEncoder,Ga=(()=>{const t=new Uint8Array(4);return!((new Uint32Array(t.buffer)[0]=1)&t[0])})(),$a={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class Ka{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=8192,e={}){let r=!1;"number"==typeof t?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);const i=e.offset?e.offset>>>0:0,n=t.byteLength-i;let s=i;(ArrayBuffer.isView(t)||t instanceof Ka)&&(t.byteLength!==t.buffer.byteLength&&(s=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=r?n:0,this.buffer=t,this.length=n,this.byteLength=n,this.byteOffset=s,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,s,n),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const e=2*(this.offset+t),r=new Uint8Array(e);r.set(new Uint8Array(this.buffer)),this.buffer=r.buffer,this.length=e,this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,e){const r=$a[e].BYTES_PER_ELEMENT*t,i=this.byteOffset+this.offset,n=this.buffer.slice(i,i+r);if(this.littleEndian===Ga&&"uint8"!==e&&"int8"!==e){const t=new Uint8Array(this.buffer.slice(i,i+r));t.reverse();const n=new $a[e](t.buffer);return this.offset+=r,n.reverse(),n}const s=new $a[e](n);return this.offset+=r,s}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let e="";for(let r=0;r<t;r++)e+=this.readChar();return e}readUtf8(t=1){return Ya(this.readBytes(t))}decodeText(t=1,e="utf8"){return Ya(this.readBytes(t),e)}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let e=0;e<t.length;e++)this._data.setUint8(this.offset++,t[e]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(t){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(t){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let e=0;e<t.length;e++)this.writeUint8(t.charCodeAt(e));return this}writeUtf8(t){return this.writeBytes(function(t){return Xa.encode(t)}(t))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function Ja(t){let e=t.length;for(;--e>=0;)t[e]=0}const Za=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Qa=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),th=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),eh=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rh=new Array(576);Ja(rh);const ih=new Array(60);Ja(ih);const nh=new Array(512);Ja(nh);const sh=new Array(256);Ja(sh);const oh=new Array(29);Ja(oh);const ah=new Array(30);function hh(t,e,r,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let lh,ch,uh;function fh(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}Ja(ah);const dh=t=>t<256?nh[t]:nh[256+(t>>>7)],ph=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},gh=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,ph(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},mh=(t,e,r)=>{gh(t,r[2*e],r[2*e+1])},vh=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},yh=(t,e,r)=>{const i=new Array(16);let n,s,o=0;for(n=1;n<=15;n++)o=o+r[n-1]<<1,i[n]=o;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=vh(i[e]++,e))}},bh=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},wh=t=>{t.bi_valid>8?ph(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},_h=(t,e,r,i)=>{const n=2*e,s=2*r;return t[n]<t[s]||t[n]===t[s]&&i[e]<=i[r]},xh=(t,e,r)=>{const i=t.heap[r];let n=r<<1;for(;n<=t.heap_len&&(n<t.heap_len&&_h(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!_h(e,i,t.heap[n],t.depth));)t.heap[r]=t.heap[n],r=n,n<<=1;t.heap[r]=i},Sh=(t,e,r)=>{let i,n,s,o,a=0;if(0!==t.sym_next)do{i=255&t.pending_buf[t.sym_buf+a++],i+=(255&t.pending_buf[t.sym_buf+a++])<<8,n=t.pending_buf[t.sym_buf+a++],0===i?mh(t,n,e):(s=sh[n],mh(t,s+256+1,e),o=Za[s],0!==o&&(n-=oh[s],gh(t,n,o)),i--,s=dh(i),mh(t,s,r),o=Qa[s],0!==o&&(i-=ah[s],gh(t,i,o)))}while(a<t.sym_next);mh(t,256,e)},Ch=(t,e)=>{const r=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,h,l=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(t.heap[++t.heap_len]=l=o,t.depth[o]=0):r[2*o+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=l<2?++l:0,r[2*h]=1,t.depth[h]=0,t.opt_len--,n&&(t.static_len-=i[2*h+1]);for(e.max_code=l,o=t.heap_len>>1;o>=1;o--)xh(t,r,o);h=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],xh(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,r[2*h]=r[2*o]+r[2*a],t.depth[h]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,r[2*o+1]=r[2*a+1]=h,t.heap[1]=h++,xh(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,h=e.stat_desc.max_length;let l,c,u,f,d,p,g=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(r[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)c=t.heap[l],f=r[2*r[2*c+1]+1]+1,f>h&&(f=h,g++),r[2*c+1]=f,c>i||(t.bl_count[f]++,d=0,c>=a&&(d=o[c-a]),p=r[2*c],t.opt_len+=p*(f+d),s&&(t.static_len+=p*(n[2*c+1]+d)));if(0!==g){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,g-=2}while(g>0);for(f=h;0!==f;f--)for(c=t.bl_count[f];0!==c;)u=t.heap[--l],u>i||(r[2*u+1]!==f&&(t.opt_len+=(f-r[2*u+1])*r[2*u],r[2*u+1]=f),c--)}})(t,e),yh(r,l,t.bl_count)},Ah=(t,e,r)=>{let i,n,s=-1,o=e[1],a=0,h=7,l=4;for(0===o&&(h=138,l=3),e[2*(r+1)+1]=65535,i=0;i<=r;i++)n=o,o=e[2*(i+1)+1],++a<h&&n===o||(a<l?t.bl_tree[2*n]+=a:0!==n?(n!==s&&t.bl_tree[2*n]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=n,0===o?(h=138,l=3):n===o?(h=6,l=3):(h=7,l=4))},kh=(t,e,r)=>{let i,n,s=-1,o=e[1],a=0,h=7,l=4;for(0===o&&(h=138,l=3),i=0;i<=r;i++)if(n=o,o=e[2*(i+1)+1],!(++a<h&&n===o)){if(a<l)do{mh(t,n,t.bl_tree)}while(0!==--a);else 0!==n?(n!==s&&(mh(t,n,t.bl_tree),a--),mh(t,16,t.bl_tree),gh(t,a-3,2)):a<=10?(mh(t,17,t.bl_tree),gh(t,a-3,3)):(mh(t,18,t.bl_tree),gh(t,a-11,7));a=0,s=n,0===o?(h=138,l=3):n===o?(h=6,l=3):(h=7,l=4)}};let Lh=!1;const Th=(t,e,r,i)=>{gh(t,0+(i?1:0),3),wh(t),ph(t,r),ph(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r};var Ph={_tr_init:t=>{Lh||((()=>{let t,e,r,i,n;const s=new Array(16);for(r=0,i=0;i<28;i++)for(oh[i]=r,t=0;t<1<<Za[i];t++)sh[r++]=i;for(sh[r-1]=i,n=0,i=0;i<16;i++)for(ah[i]=n,t=0;t<1<<Qa[i];t++)nh[n++]=i;for(n>>=7;i<30;i++)for(ah[i]=n<<7,t=0;t<1<<Qa[i]-7;t++)nh[256+n++]=i;for(e=0;e<=15;e++)s[e]=0;for(t=0;t<=143;)rh[2*t+1]=8,t++,s[8]++;for(;t<=255;)rh[2*t+1]=9,t++,s[9]++;for(;t<=279;)rh[2*t+1]=7,t++,s[7]++;for(;t<=287;)rh[2*t+1]=8,t++,s[8]++;for(yh(rh,287,s),t=0;t<30;t++)ih[2*t+1]=5,ih[2*t]=vh(t,5);lh=new hh(rh,Za,257,286,15),ch=new hh(ih,Qa,0,30,15),uh=new hh(new Array(0),th,0,19,7)})(),Lh=!0),t.l_desc=new fh(t.dyn_ltree,lh),t.d_desc=new fh(t.dyn_dtree,ch),t.bl_desc=new fh(t.bl_tree,uh),t.bi_buf=0,t.bi_valid=0,bh(t)},_tr_stored_block:Th,_tr_flush_block:(t,e,r,i)=>{let n,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Ch(t,t.l_desc),Ch(t,t.d_desc),o=(t=>{let e;for(Ah(t,t.dyn_ltree,t.l_desc.max_code),Ah(t,t.dyn_dtree,t.d_desc.max_code),Ch(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*eh[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),n=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=n&&(n=s)):n=s=r+5,r+4<=n&&-1!==e?Th(t,e,r,i):4===t.strategy||s===n?(gh(t,2+(i?1:0),3),Sh(t,rh,ih)):(gh(t,4+(i?1:0),3),((t,e,r,i)=>{let n;for(gh(t,e-257,5),gh(t,r-1,5),gh(t,i-4,4),n=0;n<i;n++)gh(t,t.bl_tree[2*eh[n]+1],3);kh(t,t.dyn_ltree,e-1),kh(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Sh(t,t.dyn_ltree,t.dyn_dtree)),bh(t),i&&wh(t)},_tr_tally:(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(sh[r]+256+1)]++,t.dyn_dtree[2*dh(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{gh(t,2,3),mh(t,256,rh),(t=>{16===t.bi_valid?(ph(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},Nh=(t,e,r,i)=>{let n=65535&t,s=t>>>16&65535,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{n=n+e[i++]|0,s=s+n|0}while(--o);n%=65521,s%=65521}return n|s<<16};const Oh=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var Eh=(t,e,r,i)=>{const n=Oh,s=i+r;t^=-1;for(let r=i;r<s;r++)t=t>>>8^n[255&(t^e[r])];return-1^t},Mh={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Dh={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Fh,_tr_stored_block:jh,_tr_flush_block:Ih,_tr_tally:Bh,_tr_align:Rh}=Ph,{Z_NO_FLUSH:zh,Z_PARTIAL_FLUSH:Uh,Z_FULL_FLUSH:qh,Z_FINISH:Wh,Z_BLOCK:Hh,Z_OK:Vh,Z_STREAM_END:Yh,Z_STREAM_ERROR:Xh,Z_DATA_ERROR:Gh,Z_BUF_ERROR:$h,Z_DEFAULT_COMPRESSION:Kh,Z_FILTERED:Jh,Z_HUFFMAN_ONLY:Zh,Z_RLE:Qh,Z_FIXED:tl,Z_DEFAULT_STRATEGY:el,Z_UNKNOWN:rl,Z_DEFLATED:il}=Dh,nl=258,sl=262,ol=42,al=113,hl=666,ll=(t,e)=>(t.msg=Mh[e],e),cl=t=>2*t-(t>4?9:0),ul=t=>{let e=t.length;for(;--e>=0;)t[e]=0},fl=t=>{let e,r,i,n=t.w_size;e=t.hash_size,i=e;do{r=t.head[--i],t.head[i]=r>=n?r-n:0}while(--e);e=n,i=e;do{r=t.prev[--i],t.prev[i]=r>=n?r-n:0}while(--e)};let dl=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const pl=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},gl=(t,e)=>{Ih(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,pl(t.strm)},ml=(t,e)=>{t.pending_buf[t.pending++]=e},vl=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},yl=(t,e,r,i)=>{let n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),r),1===t.state.wrap?t.adler=Nh(t.adler,e,n,r):2===t.state.wrap&&(t.adler=Eh(t.adler,e,n,r)),t.next_in+=n,t.total_in+=n,n)},bl=(t,e)=>{let r,i,n=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const h=t.strstart>t.w_size-sl?t.strstart-(t.w_size-sl):0,l=t.window,c=t.w_mask,u=t.prev,f=t.strstart+nl;let d=l[s+o-1],p=l[s+o];t.prev_length>=t.good_match&&(n>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,l[r+o]===p&&l[r+o-1]===d&&l[r]===l[s]&&l[++r]===l[s+1]){s+=2,r++;do{}while(l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&s<f);if(i=nl-(f-s),s=f-nl,i>o){if(t.match_start=e,o=i,i>=a)break;d=l[s+o-1],p=l[s+o]}}}while((e=u[e&c])>h&&0!==--n);return o<=t.lookahead?o:t.lookahead},wl=t=>{const e=t.w_size;let r,i,n;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-sl)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),fl(t),i+=e),0===t.strm.avail_in)break;if(r=yl(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=r,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=dl(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=dl(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<sl&&0!==t.strm.avail_in)},_l=(t,e)=>{let r,i,n,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(r=65535,n=t.bi_valid+42>>3,t.strm.avail_out<n)break;if(n=t.strm.avail_out-n,i=t.strstart-t.block_start,r>i+t.strm.avail_in&&(r=i+t.strm.avail_in),r>n&&(r=n),r<s&&(0===r&&e!==Wh||e===zh||r!==i+t.strm.avail_in))break;o=e===Wh&&r===i+t.strm.avail_in?1:0,jh(t,0,0,o),t.pending_buf[t.pending-4]=r,t.pending_buf[t.pending-3]=r>>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,pl(t.strm),i&&(i>r&&(i=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,r-=i),r&&(yl(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===o);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?4:e!==zh&&e!==Wh&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(n=t.window_size-t.strstart,t.strm.avail_in>n&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,n+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),n>t.strm.avail_in&&(n=t.strm.avail_in),n&&(yl(t.strm,t.window,t.strstart,n),t.strstart+=n,t.insert+=n>t.w_size-t.insert?t.w_size-t.insert:n),t.high_water<t.strstart&&(t.high_water=t.strstart),n=t.bi_valid+42>>3,n=t.pending_buf_size-n>65535?65535:t.pending_buf_size-n,s=n>t.w_size?t.w_size:n,i=t.strstart-t.block_start,(i>=s||(i||e===Wh)&&e!==zh&&0===t.strm.avail_in&&i<=n)&&(r=i>n?n:i,o=e===Wh&&0===t.strm.avail_in&&r===i?1:0,jh(t,t.block_start,r,o),t.block_start+=r,pl(t.strm)),o?3:1)},xl=(t,e)=>{let r,i;for(;;){if(t.lookahead<sl){if(wl(t),t.lookahead<sl&&e===zh)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=dl(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-sl&&(t.match_length=bl(t,r)),t.match_length>=3)if(i=Bh(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=dl(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=dl(t,t.ins_h,t.window[t.strstart+1]);else i=Bh(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(gl(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Wh?(gl(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(gl(t,!1),0===t.strm.avail_out)?1:2},Sl=(t,e)=>{let r,i,n;for(;;){if(t.lookahead<sl){if(wl(t),t.lookahead<sl&&e===zh)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=dl(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-sl&&(t.match_length=bl(t,r),t.match_length<=5&&(t.strategy===Jh||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=Bh(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=dl(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(gl(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=Bh(t,0,t.window[t.strstart-1]),i&&gl(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=Bh(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Wh?(gl(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(gl(t,!1),0===t.strm.avail_out)?1:2};function Cl(t,e,r,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=i,this.func=n}const Al=[new Cl(0,0,0,0,_l),new Cl(4,4,8,4,xl),new Cl(4,5,16,8,xl),new Cl(4,6,32,32,xl),new Cl(4,4,16,16,Sl),new Cl(8,16,32,32,Sl),new Cl(8,16,128,128,Sl),new Cl(8,32,128,256,Sl),new Cl(32,128,258,1024,Sl),new Cl(32,258,258,4096,Sl)];function kl(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=il,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ul(this.dyn_ltree),ul(this.dyn_dtree),ul(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ul(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ul(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ll=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==ol&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==al&&e.status!==hl?1:0},Tl=t=>{if(Ll(t))return ll(t,Xh);t.total_in=t.total_out=0,t.data_type=rl;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?ol:al,t.adler=2===e.wrap?0:1,e.last_flush=-2,Fh(e),Vh},Pl=t=>{const e=Tl(t);return e===Vh&&(t=>{t.window_size=2*t.w_size,ul(t.head),t.max_lazy_match=Al[t.level].max_lazy,t.good_match=Al[t.level].good_length,t.nice_match=Al[t.level].nice_length,t.max_chain_length=Al[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0})(t.state),e},Nl=(t,e,r,i,n,s)=>{if(!t)return Xh;let o=1;if(e===Kh&&(e=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>9||r!==il||i<8||i>15||e<0||e>9||s<0||s>tl||8===i&&1!==o)return ll(t,Xh);8===i&&(i=9);const a=new kl;return t.state=a,a.strm=t,a.status=ol,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=n+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<n+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=s,a.method=r,Pl(t)};var Ol=Nl,El=(t,e)=>Ll(t)||2!==t.state.wrap?Xh:(t.state.gzhead=e,Vh),Ml=(t,e)=>{if(Ll(t)||e>Hh||e<0)return t?ll(t,Xh):Xh;const r=t.state;if(!t.output||0!==t.avail_in&&!t.input||r.status===hl&&e!==Wh)return ll(t,0===t.avail_out?$h:Xh);const i=r.last_flush;if(r.last_flush=e,0!==r.pending){if(pl(t),0===t.avail_out)return r.last_flush=-1,Vh}else if(0===t.avail_in&&cl(e)<=cl(i)&&e!==Wh)return ll(t,$h);if(r.status===hl&&0!==t.avail_in)return ll(t,$h);if(r.status===ol&&0===r.wrap&&(r.status=al),r.status===ol){let e=il+(r.w_bits-8<<4)<<8,i=-1;if(i=r.strategy>=Zh||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=i<<6,0!==r.strstart&&(e|=32),e+=31-e%31,vl(r,e),0!==r.strstart&&(vl(r,t.adler>>>16),vl(r,65535&t.adler)),t.adler=1,r.status=al,pl(t),0!==r.pending)return r.last_flush=-1,Vh}if(57===r.status)if(t.adler=0,ml(r,31),ml(r,139),ml(r,8),r.gzhead)ml(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),ml(r,255&r.gzhead.time),ml(r,r.gzhead.time>>8&255),ml(r,r.gzhead.time>>16&255),ml(r,r.gzhead.time>>24&255),ml(r,9===r.level?2:r.strategy>=Zh||r.level<2?4:0),ml(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(ml(r,255&r.gzhead.extra.length),ml(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=Eh(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(ml(r,0),ml(r,0),ml(r,0),ml(r,0),ml(r,0),ml(r,9===r.level?2:r.strategy>=Zh||r.level<2?4:0),ml(r,3),r.status=al,pl(t),0!==r.pending)return r.last_flush=-1,Vh;if(69===r.status){if(r.gzhead.extra){let e=r.pending,i=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+i>r.pending_buf_size;){let n=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>e&&(t.adler=Eh(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex+=n,pl(t),0!==r.pending)return r.last_flush=-1,Vh;e=0,i-=n}let n=new Uint8Array(r.gzhead.extra);r.pending_buf.set(n.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending+=i,r.gzhead.hcrc&&r.pending>e&&(t.adler=Eh(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let e,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(t.adler=Eh(t.adler,r.pending_buf,r.pending-i,i)),pl(t),0!==r.pending)return r.last_flush=-1,Vh;i=0}e=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,ml(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>i&&(t.adler=Eh(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let e,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(t.adler=Eh(t.adler,r.pending_buf,r.pending-i,i)),pl(t),0!==r.pending)return r.last_flush=-1,Vh;i=0}e=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,ml(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>i&&(t.adler=Eh(t.adler,r.pending_buf,r.pending-i,i))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(pl(t),0!==r.pending))return r.last_flush=-1,Vh;ml(r,255&t.adler),ml(r,t.adler>>8&255),t.adler=0}if(r.status=al,pl(t),0!==r.pending)return r.last_flush=-1,Vh}if(0!==t.avail_in||0!==r.lookahead||e!==zh&&r.status!==hl){let i=0===r.level?_l(r,e):r.strategy===Zh?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(wl(t),0===t.lookahead)){if(e===zh)return 1;break}if(t.match_length=0,r=Bh(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(gl(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Wh?(gl(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(gl(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===Qh?((t,e)=>{let r,i,n,s;const o=t.window;for(;;){if(t.lookahead<=nl){if(wl(t),t.lookahead<=nl&&e===zh)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){s=t.strstart+nl;do{}while(i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&n<s);t.match_length=nl-(s-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=Bh(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=Bh(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(gl(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Wh?(gl(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(gl(t,!1),0===t.strm.avail_out)?1:2})(r,e):Al[r.level].func(r,e);if(3!==i&&4!==i||(r.status=hl),1===i||3===i)return 0===t.avail_out&&(r.last_flush=-1),Vh;if(2===i&&(e===Uh?Rh(r):e!==Hh&&(jh(r,0,0,!1),e===qh&&(ul(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),pl(t),0===t.avail_out))return r.last_flush=-1,Vh}return e!==Wh?Vh:r.wrap<=0?Yh:(2===r.wrap?(ml(r,255&t.adler),ml(r,t.adler>>8&255),ml(r,t.adler>>16&255),ml(r,t.adler>>24&255),ml(r,255&t.total_in),ml(r,t.total_in>>8&255),ml(r,t.total_in>>16&255),ml(r,t.total_in>>24&255)):(vl(r,t.adler>>>16),vl(r,65535&t.adler)),pl(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Vh:Yh)},Dl=t=>{if(Ll(t))return Xh;const e=t.state.status;return t.state=null,e===al?ll(t,Gh):Vh},Fl=(t,e)=>{let r=e.length;if(Ll(t))return Xh;const i=t.state,n=i.wrap;if(2===n||1===n&&i.status!==ol||i.lookahead)return Xh;if(1===n&&(t.adler=Nh(t.adler,e,r,0)),i.wrap=0,r>=i.w_size){0===n&&(ul(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(r-i.w_size,r),0),e=t,r=i.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,wl(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=dl(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,wl(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,i.wrap=n,Vh};const jl=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Il=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)jl(r,e)&&(t[e]=r[e])}}return t},Bl=t=>{let e=0;for(let r=0,i=t.length;r<i;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,i=0,n=t.length;e<n;e++){let n=t[e];r.set(n,i),i+=n.length}return r};let Rl=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Rl=!1}const zl=new Uint8Array(256);for(let t=0;t<256;t++)zl[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;zl[254]=zl[254]=1;var Ul=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,i,n,s,o=t.length,a=0;for(n=0;n<o;n++)r=t.charCodeAt(n),55296==(64512&r)&&n+1<o&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),s=0,n=0;s<a;n++)r=t.charCodeAt(n),55296==(64512&r)&&n+1<o&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?e[s++]=r:r<2048?(e[s++]=192|r>>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},ql=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,n;const s=new Array(2*r);for(n=0,i=0;i<r;){let e=t[i++];if(e<128){s[n++]=e;continue}let o=zl[e];if(o>4)s[n++]=65533,i+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&i<r;)e=e<<6|63&t[i++],o--;o>1?s[n++]=65533:e<65536?s[n++]=e:(e-=65536,s[n++]=55296|e>>10&1023,s[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Rl)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let i=0;i<e;i++)r+=String.fromCharCode(t[i]);return r})(s,n)},Wl=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+zl[t[r]]>e?r:e},Hl=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Vl=Object.prototype.toString,{Z_NO_FLUSH:Yl,Z_SYNC_FLUSH:Xl,Z_FULL_FLUSH:Gl,Z_FINISH:$l,Z_OK:Kl,Z_STREAM_END:Jl,Z_DEFAULT_COMPRESSION:Zl,Z_DEFAULT_STRATEGY:Ql,Z_DEFLATED:tc}=Dh;function ec(t){this.options=Il({level:Zl,method:tc,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ql},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Hl,this.strm.avail_out=0;let r=Ol(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Kl)throw new Error(Mh[r]);if(e.header&&El(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Ul(e.dictionary):"[object ArrayBuffer]"===Vl.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Fl(this.strm,t),r!==Kl)throw new Error(Mh[r]);this._dict_set=!0}}function rc(t,e){const r=new ec(e);if(r.push(t,!0),r.err)throw r.msg||Mh[r.err];return r.result}ec.prototype.push=function(t,e){const r=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?$l:Yl,"string"==typeof t?r.input=Ul(t):"[object ArrayBuffer]"===Vl.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(s===Xl||s===Gl)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=Ml(r,s),n===Jl)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=Dl(this.strm),this.onEnd(n),this.ended=!0,n===Kl;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},ec.prototype.onData=function(t){this.chunks.push(t)},ec.prototype.onEnd=function(t){t===Kl&&(this.result=Bl(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var ic={Deflate:ec,deflate:rc,deflateRaw:function(t,e){return(e=e||{}).raw=!0,rc(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,rc(t,e)},constants:Dh};const nc=16209;var sc=function(t,e){let r,i,n,s,o,a,h,l,c,u,f,d,p,g,m,v,y,b,w,_,x,S,C,A;const k=t.state;r=t.next_in,C=t.input,i=r+(t.avail_in-5),n=t.next_out,A=t.output,s=n-(e-t.avail_out),o=n+(t.avail_out-257),a=k.dmax,h=k.wsize,l=k.whave,c=k.wnext,u=k.window,f=k.hold,d=k.bits,p=k.lencode,g=k.distcode,m=(1<<k.lenbits)-1,v=(1<<k.distbits)-1;t:do{d<15&&(f+=C[r++]<<d,d+=8,f+=C[r++]<<d,d+=8),y=p[f&m];e:for(;;){if(b=y>>>24,f>>>=b,d-=b,b=y>>>16&255,0===b)A[n++]=65535&y;else{if(!(16&b)){if(64&b){if(32&b){k.mode=16191;break t}t.msg="invalid literal/length code",k.mode=nc;break t}y=p[(65535&y)+(f&(1<<b)-1)];continue e}for(w=65535&y,b&=15,b&&(d<b&&(f+=C[r++]<<d,d+=8),w+=f&(1<<b)-1,f>>>=b,d-=b),d<15&&(f+=C[r++]<<d,d+=8,f+=C[r++]<<d,d+=8),y=g[f&v];;){if(b=y>>>24,f>>>=b,d-=b,b=y>>>16&255,16&b){if(_=65535&y,b&=15,d<b&&(f+=C[r++]<<d,d+=8,d<b&&(f+=C[r++]<<d,d+=8)),_+=f&(1<<b)-1,_>a){t.msg="invalid distance too far back",k.mode=nc;break t}if(f>>>=b,d-=b,b=n-s,_>b){if(b=_-b,b>l&&k.sane){t.msg="invalid distance too far back",k.mode=nc;break t}if(x=0,S=u,0===c){if(x+=h-b,b<w){w-=b;do{A[n++]=u[x++]}while(--b);x=n-_,S=A}}else if(c<b){if(x+=h+c-b,b-=c,b<w){w-=b;do{A[n++]=u[x++]}while(--b);if(x=0,c<w){b=c,w-=b;do{A[n++]=u[x++]}while(--b);x=n-_,S=A}}}else if(x+=c-b,b<w){w-=b;do{A[n++]=u[x++]}while(--b);x=n-_,S=A}for(;w>2;)A[n++]=S[x++],A[n++]=S[x++],A[n++]=S[x++],w-=3;w&&(A[n++]=S[x++],w>1&&(A[n++]=S[x++]))}else{x=n-_;do{A[n++]=A[x++],A[n++]=A[x++],A[n++]=A[x++],w-=3}while(w>2);w&&(A[n++]=A[x++],w>1&&(A[n++]=A[x++]))}break}if(64&b){t.msg="invalid distance code",k.mode=nc;break t}y=g[(65535&y)+(f&(1<<b)-1)]}}break}}while(r<i&&n<o);w=d>>3,r-=w,d-=w<<3,f&=(1<<d)-1,t.next_in=r,t.next_out=n,t.avail_in=r<i?i-r+5:5-(r-i),t.avail_out=n<o?o-n+257:257-(n-o),k.hold=f,k.bits=d};const oc=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ac=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),hc=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),lc=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var cc=(t,e,r,i,n,s,o,a)=>{const h=a.bits;let l,c,u,f,d,p,g=0,m=0,v=0,y=0,b=0,w=0,_=0,x=0,S=0,C=0,A=null;const k=new Uint16Array(16),L=new Uint16Array(16);let T,P,N,O=null;for(g=0;g<=15;g++)k[g]=0;for(m=0;m<i;m++)k[e[r+m]]++;for(b=h,y=15;y>=1&&0===k[y];y--);if(b>y&&(b=y),0===y)return n[s++]=20971520,n[s++]=20971520,a.bits=1,0;for(v=1;v<y&&0===k[v];v++);for(b<v&&(b=v),x=1,g=1;g<=15;g++)if(x<<=1,x-=k[g],x<0)return-1;if(x>0&&(0===t||1!==y))return-1;for(L[1]=0,g=1;g<15;g++)L[g+1]=L[g]+k[g];for(m=0;m<i;m++)0!==e[r+m]&&(o[L[e[r+m]]++]=m);if(0===t?(A=O=o,p=20):1===t?(A=oc,O=ac,p=257):(A=hc,O=lc,p=0),C=0,m=0,g=v,d=s,w=b,_=0,u=-1,S=1<<b,f=S-1,1===t&&S>852||2===t&&S>592)return 1;for(;;){T=g-_,o[m]+1<p?(P=0,N=o[m]):o[m]>=p?(P=O[o[m]-p],N=A[o[m]-p]):(P=96,N=0),l=1<<g-_,c=1<<w,v=c;do{c-=l,n[d+(C>>_)+c]=T<<24|P<<16|N}while(0!==c);for(l=1<<g-1;C&l;)l>>=1;if(0!==l?(C&=l-1,C+=l):C=0,m++,0===--k[g]){if(g===y)break;g=e[r+o[m]]}if(g>b&&(C&f)!==u){for(0===_&&(_=b),d+=v,w=g-_,x=1<<w;w+_<y&&(x-=k[w+_],!(x<=0));)w++,x<<=1;if(S+=1<<w,1===t&&S>852||2===t&&S>592)return 1;u=C&f,n[u]=b<<24|w<<16|d-s}}return 0!==C&&(n[d+C]=g-_<<24|64<<16),a.bits=b,0};const{Z_FINISH:uc,Z_BLOCK:fc,Z_TREES:dc,Z_OK:pc,Z_STREAM_END:gc,Z_NEED_DICT:mc,Z_STREAM_ERROR:vc,Z_DATA_ERROR:yc,Z_MEM_ERROR:bc,Z_BUF_ERROR:wc,Z_DEFLATED:_c}=Dh,xc=16180,Sc=16190,Cc=16191,Ac=16192,kc=16194,Lc=16199,Tc=16200,Pc=16206,Nc=16209,Oc=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Ec(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Mc=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<xc||e.mode>16211?1:0},Dc=t=>{if(Mc(t))return vc;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=xc,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,pc},Fc=t=>{if(Mc(t))return vc;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Dc(t)},jc=(t,e)=>{let r;if(Mc(t))return vc;const i=t.state;return e<0?(r=0,e=-e):(r=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?vc:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,Fc(t))},Ic=(t,e)=>{if(!t)return vc;const r=new Ec;t.state=r,r.strm=t,r.window=null,r.mode=xc;const i=jc(t,e);return i!==pc&&(t.state=null),i};let Bc,Rc,zc=!0;const Uc=t=>{if(zc){Bc=new Int32Array(512),Rc=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(cc(1,t.lens,0,288,Bc,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;cc(2,t.lens,0,32,Rc,0,t.work,{bits:5}),zc=!1}t.lencode=Bc,t.lenbits=9,t.distcode=Rc,t.distbits=5},qc=(t,e,r,i)=>{let n;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(e.subarray(r-i,r-i+n),s.wnext),(i-=n)?(s.window.set(e.subarray(r-i,r),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var Wc=Fc,Hc=Ic,Vc=(t,e)=>{let r,i,n,s,o,a,h,l,c,u,f,d,p,g,m,v,y,b,w,_,x,S,C=0;const A=new Uint8Array(4);let k,L;const T=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Mc(t)||!t.output||!t.input&&0!==t.avail_in)return vc;r=t.state,r.mode===Cc&&(r.mode=Ac),o=t.next_out,n=t.output,h=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,l=r.hold,c=r.bits,u=a,f=h,S=pc;t:for(;;)switch(r.mode){case xc:if(0===r.wrap){r.mode=Ac;break}for(;c<16;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(2&r.wrap&&35615===l){0===r.wbits&&(r.wbits=15),r.check=0,A[0]=255&l,A[1]=l>>>8&255,r.check=Eh(r.check,A,2,0),l=0,c=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",r.mode=Nc;break}if((15&l)!==_c){t.msg="unknown compression method",r.mode=Nc;break}if(l>>>=4,c-=4,x=8+(15&l),0===r.wbits&&(r.wbits=x),x>15||x>r.wbits){t.msg="invalid window size",r.mode=Nc;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=512&l?16189:Cc,l=0,c=0;break;case 16181:for(;c<16;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(r.flags=l,(255&r.flags)!==_c){t.msg="unknown compression method",r.mode=Nc;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=Nc;break}r.head&&(r.head.text=l>>8&1),512&r.flags&&4&r.wrap&&(A[0]=255&l,A[1]=l>>>8&255,r.check=Eh(r.check,A,2,0)),l=0,c=0,r.mode=16182;case 16182:for(;c<32;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}r.head&&(r.head.time=l),512&r.flags&&4&r.wrap&&(A[0]=255&l,A[1]=l>>>8&255,A[2]=l>>>16&255,A[3]=l>>>24&255,r.check=Eh(r.check,A,4,0)),l=0,c=0,r.mode=16183;case 16183:for(;c<16;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}r.head&&(r.head.xflags=255&l,r.head.os=l>>8),512&r.flags&&4&r.wrap&&(A[0]=255&l,A[1]=l>>>8&255,r.check=Eh(r.check,A,2,0)),l=0,c=0,r.mode=16184;case 16184:if(1024&r.flags){for(;c<16;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}r.length=l,r.head&&(r.head.extra_len=l),512&r.flags&&4&r.wrap&&(A[0]=255&l,A[1]=l>>>8&255,r.check=Eh(r.check,A,2,0)),l=0,c=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(d=r.length,d>a&&(d=a),d&&(r.head&&(x=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(s,s+d),x)),512&r.flags&&4&r.wrap&&(r.check=Eh(r.check,i,d,s)),a-=d,s+=d,r.length-=d),r.length))break t;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break t;d=0;do{x=i[s+d++],r.head&&x&&r.length<65536&&(r.head.name+=String.fromCharCode(x))}while(x&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=Eh(r.check,i,d,s)),a-=d,s+=d,x)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break t;d=0;do{x=i[s+d++],r.head&&x&&r.length<65536&&(r.head.comment+=String.fromCharCode(x))}while(x&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=Eh(r.check,i,d,s)),a-=d,s+=d,x)break t}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;c<16;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(4&r.wrap&&l!==(65535&r.check)){t.msg="header crc mismatch",r.mode=Nc;break}l=0,c=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Cc;break;case 16189:for(;c<32;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}t.adler=r.check=Oc(l),l=0,c=0,r.mode=Sc;case Sc:if(0===r.havedict)return t.next_out=o,t.avail_out=h,t.next_in=s,t.avail_in=a,r.hold=l,r.bits=c,mc;t.adler=r.check=1,r.mode=Cc;case Cc:if(e===fc||e===dc)break t;case Ac:if(r.last){l>>>=7&c,c-=7&c,r.mode=Pc;break}for(;c<3;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}switch(r.last=1&l,l>>>=1,c-=1,3&l){case 0:r.mode=16193;break;case 1:if(Uc(r),r.mode=Lc,e===dc){l>>>=2,c-=2;break t}break;case 2:r.mode=16196;break;case 3:t.msg="invalid block type",r.mode=Nc}l>>>=2,c-=2;break;case 16193:for(l>>>=7&c,c-=7&c;c<32;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",r.mode=Nc;break}if(r.length=65535&l,l=0,c=0,r.mode=kc,e===dc)break t;case kc:r.mode=16195;case 16195:if(d=r.length,d){if(d>a&&(d=a),d>h&&(d=h),0===d)break t;n.set(i.subarray(s,s+d),o),a-=d,s+=d,h-=d,o+=d,r.length-=d;break}r.mode=Cc;break;case 16196:for(;c<14;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(r.nlen=257+(31&l),l>>>=5,c-=5,r.ndist=1+(31&l),l>>>=5,c-=5,r.ncode=4+(15&l),l>>>=4,c-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=Nc;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;c<3;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}r.lens[T[r.have++]]=7&l,l>>>=3,c-=3}for(;r.have<19;)r.lens[T[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,k={bits:r.lenbits},S=cc(0,r.lens,0,19,r.lencode,0,r.work,k),r.lenbits=k.bits,S){t.msg="invalid code lengths set",r.mode=Nc;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;C=r.lencode[l&(1<<r.lenbits)-1],m=C>>>24,v=C>>>16&255,y=65535&C,!(m<=c);){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(y<16)l>>>=m,c-=m,r.lens[r.have++]=y;else{if(16===y){for(L=m+2;c<L;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(l>>>=m,c-=m,0===r.have){t.msg="invalid bit length repeat",r.mode=Nc;break}x=r.lens[r.have-1],d=3+(3&l),l>>>=2,c-=2}else if(17===y){for(L=m+3;c<L;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}l>>>=m,c-=m,x=0,d=3+(7&l),l>>>=3,c-=3}else{for(L=m+7;c<L;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}l>>>=m,c-=m,x=0,d=11+(127&l),l>>>=7,c-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=Nc;break}for(;d--;)r.lens[r.have++]=x}}if(r.mode===Nc)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=Nc;break}if(r.lenbits=9,k={bits:r.lenbits},S=cc(1,r.lens,0,r.nlen,r.lencode,0,r.work,k),r.lenbits=k.bits,S){t.msg="invalid literal/lengths set",r.mode=Nc;break}if(r.distbits=6,r.distcode=r.distdyn,k={bits:r.distbits},S=cc(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,k),r.distbits=k.bits,S){t.msg="invalid distances set",r.mode=Nc;break}if(r.mode=Lc,e===dc)break t;case Lc:r.mode=Tc;case Tc:if(a>=6&&h>=258){t.next_out=o,t.avail_out=h,t.next_in=s,t.avail_in=a,r.hold=l,r.bits=c,sc(t,f),o=t.next_out,n=t.output,h=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,l=r.hold,c=r.bits,r.mode===Cc&&(r.back=-1);break}for(r.back=0;C=r.lencode[l&(1<<r.lenbits)-1],m=C>>>24,v=C>>>16&255,y=65535&C,!(m<=c);){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(v&&!(240&v)){for(b=m,w=v,_=y;C=r.lencode[_+((l&(1<<b+w)-1)>>b)],m=C>>>24,v=C>>>16&255,y=65535&C,!(b+m<=c);){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}l>>>=b,c-=b,r.back+=b}if(l>>>=m,c-=m,r.back+=m,r.length=y,0===v){r.mode=16205;break}if(32&v){r.back=-1,r.mode=Cc;break}if(64&v){t.msg="invalid literal/length code",r.mode=Nc;break}r.extra=15&v,r.mode=16201;case 16201:if(r.extra){for(L=r.extra;c<L;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;C=r.distcode[l&(1<<r.distbits)-1],m=C>>>24,v=C>>>16&255,y=65535&C,!(m<=c);){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(!(240&v)){for(b=m,w=v,_=y;C=r.distcode[_+((l&(1<<b+w)-1)>>b)],m=C>>>24,v=C>>>16&255,y=65535&C,!(b+m<=c);){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}l>>>=b,c-=b,r.back+=b}if(l>>>=m,c-=m,r.back+=m,64&v){t.msg="invalid distance code",r.mode=Nc;break}r.offset=y,r.extra=15&v,r.mode=16203;case 16203:if(r.extra){for(L=r.extra;c<L;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=Nc;break}r.mode=16204;case 16204:if(0===h)break t;if(d=f-h,r.offset>d){if(d=r.offset-d,d>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=Nc;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),g=r.window}else g=n,p=o-r.offset,d=r.length;d>h&&(d=h),h-=d,r.length-=d;do{n[o++]=g[p++]}while(--d);0===r.length&&(r.mode=Tc);break;case 16205:if(0===h)break t;n[o++]=r.length,h--,r.mode=Tc;break;case Pc:if(r.wrap){for(;c<32;){if(0===a)break t;a--,l|=i[s++]<<c,c+=8}if(f-=h,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?Eh(r.check,n,f,o-f):Nh(r.check,n,f,o-f)),f=h,4&r.wrap&&(r.flags?l:Oc(l))!==r.check){t.msg="incorrect data check",r.mode=Nc;break}l=0,c=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;c<32;){if(0===a)break t;a--,l+=i[s++]<<c,c+=8}if(4&r.wrap&&l!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=Nc;break}l=0,c=0}r.mode=16208;case 16208:S=gc;break t;case Nc:S=yc;break t;case 16210:return bc;default:return vc}return t.next_out=o,t.avail_out=h,t.next_in=s,t.avail_in=a,r.hold=l,r.bits=c,(r.wsize||f!==t.avail_out&&r.mode<Nc&&(r.mode<Pc||e!==uc))&&qc(t,t.output,t.next_out,f-t.avail_out),u-=t.avail_in,f-=t.avail_out,t.total_in+=u,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?Eh(r.check,n,f,t.next_out-f):Nh(r.check,n,f,t.next_out-f)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Cc?128:0)+(r.mode===Lc||r.mode===kc?256:0),(0===u&&0===f||e===uc)&&S===pc&&(S=wc),S},Yc=t=>{if(Mc(t))return vc;let e=t.state;return e.window&&(e.window=null),t.state=null,pc},Xc=(t,e)=>{if(Mc(t))return vc;const r=t.state;return 2&r.wrap?(r.head=e,e.done=!1,pc):vc},Gc=(t,e)=>{const r=e.length;let i,n,s;return Mc(t)?vc:(i=t.state,0!==i.wrap&&i.mode!==Sc?vc:i.mode===Sc&&(n=1,n=Nh(n,e,r,0),n!==i.check)?yc:(s=qc(t,e,r,r),s?(i.mode=16210,bc):(i.havedict=1,pc)))},$c=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Kc=Object.prototype.toString,{Z_NO_FLUSH:Jc,Z_FINISH:Zc,Z_OK:Qc,Z_STREAM_END:tu,Z_NEED_DICT:eu,Z_STREAM_ERROR:ru,Z_DATA_ERROR:iu,Z_MEM_ERROR:nu}=Dh;function su(t){this.options=Il({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Hl,this.strm.avail_out=0;let r=Hc(this.strm,e.windowBits);if(r!==Qc)throw new Error(Mh[r]);if(this.header=new $c,Xc(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Ul(e.dictionary):"[object ArrayBuffer]"===Kc.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Gc(this.strm,e.dictionary),r!==Qc)))throw new Error(Mh[r])}function ou(t,e){const r=new su(e);if(r.push(t),r.err)throw r.msg||Mh[r.err];return r.result}su.prototype.push=function(t,e){const r=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Zc:Jc,"[object ArrayBuffer]"===Kc.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),s=Vc(r,o),s===eu&&n&&(s=Gc(r,n),s===Qc?s=Vc(r,o):s===iu&&(s=eu));r.avail_in>0&&s===tu&&r.state.wrap>0&&0!==t[r.next_in];)Wc(r),s=Vc(r,o);switch(s){case ru:case iu:case eu:case nu:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===tu))if("string"===this.options.to){let t=Wl(r.output,r.next_out),e=r.next_out-t,n=ql(r.output,t);r.next_out=e,r.avail_out=i-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(n)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Qc||0!==a){if(s===tu)return s=Yc(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},su.prototype.onData=function(t){this.chunks.push(t)},su.prototype.onEnd=function(t){t===Qc&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Bl(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var au={Inflate:su,inflate:ou,inflateRaw:function(t,e){return(e=e||{}).raw=!0,ou(t,e)},ungzip:ou,constants:Dh};const{Deflate:hu,deflate:lu,deflateRaw:cu,gzip:uu}=ic,{Inflate:fu,inflate:du,inflateRaw:pu,ungzip:gu}=au;var mu=fu,vu=du;const yu=[];for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;yu[t]=e}const bu=4294967295;function wu(t,e,r){const i=t.readUint32(),n=(s=new Uint8Array(t.buffer,t.byteOffset+t.offset-e-4,e),(function(t,e,r){let i=t;for(let t=0;t<r;t++)i=yu[255&(i^e[t])]^i>>>8;return i}(bu,s,e)^bu)>>>0);var s;if(n!==i)throw new Error(`CRC mismatch for chunk ${r}. Expected ${i}, found ${n}`)}function _u(t,e,r){for(let i=0;i<r;i++)e[i]=t[i]}function xu(t,e,r,i){let n=0;for(;n<i;n++)e[n]=t[n];for(;n<r;n++)e[n]=t[n]+e[n-i]&255}function Su(t,e,r,i){let n=0;if(0===r.length)for(;n<i;n++)e[n]=t[n];else for(;n<i;n++)e[n]=t[n]+r[n]&255}function Cu(t,e,r,i,n){let s=0;if(0===r.length){for(;s<n;s++)e[s]=t[s];for(;s<i;s++)e[s]=t[s]+(e[s-n]>>1)&255}else{for(;s<n;s++)e[s]=t[s]+(r[s]>>1)&255;for(;s<i;s++)e[s]=t[s]+(e[s-n]+r[s]>>1)&255}}function Au(t,e,r,i,n){let s=0;if(0===r.length){for(;s<n;s++)e[s]=t[s];for(;s<i;s++)e[s]=t[s]+e[s-n]&255}else{for(;s<n;s++)e[s]=t[s]+r[s]&255;for(;s<i;s++)e[s]=t[s]+ku(e[s-n],r[s],r[s-n])&255}}function ku(t,e,r){const i=t+e-r,n=Math.abs(i-t),s=Math.abs(i-e),o=Math.abs(i-r);return n<=s&&n<=o?t:s<=o?e:r}function Lu(t,e,r,i,n,s){switch(t){case 0:_u(e,r,n);break;case 1:xu(e,r,n,s);break;case 2:Su(e,r,i,n);break;case 3:Cu(e,r,i,n,s);break;case 4:Au(e,r,i,n,s);break;default:throw new Error(`Unsupported filter: ${t}`)}}const Tu=new Uint16Array([255]),Pu=255===new Uint8Array(Tu.buffer)[0];function Nu(t){return(255&t)<<8|t>>8&255}const Ou=new Uint16Array([255]),Eu=255===new Uint8Array(Ou.buffer)[0],Mu=new Uint8Array(0);function Du(t){const{data:e,width:r,height:i,channels:n,depth:s}=t,o=Math.ceil(s/8)*n,a=Math.ceil(s/8*n*r),h=new Uint8Array(i*a);let l,c,u=Mu,f=0;for(let t=0;t<i;t++){switch(l=e.subarray(f+1,f+1+a),c=h.subarray(t*a,(t+1)*a),e[f]){case 0:_u(l,c,a);break;case 1:xu(l,c,a,o);break;case 2:Su(l,c,u,a);break;case 3:Cu(l,c,u,a,o);break;case 4:Au(l,c,u,a,o);break;default:throw new Error(`Unsupported filter: ${e[f]}`)}u=c,f+=a+1}if(16===s){const t=new Uint16Array(h.buffer);if(Eu)for(let e=0;e<t.length;e++)t[e]=Fu(t[e]);return t}return h}function Fu(t){return(255&t)<<8|t>>8&255}const ju=Uint8Array.of(137,80,78,71,13,10,26,10);function Iu(t){if(!function(t){if(t.length<ju.length)return!1;for(let e=0;e<ju.length;e++)if(t[e]!==ju[e])return!1;return!0}(t.readBytes(ju.length)))throw new Error("wrong PNG signature")}const Bu=new TextDecoder("latin1");function Ru(t){if(function(t){if(!zu.test(t))throw new Error("invalid latin1 text")}(t),0===t.length||t.length>79)throw new Error("keyword length must be between 1 and 79")}const zu=/^[\u0000-\u00FF]*$/;function Uu(t){for(t.mark();0!==t.readByte(););const e=t.offset;t.reset();const r=Bu.decode(t.readBytes(e-t.offset-1));return t.skip(1),Ru(r),r}class qu extends Ka{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(t,e={}){super(t);const{checkCrc:r=!1}=e;this._checkCrc=r,this._inflator=new mu,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=-1,this._filterMethod=-1,this._interlaceMethod=-1,this._colorType=-1,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(Iu(this);!this._end;){const t=this.readUint32(),e=this.readChars(4);this.decodeChunk(t,e)}return this.decodeImage(),this._png}decodeApng(){for(Iu(this);!this._end;){const t=this.readUint32(),e=this.readChars(4);this.decodeApngChunk(t,e)}return this.decodeApngImage(),this._apng}decodeChunk(t,e){const r=this.offset;switch(e){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case"tEXt":!function(t,e,r){const i=Uu(e);t[i]=function(t,e){return Bu.decode(t.readBytes(e))}(e,r-i.length-1)}(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t)}if(this.offset-r!==t)throw new Error(`Length mismatch while decoding chunk ${e}`);this._checkCrc?wu(this,t+4,e):this.skip(4)}decodeApngChunk(t,e){const r=this.offset;switch("fdAT"!==e&&"IDAT"!==e&&this._writingDataChunks&&this.pushDataToFrame(),e){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,e),this.offset=r+t}if(this.offset-r!==t)throw new Error(`Length mismatch while decoding chunk ${e}`);this._checkCrc?wu(this,t+4,e):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=function(t){if(1!==t&&2!==t&&4!==t&&8!==t&&16!==t)throw new Error(`invalid bit depth: ${t}`);return t}(this.readUint8());const e=this.readUint8();let r;switch(this._colorType=e,e){case 0:case 3:r=1;break;case 2:r=3;break;case 4:r=2;break;case 6:r=4;break;default:throw new Error(`Unknown color type: ${e}`)}if(this._png.channels=r,this._compressionMethod=this.readUint8(),0!==this._compressionMethod)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!=0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${t}`);const e=t/3;this._hasPalette=!0;const r=[];this._palette=r;for(let t=0;t<e;t++)r.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(t){this._writingDataChunks=!0;const e=t,r=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,r,e)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(t)}decodeFDAT(t){this._writingDataChunks=!0;let e=t,r=this.offset+this.byteOffset;if(r+=4,e-=4,this._inflator.push(new Uint8Array(this.buffer,r,e)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(t)}decodetRNS(t){switch(this._colorType){case 0:case 2:if(t%2!=0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${t}`);if(t/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${t/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let e=0;e<t/2;e++)this._transparency[e]=this.readUint16();break;case 3:{if(t>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${t} vs ${this._palette.length})`);let e=0;for(;e<t;e++){const t=this.readByte();this._palette[e].push(t)}for(;e<this._palette.length;e++)this._palette[e].push(255);break}default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(t){const e=Uu(this),r=this.readUint8();if(0!==r)throw new Error(`Unsupported iCCP compression method: ${r}`);const i=this.readBytes(t-e.length-2);this._png.iccEmbeddedProfile={name:e,profile:vu(i)}}decodepHYs(){const t=this.readUint32(),e=this.readUint32(),r=this.readByte();this._png.resolution={x:t,y:e,unit:r}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let t=0;t<this._numberOfFrames;t++){const e={sequenceNumber:this._frames[t].sequenceNumber,delayNumber:this._frames[t].delayNumber,delayDenominator:this._frames[t].delayDenominator,data:8===this._apng.depth?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},r=this._frames.at(t);if(r){if(r.data=Du({data:r.data,width:r.width,height:r.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),0===t||0===r.xOffset&&0===r.yOffset&&r.width===this._png.width&&r.height===this._png.height)e.data=r.data;else{const i=this._apng.frames.at(t-1);this.disposeFrame(r,i,e),this.addFrameDataToCanvas(e,r)}this._apng.frames.push(e)}}return this._apng}disposeFrame(t,e,r){switch(t.disposeOp){case 0:break;case 1:for(let e=0;e<this._png.height;e++)for(let i=0;i<this._png.width;i++){const n=(e*t.width+i)*this._png.channels;for(let t=0;t<this._png.channels;t++)r.data[n+t]=0}break;case 2:r.data.set(e.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(t,e){const r=1<<this._png.depth,i=(t,r)=>({index:((t+e.yOffset)*this._png.width+e.xOffset+r)*this._png.channels,frameIndex:(t*e.width+r)*this._png.channels});switch(e.blendOp){case 0:for(let r=0;r<e.height;r++)for(let n=0;n<e.width;n++){const{index:s,frameIndex:o}=i(r,n);for(let r=0;r<this._png.channels;r++)t.data[s+r]=e.data[o+r]}break;case 1:for(let n=0;n<e.height;n++)for(let s=0;s<e.width;s++){const{index:o,frameIndex:a}=i(n,s);for(let i=0;i<this._png.channels;i++){const n=e.data[a+this._png.channels-1]/r,s=i%(this._png.channels-1)==0?1:e.data[a+i],h=Math.floor(n*s+(1-n)*t.data[o+i]);t.data[o+i]+=h}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const t=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(0!==this._filterMethod)throw new Error(`Filter method ${this._filterMethod} not supported`);if(0===this._interlaceMethod)this._png.data=Du({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else{if(1!==this._interlaceMethod)throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._png.data=function(t){const{data:e,width:r,height:i,channels:n,depth:s}=t,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],a=Math.ceil(s/8)*n,h=new Uint8Array(i*r*a);let l=0;for(let t=0;t<7;t++){const n=o[t],s=Math.ceil((r-n.x)/n.xStep),c=Math.ceil((i-n.y)/n.yStep);if(s<=0||c<=0)continue;const u=s*a,f=new Uint8Array(u);for(let t=0;t<c;t++){const o=e[l++],c=e.subarray(l,l+u);l+=u;const d=new Uint8Array(u);Lu(o,c,d,f,u,a),f.set(d);for(let e=0;e<s;e++){const s=n.x+e*n.xStep,o=n.y+t*n.yStep;if(!(s>=r||o>=i))for(let t=0;t<a;t++)h[(o*r+s)*a+t]=d[e*a+t]}}}if(16===s){const t=new Uint16Array(h.buffer);if(Pu)for(let e=0;e<t.length;e++)t[e]=Nu(t[e]);return t}return h}({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth})}this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const t=this._inflator.result,e=this._frames.at(-1);e?e.data=t:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:0,blendOp:0,data:t}),this._inflator=new mu,this._writingDataChunks=!1}}var Wu;!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.METRE=1]="METRE"}(Wu||(Wu={}));var Hu=function(){return"undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this}();function Vu(){Hu.console&&"function"==typeof Hu.console.log&&Hu.console.log.apply(Hu.console,arguments)}var Yu={log:Vu,warn:function(t){Hu.console&&("function"==typeof Hu.console.warn?Hu.console.warn.apply(Hu.console,arguments):Vu.call(null,arguments))},error:function(t){Hu.console&&("function"==typeof Hu.console.error?Hu.console.error.apply(Hu.console,arguments):Vu(t))}};function Xu(t,e,r){var i=new XMLHttpRequest;i.open("GET",t),i.responseType="blob",i.onload=function(){Ku(i.response,e,r)},i.onerror=function(){Yu.error("could not download file")},i.send()}function Gu(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch(t){}return e.status>=200&&e.status<=299}function $u(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(r){var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var Ku=Hu.saveAs||("object"!==("undefined"==typeof window?"undefined":(0,aa.A)(window))||window!==Hu?function(){}:"undefined"!=typeof HTMLAnchorElement&&"download"in HTMLAnchorElement.prototype?function(t,e,r){var i=Hu.URL||Hu.webkitURL,n=document.createElement("a");e=e||t.name||"download",n.download=e,n.rel="noopener","string"==typeof t?(n.href=t,n.origin!==location.origin?Gu(n.href)?Xu(t,e,r):$u(n,n.target="_blank"):$u(n)):(n.href=i.createObjectURL(t),setTimeout(function(){i.revokeObjectURL(n.href)},4e4),setTimeout(function(){$u(n)},0))}:"msSaveOrOpenBlob"in navigator?function(t,e,r){if(e=e||t.name||"download","string"==typeof t)if(Gu(t))Xu(t,e,r);else{var i=document.createElement("a");i.href=t,i.target="_blank",setTimeout(function(){$u(i)})}else navigator.msSaveOrOpenBlob(function(t,e){return void 0===e?e={autoBom:!1}:"object"!==(0,aa.A)(e)&&(Yu.warn("Deprecated: Expected third argument to be a object"),e={autoBom:!e}),e.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob([String.fromCharCode(65279),t],{type:t.type}):t}(t,r),e)}:function(t,e,r,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof t)return Xu(t,e,r);var n="application/octet-stream"===t.type,s=/constructor/i.test(Hu.HTMLElement)||Hu.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||n&&s)&&"object"===("undefined"==typeof FileReader?"undefined":(0,aa.A)(FileReader))){var a=new FileReader;a.onloadend=function(){var t=a.result;t=o?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=t:location=t,i=null},a.readAsDataURL(t)}else{var h=Hu.URL||Hu.webkitURL,l=h.createObjectURL(t);i?i.location=l:location.href=l,i=null,setTimeout(function(){h.revokeObjectURL(l)},4e4)}});function Ju(t){var e;t=t||"",this.ok=!1,"#"==t.charAt(0)&&(t=t.substr(1,6)),t={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"}[t=(t=t.replace(/ /g,"")).toLowerCase()]||t;for(var r=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}],i=0;i<r.length;i++){var n=r[i].re,s=r[i].process,o=n.exec(t);o&&(e=s(o),this.r=e[0],this.g=e[1],this.b=e[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r}}var Zu=Hu.atob.bind(Hu),Qu=Hu.btoa.bind(Hu);function tf(t,e){var r=t[0],i=t[1],n=t[2],s=t[3];r=rf(r,i,n,s,e[0],7,-680876936),s=rf(s,r,i,n,e[1],12,-389564586),n=rf(n,s,r,i,e[2],17,606105819),i=rf(i,n,s,r,e[3],22,-1044525330),r=rf(r,i,n,s,e[4],7,-176418897),s=rf(s,r,i,n,e[5],12,1200080426),n=rf(n,s,r,i,e[6],17,-1473231341),i=rf(i,n,s,r,e[7],22,-45705983),r=rf(r,i,n,s,e[8],7,1770035416),s=rf(s,r,i,n,e[9],12,-1958414417),n=rf(n,s,r,i,e[10],17,-42063),i=rf(i,n,s,r,e[11],22,-1990404162),r=rf(r,i,n,s,e[12],7,1804603682),s=rf(s,r,i,n,e[13],12,-40341101),n=rf(n,s,r,i,e[14],17,-1502002290),r=nf(r,i=rf(i,n,s,r,e[15],22,1236535329),n,s,e[1],5,-165796510),s=nf(s,r,i,n,e[6],9,-1069501632),n=nf(n,s,r,i,e[11],14,643717713),i=nf(i,n,s,r,e[0],20,-373897302),r=nf(r,i,n,s,e[5],5,-701558691),s=nf(s,r,i,n,e[10],9,38016083),n=nf(n,s,r,i,e[15],14,-660478335),i=nf(i,n,s,r,e[4],20,-405537848),r=nf(r,i,n,s,e[9],5,568446438),s=nf(s,r,i,n,e[14],9,-1019803690),n=nf(n,s,r,i,e[3],14,-187363961),i=nf(i,n,s,r,e[8],20,1163531501),r=nf(r,i,n,s,e[13],5,-1444681467),s=nf(s,r,i,n,e[2],9,-51403784),n=nf(n,s,r,i,e[7],14,1735328473),r=sf(r,i=nf(i,n,s,r,e[12],20,-1926607734),n,s,e[5],4,-378558),s=sf(s,r,i,n,e[8],11,-2022574463),n=sf(n,s,r,i,e[11],16,1839030562),i=sf(i,n,s,r,e[14],23,-35309556),r=sf(r,i,n,s,e[1],4,-1530992060),s=sf(s,r,i,n,e[4],11,1272893353),n=sf(n,s,r,i,e[7],16,-155497632),i=sf(i,n,s,r,e[10],23,-1094730640),r=sf(r,i,n,s,e[13],4,681279174),s=sf(s,r,i,n,e[0],11,-358537222),n=sf(n,s,r,i,e[3],16,-722521979),i=sf(i,n,s,r,e[6],23,76029189),r=sf(r,i,n,s,e[9],4,-640364487),s=sf(s,r,i,n,e[12],11,-421815835),n=sf(n,s,r,i,e[15],16,530742520),r=of(r,i=sf(i,n,s,r,e[2],23,-995338651),n,s,e[0],6,-198630844),s=of(s,r,i,n,e[7],10,1126891415),n=of(n,s,r,i,e[14],15,-1416354905),i=of(i,n,s,r,e[5],21,-57434055),r=of(r,i,n,s,e[12],6,1700485571),s=of(s,r,i,n,e[3],10,-1894986606),n=of(n,s,r,i,e[10],15,-1051523),i=of(i,n,s,r,e[1],21,-2054922799),r=of(r,i,n,s,e[8],6,1873313359),s=of(s,r,i,n,e[15],10,-30611744),n=of(n,s,r,i,e[6],15,-1560198380),i=of(i,n,s,r,e[13],21,1309151649),r=of(r,i,n,s,e[4],6,-145523070),s=of(s,r,i,n,e[11],10,-1120210379),n=of(n,s,r,i,e[2],15,718787259),i=of(i,n,s,r,e[9],21,-343485551),t[0]=pf(r,t[0]),t[1]=pf(i,t[1]),t[2]=pf(n,t[2]),t[3]=pf(s,t[3])}function ef(t,e,r,i,n,s){return e=pf(pf(e,t),pf(i,s)),pf(e<<n|e>>>32-n,r)}function rf(t,e,r,i,n,s,o){return ef(e&r|~e&i,t,e,n,s,o)}function nf(t,e,r,i,n,s,o){return ef(e&i|r&~i,t,e,n,s,o)}function sf(t,e,r,i,n,s,o){return ef(e^r^i,t,e,n,s,o)}function of(t,e,r,i,n,s,o){return ef(r^(e|~i),t,e,n,s,o)}function af(t){var e,r=t.length,i=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=t.length;e+=64)tf(i,hf(t.substring(e-64,e)));t=t.substring(e-64);var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<t.length;e++)n[e>>2]|=t.charCodeAt(e)<<(e%4<<3);if(n[e>>2]|=128<<(e%4<<3),e>55)for(tf(i,n),e=0;e<16;e++)n[e]=0;return n[14]=8*r,tf(i,n),i}function hf(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}var lf="0123456789abcdef".split("");function cf(t){for(var e="",r=0;r<4;r++)e+=lf[t>>8*r+4&15]+lf[t>>8*r&15];return e}function uf(t){return String.fromCharCode(255&t,(65280&t)>>8,(16711680&t)>>16,(4278190080&t)>>24)}function ff(t){return af(t).map(uf).join("")}var df="5d41402abc4b2a76b9719d911017c592"!=function(t){for(var e=0;e<t.length;e++)t[e]=cf(t[e]);return t.join("")}(af("hello"));function pf(t,e){if(df){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}return t+e&4294967295}function gf(t,e){var r,i,n,s;if(t!==r){for(var o=(n=t,s=1+(256/t.length|0),new Array(s+1).join(n)),a=[],h=0;h<256;h++)a[h]=h;var l=0;for(h=0;h<256;h++){var c=a[h];l=(l+c+o.charCodeAt(h))%256,a[h]=a[l],a[l]=c}r=t,i=a}else a=i;var u=e.length,f=0,d=0,p="";for(h=0;h<u;h++)d=(d+(c=a[f=(f+1)%256]))%256,a[f]=a[d],a[d]=c,o=a[(a[f]+a[d])%256],p+=String.fromCharCode(e.charCodeAt(h)^o);return p}var mf={print:4,modify:8,copy:16,"annot-forms":32};function vf(t,e,r,i){this.v=1,this.r=2;var n=192;t.forEach(function(t){if(void 0!==mf.perm)throw new Error("Invalid permission: "+t);n+=mf[t]}),this.padding="(¿N^NuAd\0NVÿú\b..\0¶Ðh>/\f©þdSiz";var s=(e+this.padding).substr(0,32),o=(r+this.padding).substr(0,32);this.O=this.processOwnerPassword(s,o),this.P=-(1+(255^n)),this.encryptionKey=ff(s+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(i)).substr(0,5),this.U=gf(this.encryptionKey,this.padding)}function yf(t){if(/[^\u0000-\u00ff]/.test(t))throw new Error("Invalid PDF Name Object: "+t+", Only accept ASCII characters.");for(var e="",r=t.length,i=0;i<r;i++){var n=t.charCodeAt(i);e+=n<33||35===n||37===n||40===n||41===n||47===n||60===n||62===n||91===n||93===n||123===n||125===n||n>126?"#"+("0"+n.toString(16)).slice(-2):t[i]}return e}function bf(t){if("object"!==(0,aa.A)(t))throw new Error("Invalid Context passed to initialize PubSub (jsPDF-module)");var e={};this.subscribe=function(t,r,i){if(i=i||!1,"string"!=typeof t||"function"!=typeof r||"boolean"!=typeof i)throw new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)");e.hasOwnProperty(t)||(e[t]={});var n=Math.random().toString(35);return e[t][n]=[r,!!i],n},this.unsubscribe=function(t){for(var r in e)if(e[r][t])return delete e[r][t],0===Object.keys(e[r]).length&&delete e[r],!0;return!1},this.publish=function(r){if(e.hasOwnProperty(r)){var i=Array.prototype.slice.call(arguments,1),n=[];for(var s in e[r]){var o=e[r][s];try{o[0].apply(t,i)}catch(t){Hu.console&&Yu.error("jsPDF PubSub Error",t.message,t)}o[1]&&n.push(s)}n.length&&n.forEach(this.unsubscribe)}},this.getTopics=function(){return e}}function wf(t){if(!(this instanceof wf))return new wf(t);var e="opacity,stroke-opacity".split(",");for(var r in t)t.hasOwnProperty(r)&&e.indexOf(r)>=0&&(this[r]=t[r]);this.id="",this.objectNumber=-1}function _f(t,e){this.gState=t,this.matrix=e,this.id="",this.objectNumber=-1}function xf(t,e,r,i,n){if(!(this instanceof xf))return new xf(t,e,r,i,n);this.type="axial"===t?2:3,this.coords=e,this.colors=r,_f.call(this,i,n)}function Sf(t,e,r,i,n){if(!(this instanceof Sf))return new Sf(t,e,r,i,n);this.boundingBox=t,this.xStep=e,this.yStep=r,this.stream="",this.cloneIndex=0,_f.call(this,i,n)}function Cf(t){var e,r="string"==typeof arguments[0]?arguments[0]:"p",i=arguments[1],n=arguments[2],s=arguments[3],o=[],a=1,h=16,l="S",c=null;"object"===(0,aa.A)(t=t||{})&&(r=t.orientation,i=t.unit||i,n=t.format||n,s=t.compress||t.compressPdf||s,null!==(c=t.encryption||null)&&(c.userPassword=c.userPassword||"",c.ownerPassword=c.ownerPassword||"",c.userPermissions=c.userPermissions||[]),a="number"==typeof t.userUnit?Math.abs(t.userUnit):1,void 0!==t.precision&&(e=t.precision),void 0!==t.floatPrecision&&(h=t.floatPrecision),l=t.defaultPathOperation||"S"),o=t.filters||(!0===s?["FlateEncode"]:o),i=i||"mm",r=(""+(r||"P")).toLowerCase();var u=t.putOnlyUsedFonts||!1,f={},d={internal:{},__private__:{}};d.__private__.PubSub=bf;var p="1.3",g=d.__private__.getPdfVersion=function(){return p};d.__private__.setPdfVersion=function(t){p=t};var m={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};d.__private__.getPageFormats=function(){return m};var v=d.__private__.getPageFormat=function(t){return m[t]};n=n||"a4";var y="compat",b="advanced",w=y;function _(){this.saveGraphicsState(),J(new Ot(ft,0,0,-ft,0,pr()*ft).toString()+" cm"),this.setFontSize(this.getFontSize()/ft),l="n",w=b}function x(){this.restoreGraphicsState(),l="S",w=y}var S=d.__private__.combineFontStyleAndFontWeight=function(t,e){if("bold"==t&&"normal"==e||"bold"==t&&400==e||"normal"==t&&"italic"==e||"bold"==t&&"italic"==e)throw new Error("Invalid Combination of fontweight and fontstyle");return e&&(t=400==e||"normal"===e?"italic"===t?"italic":"normal":700!=e&&"bold"!==e||"normal"!==t?(700==e?"bold":e)+""+t:"bold"),t};d.advancedAPI=function(t){var e=w===y;return e&&_.call(this),"function"!=typeof t||(t(this),e&&x.call(this)),this},d.compatAPI=function(t){var e=w===b;return e&&x.call(this),"function"!=typeof t||(t(this),e&&_.call(this)),this},d.isAdvancedAPI=function(){return w===b};var C,A=function(t){if(w!==b)throw new Error(t+" is only available in 'advanced' API mode. You need to call advancedAPI() first.")},k=d.roundToPrecision=d.__private__.roundToPrecision=function(t,r){var i=e||r;if(isNaN(t)||isNaN(i))throw new Error("Invalid argument passed to jsPDF.roundToPrecision");return t.toFixed(i).replace(/0+$/,"")};C=d.hpf=d.__private__.hpf="number"==typeof h?function(t){if(isNaN(t))throw new Error("Invalid argument passed to jsPDF.hpf");return k(t,h)}:"smart"===h?function(t){if(isNaN(t))throw new Error("Invalid argument passed to jsPDF.hpf");return k(t,t>-1&&t<1?16:5)}:function(t){if(isNaN(t))throw new Error("Invalid argument passed to jsPDF.hpf");return k(t,16)};var L=d.f2=d.__private__.f2=function(t){if(isNaN(t))throw new Error("Invalid argument passed to jsPDF.f2");return k(t,2)},T=d.__private__.f3=function(t){if(isNaN(t))throw new Error("Invalid argument passed to jsPDF.f3");return k(t,3)},P=d.scale=d.__private__.scale=function(t){if(isNaN(t))throw new Error("Invalid argument passed to jsPDF.scale");return w===y?t*ft:w===b?t:void 0},N=function(t){return P(function(t){return w===y?pr()-t:w===b?t:void 0}(t))};d.__private__.setPrecision=d.setPrecision=function(t){"number"==typeof parseInt(t,10)&&(e=parseInt(t,10))};var O,E="00000000000000000000000000000000",M=d.__private__.getFileId=function(){return E},D=d.__private__.setFileId=function(t){return E=void 0!==t&&/^[a-fA-F0-9]{32}$/.test(t)?t.toUpperCase():E.split("").map(function(){return"ABCDEF0123456789".charAt(Math.floor(16*Math.random()))}).join(""),null!==c&&(we=new vf(c.userPermissions,c.userPassword,c.ownerPassword,E)),E};d.setFileId=function(t){return D(t),this},d.getFileId=function(){return M()};var F=d.__private__.convertDateToPDFDate=function(t){var e=t.getTimezoneOffset(),r=e<0?"+":"-",i=Math.floor(Math.abs(e/60)),n=Math.abs(e%60),s=[r,z(i),"'",z(n),"'"].join("");return["D:",t.getFullYear(),z(t.getMonth()+1),z(t.getDate()),z(t.getHours()),z(t.getMinutes()),z(t.getSeconds()),s].join("")},j=d.__private__.convertPDFDateToDate=function(t){var e=parseInt(t.substr(2,4),10),r=parseInt(t.substr(6,2),10)-1,i=parseInt(t.substr(8,2),10),n=parseInt(t.substr(10,2),10),s=parseInt(t.substr(12,2),10),o=parseInt(t.substr(14,2),10);return new Date(e,r,i,n,s,o,0)},I=d.__private__.setCreationDate=function(t){var e;if(void 0===t&&(t=new Date),t instanceof Date)e=F(t);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(t))throw new Error("Invalid argument passed to jsPDF.setCreationDate");e=t}return O=e},B=d.__private__.getCreationDate=function(t){var e=O;return"jsDate"===t&&(e=j(O)),e};d.setCreationDate=function(t){return I(t),this},d.getCreationDate=function(t){return B(t)};var R,z=d.__private__.padd2=function(t){return("0"+parseInt(t)).slice(-2)},U=d.__private__.padd2Hex=function(t){return("00"+(t=t.toString())).substr(t.length)},q=0,W=[],H=[],V=0,Y=[],X=[],G=!1,$=H;d.__private__.setCustomOutputDestination=function(t){G=!0,$=t};var K=function(t){G||($=t)};d.__private__.resetCustomOutputDestination=function(){G=!1,$=H};var J=d.__private__.out=function(t){return t=t.toString(),V+=t.length+1,$.push(t),$},Z=d.__private__.write=function(t){return J(1===arguments.length?t.toString():Array.prototype.join.call(arguments," "))},Q=d.__private__.getArrayBuffer=function(t){for(var e=t.length,r=new ArrayBuffer(e),i=new Uint8Array(r);e--;)i[e]=t.charCodeAt(e);return r},tt=[["Helvetica","helvetica","normal","WinAnsiEncoding"],["Helvetica-Bold","helvetica","bold","WinAnsiEncoding"],["Helvetica-Oblique","helvetica","italic","WinAnsiEncoding"],["Helvetica-BoldOblique","helvetica","bolditalic","WinAnsiEncoding"],["Courier","courier","normal","WinAnsiEncoding"],["Courier-Bold","courier","bold","WinAnsiEncoding"],["Courier-Oblique","courier","italic","WinAnsiEncoding"],["Courier-BoldOblique","courier","bolditalic","WinAnsiEncoding"],["Times-Roman","times","normal","WinAnsiEncoding"],["Times-Bold","times","bold","WinAnsiEncoding"],["Times-Italic","times","italic","WinAnsiEncoding"],["Times-BoldItalic","times","bolditalic","WinAnsiEncoding"],["ZapfDingbats","zapfdingbats","normal",null],["Symbol","symbol","normal",null]];d.__private__.getStandardFonts=function(){return tt};var et=t.fontSize||16;d.__private__.setFontSize=d.setFontSize=function(t){return et=w===b?t/ft:t,this};var rt,it=d.__private__.getFontSize=d.getFontSize=function(){return w===y?et:et*ft},nt=t.R2L||!1;d.__private__.setR2L=d.setR2L=function(t){return nt=t,this},d.__private__.getR2L=d.getR2L=function(){return nt};var st,ot=d.__private__.setZoomMode=function(t){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(t))rt=t;else if(isNaN(t)){if(-1===[void 0,null,"fullwidth","fullheight","fullpage","original"].indexOf(t))throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "'+t+'" is not recognized.');rt=t}else rt=parseInt(t,10)};d.__private__.getZoomMode=function(){return rt};var at,ht=d.__private__.setPageMode=function(t){if(-1==[void 0,null,"UseNone","UseOutlines","UseThumbs","FullScreen"].indexOf(t))throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "'+t+'" is not recognized.');st=t};d.__private__.getPageMode=function(){return st};var lt=d.__private__.setLayoutMode=function(t){if(-1==[void 0,null,"continuous","single","twoleft","tworight","two"].indexOf(t))throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. "'+t+'" is not recognized.');at=t};d.__private__.getLayoutMode=function(){return at},d.__private__.setDisplayMode=d.setDisplayMode=function(t,e,r){return ot(t),lt(e),ht(r),this};var ct={title:"",subject:"",author:"",keywords:"",creator:""};d.__private__.getDocumentProperty=function(t){if(-1===Object.keys(ct).indexOf(t))throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");return ct[t]},d.__private__.getDocumentProperties=function(){return ct},d.__private__.setDocumentProperties=d.setProperties=d.setDocumentProperties=function(t){for(var e in ct)ct.hasOwnProperty(e)&&t[e]&&(ct[e]=t[e]);return this},d.__private__.setDocumentProperty=function(t,e){if(-1===Object.keys(ct).indexOf(t))throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");return ct[t]=e};var ut,ft,dt,pt,gt,mt={},vt={},yt=[],bt={},wt={},_t={},xt={},St=null,Ct=0,At=[],kt=new bf(d),Lt=t.hotfixes||[],Tt={},Pt={},Nt=[],Ot=function t(e,r,i,n,s,o){if(!(this instanceof t))return new t(e,r,i,n,s,o);isNaN(e)&&(e=1),isNaN(r)&&(r=0),isNaN(i)&&(i=0),isNaN(n)&&(n=1),isNaN(s)&&(s=0),isNaN(o)&&(o=0),this._matrix=[e,r,i,n,s,o]};Object.defineProperty(Ot.prototype,"sx",{get:function(){return this._matrix[0]},set:function(t){this._matrix[0]=t}}),Object.defineProperty(Ot.prototype,"shy",{get:function(){return this._matrix[1]},set:function(t){this._matrix[1]=t}}),Object.defineProperty(Ot.prototype,"shx",{get:function(){return this._matrix[2]},set:function(t){this._matrix[2]=t}}),Object.defineProperty(Ot.prototype,"sy",{get:function(){return this._matrix[3]},set:function(t){this._matrix[3]=t}}),Object.defineProperty(Ot.prototype,"tx",{get:function(){return this._matrix[4]},set:function(t){this._matrix[4]=t}}),Object.defineProperty(Ot.prototype,"ty",{get:function(){return this._matrix[5]},set:function(t){this._matrix[5]=t}}),Object.defineProperty(Ot.prototype,"a",{get:function(){return this._matrix[0]},set:function(t){this._matrix[0]=t}}),Object.defineProperty(Ot.prototype,"b",{get:function(){return this._matrix[1]},set:function(t){this._matrix[1]=t}}),Object.defineProperty(Ot.prototype,"c",{get:function(){return this._matrix[2]},set:function(t){this._matrix[2]=t}}),Object.defineProperty(Ot.prototype,"d",{get:function(){return this._matrix[3]},set:function(t){this._matrix[3]=t}}),Object.defineProperty(Ot.prototype,"e",{get:function(){return this._matrix[4]},set:function(t){this._matrix[4]=t}}),Object.defineProperty(Ot.prototype,"f",{get:function(){return this._matrix[5]},set:function(t){this._matrix[5]=t}}),Object.defineProperty(Ot.prototype,"rotation",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(Ot.prototype,"scaleX",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(Ot.prototype,"scaleY",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(Ot.prototype,"isIdentity",{get:function(){return 1===this.sx&&0===this.shy&&0===this.shx&&1===this.sy&&0===this.tx&&0===this.ty}}),Ot.prototype.join=function(t){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(C).join(t)},Ot.prototype.multiply=function(t){var e=t.sx*this.sx+t.shy*this.shx,r=t.sx*this.shy+t.shy*this.sy,i=t.shx*this.sx+t.sy*this.shx,n=t.shx*this.shy+t.sy*this.sy,s=t.tx*this.sx+t.ty*this.shx+this.tx,o=t.tx*this.shy+t.ty*this.sy+this.ty;return new Ot(e,r,i,n,s,o)},Ot.prototype.decompose=function(){var t=this.sx,e=this.shy,r=this.shx,i=this.sy,n=this.tx,s=this.ty,o=Math.sqrt(t*t+e*e),a=(t/=o)*r+(e/=o)*i;r-=t*a,i-=e*a;var h=Math.sqrt(r*r+i*i);return a/=h,t*(i/=h)<e*(r/=h)&&(t=-t,e=-e,a=-a,o=-o),{scale:new Ot(o,0,0,h,0,0),translate:new Ot(1,0,0,1,n,s),rotate:new Ot(t,e,-e,t,0,0),skew:new Ot(1,0,a,1,0,0)}},Ot.prototype.toString=function(t){return this.join(" ")},Ot.prototype.inversed=function(){var t=this.sx,e=this.shy,r=this.shx,i=this.sy,n=this.tx,s=this.ty,o=1/(t*i-e*r),a=i*o,h=-e*o,l=-r*o,c=t*o;return new Ot(a,h,l,c,-a*n-l*s,-h*n-c*s)},Ot.prototype.applyToPoint=function(t){var e=t.x*this.sx+t.y*this.shx+this.tx,r=t.x*this.shy+t.y*this.sy+this.ty;return new ir(e,r)},Ot.prototype.applyToRectangle=function(t){var e=this.applyToPoint(t),r=this.applyToPoint(new ir(t.x+t.w,t.y+t.h));return new nr(e.x,e.y,r.x-e.x,r.y-e.y)},Ot.prototype.clone=function(){var t=this.sx,e=this.shy,r=this.shx,i=this.sy,n=this.tx,s=this.ty;return new Ot(t,e,r,i,n,s)},d.Matrix=Ot;var Et=d.matrixMult=function(t,e){return e.multiply(t)},Mt=new Ot(1,0,0,1,0,0);d.unitMatrix=d.identityMatrix=Mt;var Dt=function(t,e){if(!wt[t]){var r=(e instanceof xf?"Sh":"P")+(Object.keys(bt).length+1).toString(10);e.id=r,wt[t]=r,bt[r]=e,kt.publish("addPattern",e)}};d.ShadingPattern=xf,d.TilingPattern=Sf,d.addShadingPattern=function(t,e){return A("addShadingPattern()"),Dt(t,e),this},d.beginTilingPattern=function(t){A("beginTilingPattern()"),or(t.boundingBox[0],t.boundingBox[1],t.boundingBox[2]-t.boundingBox[0],t.boundingBox[3]-t.boundingBox[1],t.matrix)},d.endTilingPattern=function(t,e){A("endTilingPattern()"),e.stream=X[R].join("\n"),Dt(t,e),kt.publish("endTilingPattern",e),Nt.pop().restore()};var Ft,jt=d.__private__.newObject=function(){var t=It();return Bt(t,!0),t},It=d.__private__.newObjectDeferred=function(){return q++,W[q]=function(){return V},q},Bt=function(t,e){return e="boolean"==typeof e&&e,W[t]=V,e&&J(t+" 0 obj"),t},Rt=d.__private__.newAdditionalObject=function(){var t={objId:It(),content:""};return Y.push(t),t},zt=It(),Ut=It(),qt=d.__private__.decodeColorString=function(t){var e=t.split(" ");if(2!==e.length||"g"!==e[1]&&"G"!==e[1])5!==e.length||"k"!==e[4]&&"K"!==e[4]||(e=[(1-e[0])*(1-e[3]),(1-e[1])*(1-e[3]),(1-e[2])*(1-e[3]),"r"]);else{var r=parseFloat(e[0]);e=[r,r,r,"r"]}for(var i="#",n=0;n<3;n++)i+=("0"+Math.floor(255*parseFloat(e[n])).toString(16)).slice(-2);return i},Wt=d.__private__.encodeColorString=function(t){var e;"string"==typeof t&&(t={ch1:t});var r=t.ch1,i=t.ch2,n=t.ch3,s=t.ch4,o="draw"===t.pdfColorType?["G","RG","K"]:["g","rg","k"];if("string"==typeof r&&"#"!==r.charAt(0)){var a=new Ju(r);if(a.ok)r=a.toHex();else if(!/^\d*\.?\d*$/.test(r))throw new Error('Invalid color "'+r+'" passed to jsPDF.encodeColorString.')}if("string"==typeof r&&/^#[0-9A-Fa-f]{3}$/.test(r)&&(r="#"+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]),"string"==typeof r&&/^#[0-9A-Fa-f]{6}$/.test(r)){var h=parseInt(r.substr(1),16);r=h>>16&255,i=h>>8&255,n=255&h}if(void 0===i||void 0===s&&r===i&&i===n)e="string"==typeof r?r+" "+o[0]:2===t.precision?L(r/255)+" "+o[0]:T(r/255)+" "+o[0];else if(void 0===s||"object"===(0,aa.A)(s)){if(s&&!isNaN(s.a)&&0===s.a)return["1.","1.","1.",o[1]].join(" ");e="string"==typeof r?[r,i,n,o[1]].join(" "):2===t.precision?[L(r/255),L(i/255),L(n/255),o[1]].join(" "):[T(r/255),T(i/255),T(n/255),o[1]].join(" ")}else e="string"==typeof r?[r,i,n,s,o[2]].join(" "):2===t.precision?[L(r),L(i),L(n),L(s),o[2]].join(" "):[T(r),T(i),T(n),T(s),o[2]].join(" ");return e},Ht=d.__private__.getFilters=function(){return o},Vt=d.__private__.putStream=function(t){var e=(t=t||{}).data||"",r=t.filters||Ht(),i=t.alreadyAppliedFilters||[],n=t.addLength1||!1,s=e.length,o=t.objectId,a=function(t){return t};if(null!==c&&void 0===o)throw new Error("ObjectId must be passed to putStream for file encryption");null!==c&&(a=we.encryptor(o,0));var h={};!0===r&&(r=["FlateEncode"]);var l=t.additionalKeyValues||[],u=(h=void 0!==Cf.API.processDataByFilters?Cf.API.processDataByFilters(e,r):{data:e,reverseChain:[]}).reverseChain+(Array.isArray(i)?i.join(" "):i.toString());if(0!==h.data.length&&(l.push({key:"Length",value:h.data.length}),!0===n&&l.push({key:"Length1",value:s})),0!=u.length)if(u.split("/").length-1==1)l.push({key:"Filter",value:u});else{l.push({key:"Filter",value:"["+u+"]"});for(var f=0;f<l.length;f+=1)if("DecodeParms"===l[f].key){for(var d=[],p=0;p<h.reverseChain.split("/").length-1;p+=1)d.push("null");d.push(l[f].value),l[f].value="["+d.join(" ")+"]"}}J("<<");for(var g=0;g<l.length;g++)J("/"+l[g].key+" "+l[g].value);J(">>"),0!==h.data.length&&(J("stream"),J(a(h.data)),J("endstream"))},Yt=d.__private__.putPage=function(t){var e=t.number,r=t.data,i=t.objId,n=t.contentsObjId;Bt(i,!0),J("<</Type /Page"),J("/Parent "+t.rootDictionaryObjId+" 0 R"),J("/Resources "+t.resourceDictionaryObjId+" 0 R"),J("/MediaBox ["+parseFloat(C(t.mediaBox.bottomLeftX))+" "+parseFloat(C(t.mediaBox.bottomLeftY))+" "+C(t.mediaBox.topRightX)+" "+C(t.mediaBox.topRightY)+"]"),null!==t.cropBox&&J("/CropBox ["+C(t.cropBox.bottomLeftX)+" "+C(t.cropBox.bottomLeftY)+" "+C(t.cropBox.topRightX)+" "+C(t.cropBox.topRightY)+"]"),null!==t.bleedBox&&J("/BleedBox ["+C(t.bleedBox.bottomLeftX)+" "+C(t.bleedBox.bottomLeftY)+" "+C(t.bleedBox.topRightX)+" "+C(t.bleedBox.topRightY)+"]"),null!==t.trimBox&&J("/TrimBox ["+C(t.trimBox.bottomLeftX)+" "+C(t.trimBox.bottomLeftY)+" "+C(t.trimBox.topRightX)+" "+C(t.trimBox.topRightY)+"]"),null!==t.artBox&&J("/ArtBox ["+C(t.artBox.bottomLeftX)+" "+C(t.artBox.bottomLeftY)+" "+C(t.artBox.topRightX)+" "+C(t.artBox.topRightY)+"]"),"number"==typeof t.userUnit&&1!==t.userUnit&&J("/UserUnit "+t.userUnit),kt.publish("putPage",{objId:i,pageContext:At[e],pageNumber:e,page:r}),J("/Contents "+n+" 0 R"),J(">>"),J("endobj");var s=r.join("\n");return w===b&&(s+="\nQ"),Bt(n,!0),Vt({data:s,filters:Ht(),objectId:n}),J("endobj"),i},Xt=d.__private__.putPages=function(){var t,e,r=[];for(t=1;t<=Ct;t++)At[t].objId=It(),At[t].contentsObjId=It();for(t=1;t<=Ct;t++)r.push(Yt({number:t,data:X[t],objId:At[t].objId,contentsObjId:At[t].contentsObjId,mediaBox:At[t].mediaBox,cropBox:At[t].cropBox,bleedBox:At[t].bleedBox,trimBox:At[t].trimBox,artBox:At[t].artBox,userUnit:At[t].userUnit,rootDictionaryObjId:zt,resourceDictionaryObjId:Ut}));Bt(zt,!0),J("<</Type /Pages");var i="/Kids [";for(e=0;e<Ct;e++)i+=r[e]+" 0 R ";J(i+"]"),J("/Count "+Ct),J(">>"),J("endobj"),kt.publish("postPutPages")},Gt=function(t){kt.publish("putFont",{font:t,out:J,newObject:jt,putStream:Vt}),!0!==t.isAlreadyPutted&&(t.objectNumber=jt(),J("<<"),J("/Type /Font"),J("/BaseFont /"+yf(t.postScriptName)),J("/Subtype /Type1"),"string"==typeof t.encoding&&J("/Encoding /"+t.encoding),J("/FirstChar 32"),J("/LastChar 255"),J(">>"),J("endobj"))},$t=function(t){t.objectNumber=jt();var e=[];e.push({key:"Type",value:"/XObject"}),e.push({key:"Subtype",value:"/Form"}),e.push({key:"BBox",value:"["+[C(t.x),C(t.y),C(t.x+t.width),C(t.y+t.height)].join(" ")+"]"}),e.push({key:"Matrix",value:"["+t.matrix.toString()+"]"});var r=t.pages[1].join("\n");Vt({data:r,additionalKeyValues:e,objectId:t.objectNumber}),J("endobj")},Kt=function(t,e){e||(e=21);var r=jt(),i=function(t,e){var r,i=[],n=1/(e-1);for(r=0;r<1;r+=n)i.push(r);if(i.push(1),0!=t[0].offset){var s={offset:0,color:t[0].color};t.unshift(s)}if(1!=t[t.length-1].offset){var o={offset:1,color:t[t.length-1].color};t.push(o)}for(var a="",h=0,l=0;l<i.length;l++){for(r=i[l];r>t[h+1].offset;)h++;var c=t[h].offset,u=(r-c)/(t[h+1].offset-c),f=t[h].color,d=t[h+1].color;a+=U(Math.round((1-u)*f[0]+u*d[0]).toString(16))+U(Math.round((1-u)*f[1]+u*d[1]).toString(16))+U(Math.round((1-u)*f[2]+u*d[2]).toString(16))}return a.trim()}(t.colors,e),n=[];n.push({key:"FunctionType",value:"0"}),n.push({key:"Domain",value:"[0.0 1.0]"}),n.push({key:"Size",value:"["+e+"]"}),n.push({key:"BitsPerSample",value:"8"}),n.push({key:"Range",value:"[0.0 1.0 0.0 1.0 0.0 1.0]"}),n.push({key:"Decode",value:"[0.0 1.0 0.0 1.0 0.0 1.0]"}),Vt({data:i,additionalKeyValues:n,alreadyAppliedFilters:["/ASCIIHexDecode"],objectId:r}),J("endobj"),t.objectNumber=jt(),J("<< /ShadingType "+t.type),J("/ColorSpace /DeviceRGB");var s="/Coords ["+C(parseFloat(t.coords[0]))+" "+C(parseFloat(t.coords[1]))+" ";2===t.type?s+=C(parseFloat(t.coords[2]))+" "+C(parseFloat(t.coords[3])):s+=C(parseFloat(t.coords[2]))+" "+C(parseFloat(t.coords[3]))+" "+C(parseFloat(t.coords[4]))+" "+C(parseFloat(t.coords[5])),J(s+="]"),t.matrix&&J("/Matrix ["+t.matrix.toString()+"]"),J("/Function "+r+" 0 R"),J("/Extend [true true]"),J(">>"),J("endobj")},Jt=function(t,e){var r=It(),i=jt();e.push({resourcesOid:r,objectOid:i}),t.objectNumber=i;var n=[];n.push({key:"Type",value:"/Pattern"}),n.push({key:"PatternType",value:"1"}),n.push({key:"PaintType",value:"1"}),n.push({key:"TilingType",value:"1"}),n.push({key:"BBox",value:"["+t.boundingBox.map(C).join(" ")+"]"}),n.push({key:"XStep",value:C(t.xStep)}),n.push({key:"YStep",value:C(t.yStep)}),n.push({key:"Resources",value:r+" 0 R"}),t.matrix&&n.push({key:"Matrix",value:"["+t.matrix.toString()+"]"}),Vt({data:t.stream,additionalKeyValues:n,objectId:t.objectNumber}),J("endobj")},Zt=function(t){for(var e in t.objectNumber=jt(),J("<<"),t)switch(e){case"opacity":J("/ca "+L(t[e]));break;case"stroke-opacity":J("/CA "+L(t[e]))}J(">>"),J("endobj")},Qt=function(t){Bt(t.resourcesOid,!0),J("<<"),J("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),function(){for(var t in J("/Font <<"),mt)mt.hasOwnProperty(t)&&(!1===u||!0===u&&f.hasOwnProperty(t))&&J("/"+t+" "+mt[t].objectNumber+" 0 R");J(">>")}(),function(){if(Object.keys(bt).length>0){for(var t in J("/Shading <<"),bt)bt.hasOwnProperty(t)&&bt[t]instanceof xf&&bt[t].objectNumber>=0&&J("/"+t+" "+bt[t].objectNumber+" 0 R");kt.publish("putShadingPatternDict"),J(">>")}}(),function(t){if(Object.keys(bt).length>0){for(var e in J("/Pattern <<"),bt)bt.hasOwnProperty(e)&&bt[e]instanceof d.TilingPattern&&bt[e].objectNumber>=0&&bt[e].objectNumber<t&&J("/"+e+" "+bt[e].objectNumber+" 0 R");kt.publish("putTilingPatternDict"),J(">>")}}(t.objectOid),function(){if(Object.keys(_t).length>0){var t;for(t in J("/ExtGState <<"),_t)_t.hasOwnProperty(t)&&_t[t].objectNumber>=0&&J("/"+t+" "+_t[t].objectNumber+" 0 R");kt.publish("putGStateDict"),J(">>")}}(),function(){for(var t in J("/XObject <<"),Tt)Tt.hasOwnProperty(t)&&Tt[t].objectNumber>=0&&J("/"+t+" "+Tt[t].objectNumber+" 0 R");kt.publish("putXobjectDict"),J(">>")}(),J(">>"),J("endobj")},te=function(t){vt[t.fontName]=vt[t.fontName]||{},vt[t.fontName][t.fontStyle]=t.id},ee=function(t,e,r,i,n){var s={id:"F"+(Object.keys(mt).length+1).toString(10),postScriptName:t,fontName:e,fontStyle:r,encoding:i,isStandardFont:n||!1,metadata:{}};return kt.publish("addFont",{font:s,instance:this}),mt[s.id]=s,te(s),s.id},re=d.__private__.pdfEscape=d.pdfEscape=function(t,e){return function(t,e){var r,i,n,s,o,a,h,l,c;if(n=(e=e||{}).sourceEncoding||"Unicode",o=e.outputEncoding,(e.autoencode||o)&&mt[ut].metadata&&mt[ut].metadata[n]&&mt[ut].metadata[n].encoding&&(s=mt[ut].metadata[n].encoding,!o&&mt[ut].encoding&&(o=mt[ut].encoding),!o&&s.codePages&&(o=s.codePages[0]),"string"==typeof o&&(o=s[o]),o)){for(h=!1,a=[],r=0,i=t.length;r<i;r++)(l=o[t.charCodeAt(r)])?a.push(String.fromCharCode(l)):a.push(t[r]),a[r].charCodeAt(0)>>8&&(h=!0);t=a.join("")}for(r=t.length;void 0===h&&0!==r;)t.charCodeAt(r-1)>>8&&(h=!0),r--;if(!h)return t;for(a=e.noBOM?[]:[254,255],r=0,i=t.length;r<i;r++){if((c=(l=t.charCodeAt(r))>>8)>>8)throw new Error("Character at position "+r+" of string '"+t+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");a.push(c),a.push(l-(c<<8))}return String.fromCharCode.apply(void 0,a)}(t,e).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},ie=d.__private__.beginPage=function(t){X[++Ct]=[],At[Ct]={objId:0,contentsObjId:0,userUnit:Number(a),artBox:null,bleedBox:null,cropBox:null,trimBox:null,mediaBox:{bottomLeftX:0,bottomLeftY:0,topRightX:Number(t[0]),topRightY:Number(t[1])}},oe(Ct),K(X[R])},ne=function(t,e){var i,s,o;switch(r=e||r,"string"==typeof t&&(i=v(t.toLowerCase()),Array.isArray(i)&&(s=i[0],o=i[1])),Array.isArray(t)&&(s=t[0]*ft,o=t[1]*ft),isNaN(s)&&(s=n[0],o=n[1]),(s>14400||o>14400)&&(Yu.warn("A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400"),s=Math.min(14400,s),o=Math.min(14400,o)),n=[s,o],r.substr(0,1)){case"l":o>s&&(n=[o,s]);break;case"p":s>o&&(n=[o,s])}ie(n),ze(Be),J(Ge),0!==tr&&J(tr+" J"),0!==er&&J(er+" j"),kt.publish("addPage",{pageNumber:Ct})},se=function(t){t>0&&t<=Ct&&(X.splice(t,1),At.splice(t,1),Ct--,R>Ct&&(R=Ct),this.setPage(R))},oe=function(t){t>0&&t<=Ct&&(R=t)},ae=d.__private__.getNumberOfPages=d.getNumberOfPages=function(){return X.length-1},he=function(t,e,r){var i,n=void 0;return r=r||{},t=void 0!==t?t:mt[ut].fontName,e=void 0!==e?e:mt[ut].fontStyle,i=t.toLowerCase(),void 0!==vt[i]&&void 0!==vt[i][e]?n=vt[i][e]:void 0!==vt[t]&&void 0!==vt[t][e]?n=vt[t][e]:!1===r.disableWarning&&Yu.warn("Unable to look up font label for font '"+t+"', '"+e+"'. Refer to getFontList() for available fonts."),n||r.noFallback||null==(n=vt.times[e])&&(n=vt.times.normal),n},le=d.__private__.putInfo=function(){var t=jt(),e=function(t){return t};for(var r in null!==c&&(e=we.encryptor(t,0)),J("<<"),J("/Producer ("+re(e("jsPDF "+Cf.version))+")"),ct)ct.hasOwnProperty(r)&&ct[r]&&J("/"+r.substr(0,1).toUpperCase()+r.substr(1)+" ("+re(e(ct[r]))+")");J("/CreationDate ("+re(e(O))+")"),J(">>"),J("endobj")},ce=d.__private__.putCatalog=function(t){var e=(t=t||{}).rootDictionaryObjId||zt;switch(jt(),J("<<"),J("/Type /Catalog"),J("/Pages "+e+" 0 R"),rt||(rt="fullwidth"),rt){case"fullwidth":J("/OpenAction [3 0 R /FitH null]");break;case"fullheight":J("/OpenAction [3 0 R /FitV null]");break;case"fullpage":J("/OpenAction [3 0 R /Fit]");break;case"original":J("/OpenAction [3 0 R /XYZ null null 1]");break;default:var r=""+rt;"%"===r.substr(r.length-1)&&(rt=parseInt(rt)/100),"number"==typeof rt&&J("/OpenAction [3 0 R /XYZ null null "+L(rt)+"]")}switch(at||(at="continuous"),at){case"continuous":J("/PageLayout /OneColumn");break;case"single":J("/PageLayout /SinglePage");break;case"two":case"twoleft":J("/PageLayout /TwoColumnLeft");break;case"tworight":J("/PageLayout /TwoColumnRight")}st&&J("/PageMode /"+st),kt.publish("putCatalog"),J(">>"),J("endobj")},ue=d.__private__.putTrailer=function(){J("trailer"),J("<<"),J("/Size "+(q+1)),J("/Root "+q+" 0 R"),J("/Info "+(q-1)+" 0 R"),null!==c&&J("/Encrypt "+we.oid+" 0 R"),J("/ID [ <"+E+"> <"+E+"> ]"),J(">>")},fe=d.__private__.putHeader=function(){J("%PDF-"+p),J("%ºß¬à")},de=d.__private__.putXRef=function(){var t="0000000000";J("xref"),J("0 "+(q+1)),J("0000000000 65535 f ");for(var e=1;e<=q;e++)"function"==typeof W[e]?J((t+W[e]()).slice(-10)+" 00000 n "):void 0!==W[e]?J((t+W[e]).slice(-10)+" 00000 n "):J("0000000000 00000 n ")},pe=d.__private__.buildDocument=function(){var t;q=0,V=0,H=[],W=[],Y=[],zt=It(),Ut=It(),K(H),kt.publish("buildDocument"),fe(),Xt(),function(){kt.publish("putAdditionalObjects");for(var t=0;t<Y.length;t++){var e=Y[t];Bt(e.objId,!0),J(e.content),J("endobj")}kt.publish("postPutAdditionalObjects")}(),t=[],function(){for(var t in mt)mt.hasOwnProperty(t)&&(!1===u||!0===u&&f.hasOwnProperty(t))&&Gt(mt[t])}(),function(){var t;for(t in _t)_t.hasOwnProperty(t)&&Zt(_t[t])}(),function(){for(var t in Tt)Tt.hasOwnProperty(t)&&$t(Tt[t])}(),function(t){var e;for(e in bt)bt.hasOwnProperty(e)&&(bt[e]instanceof xf?Kt(bt[e]):bt[e]instanceof Sf&&Jt(bt[e],t))}(t),kt.publish("putResources"),t.forEach(Qt),Qt({resourcesOid:Ut,objectOid:Number.MAX_SAFE_INTEGER}),kt.publish("postPutResources"),null!==c&&(we.oid=jt(),J("<<"),J("/Filter /Standard"),J("/V "+we.v),J("/R "+we.r),J("/U <"+we.toHexString(we.U)+">"),J("/O <"+we.toHexString(we.O)+">"),J("/P "+we.P),J(">>"),J("endobj")),le(),ce();var e=V;return de(),ue(),J("startxref"),J(""+e),J("%%EOF"),K(X[R]),H.join("\n")},ge=d.__private__.getBlob=function(t){return new Blob([Q(t)],{type:"application/pdf"})},me=function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},ve=function(t){var e,r=t.document,i=r.documentElement,n=r.head,s=r.body;return n||(n=r.createElement("head"),i.appendChild(n)),s||(s=r.createElement("body"),i.appendChild(s)),me(n),me(s),(e=r.createElement("style")).appendChild(r.createTextNode("html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}")),n.appendChild(e),{document:r,body:s}},ye=d.output=d.__private__.output=(Ft=function(t,e){switch("string"==typeof(e=e||{})?e={filename:e}:e.filename=e.filename||"generated.pdf",t){case void 0:return pe();case"save":d.save(e.filename);break;case"arraybuffer":return Q(pe());case"blob":return ge(pe());case"bloburi":case"bloburl":if(void 0!==Hu.URL&&"function"==typeof Hu.URL.createObjectURL)return Hu.URL&&Hu.URL.createObjectURL(ge(pe()))||void 0;Yu.warn("bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.");break;case"datauristring":case"dataurlstring":var r="",i=pe();try{r=Qu(i)}catch(t){r=Qu(unescape(encodeURIComponent(i)))}return"data:application/pdf;filename="+encodeURIComponent(e.filename)+";base64,"+r;case"pdfobjectnewwindow":if("[object Window]"===Object.prototype.toString.call(Hu)){var n="https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js",s=!e.pdfObjectUrl;s||(n=e.pdfObjectUrl);var o=Hu.open();if(null!==o){var a=ve(o),h=a.document.createElement("script"),l=this;h.src=n,s&&(h.integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==",h.crossOrigin="anonymous"),h.onload=function(){o.PDFObject.embed(l.output("dataurlstring"),e)},a.body.appendChild(h)}return o}throw new Error("The option pdfobjectnewwindow just works in a browser-environment.");case"pdfjsnewwindow":if("[object Window]"===Object.prototype.toString.call(Hu)){var c=e.pdfJsUrl||"examples/PDF.js/web/viewer.html",u=Hu.open();if(null!==u){var f=ve(u),p=f.document.createElement("iframe"),g=-1===c.indexOf("?")?"?":"&";l=this,p.id="pdfViewer",p.width="500px",p.height="400px",p.src=c+g+"file=&downloadName="+encodeURIComponent(e.filename),p.onload=function(){u.document.title=e.filename,p.contentWindow.PDFViewerApplication.open(l.output("bloburl"))},f.body.appendChild(p)}return u}throw new Error("The option pdfjsnewwindow just works in a browser-environment.");case"dataurlnewwindow":if("[object Window]"!==Object.prototype.toString.call(Hu))throw new Error("The option dataurlnewwindow just works in a browser-environment.");var m=Hu.open();if(null!==m){var v=ve(m),y=v.document.createElement("iframe");y.src=this.output("datauristring",e),v.body.appendChild(y),m.document.title=e.filename}if(m||"undefined"==typeof safari)return m;break;case"datauri":case"dataurl":return Hu.document.location.href=this.output("datauristring",e);default:return null}},Ft.foo=function(){try{return Ft.apply(this,arguments)}catch(r){var t=r.stack||"";~t.indexOf(" at ")&&(t=t.split(" at ")[1]);var e="Error in function "+t.split("\n")[0].split("<")[0]+": "+r.message;if(!Hu.console)throw new Error(e);Hu.console.error(e,r),Hu.alert&&alert(e)}},Ft.foo.bar=Ft,Ft.foo),be=function(t){return!0===Array.isArray(Lt)&&Lt.indexOf(t)>-1};switch(i){case"pt":ft=1;break;case"mm":ft=72/25.4;break;case"cm":ft=72/2.54;break;case"in":ft=72;break;case"px":ft=1==be("px_scaling")?.75:96/72;break;case"pc":case"em":ft=12;break;case"ex":ft=6;break;default:if("number"!=typeof i)throw new Error("Invalid unit: "+i);ft=i}var we=null;I(),D();var _e=d.__private__.getPageInfo=d.getPageInfo=function(t){if(isNaN(t)||t%1!=0)throw new Error("Invalid argument passed to jsPDF.getPageInfo");return{objId:At[t].objId,pageNumber:t,pageContext:At[t]}},xe=d.__private__.getPageInfoByObjId=function(t){if(isNaN(t)||t%1!=0)throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId");for(var e in At)if(At[e].objId===t)break;return _e(e)},Se=d.__private__.getCurrentPageInfo=d.getCurrentPageInfo=function(){return{objId:At[R].objId,pageNumber:R,pageContext:At[R]}};d.addPage=function(){return ne.apply(this,arguments),this},d.setPage=function(){return oe.apply(this,arguments),K.call(this,X[R]),this},d.insertPage=function(t){return this.addPage(),this.movePage(R,t),this},d.movePage=function(t,e){var r,i;if(t>e){r=X[t],i=At[t];for(var n=t;n>e;n--)X[n]=X[n-1],At[n]=At[n-1];X[e]=r,At[e]=i,this.setPage(e)}else if(t<e){r=X[t],i=At[t];for(var s=t;s<e;s++)X[s]=X[s+1],At[s]=At[s+1];X[e]=r,At[e]=i,this.setPage(e)}return this},d.deletePage=function(){return se.apply(this,arguments),this},d.__private__.text=d.text=function(t,e,r,i,n){var s,o,a,h,l,c,u,d,p,g=(i=i||{}).scope||this;if("number"==typeof t&&"number"==typeof e&&("string"==typeof r||Array.isArray(r))){var m=r;r=e,e=t,t=m}if(arguments[3]instanceof Ot==0?(a=arguments[4],h=arguments[5],"object"===(0,aa.A)(u=arguments[3])&&null!==u||("string"==typeof a&&(h=a,a=null),"string"==typeof u&&(h=u,u=null),"number"==typeof u&&(a=u,u=null),i={flags:u,angle:a,align:h})):(A("The transform parameter of text() with a Matrix value"),p=n),isNaN(e)||isNaN(r)||null==t)throw new Error("Invalid arguments passed to jsPDF.text");if(0===t.length)return g;var v,y="",_="number"==typeof i.lineHeightFactor?i.lineHeightFactor:Ie,x=g.internal.scaleFactor;function S(t){return t=t.split("\t").join(Array(i.TabLen||9).join(" ")),re(t,u)}function k(t){for(var e,r=t.concat(),i=[],n=r.length;n--;)"string"==typeof(e=r.shift())?i.push(e):Array.isArray(t)&&(1===e.length||void 0===e[1]&&void 0===e[2])?i.push(e[0]):i.push([e[0],e[1],e[2]]);return i}function L(t,e){var r;if("string"==typeof t)r=e(t)[0];else if(Array.isArray(t)){for(var i,n,s=t.concat(),o=[],a=s.length;a--;)"string"==typeof(i=s.shift())?o.push(e(i)[0]):Array.isArray(i)&&"string"==typeof i[0]&&(n=e(i[0],i[1],i[2]),o.push([n[0],n[1],n[2]]));r=o}return r}var T=!1,N=!0;if("string"==typeof t)T=!0;else if(Array.isArray(t)){var O=t.concat();o=[];for(var E,M=O.length;M--;)("string"!=typeof(E=O.shift())||Array.isArray(E)&&"string"!=typeof E[0])&&(N=!1);T=N}if(!1===T)throw new Error('Type of text must be string or Array. "'+t+'" is not recognized.');"string"==typeof t&&(t=t.match(/[\r?\n]/)?t.split(/\r\n|\r|\n/g):[t]);var D=et/g.internal.scaleFactor,F=D*(_-1);switch(i.baseline){case"bottom":r-=F;break;case"top":r+=D-F;break;case"hanging":r+=D-2*F;break;case"middle":r+=D/2-F}if((c=i.maxWidth||0)>0&&("string"==typeof t?t=g.splitTextToSize(t,c):"[object Array]"===Object.prototype.toString.call(t)&&(t=t.reduce(function(t,e){return t.concat(g.splitTextToSize(e,c))},[]))),s={text:t,x:e,y:r,options:i,mutex:{pdfEscape:re,activeFontKey:ut,fonts:mt,activeFontSize:et}},kt.publish("preProcessText",s),t=s.text,a=(i=s.options).angle,p instanceof Ot==0&&a&&"number"==typeof a){a*=Math.PI/180,0===i.rotationDirection&&(a=-a),w===b&&(a=-a);var j=Math.cos(a),I=Math.sin(a);p=new Ot(j,I,-I,j,0,0)}else a&&a instanceof Ot&&(p=a);w!==b||p||(p=Mt),void 0!==(l=i.charSpace||Ze)&&(y+=C(P(l))+" Tc\n",this.setCharSpace(this.getCharSpace()||0)),void 0!==(d=i.horizontalScale)&&(y+=C(100*d)+" Tz\n"),i.lang;var B=-1,R=void 0!==i.renderingMode?i.renderingMode:i.stroke,z=g.internal.getCurrentPageInfo().pageContext;switch(R){case 0:case!1:case"fill":B=0;break;case 1:case!0:case"stroke":B=1;break;case 2:case"fillThenStroke":B=2;break;case 3:case"invisible":B=3;break;case 4:case"fillAndAddForClipping":B=4;break;case 5:case"strokeAndAddPathForClipping":B=5;break;case 6:case"fillThenStrokeAndAddToPathForClipping":B=6;break;case 7:case"addToPathForClipping":B=7}var U=void 0!==z.usedRenderingMode?z.usedRenderingMode:-1;-1!==B?y+=B+" Tr\n":-1!==U&&(y+="0 Tr\n"),-1!==B&&(z.usedRenderingMode=B),h=i.align||"left";var q,W=et*_,H=g.internal.pageSize.getWidth(),V=mt[ut];l=i.charSpace||Ze,c=i.maxWidth||0,u=Object.assign({autoencode:!0,noBOM:!0},i.flags);var Y=[],X=function(t){return g.getStringUnitWidth(t,{font:V,charSpace:l,fontSize:et,doKerning:!1})*et/x};if("[object Array]"===Object.prototype.toString.call(t)){var G;o=k(t),"left"!==h&&(q=o.map(X));var $,K=0;if("right"===h){e-=q[0],t=[],M=o.length;for(var Z=0;Z<M;Z++)0===Z?($=He(e),G=Ve(r)):($=P(K-q[Z]),G=-W),t.push([o[Z],$,G]),K=q[Z]}else if("center"===h){e-=q[0]/2,t=[],M=o.length;for(var Q=0;Q<M;Q++)0===Q?($=He(e),G=Ve(r)):($=P((K-q[Q])/2),G=-W),t.push([o[Q],$,G]),K=q[Q]}else if("left"===h){t=[],M=o.length;for(var tt=0;tt<M;tt++)t.push(o[tt])}else if("justify"===h&&"Identity-H"===V.encoding){t=[],M=o.length,c=0!==c?c:H;for(var rt=0,it=0;it<M;it++)if(G=0===it?Ve(r):-W,$=0===it?He(e):rt,it<M-1){var st=P((c-q[it])/(o[it].split(" ").length-1)),ot=o[it].split(" ");t.push([ot[0]+" ",$,G]),rt=0;for(var at=1;at<ot.length;at++){var ht=(X(ot[at-1]+" "+ot[at])-X(ot[at]))*x+st;at==ot.length-1?t.push([ot[at],ht,0]):t.push([ot[at]+" ",ht,0]),rt-=ht}}else t.push([o[it],$,G]);t.push(["",rt,0])}else{if("justify"!==h)throw new Error('Unrecognized alignment option, use "left", "center", "right" or "justify".');for(t=[],M=o.length,c=0!==c?c:H,it=0;it<M;it++){G=0===it?Ve(r):-W,$=0===it?He(e):0;var lt=o[it].split(" ").length-1,ct=lt>0?(c-q[it])/lt:0;it<M-1?Y.push(C(P(ct))):Y.push(0),t.push([o[it],$,G])}}}!0===("boolean"==typeof i.R2L?i.R2L:nt)&&(t=L(t,function(t,e,r){return[t.split("").reverse().join(""),e,r]})),s={text:t,x:e,y:r,options:i,mutex:{pdfEscape:re,activeFontKey:ut,fonts:mt,activeFontSize:et}},kt.publish("postProcessText",s),t=s.text,v=s.mutex.isHex||!1;var ft=mt[ut].encoding;"WinAnsiEncoding"!==ft&&"StandardEncoding"!==ft||(t=L(t,function(t,e,r){return[S(t),e,r]})),o=k(t),t=[];for(var dt,pt,gt,vt=Array.isArray(o[0])?1:0,yt="",bt=function(t,e,r){var n="";return r instanceof Ot?(r="number"==typeof i.angle?Et(r,new Ot(1,0,0,1,t,e)):Et(new Ot(1,0,0,1,t,e),r),w===b&&(r=Et(new Ot(1,0,0,-1,0,0),r)),n=r.join(" ")+" Tm\n"):n=C(t)+" "+C(e)+" Td\n",n},wt=0;wt<o.length;wt++){switch(yt="",vt){case 1:gt=(v?"<":"(")+o[wt][0]+(v?">":")"),dt=parseFloat(o[wt][1]),pt=parseFloat(o[wt][2]);break;case 0:gt=(v?"<":"(")+o[wt]+(v?">":")"),dt=He(e),pt=Ve(r)}void 0!==Y&&void 0!==Y[wt]&&(yt=Y[wt]+" Tw\n"),0===wt?t.push(yt+bt(dt,pt,p)+gt):0===vt?t.push(yt+gt):1===vt&&t.push(yt+bt(dt,pt,p)+gt)}t=0===vt?t.join(" Tj\nT* "):t.join(" Tj\n"),t+=" Tj\n";var _t="BT\n/";return _t+=ut+" "+et+" Tf\n",_t+=C(et*_)+" TL\n",_t+=Ke+"\n",_t+=y,_t+=t,J(_t+="ET"),f[ut]=!0,g};var Ce=d.__private__.clip=d.clip=function(t){return J("evenodd"===t?"W*":"W"),this};d.clipEvenOdd=function(){return Ce("evenodd")},d.__private__.discardPath=d.discardPath=function(){return J("n"),this};var Ae=d.__private__.isValidStyle=function(t){var e=!1;return-1!==[void 0,null,"S","D","F","DF","FD","f","f*","B","B*","n"].indexOf(t)&&(e=!0),e};d.__private__.setDefaultPathOperation=d.setDefaultPathOperation=function(t){return Ae(t)&&(l=t),this};var ke=d.__private__.getStyle=d.getStyle=function(t){var e=l;switch(t){case"D":case"S":e="S";break;case"F":e="f";break;case"FD":case"DF":e="B";break;case"f":case"f*":case"B":case"B*":e=t}return e},Le=d.close=function(){return J("h"),this};d.stroke=function(){return J("S"),this},d.fill=function(t){return Te("f",t),this},d.fillEvenOdd=function(t){return Te("f*",t),this},d.fillStroke=function(t){return Te("B",t),this},d.fillStrokeEvenOdd=function(t){return Te("B*",t),this};var Te=function(t,e){"object"===(0,aa.A)(e)?Oe(e,t):J(t)},Pe=function(t){null===t||w===b&&void 0===t||(t=ke(t),J(t))};function Ne(t,e,r,i,n){var s=new Sf(e||this.boundingBox,r||this.xStep,i||this.yStep,this.gState,n||this.matrix);s.stream=this.stream;var o=t+"$$"+this.cloneIndex+++"$$";return Dt(o,s),s}var Oe=function(t,e){var r=wt[t.key],i=bt[r];if(i instanceof xf)J("q"),J(Ee(e)),i.gState&&d.setGState(i.gState),J(t.matrix.toString()+" cm"),J("/"+r+" sh"),J("Q");else if(i instanceof Sf){var n=new Ot(1,0,0,-1,0,pr());t.matrix&&(n=n.multiply(t.matrix||Mt),r=Ne.call(i,t.key,t.boundingBox,t.xStep,t.yStep,n).id),J("q"),J("/Pattern cs"),J("/"+r+" scn"),i.gState&&d.setGState(i.gState),J(e),J("Q")}},Ee=function(t){switch(t){case"f":case"F":case"n":return"W n";case"f*":return"W* n";case"B":case"S":return"W S";case"B*":return"W* S"}},Me=d.moveTo=function(t,e){return J(C(P(t))+" "+C(N(e))+" m"),this},De=d.lineTo=function(t,e){return J(C(P(t))+" "+C(N(e))+" l"),this},Fe=d.curveTo=function(t,e,r,i,n,s){return J([C(P(t)),C(N(e)),C(P(r)),C(N(i)),C(P(n)),C(N(s)),"c"].join(" ")),this};d.__private__.line=d.line=function(t,e,r,i,n){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||!Ae(n))throw new Error("Invalid arguments passed to jsPDF.line");return w===y?this.lines([[r-t,i-e]],t,e,[1,1],n||"S"):this.lines([[r-t,i-e]],t,e,[1,1]).stroke()},d.__private__.lines=d.lines=function(t,e,r,i,n,s){var o,a,h,l,c,u,f,d,p,g,m,v;if("number"==typeof t&&(v=r,r=e,e=t,t=v),i=i||[1,1],s=s||!1,isNaN(e)||isNaN(r)||!Array.isArray(t)||!Array.isArray(i)||!Ae(n)||"boolean"!=typeof s)throw new Error("Invalid arguments passed to jsPDF.lines");for(Me(e,r),o=i[0],a=i[1],l=t.length,g=e,m=r,h=0;h<l;h++)2===(c=t[h]).length?(g=c[0]*o+g,m=c[1]*a+m,De(g,m)):(u=c[0]*o+g,f=c[1]*a+m,d=c[2]*o+g,p=c[3]*a+m,g=c[4]*o+g,m=c[5]*a+m,Fe(u,f,d,p,g,m));return s&&Le(),Pe(n),this},d.path=function(t){for(var e=0;e<t.length;e++){var r=t[e],i=r.c;switch(r.op){case"m":Me(i[0],i[1]);break;case"l":De(i[0],i[1]);break;case"c":Fe.apply(this,i);break;case"h":Le()}}return this},d.__private__.rect=d.rect=function(t,e,r,i,n){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||!Ae(n))throw new Error("Invalid arguments passed to jsPDF.rect");return w===y&&(i=-i),J([C(P(t)),C(N(e)),C(P(r)),C(P(i)),"re"].join(" ")),Pe(n),this},d.__private__.triangle=d.triangle=function(t,e,r,i,n,s,o){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||isNaN(n)||isNaN(s)||!Ae(o))throw new Error("Invalid arguments passed to jsPDF.triangle");return this.lines([[r-t,i-e],[n-r,s-i],[t-n,e-s]],t,e,[1,1],o,!0),this},d.__private__.roundedRect=d.roundedRect=function(t,e,r,i,n,s,o){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||isNaN(n)||isNaN(s)||!Ae(o))throw new Error("Invalid arguments passed to jsPDF.roundedRect");var a=4/3*(Math.SQRT2-1);return n=Math.min(n,.5*r),s=Math.min(s,.5*i),this.lines([[r-2*n,0],[n*a,0,n,s-s*a,n,s],[0,i-2*s],[0,s*a,-n*a,s,-n,s],[2*n-r,0],[-n*a,0,-n,-s*a,-n,-s],[0,2*s-i],[0,-s*a,n*a,-s,n,-s]],t+n,e,[1,1],o,!0),this},d.__private__.ellipse=d.ellipse=function(t,e,r,i,n){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||!Ae(n))throw new Error("Invalid arguments passed to jsPDF.ellipse");var s=4/3*(Math.SQRT2-1)*r,o=4/3*(Math.SQRT2-1)*i;return Me(t+r,e),Fe(t+r,e-o,t+s,e-i,t,e-i),Fe(t-s,e-i,t-r,e-o,t-r,e),Fe(t-r,e+o,t-s,e+i,t,e+i),Fe(t+s,e+i,t+r,e+o,t+r,e),Pe(n),this},d.__private__.circle=d.circle=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||!Ae(i))throw new Error("Invalid arguments passed to jsPDF.circle");return this.ellipse(t,e,r,r,i)},d.setFont=function(t,e,r){return r&&(e=S(e,r)),ut=he(t,e,{disableWarning:!1}),this};var je=d.__private__.getFont=d.getFont=function(){return mt[he.apply(d,arguments)]};d.__private__.getFontList=d.getFontList=function(){var t,e,r={};for(t in vt)if(vt.hasOwnProperty(t))for(e in r[t]=[],vt[t])vt[t].hasOwnProperty(e)&&r[t].push(e);return r},d.addFont=function(t,e,r,i,n){var s=["StandardEncoding","MacRomanEncoding","Identity-H","WinAnsiEncoding"];return arguments[3]&&-1!==s.indexOf(arguments[3])?n=arguments[3]:arguments[3]&&-1==s.indexOf(arguments[3])&&(r=S(r,i)),ee.call(this,t,e,r,n=n||"Identity-H")};var Ie,Be=t.lineWidth||.200025,Re=d.__private__.getLineWidth=d.getLineWidth=function(){return Be},ze=d.__private__.setLineWidth=d.setLineWidth=function(t){return Be=t,J(C(P(t))+" w"),this};d.__private__.setLineDash=Cf.API.setLineDash=Cf.API.setLineDashPattern=function(t,e){if(t=t||[],e=e||0,isNaN(e)||!Array.isArray(t))throw new Error("Invalid arguments passed to jsPDF.setLineDash");return t=t.map(function(t){return C(P(t))}).join(" "),e=C(P(e)),J("["+t+"] "+e+" d"),this};var Ue=d.__private__.getLineHeight=d.getLineHeight=function(){return et*Ie};d.__private__.getLineHeight=d.getLineHeight=function(){return et*Ie};var qe=d.__private__.setLineHeightFactor=d.setLineHeightFactor=function(t){return"number"==typeof(t=t||1.15)&&(Ie=t),this},We=d.__private__.getLineHeightFactor=d.getLineHeightFactor=function(){return Ie};qe(t.lineHeight);var He=d.__private__.getHorizontalCoordinate=function(t){return P(t)},Ve=d.__private__.getVerticalCoordinate=function(t){return w===b?t:At[R].mediaBox.topRightY-At[R].mediaBox.bottomLeftY-P(t)},Ye=d.__private__.getHorizontalCoordinateString=d.getHorizontalCoordinateString=function(t){return C(He(t))},Xe=d.__private__.getVerticalCoordinateString=d.getVerticalCoordinateString=function(t){return C(Ve(t))},Ge=t.strokeColor||"0 G";d.__private__.getStrokeColor=d.getDrawColor=function(){return qt(Ge)},d.__private__.setStrokeColor=d.setDrawColor=function(t,e,r,i){return Ge=Wt({ch1:t,ch2:e,ch3:r,ch4:i,pdfColorType:"draw",precision:2}),J(Ge),this};var $e=t.fillColor||"0 g";d.__private__.getFillColor=d.getFillColor=function(){return qt($e)},d.__private__.setFillColor=d.setFillColor=function(t,e,r,i){return $e=Wt({ch1:t,ch2:e,ch3:r,ch4:i,pdfColorType:"fill",precision:2}),J($e),this};var Ke=t.textColor||"0 g",Je=d.__private__.getTextColor=d.getTextColor=function(){return qt(Ke)};d.__private__.setTextColor=d.setTextColor=function(t,e,r,i){return Ke=Wt({ch1:t,ch2:e,ch3:r,ch4:i,pdfColorType:"text",precision:3}),this};var Ze=t.charSpace,Qe=d.__private__.getCharSpace=d.getCharSpace=function(){return parseFloat(Ze||0)};d.__private__.setCharSpace=d.setCharSpace=function(t){if(isNaN(t))throw new Error("Invalid argument passed to jsPDF.setCharSpace");return Ze=t,this};var tr=0;d.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},d.__private__.setLineCap=d.setLineCap=function(t){var e=d.CapJoinStyles[t];if(void 0===e)throw new Error("Line cap style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return tr=e,J(e+" J"),this};var er=0;d.__private__.setLineJoin=d.setLineJoin=function(t){var e=d.CapJoinStyles[t];if(void 0===e)throw new Error("Line join style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return er=e,J(e+" j"),this},d.__private__.setLineMiterLimit=d.__private__.setMiterLimit=d.setLineMiterLimit=d.setMiterLimit=function(t){if(t=t||0,isNaN(t))throw new Error("Invalid argument passed to jsPDF.setLineMiterLimit");return J(C(P(t))+" M"),this},d.GState=wf,d.setGState=function(t){(t="string"==typeof t?_t[xt[t]]:rr(null,t)).equals(St)||(J("/"+t.id+" gs"),St=t)};var rr=function(t,e){if(!t||!xt[t]){var r=!1;for(var i in _t)if(_t.hasOwnProperty(i)&&_t[i].equals(e)){r=!0;break}if(r)e=_t[i];else{var n="GS"+(Object.keys(_t).length+1).toString(10);_t[n]=e,e.id=n}return t&&(xt[t]=e.id),kt.publish("addGState",e),e}};d.addGState=function(t,e){return rr(t,e),this},d.saveGraphicsState=function(){return J("q"),yt.push({key:ut,size:et,color:Ke}),this},d.restoreGraphicsState=function(){J("Q");var t=yt.pop();return ut=t.key,et=t.size,Ke=t.color,St=null,this},d.setCurrentTransformationMatrix=function(t){return J(t.toString()+" cm"),this},d.comment=function(t){return J("#"+t),this};var ir=function(t,e){var r=t||0;Object.defineProperty(this,"x",{enumerable:!0,get:function(){return r},set:function(t){isNaN(t)||(r=parseFloat(t))}});var i=e||0;Object.defineProperty(this,"y",{enumerable:!0,get:function(){return i},set:function(t){isNaN(t)||(i=parseFloat(t))}});var n="pt";return Object.defineProperty(this,"type",{enumerable:!0,get:function(){return n},set:function(t){n=t.toString()}}),this},nr=function(t,e,r,i){ir.call(this,t,e),this.type="rect";var n=r||0;Object.defineProperty(this,"w",{enumerable:!0,get:function(){return n},set:function(t){isNaN(t)||(n=parseFloat(t))}});var s=i||0;return Object.defineProperty(this,"h",{enumerable:!0,get:function(){return s},set:function(t){isNaN(t)||(s=parseFloat(t))}}),this},sr=function(){this.page=Ct,this.currentPage=R,this.pages=X.slice(0),this.pagesContext=At.slice(0),this.x=dt,this.y=pt,this.matrix=gt,this.width=hr(R),this.height=cr(R),this.outputDestination=$,this.id="",this.objectNumber=-1};sr.prototype.restore=function(){Ct=this.page,R=this.currentPage,At=this.pagesContext,X=this.pages,dt=this.x,pt=this.y,gt=this.matrix,lr(R,this.width),ur(R,this.height),$=this.outputDestination};var or=function(t,e,r,i,n){Nt.push(new sr),Ct=R=0,X=[],dt=t,pt=e,gt=n,ie([r,i])};for(var ar in d.beginFormObject=function(t,e,r,i,n){return or(t,e,r,i,n),this},d.endFormObject=function(t){return function(t){if(Pt[t])Nt.pop().restore();else{var e=new sr,r="Xo"+(Object.keys(Tt).length+1).toString(10);e.id=r,Pt[t]=r,Tt[r]=e,kt.publish("addFormObject",e),Nt.pop().restore()}}(t),this},d.doFormObject=function(t,e){var r=Tt[Pt[t]];return J("q"),J(e.toString()+" cm"),J("/"+r.id+" Do"),J("Q"),this},d.getFormObject=function(t){var e=Tt[Pt[t]];return{x:e.x,y:e.y,width:e.width,height:e.height,matrix:e.matrix}},d.save=function(t,e){return t=t||"generated.pdf",(e=e||{}).returnPromise=e.returnPromise||!1,!1===e.returnPromise?(Ku(ge(pe()),t),"function"==typeof Ku.unload&&Hu.setTimeout&&setTimeout(Ku.unload,911),this):new Promise(function(e,r){try{var i=Ku(ge(pe()),t);"function"==typeof Ku.unload&&Hu.setTimeout&&setTimeout(Ku.unload,911),e(i)}catch(t){r(t.message)}})},Cf.API)Cf.API.hasOwnProperty(ar)&&("events"===ar&&Cf.API.events.length?function(t,e){var r,i,n;for(n=e.length-1;-1!==n;n--)r=e[n][0],i=e[n][1],t.subscribe.apply(t,[r].concat("function"==typeof i?[i]:i))}(kt,Cf.API.events):d[ar]=Cf.API[ar]);function hr(t){return At[t].mediaBox.topRightX-At[t].mediaBox.bottomLeftX}function lr(t,e){At[t].mediaBox.topRightX=e+At[t].mediaBox.bottomLeftX}function cr(t){return At[t].mediaBox.topRightY-At[t].mediaBox.bottomLeftY}function ur(t,e){At[t].mediaBox.topRightY=e+At[t].mediaBox.bottomLeftY}var fr=d.getPageWidth=function(t){return hr(t=t||R)/ft},dr=d.setPageWidth=function(t,e){lr(t,e*ft)},pr=d.getPageHeight=function(t){return cr(t=t||R)/ft},gr=d.setPageHeight=function(t,e){ur(t,e*ft)};return d.internal={pdfEscape:re,getStyle:ke,getFont:je,getFontSize:it,getCharSpace:Qe,getTextColor:Je,getLineHeight:Ue,getLineHeightFactor:We,getLineWidth:Re,write:Z,getHorizontalCoordinate:He,getVerticalCoordinate:Ve,getCoordinateString:Ye,getVerticalCoordinateString:Xe,collections:{},newObject:jt,newAdditionalObject:Rt,newObjectDeferred:It,newObjectDeferredBegin:Bt,getFilters:Ht,putStream:Vt,events:kt,scaleFactor:ft,pageSize:{getWidth:function(){return fr(R)},setWidth:function(t){dr(R,t)},getHeight:function(){return pr(R)},setHeight:function(t){gr(R,t)}},encryptionOptions:c,encryption:we,getEncryptor:function(t){return null!==c?we.encryptor(t,0):function(t){return t}},output:ye,getNumberOfPages:ae,get pages(){return X},out:J,f2:L,f3:T,getPageInfo:_e,getPageInfoByObjId:xe,getCurrentPageInfo:Se,getPDFVersion:g,Point:ir,Rectangle:nr,Matrix:Ot,hasHotfix:be},Object.defineProperty(d.internal.pageSize,"width",{get:function(){return fr(R)},set:function(t){dr(R,t)},enumerable:!0,configurable:!0}),Object.defineProperty(d.internal.pageSize,"height",{get:function(){return pr(R)},set:function(t){gr(R,t)},enumerable:!0,configurable:!0}),function(t){for(var e=0,r=tt.length;e<r;e++){var i=ee.call(this,t[e][0],t[e][1],t[e][2],tt[e][3],!0);!1===u&&(f[i]=!0);var n=t[e][0].split("-");te({id:i,fontName:n[0],fontStyle:n[1]||""})}kt.publish("addFonts",{fonts:mt,dictionary:vt})}.call(d,tt),ut="F1",ne(n,r),kt.publish("initialized"),d}vf.prototype.lsbFirstWord=function(t){return String.fromCharCode(255&t,t>>8&255,t>>16&255,t>>24&255)},vf.prototype.toHexString=function(t){return t.split("").map(function(t){return("0"+(255&t.charCodeAt(0)).toString(16)).slice(-2)}).join("")},vf.prototype.hexToBytes=function(t){for(var e=[],r=0;r<t.length;r+=2)e.push(String.fromCharCode(parseInt(t.substr(r,2),16)));return e.join("")},vf.prototype.processOwnerPassword=function(t,e){return gf(ff(e).substr(0,5),t)},vf.prototype.encryptor=function(t,e){var r=ff(this.encryptionKey+String.fromCharCode(255&t,t>>8&255,t>>16&255,255&e,e>>8&255)).substr(0,10);return function(t){return gf(r,t)}},wf.prototype.equals=function(t){var e,r="id,objectNumber,equals";if(!t||(0,aa.A)(t)!==(0,aa.A)(this))return!1;var i=0;for(e in this)if(!(r.indexOf(e)>=0)){if(this.hasOwnProperty(e)&&!t.hasOwnProperty(e))return!1;if(this[e]!==t[e])return!1;i++}for(e in t)t.hasOwnProperty(e)&&r.indexOf(e)<0&&i--;return 0===i},Cf.API={events:[]},Cf.version="4.2.1";var Af=Cf.API,kf=1,Lf=function(t){return t.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},Tf=function(t){return t.replace(/\\\\/g,"\\").replace(/\\\(/g,"(").replace(/\\\)/g,")")},Pf=function(t){return t.toString().replace(/#/g,"#23").replace(/[\s\n\r()<>[\]{}\/%]/g,function(t){var e=t.charCodeAt(0).toString(16).toUpperCase();return"#"+(1===e.length?"0"+e:e)})},Nf=function(t){return t.toFixed(2)},Of=function(t){return t.toFixed(5)};Af.__acroform__={};var Ef=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t},Mf=function(t){return t*kf},Df=function(t){var e=new Kf,r=cd.internal.getHeight(t)||0,i=cd.internal.getWidth(t)||0;return e.BBox=[0,0,Number(Nf(i)),Number(Nf(r))],e},Ff=Af.__acroform__.setBit=function(t,e){if(t=t||0,e=e||0,isNaN(t)||isNaN(e))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBit");return t|1<<e},jf=Af.__acroform__.clearBit=function(t,e){if(t=t||0,e=e||0,isNaN(t)||isNaN(e))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBit");return t&~(1<<e)},If=Af.__acroform__.getBit=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBit");return t&1<<e?1:0},Bf=Af.__acroform__.getBitForPdf=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf");return If(t,e-1)},Rf=Af.__acroform__.setBitForPdf=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf");return Ff(t,e-1)},zf=Af.__acroform__.clearBitForPdf=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf");return jf(t,e-1)},Uf=Af.__acroform__.calculateCoordinates=function(t,e){var r=e.internal.getHorizontalCoordinate,i=e.internal.getVerticalCoordinate,n=t[0],s=t[1],o=t[2],a=t[3],h={};return h.lowerLeft_X=r(n)||0,h.lowerLeft_Y=i(s+a)||0,h.upperRight_X=r(n+o)||0,h.upperRight_Y=i(s)||0,[Number(Nf(h.lowerLeft_X)),Number(Nf(h.lowerLeft_Y)),Number(Nf(h.upperRight_X)),Number(Nf(h.upperRight_Y))]},qf=function(t){if(t.appearanceStreamContent)return t.appearanceStreamContent;if(t.V||t.DV){var e=[],r=t._V||t.DV,i=Wf(t,r),n=t.scope.internal.getFont(t.fontName,t.fontStyle).id;e.push("/Tx BMC"),e.push("q"),e.push("BT"),e.push(t.scope.__private__.encodeColorString(t.color)),e.push("/"+n+" "+Nf(i.fontSize)+" Tf"),e.push("1 0 0 1 0 0 Tm"),e.push(i.text),e.push("ET"),e.push("Q"),e.push("EMC");var s=Df(t);return s.scope=t.scope,s.stream=e.join("\n"),s}},Wf=function(t,e){var r=0===t.fontSize?t.maxFontSize:t.fontSize,i={text:"",fontSize:""},n=(e=")"==(e="("==e.substr(0,1)?e.substr(1):e).substr(e.length-1)?e.substr(0,e.length-1):e).split(" ");n=t.multiline?n.map(function(t){return t.split("\n")}):n.map(function(t){return[t]});var s=r,o=cd.internal.getHeight(t)||0;o=o<0?-o:o;var a=cd.internal.getWidth(t)||0;a=a<0?-a:a;var h=function(e,r,i){if(e+1<n.length){var s=r+" "+n[e+1][0];return Hf(s,t,i).width<=a-4}return!1};s++;t:for(;s>0;){e="",s--;var l,c,u=Hf("3",t,s).height,f=t.multiline?o-s:(o-u)/2,d=f+=2,p=0,g=0,m=0;if(s<=0){e="(...) Tj\n",e+="% Width of Text: "+Hf(e,t,s=12).width+", FieldWidth:"+a+"\n";break}for(var v="",y=0,b=0;b<n.length;b++)if(n.hasOwnProperty(b)){var w=!1;if(1!==n[b].length&&m!==n[b].length-1){if((u+2)*(y+2)+2>o)continue t;v+=n[b][m],w=!0,g=b,b--}else{v=" "==(v+=n[b][m]+" ").substr(v.length-1)?v.substr(0,v.length-1):v;var _=parseInt(b),x=h(_,v,s),S=b>=n.length-1;if(x&&!S){v+=" ",m=0;continue}if(x||S){if(S)g=_;else if(t.multiline&&(u+2)*(y+2)+2>o)continue t}else{if(!t.multiline)continue t;if((u+2)*(y+2)+2>o)continue t;g=_}}for(var C="",A=p;A<=g;A++){var k=n[A];if(t.multiline){if(A===g){C+=k[m]+" ",m=(m+1)%k.length;continue}if(A===p){C+=k[k.length-1]+" ";continue}}C+=k[0]+" "}switch(C=" "==C.substr(C.length-1)?C.substr(0,C.length-1):C,c=Hf(C,t,s).width,t.textAlign){case"right":l=a-c-2;break;case"center":l=(a-c)/2;break;default:l=2}e+=Nf(l)+" "+Nf(d)+" Td\n",e+="("+Lf(C)+") Tj\n",e+=-Nf(l)+" 0 Td\n",d=-(s+2),c=0,p=w?g:g+1,y++,v=""}break}return i.text=e,i.fontSize=s,i},Hf=function(t,e,r){var i=e.scope.internal.getFont(e.fontName,e.fontStyle),n=e.scope.getStringUnitWidth(t,{font:i,fontSize:parseFloat(r),charSpace:0})*parseFloat(r);return{height:e.scope.getStringUnitWidth("3",{font:i,fontSize:parseFloat(r),charSpace:0})*parseFloat(r)*1.5,width:n}},Vf={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},Yf=function(t,e){var r={type:"reference",object:t};void 0===e.internal.getPageInfo(t.page).pageContext.annotations.find(function(t){return t.type===r.type&&t.object===r.object})&&e.internal.getPageInfo(t.page).pageContext.annotations.push(r)},Xf=Af.__acroform__.arrayToPdfArray=function(t,e,r){var i=function(t){return t};if(Array.isArray(t)){for(var n="[",s=0;s<t.length;s++)switch(0!==s&&(n+=" "),(0,aa.A)(t[s])){case"boolean":case"number":case"object":n+=t[s].toString();break;case"string":"/"===t[s].substr(0,1)?n+="/"+Pf(t[s].substr(1)):(void 0!==e&&r&&(i=r.internal.getEncryptor(e)),n+="("+Lf(i(t[s].toString()))+")")}return n+"]"}throw new Error("Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray")},Gf=function(t,e,r){var i=function(t){return t};return void 0!==e&&r&&(i=r.internal.getEncryptor(e)),(t=t||"").toString(),"("+Lf(i(t))+")"},$f=function(){this._objId=void 0,this._scope=void 0,Object.defineProperty(this,"objId",{get:function(){if(void 0===this._objId){if(void 0===this.scope)return;this._objId=this.scope.internal.newObjectDeferred()}return this._objId},set:function(t){this._objId=t}}),Object.defineProperty(this,"scope",{value:this._scope,writable:!0})};$f.prototype.toString=function(){return this.objId+" 0 R"},$f.prototype.putStream=function(){var t=this.getKeyValueListForStream();this.scope.internal.putStream({data:this.stream,additionalKeyValues:t,objectId:this.objId}),this.scope.internal.out("endobj")},$f.prototype.getKeyValueListForStream=function(){var t=[],e=Object.getOwnPropertyNames(this).filter(function(t){return"content"!=t&&"appearanceStreamContent"!=t&&"scope"!=t&&"objId"!=t&&"_"!=t.substring(0,1)});for(var r in e)if(!1===Object.getOwnPropertyDescriptor(this,e[r]).configurable){var i=e[r],n=this[i];n&&(Array.isArray(n)?t.push({key:i,value:Xf(n,this.objId,this.scope)}):n instanceof $f?(n.scope=this.scope,t.push({key:i,value:n.objId+" 0 R"})):"function"!=typeof n&&t.push({key:i,value:n}))}return t};var Kf=function(){$f.call(this),Object.defineProperty(this,"Type",{value:"/XObject",configurable:!1,writable:!0}),Object.defineProperty(this,"Subtype",{value:"/Form",configurable:!1,writable:!0}),Object.defineProperty(this,"FormType",{value:1,configurable:!1,writable:!0});var t,e=[];Object.defineProperty(this,"BBox",{configurable:!1,get:function(){return e},set:function(t){e=t}}),Object.defineProperty(this,"Resources",{value:"2 0 R",configurable:!1,writable:!0}),Object.defineProperty(this,"stream",{enumerable:!1,configurable:!0,set:function(e){t=e.trim()},get:function(){return t||null}})};Ef(Kf,$f);var Jf=function(){$f.call(this);var t,e=[];Object.defineProperty(this,"Kids",{enumerable:!1,configurable:!0,get:function(){return e.length>0?e:void 0}}),Object.defineProperty(this,"Fields",{enumerable:!1,configurable:!1,get:function(){return e}}),Object.defineProperty(this,"DA",{enumerable:!1,configurable:!1,get:function(){if(t){var e=function(t){return t};return this.scope&&(e=this.scope.internal.getEncryptor(this.objId)),"("+Lf(e(t))+")"}},set:function(e){t=e}})};Ef(Jf,$f);var Zf=function t(){$f.call(this);var e=4;Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return e},set:function(t){if(isNaN(t))throw new Error('Invalid value "'+t+'" for attribute F supplied.');e=t}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(e,3))},set:function(t){!0===Boolean(t)?this.F=Rf(e,3):this.F=zf(e,3)}});var r=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return r},set:function(t){if(isNaN(t))throw new Error('Invalid value "'+t+'" for attribute Ff supplied.');r=t}});var i=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(0!==i.length)return i},set:function(t){i=void 0!==t?t:[]}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!i||isNaN(i[0])?0:i[0]},set:function(t){i[0]=t}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!i||isNaN(i[1])?0:i[1]},set:function(t){i[1]=t}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!i||isNaN(i[2])?0:i[2]},set:function(t){i[2]=t}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!i||isNaN(i[3])?0:i[3]},set:function(t){i[3]=t}});var n="";Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return n},set:function(t){switch(t){case"/Btn":case"/Tx":case"/Ch":case"/Sig":n=t;break;default:throw new Error('Invalid value "'+t+'" for attribute FT supplied.')}}});var s=null;Object.defineProperty(this,"T",{enumerable:!0,configurable:!1,get:function(){if(!s||s.length<1){if(this instanceof od)return;s="FieldObject"+t.FieldNum++}var e=function(t){return t};return this.scope&&(e=this.scope.internal.getEncryptor(this.objId)),"("+Lf(e(s))+")"},set:function(t){s=t.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return s},set:function(t){s=t}});var o="helvetica";Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return o},set:function(t){o=t}});var a="normal";Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return a},set:function(t){a=t}});var h=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return h},set:function(t){h=t}});var l=void 0;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return void 0===l?50/kf:l},set:function(t){l=t}});var c="black";Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return c},set:function(t){c=t}});var u="/F1 0 Tf 0 g";Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!u||this instanceof od||this instanceof hd))return Gf(u,this.objId,this.scope)},set:function(t){t=t.toString(),u=t}});var f=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(f)return this instanceof id==0?Gf(f,this.objId,this.scope):f},set:function(t){t=t.toString(),f=this instanceof id==0?"("===t.substr(0,1)?Tf(t.substr(1,t.length-2)):Tf(t):t}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof id==1?Tf(f.substr(1,f.length-1)):f},set:function(t){t=t.toString(),f=this instanceof id==1?"/"+Pf(t):t}});var d=null;Object.defineProperty(this,"_V",{enumerable:!1,configurable:!1,get:function(){if(d)return d},set:function(t){this.V=t}}),Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(d)return this instanceof id==0?Gf(d,this.objId,this.scope):d},set:function(t){t=t.toString(),d=this instanceof id==0?"("===t.substr(0,1)?Tf(t.substr(1,t.length-2)):Tf(t):t}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this instanceof id==1?Tf(d.substr(1,d.length-1)):d},set:function(t){t=t.toString(),d=this instanceof id==1?"/"+Pf(t):t}}),Object.defineProperty(this,"hasAnnotation",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,"Type",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Annot":null}}),Object.defineProperty(this,"Subtype",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Widget":null}});var p,g=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return g},set:function(t){t=Boolean(t),g=t}}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,get:function(){if(p)return p},set:function(t){p=t}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,1))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,1):this.Ff=zf(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,2))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,2):this.Ff=zf(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,3))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,3):this.Ff=zf(this.Ff,3)}});var m=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(null!==m)return m},set:function(t){if(-1===[0,1,2].indexOf(t))throw new Error('Invalid value "'+t+'" for attribute Q supplied.');m=t}}),Object.defineProperty(this,"textAlign",{get:function(){var t;switch(m){case 0:default:t="left";break;case 1:t="center";break;case 2:t="right"}return t},configurable:!0,enumerable:!0,set:function(t){switch(t){case"right":case 2:m=2;break;case"center":case 1:m=1;break;default:m=0}}})};Ef(Zf,$f);var Qf=function(){Zf.call(this),this.FT="/Ch",this.V="()",this.fontName="zapfdingbats";var t=0;Object.defineProperty(this,"TI",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"topIndex",{enumerable:!0,configurable:!0,get:function(){return t},set:function(e){t=e}});var e=[];Object.defineProperty(this,"Opt",{enumerable:!0,configurable:!1,get:function(){return Xf(e,this.objId,this.scope)},set:function(t){var r,i;i=[],"string"==typeof(r=t)&&(i=function(t,e,r){r||(r=1);for(var i,n=[];i=e.exec(t);)n.push(i[r]);return n}(r,/\((.*?)\)/g)),e=i}}),this.getOptions=function(){return e},this.setOptions=function(t){e=t,this.sort&&e.sort()},this.addOption=function(t){t=(t=t||"").toString(),e.push(t),this.sort&&e.sort()},this.removeOption=function(t,r){for(r=r||!1,t=(t=t||"").toString();-1!==e.indexOf(t)&&(e.splice(e.indexOf(t),1),!1!==r););},Object.defineProperty(this,"combo",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,18))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,18):this.Ff=zf(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,19))},set:function(t){!0===this.combo&&(!0===Boolean(t)?this.Ff=Rf(this.Ff,19):this.Ff=zf(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,20))},set:function(t){!0===Boolean(t)?(this.Ff=Rf(this.Ff,20),e.sort()):this.Ff=zf(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,22))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,22):this.Ff=zf(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,23))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,23):this.Ff=zf(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,27))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,27):this.Ff=zf(this.Ff,27)}}),this.hasAppearanceStream=!1};Ef(Qf,Zf);var td=function(){Qf.call(this),this.fontName="helvetica",this.combo=!1};Ef(td,Qf);var ed=function(){td.call(this),this.combo=!0};Ef(ed,td);var rd=function(){ed.call(this),this.edit=!0};Ef(rd,ed);var id=function(){Zf.call(this),this.FT="/Btn",Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,15))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,15):this.Ff=zf(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,16))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,16):this.Ff=zf(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,17))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,17):this.Ff=zf(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,26))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,26):this.Ff=zf(this.Ff,26)}});var t,e={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var t=function(t){return t};if(this.scope&&(t=this.scope.internal.getEncryptor(this.objId)),0!==Object.keys(e).length){var r,i=[];for(r in i.push("<<"),e)i.push("/"+r+" ("+Lf(t(e[r]))+")");return i.push(">>"),i.join("\n")}},set:function(t){"object"===(0,aa.A)(t)&&(e=t)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return e.CA||""},set:function(t){"string"==typeof t&&(e.CA=t)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){var r=null==e?"":e.toString();"/"===r.substr(0,1)&&(r=r.substr(1)),t="/"+Pf(r)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return t.substr(1,t.length-1)},set:function(e){t="/"+Pf(e)}})};Ef(id,Zf);var nd=function(){id.call(this),this.pushButton=!0};Ef(nd,id);var sd=function(){id.call(this),this.radio=!0,this.pushButton=!1;var t=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=void 0!==e?e:[]}})};Ef(sd,id);var od=function(){var t,e;Zf.call(this),Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return e},set:function(t){e=t}});var r,i={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var t=function(t){return t};this.scope&&(t=this.scope.internal.getEncryptor(this.objId));var e,r=[];for(e in r.push("<<"),i)r.push("/"+e+" ("+Lf(t(i[e]))+")");return r.push(">>"),r.join("\n")},set:function(t){"object"===(0,aa.A)(t)&&(i=t)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return i.CA||""},set:function(t){"string"==typeof t&&(i.CA=t)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return r},set:function(t){var e=null==t?"":t.toString();"/"===e.substr(0,1)&&(e=e.substr(1)),r="/"+Pf(e)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return r.substr(1,r.length-1)},set:function(t){var e=null==t?"":t.toString();"/"===e.substr(0,1)&&(e=e.substr(1)),r="/"+Pf(e)}}),this.caption="l",this.appearanceState="Off",this._AppearanceType=cd.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};Ef(od,Zf),sd.prototype.setAppearance=function(t){if(!("createAppearanceStream"in t)||!("getCA"in t))throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!");for(var e in this.Kids)if(this.Kids.hasOwnProperty(e)){var r=this.Kids[e];r.appearanceStreamContent=t.createAppearanceStream(r.optionName),r.caption=t.getCA()}},sd.prototype.createOption=function(t){var e=new od;return e.Parent=this,e.optionName=t,this.Kids.push(e),ud.call(this.scope,e),e};var ad=function(){id.call(this),this.fontName="zapfdingbats",this.caption="3",this.appearanceState="On",this.value="On",this.textAlign="center",this.appearanceStreamContent=cd.CheckBox.createAppearanceStream()};Ef(ad,id);var hd=function(){Zf.call(this),this.FT="/Tx",Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,13))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,13):this.Ff=zf(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,21))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,21):this.Ff=zf(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,23))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,23):this.Ff=zf(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,24))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,24):this.Ff=zf(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,25))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,25):this.Ff=zf(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,26))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,26):this.Ff=zf(this.Ff,26)}});var t=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return t},set:function(e){t=e}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return t},set:function(e){Number.isInteger(e)&&(t=e)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};Ef(hd,Zf);var ld=function(){hd.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return Boolean(Bf(this.Ff,14))},set:function(t){!0===Boolean(t)?this.Ff=Rf(this.Ff,14):this.Ff=zf(this.Ff,14)}}),this.password=!0};Ef(ld,hd);var cd={CheckBox:{createAppearanceStream:function(){return{N:{On:cd.CheckBox.YesNormal},D:{On:cd.CheckBox.YesPushDown,Off:cd.CheckBox.OffPushDown}}},YesPushDown:function(t){var e=Df(t);e.scope=t.scope;var r=[],i=t.scope.internal.getFont(t.fontName,t.fontStyle).id,n=t.scope.__private__.encodeColorString(t.color),s=Wf(t,t.caption);return r.push("0.749023 g"),r.push("0 0 "+Nf(cd.internal.getWidth(t))+" "+Nf(cd.internal.getHeight(t))+" re"),r.push("f"),r.push("BMC"),r.push("q"),r.push("0 0 1 rg"),r.push("/"+i+" "+Nf(s.fontSize)+" Tf "+n),r.push("BT"),r.push(s.text),r.push("ET"),r.push("Q"),r.push("EMC"),e.stream=r.join("\n"),e},YesNormal:function(t){var e=Df(t);e.scope=t.scope;var r=t.scope.internal.getFont(t.fontName,t.fontStyle).id,i=t.scope.__private__.encodeColorString(t.color),n=[],s=cd.internal.getHeight(t),o=cd.internal.getWidth(t),a=Wf(t,t.caption);return n.push("1 g"),n.push("0 0 "+Nf(o)+" "+Nf(s)+" re"),n.push("f"),n.push("q"),n.push("0 0 1 rg"),n.push("0 0 "+Nf(o-1)+" "+Nf(s-1)+" re"),n.push("W"),n.push("n"),n.push("0 g"),n.push("BT"),n.push("/"+r+" "+Nf(a.fontSize)+" Tf "+i),n.push(a.text),n.push("ET"),n.push("Q"),e.stream=n.join("\n"),e},OffPushDown:function(t){var e=Df(t);e.scope=t.scope;var r=[];return r.push("0.749023 g"),r.push("0 0 "+Nf(cd.internal.getWidth(t))+" "+Nf(cd.internal.getHeight(t))+" re"),r.push("f"),e.stream=r.join("\n"),e}},RadioButton:{Circle:{createAppearanceStream:function(t){var e={D:{Off:cd.RadioButton.Circle.OffPushDown},N:{}};return e.N[t]=cd.RadioButton.Circle.YesNormal,e.D[t]=cd.RadioButton.Circle.YesPushDown,e},getCA:function(){return"l"},YesNormal:function(t){var e=Df(t);e.scope=t.scope;var r=[],i=cd.internal.getWidth(t)<=cd.internal.getHeight(t)?cd.internal.getWidth(t)/4:cd.internal.getHeight(t)/4;i=Number((.9*i).toFixed(5));var n=cd.internal.Bezier_C,s=Number((i*n).toFixed(5));return r.push("q"),r.push("1 0 0 1 "+Of(cd.internal.getWidth(t)/2)+" "+Of(cd.internal.getHeight(t)/2)+" cm"),r.push(i+" 0 m"),r.push(i+" "+s+" "+s+" "+i+" 0 "+i+" c"),r.push("-"+s+" "+i+" -"+i+" "+s+" -"+i+" 0 c"),r.push("-"+i+" -"+s+" -"+s+" -"+i+" 0 -"+i+" c"),r.push(s+" -"+i+" "+i+" -"+s+" "+i+" 0 c"),r.push("f"),r.push("Q"),e.stream=r.join("\n"),e},YesPushDown:function(t){var e=Df(t);e.scope=t.scope;var r=[],i=cd.internal.getWidth(t)<=cd.internal.getHeight(t)?cd.internal.getWidth(t)/4:cd.internal.getHeight(t)/4;i=Number((.9*i).toFixed(5));var n=Number((2*i).toFixed(5)),s=Number((n*cd.internal.Bezier_C).toFixed(5)),o=Number((i*cd.internal.Bezier_C).toFixed(5));return r.push("0.749023 g"),r.push("q"),r.push("1 0 0 1 "+Of(cd.internal.getWidth(t)/2)+" "+Of(cd.internal.getHeight(t)/2)+" cm"),r.push(n+" 0 m"),r.push(n+" "+s+" "+s+" "+n+" 0 "+n+" c"),r.push("-"+s+" "+n+" -"+n+" "+s+" -"+n+" 0 c"),r.push("-"+n+" -"+s+" -"+s+" -"+n+" 0 -"+n+" c"),r.push(s+" -"+n+" "+n+" -"+s+" "+n+" 0 c"),r.push("f"),r.push("Q"),r.push("0 g"),r.push("q"),r.push("1 0 0 1 "+Of(cd.internal.getWidth(t)/2)+" "+Of(cd.internal.getHeight(t)/2)+" cm"),r.push(i+" 0 m"),r.push(i+" "+o+" "+o+" "+i+" 0 "+i+" c"),r.push("-"+o+" "+i+" -"+i+" "+o+" -"+i+" 0 c"),r.push("-"+i+" -"+o+" -"+o+" -"+i+" 0 -"+i+" c"),r.push(o+" -"+i+" "+i+" -"+o+" "+i+" 0 c"),r.push("f"),r.push("Q"),e.stream=r.join("\n"),e},OffPushDown:function(t){var e=Df(t);e.scope=t.scope;var r=[],i=cd.internal.getWidth(t)<=cd.internal.getHeight(t)?cd.internal.getWidth(t)/4:cd.internal.getHeight(t)/4;i=Number((.9*i).toFixed(5));var n=Number((2*i).toFixed(5)),s=Number((n*cd.internal.Bezier_C).toFixed(5));return r.push("0.749023 g"),r.push("q"),r.push("1 0 0 1 "+Of(cd.internal.getWidth(t)/2)+" "+Of(cd.internal.getHeight(t)/2)+" cm"),r.push(n+" 0 m"),r.push(n+" "+s+" "+s+" "+n+" 0 "+n+" c"),r.push("-"+s+" "+n+" -"+n+" "+s+" -"+n+" 0 c"),r.push("-"+n+" -"+s+" -"+s+" -"+n+" 0 -"+n+" c"),r.push(s+" -"+n+" "+n+" -"+s+" "+n+" 0 c"),r.push("f"),r.push("Q"),e.stream=r.join("\n"),e}},Cross:{createAppearanceStream:function(t){var e={D:{Off:cd.RadioButton.Cross.OffPushDown},N:{}};return e.N[t]=cd.RadioButton.Cross.YesNormal,e.D[t]=cd.RadioButton.Cross.YesPushDown,e},getCA:function(){return"8"},YesNormal:function(t){var e=Df(t);e.scope=t.scope;var r=[],i=cd.internal.calculateCross(t);return r.push("q"),r.push("1 1 "+Nf(cd.internal.getWidth(t)-2)+" "+Nf(cd.internal.getHeight(t)-2)+" re"),r.push("W"),r.push("n"),r.push(Nf(i.x1.x)+" "+Nf(i.x1.y)+" m"),r.push(Nf(i.x2.x)+" "+Nf(i.x2.y)+" l"),r.push(Nf(i.x4.x)+" "+Nf(i.x4.y)+" m"),r.push(Nf(i.x3.x)+" "+Nf(i.x3.y)+" l"),r.push("s"),r.push("Q"),e.stream=r.join("\n"),e},YesPushDown:function(t){var e=Df(t);e.scope=t.scope;var r=cd.internal.calculateCross(t),i=[];return i.push("0.749023 g"),i.push("0 0 "+Nf(cd.internal.getWidth(t))+" "+Nf(cd.internal.getHeight(t))+" re"),i.push("f"),i.push("q"),i.push("1 1 "+Nf(cd.internal.getWidth(t)-2)+" "+Nf(cd.internal.getHeight(t)-2)+" re"),i.push("W"),i.push("n"),i.push(Nf(r.x1.x)+" "+Nf(r.x1.y)+" m"),i.push(Nf(r.x2.x)+" "+Nf(r.x2.y)+" l"),i.push(Nf(r.x4.x)+" "+Nf(r.x4.y)+" m"),i.push(Nf(r.x3.x)+" "+Nf(r.x3.y)+" l"),i.push("s"),i.push("Q"),e.stream=i.join("\n"),e},OffPushDown:function(t){var e=Df(t);e.scope=t.scope;var r=[];return r.push("0.749023 g"),r.push("0 0 "+Nf(cd.internal.getWidth(t))+" "+Nf(cd.internal.getHeight(t))+" re"),r.push("f"),e.stream=r.join("\n"),e}}},createDefaultAppearanceStream:function(t){var e=t.scope.internal.getFont(t.fontName,t.fontStyle).id,r=t.scope.__private__.encodeColorString(t.color);return"/"+e+" "+t.fontSize+" Tf "+r}};cd.internal={Bezier_C:.551915024494,calculateCross:function(t){var e=cd.internal.getWidth(t),r=cd.internal.getHeight(t),i=Math.min(e,r);return{x1:{x:(e-i)/2,y:(r-i)/2+i},x2:{x:(e-i)/2+i,y:(r-i)/2},x3:{x:(e-i)/2,y:(r-i)/2},x4:{x:(e-i)/2+i,y:(r-i)/2+i}}}},cd.internal.getWidth=function(t){var e=0;return"object"===(0,aa.A)(t)&&(e=Mf(t.Rect[2])),e},cd.internal.getHeight=function(t){var e=0;return"object"===(0,aa.A)(t)&&(e=Mf(t.Rect[3])),e};var ud=Af.addField=function(t){if(function(t,e){if(e.scope=t,void 0!==t.internal&&(void 0===t.internal.acroformPlugin||!1===t.internal.acroformPlugin.isInitialized)){if(Zf.FieldNum=0,t.internal.acroformPlugin=JSON.parse(JSON.stringify(Vf)),t.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("Exception while creating AcroformDictionary");kf=t.internal.scaleFactor,t.internal.acroformPlugin.acroFormDictionaryRoot=new Jf,t.internal.acroformPlugin.acroFormDictionaryRoot.scope=t,t.internal.acroformPlugin.acroFormDictionaryRoot._eventID=t.internal.events.subscribe("postPutResources",function(){!function(t){t.internal.events.unsubscribe(t.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete t.internal.acroformPlugin.acroFormDictionaryRoot._eventID,t.internal.acroformPlugin.printedOut=!0}(t)}),t.internal.events.subscribe("buildDocument",function(){!function(t){t.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var e=t.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var r in e)if(e.hasOwnProperty(r)){var i=e[r];i.objId=void 0,i.hasAnnotation&&Yf(i,t)}}(t)}),t.internal.events.subscribe("putCatalog",function(){!function(t){if(void 0===t.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("putCatalogCallback: Root missing.");t.internal.write("/AcroForm "+t.internal.acroformPlugin.acroFormDictionaryRoot.objId+" 0 R")}(t)}),t.internal.events.subscribe("postPutPages",function(e){!function(t,e){var r=!t;for(var i in t||(e.internal.newObjectDeferredBegin(e.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),e.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),t=t||e.internal.acroformPlugin.acroFormDictionaryRoot.Kids)if(t.hasOwnProperty(i)){var n=t[i],s=[],o=n.Rect;if(n.Rect&&(n.Rect=Uf(n.Rect,e)),e.internal.newObjectDeferredBegin(n.objId,!0),n.DA=cd.createDefaultAppearanceStream(n),"object"===(0,aa.A)(n)&&"function"==typeof n.getKeyValueListForStream&&(s=n.getKeyValueListForStream()),n.Rect=o,n.hasAppearanceStream&&!n.appearanceStreamContent){var a=qf(n);s.push({key:"AP",value:"<</N "+a+">>"}),e.internal.acroformPlugin.xForms.push(a)}if(n.appearanceStreamContent){var h="";for(var l in n.appearanceStreamContent)if(n.appearanceStreamContent.hasOwnProperty(l)){var c=n.appearanceStreamContent[l];if(h+="/"+l+" ",h+="<<",Object.keys(c).length>=1||Array.isArray(c)){for(var i in c)if(c.hasOwnProperty(i)){var u=c[i];"function"==typeof u&&(u=u.call(e,n)),h+="/"+i+" "+u+" ",e.internal.acroformPlugin.xForms.indexOf(u)>=0||e.internal.acroformPlugin.xForms.push(u)}}else"function"==typeof(u=c)&&(u=u.call(e,n)),h+="/"+i+" "+u,e.internal.acroformPlugin.xForms.indexOf(u)>=0||e.internal.acroformPlugin.xForms.push(u);h+=">>"}s.push({key:"AP",value:"<<\n"+h+">>"})}e.internal.putStream({additionalKeyValues:s,objectId:n.objId}),e.internal.out("endobj")}r&&function(t,e){for(var r in t)if(t.hasOwnProperty(r)){var i=r,n=t[r];e.internal.newObjectDeferredBegin(n.objId,!0),"object"===(0,aa.A)(n)&&"function"==typeof n.putStream&&n.putStream(),delete t[i]}}(e.internal.acroformPlugin.xForms,e)}(e,t)}),t.internal.acroformPlugin.isInitialized=!0}}(this,t),!(t instanceof Zf))throw new Error("Invalid argument passed to jsPDF.addField.");var e;return(e=t).scope.internal.acroformPlugin.printedOut&&(e.scope.internal.acroformPlugin.printedOut=!1,e.scope.internal.acroformPlugin.acroFormDictionaryRoot=null),e.scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(e),t.page=t.scope.internal.getCurrentPageInfo().pageNumber,this};function fd(t){return t.reduce(function(t,e,r){return t[e]=r,t},{})}Af.AcroFormChoiceField=Qf,Af.AcroFormListBox=td,Af.AcroFormComboBox=ed,Af.AcroFormEditBox=rd,Af.AcroFormButton=id,Af.AcroFormPushButton=nd,Af.AcroFormRadioButton=sd,Af.AcroFormCheckBox=ad,Af.AcroFormTextField=hd,Af.AcroFormPasswordField=ld,Af.AcroFormAppearance=cd,Af.AcroForm={ChoiceField:Qf,ListBox:td,ComboBox:ed,EditBox:rd,Button:id,PushButton:nd,RadioButton:sd,CheckBox:ad,TextField:hd,PasswordField:ld,Appearance:cd},Cf.AcroForm={ChoiceField:Qf,ListBox:td,ComboBox:ed,EditBox:rd,Button:id,PushButton:nd,RadioButton:sd,CheckBox:ad,TextField:hd,PasswordField:ld,Appearance:cd},Cf.AcroForm,function(t){var e="addImage_";t.__addimage__={};var r="UNKNOWN",i={PNG:[[137,80,78,71]],TIFF:[[77,77,0,42],[73,73,42,0]],JPEG:[[255,216,255,224,void 0,void 0,74,70,73,70,0],[255,216,255,225,void 0,void 0,69,120,105,102,0,0],[255,216,255,219],[255,216,255,238]],JPEG2000:[[0,0,0,12,106,80,32,32]],GIF87a:[[71,73,70,56,55,97]],GIF89a:[[71,73,70,56,57,97]],WEBP:[[82,73,70,70,void 0,void 0,void 0,void 0,87,69,66,80]],BMP:[[66,77],[66,65],[67,73],[67,80],[73,67],[80,84]]},n=t.__addimage__.getImageFileTypeByImageData=function(t,e){var n,s,o,a,h,l=r;if("RGBA"===(e=e||r)||void 0!==t.data&&t.data instanceof Uint8ClampedArray&&"height"in t&&"width"in t)return"RGBA";if(x(t))for(h in i)for(o=i[h],n=0;n<o.length;n+=1){for(a=!0,s=0;s<o[n].length;s+=1)if(void 0!==o[n][s]&&o[n][s]!==t[s]){a=!1;break}if(!0===a){l=h;break}}else for(h in i)for(o=i[h],n=0;n<o.length;n+=1){for(a=!0,s=0;s<o[n].length;s+=1)if(void 0!==o[n][s]&&o[n][s]!==t.charCodeAt(s)){a=!1;break}if(!0===a){l=h;break}}return l===r&&e!==r&&(l=e),l},s=function t(e){for(var r=this.internal.write,i=this.internal.putStream,n=(0,this.internal.getFilters)();-1!==n.indexOf("FlateEncode");)n.splice(n.indexOf("FlateEncode"),1);e.objectId=this.internal.newObject();var s=[];if(s.push({key:"Type",value:"/XObject"}),s.push({key:"Subtype",value:"/Image"}),s.push({key:"Width",value:e.width}),s.push({key:"Height",value:e.height}),e.colorSpace===v.INDEXED?s.push({key:"ColorSpace",value:"[/Indexed /DeviceRGB "+(e.palette.length/3-1)+" "+("sMask"in e&&void 0!==e.sMask?e.objectId+2:e.objectId+1)+" 0 R]"}):(s.push({key:"ColorSpace",value:"/"+e.colorSpace}),e.colorSpace===v.DEVICE_CMYK&&s.push({key:"Decode",value:"[1 0 1 0 1 0 1 0]"})),s.push({key:"BitsPerComponent",value:e.bitsPerComponent}),"decodeParameters"in e&&void 0!==e.decodeParameters&&s.push({key:"DecodeParms",value:"<<"+e.decodeParameters+">>"}),"transparency"in e&&Array.isArray(e.transparency)&&e.transparency.length>0){for(var o="",a=0,h=e.transparency.length;a<h;a++)o+=e.transparency[a]+" "+e.transparency[a]+" ";s.push({key:"Mask",value:"["+o+"]"})}void 0!==e.sMask&&s.push({key:"SMask",value:e.objectId+1+" 0 R"});var l=void 0!==e.filter?["/"+e.filter]:void 0;if(i({data:e.data,additionalKeyValues:s,alreadyAppliedFilters:l,objectId:e.objectId}),r("endobj"),"sMask"in e&&void 0!==e.sMask){var c,u=null!==(c=e.sMaskBitsPerComponent)&&void 0!==c?c:e.bitsPerComponent,f={width:e.width,height:e.height,colorSpace:"DeviceGray",bitsPerComponent:u,data:e.sMask};"filter"in e&&(f.decodeParameters="/Predictor ".concat(e.predictor," /Colors 1 /BitsPerComponent ").concat(u," /Columns ").concat(e.width),f.filter=e.filter),t.call(this,f)}if(e.colorSpace===v.INDEXED){var d=this.internal.newObject();i({data:C(new Uint8Array(e.palette)),objectId:d}),r("endobj")}},o=function(){var t=this.internal.collections[e+"images"];for(var r in t)s.call(this,t[r])},a=function(){var t,r=this.internal.collections[e+"images"],i=this.internal.write;for(var n in r)i("/I"+(t=r[n]).index,t.objectId,"0","R")},h=function(){this.internal.collections[e+"images"]||(this.internal.collections[e+"images"]={},this.internal.events.subscribe("putResources",o),this.internal.events.subscribe("putXobjectDict",a))},l=function(){var t=this.internal.collections[e+"images"];return h.call(this),t},c=function(){return Object.keys(this.internal.collections[e+"images"]).length},u=function(e){return"function"==typeof t["process"+e.toUpperCase()]},f=function(t){return"object"===(0,aa.A)(t)&&1===t.nodeType},d=function(e,r){if("IMG"===e.nodeName&&e.hasAttribute("src")){var i=""+e.getAttribute("src");if(0===i.indexOf("data:image/"))return Zu(unescape(i).split("base64,").pop());var n=t.loadFile(i,!0);if(void 0!==n)return n}if("CANVAS"===e.nodeName){if(0===e.width||0===e.height)throw new Error("Given canvas must have data. Canvas width: "+e.width+", height: "+e.height);var s;switch(r){case"PNG":s="image/png";break;case"WEBP":s="image/webp";break;default:s="image/jpeg"}return Zu(e.toDataURL(s,1).split("base64,").pop())}},p=function(t){var r=this.internal.collections[e+"images"];if(r)for(var i in r)if(t===r[i].alias)return r[i]},g=function(t,e,r){return t||e||(t=-96,e=-96),t<0&&(t=-1*r.width*72/t/this.internal.scaleFactor),e<0&&(e=-1*r.height*72/e/this.internal.scaleFactor),0===t&&(t=e*r.width/r.height),0===e&&(e=t*r.height/r.width),[t,e]},m=function(t,e,r,i,n,s){var o=g.call(this,r,i,n),a=this.internal.getCoordinateString,h=this.internal.getVerticalCoordinateString,c=l.call(this);if(r=o[0],i=o[1],c[n.index]=n,s){s*=Math.PI/180;var u=Math.cos(s),f=Math.sin(s),d=function(t){return t.toFixed(4)},p=[d(u),d(f),d(-1*f),d(u),0,0,"cm"]}this.internal.write("q"),s?(this.internal.write([1,"0","0",1,a(t),h(e+i),"cm"].join(" ")),this.internal.write(p.join(" ")),this.internal.write([a(r),"0","0",a(i),"0","0","cm"].join(" "))):this.internal.write([a(r),"0","0",a(i),a(t),h(e+i),"cm"].join(" ")),this.isAdvancedAPI()&&this.internal.write([1,0,0,-1,0,0,"cm"].join(" ")),this.internal.write("/I"+n.index+" Do"),this.internal.write("Q")},v=t.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPARATION:"Separation",DEVICE_N:"DeviceN"};t.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"};var y=t.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},b=t.__addimage__.sHashCode=function(t){var e,r,i=0;if("string"==typeof t)for(r=t.length,e=0;e<r;e++)i=(i<<5)-i+t.charCodeAt(e),i|=0;else if(x(t))for(r=t.byteLength/2,e=0;e<r;e++)i=(i<<5)-i+t[e],i|=0;return i},w=t.__addimage__.validateStringAsBase64=function(t){(t=t||"").toString().trim();var e=!0;return 0===t.length&&(e=!1),t.length%4!=0&&(e=!1),!1===/^[A-Za-z0-9+/]+$/.test(t.substr(0,t.length-2))&&(e=!1),!1===/^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test(t.substr(-2))&&(e=!1),e},_=t.__addimage__.extractImageFromDataUrl=function(t){if(null==t)return null;if(!(t=t.trim()).startsWith("data:"))return null;var e=t.indexOf(",");return e<0?null:t.substring(0,e).trim().endsWith("base64")?t.substring(e+1):null};t.__addimage__.isArrayBuffer=function(t){return t instanceof ArrayBuffer};var x=t.__addimage__.isArrayBufferView=function(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array},S=t.__addimage__.binaryStringToUint8Array=function(t){for(var e=t.length,r=new Uint8Array(e),i=0;i<e;i++)r[i]=t.charCodeAt(i);return r},C=t.__addimage__.arrayBufferToBinaryString=function(t){for(var e="",r=x(t)?t:new Uint8Array(t),i=0;i<r.length;i+=8192)e+=String.fromCharCode.apply(null,r.subarray(i,i+8192));return e};t.addImage=function(){var t,e,i,n,s,o,a,l,c;if("number"==typeof arguments[1]?(e=r,i=arguments[1],n=arguments[2],s=arguments[3],o=arguments[4],a=arguments[5],l=arguments[6],c=arguments[7]):(e=arguments[1],i=arguments[2],n=arguments[3],s=arguments[4],o=arguments[5],a=arguments[6],l=arguments[7],c=arguments[8]),"object"===(0,aa.A)(t=arguments[0])&&!f(t)&&"imageData"in t){var u=t;t=u.imageData,e=u.format||e||r,i=u.x||i||0,n=u.y||n||0,s=u.w||u.width||s,o=u.h||u.height||o,a=u.alias||a,l=u.compression||l,c=u.rotation||u.angle||c}var d=this.internal.getFilters();if(void 0===l&&-1!==d.indexOf("FlateEncode")&&(l="SLOW"),isNaN(i)||isNaN(n))throw new Error("Invalid coordinates passed to jsPDF.addImage");h.call(this);var p=A.call(this,t,e,a,l);return m.call(this,i,n,s,o,p,c),this};var A=function(e,i,s,o){var a,h,l;if("string"==typeof e&&n(e)===r){e=unescape(e);var g=k(e,!1);(""!==g||void 0!==(g=t.loadFile(e,!0)))&&(e=g)}if(f(e)&&(e=d(e,i)),i=n(e,i),!u(i))throw new Error("addImage does not support files of type '"+i+"', please ensure that a plugin for '"+i+"' support is added.");if((null==(l=s)||0===l.length)&&(s=function(t){return"string"==typeof t||x(t)?b(t):x(t.data)?b(t.data):null}(e)),(a=p.call(this,s))||(e instanceof Uint8Array||"RGBA"===i||(h=e,e=S(e)),a=this["process"+i.toUpperCase()](e,c.call(this),s,function(e){return e&&"string"==typeof e&&(e=e.toUpperCase()),e in t.image_compression?e:y.NONE}(o),h)),!a)throw new Error("An unknown error occurred whilst processing the image.");return a},k=t.__addimage__.convertBase64ToBinaryString=function(t,e){e="boolean"!=typeof e||e;var r,i="";if("string"==typeof t){var n;r=null!==(n=_(t))&&void 0!==n?n:t;try{i=Zu(r)}catch(t){if(e)throw w(r)?new Error("atob-Error in jsPDF.convertBase64ToBinaryString "+t.message):new Error("Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString ")}}return i};t.getImageProperties=function(e){var i,s,o="";if(f(e)&&(e=d(e)),"string"==typeof e&&n(e)===r&&(""===(o=k(e,!1))&&(o=t.loadFile(e)||""),e=o),s=n(e),!u(s))throw new Error("addImage does not support files of type '"+s+"', please ensure that a plugin for '"+s+"' support is added.");if(e instanceof Uint8Array||(e=S(e)),!(i=this["process"+s.toUpperCase()](e)))throw new Error("An unknown error occurred whilst processing the image");return i.fileType=s,i}}(Cf.API),function(t){var e=function(t){if(void 0!==t&&""!=t)return!0};Cf.API.events.push(["addPage",function(t){this.internal.getPageInfo(t.pageNumber).pageContext.annotations=[]}]),t.events.push(["putPage",function(t){for(var r,i,n,s=this.internal.getCoordinateString,o=this.internal.getVerticalCoordinateString,a=this.internal.getPageInfoByObjId(t.objId),h=t.pageContext.annotations,l=!1,c=0;c<h.length&&!l;c++)switch((r=h[c]).type){case"link":(e(r.options.url)||e(r.options.pageNumber))&&(l=!0);break;case"reference":case"text":case"freetext":l=!0}if(0!=l){this.internal.write("/Annots [");for(var u=0;u<h.length;u++){r=h[u];var f=this.internal.pdfEscape,d=this.internal.getEncryptor(t.objId);switch(r.type){case"reference":this.internal.write(" "+r.object.objId+" 0 R ");break;case"text":var p=this.internal.newAdditionalObject(),g=this.internal.newAdditionalObject(),m=this.internal.getEncryptor(p.objId),v=r.title||"Note";n="<</Type /Annot /Subtype /Text "+(i="/Rect ["+s(r.bounds.x)+" "+o(r.bounds.y+r.bounds.h)+" "+s(r.bounds.x+r.bounds.w)+" "+o(r.bounds.y)+"] ")+"/Contents ("+f(m(r.contents))+")",n+=" /Popup "+g.objId+" 0 R",n+=" /P "+a.objId+" 0 R",n+=" /T ("+f(m(v))+") >>",p.content=n;var y=p.objId+" 0 R";n="<</Type /Annot /Subtype /Popup "+(i="/Rect ["+s(r.bounds.x+30)+" "+o(r.bounds.y+r.bounds.h)+" "+s(r.bounds.x+r.bounds.w+30)+" "+o(r.bounds.y)+"] ")+" /Parent "+y,r.open&&(n+=" /Open true"),n+=" >>",g.content=n,this.internal.write(p.objId,"0 R",g.objId,"0 R");break;case"freetext":i="/Rect ["+s(r.bounds.x)+" "+o(r.bounds.y)+" "+s(r.bounds.x+r.bounds.w)+" "+o(r.bounds.y+r.bounds.h)+"] ";var b="font: Helvetica,sans-serif 12.0pt; text-align:left; color:#"+(r.color||"#000000");n="<</Type /Annot /Subtype /FreeText "+i+"/Contents ("+f(d(r.contents))+")",n+=" /DS("+f(d(b))+")",n+=" /Border [0 0 0]",n+=" >>",this.internal.write(n);break;case"link":if(r.options.name){var w=this.annotations._nameMap[r.options.name];r.options.pageNumber=w.page,r.options.top=w.y}else r.options.top||(r.options.top=0);if(i="/Rect ["+r.finalBounds.x+" "+r.finalBounds.y+" "+r.finalBounds.w+" "+r.finalBounds.h+"] ",n="",r.options.url)n="<</Type /Annot /Subtype /Link "+i+"/Border [0 0 0] /A <</S /URI /URI ("+f(d(r.options.url))+") >>";else if(r.options.pageNumber)switch(n="<</Type /Annot /Subtype /Link "+i+"/Border [0 0 0] /Dest ["+this.internal.getPageInfo(r.options.pageNumber).objId+" 0 R",r.options.magFactor=r.options.magFactor||"XYZ",r.options.magFactor){case"Fit":n+=" /Fit]";break;case"FitH":n+=" /FitH "+r.options.top+"]";break;case"FitV":r.options.left=r.options.left||0,n+=" /FitV "+r.options.left+"]";break;default:var _=o(r.options.top);r.options.left=r.options.left||0,void 0===r.options.zoom&&(r.options.zoom=0),n+=" /XYZ "+r.options.left+" "+_+" "+r.options.zoom+"]"}""!=n&&(n+=" >>",this.internal.write(n))}}this.internal.write("]")}}]),t.createAnnotation=function(t){var e=this.internal.getCurrentPageInfo();switch(t.type){case"link":this.link(t.bounds.x,t.bounds.y,t.bounds.w,t.bounds.h,t);break;case"text":case"freetext":e.pageContext.annotations.push(t)}},t.link=function(t,e,r,i,n){var s=this.internal.getCurrentPageInfo(),o=this.internal.getCoordinateString,a=this.internal.getVerticalCoordinateString;s.pageContext.annotations.push({finalBounds:{x:o(t),y:a(e),w:o(t+r),h:a(e+i)},options:n,type:"link"})},t.textWithLink=function(t,e,r,i){var n,s,o=this.getTextWidth(t),a=this.internal.getLineHeight()/this.internal.scaleFactor;if(void 0!==i.maxWidth){s=i.maxWidth;var h=this.splitTextToSize(t,s).length;n=Math.ceil(a*h)}else s=o,n=a;return this.text(t,e,r,i),r+=.2*a,"center"===i.align&&(e-=o/2),"right"===i.align&&(e-=o),this.link(e,r-a,s,n,i),o},t.getTextWidth=function(t){var e=this.internal.getFontSize();return this.getStringUnitWidth(t)*e/this.internal.scaleFactor}}(Cf.API),function(t){var e={1569:[65152],1570:[65153,65154],1571:[65155,65156],1572:[65157,65158],1573:[65159,65160],1574:[65161,65162,65163,65164],1575:[65165,65166],1576:[65167,65168,65169,65170],1577:[65171,65172],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194],1584:[65195,65196],1585:[65197,65198],1586:[65199,65200],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1649:[64336,64337],1655:[64477],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393],1676:[64388,64389],1677:[64386,64387],1678:[64390,64391],1681:[64396,64397],1688:[64394,64395],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421],1729:[64422,64423,64424,64425],1733:[64480,64481],1734:[64473,64474],1735:[64471,64472],1736:[64475,64476],1737:[64482,64483],1739:[64478,64479],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431],1747:[64432,64433]},r={65247:{65154:65269,65156:65271,65160:65273,65166:65275},65248:{65154:65270,65156:65272,65160:65274,65166:65276},65165:{65247:{65248:{65258:65010}}},1617:{1612:64606,1613:64607,1614:64608,1615:64609,1616:64610}},i={1612:64606,1613:64607,1614:64608,1615:64609,1616:64610},n=[1570,1571,1573,1575];t.__arabicParser__={};var s=t.__arabicParser__.isInArabicSubstitutionA=function(t){return void 0!==e[t.charCodeAt(0)]},o=t.__arabicParser__.isArabicLetter=function(t){return"string"==typeof t&&/^[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]+$/.test(t)},a=t.__arabicParser__.isArabicEndLetter=function(t){return o(t)&&s(t)&&e[t.charCodeAt(0)].length<=2},h=t.__arabicParser__.isArabicAlfLetter=function(t){return o(t)&&n.indexOf(t.charCodeAt(0))>=0};t.__arabicParser__.arabicLetterHasIsolatedForm=function(t){return o(t)&&s(t)&&e[t.charCodeAt(0)].length>=1};var l=t.__arabicParser__.arabicLetterHasFinalForm=function(t){return o(t)&&s(t)&&e[t.charCodeAt(0)].length>=2};t.__arabicParser__.arabicLetterHasInitialForm=function(t){return o(t)&&s(t)&&e[t.charCodeAt(0)].length>=3};var c=t.__arabicParser__.arabicLetterHasMedialForm=function(t){return o(t)&&s(t)&&4==e[t.charCodeAt(0)].length},u=t.__arabicParser__.resolveLigatures=function(t){var e=0,i=r,n="",s=0;for(e=0;e<t.length;e+=1)void 0!==i[t.charCodeAt(e)]?(s++,"number"==typeof(i=i[t.charCodeAt(e)])&&(n+=String.fromCharCode(i),i=r,s=0),e===t.length-1&&(i=r,n+=t.charAt(e-(s-1)),e-=s-1,s=0)):(i=r,n+=t.charAt(e-s),e-=s,s=0);return n};t.__arabicParser__.isArabicDiacritic=function(t){return void 0!==t&&void 0!==i[t.charCodeAt(0)]};var f=t.__arabicParser__.getCorrectForm=function(t,e,r){return o(t)?!1===s(t)?-1:!l(t)||!o(e)&&!o(r)||!o(r)&&a(e)||a(t)&&!o(e)||a(t)&&h(e)||a(t)&&a(e)?0:c(t)&&o(e)&&!a(e)&&o(r)&&l(r)?3:a(t)||!o(r)?1:2:-1},d=function(t){var r=0,i=0,n=0,s="",a="",h="",l=(t=t||"").split("\\s+"),c=[];for(r=0;r<l.length;r+=1){for(c.push(""),i=0;i<l[r].length;i+=1)s=l[r][i],a=l[r][i-1],h=l[r][i+1],o(s)?(n=f(s,a,h),c[r]+=-1!==n?String.fromCharCode(e[s.charCodeAt(0)][n]):s):c[r]+=s;c[r]=u(c[r])}return c.join(" ")},p=t.__arabicParser__.processArabic=t.processArabic=function(){var t,e="string"==typeof arguments[0]?arguments[0]:arguments[0].text,r=[];if(Array.isArray(e)){var i=0;for(r=[],i=0;i<e.length;i+=1)Array.isArray(e[i])?r.push([d(e[i][0]),e[i][1],e[i][2]]):r.push([d(e[i])]);t=r}else t=d(e);return"string"==typeof arguments[0]?t:(arguments[0].text=t,arguments[0])};t.events.push(["preProcessText",p])}(Cf.API),Cf.API.autoPrint=function(t){var e;return(t=t||{}).variant=t.variant||"non-conform","javascript"===t.variant?this.addJS("print({});"):(this.internal.events.subscribe("postPutResources",function(){e=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/S /Named"),this.internal.out("/Type /Action"),this.internal.out("/N /Print"),this.internal.out(">>"),this.internal.out("endobj")}),this.internal.events.subscribe("putCatalog",function(){this.internal.out("/OpenAction "+e+" 0 R")})),this},function(t){var e=function(){var t=void 0;Object.defineProperty(this,"pdf",{get:function(){return t},set:function(e){t=e}});var e=150;Object.defineProperty(this,"width",{get:function(){return e},set:function(t){e=isNaN(t)||!1===Number.isInteger(t)||t<0?150:t,this.getContext("2d").pageWrapXEnabled&&(this.getContext("2d").pageWrapX=e+1)}});var r=300;Object.defineProperty(this,"height",{get:function(){return r},set:function(t){r=isNaN(t)||!1===Number.isInteger(t)||t<0?300:t,this.getContext("2d").pageWrapYEnabled&&(this.getContext("2d").pageWrapY=r+1)}});var i=[];Object.defineProperty(this,"childNodes",{get:function(){return i},set:function(t){i=t}});var n={};Object.defineProperty(this,"style",{get:function(){return n},set:function(t){n=t}}),Object.defineProperty(this,"parentNode",{})};e.prototype.getContext=function(t,e){var r;if("2d"!==(t=t||"2d"))return null;for(r in e)this.pdf.context2d.hasOwnProperty(r)&&(this.pdf.context2d[r]=e[r]);return this.pdf.context2d._canvas=this,this.pdf.context2d},e.prototype.toDataURL=function(){throw new Error("toDataURL is not implemented.")},t.events.push(["initialized",function(){this.canvas=new e,this.canvas.pdf=this}])}(Cf.API),function(t){var e={left:0,top:0,bottom:0,right:0},r=!1,i=function(){void 0===this.internal.__cell__&&(this.internal.__cell__={},this.internal.__cell__.padding=3,this.internal.__cell__.headerFunction=void 0,this.internal.__cell__.margins=Object.assign({},e),this.internal.__cell__.margins.width=this.getPageWidth(),n.call(this))},n=function(){this.internal.__cell__.lastCell=new s,this.internal.__cell__.pages=1},s=function(){var t=arguments[0];Object.defineProperty(this,"x",{enumerable:!0,get:function(){return t},set:function(e){t=e}});var e=arguments[1];Object.defineProperty(this,"y",{enumerable:!0,get:function(){return e},set:function(t){e=t}});var r=arguments[2];Object.defineProperty(this,"width",{enumerable:!0,get:function(){return r},set:function(t){r=t}});var i=arguments[3];Object.defineProperty(this,"height",{enumerable:!0,get:function(){return i},set:function(t){i=t}});var n=arguments[4];Object.defineProperty(this,"text",{enumerable:!0,get:function(){return n},set:function(t){n=t}});var s=arguments[5];Object.defineProperty(this,"lineNumber",{enumerable:!0,get:function(){return s},set:function(t){s=t}});var o=arguments[6];return Object.defineProperty(this,"align",{enumerable:!0,get:function(){return o},set:function(t){o=t}}),this};s.prototype.clone=function(){return new s(this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align)},s.prototype.toArray=function(){return[this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align]},t.setHeaderFunction=function(t){return i.call(this),this.internal.__cell__.headerFunction="function"==typeof t?t:void 0,this},t.getTextDimensions=function(t,e){i.call(this);var r=(e=e||{}).fontSize||this.getFontSize(),n=e.font||this.getFont(),s=e.scaleFactor||this.internal.scaleFactor,o=0,a=0,h=0,l=this;if(!Array.isArray(t)&&"string"!=typeof t){if("number"!=typeof t)throw new Error("getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.");t=String(t)}var c=e.maxWidth;c>0?"string"==typeof t?t=this.splitTextToSize(t,c):"[object Array]"===Object.prototype.toString.call(t)&&(t=t.reduce(function(t,e){return t.concat(l.splitTextToSize(e,c))},[])):t=Array.isArray(t)?t:[t];for(var u=0;u<t.length;u++)o<(h=this.getStringUnitWidth(t[u],{font:n})*r)&&(o=h);return 0!==o&&(a=t.length),{w:o/=s,h:Math.max((a*r*this.getLineHeightFactor()-r*(this.getLineHeightFactor()-1))/s,0)}},t.cellAddPage=function(){i.call(this),this.addPage();var t=this.internal.__cell__.margins||e;return this.internal.__cell__.lastCell=new s(t.left,t.top,void 0,void 0),this.internal.__cell__.pages+=1,this};var o=t.cell=function(){var t;t=arguments[0]instanceof s?arguments[0]:new s(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]),i.call(this);var n=this.internal.__cell__.lastCell,o=this.internal.__cell__.padding,a=this.internal.__cell__.margins||e,h=this.internal.__cell__.tableHeaderRow,l=this.internal.__cell__.printHeaders;return void 0!==n.lineNumber&&(n.lineNumber===t.lineNumber?(t.x=(n.x||0)+(n.width||0),t.y=n.y||0):n.y+n.height+t.height+a.bottom>this.getPageHeight()?(this.cellAddPage(),t.y=a.top,l&&h&&(this.printHeaderRow(t.lineNumber,!0),t.y+=h[0].height)):t.y=n.y+n.height||t.y),void 0!==t.text[0]&&(this.rect(t.x,t.y,t.width,t.height,!0===r?"FD":void 0),"right"===t.align?this.text(t.text,t.x+t.width-o,t.y+o,{align:"right",baseline:"top"}):"center"===t.align?this.text(t.text,t.x+t.width/2,t.y+o,{align:"center",baseline:"top",maxWidth:t.width-o-o}):this.text(t.text,t.x+o,t.y+o,{align:"left",baseline:"top",maxWidth:t.width-o-o})),this.internal.__cell__.lastCell=t,this};t.table=function(t,r,h,l,c){if(i.call(this),!h)throw new Error("No data for PDF table.");var u,f,d,p,g=[],m=[],v=[],y={},b={},w=[],_=[],x=(c=c||{}).autoSize||!1,S=!1!==c.printHeaders,C=c.css&&void 0!==c.css["font-size"]?16*c.css["font-size"]:c.fontSize||12,A=c.margins||Object.assign({width:this.getPageWidth()},e),k="number"==typeof c.padding?c.padding:3,L=c.headerBackgroundColor||"#c8c8c8",T=c.headerTextColor||"#000";if(n.call(this),this.internal.__cell__.printHeaders=S,this.internal.__cell__.margins=A,this.internal.__cell__.table_font_size=C,this.internal.__cell__.padding=k,this.internal.__cell__.headerBackgroundColor=L,this.internal.__cell__.headerTextColor=T,this.setFontSize(C),null==l)m=g=Object.keys(h[0]),v=g.map(function(){return"left"});else if(Array.isArray(l)&&"object"===(0,aa.A)(l[0]))for(g=l.map(function(t){return t.name}),m=l.map(function(t){return t.prompt||t.name||""}),v=l.map(function(t){return t.align||"left"}),u=0;u<l.length;u+=1)b[l[u].name]=.7499990551181103*l[u].width;else Array.isArray(l)&&"string"==typeof l[0]&&(m=g=l,v=g.map(function(){return"left"}));if(x||Array.isArray(l)&&"string"==typeof l[0])for(u=0;u<g.length;u+=1){for(y[p=g[u]]=h.map(function(t){return t[p]}),this.setFont(void 0,"bold"),w.push(this.getTextDimensions(m[u],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w),f=y[p],this.setFont(void 0,"normal"),d=0;d<f.length;d+=1)w.push(this.getTextDimensions(f[d],{fontSize:this.internal.__cell__.table_font_size,scaleFactor:this.internal.scaleFactor}).w);b[p]=Math.max.apply(null,w)+k+k,w=[]}if(S){var P={};for(u=0;u<g.length;u+=1)P[g[u]]={},P[g[u]].text=m[u],P[g[u]].align=v[u];var N=a.call(this,P,b);_=g.map(function(e){return new s(t,r,b[e],N,P[e].text,void 0,P[e].align)}),this.setTableHeaderRow(_),this.printHeaderRow(1,!1)}var O=l.reduce(function(t,e){return t[e.name]=e.align,t},{});for(u=0;u<h.length;u+=1){"rowStart"in c&&c.rowStart instanceof Function&&c.rowStart({row:u,data:h[u]},this);var E=a.call(this,h[u],b);for(d=0;d<g.length;d+=1){var M=h[u][g[d]];"cellStart"in c&&c.cellStart instanceof Function&&c.cellStart({row:u,col:d,data:M},this),o.call(this,new s(t,r,b[g[d]],E,M,u+2,O[g[d]]))}}return this.internal.__cell__.table_x=t,this.internal.__cell__.table_y=r,this};var a=function(t,e){var r=this.internal.__cell__.padding,i=this.internal.__cell__.table_font_size,n=this.internal.scaleFactor;return Object.keys(t).map(function(i){var n=t[i];return this.splitTextToSize(n.hasOwnProperty("text")?n.text:n,e[i]-r-r)},this).map(function(t){return this.getLineHeightFactor()*t.length*i/n+r+r},this).reduce(function(t,e){return Math.max(t,e)},0)};t.setTableHeaderRow=function(t){i.call(this),this.internal.__cell__.tableHeaderRow=t},t.printHeaderRow=function(t,e){if(i.call(this),!this.internal.__cell__.tableHeaderRow)throw new Error("Property tableHeaderRow does not exist.");var n;if(r=!0,"function"==typeof this.internal.__cell__.headerFunction){var a=this.internal.__cell__.headerFunction(this,this.internal.__cell__.pages);this.internal.__cell__.lastCell=new s(a[0],a[1],a[2],a[3],void 0,-1)}this.setFont(void 0,"bold");for(var h=[],l=0;l<this.internal.__cell__.tableHeaderRow.length;l+=1){n=this.internal.__cell__.tableHeaderRow[l].clone(),e&&(n.y=this.internal.__cell__.margins.top||0,h.push(n)),n.lineNumber=t;var c=this.getTextColor();this.setTextColor(this.internal.__cell__.headerTextColor),this.setFillColor(this.internal.__cell__.headerBackgroundColor),o.call(this,n),this.setTextColor(c)}h.length>0&&this.setTableHeaderRow(h),this.setFont(void 0,"normal"),r=!1}}(Cf.API);var dd={italic:["italic","oblique","normal"],oblique:["oblique","italic","normal"],normal:["normal","oblique","italic"]},pd=["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"],gd=fd(pd),md=[100,200,300,400,500,600,700,800,900],vd=fd(md);function yd(t){var e=t.family.replace(/"|'/g,"").toLowerCase(),r=function(t){return dd[t=t||"normal"]?t:"normal"}(t.style),i=function(t){return t?"number"==typeof t?t>=100&&t<=900&&t%100==0?t:400:/^\d00$/.test(t)?parseInt(t):"bold"===t?700:400:400}(t.weight),n=function(t){return"number"==typeof gd[t=t||"normal"]?t:"normal"}(t.stretch);return{family:e,style:r,weight:i,stretch:n,src:t.src||[],ref:t.ref||{name:e,style:[n,r,i].join(" ")}}}function bd(t,e,r,i){var n;for(n=r;n>=0&&n<e.length;n+=i)if(t[e[n]])return t[e[n]];for(n=r;n>=0&&n<e.length;n-=i)if(t[e[n]])return t[e[n]]}var wd={"sans-serif":"helvetica",fixed:"courier",monospace:"courier",terminal:"courier",cursive:"times",fantasy:"times",serif:"times"},_d={caption:"times",icon:"times",menu:"times","message-box":"times","small-caption":"times","status-bar":"times"};function xd(t){return[t.stretch,t.style,t.weight,t.family].join(" ")}function Sd(t){return t.trimLeft()}function Cd(t,e){for(var r=0;r<t.length;){if(t.charAt(r)===e)return[t.substring(0,r),t.substring(r+1)];r+=1}return null}function Ad(t){var e=t.match(/^(-[a-z_]|[a-z_])[a-z0-9_-]*/i);return null===e?null:[e[0],t.substring(e[0].length)]}var kd,Ld,Td,Pd,Nd,Od=["times"];function Ed(t,e,r,i,n){var s=4,o=Fd;switch(n){case Cf.API.image_compression.FAST:s=1,o=Dd;break;case Cf.API.image_compression.MEDIUM:s=6,o=jd;break;case Cf.API.image_compression.SLOW:s=9,o=Id}t=function(t,e,r,i){for(var n,s=t.length/e,o=new Uint8Array(t.length+s),a=[Md,Dd,Fd,jd,Id],h=0;h<s;h+=1){var l=h*e,c=t.subarray(l,l+e);if(i)o.set(i(c,r,n),l+h);else{for(var u=a.length,f=[],d=0;d<u;d+=1)f[d]=a[d](c,r,n);var p=Rd(f.concat());o.set(f[p],l+h)}n=c}return o}(t,e,Math.ceil(r*i/8),o);var a=qa(t,{level:s});return Cf.API.__addimage__.arrayBufferToBinaryString(a)}function Md(t){var e=Array.apply([],t);return e.unshift(0),e}function Dd(t,e){var r=t.length,i=[];i[0]=1;for(var n=0;n<r;n+=1){var s=t[n-e]||0;i[n+1]=t[n]-s+256&255}return i}function Fd(t,e,r){var i=t.length,n=[];n[0]=2;for(var s=0;s<i;s+=1){var o=r&&r[s]||0;n[s+1]=t[s]-o+256&255}return n}function jd(t,e,r){var i=t.length,n=[];n[0]=3;for(var s=0;s<i;s+=1){var o=t[s-e]||0,a=r&&r[s]||0;n[s+1]=t[s]+256-(o+a>>>1)&255}return n}function Id(t,e,r){var i=t.length,n=[];n[0]=4;for(var s=0;s<i;s+=1){var o=Bd(t[s-e]||0,r&&r[s]||0,r&&r[s-e]||0);n[s+1]=t[s]-o+256&255}return n}function Bd(t,e,r){if(t===e&&e===r)return t;var i=Math.abs(e-r),n=Math.abs(t-r),s=Math.abs(t+e-r-r);return i<=n&&i<=s?t:n<=s?e:r}function Rd(t){var e=t.map(function(t){return t.reduce(function(t,e){return t+Math.abs(e)},0)});return e.indexOf(Math.min.apply(null,e))}function zd(t,e,r){var i=e*r,n=Math.floor(i/8),s=16-(i-8*n+r),o=(1<<r)-1;return qd(t,n)>>s&o}function Ud(t,e,r,i){var n=r*i,s=Math.floor(n/8),o=16-(n-8*s+i),a=(1<<i)-1,h=(e&a)<<o;!function(t,e,r){if(e+1<t.byteLength)t.setUint16(e,r,!1);else{var i=r>>8&255;t.setUint8(e,i)}}(t,s,qd(t,s)&~(a<<o)&65535|h)}function qd(t,e){return e+1<t.byteLength?t.getUint16(e,!1):t.getUint8(e)<<8}function Wd(t){var e=0;if(71!==t[e++]||73!==t[e++]||70!==t[e++]||56!==t[e++]||56!=(t[e++]+1&253)||97!==t[e++])throw new Error("Invalid GIF 87a/89a header.");var r=t[e++]|t[e++]<<8,i=t[e++]|t[e++]<<8,n=t[e++],s=n>>7,o=1<<1+(7&n);t[e++],t[e++];var a=null,h=null;s&&(a=e,h=o,e+=3*o);var l=!0,c=[],u=0,f=null,d=0,p=null;for(this.width=r,this.height=i;l&&e<t.length;)switch(t[e++]){case 33:switch(t[e++]){case 255:if(11!==t[e]||78==t[e+1]&&69==t[e+2]&&84==t[e+3]&&83==t[e+4]&&67==t[e+5]&&65==t[e+6]&&80==t[e+7]&&69==t[e+8]&&50==t[e+9]&&46==t[e+10]&&48==t[e+11]&&3==t[e+12]&&1==t[e+13]&&0==t[e+16])e+=14,p=t[e++]|t[e++]<<8,e++;else for(e+=12;;){if(!((L=t[e++])>=0))throw Error("Invalid block size");if(0===L)break;e+=L}break;case 249:if(4!==t[e++]||0!==t[e+4])throw new Error("Invalid graphics extension block.");var g=t[e++];u=t[e++]|t[e++]<<8,f=t[e++],1&g||(f=null),d=g>>2&7,e++;break;case 254:for(;;){if(!((L=t[e++])>=0))throw Error("Invalid block size");if(0===L)break;e+=L}break;default:throw new Error("Unknown graphic control label: 0x"+t[e-1].toString(16))}break;case 44:var m=t[e++]|t[e++]<<8,v=t[e++]|t[e++]<<8,y=t[e++]|t[e++]<<8,b=t[e++]|t[e++]<<8,w=t[e++],_=w>>6&1,x=1<<1+(7&w),S=a,C=h,A=!1;w>>7&&(A=!0,S=e,C=x,e+=3*x);var k=e;for(e++;;){var L;if(!((L=t[e++])>=0))throw Error("Invalid block size");if(0===L)break;e+=L}c.push({x:m,y:v,width:y,height:b,has_local_palette:A,palette_offset:S,palette_size:C,data_offset:k,data_length:e-k,transparent_index:f,interlaced:!!_,delay:u,disposal:d});break;case 59:l=!1;break;default:throw new Error("Unknown gif block: 0x"+t[e-1].toString(16))}this.numFrames=function(){return c.length},this.loopCount=function(){return p},this.frameInfo=function(t){if(t<0||t>=c.length)throw new Error("Frame index out of range.");return c[t]},this.decodeAndBlitFrameBGRA=function(e,i){var n=this.frameInfo(e),s=n.width*n.height;if(s>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");var o=new Uint8Array(s);Hd(t,n.data_offset,o,s);var a=n.palette_offset,h=n.transparent_index;null===h&&(h=256);var l=n.width,c=r-l,u=l,f=4*(n.y*r+n.x),d=4*((n.y+n.height)*r+n.x),p=f,g=4*c;!0===n.interlaced&&(g+=4*r*7);for(var m=8,v=0,y=o.length;v<y;++v){var b=o[v];if(0===u&&(u=l,(p+=g)>=d&&(g=4*c+4*r*(m-1),p=f+(l+c)*(m<<1),m>>=1)),b===h)p+=4;else{var w=t[a+3*b],_=t[a+3*b+1],x=t[a+3*b+2];i[p++]=x,i[p++]=_,i[p++]=w,i[p++]=255}--u}},this.decodeAndBlitFrameRGBA=function(e,i){var n=this.frameInfo(e),s=n.width*n.height;if(s>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");var o=new Uint8Array(s);Hd(t,n.data_offset,o,s);var a=n.palette_offset,h=n.transparent_index;null===h&&(h=256);var l=n.width,c=r-l,u=l,f=4*(n.y*r+n.x),d=4*((n.y+n.height)*r+n.x),p=f,g=4*c;!0===n.interlaced&&(g+=4*r*7);for(var m=8,v=0,y=o.length;v<y;++v){var b=o[v];if(0===u&&(u=l,(p+=g)>=d&&(g=4*c+4*r*(m-1),p=f+(l+c)*(m<<1),m>>=1)),b===h)p+=4;else{var w=t[a+3*b],_=t[a+3*b+1],x=t[a+3*b+2];i[p++]=w,i[p++]=_,i[p++]=x,i[p++]=255}--u}}}function Hd(t,e,r,i){for(var n=t[e++],s=1<<n,o=s+1,a=o+1,h=n+1,l=(1<<h)-1,c=0,u=0,f=0,d=t[e++],p=new Int32Array(4096),g=null;;){for(;c<16&&0!==d;)u|=t[e++]<<c,c+=8,1===d?d=t[e++]:--d;if(c<h)break;var m=u&l;if(u>>=h,c-=h,m!==s){if(m===o)break;for(var v=m<a?m:g,y=0,b=v;b>s;)b=p[b]>>8,++y;var w=b;if(f+y+(v!==m?1:0)>i)return void Yu.log("Warning, gif stream longer than expected.");r[f++]=w;var _=f+=y;for(v!==m&&(r[f++]=w),b=v;y--;)b=p[b],r[--_]=255&b,b>>=8;null!==g&&a<4096&&(p[a++]=g<<8|w,a>=l+1&&h<12&&(++h,l=l<<1|1)),g=m}else a=o+1,l=(1<<(h=n+1))-1,g=null}return f!==i&&Yu.log("Warning, gif stream shorter than expected."),r}function Vd(t){var e,r,i,n,s,o=Math.floor,a=new Array(64),h=new Array(64),l=new Array(64),c=new Array(64),u=new Array(65535),f=new Array(65535),d=new Array(64),p=new Array(64),g=[],m=0,v=7,y=new Array(64),b=new Array(64),w=new Array(64),_=new Array(256),x=new Array(2048),S=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],C=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],A=[0,1,2,3,4,5,6,7,8,9,10,11],k=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],L=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],T=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],P=[0,1,2,3,4,5,6,7,8,9,10,11],N=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],O=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function E(t,e){for(var r=0,i=0,n=new Array,s=1;s<=16;s++){for(var o=1;o<=t[s];o++)n[e[i]]=[],n[e[i]][0]=r,n[e[i]][1]=s,i++,r++;r*=2}return n}function M(t){for(var e=t[0],r=t[1]-1;r>=0;)e&1<<r&&(m|=1<<v),r--,--v<0&&(255==m?(D(255),D(0)):D(m),v=7,m=0)}function D(t){g.push(t)}function F(t){D(t>>8&255),D(255&t)}function j(t,e,r,i,n){for(var s,o=n[0],a=n[240],h=function(t,e){var r,i,n,s,o,a,h,l,c,u,f=0;for(c=0;c<8;++c){r=t[f],i=t[f+1],n=t[f+2],s=t[f+3],o=t[f+4],a=t[f+5],h=t[f+6];var p=r+(l=t[f+7]),g=r-l,m=i+h,v=i-h,y=n+a,b=n-a,w=s+o,_=s-o,x=p+w,S=p-w,C=m+y,A=m-y;t[f]=x+C,t[f+4]=x-C;var k=.707106781*(A+S);t[f+2]=S+k,t[f+6]=S-k;var L=.382683433*((x=_+b)-(A=v+g)),T=.5411961*x+L,P=1.306562965*A+L,N=.707106781*(C=b+v),O=g+N,E=g-N;t[f+5]=E+T,t[f+3]=E-T,t[f+1]=O+P,t[f+7]=O-P,f+=8}for(f=0,c=0;c<8;++c){r=t[f],i=t[f+8],n=t[f+16],s=t[f+24],o=t[f+32],a=t[f+40],h=t[f+48];var M=r+(l=t[f+56]),D=r-l,F=i+h,j=i-h,I=n+a,B=n-a,R=s+o,z=s-o,U=M+R,q=M-R,W=F+I,H=F-I;t[f]=U+W,t[f+32]=U-W;var V=.707106781*(H+q);t[f+16]=q+V,t[f+48]=q-V;var Y=.382683433*((U=z+B)-(H=j+D)),X=.5411961*U+Y,G=1.306562965*H+Y,$=.707106781*(W=B+j),K=D+$,J=D-$;t[f+40]=J+X,t[f+24]=J-X,t[f+8]=K+G,t[f+56]=K-G,f++}for(c=0;c<64;++c)u=t[c]*e[c],d[c]=u>0?u+.5|0:u-.5|0;return d}(t,e),l=0;l<64;++l)p[S[l]]=h[l];var c=p[0]-r;r=p[0],0==c?M(i[0]):(M(i[f[s=32767+c]]),M(u[s]));for(var g=63;g>0&&0==p[g];)g--;if(0==g)return M(o),r;for(var m,v=1;v<=g;){for(var y=v;0==p[v]&&v<=g;)++v;var b=v-y;if(b>=16){m=b>>4;for(var w=1;w<=m;++w)M(a);b&=15}s=32767+p[v],M(n[(b<<4)+f[s]]),M(u[s]),v++}return 63!=g&&M(o),r}function I(t){t=Math.min(Math.max(t,1),100),s!=t&&(function(t){for(var e=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],r=0;r<64;r++){var i=o((e[r]*t+50)/100);i=Math.min(Math.max(i,1),255),a[S[r]]=i}for(var n=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],s=0;s<64;s++){var u=o((n[s]*t+50)/100);u=Math.min(Math.max(u,1),255),h[S[s]]=u}for(var f=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],d=0,p=0;p<8;p++)for(var g=0;g<8;g++)l[d]=1/(a[S[d]]*f[p]*f[g]*8),c[d]=1/(h[S[d]]*f[p]*f[g]*8),d++}(t<50?Math.floor(5e3/t):Math.floor(200-2*t)),s=t)}this.encode=function(t,s){s&&I(s),g=new Array,m=0,v=7,F(65496),F(65504),F(16),D(74),D(70),D(73),D(70),D(0),D(1),D(1),D(0),F(1),F(1),D(0),D(0),function(){F(65499),F(132),D(0);for(var t=0;t<64;t++)D(a[t]);D(1);for(var e=0;e<64;e++)D(h[e])}(),function(t,e){F(65472),F(17),D(8),F(e),F(t),D(3),D(1),D(17),D(0),D(2),D(17),D(1),D(3),D(17),D(1)}(t.width,t.height),function(){F(65476),F(418),D(0);for(var t=0;t<16;t++)D(C[t+1]);for(var e=0;e<=11;e++)D(A[e]);D(16);for(var r=0;r<16;r++)D(k[r+1]);for(var i=0;i<=161;i++)D(L[i]);D(1);for(var n=0;n<16;n++)D(T[n+1]);for(var s=0;s<=11;s++)D(P[s]);D(17);for(var o=0;o<16;o++)D(N[o+1]);for(var a=0;a<=161;a++)D(O[a])}(),F(65498),F(12),D(3),D(1),D(0),D(2),D(17),D(3),D(17),D(0),D(63),D(0);var o=0,u=0,f=0;m=0,v=7,this.encode.displayName="_encode_";for(var d,p,_,S,E,B,R,z,U,q=t.data,W=t.width,H=t.height,V=4*W,Y=0;Y<H;){for(d=0;d<V;){for(E=V*Y+d,R=-1,z=0,U=0;U<64;U++)B=E+(z=U>>3)*V+(R=4*(7&U)),Y+z>=H&&(B-=V*(Y+1+z-H)),d+R>=V&&(B-=d+R-V+4),p=q[B++],_=q[B++],S=q[B++],y[U]=(x[p]+x[_+256|0]+x[S+512|0]>>16)-128,b[U]=(x[p+768|0]+x[_+1024|0]+x[S+1280|0]>>16)-128,w[U]=(x[p+1280|0]+x[_+1536|0]+x[S+1792|0]>>16)-128;o=j(y,l,o,e,i),u=j(b,c,u,r,n),f=j(w,c,f,r,n),d+=32}Y+=8}if(v>=0){var X=[];X[1]=v+1,X[0]=(1<<v+1)-1,M(X)}return F(65497),new Uint8Array(g)},t=t||50,function(){for(var t=String.fromCharCode,e=0;e<256;e++)_[e]=t(e)}(),e=E(C,A),r=E(T,P),i=E(k,L),n=E(N,O),function(){for(var t=1,e=2,r=1;r<=15;r++){for(var i=t;i<e;i++)f[32767+i]=r,u[32767+i]=[],u[32767+i][1]=r,u[32767+i][0]=i;for(var n=-(e-1);n<=-t;n++)f[32767+n]=r,u[32767+n]=[],u[32767+n][1]=r,u[32767+n][0]=e-1+n;t<<=1,e<<=1}}(),function(){for(var t=0;t<256;t++)x[t]=19595*t,x[t+256|0]=38470*t,x[t+512|0]=7471*t+32768,x[t+768|0]=-11059*t,x[t+1024|0]=-21709*t,x[t+1280|0]=32768*t+8421375,x[t+1536|0]=-27439*t,x[t+1792|0]=-5329*t}(),I(t)}function Yd(t,e){if(this.pos=0,this.buffer=t,this.datav=new DataView(t.buffer),this.is_with_alpha=!!e,this.bottom_up=!0,this.flag=String.fromCharCode(this.buffer[0])+String.fromCharCode(this.buffer[1]),this.pos+=2,-1===["BM","BA","CI","CP","IC","PT"].indexOf(this.flag))throw new Error("Invalid BMP File");this.parseHeader(),this.parseBGR()}function Xd(t){function e(t){if(!t)throw Error("assert :P")}function r(t,e,r){for(var i=0;4>i;i++)if(t[e+i]!=r.charCodeAt(i))return!0;return!1}function i(t,e,r,i,n){for(var s=0;s<n;s++)t[e+s]=r[i+s]}function n(t,e,r,i){for(var n=0;n<i;n++)t[e+n]=r}function s(t){return new Int32Array(t)}function o(t,e){for(var r=[],i=0;i<t;i++)r.push(new e);return r}function a(t,e){var r=[];return function t(r,i,n){for(var s=n[i],o=0;o<s&&(r.push(n.length>i+1?[]:new e),!(n.length<i+1));o++)t(r[o],i+1,n)}(r,0,t),r}var h=function(){var t=this;function h(t,e){for(var r=1<<e-1>>>0;t&r;)r>>>=1;return r?(t&r-1)+r:t}function l(t,r,i,n,s){e(!(n%i));do{t[r+(n-=i)]=s}while(0<n)}function c(t,r,i,n,o){if(e(2328>=o),512>=o)var a=s(512);else if(null==(a=s(o)))return 0;return function(t,r,i,n,o,a){var c,f,d=r,p=1<<i,g=s(16),m=s(16);for(e(0!=o),e(null!=n),e(null!=t),e(0<i),f=0;f<o;++f){if(15<n[f])return 0;++g[n[f]]}if(g[0]==o)return 0;for(m[1]=0,c=1;15>c;++c){if(g[c]>1<<c)return 0;m[c+1]=m[c]+g[c]}for(f=0;f<o;++f)c=n[f],0<n[f]&&(a[m[c]++]=f);if(1==m[15])return(n=new u).g=0,n.value=a[0],l(t,d,1,p,n),p;var v,y=-1,b=p-1,w=0,_=1,x=1,S=1<<i;for(f=0,c=1,o=2;c<=i;++c,o<<=1){if(_+=x<<=1,0>(x-=g[c]))return 0;for(;0<g[c];--g[c])(n=new u).g=c,n.value=a[f++],l(t,d+w,o,S,n),w=h(w,c)}for(c=i+1,o=2;15>=c;++c,o<<=1){if(_+=x<<=1,0>(x-=g[c]))return 0;for(;0<g[c];--g[c]){if(n=new u,(w&b)!=y){for(d+=S,v=1<<(y=c)-i;15>y&&!(0>=(v-=g[y]));)++y,v<<=1;p+=S=1<<(v=y-i),t[r+(y=w&b)].g=v+i,t[r+y].value=d-r-y}n.g=c-i,n.value=a[f++],l(t,d+(w>>i),o,S,n),w=h(w,c)}}return _!=2*m[15]-1?0:p}(t,r,i,n,o,a)}function u(){this.value=this.g=0}function f(){this.value=this.g=0}function d(){this.G=o(5,u),this.H=s(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=o(Ir,f)}function p(t,r,i,n){e(null!=t),e(null!=r),e(2147483648>n),t.Ca=254,t.I=0,t.b=-8,t.Ka=0,t.oa=r,t.pa=i,t.Jd=r,t.Yc=i+n,t.Zc=4<=n?i+n-4+1:i,k(t)}function g(t,e){for(var r=0;0<e--;)r|=T(t,128)<<e;return r}function m(t,e){var r=g(t,e);return L(t)?-r:r}function v(t,r,i,n){var s,o=0;for(e(null!=t),e(null!=r),e(4294967288>n),t.Sb=n,t.Ra=0,t.u=0,t.h=0,4<n&&(n=4),s=0;s<n;++s)o+=r[i+s]<<8*s;t.Ra=o,t.bb=n,t.oa=r,t.pa=i}function y(t){for(;8<=t.u&&t.bb<t.Sb;)t.Ra>>>=8,t.Ra+=t.oa[t.pa+t.bb]<<zr-8>>>0,++t.bb,t.u-=8;S(t)&&(t.h=1,t.u=0)}function b(t,r){if(e(0<=r),!t.h&&r<=Rr){var i=x(t)&Br[r];return t.u+=r,y(t),i}return t.h=1,t.u=0}function w(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function _(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function x(t){return t.Ra>>>(t.u&zr-1)>>>0}function S(t){return e(t.bb<=t.Sb),t.h||t.bb==t.Sb&&t.u>zr}function C(t,e){t.u=e,t.h=S(t)}function A(t){t.u>=Ur&&(e(t.u>=Ur),y(t))}function k(t){e(null!=t&&null!=t.oa),t.pa<t.Zc?(t.I=(t.oa[t.pa++]|t.I<<8)>>>0,t.b+=8):(e(null!=t&&null!=t.oa),t.pa<t.Yc?(t.b+=8,t.I=t.oa[t.pa++]|t.I<<8):t.Ka?t.b=0:(t.I<<=8,t.b+=8,t.Ka=1))}function L(t){return g(t,1)}function T(t,e){var r=t.Ca;0>t.b&&k(t);var i=t.b,n=r*e>>>8,s=(t.I>>>i>n)+0;for(s?(r-=n,t.I-=n+1<<i>>>0):r=n+1,i=r,n=0;256<=i;)n+=8,i>>=8;return i=7^n+qr[i],t.b-=i,t.Ca=(r<<i)-1,s}function P(t,e,r){t[e+0]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function N(t,e){return t[e+0]|t[e+1]<<8}function O(t,e){return N(t,e)|t[e+2]<<16}function E(t,e){return N(t,e)|N(t,e+2)<<16}function M(t,r){var i=1<<r;return e(null!=t),e(0<r),t.X=s(i),null==t.X?0:(t.Mb=32-r,t.Xa=r,1)}function D(t,r){e(null!=t),e(null!=r),e(t.Xa==r.Xa),i(r.X,0,t.X,0,1<<r.Xa)}function F(){this.X=[],this.Xa=this.Mb=0}function j(t,r,i,n){e(null!=i),e(null!=n);var s=i[0],o=n[0];return 0==s&&(s=(t*o+r/2)/r),0==o&&(o=(r*s+t/2)/t),0>=s||0>=o?0:(i[0]=s,n[0]=o,1)}function I(t,e){return t+(1<<e)-1>>>e}function B(t,e){return((4278255360&t)+(4278255360&e)>>>0&4278255360)+((16711935&t)+(16711935&e)>>>0&16711935)>>>0}function R(e,r){t[r]=function(r,i,n,s,o,a,h){var l;for(l=0;l<o;++l){var c=t[e](a[h+l-1],n,s+l);a[h+l]=B(r[i+l],c)}}}function z(){this.ud=this.hd=this.jd=0}function U(t,e){return((4278124286&(t^e))>>>1)+(t&e)>>>0}function q(t){return 0<=t&&256>t?t:0>t?0:255<t?255:void 0}function W(t,e){return q(t+(t-e+.5>>1))}function H(t,e,r){return Math.abs(e-r)-Math.abs(t-r)}function V(t,e,r,i,n,s,o){for(i=s[o-1],r=0;r<n;++r)s[o+r]=i=B(t[e+r],i)}function Y(t,e,r,i,n){var s;for(s=0;s<r;++s){var o=t[e+s],a=o>>8&255,h=16711935&(h=(h=16711935&o)+((a<<16)+a));i[n+s]=(4278255360&o)+h>>>0}}function X(t,e){e.jd=255&t,e.hd=t>>8&255,e.ud=t>>16&255}function G(t,e,r,i,n,s){var o;for(o=0;o<i;++o){var a=e[r+o],h=a>>>8,l=a,c=255&(c=(c=a>>>16)+((t.jd<<24>>24)*(h<<24>>24)>>>5));l=255&(l=(l+=(t.hd<<24>>24)*(h<<24>>24)>>>5)+((t.ud<<24>>24)*(c<<24>>24)>>>5)),n[s+o]=(4278255360&a)+(c<<16)+l}}function $(e,r,i,n,s){t[r]=function(t,e,r,i,o,a,h,l,c){for(i=h;i<l;++i)for(h=0;h<c;++h)o[a++]=s(r[n(t[e++])])},t[e]=function(e,r,o,a,h,l,c){var u=8>>e.b,f=e.Ea,d=e.K[0],p=e.w;if(8>u)for(e=(1<<e.b)-1,p=(1<<u)-1;r<o;++r){var g,m=0;for(g=0;g<f;++g)g&e||(m=n(a[h++])),l[c++]=s(d[m&p]),m>>=u}else t["VP8LMapColor"+i](a,h,d,p,l,c,r,o,f)}}function K(t,e,r,i,n){for(r=e+r;e<r;){var s=t[e++];i[n++]=s>>16&255,i[n++]=s>>8&255,i[n++]=255&s}}function J(t,e,r,i,n){for(r=e+r;e<r;){var s=t[e++];i[n++]=s>>16&255,i[n++]=s>>8&255,i[n++]=255&s,i[n++]=s>>24&255}}function Z(t,e,r,i,n){for(r=e+r;e<r;){var s=(o=t[e++])>>16&240|o>>12&15,o=240&o|o>>28&15;i[n++]=s,i[n++]=o}}function Q(t,e,r,i,n){for(r=e+r;e<r;){var s=(o=t[e++])>>16&248|o>>13&7,o=o>>5&224|o>>3&31;i[n++]=s,i[n++]=o}}function tt(t,e,r,i,n){for(r=e+r;e<r;){var s=t[e++];i[n++]=255&s,i[n++]=s>>8&255,i[n++]=s>>16&255}}function et(t,e,r,n,s,o){if(0==o)for(r=e+r;e<r;)P(n,((o=t[e++])[0]>>24|o[1]>>8&65280|o[2]<<8&16711680|o[3]<<24)>>>0),s+=32;else i(n,s,t,e,r)}function rt(e,r){t[r][0]=t[e+"0"],t[r][1]=t[e+"1"],t[r][2]=t[e+"2"],t[r][3]=t[e+"3"],t[r][4]=t[e+"4"],t[r][5]=t[e+"5"],t[r][6]=t[e+"6"],t[r][7]=t[e+"7"],t[r][8]=t[e+"8"],t[r][9]=t[e+"9"],t[r][10]=t[e+"10"],t[r][11]=t[e+"11"],t[r][12]=t[e+"12"],t[r][13]=t[e+"13"],t[r][14]=t[e+"0"],t[r][15]=t[e+"0"]}function it(t){return t==zi||t==Ui||t==qi||t==Wi}function nt(){this.eb=[],this.size=this.A=this.fb=0}function st(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function ot(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new nt,this.f.kb=new st,this.sd=null}function at(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function ht(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function lt(t){return alert("todo:WebPSamplerProcessPlane"),t.T}function ct(t,e){var r=t.T,n=e.ba.f.RGBA,s=n.eb,o=n.fb+t.ka*n.A,a=gn[e.ba.S],h=t.y,l=t.O,c=t.f,u=t.N,f=t.ea,d=t.W,p=e.cc,g=e.dc,m=e.Mc,v=e.Nc,y=t.ka,b=t.ka+t.T,w=t.U,_=w+1>>1;for(0==y?a(h,l,null,null,c,u,f,d,c,u,f,d,s,o,null,null,w):(a(e.ec,e.fc,h,l,p,g,m,v,c,u,f,d,s,o-n.A,s,o,w),++r);y+2<b;y+=2)p=c,g=u,m=f,v=d,u+=t.Rc,d+=t.Rc,o+=2*n.A,a(h,(l+=2*t.fa)-t.fa,h,l,p,g,m,v,c,u,f,d,s,o-n.A,s,o,w);return l+=t.fa,t.j+b<t.o?(i(e.ec,e.fc,h,l,w),i(e.cc,e.dc,c,u,_),i(e.Mc,e.Nc,f,d,_),r--):1&b||a(h,l,null,null,c,u,f,d,c,u,f,d,s,o+n.A,null,null,w),r}function ut(t,r,i){var n=t.F,s=[t.J];if(null!=n){var o=t.U,a=r.ba.S,h=a==Ii||a==qi;r=r.ba.f.RGBA;var l=[0],c=t.ka;l[0]=t.T,t.Kb&&(0==c?--l[0]:(--c,s[0]-=t.width),t.j+t.ka+t.T==t.o&&(l[0]=t.o-t.j-c));var u=r.eb;c=r.fb+c*r.A,t=Si(n,s[0],t.width,o,l,u,c+(h?0:3),r.A),e(i==l),t&&it(a)&&_i(u,c,h,o,l,r.A)}return 0}function ft(t){var e=t.ma,r=e.ba.S,i=11>r,n=r==Di||r==ji||r==Ii||r==Bi||12==r||it(r);if(e.memory=null,e.Ib=null,e.Jb=null,e.Nd=null,!Dr(e.Oa,t,n?11:12))return 0;if(n&&it(r)&&vr(),t.da)alert("todo:use_scaling");else{if(i){if(e.Ib=lt,t.Kb){if(r=t.U+1>>1,e.memory=s(t.U+2*r),null==e.memory)return 0;e.ec=e.memory,e.fc=0,e.cc=e.ec,e.dc=e.fc+t.U,e.Mc=e.cc,e.Nc=e.dc+r,e.Ib=ct,vr()}}else alert("todo:EmitYUV");n&&(e.Jb=ut,i&&gr())}if(i&&!Nn){for(t=0;256>t;++t)On[t]=89858*(t-128)+An>>Cn,Dn[t]=-22014*(t-128)+An,Mn[t]=-45773*(t-128),En[t]=113618*(t-128)+An>>Cn;for(t=kn;t<Ln;++t)e=76283*(t-16)+An>>Cn,Fn[t-kn]=Vt(e,255),jn[t-kn]=Vt(e+8>>4,15);Nn=1}return 1}function dt(t){var r=t.ma,i=t.U,n=t.T;return e(!(1&t.ka)),0>=i||0>=n?0:(i=r.Ib(t,r),null!=r.Jb&&r.Jb(t,r,i),r.Dc+=i,1)}function pt(t){t.ma.memory=null}function gt(t,e,r,i){return 47!=b(t,8)?0:(e[0]=b(t,14)+1,r[0]=b(t,14)+1,i[0]=b(t,1),0!=b(t,3)?0:!t.h)}function mt(t,e){if(4>t)return t+1;var r=t-2>>1;return(2+(1&t)<<r)+b(e,r)+1}function vt(t,e){return 120<e?e-120:1<=(r=((r=$i[e-1])>>4)*t+(8-(15&r)))?r:1;var r}function yt(t,e,r){var i=x(r),n=t[e+=255&i].g-8;return 0<n&&(C(r,r.u+8),i=x(r),e+=t[e].value,e+=i&(1<<n)-1),C(r,r.u+t[e].g),t[e].value}function bt(t,r,i){return i.g+=t.g,i.value+=t.value<<r>>>0,e(8>=i.g),t.g}function wt(t,r,i){var n=t.xc;return e((r=0==n?0:t.vc[t.md*(i>>n)+(r>>n)])<t.Wb),t.Ya[r]}function _t(t,r,n,s){var o=t.ab,a=t.c*r,h=t.C;r=h+r;var l=n,c=s;for(s=t.Ta,n=t.Ua;0<o--;){var u=t.gc[o],f=h,d=r,p=l,g=c,m=(c=s,l=n,u.Ea);switch(e(f<d),e(d<=u.nc),u.hc){case 2:Vr(p,g,(d-f)*m,c,l);break;case 0:var v=f,y=d,b=c,w=l,_=(k=u).Ea;0==v&&(Wr(p,g,null,null,1,b,w),V(p,g+1,0,0,_-1,b,w+1),g+=_,w+=_,++v);for(var x=1<<k.b,S=x-1,C=I(_,k.b),A=k.K,k=k.w+(v>>k.b)*C;v<y;){var L=A,T=k,P=1;for(Hr(p,g,b,w-_,1,b,w);P<_;){var N=(P&~S)+x;N>_&&(N=_),(0,Kr[L[T++]>>8&15])(p,g+ +P,b,w+P-_,N-P,b,w+P),P=N}g+=_,w+=_,++v&S||(k+=C)}d!=u.nc&&i(c,l-m,c,l+(d-f-1)*m,m);break;case 1:for(m=p,y=g,_=(p=u.Ea)-(w=p&~(b=(g=1<<u.b)-1)),v=I(p,u.b),x=u.K,u=u.w+(f>>u.b)*v;f<d;){for(S=x,C=u,A=new z,k=y+w,L=y+p;y<k;)X(S[C++],A),Jr(A,m,y,g,c,l),y+=g,l+=g;y<L&&(X(S[C++],A),Jr(A,m,y,_,c,l),y+=_,l+=_),++f&b||(u+=v)}break;case 3:if(p==c&&g==l&&0<u.b){for(y=c,p=m=l+(d-f)*m-(w=(d-f)*I(u.Ea,u.b)),g=c,b=l,v=[],w=(_=w)-1;0<=w;--w)v[w]=g[b+w];for(w=_-1;0<=w;--w)y[p+w]=v[w];Yr(u,f,d,c,m,c,l)}else Yr(u,f,d,p,g,c,l)}l=s,c=n}c!=n&&i(s,n,l,c,a)}function xt(t,r){var i=t.V,n=t.Ba+t.c*t.C,s=r-t.C;if(e(r<=t.l.o),e(16>=s),0<s){var o=t.l,a=t.Ta,h=t.Ua,l=o.width;if(_t(t,s,i,n),s=h=[h],e((i=t.C)<(n=r)),e(o.v<o.va),n>o.o&&(n=o.o),i<o.j){var c=o.j-i;i=o.j,s[0]+=c*l}if(i>=n?i=0:(s[0]+=4*o.v,o.ka=i-o.j,o.U=o.va-o.v,o.T=n-i,i=1),i){if(h=h[0],11>(i=t.ca).S){var u=i.f.RGBA,f=(n=i.S,s=o.U,o=o.T,c=u.eb,u.A),d=o;for(u=u.fb+t.Ma*u.A;0<d--;){var p=a,g=h,m=s,v=c,y=u;switch(n){case Mi:Zr(p,g,m,v,y);break;case Di:Qr(p,g,m,v,y);break;case zi:Qr(p,g,m,v,y),_i(v,y,0,m,1,0);break;case Fi:ri(p,g,m,v,y);break;case ji:et(p,g,m,v,y,1);break;case Ui:et(p,g,m,v,y,1),_i(v,y,0,m,1,0);break;case Ii:et(p,g,m,v,y,0);break;case qi:et(p,g,m,v,y,0),_i(v,y,1,m,1,0);break;case Bi:ti(p,g,m,v,y);break;case Wi:ti(p,g,m,v,y),xi(v,y,m,1,0);break;case Ri:ei(p,g,m,v,y);break;default:e(0)}h+=l,u+=f}t.Ma+=o}else alert("todo:EmitRescaledRowsYUVA");e(t.Ma<=i.height)}}t.C=r,e(t.C<=t.i)}function St(t){var e;if(0<t.ua)return 0;for(e=0;e<t.Wb;++e){var r=t.Ya[e].G,i=t.Ya[e].H;if(0<r[1][i[1]+0].g||0<r[2][i[2]+0].g||0<r[3][i[3]+0].g)return 0}return 1}function Ct(t,r,i,n,s,o){if(0!=t.Z){var a=t.qd,h=t.rd;for(e(null!=pn[t.Z]);r<i;++r)pn[t.Z](a,h,n,s,n,s,o),a=n,h=s,s+=o;t.qd=a,t.rd=h}}function At(t,r){var i=t.l.ma,n=0==i.Z||1==i.Z?t.l.j:t.C;if(n=t.C<n?n:t.C,e(r<=t.l.o),r>n){var s=t.l.width,o=i.ca,a=i.tb+s*n,h=t.V,l=t.Ba+t.c*n,c=t.gc;e(1==t.ab),e(3==c[0].hc),Gr(c[0],n,r,h,l,o,a),Ct(i,n,r,o,a,s)}t.C=t.Ma=r}function kt(t,r,i,n,s,o,a){var h=t.$/n,l=t.$%n,c=t.m,u=t.s,f=i+t.$,d=f;s=i+n*s;var p=i+n*o,g=280+u.ua,m=t.Pb?h:16777216,v=0<u.ua?u.Wa:null,y=u.wc,b=f<p?wt(u,l,h):null;e(t.C<o),e(p<=s);var w=!1;t:for(;;){for(;w||f<p;){var _=0;if(h>=m){var k=f-i;e((m=t).Pb),m.wd=m.m,m.xd=k,0<m.s.ua&&D(m.s.Wa,m.s.vb),m=h+Ji}if(l&y||(b=wt(u,l,h)),e(null!=b),b.Qb&&(r[f]=b.qb,w=!0),!w)if(A(c),b.jc){_=c,k=r;var L=f,T=b.pd[x(_)&Ir-1];e(b.jc),256>T.g?(C(_,_.u+T.g),k[L]=T.value,_=0):(C(_,_.u+T.g-256),e(256<=T.value),_=T.value),0==_&&(w=!0)}else _=yt(b.G[0],b.H[0],c);if(c.h)break;if(w||256>_){if(!w)if(b.nd)r[f]=(b.qb|_<<8)>>>0;else{if(A(c),w=yt(b.G[1],b.H[1],c),A(c),k=yt(b.G[2],b.H[2],c),L=yt(b.G[3],b.H[3],c),c.h)break;r[f]=(L<<24|w<<16|_<<8|k)>>>0}if(w=!1,++f,++l>=n&&(l=0,++h,null!=a&&h<=o&&!(h%16)&&a(t,h),null!=v))for(;d<f;)_=r[d++],v.X[(506832829*_&4294967295)>>>v.Mb]=_}else if(280>_){if(_=mt(_-256,c),k=yt(b.G[4],b.H[4],c),A(c),k=vt(n,k=mt(k,c)),c.h)break;if(f-i<k||s-f<_)break t;for(L=0;L<_;++L)r[f+L]=r[f+L-k];for(f+=_,l+=_;l>=n;)l-=n,++h,null!=a&&h<=o&&!(h%16)&&a(t,h);if(e(f<=s),l&y&&(b=wt(u,l,h)),null!=v)for(;d<f;)_=r[d++],v.X[(506832829*_&4294967295)>>>v.Mb]=_}else{if(!(_<g))break t;for(w=_-280,e(null!=v);d<f;)_=r[d++],v.X[(506832829*_&4294967295)>>>v.Mb]=_;_=f,e(!(w>>>(k=v).Xa)),r[_]=k.X[w],w=!0}w||e(c.h==S(c))}if(t.Pb&&c.h&&f<s)e(t.m.h),t.a=5,t.m=t.wd,t.$=t.xd,0<t.s.ua&&D(t.s.vb,t.s.Wa);else{if(c.h)break t;null!=a&&a(t,h>o?o:h),t.a=0,t.$=f-i}return 1}return t.a=3,0}function Lt(t){e(null!=t),t.vc=null,t.yc=null,t.Ya=null;var r=t.Wa;null!=r&&(r.X=null),t.vb=null,e(null!=t)}function Tt(){var e=new sr;return null==e?null:(e.a=0,e.xb=dn,rt("Predictor","VP8LPredictors"),rt("Predictor","VP8LPredictors_C"),rt("PredictorAdd","VP8LPredictorsAdd"),rt("PredictorAdd","VP8LPredictorsAdd_C"),Vr=Y,Jr=G,Zr=K,Qr=J,ti=Z,ei=Q,ri=tt,t.VP8LMapColor32b=Xr,t.VP8LMapColor8b=$r,e)}function Pt(t,r,i,a,h){var l=1,f=[t],p=[r],g=a.m,m=a.s,v=null,y=0;t:for(;;){if(i)for(;l&&b(g,1);){var w=f,_=p,S=a,k=1,L=S.m,T=S.gc[S.ab],P=b(L,2);if(S.Oc&1<<P)l=0;else{switch(S.Oc|=1<<P,T.hc=P,T.Ea=w[0],T.nc=_[0],T.K=[null],++S.ab,e(4>=S.ab),P){case 0:case 1:T.b=b(L,3)+2,k=Pt(I(T.Ea,T.b),I(T.nc,T.b),0,S,T.K),T.K=T.K[0];break;case 3:var N,O=b(L,8)+1,E=16<O?0:4<O?1:2<O?2:3;if(w[0]=I(T.Ea,E),T.b=E,N=k=Pt(O,1,0,S,T.K)){var D,F=O,j=T,R=1<<(8>>j.b),z=s(R);if(null==z)N=0;else{var U=j.K[0],q=j.w;for(z[0]=j.K[0][0],D=1;D<1*F;++D)z[D]=B(U[q+D],z[D-1]);for(;D<4*R;++D)z[D]=0;j.K[0]=null,j.K[0]=z,N=1}}k=N;break;case 2:break;default:e(0)}l=k}}if(f=f[0],p=p[0],l&&b(g,1)&&!(l=1<=(y=b(g,4))&&11>=y)){a.a=3;break t}var W;if(W=l)e:{var H,V,Y,X=a,G=f,$=p,K=y,J=i,Z=X.m,Q=X.s,tt=[null],et=1,rt=0,it=Ki[K];r:for(;;){if(J&&b(Z,1)){var nt=b(Z,3)+2,st=I(G,nt),ot=I($,nt),at=st*ot;if(!Pt(st,ot,0,X,tt))break r;for(tt=tt[0],Q.xc=nt,H=0;H<at;++H){var ht=tt[H]>>8&65535;tt[H]=ht,ht>=et&&(et=ht+1)}}if(Z.h)break r;for(V=0;5>V;++V){var lt=Yi[V];!V&&0<K&&(lt+=1<<K),rt<lt&&(rt=lt)}var ct=o(et*it,u),ut=et,ft=o(ut,d);if(null==ft)var dt=null;else e(65536>=ut),dt=ft;var pt=s(rt);if(null==dt||null==pt||null==ct){X.a=1;break r}var gt=ct;for(H=Y=0;H<et;++H){var mt=dt[H],vt=mt.G,yt=mt.H,wt=0,_t=1,xt=0;for(V=0;5>V;++V){lt=Yi[V],vt[V]=gt,yt[V]=Y,!V&&0<K&&(lt+=1<<K);i:{var St,Ct=lt,At=X,Tt=pt,Nt=gt,Ot=Y,Et=0,Mt=At.m,Dt=b(Mt,1);if(n(Tt,0,0,Ct),Dt){var Ft=b(Mt,1)+1,jt=b(Mt,1),It=b(Mt,0==jt?1:8);Tt[It]=1,2==Ft&&(Tt[It=b(Mt,8)]=1);var Bt=1}else{var Rt=s(19),zt=b(Mt,4)+4;if(19<zt){At.a=3;var Ut=0;break i}for(St=0;St<zt;++St)Rt[Gi[St]]=b(Mt,3);var qt=void 0,Wt=void 0,Ht=At,Vt=Rt,Yt=Ct,Xt=Tt,Gt=0,$t=Ht.m,Kt=8,Jt=o(128,u);n:for(;c(Jt,0,7,Vt,19);){if(b($t,1)){var Zt=2+2*b($t,3);if((qt=2+b($t,Zt))>Yt)break n}else qt=Yt;for(Wt=0;Wt<Yt&&qt--;){A($t);var Qt=Jt[0+(127&x($t))];C($t,$t.u+Qt.g);var te=Qt.value;if(16>te)Xt[Wt++]=te,0!=te&&(Kt=te);else{var ee=16==te,re=te-16,ie=Vi[re],ne=b($t,Hi[re])+ie;if(Wt+ne>Yt)break n;for(var se=ee?Kt:0;0<ne--;)Xt[Wt++]=se}}Gt=1;break n}Gt||(Ht.a=3),Bt=Gt}(Bt=Bt&&!Mt.h)&&(Et=c(Nt,Ot,8,Tt,Ct)),Bt&&0!=Et?Ut=Et:(At.a=3,Ut=0)}if(0==Ut)break r;if(_t&&1==Xi[V]&&(_t=0==gt[Y].g),wt+=gt[Y].g,Y+=Ut,3>=V){var oe,ae=pt[0];for(oe=1;oe<lt;++oe)pt[oe]>ae&&(ae=pt[oe]);xt+=ae}}if(mt.nd=_t,mt.Qb=0,_t&&(mt.qb=(vt[3][yt[3]+0].value<<24|vt[1][yt[1]+0].value<<16|vt[2][yt[2]+0].value)>>>0,0==wt&&256>vt[0][yt[0]+0].value&&(mt.Qb=1,mt.qb+=vt[0][yt[0]+0].value<<8)),mt.jc=!mt.Qb&&6>xt,mt.jc){var he,le=mt;for(he=0;he<Ir;++he){var ce=he,ue=le.pd[ce],fe=le.G[0][le.H[0]+ce];256<=fe.value?(ue.g=fe.g+256,ue.value=fe.value):(ue.g=0,ue.value=0,ce>>=bt(fe,8,ue),ce>>=bt(le.G[1][le.H[1]+ce],16,ue),ce>>=bt(le.G[2][le.H[2]+ce],0,ue),bt(le.G[3][le.H[3]+ce],24,ue))}}}Q.vc=tt,Q.Wb=et,Q.Ya=dt,Q.yc=ct,W=1;break e}W=0}if(!(l=W)){a.a=3;break t}if(0<y){if(m.ua=1<<y,!M(m.Wa,y)){a.a=1,l=0;break t}}else m.ua=0;var de=a,pe=f,ge=p,me=de.s,ve=me.xc;if(de.c=pe,de.i=ge,me.md=I(pe,ve),me.wc=0==ve?-1:(1<<ve)-1,i){a.xb=fn;break t}if(null==(v=s(f*p))){a.a=1,l=0;break t}l=(l=kt(a,v,0,f,p,p,null))&&!g.h;break t}return l?(null!=h?h[0]=v:(e(null==v),e(i)),a.$=0,i||Lt(m)):Lt(m),l}function Nt(t,r){var i=t.c*t.i,n=i+r+16*r;return e(t.c<=r),t.V=s(n),null==t.V?(t.Ta=null,t.Ua=0,t.a=1,0):(t.Ta=t.V,t.Ua=t.Ba+i+r,1)}function Ot(t,r){var i=t.C,n=r-i,s=t.V,o=t.Ba+t.c*i;for(e(r<=t.l.o);0<n;){var a=16<n?16:n,h=t.l.ma,l=t.l.width,c=l*a,u=h.ca,f=h.tb+l*i,d=t.Ta,p=t.Ua;_t(t,a,s,o),Ci(d,p,u,f,c),Ct(h,i,i+a,u,f,l),n-=a,s+=a*t.c,i+=a}e(i==r),t.C=t.Ma=r}function Et(){this.ub=this.yd=this.td=this.Rb=0}function Mt(){this.Kd=this.Ld=this.Ud=this.Td=this.i=this.c=0}function Dt(){this.Fb=this.Bb=this.Cb=0,this.Zb=s(4),this.Lb=s(4)}function Ft(){this.Yb=function(){var t=[];return function t(e,r,i){for(var n=i[r],s=0;s<n&&(e.push(i.length>r+1?[]:0),!(i.length<r+1));s++)t(e[s],r+1,i)}(t,0,[3,11]),t}()}function jt(){this.jb=s(3),this.Wc=a([4,8],Ft),this.Xc=a([4,17],Ft)}function It(){this.Pc=this.wb=this.Tb=this.zd=0,this.vd=new s(4),this.od=new s(4)}function Bt(){this.ld=this.La=this.dd=this.tc=0}function Rt(){this.Na=this.la=0}function zt(){this.Sc=[0,0],this.Eb=[0,0],this.Qc=[0,0],this.ia=this.lc=0}function Ut(){this.ad=s(384),this.Za=0,this.Ob=s(16),this.$b=this.Ad=this.ia=this.Gc=this.Hc=this.Dd=0}function qt(){this.uc=this.M=this.Nb=0,this.wa=Array(new Bt),this.Y=0,this.ya=Array(new Ut),this.aa=0,this.l=new Yt}function Wt(){this.y=s(16),this.f=s(8),this.ea=s(8)}function Ht(){this.cb=this.a=0,this.sc="",this.m=new w,this.Od=new Et,this.Kc=new Mt,this.ed=new It,this.Qa=new Dt,this.Ic=this.$c=this.Aa=0,this.D=new qt,this.Xb=this.Va=this.Hb=this.zb=this.yb=this.Ub=this.za=0,this.Jc=o(8,w),this.ia=0,this.pb=o(4,zt),this.Pa=new jt,this.Bd=this.kc=0,this.Ac=[],this.Bc=0,this.zc=[0,0,0,0],this.Gd=Array(new Wt),this.Hd=0,this.rb=Array(new Rt),this.sb=0,this.wa=Array(new Bt),this.Y=0,this.oc=[],this.pc=0,this.sa=[],this.ta=0,this.qa=[],this.ra=0,this.Ha=[],this.B=this.R=this.Ia=0,this.Ec=[],this.M=this.ja=this.Vb=this.Fc=0,this.ya=Array(new Ut),this.L=this.aa=0,this.gd=a([4,2],Bt),this.ga=null,this.Fa=[],this.Cc=this.qc=this.P=0,this.Gb=[],this.Uc=0,this.mb=[],this.nb=0,this.rc=[],this.Ga=this.Vc=0}function Vt(t,e){return 0>t?0:t>e?e:t}function Yt(){this.T=this.U=this.ka=this.height=this.width=0,this.y=[],this.f=[],this.ea=[],this.Rc=this.fa=this.W=this.N=this.O=0,this.ma="void",this.put="VP8IoPutHook",this.ac="VP8IoSetupHook",this.bc="VP8IoTeardownHook",this.ha=this.Kb=0,this.data=[],this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0,this.F=[],this.J=0}function Xt(){var t=new Ht;return null!=t&&(t.a=0,t.sc="OK",t.cb=0,t.Xb=0,tn||(tn=Jt)),t}function Gt(t,e,r){return 0==t.a&&(t.a=e,t.sc=r,t.cb=0),0}function $t(t,e,r){return 3<=r&&157==t[e+0]&&1==t[e+1]&&42==t[e+2]}function Kt(t,r){if(null==t)return 0;if(t.a=0,t.sc="OK",null==r)return Gt(t,2,"null VP8Io passed to VP8GetHeaders()");var i=r.data,s=r.w,o=r.ha;if(4>o)return Gt(t,7,"Truncated header.");var a=i[s+0]|i[s+1]<<8|i[s+2]<<16,h=t.Od;if(h.Rb=!(1&a),h.td=a>>1&7,h.yd=a>>4&1,h.ub=a>>5,3<h.td)return Gt(t,3,"Incorrect keyframe parameters.");if(!h.yd)return Gt(t,4,"Frame not displayable.");s+=3,o-=3;var l=t.Kc;if(h.Rb){if(7>o)return Gt(t,7,"cannot parse picture header");if(!$t(i,s,o))return Gt(t,3,"Bad code word");l.c=16383&(i[s+4]<<8|i[s+3]),l.Td=i[s+4]>>6,l.i=16383&(i[s+6]<<8|i[s+5]),l.Ud=i[s+6]>>6,s+=7,o-=7,t.za=l.c+15>>4,t.Ub=l.i+15>>4,r.width=l.c,r.height=l.i,r.Da=0,r.j=0,r.v=0,r.va=r.width,r.o=r.height,r.da=0,r.ib=r.width,r.hb=r.height,r.U=r.width,r.T=r.height,n((a=t.Pa).jb,0,255,a.jb.length),e(null!=(a=t.Qa)),a.Cb=0,a.Bb=0,a.Fb=1,n(a.Zb,0,0,a.Zb.length),n(a.Lb,0,0,a.Lb)}if(h.ub>o)return Gt(t,7,"bad partition length");p(a=t.m,i,s,h.ub),s+=h.ub,o-=h.ub,h.Rb&&(l.Ld=L(a),l.Kd=L(a)),l=t.Qa;var c,u=t.Pa;if(e(null!=a),e(null!=l),l.Cb=L(a),l.Cb){if(l.Bb=L(a),L(a)){for(l.Fb=L(a),c=0;4>c;++c)l.Zb[c]=L(a)?m(a,7):0;for(c=0;4>c;++c)l.Lb[c]=L(a)?m(a,6):0}if(l.Bb)for(c=0;3>c;++c)u.jb[c]=L(a)?g(a,8):255}else l.Bb=0;if(a.Ka)return Gt(t,3,"cannot parse segment header");if((l=t.ed).zd=L(a),l.Tb=g(a,6),l.wb=g(a,3),l.Pc=L(a),l.Pc&&L(a)){for(u=0;4>u;++u)L(a)&&(l.vd[u]=m(a,6));for(u=0;4>u;++u)L(a)&&(l.od[u]=m(a,6))}if(t.L=0==l.Tb?0:l.zd?1:2,a.Ka)return Gt(t,3,"cannot parse filter header");var f=o;if(o=c=s,s=c+f,l=f,t.Xb=(1<<g(t.m,2))-1,f<3*(u=t.Xb))i=7;else{for(c+=3*u,l-=3*u,f=0;f<u;++f){var d=i[o+0]|i[o+1]<<8|i[o+2]<<16;d>l&&(d=l),p(t.Jc[+f],i,c,d),c+=d,l-=d,o+=3}p(t.Jc[+u],i,c,l),i=c<s?0:5}if(0!=i)return Gt(t,i,"cannot parse partitions");for(i=g(c=t.m,7),o=L(c)?m(c,4):0,s=L(c)?m(c,4):0,l=L(c)?m(c,4):0,u=L(c)?m(c,4):0,c=L(c)?m(c,4):0,f=t.Qa,d=0;4>d;++d){if(f.Cb){var v=f.Zb[d];f.Fb||(v+=i)}else{if(0<d){t.pb[d]=t.pb[0];continue}v=i}var y=t.pb[d];y.Sc[0]=Zi[Vt(v+o,127)],y.Sc[1]=Qi[Vt(v+0,127)],y.Eb[0]=2*Zi[Vt(v+s,127)],y.Eb[1]=101581*Qi[Vt(v+l,127)]>>16,8>y.Eb[1]&&(y.Eb[1]=8),y.Qc[0]=Zi[Vt(v+u,117)],y.Qc[1]=Qi[Vt(v+c,127)],y.lc=v+c}if(!h.Rb)return Gt(t,4,"Not a key frame.");for(L(a),h=t.Pa,i=0;4>i;++i){for(o=0;8>o;++o)for(s=0;3>s;++s)for(l=0;11>l;++l)u=T(a,an[i][o][s][l])?g(a,8):sn[i][o][s][l],h.Wc[i][o].Yb[s][l]=u;for(o=0;17>o;++o)h.Xc[i][o]=h.Wc[i][hn[o]]}return t.kc=L(a),t.kc&&(t.Bd=g(a,8)),t.cb=1}function Jt(t,e,r,i,n,s,o){var a=e[n].Yb[r];for(r=0;16>n;++n){if(!T(t,a[r+0]))return n;for(;!T(t,a[r+1]);)if(a=e[++n].Yb[0],r=0,16==n)return 16;var h=e[n+1].Yb;if(T(t,a[r+2])){var l=t,c=0;if(T(l,(f=a)[(u=r)+3]))if(T(l,f[u+6])){for(a=0,u=2*(c=T(l,f[u+8]))+(f=T(l,f[u+9+c])),c=0,f=en[u];f[a];++a)c+=c+T(l,f[a]);c+=3+(8<<u)}else T(l,f[u+7])?(c=7+2*T(l,165),c+=T(l,145)):c=5+T(l,159);else c=T(l,f[u+4])?3+T(l,f[u+5]):2;a=h[2]}else c=1,a=h[1];h=o+rn[n],0>(l=t).b&&k(l);var u,f=l.b,d=(u=l.Ca>>1)-(l.I>>f)>>31;--l.b,l.Ca+=d,l.Ca|=1,l.I-=(u+1&d)<<f,s[h]=((c^d)-d)*i[(0<n)+0]}return 16}function Zt(t){var e=t.rb[t.sb-1];e.la=0,e.Na=0,n(t.zc,0,0,t.zc.length),t.ja=0}function Qt(t,e,r,i,n){n=t[e+r+32*i]+(n>>3),t[e+r+32*i]=-256&n?0>n?0:255:n}function te(t,e,r,i,n,s){Qt(t,e,0,r,i+n),Qt(t,e,1,r,i+s),Qt(t,e,2,r,i-s),Qt(t,e,3,r,i-n)}function ee(t){return(20091*t>>16)+t}function re(t,e,r,i){var n,o=0,a=s(16);for(n=0;4>n;++n){var h=t[e+0]+t[e+8],l=t[e+0]-t[e+8],c=(35468*t[e+4]>>16)-ee(t[e+12]),u=ee(t[e+4])+(35468*t[e+12]>>16);a[o+0]=h+u,a[o+1]=l+c,a[o+2]=l-c,a[o+3]=h-u,o+=4,e++}for(n=o=0;4>n;++n)h=(t=a[o+0]+4)+a[o+8],l=t-a[o+8],c=(35468*a[o+4]>>16)-ee(a[o+12]),Qt(r,i,0,0,h+(u=ee(a[o+4])+(35468*a[o+12]>>16))),Qt(r,i,1,0,l+c),Qt(r,i,2,0,l-c),Qt(r,i,3,0,h-u),o++,i+=32}function ie(t,e,r,i){var n=t[e+0]+4,s=35468*t[e+4]>>16,o=ee(t[e+4]),a=35468*t[e+1]>>16;te(r,i,0,n+o,t=ee(t[e+1]),a),te(r,i,1,n+s,t,a),te(r,i,2,n-s,t,a),te(r,i,3,n-o,t,a)}function ne(t,e,r,i,n){re(t,e,r,i),n&&re(t,e+16,r,i+4)}function se(t,e,r,i){ni(t,e+0,r,i,1),ni(t,e+32,r,i+128,1)}function oe(t,e,r,i){var n;for(t=t[e+0]+4,n=0;4>n;++n)for(e=0;4>e;++e)Qt(r,i,e,n,t)}function ae(t,e,r,i){t[e+0]&&ai(t,e+0,r,i),t[e+16]&&ai(t,e+16,r,i+4),t[e+32]&&ai(t,e+32,r,i+128),t[e+48]&&ai(t,e+48,r,i+128+4)}function he(t,e,r,i){var n,o=s(16);for(n=0;4>n;++n){var a=t[e+0+n]+t[e+12+n],h=t[e+4+n]+t[e+8+n],l=t[e+4+n]-t[e+8+n],c=t[e+0+n]-t[e+12+n];o[0+n]=a+h,o[8+n]=a-h,o[4+n]=c+l,o[12+n]=c-l}for(n=0;4>n;++n)a=(t=o[0+4*n]+3)+o[3+4*n],h=o[1+4*n]+o[2+4*n],l=o[1+4*n]-o[2+4*n],c=t-o[3+4*n],r[i+0]=a+h>>3,r[i+16]=c+l>>3,r[i+32]=a-h>>3,r[i+48]=c-l>>3,i+=64}function le(t,e,r){var i,n=e-32,s=Oi,o=255-t[n-1];for(i=0;i<r;++i){var a,h=s,l=o+t[e-1];for(a=0;a<r;++a)t[e+a]=h[l+t[n+a]];e+=32}}function ce(t,e){le(t,e,4)}function ue(t,e){le(t,e,8)}function fe(t,e){le(t,e,16)}function de(t,e){var r;for(r=0;16>r;++r)i(t,e+32*r,t,e-32,16)}function pe(t,e){var r;for(r=16;0<r;--r)n(t,e,t[e-1],16),e+=32}function ge(t,e,r){var i;for(i=0;16>i;++i)n(e,r+32*i,t,16)}function me(t,e){var r,i=16;for(r=0;16>r;++r)i+=t[e-1+32*r]+t[e+r-32];ge(i>>5,t,e)}function ve(t,e){var r,i=8;for(r=0;16>r;++r)i+=t[e-1+32*r];ge(i>>4,t,e)}function ye(t,e){var r,i=8;for(r=0;16>r;++r)i+=t[e+r-32];ge(i>>4,t,e)}function be(t,e){ge(128,t,e)}function we(t,e,r){return t+2*e+r+2>>2}function _e(t,e){var r,n=e-32;for(n=new Uint8Array([we(t[n-1],t[n+0],t[n+1]),we(t[n+0],t[n+1],t[n+2]),we(t[n+1],t[n+2],t[n+3]),we(t[n+2],t[n+3],t[n+4])]),r=0;4>r;++r)i(t,e+32*r,n,0,n.length)}function xe(t,e){var r=t[e-1],i=t[e-1+32],n=t[e-1+64],s=t[e-1+96];P(t,e+0,16843009*we(t[e-1-32],r,i)),P(t,e+32,16843009*we(r,i,n)),P(t,e+64,16843009*we(i,n,s)),P(t,e+96,16843009*we(n,s,s))}function Se(t,e){var r,i=4;for(r=0;4>r;++r)i+=t[e+r-32]+t[e-1+32*r];for(i>>=3,r=0;4>r;++r)n(t,e+32*r,i,4)}function Ce(t,e){var r=t[e-1+0],i=t[e-1+32],n=t[e-1+64],s=t[e-1-32],o=t[e+0-32],a=t[e+1-32],h=t[e+2-32],l=t[e+3-32];t[e+0+96]=we(i,n,t[e-1+96]),t[e+1+96]=t[e+0+64]=we(r,i,n),t[e+2+96]=t[e+1+64]=t[e+0+32]=we(s,r,i),t[e+3+96]=t[e+2+64]=t[e+1+32]=t[e+0+0]=we(o,s,r),t[e+3+64]=t[e+2+32]=t[e+1+0]=we(a,o,s),t[e+3+32]=t[e+2+0]=we(h,a,o),t[e+3+0]=we(l,h,a)}function Ae(t,e){var r=t[e+1-32],i=t[e+2-32],n=t[e+3-32],s=t[e+4-32],o=t[e+5-32],a=t[e+6-32],h=t[e+7-32];t[e+0+0]=we(t[e+0-32],r,i),t[e+1+0]=t[e+0+32]=we(r,i,n),t[e+2+0]=t[e+1+32]=t[e+0+64]=we(i,n,s),t[e+3+0]=t[e+2+32]=t[e+1+64]=t[e+0+96]=we(n,s,o),t[e+3+32]=t[e+2+64]=t[e+1+96]=we(s,o,a),t[e+3+64]=t[e+2+96]=we(o,a,h),t[e+3+96]=we(a,h,h)}function ke(t,e){var r=t[e-1+0],i=t[e-1+32],n=t[e-1+64],s=t[e-1-32],o=t[e+0-32],a=t[e+1-32],h=t[e+2-32],l=t[e+3-32];t[e+0+0]=t[e+1+64]=s+o+1>>1,t[e+1+0]=t[e+2+64]=o+a+1>>1,t[e+2+0]=t[e+3+64]=a+h+1>>1,t[e+3+0]=h+l+1>>1,t[e+0+96]=we(n,i,r),t[e+0+64]=we(i,r,s),t[e+0+32]=t[e+1+96]=we(r,s,o),t[e+1+32]=t[e+2+96]=we(s,o,a),t[e+2+32]=t[e+3+96]=we(o,a,h),t[e+3+32]=we(a,h,l)}function Le(t,e){var r=t[e+0-32],i=t[e+1-32],n=t[e+2-32],s=t[e+3-32],o=t[e+4-32],a=t[e+5-32],h=t[e+6-32],l=t[e+7-32];t[e+0+0]=r+i+1>>1,t[e+1+0]=t[e+0+64]=i+n+1>>1,t[e+2+0]=t[e+1+64]=n+s+1>>1,t[e+3+0]=t[e+2+64]=s+o+1>>1,t[e+0+32]=we(r,i,n),t[e+1+32]=t[e+0+96]=we(i,n,s),t[e+2+32]=t[e+1+96]=we(n,s,o),t[e+3+32]=t[e+2+96]=we(s,o,a),t[e+3+64]=we(o,a,h),t[e+3+96]=we(a,h,l)}function Te(t,e){var r=t[e-1+0],i=t[e-1+32],n=t[e-1+64],s=t[e-1+96];t[e+0+0]=r+i+1>>1,t[e+2+0]=t[e+0+32]=i+n+1>>1,t[e+2+32]=t[e+0+64]=n+s+1>>1,t[e+1+0]=we(r,i,n),t[e+3+0]=t[e+1+32]=we(i,n,s),t[e+3+32]=t[e+1+64]=we(n,s,s),t[e+3+64]=t[e+2+64]=t[e+0+96]=t[e+1+96]=t[e+2+96]=t[e+3+96]=s}function Pe(t,e){var r=t[e-1+0],i=t[e-1+32],n=t[e-1+64],s=t[e-1+96],o=t[e-1-32],a=t[e+0-32],h=t[e+1-32],l=t[e+2-32];t[e+0+0]=t[e+2+32]=r+o+1>>1,t[e+0+32]=t[e+2+64]=i+r+1>>1,t[e+0+64]=t[e+2+96]=n+i+1>>1,t[e+0+96]=s+n+1>>1,t[e+3+0]=we(a,h,l),t[e+2+0]=we(o,a,h),t[e+1+0]=t[e+3+32]=we(r,o,a),t[e+1+32]=t[e+3+64]=we(i,r,o),t[e+1+64]=t[e+3+96]=we(n,i,r),t[e+1+96]=we(s,n,i)}function Ne(t,e){var r;for(r=0;8>r;++r)i(t,e+32*r,t,e-32,8)}function Oe(t,e){var r;for(r=0;8>r;++r)n(t,e,t[e-1],8),e+=32}function Ee(t,e,r){var i;for(i=0;8>i;++i)n(e,r+32*i,t,8)}function Me(t,e){var r,i=8;for(r=0;8>r;++r)i+=t[e+r-32]+t[e-1+32*r];Ee(i>>4,t,e)}function De(t,e){var r,i=4;for(r=0;8>r;++r)i+=t[e+r-32];Ee(i>>3,t,e)}function Fe(t,e){var r,i=4;for(r=0;8>r;++r)i+=t[e-1+32*r];Ee(i>>3,t,e)}function je(t,e){Ee(128,t,e)}function Ie(t,e,r){var i=t[e-r],n=t[e+0],s=3*(n-i)+Pi[1020+t[e-2*r]-t[e+r]],o=Ni[112+(s+4>>3)];t[e-r]=Oi[255+i+Ni[112+(s+3>>3)]],t[e+0]=Oi[255+n-o]}function Be(t,e,r,i){var n=t[e+0],s=t[e+r];return Ei[255+t[e-2*r]-t[e-r]]>i||Ei[255+s-n]>i}function Re(t,e,r,i){return 4*Ei[255+t[e-r]-t[e+0]]+Ei[255+t[e-2*r]-t[e+r]]<=i}function ze(t,e,r,i,n){var s=t[e-3*r],o=t[e-2*r],a=t[e-r],h=t[e+0],l=t[e+r],c=t[e+2*r],u=t[e+3*r];return 4*Ei[255+a-h]+Ei[255+o-l]>i?0:Ei[255+t[e-4*r]-s]<=n&&Ei[255+s-o]<=n&&Ei[255+o-a]<=n&&Ei[255+u-c]<=n&&Ei[255+c-l]<=n&&Ei[255+l-h]<=n}function Ue(t,e,r,i){var n=2*i+1;for(i=0;16>i;++i)Re(t,e+i,r,n)&&Ie(t,e+i,r)}function qe(t,e,r,i){var n=2*i+1;for(i=0;16>i;++i)Re(t,e+i*r,1,n)&&Ie(t,e+i*r,1)}function We(t,e,r,i){var n;for(n=3;0<n;--n)Ue(t,e+=4*r,r,i)}function He(t,e,r,i){var n;for(n=3;0<n;--n)qe(t,e+=4,r,i)}function Ve(t,e,r,i,n,s,o,a){for(s=2*s+1;0<n--;){if(ze(t,e,r,s,o))if(Be(t,e,r,a))Ie(t,e,r);else{var h=t,l=e,c=r,u=h[l-2*c],f=h[l-c],d=h[l+0],p=h[l+c],g=h[l+2*c],m=27*(y=Pi[1020+3*(d-f)+Pi[1020+u-p]])+63>>7,v=18*y+63>>7,y=9*y+63>>7;h[l-3*c]=Oi[255+h[l-3*c]+y],h[l-2*c]=Oi[255+u+v],h[l-c]=Oi[255+f+m],h[l+0]=Oi[255+d-m],h[l+c]=Oi[255+p-v],h[l+2*c]=Oi[255+g-y]}e+=i}}function Ye(t,e,r,i,n,s,o,a){for(s=2*s+1;0<n--;){if(ze(t,e,r,s,o))if(Be(t,e,r,a))Ie(t,e,r);else{var h=t,l=e,c=r,u=h[l-c],f=h[l+0],d=h[l+c],p=Ni[112+(4+(g=3*(f-u))>>3)],g=Ni[112+(g+3>>3)],m=p+1>>1;h[l-2*c]=Oi[255+h[l-2*c]+m],h[l-c]=Oi[255+u+g],h[l+0]=Oi[255+f-p],h[l+c]=Oi[255+d-m]}e+=i}}function Xe(t,e,r,i,n,s){Ve(t,e,r,1,16,i,n,s)}function Ge(t,e,r,i,n,s){Ve(t,e,1,r,16,i,n,s)}function $e(t,e,r,i,n,s){var o;for(o=3;0<o;--o)Ye(t,e+=4*r,r,1,16,i,n,s)}function Ke(t,e,r,i,n,s){var o;for(o=3;0<o;--o)Ye(t,e+=4,1,r,16,i,n,s)}function Je(t,e,r,i,n,s,o,a){Ve(t,e,n,1,8,s,o,a),Ve(r,i,n,1,8,s,o,a)}function Ze(t,e,r,i,n,s,o,a){Ve(t,e,1,n,8,s,o,a),Ve(r,i,1,n,8,s,o,a)}function Qe(t,e,r,i,n,s,o,a){Ye(t,e+4*n,n,1,8,s,o,a),Ye(r,i+4*n,n,1,8,s,o,a)}function tr(t,e,r,i,n,s,o,a){Ye(t,e+4,1,n,8,s,o,a),Ye(r,i+4,1,n,8,s,o,a)}function er(){this.ba=new ot,this.ec=[],this.cc=[],this.Mc=[],this.Dc=this.Nc=this.dc=this.fc=0,this.Oa=new ht,this.memory=0,this.Ib="OutputFunc",this.Jb="OutputAlphaFunc",this.Nd="OutputRowFunc"}function rr(){this.data=[],this.offset=this.kd=this.ha=this.w=0,this.na=[],this.xa=this.gb=this.Ja=this.Sa=this.P=0}function ir(){this.nc=this.Ea=this.b=this.hc=0,this.K=[],this.w=0}function nr(){this.ua=0,this.Wa=new F,this.vb=new F,this.md=this.xc=this.wc=0,this.vc=[],this.Wb=0,this.Ya=new d,this.yc=new u}function sr(){this.xb=this.a=0,this.l=new Yt,this.ca=new ot,this.V=[],this.Ba=0,this.Ta=[],this.Ua=0,this.m=new _,this.Pb=0,this.wd=new _,this.Ma=this.$=this.C=this.i=this.c=this.xd=0,this.s=new nr,this.ab=0,this.gc=o(4,ir),this.Oc=0}function or(){this.Lc=this.Z=this.$a=this.i=this.c=0,this.l=new Yt,this.ic=0,this.ca=[],this.tb=0,this.qd=null,this.rd=0}function ar(t,e,r,i,n,s,o){for(t=null==t?0:t[e+0],e=0;e<o;++e)n[s+e]=t+r[i+e]&255,t=n[s+e]}function hr(t,e,r,i,n,s,o){var a;if(null==t)ar(null,null,r,i,n,s,o);else for(a=0;a<o;++a)n[s+a]=t[e+a]+r[i+a]&255}function lr(t,e,r,i,n,s,o){if(null==t)ar(null,null,r,i,n,s,o);else{var a,h=t[e+0],l=h,c=h;for(a=0;a<o;++a)l=c+(h=t[e+a])-l,c=r[i+a]+(-256&l?0>l?0:255:l)&255,l=h,n[s+a]=c}}function cr(t,r,n,o){var a=r.width,h=r.o;if(e(null!=t&&null!=r),0>n||0>=o||n+o>h)return null;if(!t.Cc){if(null==t.ga){var l;if(t.ga=new or,(l=null==t.ga)||(l=r.width*r.o,e(0==t.Gb.length),t.Gb=s(l),t.Uc=0,null==t.Gb?l=0:(t.mb=t.Gb,t.nb=t.Uc,t.rc=null,l=1),l=!l),!l){l=t.ga;var c=t.Fa,u=t.P,f=t.qc,d=t.mb,p=t.nb,g=u+1,m=f-1,y=l.l;if(e(null!=c&&null!=d&&null!=r),pn[0]=null,pn[1]=ar,pn[2]=hr,pn[3]=lr,l.ca=d,l.tb=p,l.c=r.width,l.i=r.height,e(0<l.c&&0<l.i),1>=f)r=0;else if(l.$a=3&c[u+0],l.Z=c[u+0]>>2&3,l.Lc=c[u+0]>>4&3,u=c[u+0]>>6&3,0>l.$a||1<l.$a||4<=l.Z||1<l.Lc||u)r=0;else if(y.put=dt,y.ac=ft,y.bc=pt,y.ma=l,y.width=r.width,y.height=r.height,y.Da=r.Da,y.v=r.v,y.va=r.va,y.j=r.j,y.o=r.o,l.$a)t:{e(1==l.$a),r=Tt();e:for(;;){if(null==r){r=0;break t}if(e(null!=l),l.mc=r,r.c=l.c,r.i=l.i,r.l=l.l,r.l.ma=l,r.l.width=l.c,r.l.height=l.i,r.a=0,v(r.m,c,g,m),!Pt(l.c,l.i,1,r,null))break e;if(1==r.ab&&3==r.gc[0].hc&&St(r.s)?(l.ic=1,c=r.c*r.i,r.Ta=null,r.Ua=0,r.V=s(c),r.Ba=0,null==r.V?(r.a=1,r=0):r=1):(l.ic=0,r=Nt(r,l.c)),!r)break e;r=1;break t}l.mc=null,r=0}else r=m>=l.c*l.i;l=!r}if(l)return null;1!=t.ga.Lc?t.Ga=0:o=h-n}e(null!=t.ga),e(n+o<=h);t:{if(r=(c=t.ga).c,h=c.l.o,0==c.$a){if(g=t.rc,m=t.Vc,y=t.Fa,u=t.P+1+n*r,f=t.mb,d=t.nb+n*r,e(u<=t.P+t.qc),0!=c.Z)for(e(null!=pn[c.Z]),l=0;l<o;++l)pn[c.Z](g,m,y,u,f,d,r),g=f,m=d,d+=r,u+=r;else for(l=0;l<o;++l)i(f,d,y,u,r),g=f,m=d,d+=r,u+=r;t.rc=g,t.Vc=m}else{if(e(null!=c.mc),r=n+o,e(null!=(l=c.mc)),e(r<=l.i),l.C>=r)r=1;else if(c.ic||gr(),c.ic){c=l.V,g=l.Ba,m=l.c;var b=l.i,w=(y=1,u=l.$/m,f=l.$%m,d=l.m,p=l.s,l.$),_=m*b,x=m*r,C=p.wc,k=w<x?wt(p,f,u):null;e(w<=_),e(r<=b),e(St(p));e:for(;;){for(;!d.h&&w<x;){if(f&C||(k=wt(p,f,u)),e(null!=k),A(d),256>(b=yt(k.G[0],k.H[0],d)))c[g+w]=b,++w,++f>=m&&(f=0,++u<=r&&!(u%16)&&At(l,u));else{if(!(280>b)){y=0;break e}b=mt(b-256,d);var L,T=yt(k.G[4],k.H[4],d);if(A(d),!(w>=(T=vt(m,T=mt(T,d)))&&_-w>=b)){y=0;break e}for(L=0;L<b;++L)c[g+w+L]=c[g+w+L-T];for(w+=b,f+=b;f>=m;)f-=m,++u<=r&&!(u%16)&&At(l,u);w<x&&f&C&&(k=wt(p,f,u))}e(d.h==S(d))}At(l,u>r?r:u);break e}!y||d.h&&w<_?(y=0,l.a=d.h?5:3):l.$=w,r=y}else r=kt(l,l.V,l.Ba,l.c,l.i,r,Ot);if(!r){o=0;break t}}n+o>=h&&(t.Cc=1),o=1}if(!o)return null;if(t.Cc&&(null!=(o=t.ga)&&(o.mc=null),t.ga=null,0<t.Ga))return alert("todo:WebPDequantizeLevels"),null}return t.nb+n*a}function ur(t,e,r,i,n,s){for(;0<n--;){var o,a=t,h=e+(r?1:0),l=t,c=e+(r?0:3);for(o=0;o<i;++o){var u=l[c+4*o];255!=u&&(u*=32897,a[h+4*o+0]=a[h+4*o+0]*u>>23,a[h+4*o+1]=a[h+4*o+1]*u>>23,a[h+4*o+2]=a[h+4*o+2]*u>>23)}e+=s}}function fr(t,e,r,i,n){for(;0<i--;){var s;for(s=0;s<r;++s){var o=t[e+2*s+0],a=15&(l=t[e+2*s+1]),h=4369*a,l=(240&l|l>>4)*h>>16;t[e+2*s+0]=(240&o|o>>4)*h>>16&240|(15&o|o<<4)*h>>16>>4&15,t[e+2*s+1]=240&l|a}e+=n}}function dr(t,e,r,i,n,s,o,a){var h,l,c=255;for(l=0;l<n;++l){for(h=0;h<i;++h){var u=t[e+h];s[o+4*h]=u,c&=u}e+=r,o+=a}return 255!=c}function pr(t,e,r,i,n){var s;for(s=0;s<n;++s)r[i+s]=t[e+s]>>8}function gr(){_i=ur,xi=fr,Si=dr,Ci=pr}function mr(r,i,n){t[r]=function(t,r,s,o,a,h,l,c,u,f,d,p,g,m,v,y,b){var w,_=b-1>>1,x=a[h+0]|l[c+0]<<16,S=u[f+0]|d[p+0]<<16;e(null!=t);var C=3*x+S+131074>>2;for(i(t[r+0],255&C,C>>16,g,m),null!=s&&(C=3*S+x+131074>>2,i(s[o+0],255&C,C>>16,v,y)),w=1;w<=_;++w){var A=a[h+w]|l[c+w]<<16,k=u[f+w]|d[p+w]<<16,L=x+A+S+k+524296,T=L+2*(A+S)>>3;C=T+x>>1,x=(L=L+2*(x+k)>>3)+A>>1,i(t[r+2*w-1],255&C,C>>16,g,m+(2*w-1)*n),i(t[r+2*w-0],255&x,x>>16,g,m+(2*w-0)*n),null!=s&&(C=L+S>>1,x=T+k>>1,i(s[o+2*w-1],255&C,C>>16,v,y+(2*w-1)*n),i(s[o+2*w+0],255&x,x>>16,v,y+(2*w+0)*n)),x=A,S=k}1&b||(C=3*x+S+131074>>2,i(t[r+b-1],255&C,C>>16,g,m+(b-1)*n),null!=s&&(C=3*S+x+131074>>2,i(s[o+b-1],255&C,C>>16,v,y+(b-1)*n)))}}function vr(){gn[Mi]=mn,gn[Di]=yn,gn[Fi]=vn,gn[ji]=bn,gn[Ii]=wn,gn[Bi]=xn,gn[Ri]=Sn,gn[zi]=yn,gn[Ui]=bn,gn[qi]=wn,gn[Wi]=xn}function yr(t){return t&~Pn?0>t?0:255:t>>Tn}function br(t,e){return yr((19077*t>>8)+(26149*e>>8)-14234)}function wr(t,e,r){return yr((19077*t>>8)-(6419*e>>8)-(13320*r>>8)+8708)}function _r(t,e){return yr((19077*t>>8)+(33050*e>>8)-17685)}function xr(t,e,r,i,n){i[n+0]=br(t,r),i[n+1]=wr(t,e,r),i[n+2]=_r(t,e)}function Sr(t,e,r,i,n){i[n+0]=_r(t,e),i[n+1]=wr(t,e,r),i[n+2]=br(t,r)}function Cr(t,e,r,i,n){var s=wr(t,e,r);e=s<<3&224|_r(t,e)>>3,i[n+0]=248&br(t,r)|s>>5,i[n+1]=e}function Ar(t,e,r,i,n){var s=240&_r(t,e)|15;i[n+0]=240&br(t,r)|wr(t,e,r)>>4,i[n+1]=s}function kr(t,e,r,i,n){i[n+0]=255,xr(t,e,r,i,n+1)}function Lr(t,e,r,i,n){Sr(t,e,r,i,n),i[n+3]=255}function Tr(t,e,r,i,n){xr(t,e,r,i,n),i[n+3]=255}function Pr(e,r,i){t[e]=function(t,e,n,s,o,a,h,l,c){for(var u=l+(-2&c)*i;l!=u;)r(t[e+0],n[s+0],o[a+0],h,l),r(t[e+1],n[s+0],o[a+0],h,l+i),e+=2,++s,++a,l+=2*i;1&c&&r(t[e+0],n[s+0],o[a+0],h,l)}}function Nr(t,e,r){return 0==r?0==t?0==e?6:5:0==e?4:0:r}function Or(t,e,r,i,n){switch(t>>>30){case 3:ni(e,r,i,n,0);break;case 2:si(e,r,i,n);break;case 1:ai(e,r,i,n)}}function Er(t,e){var r,s,o=e.M,a=e.Nb,h=t.oc,l=t.pc+40,c=t.oc,u=t.pc+584,f=t.oc,d=t.pc+600;for(r=0;16>r;++r)h[l+32*r-1]=129;for(r=0;8>r;++r)c[u+32*r-1]=129,f[d+32*r-1]=129;for(0<o?h[l-1-32]=c[u-1-32]=f[d-1-32]=129:(n(h,l-32-1,127,21),n(c,u-32-1,127,9),n(f,d-32-1,127,9)),s=0;s<t.za;++s){var p=e.ya[e.aa+s];if(0<s){for(r=-1;16>r;++r)i(h,l+32*r-4,h,l+32*r+12,4);for(r=-1;8>r;++r)i(c,u+32*r-4,c,u+32*r+4,4),i(f,d+32*r-4,f,d+32*r+4,4)}var g=t.Gd,m=t.Hd+s,v=p.ad,y=p.Hc;if(0<o&&(i(h,l-32,g[m].y,0,16),i(c,u-32,g[m].f,0,8),i(f,d-32,g[m].ea,0,8)),p.Za){var b=h,w=l-32+16;for(0<o&&(s>=t.za-1?n(b,w,g[m].y[15],4):i(b,w,g[m+1].y,0,4)),r=0;4>r;r++)b[w+128+r]=b[w+256+r]=b[w+384+r]=b[w+0+r];for(r=0;16>r;++r,y<<=2)b=h,w=l+In[r],cn[p.Ob[r]](b,w),Or(y,v,16*+r,b,w)}else if(b=Nr(s,o,p.Ob[0]),ln[b](h,l),0!=y)for(r=0;16>r;++r,y<<=2)Or(y,v,16*+r,h,l+In[r]);for(r=p.Gc,b=Nr(s,o,p.Dd),un[b](c,u),un[b](f,d),y=v,b=c,w=u,255&(p=0|r)&&(170&p?oi(y,256,b,w):hi(y,256,b,w)),p=f,y=d,255&(r>>=8)&&(170&r?oi(v,320,p,y):hi(v,320,p,y)),o<t.Ub-1&&(i(g[m].y,0,h,l+480,16),i(g[m].f,0,c,u+224,8),i(g[m].ea,0,f,d+224,8)),r=8*a*t.B,g=t.sa,m=t.ta+16*s+16*a*t.R,v=t.qa,p=t.ra+8*s+r,y=t.Ha,b=t.Ia+8*s+r,r=0;16>r;++r)i(g,m+r*t.R,h,l+32*r,16);for(r=0;8>r;++r)i(v,p+r*t.B,c,u+32*r,8),i(y,b+r*t.B,f,d+32*r,8)}}function Mr(t,i,n,s,o,a,h,l,c){var u=[0],f=[0],d=0,p=null!=c?c.kd:0,g=null!=c?c:new rr;if(null==t||12>n)return 7;g.data=t,g.w=i,g.ha=n,i=[i],n=[n],g.gb=[g.gb];t:{var m=i,y=n,b=g.gb;if(e(null!=t),e(null!=y),e(null!=b),b[0]=0,12<=y[0]&&!r(t,m[0],"RIFF")){if(r(t,m[0]+8,"WEBP")){b=3;break t}var w=E(t,m[0]+4);if(12>w||4294967286<w){b=3;break t}if(p&&w>y[0]-8){b=7;break t}b[0]=w,m[0]+=12,y[0]-=12}b=0}if(0!=b)return b;for(w=0<g.gb[0],n=n[0];;){t:{var x=t;y=i,b=n;var S=u,C=f,A=m=[0];if((T=d=[d])[0]=0,8>b[0])b=7;else{if(!r(x,y[0],"VP8X")){if(10!=E(x,y[0]+4)){b=3;break t}if(18>b[0]){b=7;break t}var k=E(x,y[0]+8),L=1+O(x,y[0]+12);if(2147483648<=L*(x=1+O(x,y[0]+15))){b=3;break t}null!=A&&(A[0]=k),null!=S&&(S[0]=L),null!=C&&(C[0]=x),y[0]+=18,b[0]-=18,T[0]=1}b=0}}if(d=d[0],m=m[0],0!=b)return b;if(y=!!(2&m),!w&&d)return 3;if(null!=a&&(a[0]=!!(16&m)),null!=h&&(h[0]=y),null!=l&&(l[0]=0),h=u[0],m=f[0],d&&y&&null==c){b=0;break}if(4>n){b=7;break}if(w&&d||!w&&!d&&!r(t,i[0],"ALPH")){n=[n],g.na=[g.na],g.P=[g.P],g.Sa=[g.Sa];t:{k=t,b=i,w=n;var T=g.gb;S=g.na,C=g.P,A=g.Sa,L=22,e(null!=k),e(null!=w),x=b[0];var P=w[0];for(e(null!=S),e(null!=A),S[0]=null,C[0]=null,A[0]=0;;){if(b[0]=x,w[0]=P,8>P){b=7;break t}var N=E(k,x+4);if(4294967286<N){b=3;break t}var M=8+N+1&-2;if(L+=M,0<T&&L>T){b=3;break t}if(!r(k,x,"VP8 ")||!r(k,x,"VP8L")){b=0;break t}if(P[0]<M){b=7;break t}r(k,x,"ALPH")||(S[0]=k,C[0]=x+8,A[0]=N),x+=M,P-=M}}if(n=n[0],g.na=g.na[0],g.P=g.P[0],g.Sa=g.Sa[0],0!=b)break}n=[n],g.Ja=[g.Ja],g.xa=[g.xa];t:if(T=t,b=i,w=n,S=g.gb[0],C=g.Ja,A=g.xa,k=b[0],x=!r(T,k,"VP8 "),L=!r(T,k,"VP8L"),e(null!=T),e(null!=w),e(null!=C),e(null!=A),8>w[0])b=7;else{if(x||L){if(T=E(T,k+4),12<=S&&T>S-12){b=3;break t}if(p&&T>w[0]-8){b=7;break t}C[0]=T,b[0]+=8,w[0]-=8,A[0]=L}else A[0]=5<=w[0]&&47==T[k+0]&&!(T[k+4]>>5),C[0]=w[0];b=0}if(n=n[0],g.Ja=g.Ja[0],g.xa=g.xa[0],i=i[0],0!=b)break;if(4294967286<g.Ja)return 3;if(null==l||y||(l[0]=g.xa?2:1),h=[h],m=[m],g.xa){if(5>n){b=7;break}l=h,p=m,y=a,null==t||5>n?t=0:5<=n&&47==t[i+0]&&!(t[i+4]>>5)?(w=[0],T=[0],S=[0],v(C=new _,t,i,n),gt(C,w,T,S)?(null!=l&&(l[0]=w[0]),null!=p&&(p[0]=T[0]),null!=y&&(y[0]=S[0]),t=1):t=0):t=0}else{if(10>n){b=7;break}l=m,null==t||10>n||!$t(t,i+3,n-3)?t=0:(p=t[i+0]|t[i+1]<<8|t[i+2]<<16,y=16383&(t[i+7]<<8|t[i+6]),t=16383&(t[i+9]<<8|t[i+8]),1&p||3<(p>>1&7)||!(p>>4&1)||p>>5>=g.Ja||!y||!t?t=0:(h&&(h[0]=y),l&&(l[0]=t),t=1))}if(!t)return 3;if(h=h[0],m=m[0],d&&(u[0]!=h||f[0]!=m))return 3;null!=c&&(c[0]=g,c.offset=i-c.w,e(4294967286>i-c.w),e(c.offset==c.ha-n));break}return 0==b||7==b&&d&&null==c?(null!=a&&(a[0]|=null!=g.na&&0<g.na.length),null!=s&&(s[0]=h),null!=o&&(o[0]=m),0):b}function Dr(t,e,r){var i=e.width,n=e.height,s=0,o=0,a=i,h=n;if(e.Da=null!=t&&0<t.Da,e.Da&&(a=t.cd,h=t.bd,s=t.v,o=t.j,11>r||(s&=-2,o&=-2),0>s||0>o||0>=a||0>=h||s+a>i||o+h>n))return 0;if(e.v=s,e.j=o,e.va=s+a,e.o=o+h,e.U=a,e.T=h,e.da=null!=t&&0<t.da,e.da){if(!j(a,h,r=[t.ib],s=[t.hb]))return 0;e.ib=r[0],e.hb=s[0]}return e.ob=null!=t&&t.ob,e.Kb=null==t||!t.Sd,e.da&&(e.ob=e.ib<3*i/4&&e.hb<3*n/4,e.Kb=0),1}function Fr(t){if(null==t)return 2;if(11>t.S){var e=t.f.RGBA;e.fb+=(t.height-1)*e.A,e.A=-e.A}else e=t.f.kb,t=t.height,e.O+=(t-1)*e.fa,e.fa=-e.fa,e.N+=(t-1>>1)*e.Ab,e.Ab=-e.Ab,e.W+=(t-1>>1)*e.Db,e.Db=-e.Db,null!=e.F&&(e.J+=(t-1)*e.lb,e.lb=-e.lb);return 0}function jr(t,e,r,i){if(null==i||0>=t||0>=e)return 2;if(null!=r){if(r.Da){var n=r.cd,o=r.bd,a=-2&r.v,h=-2&r.j;if(0>a||0>h||0>=n||0>=o||a+n>t||h+o>e)return 2;t=n,e=o}if(r.da){if(!j(t,e,n=[r.ib],o=[r.hb]))return 2;t=n[0],e=o[0]}}i.width=t,i.height=e;t:{var l=i.width,c=i.height;if(t=i.S,0>=l||0>=c||!(t>=Mi&&13>t))t=2;else{if(0>=i.Rd&&null==i.sd){a=o=n=e=0;var u=(h=l*zn[t])*c;if(11>t||(o=(c+1)/2*(e=(l+1)/2),12==t&&(a=(n=l)*c)),null==(c=s(u+2*o+a))){t=1;break t}i.sd=c,11>t?((l=i.f.RGBA).eb=c,l.fb=0,l.A=h,l.size=u):((l=i.f.kb).y=c,l.O=0,l.fa=h,l.Fd=u,l.f=c,l.N=0+u,l.Ab=e,l.Cd=o,l.ea=c,l.W=0+u+o,l.Db=e,l.Ed=o,12==t&&(l.F=c,l.J=0+u+2*o),l.Tc=a,l.lb=n)}if(e=1,n=i.S,o=i.width,a=i.height,n>=Mi&&13>n)if(11>n)t=i.f.RGBA,e&=(h=Math.abs(t.A))*(a-1)+o<=t.size,e&=h>=o*zn[n],e&=null!=t.eb;else{t=i.f.kb,h=(o+1)/2,u=(a+1)/2,l=Math.abs(t.fa),c=Math.abs(t.Ab);var f=Math.abs(t.Db),d=Math.abs(t.lb),p=d*(a-1)+o;e&=l*(a-1)+o<=t.Fd,e&=c*(u-1)+h<=t.Cd,e=(e&=f*(u-1)+h<=t.Ed)&l>=o&c>=h&f>=h,e&=null!=t.y,e&=null!=t.f,e&=null!=t.ea,12==n&&(e&=d>=o,e&=p<=t.Tc,e&=null!=t.F)}else e=0;t=e?0:2}}return 0!=t||null!=r&&r.fd&&(t=Fr(i)),t}var Ir=64,Br=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],Rr=24,zr=32,Ur=8,qr=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];R("Predictor0","PredictorAdd0"),t.Predictor0=function(){return 4278190080},t.Predictor1=function(t){return t},t.Predictor2=function(t,e,r){return e[r+0]},t.Predictor3=function(t,e,r){return e[r+1]},t.Predictor4=function(t,e,r){return e[r-1]},t.Predictor5=function(t,e,r){return U(U(t,e[r+1]),e[r+0])},t.Predictor6=function(t,e,r){return U(t,e[r-1])},t.Predictor7=function(t,e,r){return U(t,e[r+0])},t.Predictor8=function(t,e,r){return U(e[r-1],e[r+0])},t.Predictor9=function(t,e,r){return U(e[r+0],e[r+1])},t.Predictor10=function(t,e,r){return U(U(t,e[r-1]),U(e[r+0],e[r+1]))},t.Predictor11=function(t,e,r){var i=e[r+0];return 0>=H(i>>24&255,t>>24&255,(e=e[r-1])>>24&255)+H(i>>16&255,t>>16&255,e>>16&255)+H(i>>8&255,t>>8&255,e>>8&255)+H(255&i,255&t,255&e)?i:t},t.Predictor12=function(t,e,r){var i=e[r+0];return(q((t>>24&255)+(i>>24&255)-((e=e[r-1])>>24&255))<<24|q((t>>16&255)+(i>>16&255)-(e>>16&255))<<16|q((t>>8&255)+(i>>8&255)-(e>>8&255))<<8|q((255&t)+(255&i)-(255&e)))>>>0},t.Predictor13=function(t,e,r){var i=e[r-1];return(W((t=U(t,e[r+0]))>>24&255,i>>24&255)<<24|W(t>>16&255,i>>16&255)<<16|W(t>>8&255,i>>8&255)<<8|W(255&t,255&i))>>>0};var Wr=t.PredictorAdd0;t.PredictorAdd1=V,R("Predictor2","PredictorAdd2"),R("Predictor3","PredictorAdd3"),R("Predictor4","PredictorAdd4"),R("Predictor5","PredictorAdd5"),R("Predictor6","PredictorAdd6"),R("Predictor7","PredictorAdd7"),R("Predictor8","PredictorAdd8"),R("Predictor9","PredictorAdd9"),R("Predictor10","PredictorAdd10"),R("Predictor11","PredictorAdd11"),R("Predictor12","PredictorAdd12"),R("Predictor13","PredictorAdd13");var Hr=t.PredictorAdd2;$("ColorIndexInverseTransform","MapARGB","32b",function(t){return t>>8&255},function(t){return t}),$("VP8LColorIndexInverseTransformAlpha","MapAlpha","8b",function(t){return t},function(t){return t>>8&255});var Vr,Yr=t.ColorIndexInverseTransform,Xr=t.MapARGB,Gr=t.VP8LColorIndexInverseTransformAlpha,$r=t.MapAlpha,Kr=t.VP8LPredictorsAdd=[];Kr.length=16,(t.VP8LPredictors=[]).length=16,(t.VP8LPredictorsAdd_C=[]).length=16,(t.VP8LPredictors_C=[]).length=16;var Jr,Zr,Qr,ti,ei,ri,ii,ni,si,oi,ai,hi,li,ci,ui,fi,di,pi,gi,mi,vi,yi,bi,wi,_i,xi,Si,Ci,_n=s(511),Ai=s(2041),ki=s(225),Li=s(767),Ti=0,Pi=Ai,Ni=ki,Oi=Li,Ei=_n,Mi=0,Di=1,Fi=2,ji=3,Ii=4,Bi=5,Ri=6,zi=7,Ui=8,qi=9,Wi=10,Hi=[2,3,7],Vi=[3,3,11],Yi=[280,256,256,256,40],Xi=[0,1,1,1,0],Gi=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],$i=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],Ki=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],Ji=8,Zi=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],Qi=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],tn=null,en=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],rn=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],nn=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],sn=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],on=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],an=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],hn=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],ln=[],cn=[],un=[],fn=1,dn=2,pn=[],gn=[];mr("UpsampleRgbLinePair",xr,3),mr("UpsampleBgrLinePair",Sr,3),mr("UpsampleRgbaLinePair",Tr,4),mr("UpsampleBgraLinePair",Lr,4),mr("UpsampleArgbLinePair",kr,4),mr("UpsampleRgba4444LinePair",Ar,2),mr("UpsampleRgb565LinePair",Cr,2);var mn=t.UpsampleRgbLinePair,vn=t.UpsampleBgrLinePair,yn=t.UpsampleRgbaLinePair,bn=t.UpsampleBgraLinePair,wn=t.UpsampleArgbLinePair,xn=t.UpsampleRgba4444LinePair,Sn=t.UpsampleRgb565LinePair,Cn=16,An=1<<Cn-1,kn=-227,Ln=482,Tn=6,Pn=(256<<Tn)-1,Nn=0,On=s(256),En=s(256),Mn=s(256),Dn=s(256),Fn=s(Ln-kn),jn=s(Ln-kn);Pr("YuvToRgbRow",xr,3),Pr("YuvToBgrRow",Sr,3),Pr("YuvToRgbaRow",Tr,4),Pr("YuvToBgraRow",Lr,4),Pr("YuvToArgbRow",kr,4),Pr("YuvToRgba4444Row",Ar,2),Pr("YuvToRgb565Row",Cr,2);var In=[0,4,8,12,128,132,136,140,256,260,264,268,384,388,392,396],Bn=[0,2,8],Rn=[8,7,6,4,4,2,2,2,1,1,1,1];this.WebPDecodeRGBA=function(t,r,a,h,l){var c=Di,u=new er,f=new ot;u.ba=f,f.S=c,f.width=[f.width],f.height=[f.height];var d=f.width,p=f.height,g=new at;if(null==g||null==t)var m=2;else e(null!=g),m=Mr(t,r,a,g.width,g.height,g.Pd,g.Qd,g.format,null);if(0!=m?d=0:(null!=d&&(d[0]=g.width[0]),null!=p&&(p[0]=g.height[0]),d=1),d){f.width=f.width[0],f.height=f.height[0],null!=h&&(h[0]=f.width),null!=l&&(l[0]=f.height);t:{if(h=new Yt,(l=new rr).data=t,l.w=r,l.ha=a,l.kd=1,r=[0],e(null!=l),(0==(t=Mr(l.data,l.w,l.ha,null,null,null,r,null,l))||7==t)&&r[0]&&(t=4),0==(r=t)){if(e(null!=u),h.data=l.data,h.w=l.w+l.offset,h.ha=l.ha-l.offset,h.put=dt,h.ac=ft,h.bc=pt,h.ma=u,l.xa){if(null==(t=Tt())){u=1;break t}if(function(t,r){var i=[0],n=[0],s=[0];e:for(;;){if(null==t)return 0;if(null==r)return t.a=2,0;if(t.l=r,t.a=0,v(t.m,r.data,r.w,r.ha),!gt(t.m,i,n,s)){t.a=3;break e}if(t.xb=dn,r.width=i[0],r.height=n[0],!Pt(i[0],n[0],1,t,null))break e;return 1}return e(0!=t.a),0}(t,h)){if(h=0==(r=jr(h.width,h.height,u.Oa,u.ba))){e:{h=t;r:for(;;){if(null==h){h=0;break e}if(e(null!=h.s.yc),e(null!=h.s.Ya),e(0<h.s.Wb),e(null!=(a=h.l)),e(null!=(l=a.ma)),0!=h.xb){if(h.ca=l.ba,h.tb=l.tb,e(null!=h.ca),!Dr(l.Oa,a,ji)){h.a=2;break r}if(!Nt(h,a.width))break r;if(a.da)break r;if((a.da||it(h.ca.S))&&gr(),11>h.ca.S||(alert("todo:WebPInitConvertARGBToYUV"),null!=h.ca.f.kb.F&&gr()),h.Pb&&0<h.s.ua&&null==h.s.vb.X&&!M(h.s.vb,h.s.Wa.Xa)){h.a=1;break r}h.xb=0}if(!kt(h,h.V,h.Ba,h.c,h.i,a.o,xt))break r;l.Dc=h.Ma,h=1;break e}e(0!=h.a),h=0}h=!h}h&&(r=t.a)}else r=t.a}else{if(null==(t=new Xt)){u=1;break t}if(t.Fa=l.na,t.P=l.P,t.qc=l.Sa,Kt(t,h)){if(0==(r=jr(h.width,h.height,u.Oa,u.ba))){if(t.Aa=0,a=u.Oa,e(null!=(l=t)),null!=a){if(0<(d=0>(d=a.Md)?0:100<d?255:255*d/100)){for(p=g=0;4>p;++p)12>(m=l.pb[p]).lc&&(m.ia=d*Rn[0>m.lc?0:m.lc]>>3),g|=m.ia;g&&(alert("todo:VP8InitRandom"),l.ia=1)}l.Ga=a.Id,100<l.Ga?l.Ga=100:0>l.Ga&&(l.Ga=0)}(function(t,r){if(null==t)return 0;if(null==r)return Gt(t,2,"NULL VP8Io parameter in VP8Decode().");if(!t.cb&&!Kt(t,r))return 0;if(e(t.cb),null==r.ac||r.ac(r)){r.ob&&(t.L=0);var a=Bn[t.L];if(2==t.L?(t.yb=0,t.zb=0):(t.yb=r.v-a>>4,t.zb=r.j-a>>4,0>t.yb&&(t.yb=0),0>t.zb&&(t.zb=0)),t.Va=r.o+15+a>>4,t.Hb=r.va+15+a>>4,t.Hb>t.za&&(t.Hb=t.za),t.Va>t.Ub&&(t.Va=t.Ub),0<t.L){var h=t.ed;for(a=0;4>a;++a){var l;if(t.Qa.Cb){var c=t.Qa.Lb[a];t.Qa.Fb||(c+=h.Tb)}else c=h.Tb;for(l=0;1>=l;++l){var u=t.gd[a][l],f=c;if(h.Pc&&(f+=h.vd[0],l&&(f+=h.od[0])),0<(f=0>f?0:63<f?63:f)){var d=f;0<h.wb&&(d=4<h.wb?d>>2:d>>1)>9-h.wb&&(d=9-h.wb),1>d&&(d=1),u.dd=d,u.tc=2*f+d,u.ld=40<=f?2:15<=f?1:0}else u.tc=0;u.La=l}}}a=0}else Gt(t,6,"Frame setup failed"),a=t.a;if(a=0==a){if(a){t.$c=0,0<t.Aa||(t.Ic=1);e:{a=t.Ic,h=4*(d=t.za);var p=32*d,g=d+1,m=0<t.L?d*(0<t.Aa?2:1):0,v=(2==t.Aa?2:1)*d;if((u=h+832+(l=3*(16*a+Bn[t.L])/2*p)+(c=null!=t.Fa&&0<t.Fa.length?t.Kc.c*t.Kc.i:0))!=u)a=0;else{if(u>t.Vb){if(t.Vb=0,t.Ec=s(u),t.Fc=0,null==t.Ec){a=Gt(t,1,"no memory during frame initialization.");break e}t.Vb=u}u=t.Ec,f=t.Fc,t.Ac=u,t.Bc=f,f+=h,t.Gd=o(p,Wt),t.Hd=0,t.rb=o(g+1,Rt),t.sb=1,t.wa=m?o(m,Bt):null,t.Y=0,t.D.Nb=0,t.D.wa=t.wa,t.D.Y=t.Y,0<t.Aa&&(t.D.Y+=d),e(!0),t.oc=u,t.pc=f,f+=832,t.ya=o(v,Ut),t.aa=0,t.D.ya=t.ya,t.D.aa=t.aa,2==t.Aa&&(t.D.aa+=d),t.R=16*d,t.B=8*d,d=(p=Bn[t.L])*t.R,p=p/2*t.B,t.sa=u,t.ta=f+d,t.qa=t.sa,t.ra=t.ta+16*a*t.R+p,t.Ha=t.qa,t.Ia=t.ra+8*a*t.B+p,t.$c=0,f+=l,t.mb=c?u:null,t.nb=c?f:null,e(f+c<=t.Fc+t.Vb),Zt(t),n(t.Ac,t.Bc,0,h),a=1}}if(a){if(r.ka=0,r.y=t.sa,r.O=t.ta,r.f=t.qa,r.N=t.ra,r.ea=t.Ha,r.Vd=t.Ia,r.fa=t.R,r.Rc=t.B,r.F=null,r.J=0,!Ti){for(a=-255;255>=a;++a)_n[255+a]=0>a?-a:a;for(a=-1020;1020>=a;++a)Ai[1020+a]=-128>a?-128:127<a?127:a;for(a=-112;112>=a;++a)ki[112+a]=-16>a?-16:15<a?15:a;for(a=-255;510>=a;++a)Li[255+a]=0>a?0:255<a?255:a;Ti=1}ii=he,ni=ne,oi=se,ai=oe,hi=ae,si=ie,li=Xe,ci=Ge,ui=Je,fi=Ze,di=$e,pi=Ke,gi=Qe,mi=tr,vi=Ue,yi=qe,bi=We,wi=He,cn[0]=Se,cn[1]=ce,cn[2]=_e,cn[3]=xe,cn[4]=Ce,cn[5]=ke,cn[6]=Ae,cn[7]=Le,cn[8]=Pe,cn[9]=Te,ln[0]=me,ln[1]=fe,ln[2]=de,ln[3]=pe,ln[4]=ve,ln[5]=ye,ln[6]=be,un[0]=Me,un[1]=ue,un[2]=Ne,un[3]=Oe,un[4]=Fe,un[5]=De,un[6]=je,a=1}else a=0}a&&(a=function(t,r){for(t.M=0;t.M<t.Va;++t.M){var o,a=t.Jc[t.M&t.Xb],h=t.m,l=t;for(o=0;o<l.za;++o){var c=h,u=l,f=u.Ac,d=u.Bc+4*o,p=u.zc,g=u.ya[u.aa+o];if(u.Qa.Bb?g.$b=T(c,u.Pa.jb[0])?2+T(c,u.Pa.jb[2]):T(c,u.Pa.jb[1]):g.$b=0,u.kc&&(g.Ad=T(c,u.Bd)),g.Za=!T(c,145)+0,g.Za){var m=g.Ob,v=0;for(u=0;4>u;++u){var y,b=p[0+u];for(y=0;4>y;++y){b=on[f[d+y]][b];for(var w=nn[T(c,b[0])];0<w;)w=nn[2*w+T(c,b[w])];b=-w,f[d+y]=b}i(m,v,f,d,4),v+=4,p[0+u]=b}}else b=T(c,156)?T(c,128)?1:3:T(c,163)?2:0,g.Ob[0]=b,n(f,d,b,4),n(p,0,b,4);g.Dd=T(c,142)?T(c,114)?T(c,183)?1:3:2:0}if(l.m.Ka)return Gt(t,7,"Premature end-of-partition0 encountered.");for(;t.ja<t.za;++t.ja){if(l=a,c=(h=t).rb[h.sb-1],f=h.rb[h.sb+h.ja],o=h.ya[h.aa+h.ja],d=h.kc?o.Ad:0)c.la=f.la=0,o.Za||(c.Na=f.Na=0),o.Hc=0,o.Gc=0,o.ia=0;else{var _,x;if(c=f,f=l,d=h.Pa.Xc,p=h.ya[h.aa+h.ja],g=h.pb[p.$b],u=p.ad,m=0,v=h.rb[h.sb-1],b=y=0,n(u,m,0,384),p.Za)var S=0,C=d[3];else{w=s(16);var A=c.Na+v.Na;if(A=tn(f,d[1],A,g.Eb,0,w,0),c.Na=v.Na=(0<A)+0,1<A)ii(w,0,u,m);else{var k=w[0]+3>>3;for(w=0;256>w;w+=16)u[m+w]=k}S=1,C=d[0]}var L=15&c.la,P=15&v.la;for(w=0;4>w;++w){var N=1&P;for(k=x=0;4>k;++k)L=L>>1|(N=(A=tn(f,C,A=N+(1&L),g.Sc,S,u,m))>S)<<7,x=x<<2|(3<A?3:1<A?2:0!=u[m+0]),m+=16;L>>=4,P=P>>1|N<<7,y=(y<<8|x)>>>0}for(C=L,S=P>>4,_=0;4>_;_+=2){for(x=0,L=c.la>>4+_,P=v.la>>4+_,w=0;2>w;++w){for(N=1&P,k=0;2>k;++k)A=N+(1&L),L=L>>1|(N=0<(A=tn(f,d[2],A,g.Qc,0,u,m)))<<3,x=x<<2|(3<A?3:1<A?2:0!=u[m+0]),m+=16;L>>=2,P=P>>1|N<<5}b|=x<<4*_,C|=L<<4<<_,S|=(240&P)<<_}c.la=C,v.la=S,p.Hc=y,p.Gc=b,p.ia=43690&b?0:g.ia,d=!(y|b)}if(0<h.L&&(h.wa[h.Y+h.ja]=h.gd[o.$b][o.Za],h.wa[h.Y+h.ja].La|=!d),l.Ka)return Gt(t,7,"Premature end-of-file encountered.")}if(Zt(t),h=r,l=1,o=(a=t).D,c=0<a.L&&a.M>=a.zb&&a.M<=a.Va,0==a.Aa)e:{if(o.M=a.M,o.uc=c,Er(a,o),l=1,o=(x=a.D).Nb,c=(b=Bn[a.L])*a.R,f=b/2*a.B,w=16*o*a.R,k=8*o*a.B,d=a.sa,p=a.ta-c+w,g=a.qa,u=a.ra-f+k,m=a.Ha,v=a.Ia-f+k,P=0==(L=x.M),y=L>=a.Va-1,2==a.Aa&&Er(a,x),x.uc)for(N=(A=a).D.M,e(A.D.uc),x=A.yb;x<A.Hb;++x){S=x,C=N;var O=(E=(U=A).D).Nb;_=U.R;var E=E.wa[E.Y+S],M=U.sa,D=U.ta+16*O*_+16*S,F=E.dd,j=E.tc;if(0!=j)if(e(3<=j),1==U.L)0<S&&yi(M,D,_,j+4),E.La&&wi(M,D,_,j),0<C&&vi(M,D,_,j+4),E.La&&bi(M,D,_,j);else{var I=U.B,B=U.qa,R=U.ra+8*O*I+8*S,z=U.Ha,U=U.Ia+8*O*I+8*S;O=E.ld,0<S&&(ci(M,D,_,j+4,F,O),fi(B,R,z,U,I,j+4,F,O)),E.La&&(pi(M,D,_,j,F,O),mi(B,R,z,U,I,j,F,O)),0<C&&(li(M,D,_,j+4,F,O),ui(B,R,z,U,I,j+4,F,O)),E.La&&(di(M,D,_,j,F,O),gi(B,R,z,U,I,j,F,O))}}if(a.ia&&alert("todo:DitherRow"),null!=h.put){if(x=16*L,L=16*(L+1),P?(h.y=a.sa,h.O=a.ta+w,h.f=a.qa,h.N=a.ra+k,h.ea=a.Ha,h.W=a.Ia+k):(x-=b,h.y=d,h.O=p,h.f=g,h.N=u,h.ea=m,h.W=v),y||(L-=b),L>h.o&&(L=h.o),h.F=null,h.J=null,null!=a.Fa&&0<a.Fa.length&&x<L&&(h.J=cr(a,h,x,L-x),h.F=a.mb,null==h.F&&0==h.F.length)){l=Gt(a,3,"Could not decode alpha data.");break e}x<h.j&&(b=h.j-x,x=h.j,e(!(1&b)),h.O+=a.R*b,h.N+=a.B*(b>>1),h.W+=a.B*(b>>1),null!=h.F&&(h.J+=h.width*b)),x<L&&(h.O+=h.v,h.N+=h.v>>1,h.W+=h.v>>1,null!=h.F&&(h.J+=h.v),h.ka=x-h.j,h.U=h.va-h.v,h.T=L-x,l=h.put(h))}o+1!=a.Ic||y||(i(a.sa,a.ta-c,d,p+16*a.R,c),i(a.qa,a.ra-f,g,u+8*a.B,f),i(a.Ha,a.Ia-f,m,v+8*a.B,f))}if(!l)return Gt(t,6,"Output aborted.")}return 1}(t,r)),null!=r.bc&&r.bc(r),a&=1}return a?(t.cb=0,a):0})(t,h)||(r=t.a)}}else r=t.a}0==r&&null!=u.Oa&&u.Oa.fd&&(r=Fr(u.ba))}u=r}c=0!=u?null:11>c?f.f.RGBA.eb:f.f.kb.y}else c=null;return c};var zn=[3,4,3,4,4,2,2,4,4,4,2,1,1]};function l(t,e){for(var r="",i=0;i<4;i++)r+=String.fromCharCode(t[e++]);return r}function c(t,e){return t[e+0]|t[e+1]<<8}function u(t,e){return(t[e+0]|t[e+1]<<8|t[e+2]<<16)>>>0}function f(t,e){return(t[e+0]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}new h;var d=[0],p=[0],g=[],m=new h,v=t,y=function(t,e){var r={},i=0,n=!1,s=0,o=0;if(r.frames=[],!function(t,e){for(var r=0;r<4;r++)if(t[e+r]!="RIFF".charCodeAt(r))return!0;return!1}(t,e)){for(f(t,e+=4),e+=8;e<t.length;){var a=l(t,e),h=f(t,e+=4);e+=4;var d=h+(1&h);switch(a){case"VP8 ":case"VP8L":void 0===r.frames[i]&&(r.frames[i]={}),(m=r.frames[i]).src_off=n?o:e-8,m.src_size=s+h+8,i++,n&&(n=!1,s=0,o=0);break;case"VP8X":(m=r.header={}).feature_flags=t[e];var p=e+4;m.canvas_width=1+u(t,p),p+=3,m.canvas_height=1+u(t,p),p+=3;break;case"ALPH":n=!0,s=d+8,o=e-8;break;case"ANIM":(m=r.header).bgcolor=f(t,e),p=e+4,m.loop_count=c(t,p),p+=2;break;case"ANMF":var g,m;(m=r.frames[i]={}).offset_x=2*u(t,e),e+=3,m.offset_y=2*u(t,e),e+=3,m.width=1+u(t,e),e+=3,m.height=1+u(t,e),e+=3,m.duration=u(t,e),e+=3,g=t[e++],m.dispose=1&g,m.blend=g>>1&1}"ANMF"!=a&&(e+=d)}return r}}(v,0);y.response=v,y.rgbaoutput=!0,y.dataurl=!1;var b=y.header?y.header:null,w=y.frames?y.frames:null;if(b){b.loop_counter=b.loop_count,d=[b.canvas_height],p=[b.canvas_width];for(var _=0;_<w.length&&0!=w[_].blend;_++);}var x=w[0],S=m.WebPDecodeRGBA(v,x.src_off,x.src_size,p,d);x.rgba=S,x.imgwidth=p[0],x.imgheight=d[0];for(var C=0;C<p[0]*d[0]*4;C++)g[C]=S[C];return this.width=p,this.height=d,this.data=g,this}function Gd(){var t,e=this.internal.__metadata__.metadata,r=unescape(encodeURIComponent(e));t=this.internal.__metadata__.rawXml?r:'<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:jspdf="'+this.internal.__metadata__.namespaceUri+'"><jspdf:metadata>'+r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")+"</jspdf:metadata></rdf:Description></rdf:RDF></x:xmpmeta>",this.internal.__metadata__.metadataObjectNumber=this.internal.newObject(),this.internal.write("<< /Type /Metadata /Subtype /XML /Length "+t.length+" >>"),this.internal.write("stream"),this.internal.write(t),this.internal.write("endstream"),this.internal.write("endobj")}function $d(){this.internal.__metadata__.metadataObjectNumber&&this.internal.write("/Metadata "+this.internal.__metadata__.metadataObjectNumber+" 0 R")}!function(t){var e,r,i,n,s,o,a,h,l,c=function(t){return t=t||{},this.isStrokeTransparent=t.isStrokeTransparent||!1,this.strokeOpacity=t.strokeOpacity||1,this.strokeStyle=t.strokeStyle||"#000000",this.fillStyle=t.fillStyle||"#000000",this.isFillTransparent=t.isFillTransparent||!1,this.fillOpacity=t.fillOpacity||1,this.font=t.font||"10px sans-serif",this.textBaseline=t.textBaseline||"alphabetic",this.textAlign=t.textAlign||"left",this.lineWidth=t.lineWidth||1,this.lineJoin=t.lineJoin||"miter",this.lineCap=t.lineCap||"butt",this.path=t.path||[],this.transform=void 0!==t.transform?t.transform.clone():new h,this.globalCompositeOperation=t.globalCompositeOperation||"normal",this.globalAlpha=t.globalAlpha||1,this.clip_path=t.clip_path||[],this.currentPoint=t.currentPoint||new o,this.miterLimit=t.miterLimit||10,this.lastPoint=t.lastPoint||new o,this.lineDashOffset=t.lineDashOffset||0,this.lineDash=t.lineDash||[],this.margin=t.margin||[0,0,0,0],this.prevPageLastElemOffset=t.prevPageLastElemOffset||0,this.ignoreClearRect="boolean"!=typeof t.ignoreClearRect||t.ignoreClearRect,this};t.events.push(["initialized",function(){this.context2d=new u(this),e=this.internal.f2,r=this.internal.getCoordinateString,i=this.internal.getVerticalCoordinateString,n=this.internal.getHorizontalCoordinate,s=this.internal.getVerticalCoordinate,o=this.internal.Point,a=this.internal.Rectangle,h=this.internal.Matrix,l=new c}]);var u=function(t){Object.defineProperty(this,"canvas",{get:function(){return{parentNode:!1,style:!1}}});var e=t;Object.defineProperty(this,"pdf",{get:function(){return e}});var r=!1;Object.defineProperty(this,"pageWrapXEnabled",{get:function(){return r},set:function(t){r=Boolean(t)}});var i=!1;Object.defineProperty(this,"pageWrapYEnabled",{get:function(){return i},set:function(t){i=Boolean(t)}});var n=0;Object.defineProperty(this,"posX",{get:function(){return n},set:function(t){isNaN(t)||(n=t)}});var s=0;Object.defineProperty(this,"posY",{get:function(){return s},set:function(t){isNaN(t)||(s=t)}}),Object.defineProperty(this,"margin",{get:function(){return l.margin},set:function(t){var e;"number"==typeof t?e=[t,t,t,t]:((e=new Array(4))[0]=t[0],e[1]=t.length>=2?t[1]:e[0],e[2]=t.length>=3?t[2]:e[0],e[3]=t.length>=4?t[3]:e[1]),l.margin=e}});var o=!1;Object.defineProperty(this,"autoPaging",{get:function(){return o},set:function(t){o=t}});var a=0;Object.defineProperty(this,"lastBreak",{get:function(){return a},set:function(t){a=t}});var h=[];Object.defineProperty(this,"pageBreaks",{get:function(){return h},set:function(t){h=t}}),Object.defineProperty(this,"ctx",{get:function(){return l},set:function(t){t instanceof c&&(l=t)}}),Object.defineProperty(this,"path",{get:function(){return l.path},set:function(t){l.path=t}});var u=[];Object.defineProperty(this,"ctxStack",{get:function(){return u},set:function(t){u=t}}),Object.defineProperty(this,"fillStyle",{get:function(){return this.ctx.fillStyle},set:function(t){var e;e=f(t),this.ctx.fillStyle=e.style,this.ctx.isFillTransparent=0===e.a,this.ctx.fillOpacity=e.a,this.pdf.setFillColor(e.r,e.g,e.b,{a:e.a}),this.pdf.setTextColor(e.r,e.g,e.b,{a:e.a})}}),Object.defineProperty(this,"strokeStyle",{get:function(){return this.ctx.strokeStyle},set:function(t){var e=f(t);this.ctx.strokeStyle=e.style,this.ctx.isStrokeTransparent=0===e.a,this.ctx.strokeOpacity=e.a,0===e.a?this.pdf.setDrawColor(255,255,255):(e.a,this.pdf.setDrawColor(e.r,e.g,e.b))}}),Object.defineProperty(this,"lineCap",{get:function(){return this.ctx.lineCap},set:function(t){-1!==["butt","round","square"].indexOf(t)&&(this.ctx.lineCap=t,this.pdf.setLineCap(t))}}),Object.defineProperty(this,"lineWidth",{get:function(){return this.ctx.lineWidth},set:function(t){isNaN(t)||(this.ctx.lineWidth=t,this.pdf.setLineWidth(t))}}),Object.defineProperty(this,"lineJoin",{get:function(){return this.ctx.lineJoin},set:function(t){-1!==["bevel","round","miter"].indexOf(t)&&(this.ctx.lineJoin=t,this.pdf.setLineJoin(t))}}),Object.defineProperty(this,"miterLimit",{get:function(){return this.ctx.miterLimit},set:function(t){isNaN(t)||(this.ctx.miterLimit=t,this.pdf.setMiterLimit(t))}}),Object.defineProperty(this,"textBaseline",{get:function(){return this.ctx.textBaseline},set:function(t){this.ctx.textBaseline=t}}),Object.defineProperty(this,"textAlign",{get:function(){return this.ctx.textAlign},set:function(t){-1!==["right","end","center","left","start"].indexOf(t)&&(this.ctx.textAlign=t)}});var d=null,p=null,g=null;Object.defineProperty(this,"fontFaces",{get:function(){return g},set:function(t){d=null,p=null,g=t}}),Object.defineProperty(this,"font",{get:function(){return this.ctx.font},set:function(t){var e;if(this.ctx.font=t,null!==(e=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z0-9]+?)\s*$/i.exec(t))){var r=e[1];e[2];var i=e[3],n=e[4];e[5];var s=e[6],o=/^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i.exec(n)[2];n="px"===o?Math.floor(parseFloat(n)*this.pdf.internal.scaleFactor):"em"===o?Math.floor(parseFloat(n)*this.pdf.getFontSize()):Math.floor(parseFloat(n)*this.pdf.internal.scaleFactor),this.pdf.setFontSize(n);var a=function(t){var e,r,i=[],n=t.trim();if(""===n)return Od;if(n in _d)return[_d[n]];for(;""!==n;){switch(r=null,e=(n=Sd(n)).charAt(0)){case'"':case"'":r=Cd(n.substring(1),e);break;default:r=Ad(n)}if(null===r)return Od;if(i.push(r[0]),""!==(n=Sd(r[1]))&&","!==n.charAt(0))return Od;n=n.replace(/^,/,"")}return i}(s);if(this.fontFaces){var h=function(t,e){var r=t.getFontList(),i=JSON.stringify(r);if(null===d||p!==i){var n=function(t){var e=[];return Object.keys(t).forEach(function(r){t[r].forEach(function(t){var i=null;switch(t){case"bold":i={family:r,weight:"bold"};break;case"italic":i={family:r,style:"italic"};break;case"bolditalic":i={family:r,weight:"bold",style:"italic"};break;case"":case"normal":i={family:r}}null!==i&&(i.ref={name:r,style:t},e.push(i))})}),e}(r);d=function(t){for(var e={},r=0;r<t.length;++r){var i=yd(t[r]),n=i.family,s=i.stretch,o=i.style,a=i.weight;e[n]=e[n]||{},e[n][s]=e[n][s]||{},e[n][s][o]=e[n][s][o]||{},e[n][s][o][a]=i}return e}(n.concat(e)),p=i}return d}(this.pdf,this.fontFaces),l=a.map(function(t){return{family:t,stretch:"normal",weight:i,style:r}}),c=function(t,e,r){for(var i=(r=r||{}).defaultFontFamily||"times",n=Object.assign({},wd,r.genericFontFamilies||{}),s=null,o=null,a=0;a<e.length;++a)if(n[(s=yd(e[a])).family]&&(s.family=n[s.family]),t.hasOwnProperty(s.family)){o=t[s.family];break}if(!(o=o||t[i]))throw new Error("Could not find a font-family for the rule '"+xd(s)+"' and default family '"+i+"'.");if(o=function(t,e){if(e[t])return e[t];var r=gd[t],i=r<=gd.normal?-1:1,n=bd(e,pd,r,i);if(!n)throw new Error("Could not find a matching font-stretch value for "+t);return n}(s.stretch,o),o=function(t,e){if(e[t])return e[t];for(var r=dd[t],i=0;i<r.length;++i)if(e[r[i]])return e[r[i]];throw new Error("Could not find a matching font-style for "+t)}(s.style,o),!(o=function(t,e){if(e[t])return e[t];if(400===t&&e[500])return e[500];if(500===t&&e[400])return e[400];var r=vd[t],i=bd(e,md,r,t<400?-1:1);if(!i)throw new Error("Could not find a matching font-weight for value "+t);return i}(s.weight,o)))throw new Error("Failed to resolve a font for the rule '"+xd(s)+"'.");return o}(h,l);this.pdf.setFont(c.ref.name,c.ref.style)}else{var u="";("bold"===i||parseInt(i,10)>=700||"bold"===r)&&(u="bold"),"italic"===r&&(u+="italic"),0===u.length&&(u="normal");for(var f="",g={arial:"Helvetica",Arial:"Helvetica",verdana:"Helvetica",Verdana:"Helvetica",helvetica:"Helvetica",Helvetica:"Helvetica","sans-serif":"Helvetica",fixed:"Courier",monospace:"Courier",terminal:"Courier",cursive:"Times",fantasy:"Times",serif:"Times"},m=0;m<a.length;m++){if(void 0!==this.pdf.internal.getFont(a[m],u,{noFallback:!0,disableWarning:!0})){f=a[m];break}if("bolditalic"===u&&void 0!==this.pdf.internal.getFont(a[m],"bold",{noFallback:!0,disableWarning:!0}))f=a[m],u="bold";else if(void 0!==this.pdf.internal.getFont(a[m],"normal",{noFallback:!0,disableWarning:!0})){f=a[m],u="normal";break}}if(""===f)for(var v=0;v<a.length;v++)if(g[a[v]]){f=g[a[v]];break}f=""===f?"Times":f,this.pdf.setFont(f,u)}}}}),Object.defineProperty(this,"globalCompositeOperation",{get:function(){return this.ctx.globalCompositeOperation},set:function(t){this.ctx.globalCompositeOperation=t}}),Object.defineProperty(this,"globalAlpha",{get:function(){return this.ctx.globalAlpha},set:function(t){this.ctx.globalAlpha=t}}),Object.defineProperty(this,"lineDashOffset",{get:function(){return this.ctx.lineDashOffset},set:function(t){this.ctx.lineDashOffset=t,I.call(this)}}),Object.defineProperty(this,"lineDash",{get:function(){return this.ctx.lineDash},set:function(t){this.ctx.lineDash=t,I.call(this)}}),Object.defineProperty(this,"ignoreClearRect",{get:function(){return this.ctx.ignoreClearRect},set:function(t){this.ctx.ignoreClearRect=Boolean(t)}})};u.prototype.setLineDash=function(t){this.lineDash=t},u.prototype.getLineDash=function(){return this.lineDash.length%2?this.lineDash.concat(this.lineDash):this.lineDash.slice()},u.prototype.fill=function(){w.call(this,"fill",!1)},u.prototype.stroke=function(){w.call(this,"stroke",!1)},u.prototype.beginPath=function(){this.path=[{type:"begin"}]},u.prototype.moveTo=function(t,e){if(isNaN(t)||isNaN(e))throw Yu.error("jsPDF.context2d.moveTo: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.moveTo");var r=this.ctx.transform.applyToPoint(new o(t,e));this.path.push({type:"mt",x:r.x,y:r.y}),this.ctx.lastPoint=new o(t,e)},u.prototype.closePath=function(){var t=new o(0,0),e=0;for(e=this.path.length-1;-1!==e;e--)if("begin"===this.path[e].type&&"object"===(0,aa.A)(this.path[e+1])&&"number"==typeof this.path[e+1].x){t=new o(this.path[e+1].x,this.path[e+1].y);break}this.path.push({type:"close"}),this.ctx.lastPoint=new o(t.x,t.y)},u.prototype.lineTo=function(t,e){if(isNaN(t)||isNaN(e))throw Yu.error("jsPDF.context2d.lineTo: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.lineTo");var r=this.ctx.transform.applyToPoint(new o(t,e));this.path.push({type:"lt",x:r.x,y:r.y}),this.ctx.lastPoint=new o(r.x,r.y)},u.prototype.clip=function(){this.ctx.clip_path=JSON.parse(JSON.stringify(this.path)),w.call(this,null,!0)},u.prototype.quadraticCurveTo=function(t,e,r,i){if(isNaN(r)||isNaN(i)||isNaN(t)||isNaN(e))throw Yu.error("jsPDF.context2d.quadraticCurveTo: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.quadraticCurveTo");var n=this.ctx.transform.applyToPoint(new o(r,i)),s=this.ctx.transform.applyToPoint(new o(t,e));this.path.push({type:"qct",x1:s.x,y1:s.y,x:n.x,y:n.y}),this.ctx.lastPoint=new o(n.x,n.y)},u.prototype.bezierCurveTo=function(t,e,r,i,n,s){if(isNaN(n)||isNaN(s)||isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw Yu.error("jsPDF.context2d.bezierCurveTo: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo");var a=this.ctx.transform.applyToPoint(new o(n,s)),h=this.ctx.transform.applyToPoint(new o(t,e)),l=this.ctx.transform.applyToPoint(new o(r,i));this.path.push({type:"bct",x1:h.x,y1:h.y,x2:l.x,y2:l.y,x:a.x,y:a.y}),this.ctx.lastPoint=new o(a.x,a.y)},u.prototype.arc=function(t,e,r,i,n,s){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||isNaN(n))throw Yu.error("jsPDF.context2d.arc: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.arc");if(s=Boolean(s),!this.ctx.transform.isIdentity){var a=this.ctx.transform.applyToPoint(new o(t,e));t=a.x,e=a.y;var h=this.ctx.transform.applyToPoint(new o(0,r)),l=this.ctx.transform.applyToPoint(new o(0,0));r=Math.sqrt(Math.pow(h.x-l.x,2)+Math.pow(h.y-l.y,2))}Math.abs(n-i)>=2*Math.PI&&(i=0,n=2*Math.PI),this.path.push({type:"arc",x:t,y:e,radius:r,startAngle:i,endAngle:n,counterclockwise:s})},u.prototype.arcTo=function(t,e,r,i,n){throw new Error("arcTo not implemented.")},u.prototype.rect=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw Yu.error("jsPDF.context2d.rect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.rect");this.moveTo(t,e),this.lineTo(t+r,e),this.lineTo(t+r,e+i),this.lineTo(t,e+i),this.lineTo(t,e),this.lineTo(t+r,e),this.lineTo(t,e)},u.prototype.fillRect=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw Yu.error("jsPDF.context2d.fillRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.fillRect");if(!d.call(this)){var n={};"butt"!==this.lineCap&&(n.lineCap=this.lineCap,this.lineCap="butt"),"miter"!==this.lineJoin&&(n.lineJoin=this.lineJoin,this.lineJoin="miter"),this.beginPath(),this.rect(t,e,r,i),this.fill(),n.hasOwnProperty("lineCap")&&(this.lineCap=n.lineCap),n.hasOwnProperty("lineJoin")&&(this.lineJoin=n.lineJoin)}},u.prototype.strokeRect=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw Yu.error("jsPDF.context2d.strokeRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.strokeRect");p.call(this)||(this.beginPath(),this.rect(t,e,r,i),this.stroke())},u.prototype.clearRect=function(t,e,r,i){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i))throw Yu.error("jsPDF.context2d.clearRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.clearRect");this.ignoreClearRect||(this.fillStyle="#ffffff",this.fillRect(t,e,r,i))},u.prototype.save=function(t){t="boolean"!=typeof t||t;for(var e=this.pdf.internal.getCurrentPageInfo().pageNumber,r=0;r<this.pdf.internal.getNumberOfPages();r++)this.pdf.setPage(r+1),this.pdf.internal.out("q");if(this.pdf.setPage(e),t){this.ctx.fontSize=this.pdf.internal.getFontSize();var i=new c(this.ctx);this.ctxStack.push(this.ctx),this.ctx=i}},u.prototype.restore=function(t){t="boolean"!=typeof t||t;for(var e=this.pdf.internal.getCurrentPageInfo().pageNumber,r=0;r<this.pdf.internal.getNumberOfPages();r++)this.pdf.setPage(r+1),this.pdf.internal.out("Q");this.pdf.setPage(e),t&&0!==this.ctxStack.length&&(this.ctx=this.ctxStack.pop(),this.fillStyle=this.ctx.fillStyle,this.strokeStyle=this.ctx.strokeStyle,this.font=this.ctx.font,this.lineCap=this.ctx.lineCap,this.lineWidth=this.ctx.lineWidth,this.lineJoin=this.ctx.lineJoin,this.lineDash=this.ctx.lineDash,this.lineDashOffset=this.ctx.lineDashOffset)},u.prototype.toDataURL=function(){throw new Error("toDataUrl not implemented.")};var f=function(t){var e,r,i,n;if(!0===t.isCanvasGradient&&(t=t.getColor()),!t)return{r:0,g:0,b:0,a:0,style:t};if(/transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/.test(t))e=0,r=0,i=0,n=0;else{var s=/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(t);if(null!==s)e=parseInt(s[1]),r=parseInt(s[2]),i=parseInt(s[3]),n=1;else if(null!==(s=/rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/.exec(t)))e=parseInt(s[1]),r=parseInt(s[2]),i=parseInt(s[3]),n=parseFloat(s[4]);else{if(n=1,"string"==typeof t&&"#"!==t.charAt(0)){var o=new Ju(t);t=o.ok?o.toHex():"#000000"}4===t.length?(e=t.substring(1,2),e+=e,r=t.substring(2,3),r+=r,i=t.substring(3,4),i+=i):(e=t.substring(1,3),r=t.substring(3,5),i=t.substring(5,7)),e=parseInt(e,16),r=parseInt(r,16),i=parseInt(i,16)}}return{r:e,g:r,b:i,a:n,style:t}},d=function(){return this.ctx.isFillTransparent||0==this.globalAlpha},p=function(){return Boolean(this.ctx.isStrokeTransparent||0==this.globalAlpha)};u.prototype.fillText=function(t,e,r,i){if(isNaN(e)||isNaN(r)||"string"!=typeof t)throw Yu.error("jsPDF.context2d.fillText: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.fillText");if(i=isNaN(i)?void 0:i,!d.call(this)){var n=D(this.ctx.transform.rotation),s=this.ctx.transform.scaleX;T.call(this,{text:t,x:e,y:r,scale:s,angle:n,align:this.textAlign,maxWidth:i})}},u.prototype.strokeText=function(t,e,r,i){if(isNaN(e)||isNaN(r)||"string"!=typeof t)throw Yu.error("jsPDF.context2d.strokeText: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.strokeText");if(!p.call(this)){i=isNaN(i)?void 0:i;var n=D(this.ctx.transform.rotation),s=this.ctx.transform.scaleX;T.call(this,{text:t,x:e,y:r,scale:s,renderingMode:"stroke",angle:n,align:this.textAlign,maxWidth:i})}},u.prototype.measureText=function(t){if("string"!=typeof t)throw Yu.error("jsPDF.context2d.measureText: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.measureText");var e=this.pdf,r=this.pdf.internal.scaleFactor,i=e.internal.getFontSize(),n=e.getStringUnitWidth(t)*i/e.internal.scaleFactor;return new function(t){var e=(t=t||{}).width||0;return Object.defineProperty(this,"width",{get:function(){return e}}),this}({width:n*=Math.round(96*r/72*1e4)/1e4})},u.prototype.scale=function(t,e){if(isNaN(t)||isNaN(e))throw Yu.error("jsPDF.context2d.scale: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.scale");var r=new h(t,0,0,e,0,0);this.ctx.transform=this.ctx.transform.multiply(r)},u.prototype.rotate=function(t){if(isNaN(t))throw Yu.error("jsPDF.context2d.rotate: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.rotate");var e=new h(Math.cos(t),Math.sin(t),-Math.sin(t),Math.cos(t),0,0);this.ctx.transform=this.ctx.transform.multiply(e)},u.prototype.translate=function(t,e){if(isNaN(t)||isNaN(e))throw Yu.error("jsPDF.context2d.translate: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.translate");var r=new h(1,0,0,1,t,e);this.ctx.transform=this.ctx.transform.multiply(r)},u.prototype.transform=function(t,e,r,i,n,s){if(isNaN(t)||isNaN(e)||isNaN(r)||isNaN(i)||isNaN(n)||isNaN(s))throw Yu.error("jsPDF.context2d.transform: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.transform");var o=new h(t,e,r,i,n,s);this.ctx.transform=this.ctx.transform.multiply(o)},u.prototype.setTransform=function(t,e,r,i,n,s){t=isNaN(t)?1:t,e=isNaN(e)?0:e,r=isNaN(r)?0:r,i=isNaN(i)?1:i,n=isNaN(n)?0:n,s=isNaN(s)?0:s,this.ctx.transform=new h(t,e,r,i,n,s)};var g=function(){return this.margin[0]>0||this.margin[1]>0||this.margin[2]>0||this.margin[3]>0};u.prototype.drawImage=function(t,e,r,i,n,s,o,l,c){var u=this.pdf.getImageProperties(t),f=1,d=1,p=1,v=1;void 0!==i&&void 0!==l&&(p=l/i,v=c/n,f=u.width/i*l/i,d=u.height/n*c/n),void 0===s&&(s=e,o=r,e=0,r=0),void 0!==i&&void 0===l&&(l=i,c=n),void 0===i&&void 0===l&&(l=u.width,c=u.height);var w=this.ctx.transform.decompose(),x=D(w.rotate.shx),S=new h,C=(S=(S=(S=S.multiply(w.translate)).multiply(w.skew)).multiply(w.scale)).applyToRectangle(new a(s-e*p,o-r*v,i*f,n*d));if(this.autoPaging){for(var A,k=m.call(this,C),L=[],T=0;T<k.length;T+=1)-1===L.indexOf(k[T])&&L.push(k[T]);b(L);for(var P=L[0],N=L[L.length-1],O=P;O<N+1;O++){this.pdf.setPage(O);var E=this.pdf.internal.pageSize.width-this.margin[3]-this.margin[1],M=1===O?this.posY+this.margin[0]:this.margin[0],F=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],j=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2],I=1===O?0:F+(O-2)*j;if(0!==this.ctx.clip_path.length){var B=this.path;A=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=y(A,this.posX+this.margin[3],-I+M+this.ctx.prevPageLastElemOffset),_.call(this,"fill",!0),this.path=B}var R=JSON.parse(JSON.stringify(C));R=y([R],this.posX+this.margin[3],-I+M+this.ctx.prevPageLastElemOffset)[0];var z=(O>P||O<N)&&g.call(this);z&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],E,j,null).clip().discardPath()),this.pdf.addImage(t,"JPEG",R.x,R.y,R.w,R.h,null,null,x),z&&this.pdf.restoreGraphicsState()}}else this.pdf.addImage(t,"JPEG",C.x,C.y,C.w,C.h,null,null,x)};var m=function(t,e,r){var i=[];e=e||this.pdf.internal.pageSize.width,r=r||this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2];var n=this.posY+this.ctx.prevPageLastElemOffset;switch(t.type){default:case"mt":case"lt":i.push(Math.floor((t.y+n)/r)+1);break;case"arc":i.push(Math.floor((t.y+n-t.radius)/r)+1),i.push(Math.floor((t.y+n+t.radius)/r)+1);break;case"qct":var s=F(this.ctx.lastPoint.x,this.ctx.lastPoint.y,t.x1,t.y1,t.x,t.y);i.push(Math.floor((s.y+n)/r)+1),i.push(Math.floor((s.y+s.h+n)/r)+1);break;case"bct":var o=j(this.ctx.lastPoint.x,this.ctx.lastPoint.y,t.x1,t.y1,t.x2,t.y2,t.x,t.y);i.push(Math.floor((o.y+n)/r)+1),i.push(Math.floor((o.y+o.h+n)/r)+1);break;case"rect":i.push(Math.floor((t.y+n)/r)+1),i.push(Math.floor((t.y+t.h+n)/r)+1)}for(var a=0;a<i.length;a+=1)for(;this.pdf.internal.getNumberOfPages()<i[a];)v.call(this);return i},v=function(){var t=this.fillStyle,e=this.strokeStyle,r=this.font,i=this.lineCap,n=this.lineWidth,s=this.lineJoin;this.pdf.addPage(),this.fillStyle=t,this.strokeStyle=e,this.font=r,this.lineCap=i,this.lineWidth=n,this.lineJoin=s},y=function(t,e,r){for(var i=0;i<t.length;i++)switch(t[i].type){case"bct":t[i].x2+=e,t[i].y2+=r;case"qct":t[i].x1+=e,t[i].y1+=r;default:t[i].x+=e,t[i].y+=r}return t},b=function(t){return t.sort(function(t,e){return t-e})},w=function(t,e){var r=this.fillStyle,i=this.strokeStyle,n=this.lineCap,s=this.lineWidth,o=Math.abs(s*this.ctx.transform.scaleX),a=this.lineJoin;if(this.autoPaging){for(var h,l,c=JSON.parse(JSON.stringify(this.path)),u=JSON.parse(JSON.stringify(this.path)),f=[],d=0;d<u.length;d++)if(void 0!==u[d].x)for(var p=m.call(this,u[d]),w=0;w<p.length;w+=1)-1===f.indexOf(p[w])&&f.push(p[w]);for(var x=0;x<f.length;x++)for(;this.pdf.internal.getNumberOfPages()<f[x];)v.call(this);b(f);for(var S=f[0],C=f[f.length-1],A=S;A<C+1;A++){this.pdf.setPage(A),this.fillStyle=r,this.strokeStyle=i,this.lineCap=n,this.lineWidth=o,this.lineJoin=a;var k=this.pdf.internal.pageSize.width-this.margin[3]-this.margin[1],L=1===A?this.posY+this.margin[0]:this.margin[0],T=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],P=this.pdf.internal.pageSize.height-this.margin[0]-this.margin[2],N=1===A?0:T+(A-2)*P;if(0!==this.ctx.clip_path.length){var O=this.path;h=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=y(h,this.posX+this.margin[3],-N+L+this.ctx.prevPageLastElemOffset),_.call(this,t,!0),this.path=O}if(l=JSON.parse(JSON.stringify(c)),this.path=y(l,this.posX+this.margin[3],-N+L+this.ctx.prevPageLastElemOffset),!1===e||0===A){var E=(A>S||A<C)&&g.call(this);E&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],k,P,null).clip().discardPath()),_.call(this,t,e),E&&this.pdf.restoreGraphicsState()}this.lineWidth=s}this.path=c}else this.lineWidth=o,_.call(this,t,e),this.lineWidth=s},_=function(t,e){if(("stroke"!==t||e||!p.call(this))&&("stroke"===t||e||!d.call(this))){for(var r,i,n=[],s=this.path,o=0;o<s.length;o++){var a=s[o];switch(a.type){case"begin":n.push({begin:!0});break;case"close":n.push({close:!0});break;case"mt":n.push({start:a,deltas:[],abs:[]});break;case"lt":var h=n.length;if(s[o-1]&&!isNaN(s[o-1].x)&&(r=[a.x-s[o-1].x,a.y-s[o-1].y],h>0))for(;h>=0;h--)if(!0!==n[h-1].close&&!0!==n[h-1].begin){n[h-1].deltas.push(r),n[h-1].abs.push(a);break}break;case"bct":r=[a.x1-s[o-1].x,a.y1-s[o-1].y,a.x2-s[o-1].x,a.y2-s[o-1].y,a.x-s[o-1].x,a.y-s[o-1].y],n[n.length-1].deltas.push(r);break;case"qct":var l=s[o-1].x+2/3*(a.x1-s[o-1].x),c=s[o-1].y+2/3*(a.y1-s[o-1].y),u=a.x+2/3*(a.x1-a.x),f=a.y+2/3*(a.y1-a.y),g=a.x,m=a.y;r=[l-s[o-1].x,c-s[o-1].y,u-s[o-1].x,f-s[o-1].y,g-s[o-1].x,m-s[o-1].y],n[n.length-1].deltas.push(r);break;case"arc":n.push({deltas:[],abs:[],arc:!0}),Array.isArray(n[n.length-1].abs)&&n[n.length-1].abs.push(a)}}i=e?null:"stroke"===t?"stroke":"fill";for(var v=!1,y=0;y<n.length;y++)if(n[y].arc)for(var b=n[y].abs,w=0;w<b.length;w++){var _=b[w];"arc"===_.type?C.call(this,_.x,_.y,_.radius,_.startAngle,_.endAngle,_.counterclockwise,void 0,e,!v):P.call(this,_.x,_.y),v=!0}else if(!0===n[y].close)this.pdf.internal.out("h"),v=!1;else if(!0!==n[y].begin){var x=n[y].start.x,S=n[y].start.y;N.call(this,n[y].deltas,x,S),v=!0}i&&A.call(this,i),e&&k.call(this)}},x=function(t){var e=this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor,r=e*(this.pdf.internal.getLineHeightFactor()-1);switch(this.ctx.textBaseline){case"bottom":return t-r;case"top":return t+e-r;case"hanging":return t+e-2*r;case"middle":return t+e/2-r;default:return t}},S=function(t){return t+this.pdf.internal.getFontSize()/this.pdf.internal.scaleFactor*(this.pdf.internal.getLineHeightFactor()-1)};u.prototype.createLinearGradient=function(){var t=function(){};return t.colorStops=[],t.addColorStop=function(t,e){this.colorStops.push([t,e])},t.getColor=function(){return 0===this.colorStops.length?"#000000":this.colorStops[0][1]},t.isCanvasGradient=!0,t},u.prototype.createPattern=function(){return this.createLinearGradient()},u.prototype.createRadialGradient=function(){return this.createLinearGradient()};var C=function(t,e,r,i,n,s,o,a,h){for(var l=E.call(this,r,i,n,s),c=0;c<l.length;c++){var u=l[c];0===c&&(h?L.call(this,u.x1+t,u.y1+e):P.call(this,u.x1+t,u.y1+e)),O.call(this,t,e,u.x2,u.y2,u.x3,u.y3,u.x4,u.y4)}a?k.call(this):A.call(this,o)},A=function(t){switch(t){case"stroke":this.pdf.internal.out("S");break;case"fill":this.pdf.internal.out("f")}},k=function(){this.pdf.clip(),this.pdf.discardPath()},L=function(t,e){this.pdf.internal.out(r(t)+" "+i(e)+" m")},T=function(t){var e;switch(t.align){case"right":case"end":e="right";break;case"center":e="center";break;default:e="left"}var r,i,n,s=this.pdf.getTextDimensions(t.text),l=x.call(this,t.y),c=S.call(this,l)-s.h,u=this.ctx.transform.applyToPoint(new o(t.x,l));if(this.autoPaging){var f=this.ctx.transform.decompose(),d=new h;d=(d=(d=d.multiply(f.translate)).multiply(f.skew)).multiply(f.scale);for(var p=this.ctx.transform.applyToRectangle(new a(t.x,l,s.w,s.h)),v=d.applyToRectangle(new a(t.x,c,s.w,s.h)),w=m.call(this,v),C=[],A=0;A<w.length;A+=1)-1===C.indexOf(w[A])&&C.push(w[A]);b(C);for(var k=C[0],L=C[C.length-1],T=k;T<L+1;T++){this.pdf.setPage(T);var P=1===T?this.posY+this.margin[0]:this.margin[0],N=this.pdf.internal.pageSize.height-this.posY-this.margin[0]-this.margin[2],O=this.pdf.internal.pageSize.height-this.margin[2],E=O-this.margin[0],M=this.pdf.internal.pageSize.width-this.margin[1],D=M-this.margin[3],F=1===T?0:N+(T-2)*E;if(0!==this.ctx.clip_path.length){var j=this.path;r=JSON.parse(JSON.stringify(this.ctx.clip_path)),this.path=y(r,this.posX+this.margin[3],-1*F+P),_.call(this,"fill",!0),this.path=j}var I=y([JSON.parse(JSON.stringify(v))],this.posX+this.margin[3],-F+P+this.ctx.prevPageLastElemOffset)[0];t.scale>=.01&&(i=this.pdf.internal.getFontSize(),this.pdf.setFontSize(i*t.scale),n=this.lineWidth,this.lineWidth=n*t.scale);var B="text"!==this.autoPaging;if(B||I.y+I.h<=O){if(B||I.y>=P&&I.x<=M){var R=B?t.text:this.pdf.splitTextToSize(t.text,t.maxWidth||M-I.x)[0],z=y([JSON.parse(JSON.stringify(p))],this.posX+this.margin[3],-F+P+this.ctx.prevPageLastElemOffset)[0],U=B&&(T>k||T<L)&&g.call(this);U&&(this.pdf.saveGraphicsState(),this.pdf.rect(this.margin[3],this.margin[0],D,E,null).clip().discardPath()),this.pdf.text(R,z.x,z.y,{angle:t.angle,align:e,renderingMode:t.renderingMode}),U&&this.pdf.restoreGraphicsState()}}else I.y<O&&(this.ctx.prevPageLastElemOffset+=O-I.y);t.scale>=.01&&(this.pdf.setFontSize(i),this.lineWidth=n)}}else t.scale>=.01&&(i=this.pdf.internal.getFontSize(),this.pdf.setFontSize(i*t.scale),n=this.lineWidth,this.lineWidth=n*t.scale),this.pdf.text(t.text,u.x+this.posX,u.y+this.posY,{angle:t.angle,align:e,renderingMode:t.renderingMode,maxWidth:t.maxWidth}),t.scale>=.01&&(this.pdf.setFontSize(i),this.lineWidth=n)},P=function(t,e,n,s){n=n||0,s=s||0,this.pdf.internal.out(r(t+n)+" "+i(e+s)+" l")},N=function(t,e,r){return this.pdf.lines(t,e,r,null,null)},O=function(t,r,i,o,a,h,l,c){this.pdf.internal.out([e(n(i+t)),e(s(o+r)),e(n(a+t)),e(s(h+r)),e(n(l+t)),e(s(c+r)),"c"].join(" "))},E=function(t,e,r,i){for(var n=2*Math.PI,s=Math.PI/2;e>r;)e-=n;var o=Math.abs(r-e);o<n&&i&&(o=n-o);for(var a=[],h=i?-1:1,l=e;o>1e-5;){var c=l+h*Math.min(o,s);a.push(M.call(this,t,l,c)),o-=Math.abs(c-l),l=c}return a},M=function(t,e,r){var i=(r-e)/2,n=t*Math.cos(i),s=t*Math.sin(i),o=n,a=-s,h=o*o+a*a,l=h+o*n+a*s,c=4/3*(Math.sqrt(2*h*l)-l)/(o*s-a*n),u=o-c*a,f=a+c*o,d=u,p=-f,g=i+e,m=Math.cos(g),v=Math.sin(g);return{x1:t*Math.cos(e),y1:t*Math.sin(e),x2:u*m-f*v,y2:u*v+f*m,x3:d*m-p*v,y3:d*v+p*m,x4:t*Math.cos(r),y4:t*Math.sin(r)}},D=function(t){return 180*t/Math.PI},F=function(t,e,r,i,n,s){var o=t+.5*(r-t),h=e+.5*(i-e),l=n+.5*(r-n),c=s+.5*(i-s),u=Math.min(t,n,o,l),f=Math.max(t,n,o,l),d=Math.min(e,s,h,c),p=Math.max(e,s,h,c);return new a(u,d,f-u,p-d)},j=function(t,e,r,i,n,s,o,h){var l,c,u,f,d,p,g,m,v,y,b,w,_,x,S=r-t,C=i-e,A=n-r,k=s-i,L=o-n,T=h-s;for(c=0;c<41;c++)v=(g=(u=t+(l=c/40)*S)+l*((d=r+l*A)-u))+l*(d+l*(n+l*L-d)-g),y=(m=(f=e+l*C)+l*((p=i+l*k)-f))+l*(p+l*(s+l*T-p)-m),0==c?(b=v,w=y,_=v,x=y):(b=Math.min(b,v),w=Math.min(w,y),_=Math.max(_,v),x=Math.max(x,y));return new a(Math.round(b),Math.round(w),Math.round(_-b),Math.round(x-w))},I=function(){if(this.prevLineDash||this.ctx.lineDash.length||this.ctx.lineDashOffset){var t,e,r=(t=this.ctx.lineDash,e=this.ctx.lineDashOffset,JSON.stringify({lineDash:t,lineDashOffset:e}));this.prevLineDash!==r&&(this.pdf.setLineDash(this.ctx.lineDash,this.ctx.lineDashOffset),this.prevLineDash=r)}}}(Cf.API),function(t){var e=function(t){var e,r,i,n,s,o,a,h,l,c;for(/[^\x00-\xFF]/.test(t),r=[],i=0,n=(t+=e="\0\0\0\0".slice(t.length%4||4)).length;n>i;i+=4)0!==(s=(t.charCodeAt(i)<<24)+(t.charCodeAt(i+1)<<16)+(t.charCodeAt(i+2)<<8)+t.charCodeAt(i+3))?(o=(s=((s=((s=((s=(s-(c=s%85))/85)-(l=s%85))/85)-(h=s%85))/85)-(a=s%85))/85)%85,r.push(o+33,a+33,h+33,l+33,c+33)):r.push(122);return function(t,e){for(var r=e;r>0;r--)t.pop()}(r,e.length),String.fromCharCode.apply(String,r)+"~>"},r=function(t){var e,r,i,n,s,o=String,a="length",h=255,l="charCodeAt",c="slice",u="replace";for(t[c](-2),t=t[c](0,-2)[u](/\s/g,"")[u]("z","!!!!!"),i=[],n=0,s=(t+=e="uuuuu"[c](t[a]%5||5))[a];s>n;n+=5)r=52200625*(t[l](n)-33)+614125*(t[l](n+1)-33)+7225*(t[l](n+2)-33)+85*(t[l](n+3)-33)+(t[l](n+4)-33),i.push(h&r>>24,h&r>>16,h&r>>8,h&r);return function(t,e){for(var r=e;r>0;r--)t.pop()}(i,e[a]),o.fromCharCode.apply(o,i)},i=function(t){return t.split("").map(function(t){return("0"+t.charCodeAt().toString(16)).slice(-2)}).join("")+">"},n=function(t){var e=new RegExp(/^([0-9A-Fa-f]{2})+$/);if(-1!==(t=t.replace(/\s/g,"")).indexOf(">")&&(t=t.substr(0,t.indexOf(">"))),t.length%2&&(t+="0"),!1===e.test(t))return"";for(var r="",i=0;i<t.length;i+=2)r+=String.fromCharCode("0x"+(t[i]+t[i+1]));return r},s=function(t){for(var e=new Uint8Array(t.length),r=t.length;r--;)e[r]=t.charCodeAt(r);return(e=qa(e)).reduce(function(t,e){return t+String.fromCharCode(e)},"")};t.processDataByFilters=function(t,o){var a=0,h=t||"",l=[];for("string"==typeof(o=o||[])&&(o=[o]),a=0;a<o.length;a+=1)switch(o[a]){case"ASCII85Decode":case"/ASCII85Decode":h=r(h),l.push("/ASCII85Encode");break;case"ASCII85Encode":case"/ASCII85Encode":h=e(h),l.push("/ASCII85Decode");break;case"ASCIIHexDecode":case"/ASCIIHexDecode":h=n(h),l.push("/ASCIIHexEncode");break;case"ASCIIHexEncode":case"/ASCIIHexEncode":h=i(h),l.push("/ASCIIHexDecode");break;case"FlateEncode":case"/FlateEncode":h=s(h),l.push("/FlateDecode");break;default:throw new Error('The filter: "'+o[a]+'" is not implemented')}return{data:h,reverseChain:l.reverse().join(" ")}}}(Cf.API),function(t){t.loadFile=function(t,e,r){return function(t,e,r){e=!1!==e,r="function"==typeof r?r:function(){};var i=void 0;try{i=function(t,e,r){var i=new XMLHttpRequest,n=0,s=function(t){var e=t.length,r=[],i=String.fromCharCode;for(n=0;n<e;n+=1)r.push(i(255&t.charCodeAt(n)));return r.join("")};if(i.open("GET",t,!e),i.overrideMimeType("text/plain; charset=x-user-defined"),!1===e&&(i.onload=function(){200===i.status?r(s(this.responseText)):r(void 0)}),i.send(null),e&&200===i.status)return s(i.responseText)}(t,e,r)}catch(t){}return i}(t,e,r)},t.allowFsRead=void 0,t.loadImageFile=t.loadFile}(Cf.API),function(t){function e(){return(Hu.html2canvas?Promise.resolve(Hu.html2canvas):o.e(354).then(o.t.bind(o,354,23))).catch(function(t){return Promise.reject(new Error("Could not load html2canvas: "+t))}).then(function(t){return t.default?t.default:t})}function r(){return(Hu.DOMPurify?Promise.resolve(Hu.DOMPurify):o.e(418).then(o.bind(o,9418))).catch(function(t){return Promise.reject(new Error("Could not load dompurify: "+t))}).then(function(t){return t.default?t.default:t})}var i=function(t){var e=(0,aa.A)(t);return"undefined"===e?"undefined":"string"===e||t instanceof String?"string":"number"===e||t instanceof Number?"number":"function"===e||t instanceof Function?"function":t&&t.constructor===Array?"array":t&&1===t.nodeType?"element":"object"===e?"object":"unknown"},n=function(t,e){var r=document.createElement(t);for(var i in e.className&&(r.className=e.className),e.innerHTML&&e.dompurify&&(r.innerHTML=e.dompurify.sanitize(e.innerHTML)),e.style)r.style[i]=e.style[i];return r},s=function t(e,r){for(var i=3===e.nodeType?document.createTextNode(e.nodeValue):e.cloneNode(!1),n=e.firstChild;n;n=n.nextSibling)!0!==r&&1===n.nodeType&&"SCRIPT"===n.nodeName||i.appendChild(t(n,r));return 1===e.nodeType&&("CANVAS"===e.nodeName?(i.width=e.width,i.height=e.height,i.getContext("2d").drawImage(e,0,0)):"TEXTAREA"!==e.nodeName&&"SELECT"!==e.nodeName||(i.value=e.value),i.addEventListener("load",function(){i.scrollTop=e.scrollTop,i.scrollLeft=e.scrollLeft},!0)),i},a=function t(e){var r=Object.assign(t.convert(Promise.resolve()),JSON.parse(JSON.stringify(t.template))),i=t.convert(Promise.resolve(),r);return(i=i.setProgress(1,t,1,[t])).set(e)};(a.prototype=Object.create(Promise.prototype)).constructor=a,a.convert=function(t,e){return t.__proto__=e||a.prototype,t},a.template={prop:{src:null,container:null,overlay:null,canvas:null,img:null,pdf:null,pageSize:null,callback:function(){}},progress:{val:0,state:null,n:0,stack:[]},opt:{filename:"file.pdf",margin:[0,0,0,0],enableLinks:!0,x:0,y:0,html2canvas:{},jsPDF:{},backgroundColor:"transparent"}},a.prototype.from=function(t,e){return this.then(function(){switch(e=e||function(t){switch(i(t)){case"string":return"string";case"element":return"canvas"===t.nodeName.toLowerCase()?"canvas":"element";default:return"unknown"}}(t),e){case"string":return this.then(r).then(function(e){return this.set({src:n("div",{innerHTML:t,dompurify:e})})});case"element":return this.set({src:t});case"canvas":return this.set({canvas:t});case"img":return this.set({img:t});default:return this.error("Unknown source type.")}})},a.prototype.to=function(t){switch(t){case"container":return this.toContainer();case"canvas":return this.toCanvas();case"img":return this.toImg();case"pdf":return this.toPdf();default:return this.error("Invalid target.")}},a.prototype.toContainer=function(){return this.thenList([function(){return this.prop.src||this.error("Cannot duplicate - no source HTML.")},function(){return this.prop.pageSize||this.setPageSize()}]).then(function(){var t={position:"relative",display:"inline-block",width:("number"!=typeof this.opt.width||isNaN(this.opt.width)||"number"!=typeof this.opt.windowWidth||isNaN(this.opt.windowWidth)?Math.max(this.prop.src.clientWidth,this.prop.src.scrollWidth,this.prop.src.offsetWidth):this.opt.windowWidth)+"px",left:0,right:0,top:0,margin:"auto",backgroundColor:this.opt.backgroundColor},e=s(this.prop.src,this.opt.html2canvas.javascriptEnabled);"BODY"===e.tagName&&(t.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)+"px"),this.prop.overlay=n("div",{className:"html2pdf__overlay",style:{position:"fixed",overflow:"hidden",zIndex:1e3,left:"-100000px",right:0,bottom:0,top:0}}),this.prop.container=n("div",{className:"html2pdf__container",style:t}),this.prop.container.appendChild(e),this.prop.container.firstChild.appendChild(n("div",{style:{clear:"both",border:"0 none transparent",margin:0,padding:0,height:0}})),this.prop.container.style.float="none",this.prop.overlay.appendChild(this.prop.container),document.body.appendChild(this.prop.overlay),this.prop.container.firstChild.style.position="relative",this.prop.container.height=Math.max(this.prop.container.firstChild.clientHeight,this.prop.container.firstChild.scrollHeight,this.prop.container.firstChild.offsetHeight)+"px"})},a.prototype.toCanvas=function(){var t=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(t).then(e).then(function(t){var e=Object.assign({},this.opt.html2canvas);return delete e.onrendered,t(this.prop.container,e)}).then(function(t){(this.opt.html2canvas.onrendered||function(){})(t),this.prop.canvas=t,document.body.removeChild(this.prop.overlay)})},a.prototype.toContext2d=function(){var t=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(t).then(e).then(function(t){var e=this.opt.jsPDF,r=this.opt.fontFaces,i="number"!=typeof this.opt.width||isNaN(this.opt.width)||"number"!=typeof this.opt.windowWidth||isNaN(this.opt.windowWidth)?1:this.opt.width/this.opt.windowWidth,n=Object.assign({async:!0,allowTaint:!0,scale:i,scrollX:this.opt.scrollX||0,scrollY:this.opt.scrollY||0,backgroundColor:"#ffffff",imageTimeout:15e3,logging:!0,proxy:null,removeContainer:!0,foreignObjectRendering:!1,useCORS:!1},this.opt.html2canvas);if(delete n.onrendered,e.context2d.autoPaging=void 0===this.opt.autoPaging||this.opt.autoPaging,e.context2d.posX=this.opt.x,e.context2d.posY=this.opt.y,e.context2d.margin=this.opt.margin,e.context2d.fontFaces=r,r)for(var s=0;s<r.length;++s){var o=r[s],a=o.src.find(function(t){return"truetype"===t.format});a&&e.addFont(a.url,o.ref.name,o.ref.style)}return n.windowHeight=n.windowHeight||0,n.windowHeight=0==n.windowHeight?Math.max(this.prop.container.clientHeight,this.prop.container.scrollHeight,this.prop.container.offsetHeight):n.windowHeight,e.context2d.save(!0),t(this.prop.container,n)}).then(function(t){this.opt.jsPDF.context2d.restore(!0),(this.opt.html2canvas.onrendered||function(){})(t),this.prop.canvas=t,document.body.removeChild(this.prop.overlay)})},a.prototype.toImg=function(){return this.thenList([function(){return this.prop.canvas||this.toCanvas()}]).then(function(){var t=this.prop.canvas.toDataURL("image/"+this.opt.image.type,this.opt.image.quality);this.prop.img=document.createElement("img"),this.prop.img.src=t})},a.prototype.toPdf=function(){return this.thenList([function(){return this.toContext2d()}]).then(function(){this.prop.pdf=this.prop.pdf||this.opt.jsPDF})},a.prototype.output=function(t,e,r){return"img"===(r=r||"pdf").toLowerCase()||"image"===r.toLowerCase()?this.outputImg(t,e):this.outputPdf(t,e)},a.prototype.outputPdf=function(t,e){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then(function(){return this.prop.pdf.output(t,e)})},a.prototype.outputImg=function(t){return this.thenList([function(){return this.prop.img||this.toImg()}]).then(function(){switch(t){case void 0:case"img":return this.prop.img;case"datauristring":case"dataurlstring":return this.prop.img.src;case"datauri":case"dataurl":return document.location.href=this.prop.img.src;default:throw'Image output type "'+t+'" is not supported.'}})},a.prototype.save=function(t){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).set(t?{filename:t}:null).then(function(){this.prop.pdf.save(this.opt.filename)})},a.prototype.doCallback=function(){return this.thenList([function(){return this.prop.pdf||this.toPdf()}]).then(function(){this.prop.callback(this.prop.pdf)})},a.prototype.set=function(t){if("object"!==i(t))return this;var e=Object.keys(t||{}).map(function(e){if(e in a.template.prop)return function(){this.prop[e]=t[e]};switch(e){case"margin":return this.setMargin.bind(this,t.margin);case"jsPDF":return function(){return this.opt.jsPDF=t.jsPDF,this.setPageSize()};case"pageSize":return this.setPageSize.bind(this,t.pageSize);default:return function(){this.opt[e]=t[e]}}},this);return this.then(function(){return this.thenList(e)})},a.prototype.get=function(t,e){return this.then(function(){var r=t in a.template.prop?this.prop[t]:this.opt[t];return e?e(r):r})},a.prototype.setMargin=function(t){return this.then(function(){switch(i(t)){case"number":t=[t,t,t,t];case"array":if(2===t.length&&(t=[t[0],t[1],t[0],t[1]]),4===t.length)break;default:return this.error("Invalid margin array.")}this.opt.margin=t}).then(this.setPageSize)},a.prototype.setPageSize=function(t){function e(t,e){return Math.floor(t*e/72*96)}return this.then(function(){(t=t||Cf.getPageSize(this.opt.jsPDF)).hasOwnProperty("inner")||(t.inner={width:t.width-this.opt.margin[1]-this.opt.margin[3],height:t.height-this.opt.margin[0]-this.opt.margin[2]},t.inner.px={width:e(t.inner.width,t.k),height:e(t.inner.height,t.k)},t.inner.ratio=t.inner.height/t.inner.width),this.prop.pageSize=t})},a.prototype.setProgress=function(t,e,r,i){return null!=t&&(this.progress.val=t),null!=e&&(this.progress.state=e),null!=r&&(this.progress.n=r),null!=i&&(this.progress.stack=i),this.progress.ratio=this.progress.val/this.progress.state,this},a.prototype.updateProgress=function(t,e,r,i){return this.setProgress(t?this.progress.val+t:null,e||null,r?this.progress.n+r:null,i?this.progress.stack.concat(i):null)},a.prototype.then=function(t,e){var r=this;return this.thenCore(t,e,function(t,e){return r.updateProgress(null,null,1,[t]),Promise.prototype.then.call(this,function(e){return r.updateProgress(null,t),e}).then(t,e).then(function(t){return r.updateProgress(1),t})})},a.prototype.thenCore=function(t,e,r){r=r||Promise.prototype.then;var i=this;t&&(t=t.bind(i)),e&&(e=e.bind(i));var n=-1!==Promise.toString().indexOf("[native code]")&&"Promise"===Promise.name?i:a.convert(Object.assign({},i),Promise.prototype),s=r.call(n,t,e);return a.convert(s,i.__proto__)},a.prototype.thenExternal=function(t,e){return Promise.prototype.then.call(this,t,e)},a.prototype.thenList=function(t){var e=this;return t.forEach(function(t){e=e.thenCore(t)}),e},a.prototype.catch=function(t){t&&(t=t.bind(this));var e=Promise.prototype.catch.call(this,t);return a.convert(e,this)},a.prototype.catchExternal=function(t){return Promise.prototype.catch.call(this,t)},a.prototype.error=function(t){return this.then(function(){throw new Error(t)})},a.prototype.using=a.prototype.set,a.prototype.saveAs=a.prototype.save,a.prototype.export=a.prototype.output,a.prototype.run=a.prototype.then,Cf.getPageSize=function(t,e,r){if("object"===(0,aa.A)(t)){var i=t;t=i.orientation,e=i.unit||e,r=i.format||r}e=e||"mm",r=r||"a4",t=(""+(t||"P")).toLowerCase();var n,s=(""+r).toLowerCase(),o={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};switch(e){case"pt":n=1;break;case"mm":n=72/25.4;break;case"cm":n=72/2.54;break;case"in":n=72;break;case"px":n=.75;break;case"pc":case"em":n=12;break;case"ex":n=6;break;default:throw"Invalid unit: "+e}var a,h=0,l=0;if(o.hasOwnProperty(s))h=o[s][1]/n,l=o[s][0]/n;else try{h=r[1],l=r[0]}catch(t){throw new Error("Invalid format: "+r)}if("p"===t||"portrait"===t)t="p",l>h&&(a=l,l=h,h=a);else{if("l"!==t&&"landscape"!==t)throw"Invalid orientation: "+t;t="l",h>l&&(a=l,l=h,h=a)}return{width:l,height:h,unit:e,k:n,orientation:t}},t.html=function(t,e){(e=e||{}).callback=e.callback||function(){},e.html2canvas=e.html2canvas||{},e.html2canvas.canvas=e.html2canvas.canvas||this.canvas,e.jsPDF=e.jsPDF||this,e.fontFaces=e.fontFaces?e.fontFaces.map(yd):null;var r=new a(e);return e.worker?r:r.from(t).doCallback()}}(Cf.API),Cf.API.addJS=function(t){var e,r,i=function(t){for(var e="",r=0;r<t.length;r++){var i=t[r];if("("===i||")"===i){for(var n=0,s=r-1;s>=0&&"\\"===t[s];s--)n++;e+=n%2==0?"\\"+i:i}else e+=i}return e}(t);return this.internal.events.subscribe("postPutResources",function(){e=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/Names [(EmbeddedJS) "+(e+1)+" 0 R]"),this.internal.out(">>"),this.internal.out("endobj"),r=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/S /JavaScript"),this.internal.out("/JS ("+i+")"),this.internal.out(">>"),this.internal.out("endobj")}),this.internal.events.subscribe("putCatalog",function(){void 0!==e&&void 0!==r&&this.internal.out("/Names <</JavaScript "+e+" 0 R>>")}),this},function(t){var e;t.events.push(["postPutResources",function(){var t=this,r=/^(\d+) 0 obj$/;if(this.outline.root.children.length>0)for(var i=t.outline.render().split(/\r\n/),n=0;n<i.length;n++){var s=i[n],o=r.exec(s);if(null!=o){var a=o[1];t.internal.newObjectDeferredBegin(a,!1)}t.internal.write(s)}if(this.outline.createNamedDestinations){var h=this.internal.pages.length,l=[];for(n=0;n<h;n++){var c=t.internal.newObject();l.push(c);var u=t.internal.getPageInfo(n+1);t.internal.write("<< /D["+u.objId+" 0 R /XYZ null null null]>> endobj")}var f=t.internal.newObject();for(t.internal.write("<< /Names [ "),n=0;n<l.length;n++)t.internal.write("(page_"+(n+1)+")"+l[n]+" 0 R");t.internal.write(" ] >>","endobj"),e=t.internal.newObject(),t.internal.write("<< /Dests "+f+" 0 R"),t.internal.write(">>","endobj")}}]),t.events.push(["putCatalog",function(){var t=this;t.outline.root.children.length>0&&(t.internal.write("/Outlines",this.outline.makeRef(this.outline.root)),this.outline.createNamedDestinations&&t.internal.write("/Names "+e+" 0 R"))}]),t.events.push(["initialized",function(){var t=this;t.outline={createNamedDestinations:!1,root:{children:[]}},t.outline.add=function(t,e,r){var i={title:e,options:r,children:[]};return null==t&&(t=this.root),t.children.push(i),i},t.outline.render=function(){return this.ctx={},this.ctx.val="",this.ctx.pdf=t,this.genIds_r(this.root),this.renderRoot(this.root),this.renderItems(this.root),this.ctx.val},t.outline.genIds_r=function(e){e.id=t.internal.newObjectDeferred();for(var r=0;r<e.children.length;r++)this.genIds_r(e.children[r])},t.outline.renderRoot=function(t){this.objStart(t),this.line("/Type /Outlines"),t.children.length>0&&(this.line("/First "+this.makeRef(t.children[0])),this.line("/Last "+this.makeRef(t.children[t.children.length-1]))),this.line("/Count "+this.count_r({count:0},t)),this.objEnd()},t.outline.renderItems=function(e){for(var r=this.ctx.pdf.internal.getVerticalCoordinateString,i=0;i<e.children.length;i++){var n=e.children[i];this.objStart(n),this.line("/Title "+this.makeString(n.title)),this.line("/Parent "+this.makeRef(e)),i>0&&this.line("/Prev "+this.makeRef(e.children[i-1])),i<e.children.length-1&&this.line("/Next "+this.makeRef(e.children[i+1])),n.children.length>0&&(this.line("/First "+this.makeRef(n.children[0])),this.line("/Last "+this.makeRef(n.children[n.children.length-1])));var s=this.count=this.count_r({count:0},n);if(s>0&&this.line("/Count "+s),n.options&&n.options.pageNumber){var o=t.internal.getPageInfo(n.options.pageNumber);this.line("/Dest ["+o.objId+" 0 R /XYZ 0 "+r(0)+" 0]")}this.objEnd()}for(var a=0;a<e.children.length;a++)this.renderItems(e.children[a])},t.outline.line=function(t){this.ctx.val+=t+"\r\n"},t.outline.makeRef=function(t){return t.id+" 0 R"},t.outline.makeString=function(e){return"("+t.internal.pdfEscape(e)+")"},t.outline.objStart=function(t){this.ctx.val+="\r\n"+t.id+" 0 obj\r\n<<\r\n"},t.outline.objEnd=function(){this.ctx.val+=">> \r\nendobj\r\n"},t.outline.count_r=function(t,e){for(var r=0;r<e.children.length;r++)t.count++,this.count_r(t,e.children[r]);return t.count}}])}(Cf.API),function(t){var e=[192,193,194,195,196,197,198,199];t.processJPEG=function(t,r,i,n,s,o){var a,h=this.decode.DCT_DECODE,l=null;if("string"==typeof t||this.__addimage__.isArrayBuffer(t)||this.__addimage__.isArrayBufferView(t)){switch(t=s||t,t=this.__addimage__.isArrayBuffer(t)?new Uint8Array(t):t,a=function(t){for(var r,i=256*t.charCodeAt(4)+t.charCodeAt(5),n=t.length,s={width:0,height:0,numcomponents:1},o=4;o<n;o+=2){if(o+=i,-1!==e.indexOf(t.charCodeAt(o+1))){r=256*t.charCodeAt(o+5)+t.charCodeAt(o+6),s={width:256*t.charCodeAt(o+7)+t.charCodeAt(o+8),height:r,numcomponents:t.charCodeAt(o+9)};break}i=256*t.charCodeAt(o+2)+t.charCodeAt(o+3)}return s}(t=this.__addimage__.isArrayBufferView(t)?this.__addimage__.arrayBufferToBinaryString(t):t),a.numcomponents){case 1:o=this.color_spaces.DEVICE_GRAY;break;case 4:o=this.color_spaces.DEVICE_CMYK;break;case 3:o=this.color_spaces.DEVICE_RGB}l={data:t,width:a.width,height:a.height,colorSpace:o,bitsPerComponent:8,filter:h,index:r,alias:i}}return l}}(Cf.API),Cf.API.processPNG=function(t,e,r,i){if(this.__addimage__.isArrayBuffer(t)&&(t=new Uint8Array(t)),this.__addimage__.isArrayBufferView(t)){var n,s=new qu(t,{checkCrc:!0}).decode(),o=s.width,a=s.height,h=s.channels,l=s.palette,c=s.depth;n=l&&1===h?function(t){for(var e=t.width,r=t.height,i=t.data,n=t.palette,s=t.depth,o=!1,a=[],h=[],l=void 0,c=!1,u=0,f=0;f<n.length;f++){var d=Va(n[f],4),p=d[0],g=d[1],m=d[2],v=d[3];a.push(p,g,m),null!=v&&(0===v?(u++,h.length<1&&h.push(f)):v<255&&(c=!0))}if(c||u>1){o=!0,h=void 0;var y=e*r;l=new Uint8Array(y);for(var b=new DataView(i.buffer),w=0;w<y;w++){var _=Va(n[zd(b,w,s)],4)[3];l[w]=_}}else 0===u&&(h=void 0);return{colorSpace:"Indexed",colorsPerPixel:1,sMaskBitsPerComponent:o?8:void 0,colorBytes:i,alphaBytes:l,needSMask:o,palette:a,mask:h}}(s):2===h||4===h?function(t){for(var e=t.data,r=t.width,i=t.height,n=t.channels,s=t.depth,o=2===n?"DeviceGray":"DeviceRGB",a=n-1,h=r*i,l=a,c=h*l,u=1*h,f=Math.ceil(c*s/8),d=Math.ceil(u*s/8),p=new Uint8Array(f),g=new Uint8Array(d),m=new DataView(e.buffer),v=new DataView(p.buffer),y=new DataView(g.buffer),b=!1,w=0;w<h;w++){for(var _=w*n,x=0;x<l;x++)Ud(v,zd(m,_+x,s),w*l+x,s);var S=zd(m,_+l,s);S<(1<<s)-1&&(b=!0),Ud(y,S,1*w,s)}return{colorSpace:o,colorsPerPixel:a,sMaskBitsPerComponent:b?s:void 0,colorBytes:p,alphaBytes:g,needSMask:b}}(s):function(t){var e=t.data,r=1===t.channels?"DeviceGray":"DeviceRGB";return{colorSpace:r,colorsPerPixel:"DeviceGray"===r?1:3,colorBytes:e instanceof Uint16Array?function(t){for(var e=t.length,r=new Uint8Array(2*e),i=new DataView(r.buffer,r.byteOffset,r.byteLength),n=0;n<e;n++)i.setUint16(2*n,t[n],!1);return r}(e):e,needSMask:!1}}(s);var u,f,d,p=n,g=p.colorSpace,m=p.colorsPerPixel,v=p.sMaskBitsPerComponent,y=p.colorBytes,b=p.alphaBytes,w=p.needSMask,_=p.palette,x=p.mask,S=null;return i!==Cf.API.image_compression.NONE?(S=function(t){var e;switch(t){case Cf.API.image_compression.FAST:e=11;break;case Cf.API.image_compression.MEDIUM:e=13;break;case Cf.API.image_compression.SLOW:e=14;break;default:e=12}return e}(i),u=this.decode.FLATE_DECODE,f="/Predictor ".concat(S," /Colors ").concat(m," /BitsPerComponent ").concat(c," /Columns ").concat(o),t=Ed(y,Math.ceil(o*m*c/8),m,c,i),w&&(d=Ed(b,Math.ceil(o*v/8),1,v,i))):(u=void 0,f=void 0,t=y,w&&(d=b)),(this.__addimage__.isArrayBuffer(t)||this.__addimage__.isArrayBufferView(t))&&(t=this.__addimage__.arrayBufferToBinaryString(t)),(d&&this.__addimage__.isArrayBuffer(d)||this.__addimage__.isArrayBufferView(d))&&(d=this.__addimage__.arrayBufferToBinaryString(d)),{alias:r,data:t,index:e,filter:u,decodeParameters:f,transparency:x,palette:_,sMask:d,predictor:S,width:o,height:a,bitsPerComponent:c,sMaskBitsPerComponent:v,colorSpace:g}}},function(t){t.processGIF89A=function(e,r,i,n){var s=new Wd(e),o=s.width,a=s.height,h=[];s.decodeAndBlitFrameRGBA(0,h);var l={data:h,width:o,height:a},c=new Vd(100).encode(l,100);return t.processJPEG.call(this,c,r,i,n)},t.processGIF87A=t.processGIF89A}(Cf.API),Yd.prototype.parseHeader=function(){if(this.fileSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.reserved=this.datav.getUint32(this.pos,!0),this.pos+=4,this.offset=this.datav.getUint32(this.pos,!0),this.pos+=4,this.headerSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.width=this.datav.getUint32(this.pos,!0),this.pos+=4,this.height=this.datav.getInt32(this.pos,!0),this.pos+=4,this.planes=this.datav.getUint16(this.pos,!0),this.pos+=2,this.bitPP=this.datav.getUint16(this.pos,!0),this.pos+=2,this.compress=this.datav.getUint32(this.pos,!0),this.pos+=4,this.rawSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.hr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.vr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.colors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.importantColors=this.datav.getUint32(this.pos,!0),this.pos+=4,16===this.bitPP&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var t=0===this.colors?1<<this.bitPP:this.colors;this.palette=new Array(t);for(var e=0;e<t;e++){var r=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),n=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0);this.palette[e]={red:n,green:i,blue:r,quad:s}}}this.height<0&&(this.height*=-1,this.bottom_up=!1)},Yd.prototype.parseBGR=function(){this.pos=this.offset;var t="bit"+this.bitPP,e=this.width*this.height*4;if(e>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");this.data=new Uint8Array(e);try{this[t]()}catch(t){Yu.log("bit decode error:"+t)}},Yd.prototype.bit1=function(){var t,e=Math.ceil(this.width/8),r=e%4;for(t=this.height-1;t>=0;t--){for(var i=this.bottom_up?t:this.height-1-t,n=0;n<e;n++)for(var s=this.datav.getUint8(this.pos++,!0),o=i*this.width*4+8*n*4,a=0;a<8&&8*n+a<this.width;a++){var h=this.palette[s>>7-a&1];this.data[o+4*a]=h.blue,this.data[o+4*a+1]=h.green,this.data[o+4*a+2]=h.red,this.data[o+4*a+3]=255}0!==r&&(this.pos+=4-r)}},Yd.prototype.bit4=function(){for(var t=Math.ceil(this.width/2),e=t%4,r=this.height-1;r>=0;r--){for(var i=this.bottom_up?r:this.height-1-r,n=0;n<t;n++){var s=this.datav.getUint8(this.pos++,!0),o=i*this.width*4+2*n*4,a=s>>4,h=15&s,l=this.palette[a];if(this.data[o]=l.blue,this.data[o+1]=l.green,this.data[o+2]=l.red,this.data[o+3]=255,2*n+1>=this.width)break;l=this.palette[h],this.data[o+4]=l.blue,this.data[o+4+1]=l.green,this.data[o+4+2]=l.red,this.data[o+4+3]=255}0!==e&&(this.pos+=4-e)}},Yd.prototype.bit8=function(){for(var t=this.width%4,e=this.height-1;e>=0;e--){for(var r=this.bottom_up?e:this.height-1-e,i=0;i<this.width;i++){var n=this.datav.getUint8(this.pos++,!0),s=r*this.width*4+4*i;if(n<this.palette.length){var o=this.palette[n];this.data[s]=o.red,this.data[s+1]=o.green,this.data[s+2]=o.blue,this.data[s+3]=255}else this.data[s]=255,this.data[s+1]=255,this.data[s+2]=255,this.data[s+3]=255}0!==t&&(this.pos+=4-t)}},Yd.prototype.bit15=function(){for(var t=this.width%3,e=parseInt("11111",2),r=this.height-1;r>=0;r--){for(var i=this.bottom_up?r:this.height-1-r,n=0;n<this.width;n++){var s=this.datav.getUint16(this.pos,!0);this.pos+=2;var o=(s&e)/e*255|0,a=(s>>5&e)/e*255|0,h=(s>>10&e)/e*255|0,l=s>>15?255:0,c=i*this.width*4+4*n;this.data[c]=h,this.data[c+1]=a,this.data[c+2]=o,this.data[c+3]=l}this.pos+=t}},Yd.prototype.bit16=function(){for(var t=this.width%3,e=parseInt("11111",2),r=parseInt("111111",2),i=this.height-1;i>=0;i--){for(var n=this.bottom_up?i:this.height-1-i,s=0;s<this.width;s++){var o=this.datav.getUint16(this.pos,!0);this.pos+=2;var a=(o&e)/e*255|0,h=(o>>5&r)/r*255|0,l=(o>>11)/e*255|0,c=n*this.width*4+4*s;this.data[c]=l,this.data[c+1]=h,this.data[c+2]=a,this.data[c+3]=255}this.pos+=t}},Yd.prototype.bit24=function(){for(var t=this.height-1;t>=0;t--){for(var e=this.bottom_up?t:this.height-1-t,r=0;r<this.width;r++){var i=this.datav.getUint8(this.pos++,!0),n=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0),o=e*this.width*4+4*r;this.data[o]=s,this.data[o+1]=n,this.data[o+2]=i,this.data[o+3]=255}this.pos+=this.width%4}},Yd.prototype.bit32=function(){for(var t=this.height-1;t>=0;t--)for(var e=this.bottom_up?t:this.height-1-t,r=0;r<this.width;r++){var i=this.datav.getUint8(this.pos++,!0),n=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0),o=this.datav.getUint8(this.pos++,!0),a=e*this.width*4+4*r;this.data[a]=s,this.data[a+1]=n,this.data[a+2]=i,this.data[a+3]=o}},Yd.prototype.getData=function(){return this.data},function(t){t.processBMP=function(e,r,i,n){var s=new Yd(e,!1),o=s.width,a=s.height,h={data:s.getData(),width:o,height:a},l=new Vd(100).encode(h,100);return t.processJPEG.call(this,l,r,i,n)}}(Cf.API),Xd.prototype.getData=function(){return this.data},function(t){t.processWEBP=function(e,r,i,n){var s=new Xd(e),o=s.width,a=s.height,h={data:s.getData(),width:o,height:a},l=new Vd(100).encode(h,100);return t.processJPEG.call(this,l,r,i,n)}}(Cf.API),Cf.API.processRGBA=function(t,e,r){for(var i=t.data,n=i.length,s=new Uint8Array(n/4*3),o=new Uint8Array(n/4),a=0,h=0,l=0;l<n;l+=4){var c=i[l],u=i[l+1],f=i[l+2],d=i[l+3];s[a++]=c,s[a++]=u,s[a++]=f,o[h++]=d}var p=this.__addimage__.arrayBufferToBinaryString(s);return{alpha:this.__addimage__.arrayBufferToBinaryString(o),data:p,index:e,alias:r,colorSpace:"DeviceRGB",bitsPerComponent:8,width:t.width,height:t.height}},Cf.API.setLanguage=function(t){return void 0===this.internal.languageSettings&&(this.internal.languageSettings={},this.internal.languageSettings.isSubscribed=!1),void 0!=={af:"Afrikaans",sq:"Albanian",ar:"Arabic (Standard)","ar-DZ":"Arabic (Algeria)","ar-BH":"Arabic (Bahrain)","ar-EG":"Arabic (Egypt)","ar-IQ":"Arabic (Iraq)","ar-JO":"Arabic (Jordan)","ar-KW":"Arabic (Kuwait)","ar-LB":"Arabic (Lebanon)","ar-LY":"Arabic (Libya)","ar-MA":"Arabic (Morocco)","ar-OM":"Arabic (Oman)","ar-QA":"Arabic (Qatar)","ar-SA":"Arabic (Saudi Arabia)","ar-SY":"Arabic (Syria)","ar-TN":"Arabic (Tunisia)","ar-AE":"Arabic (U.A.E.)","ar-YE":"Arabic (Yemen)",an:"Aragonese",hy:"Armenian",as:"Assamese",ast:"Asturian",az:"Azerbaijani",eu:"Basque",be:"Belarusian",bn:"Bengali",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",zh:"Chinese","zh-HK":"Chinese (Hong Kong)","zh-CN":"Chinese (PRC)","zh-SG":"Chinese (Singapore)","zh-TW":"Chinese (Taiwan)",cv:"Chuvash",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch (Standard)","nl-BE":"Dutch (Belgian)",en:"English","en-AU":"English (Australia)","en-BZ":"English (Belize)","en-CA":"English (Canada)","en-IE":"English (Ireland)","en-JM":"English (Jamaica)","en-NZ":"English (New Zealand)","en-PH":"English (Philippines)","en-ZA":"English (South Africa)","en-TT":"English (Trinidad & Tobago)","en-GB":"English (United Kingdom)","en-US":"English (United States)","en-ZW":"English (Zimbabwe)",eo:"Esperanto",et:"Estonian",fo:"Faeroese",fj:"Fijian",fi:"Finnish",fr:"French (Standard)","fr-BE":"French (Belgium)","fr-CA":"French (Canada)","fr-FR":"French (France)","fr-LU":"French (Luxembourg)","fr-MC":"French (Monaco)","fr-CH":"French (Switzerland)",fy:"Frisian",fur:"Friulian",gd:"Gaelic (Scots)","gd-IE":"Gaelic (Irish)",gl:"Galacian",ka:"Georgian",de:"German (Standard)","de-AT":"German (Austria)","de-DE":"German (Germany)","de-LI":"German (Liechtenstein)","de-LU":"German (Luxembourg)","de-CH":"German (Switzerland)",el:"Greek",gu:"Gujurati",ht:"Haitian",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",iu:"Inuktitut",ga:"Irish",it:"Italian (Standard)","it-CH":"Italian (Switzerland)",ja:"Japanese",kn:"Kannada",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ky:"Kirghiz",tlh:"Klingon",ko:"Korean","ko-KP":"Korean (North Korea)","ko-KR":"Korean (South Korea)",la:"Latin",lv:"Latvian",lt:"Lithuanian",lb:"Luxembourgish",mk:"North Macedonia",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mo:"Moldavian",nv:"Navajo",ng:"Ndonga",ne:"Nepali",no:"Norwegian",nb:"Norwegian (Bokmal)",nn:"Norwegian (Nynorsk)",oc:"Occitan",or:"Oriya",om:"Oromo",fa:"Persian","fa-IR":"Persian/Iran",pl:"Polish",pt:"Portuguese","pt-BR":"Portuguese (Brazil)",pa:"Punjabi","pa-IN":"Punjabi (India)","pa-PK":"Punjabi (Pakistan)",qu:"Quechua",rm:"Rhaeto-Romanic",ro:"Romanian","ro-MO":"Romanian (Moldavia)",ru:"Russian","ru-MO":"Russian (Moldavia)",sz:"Sami (Lappish)",sg:"Sango",sa:"Sanskrit",sc:"Sardinian",sd:"Sindhi",si:"Singhalese",sr:"Serbian",sk:"Slovak",sl:"Slovenian",so:"Somani",sb:"Sorbian",es:"Spanish","es-AR":"Spanish (Argentina)","es-BO":"Spanish (Bolivia)","es-CL":"Spanish (Chile)","es-CO":"Spanish (Colombia)","es-CR":"Spanish (Costa Rica)","es-DO":"Spanish (Dominican Republic)","es-EC":"Spanish (Ecuador)","es-SV":"Spanish (El Salvador)","es-GT":"Spanish (Guatemala)","es-HN":"Spanish (Honduras)","es-MX":"Spanish (Mexico)","es-NI":"Spanish (Nicaragua)","es-PA":"Spanish (Panama)","es-PY":"Spanish (Paraguay)","es-PE":"Spanish (Peru)","es-PR":"Spanish (Puerto Rico)","es-ES":"Spanish (Spain)","es-UY":"Spanish (Uruguay)","es-VE":"Spanish (Venezuela)",sx:"Sutu",sw:"Swahili",sv:"Swedish","sv-FI":"Swedish (Finland)","sv-SV":"Swedish (Sweden)",ta:"Tamil",tt:"Tatar",te:"Teluga",th:"Thai",tig:"Tigre",ts:"Tsonga",tn:"Tswana",tr:"Turkish",tk:"Turkmen",uk:"Ukrainian",hsb:"Upper Sorbian",ur:"Urdu",ve:"Venda",vi:"Vietnamese",vo:"Volapuk",wa:"Walloon",cy:"Welsh",xh:"Xhosa",ji:"Yiddish",zu:"Zulu"}[t]&&(this.internal.languageSettings.languageCode=t,!1===this.internal.languageSettings.isSubscribed&&(this.internal.events.subscribe("putCatalog",function(){this.internal.write("/Lang ("+this.internal.languageSettings.languageCode+")")}),this.internal.languageSettings.isSubscribed=!0)),this},kd=Cf.API,Ld=kd.getCharWidthsArray=function(t,e){var r,i,n=(e=e||{}).font||this.internal.getFont(),s=e.fontSize||this.internal.getFontSize(),o=e.charSpace||this.internal.getCharSpace(),a=e.widths?e.widths:n.metadata.Unicode.widths,h=a.fof?a.fof:1,l=e.kerning?e.kerning:n.metadata.Unicode.kerning,c=l.fof?l.fof:1,u=!1!==e.doKerning,f=0,d=t.length,p=0,g=a[0]||h,m=[];for(r=0;r<d;r++)i=t.charCodeAt(r),"function"==typeof n.metadata.widthOfString?m.push((n.metadata.widthOfGlyph(n.metadata.characterToGlyph(i))+o*(1e3/s)||0)/1e3):(f=u&&"object"===(0,aa.A)(l[i])&&!isNaN(parseInt(l[i][p],10))?l[i][p]/c:0,m.push((a[i]||g)/h+f)),p=i;return m},Td=kd.getStringUnitWidth=function(t,e){var r=(e=e||{}).fontSize||this.internal.getFontSize(),i=e.font||this.internal.getFont(),n=e.charSpace||this.internal.getCharSpace();return kd.processArabic&&(t=kd.processArabic(t)),"function"==typeof i.metadata.widthOfString?i.metadata.widthOfString(t,r,n)/r:Ld.apply(this,arguments).reduce(function(t,e){return t+e},0)},Pd=function(t,e,r,i){for(var n=[],s=0,o=t.length,a=0;s!==o&&a+e[s]<r;)a+=e[s],s++;n.push(t.slice(0,s));var h=s;for(a=0;s!==o;)a+e[s]>i&&(n.push(t.slice(h,s)),a=0,h=s),a+=e[s],s++;return h!==s&&n.push(t.slice(h,s)),n},Nd=function(t,e,r){r||(r={});var i,n,s,o,a,h,l,c=[],u=[c],f=r.textIndent||0,d=0,p=0,g=t.split(" "),m=Ld.apply(this,[" ",r])[0];if(h=-1===r.lineIndent?g[0].length+2:r.lineIndent||0){var v=Array(h).join(" "),y=[];g.map(function(t){(t=t.split(/\s*\n/)).length>1?y=y.concat(t.map(function(t,e){return(e&&t.length?"\n":"")+t})):y.push(t[0])}),g=y,h=Td.apply(this,[v,r])}for(s=0,o=g.length;s<o;s++){var b=0;if(i=g[s],h&&"\n"==i[0]&&(i=i.substr(1),b=1),f+d+(p=(n=Ld.apply(this,[i,r])).reduce(function(t,e){return t+e},0))>e||b){if(p>e){for(a=Pd.apply(this,[i,n,e-(f+d),e]),c.push(a.shift()),c=[a.pop()];a.length;)u.push([a.shift()]);p=n.slice(i.length-(c[0]?c[0].length:0)).reduce(function(t,e){return t+e},0)}else c=[i];u.push(c),f=p+h,d=m}else c.push(i),f+=d+p,d=m}return l=h?function(t,e){return(e?v:"")+t.join(" ")}:function(t){return t.join(" ")},u.map(l)},kd.splitTextToSize=function(t,e,r){var i,n=(r=r||{}).fontSize||this.internal.getFontSize(),s=function(t){if(t.widths&&t.kerning)return{widths:t.widths,kerning:t.kerning};var e=this.internal.getFont(t.fontName,t.fontStyle),r="Unicode";return e.metadata[r]?{widths:e.metadata[r].widths||{0:1},kerning:e.metadata[r].kerning||{}}:{font:e.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,r);i=Array.isArray(t)?t:String(t).split(/\r?\n/);var o=1*this.internal.scaleFactor*e/n;s.textIndent=r.textIndent?1*r.textIndent*this.internal.scaleFactor/n:0,s.lineIndent=r.lineIndent;var a,h,l=[];for(a=0,h=i.length;a<h;a++)l=l.concat(Nd.apply(this,[i[a],o,s]));return l},function(t){t.__fontmetrics__=t.__fontmetrics__||{};for(var e="0123456789abcdef",r="klmnopqrstuvwxyz",i={},n={},s=0;s<16;s++)i[r[s]]=e[s],n[e[s]]=r[s];var o=function(t){return"0x"+parseInt(t,10).toString(16)},a=t.__fontmetrics__.compress=function(t){var e,r,i,s,h=["{"];for(var l in t){if(e=t[l],isNaN(parseInt(l,10))?r="'"+l+"'":(l=parseInt(l,10),r=(r=o(l).slice(2)).slice(0,-1)+n[r.slice(-1)]),"number"==typeof e)e<0?(i=o(e).slice(3),s="-"):(i=o(e).slice(2),s=""),i=s+i.slice(0,-1)+n[i.slice(-1)];else{if("object"!==(0,aa.A)(e))throw new Error("Don't know what to do with value type "+(0,aa.A)(e)+".");i=a(e)}h.push(r+i)}return h.push("}"),h.join("")},h=t.__fontmetrics__.uncompress=function(t){if("string"!=typeof t)throw new Error("Invalid argument passed to uncompress.");for(var e,r,n,s,o={},a=1,h=o,l=[],c="",u="",f=t.length-1,d=1;d<f;d+=1)"'"==(s=t[d])?e?(n=e.join(""),e=void 0):e=[]:e?e.push(s):"{"==s?(l.push([h,n]),h={},n=void 0):"}"==s?((r=l.pop())[0][r[1]]=h,n=void 0,h=r[0]):"-"==s?a=-1:void 0===n?i.hasOwnProperty(s)?(c+=i[s],n=parseInt(c,16)*a,a=1,c=""):c+=s:i.hasOwnProperty(s)?(u+=i[s],h[n]=parseInt(u,16)*a,a=1,n=void 0,u=""):u+=s;return o},l={codePages:["WinAnsiEncoding"],WinAnsiEncoding:h("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}")},c={Unicode:{Courier:l,"Courier-Bold":l,"Courier-BoldOblique":l,"Courier-Oblique":l,Helvetica:l,"Helvetica-Bold":l,"Helvetica-BoldOblique":l,"Helvetica-Oblique":l,"Times-Roman":l,"Times-Bold":l,"Times-BoldItalic":l,"Times-Italic":l}},u={Unicode:{"Courier-Oblique":h("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-BoldItalic":h("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"),"Helvetica-Bold":h("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),Courier:h("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-BoldOblique":h("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Bold":h("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"),Symbol:h("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"),Helvetica:h("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"),"Helvetica-BoldOblique":h("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),ZapfDingbats:h("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-Bold":h("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Italic":h("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"),"Times-Roman":h("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"),"Helvetica-Oblique":h("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}")}};t.events.push(["addFont",function(t){var e=t.font,r=u.Unicode[e.postScriptName];r&&(e.metadata.Unicode={},e.metadata.Unicode.widths=r.widths,e.metadata.Unicode.kerning=r.kerning);var i=c.Unicode[e.postScriptName];i&&(e.metadata.Unicode.encoding=i,e.encoding=i.codePages[0])}])}(Cf.API),function(t){var e=function(t){for(var e=t.length,r=new Uint8Array(e),i=0;i<e;i++)r[i]=t.charCodeAt(i);return r};t.API.events.push(["addFont",function(r){var i=void 0,n=r.font,s=r.instance;if(!n.isStandardFont){if(void 0===s)throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('"+n.postScriptName+"').");if("string"!=typeof(i=!1===s.existsFileInVFS(n.postScriptName)?s.loadFile(n.postScriptName):s.getFileFromVFS(n.postScriptName)))throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('"+n.postScriptName+"').");!function(r,i){i=/^\x00\x01\x00\x00/.test(i)?e(i):e(Zu(i)),r.metadata=t.API.TTFFont.open(i),r.metadata.Unicode=r.metadata.Unicode||{encoding:{},kerning:{},widths:[]},r.metadata.glyIdsUsed=[0]}(n,i)}}])}(Cf),Cf.API.addSvgAsImage=function(t,e,r,i,n,s,a,h){if(isNaN(e)||isNaN(r))throw Yu.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(i)||isNaN(n))throw Yu.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var l=document.createElement("canvas");l.width=i,l.height=n;var c=l.getContext("2d");c.fillStyle="#fff",c.fillRect(0,0,l.width,l.height);var u={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},f=this;return(Hu.canvg?Promise.resolve(Hu.canvg):o.e(661).then(o.bind(o,661))).catch(function(t){return Promise.reject(new Error("Could not load canvg: "+t))}).then(function(t){return t.default?t.default:t}).then(function(e){return e.fromString(c,t,u)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(t){return t.render(u)}).then(function(){f.addImage(l.toDataURL("image/jpeg",1),e,r,i,n,a,h)})},Cf.API.putTotalPages=function(t){var e,r=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(t,"g"),r=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(t,this.internal.getFont()),"g"),r=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var i=1;i<=this.internal.getNumberOfPages();i++)for(var n=0;n<this.internal.pages[i].length;n++)this.internal.pages[i][n]=this.internal.pages[i][n].replace(e,r);return this},Cf.API.viewerPreferences=function(t,e){var r;t=t||{},e=e||!1;var i,n,s,o={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},a=Object.keys(o),h=[],l=0,c=0,u=0;function f(t,e){var r,i=!1;for(r=0;r<t.length;r+=1)t[r]===e&&(i=!0);return i}if(void 0===this.internal.viewerpreferences&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),r=this.internal.viewerpreferences.configuration,"reset"===t||!0===e){var d=a.length;for(u=0;u<d;u+=1)r[a[u]].value=r[a[u]].defaultValue,r[a[u]].explicitSet=!1}if("object"===(0,aa.A)(t))for(n in t)if(s=t[n],f(a,n)&&void 0!==s){if("boolean"===r[n].type&&"boolean"==typeof s)r[n].value=s;else if("name"===r[n].type&&f(r[n].valueSet,s))r[n].value=s;else if("integer"===r[n].type&&Number.isInteger(s))r[n].value=s;else if("array"===r[n].type){for(l=0;l<s.length;l+=1)if(i=!0,1===s[l].length&&"number"==typeof s[l][0])h.push(String(s[l]-1));else if(s[l].length>1){for(c=0;c<s[l].length;c+=1)"number"!=typeof s[l][c]&&(i=!1);!0===i&&h.push([s[l][0]-1,s[l][1]-1].join(" "))}r[n].value="["+h.join(" ")+"]"}else r[n].value=r[n].defaultValue;r[n].explicitSet=!0}return!1===this.internal.viewerpreferences.isSubscribed&&(this.internal.events.subscribe("putCatalog",function(){var t,e=[];for(t in r)!0===r[t].explicitSet&&("name"===r[t].type?e.push("/"+t+" /"+r[t].value):e.push("/"+t+" "+r[t].value));0!==e.length&&this.internal.write("/ViewerPreferences\n<<\n"+e.join("\n")+"\n>>")}),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=r,this},Cf.API.addMetadata=function(t,e){return void 0===this.internal.__metadata__&&(this.internal.__metadata__={metadata:t,namespaceUri:null!=e?e:"http://jspdf.default.namespaceuri/",rawXml:"boolean"==typeof e&&e},this.internal.events.subscribe("putCatalog",$d),this.internal.events.subscribe("postPutResources",Gd)),this},function(t){var e=t.API,r=e.pdfEscape16=function(t,e){for(var r,i=e.metadata.Unicode.widths,n=["","0","00","000","0000"],s=[""],o=0,a=t.length;o<a;++o){if(r=e.metadata.characterToGlyph(t.charCodeAt(o)),e.metadata.glyIdsUsed.push(r),e.metadata.toUnicode[r]=t.charCodeAt(o),-1==i.indexOf(r)&&(i.push(r),i.push([parseInt(e.metadata.widthOfGlyph(r),10)])),"0"==r)return s.join("");r=r.toString(16),s.push(n[4-r.length],r)}return s.join("")},i=function(t){var e,r,i,n,s,o,a;for(s="/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo <<\n  /Registry (Adobe)\n  /Ordering (UCS)\n  /Supplement 0\n>> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000><ffff>\nendcodespacerange",i=[],o=0,a=(r=Object.keys(t).sort(function(t,e){return t-e})).length;o<a;o++)e=r[o],i.length>=100&&(s+="\n"+i.length+" beginbfchar\n"+i.join("\n")+"\nendbfchar",i=[]),void 0!==t[e]&&null!==t[e]&&"function"==typeof t[e].toString&&(n=("0000"+t[e].toString(16)).slice(-4),e=("0000"+(+e).toString(16)).slice(-4),i.push("<"+e+"><"+n+">"));return i.length&&(s+="\n"+i.length+" beginbfchar\n"+i.join("\n")+"\nendbfchar\n"),s+"endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend"};e.events.push(["putFont",function(e){!function(e){var r=e.font,n=e.out,s=e.newObject,o=e.putStream;if(r.metadata instanceof t.API.TTFFont&&"Identity-H"===r.encoding){for(var a=r.metadata.Unicode.widths,h=r.metadata.subset.encode(r.metadata.glyIdsUsed,1),l="",c=0;c<h.length;c++)l+=String.fromCharCode(h[c]);var u=s();o({data:l,addLength1:!0,objectId:u}),n("endobj");var f=s();o({data:i(r.metadata.toUnicode),addLength1:!0,objectId:f}),n("endobj");var d=s();n("<<"),n("/Type /FontDescriptor"),n("/FontName /"+yf(r.fontName)),n("/FontFile2 "+u+" 0 R"),n("/FontBBox "+t.API.PDFObject.convert(r.metadata.bbox)),n("/Flags "+r.metadata.flags),n("/StemV "+r.metadata.stemV),n("/ItalicAngle "+r.metadata.italicAngle),n("/Ascent "+r.metadata.ascender),n("/Descent "+r.metadata.decender),n("/CapHeight "+r.metadata.capHeight),n(">>"),n("endobj");var p=s();n("<<"),n("/Type /Font"),n("/BaseFont /"+yf(r.fontName)),n("/FontDescriptor "+d+" 0 R"),n("/W "+t.API.PDFObject.convert(a)),n("/CIDToGIDMap /Identity"),n("/DW 1000"),n("/Subtype /CIDFontType2"),n("/CIDSystemInfo"),n("<<"),n("/Supplement 0"),n("/Registry (Adobe)"),n("/Ordering ("+r.encoding+")"),n(">>"),n(">>"),n("endobj"),r.objectNumber=s(),n("<<"),n("/Type /Font"),n("/Subtype /Type0"),n("/ToUnicode "+f+" 0 R"),n("/BaseFont /"+yf(r.fontName)),n("/Encoding /"+r.encoding),n("/DescendantFonts ["+p+" 0 R]"),n(">>"),n("endobj"),r.isAlreadyPutted=!0}}(e)}]),e.events.push(["putFont",function(e){!function(e){var r=e.font,n=e.out,s=e.newObject,o=e.putStream;if(r.metadata instanceof t.API.TTFFont&&"WinAnsiEncoding"===r.encoding){for(var a=r.metadata.rawData,h="",l=0;l<a.length;l++)h+=String.fromCharCode(a[l]);var c=s();o({data:h,addLength1:!0,objectId:c}),n("endobj");var u=s();o({data:i(r.metadata.toUnicode),addLength1:!0,objectId:u}),n("endobj");var f=s();n("<<"),n("/Descent "+r.metadata.decender),n("/CapHeight "+r.metadata.capHeight),n("/StemV "+r.metadata.stemV),n("/Type /FontDescriptor"),n("/FontFile2 "+c+" 0 R"),n("/Flags 96"),n("/FontBBox "+t.API.PDFObject.convert(r.metadata.bbox)),n("/FontName /"+yf(r.fontName)),n("/ItalicAngle "+r.metadata.italicAngle),n("/Ascent "+r.metadata.ascender),n(">>"),n("endobj"),r.objectNumber=s();for(var d=0;d<r.metadata.hmtx.widths.length;d++)r.metadata.hmtx.widths[d]=parseInt(r.metadata.hmtx.widths[d]*(1e3/r.metadata.head.unitsPerEm));n("<</Subtype/TrueType/Type/Font/ToUnicode "+u+" 0 R/BaseFont/"+yf(r.fontName)+"/FontDescriptor "+f+" 0 R/Encoding/"+r.encoding+" /FirstChar 29 /LastChar 255 /Widths "+t.API.PDFObject.convert(r.metadata.hmtx.widths)+">>"),n("endobj"),r.isAlreadyPutted=!0}}(e)}]);var n=function(t){var e,i=t.text||"",n=t.x,s=t.y,o=t.options||{},a=t.mutex||{},h=a.pdfEscape,l=a.activeFontKey,c=a.fonts,u=l,f="",d=0,p="",g=c[u].encoding;if("Identity-H"!==c[u].encoding)return{text:i,x:n,y:s,options:o,mutex:a};for(p=i,u=l,Array.isArray(i)&&(p=i[0]),d=0;d<p.length;d+=1)c[u].metadata.hasOwnProperty("cmap")&&(e=c[u].metadata.cmap.unicode.codeMap[p[d].charCodeAt(0)]),e||p[d].charCodeAt(0)<256&&c[u].metadata.hasOwnProperty("Unicode")?f+=p[d]:f+="";var m="";return parseInt(u.slice(1))<14||"WinAnsiEncoding"===g?m=h(f,u).split("").map(function(t){return t.charCodeAt(0).toString(16)}).join(""):"Identity-H"===g&&(m=r(f,c[u])),a.isHex=!0,{text:m,x:n,y:s,options:o,mutex:a}};e.events.push(["postProcessText",function(t){var e=t.text||"",r=[],i={text:e,x:t.x,y:t.y,options:t.options,mutex:t.mutex};if(Array.isArray(e)){var s=0;for(s=0;s<e.length;s+=1)Array.isArray(e[s])&&3===e[s].length?r.push([n(Object.assign({},i,{text:e[s][0]})).text,e[s][1],e[s][2]]):r.push(n(Object.assign({},i,{text:e[s]})).text);t.text=r}else t.text=n(Object.assign({},i,{text:e})).text}])}(Cf),function(t){var e=function(){return void 0===this.internal.vFS&&(this.internal.vFS={}),!0};t.existsFileInVFS=function(t){return e.call(this),void 0!==this.internal.vFS[t]},t.addFileToVFS=function(t,r){return e.call(this),this.internal.vFS[t]=r,this},t.getFileFromVFS=function(t){return e.call(this),void 0!==this.internal.vFS[t]?this.internal.vFS[t]:null}}(Cf.API),function(t){t.__bidiEngine__=t.prototype.__bidiEngine__=function(t){var r,i,n,s,o,a,h,l=e,c=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],u=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],f={L:0,R:1,EN:2,AN:3,N:4,B:5,S:6},d={0:0,5:1,6:2,7:3,32:4,251:5,254:6,255:7},p=["(",")","(","<",">","<","[","]","[","{","}","{","«","»","«","‹","›","‹","⁅","⁆","⁅","⁽","⁾","⁽","₍","₎","₍","≤","≥","≤","〈","〉","〈","﹙","﹚","﹙","﹛","﹜","﹛","﹝","﹞","﹝","﹤","﹥","﹤"],g=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),m=!1,v=0;this.__bidiEngine__={};var y=function(t){var e=t.charCodeAt(),r=e>>8,i=d[r];return void 0!==i?l[256*i+(255&e)]:252===r||253===r?"AL":g.test(r)?"L":8===r?"R":"N"},b=function(t){for(var e,r=0;r<t.length;r++){if("L"===(e=y(t.charAt(r))))return!1;if("R"===e)return!0}return!1},w=function(t,e,o,a){var h,l,c,u,f=e[a];switch(f){case"L":case"R":case"LRE":case"RLE":case"LRO":case"RLO":case"PDF":m=!1;break;case"N":case"AN":break;case"EN":m&&(f="AN");break;case"AL":m=!0,f="R";break;case"WS":case"BN":f="N";break;case"CS":a<1||a+1>=e.length||"EN"!==(h=o[a-1])&&"AN"!==h||"EN"!==(l=e[a+1])&&"AN"!==l?f="N":m&&(l="AN"),f=l===h?l:"N";break;case"ES":f="EN"===(h=a>0?o[a-1]:"B")&&a+1<e.length&&"EN"===e[a+1]?"EN":"N";break;case"ET":if(a>0&&"EN"===o[a-1]){f="EN";break}if(m){f="N";break}for(c=a+1,u=e.length;c<u&&"ET"===e[c];)c++;f=c<u&&"EN"===e[c]?"EN":"N";break;case"NSM":if(n&&!s){for(u=e.length,c=a+1;c<u&&"NSM"===e[c];)c++;if(c<u){var d=t[a],p=d>=1425&&d<=2303||64286===d;if(h=e[c],p&&("R"===h||"AL"===h)){f="R";break}}}f=a<1||"B"===(h=e[a-1])?"N":o[a-1];break;case"B":m=!1,r=!0,f=v;break;case"S":i=!0,f="N"}return f},_=function(t,e,r){var i=t.split("");return r&&x(i,r,{hiLevel:v}),i.reverse(),e&&e.reverse(),i.join("")},x=function(t,e,n){var s,o,a,h,l,d=-1,p=t.length,g=0,b=[],_=v?u:c,x=[];for(m=!1,r=!1,i=!1,o=0;o<p;o++)x[o]=y(t[o]);for(a=0;a<p;a++){if(l=g,b[a]=w(t,x,b,a),s=240&(g=_[l][f[b[a]]]),g&=15,e[a]=h=_[g][5],s>0)if(16===s){for(o=d;o<a;o++)e[o]=1;d=-1}else d=-1;if(_[g][6])-1===d&&(d=a);else if(d>-1){for(o=d;o<a;o++)e[o]=h;d=-1}"B"===x[a]&&(e[a]=0),n.hiLevel|=h}i&&function(t,e,r){for(var i=0;i<r;i++)if("S"===t[i]){e[i]=v;for(var n=i-1;n>=0&&"WS"===t[n];n--)e[n]=v}}(x,e,p)},S=function(t,e,i,n,s){if(!(s.hiLevel<t)){if(1===t&&1===v&&!r)return e.reverse(),void(i&&i.reverse());for(var o,a,h,l,c=e.length,u=0;u<c;){if(n[u]>=t){for(h=u+1;h<c&&n[h]>=t;)h++;for(l=u,a=h-1;l<a;l++,a--)o=e[l],e[l]=e[a],e[a]=o,i&&(o=i[l],i[l]=i[a],i[a]=o);u=h}u++}}},C=function(t,e,r){var i=t.split(""),n={hiLevel:v};return r||(r=[]),x(i,r,n),function(t,e,r){if(0!==r.hiLevel&&h)for(var i,n=0;n<t.length;n++)1===e[n]&&(i=p.indexOf(t[n]))>=0&&(t[n]=p[i+1])}(i,r,n),S(2,i,e,r,n),S(1,i,e,r,n),i.join("")};return this.__bidiEngine__.doBidiReorder=function(t,e,r){if(function(t,e){if(e)for(var r=0;r<t.length;r++)e[r]=r;void 0===s&&(s=b(t)),void 0===a&&(a=b(t))}(t,e),n||!o||a)if(n&&o&&s^a)v=s?1:0,t=_(t,e,r);else if(!n&&o&&a)v=s?1:0,t=C(t,e,r),t=_(t,e);else if(!n||s||o||a){if(n&&!o&&s^a)t=_(t,e),s?(v=0,t=C(t,e,r)):(v=1,t=C(t,e,r),t=_(t,e));else if(n&&s&&!o&&a)v=1,t=C(t,e,r),t=_(t,e);else if(!n&&!o&&s^a){var i=h;s?(v=1,t=C(t,e,r),v=0,h=!1,t=C(t,e,r),h=i):(v=0,t=C(t,e,r),t=_(t,e),v=1,h=!1,t=C(t,e,r),h=i,t=_(t,e))}}else v=0,t=C(t,e,r);else v=s?1:0,t=C(t,e,r);return t},this.__bidiEngine__.setOptions=function(t){t&&(n=t.isInputVisual,o=t.isOutputVisual,s=t.isInputRtl,a=t.isOutputRtl,h=t.isSymmetricSwapping)},this.__bidiEngine__.setOptions(t),this.__bidiEngine__};var e=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","N","ET","ET","ET","ET","N","N","N","N","L","N","N","BN","N","N","ET","ET","EN","EN","N","L","N","N","N","EN","L","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","N","N","N","N","N","ET","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","NSM","R","NSM","NSM","R","NSM","NSM","R","NSM","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","N","N","N","N","N","R","R","R","R","R","N","N","N","N","N","N","N","N","N","N","N","AN","AN","AN","AN","AN","AN","N","N","AL","ET","ET","AL","CS","AL","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","N","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","NSM","NSM","N","NSM","NSM","NSM","NSM","AL","AL","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","R","N","N","N","N","R","N","N","N","N","N","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","BN","BN","BN","L","R","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","B","LRE","RLE","PDF","LRO","RLO","CS","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","BN","BN","BN","BN","BN","N","LRI","RLI","FSI","PDI","BN","BN","BN","BN","BN","BN","EN","L","N","N","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","L","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","N","N","N","N","N","R","NSM","R","R","R","R","R","R","R","R","R","R","ES","R","R","R","R","R","R","R","R","R","R","R","R","R","N","R","R","R","R","R","N","R","N","R","R","N","R","R","N","R","R","R","R","R","R","R","R","R","R","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","CS","N","N","CS","N","N","N","N","N","N","N","N","N","ET","N","N","ES","ES","N","N","N","N","N","ET","ET","N","N","N","N","N","AL","AL","AL","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","BN","N","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","N","N","N","ET","ET","N","N","N","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N"],r=new t.__bidiEngine__({isInputVisual:!0});t.API.events.push(["postProcessText",function(t){var e=t.text;t.x,t.y;var i=t.options||{};t.mutex,i.lang;var n=[];if(i.isInputVisual="boolean"!=typeof i.isInputVisual||i.isInputVisual,r.setOptions(i),"[object Array]"===Object.prototype.toString.call(e)){var s=0;for(n=[],s=0;s<e.length;s+=1)"[object Array]"===Object.prototype.toString.call(e[s])?n.push([r.doBidiReorder(e[s][0]),e[s][1],e[s][2]]):n.push([r.doBidiReorder(e[s])]);t.text=n}else t.text=r.doBidiReorder(e);r.setOptions({isInputVisual:!0})}])}(Cf),Cf.API.TTFFont=function(){function t(t){var e;if(this.rawData=t,e=this.contents=new Jd(t),this.contents.pos=4,"ttcf"===e.readString(4))throw new Error("TTCF not supported.");e.pos=0,this.parse(),this.subset=new mp(this),this.registerTTF()}return t.open=function(e){return new t(e)},t.prototype.parse=function(){return this.directory=new Zd(this.contents),this.head=new ep(this),this.name=new hp(this),this.cmap=new ip(this),this.toUnicode={},this.hhea=new np(this),this.maxp=new lp(this),this.hmtx=new cp(this),this.post=new op(this),this.os2=new sp(this),this.loca=new gp(this),this.glyf=new fp(this),this.ascender=this.os2.exists&&this.os2.ascender||this.hhea.ascender,this.decender=this.os2.exists&&this.os2.decender||this.hhea.decender,this.lineGap=this.os2.exists&&this.os2.lineGap||this.hhea.lineGap,this.bbox=[this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax]},t.prototype.registerTTF=function(){var t,e,r,i,n;if(this.scaleFactor=1e3/this.head.unitsPerEm,this.bbox=function(){var e,r,i,n;for(n=[],e=0,r=(i=this.bbox).length;e<r;e++)t=i[e],n.push(Math.round(t*this.scaleFactor));return n}.call(this),this.stemV=0,this.post.exists?(r=255&(i=this.post.italic_angle),32768&(e=i>>16)&&(e=-(1+(65535^e))),this.italicAngle=+(e+"."+r)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=1===(n=this.familyClass)||2===n||3===n||4===n||5===n||7===n,this.isScript=10===this.familyClass,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),0!==this.italicAngle&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw new Error("No unicode cmap for font")},t.prototype.characterToGlyph=function(t){var e;return(null!=(e=this.cmap.unicode)?e.codeMap[t]:void 0)||0},t.prototype.widthOfGlyph=function(t){var e;return e=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(t).advance*e},t.prototype.widthOfString=function(t,e,r){var i,n,s,o;for(s=0,n=0,o=(t=""+t).length;0<=o?n<o:n>o;n=0<=o?++n:--n)i=t.charCodeAt(n),s+=this.widthOfGlyph(this.characterToGlyph(i))+r*(1e3/e)||0;return s*(e/1e3)},t.prototype.lineHeight=function(t,e){var r;return null==e&&(e=!1),r=e?this.lineGap:0,(this.ascender+r-this.decender)/1e3*t},t}();var Kd,Jd=function(){function t(t){this.data=null!=t?t:[],this.pos=0,this.length=this.data.length}return t.prototype.readByte=function(){return this.data[this.pos++]},t.prototype.writeByte=function(t){return this.data[this.pos++]=t},t.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},t.prototype.writeUInt32=function(t){return this.writeByte(t>>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt32=function(){var t;return(t=this.readUInt32())>=2147483648?t-4294967296:t},t.prototype.writeInt32=function(t){return t<0&&(t+=4294967296),this.writeUInt32(t)},t.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},t.prototype.writeUInt16=function(t){return this.writeByte(t>>8&255),this.writeByte(255&t)},t.prototype.readInt16=function(){var t;return(t=this.readUInt16())>=32768?t-65536:t},t.prototype.writeInt16=function(t){return t<0&&(t+=65536),this.writeUInt16(t)},t.prototype.readString=function(t){var e,r;for(r=[],e=0;0<=t?e<t:e>t;e=0<=t?++e:--e)r[e]=String.fromCharCode(this.readByte());return r.join("")},t.prototype.writeString=function(t){var e,r,i;for(i=[],e=0,r=t.length;0<=r?e<r:e>r;e=0<=r?++e:--e)i.push(this.writeByte(t.charCodeAt(e)));return i},t.prototype.readShort=function(){return this.readInt16()},t.prototype.writeShort=function(t){return this.writeInt16(t)},t.prototype.readLongLong=function(){var t,e,r,i,n,s,o,a;return t=this.readByte(),e=this.readByte(),r=this.readByte(),i=this.readByte(),n=this.readByte(),s=this.readByte(),o=this.readByte(),a=this.readByte(),128&t?-1*(72057594037927940*(255^t)+281474976710656*(255^e)+1099511627776*(255^r)+4294967296*(255^i)+16777216*(255^n)+65536*(255^s)+256*(255^o)+(255^a)+1):72057594037927940*t+281474976710656*e+1099511627776*r+4294967296*i+16777216*n+65536*s+256*o+a},t.prototype.writeLongLong=function(t){var e,r;return e=Math.floor(t/4294967296),r=4294967295&t,this.writeByte(e>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e),this.writeByte(r>>24&255),this.writeByte(r>>16&255),this.writeByte(r>>8&255),this.writeByte(255&r)},t.prototype.readInt=function(){return this.readInt32()},t.prototype.writeInt=function(t){return this.writeInt32(t)},t.prototype.read=function(t){var e,r;for(e=[],r=0;0<=t?r<t:r>t;r=0<=t?++r:--r)e.push(this.readByte());return e},t.prototype.write=function(t){var e,r,i,n;for(n=[],r=0,i=t.length;r<i;r++)e=t[r],n.push(this.writeByte(e));return n},t}(),Zd=function(){var t;function e(t){var e,r,i;for(this.scalarType=t.readInt(),this.tableCount=t.readShort(),this.searchRange=t.readShort(),this.entrySelector=t.readShort(),this.rangeShift=t.readShort(),this.tables={},r=0,i=this.tableCount;0<=i?r<i:r>i;r=0<=i?++r:--r)e={tag:t.readString(4),checksum:t.readInt(),offset:t.readInt(),length:t.readInt()},this.tables[e.tag]=e}return e.prototype.encode=function(e){var r,i,n,s,o,a,h,l,c,u,f,d,p;for(p in f=Object.keys(e).length,a=Math.log(2),c=16*Math.floor(Math.log(f)/a),s=Math.floor(c/a),l=16*f-c,(i=new Jd).writeInt(this.scalarType),i.writeShort(f),i.writeShort(c),i.writeShort(s),i.writeShort(l),n=16*f,h=i.pos+n,o=null,d=[],e)for(u=e[p],i.writeString(p),i.writeInt(t(u)),i.writeInt(h),i.writeInt(u.length),d=d.concat(u),"head"===p&&(o=h),h+=u.length;h%4;)d.push(0),h++;return i.write(d),r=2981146554-t(i.data),i.pos=o+8,i.writeUInt32(r),i.data},t=function(t){var e,r,i,n;for(t=up.call(t);t.length%4;)t.push(0);for(i=new Jd(t),r=0,e=0,n=t.length;e<n;e=e+=4)r+=i.readUInt32();return 4294967295&r},e}(),Qd={}.hasOwnProperty,tp=function(t,e){for(var r in e)Qd.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t};Kd=function(){function t(t){var e;this.file=t,e=this.file.directory.tables[this.tag],this.exists=!!e,e&&(this.offset=e.offset,this.length=e.length,this.parse(this.file.contents))}return t.prototype.parse=function(){},t.prototype.encode=function(){},t.prototype.raw=function(){return this.exists?(this.file.contents.pos=this.offset,this.file.contents.read(this.length)):null},t}();var ep=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="head",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.revision=t.readInt(),this.checkSumAdjustment=t.readInt(),this.magicNumber=t.readInt(),this.flags=t.readShort(),this.unitsPerEm=t.readShort(),this.created=t.readLongLong(),this.modified=t.readLongLong(),this.xMin=t.readShort(),this.yMin=t.readShort(),this.xMax=t.readShort(),this.yMax=t.readShort(),this.macStyle=t.readShort(),this.lowestRecPPEM=t.readShort(),this.fontDirectionHint=t.readShort(),this.indexToLocFormat=t.readShort(),this.glyphDataFormat=t.readShort()},t.prototype.encode=function(t){var e;return(e=new Jd).writeInt(this.version),e.writeInt(this.revision),e.writeInt(this.checkSumAdjustment),e.writeInt(this.magicNumber),e.writeShort(this.flags),e.writeShort(this.unitsPerEm),e.writeLongLong(this.created),e.writeLongLong(this.modified),e.writeShort(this.xMin),e.writeShort(this.yMin),e.writeShort(this.xMax),e.writeShort(this.yMax),e.writeShort(this.macStyle),e.writeShort(this.lowestRecPPEM),e.writeShort(this.fontDirectionHint),e.writeShort(t),e.writeShort(this.glyphDataFormat),e.data},t}(),rp=function(){function t(t,e){var r,i,n,s,o,a,h,l,c,u,f,d,p,g,m,v,y;switch(this.platformID=t.readUInt16(),this.encodingID=t.readShort(),this.offset=e+t.readInt(),c=t.pos,t.pos=this.offset,this.format=t.readUInt16(),this.length=t.readUInt16(),this.language=t.readUInt16(),this.isUnicode=3===this.platformID&&1===this.encodingID&&4===this.format||0===this.platformID&&4===this.format,this.codeMap={},this.format){case 0:for(a=0;a<256;++a)this.codeMap[a]=t.readByte();break;case 4:for(f=t.readUInt16(),u=f/2,t.pos+=6,n=function(){var e,r;for(r=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)r.push(t.readUInt16());return r}(),t.pos+=2,p=function(){var e,r;for(r=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)r.push(t.readUInt16());return r}(),h=function(){var e,r;for(r=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)r.push(t.readUInt16());return r}(),l=function(){var e,r;for(r=[],a=e=0;0<=u?e<u:e>u;a=0<=u?++e:--e)r.push(t.readUInt16());return r}(),i=(this.length-t.pos+this.offset)/2,o=function(){var e,r;for(r=[],a=e=0;0<=i?e<i:e>i;a=0<=i?++e:--e)r.push(t.readUInt16());return r}(),a=m=0,y=n.length;m<y;a=++m)for(g=n[a],r=v=d=p[a];d<=g?v<=g:v>=g;r=d<=g?++v:--v)0===l[a]?s=r+h[a]:0!==(s=o[l[a]/2+(r-d)-(u-a)]||0)&&(s+=h[a]),this.codeMap[r]=65535&s}t.pos=c}return t.encode=function(t,e){var r,i,n,s,o,a,h,l,c,u,f,d,p,g,m,v,y,b,w,_,x,S,C,A,k,L,T,P,N,O,E,M,D,F,j,I,B,R,z,U,q,W,H,V,Y,X;switch(P=new Jd,s=Object.keys(t).sort(function(t,e){return t-e}),e){case"macroman":for(p=0,g=function(){var t=[];for(d=0;d<256;++d)t.push(0);return t}(),v={0:0},n={},N=0,D=s.length;N<D;N++)null==v[H=t[i=s[N]]]&&(v[H]=++p),n[i]={old:t[i],new:v[t[i]]},g[i]=v[t[i]];return P.writeUInt16(1),P.writeUInt16(0),P.writeUInt32(12),P.writeUInt16(0),P.writeUInt16(262),P.writeUInt16(0),P.write(g),{charMap:n,subtable:P.data,maxGlyphID:p+1};case"unicode":for(L=[],c=[],y=0,v={},r={},m=h=null,O=0,F=s.length;O<F;O++)null==v[w=t[i=s[O]]]&&(v[w]=++y),r[i]={old:w,new:v[w]},o=v[w]-i,null!=m&&o===h||(m&&c.push(m),L.push(i),h=o),m=i;for(m&&c.push(m),c.push(65535),L.push(65535),A=2*(C=L.length),S=2*Math.pow(Math.log(C)/Math.LN2,2),u=Math.log(S/2)/Math.LN2,x=2*C-S,a=[],_=[],f=[],d=E=0,j=L.length;E<j;d=++E){if(k=L[d],l=c[d],65535===k){a.push(0),_.push(0);break}if(k-(T=r[k].new)>=32768)for(a.push(0),_.push(2*(f.length+C-d)),i=M=k;k<=l?M<=l:M>=l;i=k<=l?++M:--M)f.push(r[i].new);else a.push(T-k),_.push(0)}for(P.writeUInt16(3),P.writeUInt16(1),P.writeUInt32(12),P.writeUInt16(4),P.writeUInt16(16+8*C+2*f.length),P.writeUInt16(0),P.writeUInt16(A),P.writeUInt16(S),P.writeUInt16(u),P.writeUInt16(x),q=0,I=c.length;q<I;q++)i=c[q],P.writeUInt16(i);for(P.writeUInt16(0),W=0,B=L.length;W<B;W++)i=L[W],P.writeUInt16(i);for(V=0,R=a.length;V<R;V++)o=a[V],P.writeUInt16(o);for(Y=0,z=_.length;Y<z;Y++)b=_[Y],P.writeUInt16(b);for(X=0,U=f.length;X<U;X++)p=f[X],P.writeUInt16(p);return{charMap:r,subtable:P.data,maxGlyphID:y+1}}},t}(),ip=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="cmap",t.prototype.parse=function(t){var e,r,i;for(t.pos=this.offset,this.version=t.readUInt16(),i=t.readUInt16(),this.tables=[],this.unicode=null,r=0;0<=i?r<i:r>i;r=0<=i?++r:--r)e=new rp(t,this.offset),this.tables.push(e),e.isUnicode&&null==this.unicode&&(this.unicode=e);return!0},t.encode=function(t,e){var r,i;return null==e&&(e="macroman"),r=rp.encode(t,e),(i=new Jd).writeUInt16(0),i.writeUInt16(1),r.table=i.data.concat(r.subtable),r},t}(),np=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="hhea",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.ascender=t.readShort(),this.decender=t.readShort(),this.lineGap=t.readShort(),this.advanceWidthMax=t.readShort(),this.minLeftSideBearing=t.readShort(),this.minRightSideBearing=t.readShort(),this.xMaxExtent=t.readShort(),this.caretSlopeRise=t.readShort(),this.caretSlopeRun=t.readShort(),this.caretOffset=t.readShort(),t.pos+=8,this.metricDataFormat=t.readShort(),this.numberOfMetrics=t.readUInt16()},t}(),sp=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="OS/2",t.prototype.parse=function(t){if(t.pos=this.offset,this.version=t.readUInt16(),this.averageCharWidth=t.readShort(),this.weightClass=t.readUInt16(),this.widthClass=t.readUInt16(),this.type=t.readShort(),this.ySubscriptXSize=t.readShort(),this.ySubscriptYSize=t.readShort(),this.ySubscriptXOffset=t.readShort(),this.ySubscriptYOffset=t.readShort(),this.ySuperscriptXSize=t.readShort(),this.ySuperscriptYSize=t.readShort(),this.ySuperscriptXOffset=t.readShort(),this.ySuperscriptYOffset=t.readShort(),this.yStrikeoutSize=t.readShort(),this.yStrikeoutPosition=t.readShort(),this.familyClass=t.readShort(),this.panose=function(){var e,r;for(r=[],e=0;e<10;++e)r.push(t.readByte());return r}(),this.charRange=function(){var e,r;for(r=[],e=0;e<4;++e)r.push(t.readInt());return r}(),this.vendorID=t.readString(4),this.selection=t.readShort(),this.firstCharIndex=t.readShort(),this.lastCharIndex=t.readShort(),this.version>0&&(this.ascent=t.readShort(),this.descent=t.readShort(),this.lineGap=t.readShort(),this.winAscent=t.readShort(),this.winDescent=t.readShort(),this.codePageRange=function(){var e,r;for(r=[],e=0;e<2;e=++e)r.push(t.readInt());return r}(),this.version>1))return this.xHeight=t.readShort(),this.capHeight=t.readShort(),this.defaultChar=t.readShort(),this.breakChar=t.readShort(),this.maxContext=t.readShort()},t}(),op=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="post",t.prototype.parse=function(t){var e,r,i;switch(t.pos=this.offset,this.format=t.readInt(),this.italicAngle=t.readInt(),this.underlinePosition=t.readShort(),this.underlineThickness=t.readShort(),this.isFixedPitch=t.readInt(),this.minMemType42=t.readInt(),this.maxMemType42=t.readInt(),this.minMemType1=t.readInt(),this.maxMemType1=t.readInt(),this.format){case 65536:case 196608:break;case 131072:var n;for(r=t.readUInt16(),this.glyphNameIndex=[],n=0;0<=r?n<r:n>r;n=0<=r?++n:--n)this.glyphNameIndex.push(t.readUInt16());for(this.names=[],i=[];t.pos<this.offset+this.length;)e=t.readByte(),i.push(this.names.push(t.readString(e)));return i;case 151552:return r=t.readUInt16(),this.offsets=t.read(r);case 262144:return this.map=function(){var e,r,i;for(i=[],n=e=0,r=this.file.maxp.numGlyphs;0<=r?e<r:e>r;n=0<=r?++e:--e)i.push(t.readUInt32());return i}.call(this)}},t}(),ap=function(t,e){this.raw=t,this.length=t.length,this.platformID=e.platformID,this.encodingID=e.encodingID,this.languageID=e.languageID},hp=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="name",t.prototype.parse=function(t){var e,r,i,n,s,o,a,h,l,c,u;for(t.pos=this.offset,t.readShort(),e=t.readShort(),o=t.readShort(),r=[],n=0;0<=e?n<e:n>e;n=0<=e?++n:--n)r.push({platformID:t.readShort(),encodingID:t.readShort(),languageID:t.readShort(),nameID:t.readShort(),length:t.readShort(),offset:this.offset+o+t.readShort()});for(a={},n=l=0,c=r.length;l<c;n=++l)i=r[n],t.pos=i.offset,h=t.readString(i.length),s=new ap(h,i),null==a[u=i.nameID]&&(a[u]=[]),a[i.nameID].push(s);this.strings=a,this.copyright=a[0],this.fontFamily=a[1],this.fontSubfamily=a[2],this.uniqueSubfamily=a[3],this.fontName=a[4],this.version=a[5];try{this.postscriptName=a[6][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}catch(t){this.postscriptName=a[4][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}return this.trademark=a[7],this.manufacturer=a[8],this.designer=a[9],this.description=a[10],this.vendorUrl=a[11],this.designerUrl=a[12],this.license=a[13],this.licenseUrl=a[14],this.preferredFamily=a[15],this.preferredSubfamily=a[17],this.compatibleFull=a[18],this.sampleText=a[19]},t}(),lp=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="maxp",t.prototype.parse=function(t){return t.pos=this.offset,this.version=t.readInt(),this.numGlyphs=t.readUInt16(),this.maxPoints=t.readUInt16(),this.maxContours=t.readUInt16(),this.maxCompositePoints=t.readUInt16(),this.maxComponentContours=t.readUInt16(),this.maxZones=t.readUInt16(),this.maxTwilightPoints=t.readUInt16(),this.maxStorage=t.readUInt16(),this.maxFunctionDefs=t.readUInt16(),this.maxInstructionDefs=t.readUInt16(),this.maxStackElements=t.readUInt16(),this.maxSizeOfInstructions=t.readUInt16(),this.maxComponentElements=t.readUInt16(),this.maxComponentDepth=t.readUInt16()},t}(),cp=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="hmtx",t.prototype.parse=function(t){var e,r,i,n,s,o,a;for(t.pos=this.offset,this.metrics=[],e=0,o=this.file.hhea.numberOfMetrics;0<=o?e<o:e>o;e=0<=o?++e:--e)this.metrics.push({advance:t.readUInt16(),lsb:t.readInt16()});for(i=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var r,n;for(n=[],e=r=0;0<=i?r<i:r>i;e=0<=i?++r:--r)n.push(t.readInt16());return n}(),this.widths=function(){var t,e,r,i;for(i=[],t=0,e=(r=this.metrics).length;t<e;t++)n=r[t],i.push(n.advance);return i}.call(this),r=this.widths[this.widths.length-1],a=[],e=s=0;0<=i?s<i:s>i;e=0<=i?++s:--s)a.push(this.widths.push(r));return a},t.prototype.forGlyph=function(t){return t in this.metrics?this.metrics[t]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[t-this.metrics.length]}},t}(),up=[].slice,fp=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="glyf",t.prototype.parse=function(){return this.cache={}},t.prototype.glyphFor=function(t){var e,r,i,n,s,o,a,h,l,c;return t in this.cache?this.cache[t]:(n=this.file.loca,e=this.file.contents,r=n.indexOf(t),0===(i=n.lengthOf(t))?this.cache[t]=null:(e.pos=this.offset+r,s=(o=new Jd(e.read(i))).readShort(),h=o.readShort(),c=o.readShort(),a=o.readShort(),l=o.readShort(),this.cache[t]=-1===s?new pp(o,h,c,a,l):new dp(o,s,h,c,a,l),this.cache[t]))},t.prototype.encode=function(t,e,r){var i,n,s,o,a;for(s=[],n=[],o=0,a=e.length;o<a;o++)i=t[e[o]],n.push(s.length),i&&(s=s.concat(i.encode(r)));return n.push(s.length),{table:s,offsets:n}},t}(),dp=function(){function t(t,e,r,i,n,s){this.raw=t,this.numberOfContours=e,this.xMin=r,this.yMin=i,this.xMax=n,this.yMax=s,this.compound=!1}return t.prototype.encode=function(){return this.raw.data},t}(),pp=function(){function t(t,e,r,i,n){var s,o;for(this.raw=t,this.xMin=e,this.yMin=r,this.xMax=i,this.yMax=n,this.compound=!0,this.glyphIDs=[],this.glyphOffsets=[],s=this.raw;o=s.readShort(),this.glyphOffsets.push(s.pos),this.glyphIDs.push(s.readUInt16()),32&o;)s.pos+=1&o?4:2,128&o?s.pos+=8:64&o?s.pos+=4:8&o&&(s.pos+=2)}return t.prototype.encode=function(){var t,e,r;for(e=new Jd(up.call(this.raw.data)),t=0,r=this.glyphIDs.length;t<r;++t)e.pos=this.glyphOffsets[t];return e.data},t}(),gp=function(){function t(){return t.__super__.constructor.apply(this,arguments)}return tp(t,Kd),t.prototype.tag="loca",t.prototype.parse=function(t){var e,r;return t.pos=this.offset,e=this.file.head.indexToLocFormat,this.offsets=0===e?function(){var e,i;for(i=[],r=0,e=this.length;r<e;r+=2)i.push(2*t.readUInt16());return i}.call(this):function(){var e,i;for(i=[],r=0,e=this.length;r<e;r+=4)i.push(t.readUInt32());return i}.call(this)},t.prototype.indexOf=function(t){return this.offsets[t]},t.prototype.lengthOf=function(t){return this.offsets[t+1]-this.offsets[t]},t.prototype.encode=function(t,e){for(var r=new Uint32Array(this.offsets.length),i=0,n=0,s=0;s<r.length;++s)if(r[s]=i,n<e.length&&e[n]==s){++n,r[s]=i;var o=this.offsets[s],a=this.offsets[s+1]-o;a>0&&(i+=a)}for(var h=new Array(4*r.length),l=0;l<r.length;++l)h[4*l+3]=255&r[l],h[4*l+2]=(65280&r[l])>>8,h[4*l+1]=(16711680&r[l])>>16,h[4*l]=(4278190080&r[l])>>24;return h},t}(),mp=function(){function t(t){this.font=t,this.subset={},this.unicodes={},this.next=33}return t.prototype.generateCmap=function(){var t,e,r,i,n;for(e in i=this.font.cmap.tables[0].codeMap,t={},n=this.subset)r=n[e],t[e]=i[r];return t},t.prototype.glyphsFor=function(t){var e,r,i,n,s,o,a;for(i={},s=0,o=t.length;s<o;s++)i[n=t[s]]=this.font.glyf.glyphFor(n);for(n in e=[],i)(null!=(r=i[n])?r.compound:void 0)&&e.push.apply(e,r.glyphIDs);if(e.length>0)for(n in a=this.glyphsFor(e))r=a[n],i[n]=r;return i},t.prototype.encode=function(t,e){var r,i,n,s,o,a,h,l,c,u,f,d,p,g,m;for(i in r=ip.encode(this.generateCmap(),"unicode"),s=this.glyphsFor(t),f={0:0},m=r.charMap)f[(a=m[i]).old]=a.new;for(d in u=r.maxGlyphID,s)d in f||(f[d]=u++);return l=function(t){var e,r;for(e in r={},t)r[t[e]]=e;return r}(f),c=Object.keys(l).sort(function(t,e){return t-e}),p=function(){var t,e,r;for(r=[],t=0,e=c.length;t<e;t++)o=c[t],r.push(l[o]);return r}(),n=this.font.glyf.encode(s,p,f),h=this.font.loca.encode(n.offsets,p),g={cmap:this.font.cmap.raw(),glyf:n.table,loca:h,hmtx:this.font.hmtx.raw(),hhea:this.font.hhea.raw(),maxp:this.font.maxp.raw(),post:this.font.post.raw(),name:this.font.name.raw(),head:this.font.head.encode(e)},this.font.os2.exists&&(g["OS/2"]=this.font.os2.raw()),this.font.directory.encode(g)},t}();Cf.API.PDFObject=function(){var t;function e(){}return t=function(t,e){return(Array(e+1).join("0")+t).slice(-e)},e.convert=function(r){var i,n,s,o;if(Array.isArray(r))return"["+function(){var t,n,s;for(s=[],t=0,n=r.length;t<n;t++)i=r[t],s.push(e.convert(i));return s}().join(" ")+"]";if("string"==typeof r)return"/"+r;if(null!=r?r.isString:void 0)return"("+r+")";if(r instanceof Date)return"(D:"+t(r.getUTCFullYear(),4)+t(r.getUTCMonth(),2)+t(r.getUTCDate(),2)+t(r.getUTCHours(),2)+t(r.getUTCMinutes(),2)+t(r.getUTCSeconds(),2)+"Z)";if("[object Object]"==={}.toString.call(r)){for(n in s=["<<"],r)o=r[n],s.push("/"+n+" "+e.convert(o));return s.push(">>"),s.join("\n")}return""+r},e}();const vp="Arial",yp=["Arial","Georgia","Helvetica","Verdana"];function bp(t){if(!t)return t;if(Array.isArray(t))return t.map(t=>bp(t));if("object"==typeof t&&null!==t){const e={...t};return e.text&&"string"==typeof e.text&&(e.text=e.text.replace(/\{n\}/g,"\n").replace(/\/n/g,"\n")),e.layers&&Array.isArray(e.layers)&&(e.layers=e.layers.map(t=>bp(t))),e}return t}async function _p(t){if(yp.includes(t))return t;const e=document.getElementById("lp-certificates-fonts-gg");if(e&&e.textContent.includes(t)){try{await document.fonts.load(`16px "${t}"`),await document.fonts.ready}catch(e){return console.warn(`Font "${t}" failed to load.`),vp}return t}return console.warn(`Font "${t}" is not available. Please add it in LearnPress > Settings > Certificates > Google Fonts.`),vp}const xp=["text-edit","text-static"];function Sp(t){return xp.includes(t)}function Cp(t){return t?.startsWith("svg-")||!1}function Ap(t,e,r={}){switch(t){case"text-edit":case"text-static":{const i="text-static"===t,{fontFamily:n,fill:s,fontSize:o,left:a,top:h,originX:l,originY:c,type:u}=r;return new("Textbox"===u?uo:co)(e,{left:a,top:h,fontFamily:n,fill:s,fontSize:o,originX:l,originY:c,editable:!i})}case"image":case"qr_code":return xo.fromURL(e,{crossOrigin:"anonymous"});case"svg-circle":{const{left:t=0,top:r=0,originX:i="center",originY:n="center",fill:s="transparent",stroke:o="",strokeWidth:a=0,radius:h}=e;return new js({left:t,top:r,originX:i,originY:n,fill:s,stroke:o,strokeWidth:a,radius:h||50})}case"svg-rect":{const{left:t=0,top:r=0,originX:i="center",originY:n="center",fill:s="transparent",stroke:o="",strokeWidth:a=0,width:h,height:l,rx:c,ry:u}=e;return new un({left:t,top:r,originX:i,originY:n,fill:s,stroke:o,strokeWidth:a,width:h||100,height:l||100,rx:c||0,ry:u||0})}case"svg-triangle":{const{left:t=0,top:r=0,originX:i="center",originY:n="center",fill:s="transparent",stroke:o="",strokeWidth:a=0,width:h,height:l}=e;return new Rs({left:t,top:r,originX:i,originY:n,fill:s,stroke:o,strokeWidth:a,width:h||100,height:l||100})}case"svg-ellipse":{const{left:t=0,top:r=0,originX:i="center",originY:n="center",fill:s="transparent",stroke:o="",strokeWidth:a=0,rx:h,ry:l}=e;return new Us({left:t,top:r,originX:i,originY:n,fill:s,stroke:o,strokeWidth:a,rx:h||70,ry:l||45})}case"svg-line":{delete e.type;const{left:t=0,top:r=0,originX:i="center",originY:n="center",stroke:s="#333333",strokeWidth:o=3,x1:a,y1:h,x2:l,y2:c}=e;return new Bs([a||0,h||0,l||150,c||0],{left:t,top:r,originX:i,originY:n,stroke:s,strokeWidth:o})}default:return null}}var kp=o(7583);function Lp(t){return"qr_code"===t.get("type_layer")}function Tp(t,e,r){const i=(t.width||100)*(t.scaleX||1),n=(t.height||100)*(t.scaleY||1),s=Math.max(i,n);r.set(e,{left:t.get("left"),top:t.get("top"),originX:t.get("originX")||"center",originY:t.get("originY")||"center",size:s,qr_url:t.get("qr_url")||null}),e.set("visible",!1)}async function Pp(t,e){try{return await kp.toDataURL(t,{width:e,margin:0,color:{dark:"#000000",light:"#00000000"}})}catch(t){return console.error("Error generating QR code:",t),null}}const Np="Arial";async function Op(t,e={}){const r=!!t.builder_data;let i=300,n=150,s=null,o=null;if(r){i=t.canvas_width||842,n=t.canvas_height||595;const e=t.background||"";/^(https?:\/\/|\/|data:image)/i.test(e)?s=e:e&&(o=e)}else t.template&&(s=t.template);let a=null;if(s)try{a=await xo.fromURL(s,{crossOrigin:"anonymous"}),r||(i=a.width||300,n=a.height||150)}catch(t){console.error("renderCertificate: Error loading background:",s,t)}const h=e.canvasEl||document.createElement("canvas"),l=new ys(h,{selection:!1,width:i,height:n,backgroundColor:o||void 0,enableRetinaScaling:!0});if(a){const t=i/a.width,e=n/a.height,r=Math.max(t,e);a.set({scaleX:r,scaleY:r,originX:"center",originY:"center",left:i/2,top:n/2,selectable:!1,evented:!1}),l.add(a),l.sendObjectToBack(a)}r?await async function(t,e){const r=bp(e).layers||[];if(Array.isArray(r)&&0!==r.length)for(let e=0;e<r.length;e++){const i=r[e];try{const e=i.type_layer;if(!i||!e)continue;const{id:r,name:n,type_layer:s,type:o,text:a,src:h,canvas:l,group:c,stateProperties:u,cacheProperties:f,...d}=i;let p=null;const g=Sp(e);if(g){const t=(a||"").replace(/\{n\}/g,"\n").replace(/\/n/g,"\n").replace(/&quot;/g,'"'),r=d.fontFamily||Np,i={...d,fontFamily:Np,type:o};p=await Ap(e,t,i),p&&(p.set("text",t),p.set("fontFamily",await _p(r)),"function"==typeof p.initDimensions&&p.initDimensions(),p.set("dirty",!0))}else{if("qr_code"===e){const e=i.qr_url||h;if(!e)continue;const r=(d.width||100)*(d.scaleX||1),n=(d.height||100)*(d.scaleY||1),s=Math.max(r,n),o=3*s,a=await Pp(e,o);if(!a)continue;const l=await xo.fromURL(a);l&&(l.set({left:d.left||0,top:d.top||0,originX:d.originX||"center",originY:d.originY||"center",scaleX:s/l.width,scaleY:s/l.height,selectable:!1,evented:!1,type_layer:"qr_code",qr_url:e}),l.setCoords(),t.add(l));continue}if("image"===e){if(!h)continue;p=await Ap(e,h,d)}else Cp(e)&&(p=await Ap(e,i))}if(p){if(!Cp(e)){const{clipPath:t,...e}=d;p.set(e)}g&&d.originX&&p.set("originX",d.originX),p.set({selectable:!1,evented:!1}),p.setCoords(),t.add(p),g&&Mp(p)}}catch(t){console.error(`renderCertificate: Error loading layer ${e}:`,t)}}}(l,t):await async function(t,e){for(const r in e){if(!e.hasOwnProperty(r))continue;const i=e[r];if(i)try{const e=Ep(i.text)||"",r=/^(https?|s?ftp):\/\//i.test(e);if(("verified-link"===i.fieldType||"qr_code"===i.type_layer||"qr_code"===i.type||"image"===i.type)&&r){const r=await xo.fromURL(e,{crossOrigin:"anonymous"});r.set({left:parseFloat(i.left)||0,top:parseFloat(i.top)||0,originX:i.originX||"center",originY:i.originY||"center",selectable:!1,evented:!1}),i.scaleX&&r.set("scaleX",parseFloat(i.scaleX)),i.scaleY&&r.set("scaleY",parseFloat(i.scaleY)),t.add(r);continue}const n={fontSize:parseFloat(i.fontSize)||24,left:parseFloat(i.left)||0,top:parseFloat(i.top)||0,lineHeight:parseFloat(i.lineHeight)||1,originX:i.originX||"center",originY:i.originY||"center",fontFamily:i.fontFamily||"Helvetica",fill:i.fill||i.color||"#000000",textAlign:i.textAlign||"center",fontWeight:i.fontWeight||"normal",fontStyle:i.fontStyle||"normal",angle:parseFloat(i.angle)||0,selectable:!1,evented:!1};i.scaleX&&(n.scaleX=Math.abs(parseFloat(i.scaleX)),n.flipX=parseFloat(i.scaleX)<0),i.scaleY&&(n.scaleY=Math.abs(parseFloat(i.scaleY)),n.flipY=parseFloat(i.scaleY)<0);const s=i.type||i.type_layer||"text-static",o=await Ap(s,e,n);o&&(o.set({selectable:!1,evented:!1}),t.add(o))}catch(t){console.error("renderCertificate: Error loading old layer:",r,t)}}}(l,t.layers||[]),l.renderAll();const c=l.toDataURL({format:"png",quality:1});return{canvas:l,dataURL:c}}function Ep(t){if(!t)return"";const e=document.createElement("div");return e.innerHTML=t,0===e.childNodes.length?"":e.childNodes[0].nodeValue}function Mp(t){if(!t)return;const e=t.textAlign||"left",r=t.originX||"center",i=function(t){switch(t){case"left":return"left";case"right":return"right";default:return"center"}}(e);if(r===i)return;const n=t.getBoundingRect(),s=n.left,o=n.left+n.width,a=n.left+n.width/2;let h=t.left;switch(e){case"left":t.set("originX","left"),h=s;break;case"right":t.set("originX","right"),h=o;break;case"center":case"justify":t.set("originX","center"),h=a}t.set("left",h),t.setCoords()}function Dp(t){return"i-text"===t.type||"textbox"===t.type}function Fp(t,e){if(!t||!e)return t;let r=t;return Object.keys(e).forEach(t=>{const i=e[t];if(i){const e=new RegExp(`\\[${t}\\]`,"g");r=r.replace(e,i)}}),r}async function jp(t,e={}){const r=document.createElement("canvas"),i=new ys(r,{width:t.getWidth(),height:t.getHeight(),backgroundColor:t.backgroundColor||"#ffffff",selection:!1});if(t.backgroundImage)try{const e=t.backgroundImage.getSrc();if(e){const r=await xo.fromURL(e,{crossOrigin:"anonymous"});r&&(r.set({scaleX:t.backgroundImage.scaleX,scaleY:t.backgroundImage.scaleY,originX:t.backgroundImage.originX,originY:t.backgroundImage.originY,left:t.backgroundImage.left,top:t.backgroundImage.top,opacity:t.backgroundImage.opacity}),i.backgroundImage=r)}}catch(t){console.error("Error copying background:",t)}const n=new Map,s=t.getObjects();for(const t of s)try{const r=await t.clone();if(r.set({selectable:!1,evented:!1}),Lp(t))Tp(t,r,n),i.add(r);else if(Dp(r)){if(Mp(r),Object.keys(e).length>0){const t=Fp(r.get("text")||"",e);r.set("text",t)}i.add(r)}else i.add(r)}catch(t){console.error("Error cloning object:",t)}if(n.size>0){const t=e.QR_CODE||null;await async function(t,e,r){for(const[i,n]of t){const t=e||n.qr_url||"https://thimpress.com/";i._qrImage&&(r.remove(i._qrImage),i._qrImage=null);const s=n.size||100,o=3*s,a=await Pp(t,o);if(a){const t=await xo.fromURL(a);t&&(t.set({left:n.left,top:n.top,originX:n.originX,originY:n.originY,scaleX:s/t.width,scaleY:s/t.height,selectable:!1,evented:!1}),i.set("visible",!1),i._qrImage=t,r.add(t))}}}(n,t,i)}return i.renderAll(),i}!function(t){let e,r,i,n,s,o,a,h,l,c;window.LP_Certificate=function(e,r){const i=t(e);let n,s,o,l=null,c="certificate";!async function(){s=t(".certificate-actions");try{const e=i.find("canvas").get(0);if(!e)return void console.error("LP_Certificate: canvas element not found");const c=await Op(r,{canvasEl:e});if(l=c.canvas,i.addClass("canvas-preview-ready"),l){const e=l.toDataURL({format:"png",quality:1}),r=t('<img class="certificate-result" />').insertBefore("#"+i[0].id);n=t(".certificate-result"),r.attr("src",e),i.hide()}h.length&&function(){if(!n||!n.length)return;const e={action:"lpCertCreateImage",data64:n.attr("src"),name_image:r.key_cer};t.ajax({url:localize_lp_cer_js.url_ajax,data:e,method:"post",dataType:"json",beforeSend(){s.append('<li class="fa fa-spinner">Loading share social...</li>')},success(e){1===e.code&&(t.each(a,function(){const r=t(this).find("a"),i=r.attr("href")+e.url_cert;r.attr("href",i)}),a.show())},complete(){s.find(".fa-spinner").remove()},error(t){console.log(t)}})}(),s.length&&(o=s.find(".download")),i.find(".lp-data-config-cer").addClass("loaded"),t(document).triggerHandler("learn-press/certificates/loaded")}catch(t){console.error("LP_Certificate init error:",t)}t(document).on("click",'[data-cert="'+i.attr("id")+'"]',function(t){t.preventDefault(),l&&o&&o.length&&(void 0!==r.name&&(c=r.name),"pdf"===o.data("type-download")?async function(t,e={}){if(!t)throw new Error("Source canvas is required");const{replacements:r={},filename:i=`certificate-${Date.now()}.pdf`,multiplier:n=2}=e,s=await async function(t,e={}){if(!t)throw new Error("Source canvas is required");const{replacements:r={},format:i="png",quality:n=1,multiplier:s=2}=e,o=await jp(t,r),a=o.toDataURL({format:i,quality:n,multiplier:s});return o.dispose(),a}(t,{replacements:r,format:"png",quality:1,multiplier:n}),o=25.4/96,a=t.getWidth()*o,h=t.getHeight()*o,l=new Cf({orientation:a>=h?"landscape":"portrait",unit:"mm",format:[a,h]});l.addImage(s,"PNG",0,0,a,h),l.save(i)}(l,{filename:c+".pdf",multiplier:2}):async function(t,e={}){if(!t)throw new Error("Source canvas is required");const{replacements:r={},filename:i=`certificate-${Date.now()}.png`,format:n="png",quality:s=1,multiplier:o=2}=e,a=await jp(t,r),h=a.toDataURL({format:n,quality:s,multiplier:o}),l=document.createElement("a");l.download=i,l.href=h,document.body.appendChild(l),l.click(),document.body.removeChild(l),a.dispose()}(l,{filename:c+".png",format:"png",quality:1,multiplier:2}))})}()},t(document).ready(function(){if(e=t("html, body"),r=t(".lp-data-config-cer"),i=t("input[name=f_auto_show_cer_popup_first]"),n=t('form[name="certificate-form-button"]'),s=t("#certificate-popup"),o=t(".single-certificate-content"),a=t(".share-social-cert"),h=t("input[name=need_upload_cert_img_to_server]"),l=t("form[name=form-lp-cert-add-to-cart-woo]"),c=t("form[name=form-lp-cert-purchase]"),a.hide(),i.length||n.css("display","inline-block"),r.length)try{t.each(r,function(){const e=JSON.parse(t(this).val())||{};t(this).val("");const r="#"+t(this).closest("div").attr("id");LP_Certificate(r,e)})}catch(t){console.log(t)}!function(){if(s.length){let r=!1;function o(){s.fadeOut(function(){e.css("overflow","auto")})}function a(){r&&(e.css("overflow","hidden"),s.fadeIn())}n.on("submit",function(t){t.preventDefault(),a()}),t(document).on("learn-press/certificates/loaded",function(){r=!0,s.addClass("ready").hide(),e.on("keyup",function(t){27===t.keyCode&&o()}).on("click",".close-popup",function(t){o(),t.preventDefault()}),i.length&&a()})}}(),document.addEventListener("submit",function(e){const r=e.target;"form-lp-cert-purchase"===r.getAttribute("name")?(e.preventDefault(),function(t){let e="",r="";const i=new FormData(t),n=Object.fromEntries(i.entries()),s=t.querySelector(".btn-purchase-certificate");s.classList.add("loading");const o=document.createElement("div");o.classList.add("learn-press-message"),wp.apiFetch({path:"/lp/v1/certificate/purchase",method:"POST",data:n}).then(i=>{const{data:n}=i;r=i.status,e=i.message,o.classList.add(r),o.innerHTML=e,t.insertAdjacentElement("beforeend",o),void 0!==r&&"success"===r&&n.redirect&&setTimeout(function(){window.location.href=n.redirect},800)}).catch(e=>{o.classList.add("error"),o.innerHTML=e.message,t.insertAdjacentElement("beforeend",o)}).then(()=>{s.remove()})}(r)):"form-lp-cert-add-to-cart-woo"===r.getAttribute("name")&&(e.preventDefault(),function(e){const r=lpData.urlParams.lang?`?lang=${lpData.urlParams.lang}`:"",i=e.querySelector(".btn-add-cert-to-cart-woo"),n=new FormData(e),s=Object.fromEntries(n.entries());s.action="lp_cert_add_to_cart_woo",t.ajax({url:localize_lp_cer_js.url_ajax+r,data:s,method:"post",beforeSend(){i.classList.add("loading")},success(t){1===t.code?void 0!==t.redirect_to?window.location.replace(t.redirect_to):(e.closest(".wrapper-lp-cert-add-to-cart-woo").insertAdjacentHTML("beforeend",t.button_view_cart),e.remove()):alert(t.message)},error(t){console.log(t)},complete(){i.classList.remove("loading")}})}(r))})})}(jQuery)})()})();