-
Notifications
You must be signed in to change notification settings - Fork 29
/
app.js
1 lines (1 loc) · 76.9 KB
/
app.js
1
!function(t){var e={};function s(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,s),n.l=!0,n.exports}s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)s.d(i,n,function(e){return t[e]}.bind(null,n));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=4)}([,function(t,e){void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(t,e,s){var i=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return i?new Promise(function(e,s){i.call(navigator,t,e,s)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))})},,,function(t,e,s){"use strict";s.r(e);var i=[.15798166917391213,.13588302790761367,.08257064114644565,.20185688150773543,.4686456855672267,.23292964864886617,1,.7614670577640408,.7901302704021573,.7945145744734023,.7278899156307944,.635791806556467,.5514504431311956,.4934175084572007,.28053012595650534,.07119838102017202,.06936420661638935,.11944556293991333,.25566229718786593,.7295526125485244,.6699093068541809,.5777445191572659,.23025588146646028,.08373009176579835,.027677115439917785,.023309379953109628,.06926194963076784,.2061303907602091,.6956630436277177,.639825915621342,.3614494067424368,.05637579364422638,.15979984704746575,.1368189258468383,.09895494509062856,.09116498393273482,.07949501490219282,.042663661540257004,.2950476955589612,.506802797445949,.44117017714071594,.32873624816304536,.3020810994424428,.08367757184808672,.005325558107331966,.002598171991255612,.10922012802781508,.17091167401050422,.21818604693053023,.8453113615190673,.9890417396777571,.76407011913261,.6593120204592107,.5900988293974495,.6733164372820017,.6865432761793061,.5838938991128904,.45213414079041037,.30121456476694664,.31129441073534503,.32702338526068314,.18854546008327958,.031858039157651966,0];function n(t){return navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(t):new Promise(function(t,e){e("no getUserMedia")})}var r=function(){function t(){this._audioChunks=[]}return t.prototype.start=function(){var t=this;return n?n({audio:!0,video:!1}).then(function(e){return t._stream=e,t._mediaRecorder=new MediaRecorder(e),t._mediaRecorder.start(),t._audioChunks=[],new Promise(function(e,s){t._mediaRecorder.addEventListener("dataavailable",function(s){t._audioChunks.push(s.data),e()})})}):new Promise(function(t,e){return e({code:-1,message:"getUserMedia not supported."})})},t.prototype.stop=function(){var t=this;return new Promise(function(e,s){t._mediaRecorder?(t._mediaRecorder.addEventListener("stop",function(){t._stream.getTracks().forEach(function(t){return t.stop()}),e()}),t._mediaRecorder.stop()):s({code:-2,message:"Start audio first."})})},t.prototype.getData=function(){return new Blob(this._audioChunks)},t}(),o=[191,102],a="M145.617188,25.171875 L153.820312,25.171875 L153.820312,26.9296875 L182.921875,26.9296875 L182.921875,25.171875 L191.125,25.171875 L191.125,57.59375 C191.125,79.0782324 191.059896,90.2760371 190.929688,91.1875 C190.799479,91.9687539 190.506513,92.8150996 190.050781,93.7265625 C189.59505,94.6380254 189.009118,95.4192676 188.292969,96.0703125 C187.576819,96.7213574 186.632818,97.3072891 185.460938,97.828125 C184.549475,98.3489609 183.898439,98.6744785 183.507812,98.8046875 L183.117188,97.4375 C183.117188,96.5260371 183.052084,92.2943086 182.921875,84.7421875 L182.921875,70.6796875 L153.820312,70.6796875 L153.625,74.5859375 C153.625,77.3203262 153.429689,79.4036387 153.039062,80.8359375 C152.778645,82.1380273 152.453127,83.3749941 152.0625,84.546875 C151.671873,85.7187559 151.2487,86.7929639 150.792969,87.7695312 C150.337237,88.7460986 149.848961,89.6575479 149.328125,90.5039062 C148.807289,91.3502646 148.09115,92.4244727 147.179688,93.7265625 C146.268225,94.8984434 145.226568,96.0052031 144.054688,97.046875 C143.143225,97.9583379 142.166672,98.7395801 141.125,99.390625 C140.343746,100.04167 139.106779,100.822912 137.414062,101.734375 C135.851555,102.515629 135.037761,102.90625 134.972656,102.90625 C134.907552,102.90625 134.875,102.385422 134.875,101.34375 L134.875,99.5859375 L135.65625,99.1953125 C136.177086,98.9348945 137.218742,98.0234453 138.78125,96.4609375 C140.343758,94.8984297 141.450518,93.5312559 142.101562,92.359375 C142.882816,91.0572852 143.468748,89.8854219 143.859375,88.84375 C144.380211,87.5416602 144.770832,86.3697969 145.03125,85.328125 C145.291668,84.2864531 145.421875,74.0000977 145.421875,54.46875 L145.617188,25.171875 Z M182.921875,31.421875 L153.820312,31.421875 L153.820312,46.4609375 L182.921875,46.4609375 L182.921875,31.421875 Z M182.921875,50.7578125 L182.921875,66.1875 L153.820312,66.1875 L153.820312,50.7578125 L182.921875,50.7578125 Z M34.2890625,0.875 L42.8828125,0.875 L42.8828125,11.8125 L42.1015625,12.3984375 C41.7109355,12.7890645 41.0599004,13.0820303 40.1484375,13.2773438 C39.2369746,13.4726572 38.0651113,13.635416 36.6328125,13.765625 L34.484375,13.765625 L34.2890625,7.3203125 L34.2890625,0.875 Z M0.5,15.1328125 L75.3046875,15.1328125 L75.3046875,19.234375 L0.5,19.234375 L0.5,15.1328125 Z M13.9765625,22.1640625 C13.9765625,22.0338535 15.6041504,21.96875 18.859375,21.96875 C22.1145996,21.96875 23.7747393,22.0664053 23.8398438,22.2617188 C23.9049482,22.4570322 23.7747412,23.2382744 23.4492188,24.6054688 C23.1236963,25.9726631 22.7005234,27.4049404 22.1796875,28.9023438 C21.6588516,30.3997471 21.0078164,31.9947832 20.2265625,33.6875 C19.4453086,35.3802168 19.0546875,36.2591143 19.0546875,36.3242188 C19.0546875,36.3893232 19.1523428,36.421875 19.3476562,36.421875 C19.5429697,36.421875 19.640625,43.5832617 19.640625,57.90625 C19.640625,66.8906699 19.6080732,72.8150898 19.5429688,75.6796875 C19.4778643,78.5442852 19.380209,80.2369766 19.25,80.7578125 C19.119791,81.6692754 18.859377,82.5156211 18.46875,83.296875 C18.078123,83.9479199 17.5898467,84.5664033 17.0039062,85.1523438 C16.4179658,85.7382842 15.7994824,86.2265605 15.1484375,86.6171875 C14.3671836,87.0078145 13.5208379,87.203125 12.609375,87.203125 L11.2421875,87.203125 L11.2421875,66.890625 C11.1119785,53.7395176 10.916668,47.1640625 10.65625,47.1640625 C10.526041,47.1640625 9.87500586,47.6197871 8.703125,48.53125 C7.66145312,49.4427129 6.65234863,50.1588516 5.67578125,50.6796875 C4.69921387,51.2005234 3.69010938,51.656248 2.6484375,52.046875 C1.60676562,52.437502 1.02083398,52.6328125 0.890625,52.6328125 C0.760416016,52.6328125 0.6953125,52.5351572 0.6953125,52.3398438 C0.6953125,52.1445303 1.15103711,51.2656328 2.0625,49.703125 C2.84375391,48.5312441 3.82030664,46.9687598 4.9921875,45.015625 C6.03385938,43.1926992 6.94530859,41.4349043 7.7265625,39.7421875 C8.76823438,37.7890527 9.54947656,36.1614648 10.0703125,34.859375 C10.8515664,33.0364492 11.5026016,31.2786543 12.0234375,29.5859375 C12.6744824,27.6328027 13.130207,26.0052148 13.390625,24.703125 C13.781252,23.1406172 13.9765625,22.2942715 13.9765625,22.1640625 Z M46.59375,22.9453125 C46.854168,22.9453125 46.984375,23.0429678 46.984375,23.2382812 C46.984375,23.4335947 46.5286504,24.6380098 45.6171875,26.8515625 C44.7057246,29.1953242 44.119793,30.5299463 43.859375,30.8554688 C43.598957,31.1809912 43.46875,31.4414053 43.46875,31.6367188 C43.46875,31.8320322 48.0259961,31.9296875 57.140625,31.9296875 L70.8125,31.9296875 L70.8125,35.640625 L69.25,35.640625 L66.3203125,41.3046875 C64.4973867,44.8203301 63.0000059,47.6197812 61.828125,49.703125 C60.6562441,51.6562598 59.4843809,53.4791582 58.3125,55.171875 C57.0104102,56.9948008 55.6432363,58.8176992 54.2109375,60.640625 C52.6484297,62.5937598 51.932291,63.635416 52.0625,63.765625 C52.0625,63.895834 52.8437422,64.4817656 54.40625,65.5234375 C55.7083398,66.5651094 57.2708242,67.6718691 59.09375,68.84375 C60.9166758,69.8854219 62.4140566,70.6666641 63.5859375,71.1875 C64.8880273,71.8385449 67.0364434,72.8802012 70.03125,74.3125 C73.1562656,75.6145898 74.7838535,76.3307285 74.9140625,76.4609375 C75.1744805,76.7213555 75.1744805,78.3489434 74.9140625,81.34375 C74.6536445,84.3385566 74.4908857,85.901041 74.4257812,86.03125 C74.3606768,86.161459 73.8724004,85.9661484 72.9609375,85.4453125 C72.4401016,85.0546855 69.1849258,83.3619941 63.1953125,80.3671875 C57.4661172,77.3723809 53.8203203,75.3541719 52.2578125,74.3125 C50.6953047,73.2708281 49.3932344,72.3593789 48.3515625,71.578125 C48.0911445,71.317707 47.8307305,71.0898447 47.5703125,70.8945312 C47.3098945,70.6992178 47.0820322,70.5039072 46.8867188,70.3085938 L46.59375,70.015625 C46.333332,69.755207 45.4869863,70.3411387 44.0546875,71.7734375 C42.3619707,73.2057363 40.7994863,74.5078066 39.3671875,75.6796875 C37.9348887,76.9817773 36.1119902,78.3489512 33.8984375,79.78125 C31.6848848,81.2135488 29.4713652,82.5156191 27.2578125,83.6875 C24.9140508,84.8593809 23.4817734,85.380209 22.9609375,85.25 C22.8307285,85.25 22.6028662,85.2174482 22.2773438,85.1523438 C21.9518213,85.0872393 21.723959,85.0546875 21.59375,85.0546875 L20.8125,84.859375 L23.15625,82.90625 C24.3281309,81.9947871 25.8906152,80.6927168 27.84375,79 C29.1458398,77.9583281 31.0989453,76.1354297 33.703125,73.53125 C36.0468867,71.1874883 37.9674404,69.2018311 39.4648438,67.5742188 C40.9622471,65.9466064 41.7109375,65.067709 41.7109375,64.9375 L40.5390625,63.375 C39.8880176,62.5937461 39.1067754,61.4869863 38.1953125,60.0546875 C37.4140586,58.8828066 36.5026094,57.3854258 35.4609375,55.5625 C34.5494746,53.8697832 33.7031289,52.1770918 32.921875,50.484375 C32.1406211,48.7916582 31.6848965,47.880209 31.5546875,47.75 L30.578125,48.6289062 C29.9270801,49.2148467 29.1458379,49.9635371 28.234375,50.875 C25.8906133,53.0885527 24.5234395,54.390623 24.1328125,54.78125 C23.4817676,55.171877 22.7656289,55.302084 21.984375,55.171875 L20.8125,54.9765625 L23.546875,51.0703125 C25.6302188,47.9452969 27.3229102,45.3411563 28.625,43.2578125 C30.4479258,40.5234238 31.8150996,38.3750078 32.7265625,36.8125 C33.8984434,34.9895742 34.7447891,33.4921934 35.265625,32.3203125 C35.9166699,31.0182227 36.7630156,29.1953242 37.8046875,26.8515625 L39.171875,23.3359375 L42.4921875,23.140625 C44.5755313,23.140625 45.9427051,23.0755215 46.59375,22.9453125 Z M58.3125,35.640625 L40.734375,35.640625 L39.3671875,37.59375 C38.5859336,38.8958398 37.4140703,40.4583242 35.8515625,42.28125 C34.2890547,44.2343848 33.5078125,45.276041 33.5078125,45.40625 C33.5078125,45.536459 34.1588477,46.4479082 35.4609375,48.140625 C36.6328184,49.4427148 38.2604062,51.2005098 40.34375,53.4140625 C42.5573027,55.6276152 44.0546836,57.0598926 44.8359375,57.7109375 L46.3984375,59.078125 L47.1796875,57.7109375 C47.8307324,56.9296836 48.7421816,55.6276133 49.9140625,53.8046875 C50.9557344,52.2421797 51.9322871,50.4843848 52.84375,48.53125 C53.6250039,46.8385332 54.6666602,44.5599102 55.96875,41.6953125 C56.229168,41.0442676 56.5221338,40.2955771 56.8476562,39.4492188 C57.1731787,38.6028604 57.4335928,37.9518252 57.6289062,37.4960938 C57.8242197,37.0403623 57.9869785,36.682293 58.1171875,36.421875 L58.3125,35.640625 Z M41.90625,37.3984375 C42.5572949,37.5286465 43.4036406,37.8216123 44.4453125,38.2773438 C45.4869844,38.7330752 46.7239512,39.6119727 48.15625,40.9140625 C49.4583398,42.2161523 50.6302031,43.5182227 51.671875,44.8203125 C52.5833379,46.1224023 53.0390625,46.838541 53.0390625,46.96875 C53.0390625,47.098959 52.1276133,47.7499941 50.3046875,48.921875 C48.3515527,50.0937559 47.3424482,50.6471357 47.2773437,50.5820312 C47.2122393,50.5169268 47.114584,50.0286504 46.984375,49.1171875 C46.723957,48.2057246 46.2682324,47.1640684 45.6171875,45.9921875 C45.0963516,44.8203066 44.5104199,43.7135469 43.859375,42.671875 C43.2083301,41.7604121 42.4921914,40.8815146 41.7109375,40.0351562 C40.9296836,39.1887979 40.604166,38.5052109 40.734375,37.984375 L40.734375,37.203125 L41.90625,37.3984375 Z M110.1875,45.5625 C113.104181,45.5625 114.5625,47.4374813 114.5625,51.1875 C114.5625,56.6041938 112.270856,59.3125 107.6875,59.3125 C105.187487,58.8958313 103.729169,57.2291813 103.3125,54.3125 C104.145838,49.312475 106.437481,46.3958375 110.1875,45.5625 Z",h=[278,83];function l(t,e){return t.type===e}const c={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:4,t:2,V:1,v:1,Z:0,z:0};class p{constructor(t){this.COMMAND=0,this.NUMBER=1,this.EOD=2,this.segments=[],this.parseData(t),this.processPoints()}tokenize(t){const e=new Array;for(;""!==t;)if(t.match(/^([ \t\r\n,]+)/))t=t.substr(RegExp.$1.length);else if(t.match(/^([aAcChHlLmMqQsStTvVzZ])/))e[e.length]={type:this.COMMAND,text:RegExp.$1},t=t.substr(RegExp.$1.length);else{if(!t.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return console.error("Unrecognized segment command: "+t),[];e[e.length]={type:this.NUMBER,text:`${parseFloat(RegExp.$1)}`},t=t.substr(RegExp.$1.length)}return e[e.length]={type:this.EOD,text:""},e}parseData(t){const e=this.tokenize(t);let s=0,i=e[s],n="BOD";for(this.segments=new Array;!l(i,this.EOD);){let r;const o=new Array;if("BOD"===n){if("M"!==i.text&&"m"!==i.text)return void this.parseData("M0,0"+t);s++,r=c[i.text],n=i.text}else l(i,this.NUMBER)?r=c[n]:(s++,r=c[i.text],n=i.text);if(s+r<e.length){for(let t=s;t<s+r;t++){const s=e[t];if(!l(s,this.NUMBER))return void console.error("Parameter type is not a number: "+n+","+s.text);o[o.length]=+s.text}if("number"!=typeof c[n])return void console.error("Unsupported segment type: "+n);{const t={key:n,data:o};this.segments.push(t),i=e[s+=r],"M"===n&&(n="L"),"m"===n&&(n="l")}}else console.error("Path data ended before all parameters were found")}}get closed(){if(void 0===this._closed){this._closed=!1;for(const t of this.segments)"z"===t.key.toLowerCase()&&(this._closed=!0)}return this._closed}processPoints(){let t=null,e=[0,0];for(let s=0;s<this.segments.length;s++){const i=this.segments[s];switch(i.key){case"M":case"L":case"T":i.point=[i.data[0],i.data[1]];break;case"m":case"l":case"t":i.point=[i.data[0]+e[0],i.data[1]+e[1]];break;case"H":i.point=[i.data[0],e[1]];break;case"h":i.point=[i.data[0]+e[0],e[1]];break;case"V":i.point=[e[0],i.data[0]];break;case"v":i.point=[e[0],i.data[0]+e[1]];break;case"z":case"Z":t&&(i.point=[t[0],t[1]]);break;case"C":i.point=[i.data[4],i.data[5]];break;case"c":i.point=[i.data[4]+e[0],i.data[5]+e[1]];break;case"S":i.point=[i.data[2],i.data[3]];break;case"s":i.point=[i.data[2]+e[0],i.data[3]+e[1]];break;case"Q":i.point=[i.data[2],i.data[3]];break;case"q":i.point=[i.data[2]+e[0],i.data[3]+e[1]];break;case"A":i.point=[i.data[5],i.data[6]];break;case"a":i.point=[i.data[5]+e[0],i.data[6]+e[1]]}"m"!==i.key&&"M"!==i.key||(t=null),i.point&&(e=i.point,t||(t=i.point)),"z"!==i.key&&"Z"!==i.key||(t=null)}}}class u{constructor(t){this._position=[0,0],this._first=null,this.bezierReflectionPoint=null,this.quadReflectionPoint=null,this.parsed=new p(t)}get segments(){return this.parsed.segments}get closed(){return this.parsed.closed}get linearPoints(){if(!this._linearPoints){const t=[];let e=[];for(const s of this.parsed.segments){const i=s.key.toLowerCase();("m"!==i&&"z"!==i||(e.length&&(t.push(e),e=[]),"z"!==i))&&(s.point&&e.push(s.point))}e.length&&(t.push(e),e=[]),this._linearPoints=t}return this._linearPoints}get first(){return this._first}set first(t){this._first=t}setPosition(t,e){this._position=[t,e],this._first||(this._first=[t,e])}get position(){return this._position}get x(){return this._position[0]}get y(){return this._position[1]}}class f{constructor(t,e,s,i,n,r){if(this._segIndex=0,this._numSegs=0,this._rx=0,this._ry=0,this._sinPhi=0,this._cosPhi=0,this._C=[0,0],this._theta=0,this._delta=0,this._T=0,this._from=t,t[0]===e[0]&&t[1]===e[1])return;const o=Math.PI/180;this._rx=Math.abs(s[0]),this._ry=Math.abs(s[1]),this._sinPhi=Math.sin(i*o),this._cosPhi=Math.cos(i*o);const a=this._cosPhi*(t[0]-e[0])/2+this._sinPhi*(t[1]-e[1])/2,h=-this._sinPhi*(t[0]-e[0])/2+this._cosPhi*(t[1]-e[1])/2;let l=0;const c=this._rx*this._rx*this._ry*this._ry-this._rx*this._rx*h*h-this._ry*this._ry*a*a;if(c<0){const t=Math.sqrt(1-c/(this._rx*this._rx*this._ry*this._ry));this._rx=this._rx*t,this._ry=this._ry*t,l=0}else l=(n===r?-1:1)*Math.sqrt(c/(this._rx*this._rx*h*h+this._ry*this._ry*a*a));const p=l*this._rx*h/this._ry,u=-l*this._ry*a/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*p-this._sinPhi*u+(t[0]+e[0])/2,this._C[1]=this._sinPhi*p+this._cosPhi*u+(t[1]+e[1])/2,this._theta=this.calculateVectorAngle(1,0,(a-p)/this._rx,(h-u)/this._ry);let f=this.calculateVectorAngle((a-p)/this._rx,(h-u)/this._ry,(-a-p)/this._rx,(-h-u)/this._ry);!r&&f>0?f-=2*Math.PI:r&&f<0&&(f+=2*Math.PI),this._numSegs=Math.ceil(Math.abs(f/(Math.PI/2))),this._delta=f/this._numSegs,this._T=8/3*Math.sin(this._delta/4)*Math.sin(this._delta/4)/Math.sin(this._delta/2)}getNextSegment(){if(this._segIndex===this._numSegs)return null;const t=Math.cos(this._theta),e=Math.sin(this._theta),s=this._theta+this._delta,i=Math.cos(s),n=Math.sin(s),r=[this._cosPhi*this._rx*i-this._sinPhi*this._ry*n+this._C[0],this._sinPhi*this._rx*i+this._cosPhi*this._ry*n+this._C[1]],o=[this._from[0]+this._T*(-this._cosPhi*this._rx*e-this._sinPhi*this._ry*t),this._from[1]+this._T*(-this._sinPhi*this._rx*e+this._cosPhi*this._ry*t)],a=[r[0]+this._T*(this._cosPhi*this._rx*n+this._sinPhi*this._ry*i),r[1]+this._T*(this._sinPhi*this._rx*n-this._cosPhi*this._ry*i)];return this._theta=s,this._from=[r[0],r[1]],this._segIndex++,{cp1:o,cp2:a,to:r}}calculateVectorAngle(t,e,s,i){const n=Math.atan2(e,t),r=Math.atan2(i,s);return r>=n?r-n:2*Math.PI-(n-r)}}class d{constructor(t,e){this.sets=t,this.closed=e}fit(t){const e=[];for(const s of this.sets){const i=s.length;let n=Math.floor(t*i);if(n<5){if(i<=5)continue;n=5}e.push(this.reduce(s,n))}let s="";for(const t of e){for(let e=0;e<t.length;e++){const i=t[e];s+=0===e?"M"+i[0]+","+i[1]:"L"+i[0]+","+i[1]}this.closed&&(s+="z ")}return s}distance(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}reduce(t,e){if(t.length<=e)return t;const s=t.slice(0);for(;s.length>e;){const t=[];let e=-1,i=-1;for(let n=1;n<s.length-1;n++){const r=this.distance(s[n-1],s[n]),o=this.distance(s[n],s[n+1]),a=this.distance(s[n-1],s[n+1]),h=(r+o+a)/2,l=Math.sqrt(h*(h-r)*(h-o)*(h-a));t.push(l),(e<0||l<e)&&(e=l,i=n)}if(!(i>0))break;s.splice(i,1)}return s}}class g{constructor(t,e){this.xi=Number.MAX_VALUE,this.yi=Number.MAX_VALUE,this.px1=t[0],this.py1=t[1],this.px2=e[0],this.py2=e[1],this.a=this.py2-this.py1,this.b=this.px1-this.px2,this.c=this.px2*this.py1-this.px1*this.py2,this._undefined=0===this.a&&0===this.b&&0===this.c}isUndefined(){return this._undefined}intersects(t){if(this.isUndefined()||t.isUndefined())return!1;let e=Number.MAX_VALUE,s=Number.MAX_VALUE,i=0,n=0;const r=this.a,o=this.b,a=this.c;return Math.abs(o)>1e-5&&(e=-r/o,i=-a/o),Math.abs(t.b)>1e-5&&(s=-t.a/t.b,n=-t.c/t.b),e===Number.MAX_VALUE?s===Number.MAX_VALUE?-a/r==-t.c/t.a&&(this.py1>=Math.min(t.py1,t.py2)&&this.py1<=Math.max(t.py1,t.py2)?(this.xi=this.px1,this.yi=this.py1,!0):this.py2>=Math.min(t.py1,t.py2)&&this.py2<=Math.max(t.py1,t.py2)&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=this.px1,this.yi=s*this.xi+n,!((this.py1-this.yi)*(this.yi-this.py2)<-1e-5||(t.py1-this.yi)*(this.yi-t.py2)<-1e-5)&&(!(Math.abs(t.a)<1e-5)||!((t.px1-this.xi)*(this.xi-t.px2)<-1e-5))):s===Number.MAX_VALUE?(this.xi=t.px1,this.yi=e*this.xi+i,!((t.py1-this.yi)*(this.yi-t.py2)<-1e-5||(this.py1-this.yi)*(this.yi-this.py2)<-1e-5)&&(!(Math.abs(r)<1e-5)||!((this.px1-this.xi)*(this.xi-this.px2)<-1e-5))):e===s?i===n&&(this.px1>=Math.min(t.px1,t.px2)&&this.px1<=Math.max(t.py1,t.py2)?(this.xi=this.px1,this.yi=this.py1,!0):this.px2>=Math.min(t.px1,t.px2)&&this.px2<=Math.max(t.px1,t.px2)&&(this.xi=this.px2,this.yi=this.py2,!0)):(this.xi=(n-i)/(e-s),this.yi=e*this.xi+i,!((this.px1-this.xi)*(this.xi-this.px2)<-1e-5||(t.px1-this.xi)*(this.xi-t.px2)<-1e-5))}}class y{constructor(t,e,s,i,n,r,o,a){this.deltaX=0,this.hGap=0,this.top=t,this.bottom=e,this.left=s,this.right=i,this.gap=n,this.sinAngle=r,this.tanAngle=a,Math.abs(r)<1e-4?this.pos=s+n:Math.abs(r)>.9999?this.pos=t+n:(this.deltaX=(e-t)*Math.abs(a),this.pos=s-Math.abs(this.deltaX),this.hGap=Math.abs(n/o),this.sLeft=new g([s,e],[s,t]),this.sRight=new g([i,e],[i,t]))}nextLine(){if(Math.abs(this.sinAngle)<1e-4){if(this.pos<this.right){const t=[this.pos,this.top,this.pos,this.bottom];return this.pos+=this.gap,t}}else if(Math.abs(this.sinAngle)>.9999){if(this.pos<this.bottom){const t=[this.left,this.pos,this.right,this.pos];return this.pos+=this.gap,t}}else{let t=this.pos-this.deltaX/2,e=this.pos+this.deltaX/2,s=this.bottom,i=this.top;if(this.pos<this.right+this.deltaX){for(;t<this.left&&e<this.left||t>this.right&&e>this.right;)if(this.pos+=this.hGap,t=this.pos-this.deltaX/2,e=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;const n=new g([t,s],[e,i]);this.sLeft&&n.intersects(this.sLeft)&&(t=n.xi,s=n.yi),this.sRight&&n.intersects(this.sRight)&&(e=n.xi,i=n.yi),this.tanAngle>0&&(t=this.right-(t-this.left),e=this.right-(e-this.left));const r=[t,s,e,i];return this.pos+=this.hGap,r}}return null}}function w(t){const e=t[0],s=t[1];return Math.sqrt(Math.pow(e[0]-s[0],2)+Math.pow(e[1]-s[1],2))}function b(t,e){const s=[],i=new g([t[0],t[1]],[t[2],t[3]]);for(let t=0;t<e.length;t++){const n=new g(e[t],e[(t+1)%e.length]);i.intersects(n)&&s.push([i.xi,i.yi])}return s}function m(t,e,s,i,n,r,o){return[-s*r-i*n+s+r*t+n*e,o*(s*n-i*r)+i+-o*n*t+o*r*e]}function v(t,e){const s=[];if(t&&t.length){let i=t[0][0],n=t[0][0],r=t[0][1],o=t[0][1];for(let e=1;e<t.length;e++)i=Math.min(i,t[e][0]),n=Math.max(n,t[e][0]),r=Math.min(r,t[e][1]),o=Math.max(o,t[e][1]);const a=e.hachureAngle;let h=e.hachureGap;h<0&&(h=4*e.strokeWidth),h=Math.max(h,.1);const l=a%180*(Math.PI/180),c=Math.cos(l),p=Math.sin(l),u=Math.tan(l),f=new y(r-1,o+1,i-1,n+1,h,p,c,u);let d;for(;null!=(d=f.nextLine());){const e=b(d,t);for(let t=0;t<e.length;t++)if(t<e.length-1){const i=e[t],n=e[t+1];s.push([i,n])}}}return s}function C(t,e,s,i,n,r){const o=[];let a=Math.abs(s/2),h=Math.abs(i/2);a+=r.getOffset(.05*-a,.05*a,n),h+=r.getOffset(.05*-h,.05*h,n);const l=n.hachureAngle;let c=n.hachureGap;c<=0&&(c=4*n.strokeWidth);let p=n.fillWeight;p<0&&(p=n.strokeWidth/2);const u=l%180*(Math.PI/180),f=Math.tan(u),d=h/a,g=Math.sqrt(d*f*d*f+1),y=d*f/g,w=1/g,b=c/(a*h/Math.sqrt(h*w*(h*w)+a*y*(a*y))/a);let v=Math.sqrt(a*a-(t-a+b)*(t-a+b));for(let s=t-a+b;s<t+a;s+=b){const i=m(s,e-(v=Math.sqrt(a*a-(t-s)*(t-s))),t,e,y,w,d),n=m(s,e+v,t,e,y,w,d);o.push([i,n])}return o}class _{constructor(t){this.renderer=t}fillPolygon(t,e){return this._fillPolygon(t,e)}fillEllipse(t,e,s,i,n){return this._fillEllipse(t,e,s,i,n)}_fillPolygon(t,e,s=!1){const i=v(t,e);return{type:"fillSketch",ops:this.renderLines(i,e,s)}}_fillEllipse(t,e,s,i,n,r=!1){const o=C(t,e,s,i,n,this.renderer);return{type:"fillSketch",ops:this.renderLines(o,n,r)}}renderLines(t,e,s){let i=[],n=null;for(const r of t)i=i.concat(this.renderer.doubleLine(r[0][0],r[0][1],r[1][0],r[1][1],e)),s&&n&&(i=i.concat(this.renderer.doubleLine(n[0],n[1],r[0][0],r[0][1],e))),n=r[1];return i}}class x extends _{fillPolygon(t,e){return this._fillPolygon(t,e,!0)}fillEllipse(t,e,s,i,n){return this._fillEllipse(t,e,s,i,n,!0)}}class M extends _{fillPolygon(t,e){const s=this._fillPolygon(t,e),i=Object.assign({},e,{hachureAngle:e.hachureAngle+90}),n=this._fillPolygon(t,i);return s.ops=s.ops.concat(n.ops),s}fillEllipse(t,e,s,i,n){const r=this._fillEllipse(t,e,s,i,n),o=Object.assign({},n,{hachureAngle:n.hachureAngle+90}),a=this._fillEllipse(t,e,s,i,o);return r.ops=r.ops.concat(a.ops),r}}class L{constructor(t){this.renderer=t}fillPolygon(t,e){const s=v(t,e=Object.assign({},e,{curveStepCount:4,hachureAngle:0}));return this.dotsOnLines(s,e)}fillEllipse(t,e,s,i,n){const r=C(t,e,s,i,n=Object.assign({},n,{curveStepCount:4,hachureAngle:0}),this.renderer);return this.dotsOnLines(r,n)}dotsOnLines(t,e){let s=[],i=e.hachureGap;i<0&&(i=4*e.strokeWidth),i=Math.max(i,.1);let n=e.fillWeight;n<0&&(n=e.strokeWidth/2);for(const r of t){const t=w(r)/i,o=Math.ceil(t)-1,a=Math.atan((r[1][1]-r[0][1])/(r[1][0]-r[0][0]));for(let t=0;t<o;t++){const o=i*(t+1),h=o*Math.sin(a),l=o*Math.cos(a),c=[r[0][0]-l,r[0][1]+h],p=this.renderer.getOffset(c[0]-i/4,c[0]+i/4,e),u=this.renderer.getOffset(c[1]-i/4,c[1]+i/4,e),f=this.renderer.ellipse(p,u,n,n,e);s=s.concat(f.ops)}}return{type:"fillSketch",ops:s}}}const A={};function P(t,e){let s=e.fillStyle||"hachure";if(!A[s])switch(s){case"zigzag":A[s]||(A[s]=new x(t));break;case"cross-hatch":A[s]||(A[s]=new M(t));break;case"dots":A[s]||(A[s]=new L(t));break;case"hachure":default:A[s="hachure"]||(A[s]=new _(t))}return A[s]}class k{line(t,e,s,i,n){return{type:"path",ops:this.doubleLine(t,e,s,i,n)}}linearPath(t,e,s){const i=(t||[]).length;if(i>2){let n=[];for(let e=0;e<i-1;e++)n=n.concat(this.doubleLine(t[e][0],t[e][1],t[e+1][0],t[e+1][1],s));return e&&(n=n.concat(this.doubleLine(t[i-1][0],t[i-1][1],t[0][0],t[0][1],s))),{type:"path",ops:n}}return 2===i?this.line(t[0][0],t[0][1],t[1][0],t[1][1],s):{type:"path",ops:[]}}polygon(t,e){return this.linearPath(t,!0,e)}rectangle(t,e,s,i,n){const r=[[t,e],[t+s,e],[t+s,e+i],[t,e+i]];return this.polygon(r,n)}curve(t,e){const s=this._curveWithOffset(t,1*(1+.2*e.roughness),e),i=this._curveWithOffset(t,1.5*(1+.22*e.roughness),e);return{type:"path",ops:s.concat(i)}}ellipse(t,e,s,i,n){const r=2*Math.PI/n.curveStepCount;let o=Math.abs(s/2),a=Math.abs(i/2);o+=this.getOffset(.05*-o,.05*o,n),a+=this.getOffset(.05*-a,.05*a,n);const h=this._ellipse(r,t,e,o,a,1,r*this.getOffset(.1,this.getOffset(.4,1,n),n),n),l=this._ellipse(r,t,e,o,a,1.5,0,n);return{type:"path",ops:h.concat(l)}}arc(t,e,s,i,n,r,o,a,h){const l=t,c=e;let p=Math.abs(s/2),u=Math.abs(i/2);p+=this.getOffset(.01*-p,.01*p,h),u+=this.getOffset(.01*-u,.01*u,h);let f=n,d=r;for(;f<0;)f+=2*Math.PI,d+=2*Math.PI;d-f>2*Math.PI&&(f=0,d=2*Math.PI);const g=2*Math.PI/h.curveStepCount,y=Math.min(g/2,(d-f)/2),w=this._arc(y,l,c,p,u,f,d,1,h),b=this._arc(y,l,c,p,u,f,d,1.5,h);let m=w.concat(b);return o&&(a?m=(m=m.concat(this.doubleLine(l,c,l+p*Math.cos(f),c+u*Math.sin(f),h))).concat(this.doubleLine(l,c,l+p*Math.cos(d),c+u*Math.sin(d),h)):(m.push({op:"lineTo",data:[l,c]}),m.push({op:"lineTo",data:[l+p*Math.cos(f),c+u*Math.sin(f)]}))),{type:"path",ops:m}}svgPath(t,e){t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let s=new u(t);if(e.simplification){const t=new d(s.linearPoints,s.closed).fit(e.simplification);s=new u(t)}let i=[];const n=s.segments||[];for(let t=0;t<n.length;t++){const r=n[t],o=t>0?n[t-1]:null,a=this._processSegment(s,r,o,e);a&&a.length&&(i=i.concat(a))}return{type:"path",ops:i}}solidFillPolygon(t,e){const s=[];if(t.length){const i=e.maxRandomnessOffset||0,n=t.length;if(n>2){s.push({op:"move",data:[t[0][0]+this.getOffset(-i,i,e),t[0][1]+this.getOffset(-i,i,e)]});for(let r=1;r<n;r++)s.push({op:"lineTo",data:[t[r][0]+this.getOffset(-i,i,e),t[r][1]+this.getOffset(-i,i,e)]})}}return{type:"fillPath",ops:s}}patternFillPolygon(t,e){return P(this,e).fillPolygon(t,e)}patternFillEllipse(t,e,s,i,n){return P(this,n).fillEllipse(t,e,s,i,n)}patternFillArc(t,e,s,i,n,r,o){const a=t,h=e;let l=Math.abs(s/2),c=Math.abs(i/2);l+=this.getOffset(.01*-l,.01*l,o),c+=this.getOffset(.01*-c,.01*c,o);let p=n,u=r;for(;p<0;)p+=2*Math.PI,u+=2*Math.PI;u-p>2*Math.PI&&(p=0,u=2*Math.PI);const f=(u-p)/o.curveStepCount,d=[];for(let t=p;t<=u;t+=f)d.push([a+l*Math.cos(t),h+c*Math.sin(t)]);return d.push([a+l*Math.cos(u),h+c*Math.sin(u)]),d.push([a,h]),this.patternFillPolygon(d,o)}getOffset(t,e,s){return s.roughness*(Math.random()*(e-t)+t)}doubleLine(t,e,s,i,n){const r=this._line(t,e,s,i,n,!0,!1),o=this._line(t,e,s,i,n,!0,!0);return r.concat(o)}_line(t,e,s,i,n,r,o){const a=Math.pow(t-s,2)+Math.pow(e-i,2);let h=n.maxRandomnessOffset||0;h*h*100>a&&(h=Math.sqrt(a)/10);const l=h/2,c=.2+.2*Math.random();let p=n.bowing*n.maxRandomnessOffset*(i-e)/200,u=n.bowing*n.maxRandomnessOffset*(t-s)/200;p=this.getOffset(-p,p,n),u=this.getOffset(-u,u,n);const f=[];return r&&(o?f.push({op:"move",data:[t+this.getOffset(-l,l,n),e+this.getOffset(-l,l,n)]}):f.push({op:"move",data:[t+this.getOffset(-h,h,n),e+this.getOffset(-h,h,n)]})),o?f.push({op:"bcurveTo",data:[p+t+(s-t)*c+this.getOffset(-l,l,n),u+e+(i-e)*c+this.getOffset(-l,l,n),p+t+2*(s-t)*c+this.getOffset(-l,l,n),u+e+2*(i-e)*c+this.getOffset(-l,l,n),s+this.getOffset(-l,l,n),i+this.getOffset(-l,l,n)]}):f.push({op:"bcurveTo",data:[p+t+(s-t)*c+this.getOffset(-h,h,n),u+e+(i-e)*c+this.getOffset(-h,h,n),p+t+2*(s-t)*c+this.getOffset(-h,h,n),u+e+2*(i-e)*c+this.getOffset(-h,h,n),s+this.getOffset(-h,h,n),i+this.getOffset(-h,h,n)]}),f}_curve(t,e,s){const i=t.length;let n=[];if(i>3){const r=[],o=1-s.curveTightness;n.push({op:"move",data:[t[1][0],t[1][1]]});for(let e=1;e+2<i;e++){const s=t[e];r[0]=[s[0],s[1]],r[1]=[s[0]+(o*t[e+1][0]-o*t[e-1][0])/6,s[1]+(o*t[e+1][1]-o*t[e-1][1])/6],r[2]=[t[e+1][0]+(o*t[e][0]-o*t[e+2][0])/6,t[e+1][1]+(o*t[e][1]-o*t[e+2][1])/6],r[3]=[t[e+1][0],t[e+1][1]],n.push({op:"bcurveTo",data:[r[1][0],r[1][1],r[2][0],r[2][1],r[3][0],r[3][1]]})}if(e&&2===e.length){const t=s.maxRandomnessOffset;n.push({op:"lineTo",data:[e[0]+this.getOffset(-t,t,s),e[1]+ +this.getOffset(-t,t,s)]})}}else 3===i?(n.push({op:"move",data:[t[1][0],t[1][1]]}),n.push({op:"bcurveTo",data:[t[1][0],t[1][1],t[2][0],t[2][1],t[2][0],t[2][1]]})):2===i&&(n=n.concat(this.doubleLine(t[0][0],t[0][1],t[1][0],t[1][1],s)));return n}_ellipse(t,e,s,i,n,r,o,a){const h=this.getOffset(-.5,.5,a)-Math.PI/2,l=[];l.push([this.getOffset(-r,r,a)+e+.9*i*Math.cos(h-t),this.getOffset(-r,r,a)+s+.9*n*Math.sin(h-t)]);for(let o=h;o<2*Math.PI+h-.01;o+=t)l.push([this.getOffset(-r,r,a)+e+i*Math.cos(o),this.getOffset(-r,r,a)+s+n*Math.sin(o)]);return l.push([this.getOffset(-r,r,a)+e+i*Math.cos(h+2*Math.PI+.5*o),this.getOffset(-r,r,a)+s+n*Math.sin(h+2*Math.PI+.5*o)]),l.push([this.getOffset(-r,r,a)+e+.98*i*Math.cos(h+o),this.getOffset(-r,r,a)+s+.98*n*Math.sin(h+o)]),l.push([this.getOffset(-r,r,a)+e+.9*i*Math.cos(h+.5*o),this.getOffset(-r,r,a)+s+.9*n*Math.sin(h+.5*o)]),this._curve(l,null,a)}_curveWithOffset(t,e,s){const i=[];i.push([t[0][0]+this.getOffset(-e,e,s),t[0][1]+this.getOffset(-e,e,s)]),i.push([t[0][0]+this.getOffset(-e,e,s),t[0][1]+this.getOffset(-e,e,s)]);for(let n=1;n<t.length;n++)i.push([t[n][0]+this.getOffset(-e,e,s),t[n][1]+this.getOffset(-e,e,s)]),n===t.length-1&&i.push([t[n][0]+this.getOffset(-e,e,s),t[n][1]+this.getOffset(-e,e,s)]);return this._curve(i,null,s)}_arc(t,e,s,i,n,r,o,a,h){const l=r+this.getOffset(-.1,.1,h),c=[];c.push([this.getOffset(-a,a,h)+e+.9*i*Math.cos(l-t),this.getOffset(-a,a,h)+s+.9*n*Math.sin(l-t)]);for(let r=l;r<=o;r+=t)c.push([this.getOffset(-a,a,h)+e+i*Math.cos(r),this.getOffset(-a,a,h)+s+n*Math.sin(r)]);return c.push([e+i*Math.cos(o),s+n*Math.sin(o)]),c.push([e+i*Math.cos(o),s+n*Math.sin(o)]),this._curve(c,null,h)}_bezierTo(t,e,s,i,n,r,o,a){const h=[],l=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.5];let c=[0,0];for(let p=0;p<2;p++)0===p?h.push({op:"move",data:[o.x,o.y]}):h.push({op:"move",data:[o.x+this.getOffset(-l[0],l[0],a),o.y+this.getOffset(-l[0],l[0],a)]}),c=[n+this.getOffset(-l[p],l[p],a),r+this.getOffset(-l[p],l[p],a)],h.push({op:"bcurveTo",data:[t+this.getOffset(-l[p],l[p],a),e+this.getOffset(-l[p],l[p],a),s+this.getOffset(-l[p],l[p],a),i+this.getOffset(-l[p],l[p],a),c[0],c[1]]});return o.setPosition(c[0],c[1]),h}_processSegment(t,e,s,i){let n=[];switch(e.key){case"M":case"m":{const s="m"===e.key;if(e.data.length>=2){let r=+e.data[0],o=+e.data[1];s&&(r+=t.x,o+=t.y);const a=1*(i.maxRandomnessOffset||0);r+=this.getOffset(-a,a,i),o+=this.getOffset(-a,a,i),t.setPosition(r,o),n.push({op:"move",data:[r,o]})}break}case"L":case"l":{const s="l"===e.key;if(e.data.length>=2){let r=+e.data[0],o=+e.data[1];s&&(r+=t.x,o+=t.y),n=n.concat(this.doubleLine(t.x,t.y,r,o,i)),t.setPosition(r,o)}break}case"H":case"h":{const s="h"===e.key;if(e.data.length){let r=+e.data[0];s&&(r+=t.x),n=n.concat(this.doubleLine(t.x,t.y,r,t.y,i)),t.setPosition(r,t.y)}break}case"V":case"v":{const s="v"===e.key;if(e.data.length){let r=+e.data[0];s&&(r+=t.y),n=n.concat(this.doubleLine(t.x,t.y,t.x,r,i)),t.setPosition(t.x,r)}break}case"Z":case"z":t.first&&(n=n.concat(this.doubleLine(t.x,t.y,t.first[0],t.first[1],i)),t.setPosition(t.first[0],t.first[1]),t.first=null);break;case"C":case"c":{const s="c"===e.key;if(e.data.length>=6){let r=+e.data[0],o=+e.data[1],a=+e.data[2],h=+e.data[3],l=+e.data[4],c=+e.data[5];s&&(r+=t.x,a+=t.x,l+=t.x,o+=t.y,h+=t.y,c+=t.y);const p=this._bezierTo(r,o,a,h,l,c,t,i);n=n.concat(p),t.bezierReflectionPoint=[l+(l-a),c+(c-h)]}break}case"S":case"s":{const r="s"===e.key;if(e.data.length>=4){let o=+e.data[0],a=+e.data[1],h=+e.data[2],l=+e.data[3];r&&(o+=t.x,h+=t.x,a+=t.y,l+=t.y);let c=o,p=a;const u=s?s.key:"";let f=null;"c"!==u&&"C"!==u&&"s"!==u&&"S"!==u||(f=t.bezierReflectionPoint),f&&(c=f[0],p=f[1]);const d=this._bezierTo(c,p,o,a,h,l,t,i);n=n.concat(d),t.bezierReflectionPoint=[h+(h-o),l+(l-a)]}break}case"Q":case"q":{const s="q"===e.key;if(e.data.length>=4){let r=+e.data[0],o=+e.data[1],a=+e.data[2],h=+e.data[3];s&&(r+=t.x,a+=t.x,o+=t.y,h+=t.y);const l=1*(1+.2*i.roughness),c=1.5*(1+.22*i.roughness);n.push({op:"move",data:[t.x+this.getOffset(-l,l,i),t.y+this.getOffset(-l,l,i)]});let p=[a+this.getOffset(-l,l,i),h+this.getOffset(-l,l,i)];n.push({op:"qcurveTo",data:[r+this.getOffset(-l,l,i),o+this.getOffset(-l,l,i),p[0],p[1]]}),n.push({op:"move",data:[t.x+this.getOffset(-c,c,i),t.y+this.getOffset(-c,c,i)]}),p=[a+this.getOffset(-c,c,i),h+this.getOffset(-c,c,i)],n.push({op:"qcurveTo",data:[r+this.getOffset(-c,c,i),o+this.getOffset(-c,c,i),p[0],p[1]]}),t.setPosition(p[0],p[1]),t.quadReflectionPoint=[a+(a-r),h+(h-o)]}break}case"T":case"t":{const r="t"===e.key;if(e.data.length>=2){let o=+e.data[0],a=+e.data[1];r&&(o+=t.x,a+=t.y);let h=o,l=a;const c=s?s.key:"";let p=null;"q"!==c&&"Q"!==c&&"t"!==c&&"T"!==c||(p=t.quadReflectionPoint),p&&(h=p[0],l=p[1]);const u=1*(1+.2*i.roughness),f=1.5*(1+.22*i.roughness);n.push({op:"move",data:[t.x+this.getOffset(-u,u,i),t.y+this.getOffset(-u,u,i)]});let d=[o+this.getOffset(-u,u,i),a+this.getOffset(-u,u,i)];n.push({op:"qcurveTo",data:[h+this.getOffset(-u,u,i),l+this.getOffset(-u,u,i),d[0],d[1]]}),n.push({op:"move",data:[t.x+this.getOffset(-f,f,i),t.y+this.getOffset(-f,f,i)]}),d=[o+this.getOffset(-f,f,i),a+this.getOffset(-f,f,i)],n.push({op:"qcurveTo",data:[h+this.getOffset(-f,f,i),l+this.getOffset(-f,f,i),d[0],d[1]]}),t.setPosition(d[0],d[1]),t.quadReflectionPoint=[o+(o-h),a+(a-l)]}break}case"A":case"a":{const s="a"===e.key;if(e.data.length>=7){const r=+e.data[0],o=+e.data[1],a=+e.data[2],h=+e.data[3],l=+e.data[4];let c=+e.data[5],p=+e.data[6];if(s&&(c+=t.x,p+=t.y),c===t.x&&p===t.y)break;if(0===r||0===o)n=n.concat(this.doubleLine(t.x,t.y,c,p,i)),t.setPosition(c,p);else for(let e=0;e<1;e++){const e=new f([t.x,t.y],[c,p],[r,o],a,!!h,!!l);let s=e.getNextSegment();for(;s;){const r=this._bezierTo(s.cp1[0],s.cp1[1],s.cp2[0],s.cp2[1],s.to[0],s.to[1],t,i);n=n.concat(r),s=e.getNextSegment()}}}break}}return n}}const O="undefined"!=typeof self,S=O&&self&&self.document&&self.document.currentScript&&self.document.currentScript.src;const D="undefined"!=typeof self;class E{constructor(t,e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1},this.config=t||{},this.surface=e,this.renderer=function(t){if(O&&S&&self&&self.workly&&t.async&&!t.noWorker){const e=t.worklyURL||"https://cdn.jsdelivr.net/gh/pshihn/workly/dist/workly.min.js";if(e){const t=`importScripts('${e}', '${S}');\nworkly.expose(self.rough.createRenderer());`,s=URL.createObjectURL(new Blob([t]));return self.workly.proxy(s)}}return new k}(this.config),this.config.options&&(this.defaultOptions=this._options(this.config.options))}_options(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_drawable(t,e,s){return{shape:t,sets:e||[],options:s||this.defaultOptions}}get lib(){return this.renderer}getCanvasSize(){const t=t=>t&&"object"==typeof t&&t.baseVal&&t.baseVal.value?t.baseVal.value:t||100;return this.surface?[t(this.surface.width),t(this.surface.height)]:[100,100]}computePolygonSize(t){if(t.length){let e=t[0][0],s=t[0][0],i=t[0][1],n=t[0][1];for(let r=1;r<t.length;r++)e=Math.min(e,t[r][0]),s=Math.max(s,t[r][0]),i=Math.min(i,t[r][1]),n=Math.max(n,t[r][1]);return[s-e,n-i]}return[0,0]}polygonPath(t){let e="";if(t.length){e=`M${t[0][0]},${t[0][1]}`;for(let s=1;s<t.length;s++)e=`${e} L${t[s][0]},${t[s][1]}`}return e}computePathSize(t){let e=[0,0];if(D&&self.document)try{const s="http://www.w3.org/2000/svg",i=self.document.createElementNS(s,"svg");i.setAttribute("width","0"),i.setAttribute("height","0");const n=self.document.createElementNS(s,"path");n.setAttribute("d",t),i.appendChild(n),self.document.body.appendChild(i);const r=n.getBBox();r&&(e[0]=r.width||0,e[1]=r.height||0),self.document.body.removeChild(i)}catch(t){}const s=this.getCanvasSize();return e[0]*e[1]||(e=s),e}toPaths(t){const e=t.sets||[],s=t.options||this.defaultOptions,i=[];for(const t of e){let e=null;switch(t.type){case"path":e={d:this.opsToPath(t),stroke:s.stroke,strokeWidth:s.strokeWidth,fill:"none"};break;case"fillPath":e={d:this.opsToPath(t),stroke:"none",strokeWidth:0,fill:s.fill||"none"};break;case"fillSketch":e=this.fillSketch(t,s);break;case"path2Dfill":e={d:t.path||"",stroke:"none",strokeWidth:0,fill:s.fill||"none"};break;case"path2Dpattern":{const i=t.size,n={x:0,y:0,width:1,height:1,viewBox:`0 0 ${Math.round(i[0])} ${Math.round(i[1])}`,patternUnits:"objectBoundingBox",path:this.fillSketch(t,s)};e={d:t.path,stroke:"none",strokeWidth:0,pattern:n};break}}e&&i.push(e)}return i}fillSketch(t,e){let s=e.fillWeight;return s<0&&(s=e.strokeWidth/2),{d:this.opsToPath(t),stroke:e.fill||"none",strokeWidth:s,fill:"none"}}opsToPath(t){let e="";for(const s of t.ops){const t=s.data;switch(s.op){case"move":e+=`M${t[0]} ${t[1]} `;break;case"bcurveTo":e+=`C${t[0]} ${t[1]}, ${t[2]} ${t[3]}, ${t[4]} ${t[5]} `;break;case"qcurveTo":e+=`Q${t[0]} ${t[1]}, ${t[2]} ${t[3]} `;break;case"lineTo":e+=`L${t[0]} ${t[1]} `}}return e.trim()}}class z extends E{constructor(t,e){super(t,e)}line(t,e,s,i,n){const r=this._options(n);return this._drawable("line",[this.lib.line(t,e,s,i,r)],r)}rectangle(t,e,s,i,n){const r=this._options(n),o=[];if(r.fill){const n=[[t,e],[t+s,e],[t+s,e+i],[t,e+i]];"solid"===r.fillStyle?o.push(this.lib.solidFillPolygon(n,r)):o.push(this.lib.patternFillPolygon(n,r))}return o.push(this.lib.rectangle(t,e,s,i,r)),this._drawable("rectangle",o,r)}ellipse(t,e,s,i,n){const r=this._options(n),o=[];if(r.fill)if("solid"===r.fillStyle){const n=this.lib.ellipse(t,e,s,i,r);n.type="fillPath",o.push(n)}else o.push(this.lib.patternFillEllipse(t,e,s,i,r));return o.push(this.lib.ellipse(t,e,s,i,r)),this._drawable("ellipse",o,r)}circle(t,e,s,i){const n=this.ellipse(t,e,s,s,i);return n.shape="circle",n}linearPath(t,e){const s=this._options(e);return this._drawable("linearPath",[this.lib.linearPath(t,!1,s)],s)}arc(t,e,s,i,n,r,o=!1,a){const h=this._options(a),l=[];if(o&&h.fill)if("solid"===h.fillStyle){const o=this.lib.arc(t,e,s,i,n,r,!0,!1,h);o.type="fillPath",l.push(o)}else l.push(this.lib.patternFillArc(t,e,s,i,n,r,h));return l.push(this.lib.arc(t,e,s,i,n,r,o,!0,h)),this._drawable("arc",l,h)}curve(t,e){const s=this._options(e);return this._drawable("curve",[this.lib.curve(t,s)],s)}polygon(t,e){const s=this._options(e),i=[];if(s.fill)if("solid"===s.fillStyle)i.push(this.lib.solidFillPolygon(t,s));else{const e=this.computePolygonSize(t),n=[[0,0],[e[0],0],[e[0],e[1]],[0,e[1]]],r=this.lib.patternFillPolygon(n,s);r.type="path2Dpattern",r.size=e,r.path=this.polygonPath(t),i.push(r)}return i.push(this.lib.linearPath(t,!0,s)),this._drawable("polygon",i,s)}path(t,e){const s=this._options(e),i=[];if(!t)return this._drawable("path",i,s);if(s.fill)if("solid"===s.fillStyle){const e={type:"path2Dfill",path:t,ops:[]};i.push(e)}else{const e=this.computePathSize(t),n=[[0,0],[e[0],0],[e[0],e[1]],[0,e[1]]],r=this.lib.patternFillPolygon(n,s);r.type="path2Dpattern",r.size=e,r.path=t,i.push(r)}return i.push(this.lib.svgPath(t,s)),this._drawable("path",i,s)}}const T="undefined"!=typeof document;class B{constructor(t){this.canvas=t,this.ctx=this.canvas.getContext("2d")}static createRenderer(){return new k}draw(t){const e=t.sets||[],s=t.options||this.getDefaultOptions(),i=this.ctx;for(const t of e)switch(t.type){case"path":i.save(),i.strokeStyle=s.stroke,i.lineWidth=s.strokeWidth,this._drawToContext(i,t),i.restore();break;case"fillPath":i.save(),i.fillStyle=s.fill||"",this._drawToContext(i,t),i.restore();break;case"fillSketch":this.fillSketch(i,t,s);break;case"path2Dfill":{this.ctx.save(),this.ctx.fillStyle=s.fill||"";const e=new Path2D(t.path);this.ctx.fill(e),this.ctx.restore();break}case"path2Dpattern":{const e=this.canvas.ownerDocument||T&&document;if(e){const i=t.size,n=e.createElement("canvas"),r=n.getContext("2d"),o=this.computeBBox(t.path);o&&(o.width||o.height)?(n.width=this.canvas.width,n.height=this.canvas.height,r.translate(o.x||0,o.y||0)):(n.width=i[0],n.height=i[1]),this.fillSketch(r,t,s),this.ctx.save(),this.ctx.fillStyle=this.ctx.createPattern(n,"repeat");const a=new Path2D(t.path);this.ctx.fill(a),this.ctx.restore()}else console.error("Cannot render path2Dpattern. No defs/document defined.");break}}}computeBBox(t){if(T)try{const e="http://www.w3.org/2000/svg",s=document.createElementNS(e,"svg");s.setAttribute("width","0"),s.setAttribute("height","0");const i=self.document.createElementNS(e,"path");i.setAttribute("d",t),s.appendChild(i),document.body.appendChild(s);const n=i.getBBox();return document.body.removeChild(s),n}catch(t){}return null}fillSketch(t,e,s){let i=s.fillWeight;i<0&&(i=s.strokeWidth/2),t.save(),t.strokeStyle=s.fill||"",t.lineWidth=i,this._drawToContext(t,e),t.restore()}_drawToContext(t,e){t.beginPath();for(const s of e.ops){const e=s.data;switch(s.op){case"move":t.moveTo(e[0],e[1]);break;case"bcurveTo":t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]);break;case"qcurveTo":t.quadraticCurveTo(e[0],e[1],e[2],e[3]);break;case"lineTo":t.lineTo(e[0],e[1])}}"fillPath"===e.type?t.fill():t.stroke()}}class I extends B{constructor(t,e){super(t),this.gen=new z(e||null,this.canvas)}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,e,s,i,n){const r=this.gen.line(t,e,s,i,n);return this.draw(r),r}rectangle(t,e,s,i,n){const r=this.gen.rectangle(t,e,s,i,n);return this.draw(r),r}ellipse(t,e,s,i,n){const r=this.gen.ellipse(t,e,s,i,n);return this.draw(r),r}circle(t,e,s,i){const n=this.gen.circle(t,e,s,i);return this.draw(n),n}linearPath(t,e){const s=this.gen.linearPath(t,e);return this.draw(s),s}polygon(t,e){const s=this.gen.polygon(t,e);return this.draw(s),s}arc(t,e,s,i,n,r,o=!1,a){const h=this.gen.arc(t,e,s,i,n,r,o,a);return this.draw(h),h}curve(t,e){const s=this.gen.curve(t,e);return this.draw(s),s}path(t,e){const s=this.gen.path(t,e);return this.draw(s),s}}class R extends E{async line(t,e,s,i,n){const r=this._options(n);return this._drawable("line",[await this.lib.line(t,e,s,i,r)],r)}async rectangle(t,e,s,i,n){const r=this._options(n),o=[];if(r.fill){const n=[[t,e],[t+s,e],[t+s,e+i],[t,e+i]];"solid"===r.fillStyle?o.push(await this.lib.solidFillPolygon(n,r)):o.push(await this.lib.patternFillPolygon(n,r))}return o.push(await this.lib.rectangle(t,e,s,i,r)),this._drawable("rectangle",o,r)}async ellipse(t,e,s,i,n){const r=this._options(n),o=[];if(r.fill)if("solid"===r.fillStyle){const n=await this.lib.ellipse(t,e,s,i,r);n.type="fillPath",o.push(n)}else o.push(await this.lib.patternFillEllipse(t,e,s,i,r));return o.push(await this.lib.ellipse(t,e,s,i,r)),this._drawable("ellipse",o,r)}async circle(t,e,s,i){const n=await this.ellipse(t,e,s,s,i);return n.shape="circle",n}async linearPath(t,e){const s=this._options(e);return this._drawable("linearPath",[await this.lib.linearPath(t,!1,s)],s)}async arc(t,e,s,i,n,r,o=!1,a){const h=this._options(a),l=[];if(o&&h.fill)if("solid"===h.fillStyle){const o=await this.lib.arc(t,e,s,i,n,r,!0,!1,h);o.type="fillPath",l.push(o)}else l.push(await this.lib.patternFillArc(t,e,s,i,n,r,h));return l.push(await this.lib.arc(t,e,s,i,n,r,o,!0,h)),this._drawable("arc",l,h)}async curve(t,e){const s=this._options(e);return this._drawable("curve",[await this.lib.curve(t,s)],s)}async polygon(t,e){const s=this._options(e),i=[];if(s.fill)if("solid"===s.fillStyle)i.push(await this.lib.solidFillPolygon(t,s));else{const e=this.computePolygonSize(t),n=[[0,0],[e[0],0],[e[0],e[1]],[0,e[1]]],r=await this.lib.patternFillPolygon(n,s);r.type="path2Dpattern",r.size=e,r.path=this.polygonPath(t),i.push(r)}return i.push(await this.lib.linearPath(t,!0,s)),this._drawable("polygon",i,s)}async path(t,e){const s=this._options(e),i=[];if(!t)return this._drawable("path",i,s);if(s.fill)if("solid"===s.fillStyle){const e={type:"path2Dfill",path:t,ops:[]};i.push(e)}else{const e=this.computePathSize(t),n=[[0,0],[e[0],0],[e[0],e[1]],[0,e[1]]],r=await this.lib.patternFillPolygon(n,s);r.type="path2Dpattern",r.size=e,r.path=t,i.push(r)}return i.push(await this.lib.svgPath(t,s)),this._drawable("path",i,s)}}const N="undefined"!=typeof document;class G{constructor(t){this.svg=t}static createRenderer(){return new k}get defs(){const t=this.svg.ownerDocument||N&&document;if(t&&!this._defs){const e=t.createElementNS("http://www.w3.org/2000/svg","defs");this.svg.firstChild?this.svg.insertBefore(e,this.svg.firstChild):this.svg.appendChild(e),this._defs=e}return this._defs||null}draw(t){const e=t.sets||[],s=t.options||this.getDefaultOptions(),i=this.svg.ownerDocument||N&&document,n=i.createElementNS("http://www.w3.org/2000/svg","g");for(const t of e){let e=null;switch(t.type){case"path":(e=i.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",this.opsToPath(t)),e.style.stroke=s.stroke,e.style.strokeWidth=s.strokeWidth+"",e.style.fill="none";break;case"fillPath":(e=i.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",this.opsToPath(t)),e.style.stroke="none",e.style.strokeWidth="0",e.style.fill=s.fill||null;break;case"fillSketch":e=this.fillSketch(i,t,s);break;case"path2Dfill":(e=i.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t.path||""),e.style.stroke="none",e.style.strokeWidth="0",e.style.fill=s.fill||null;break;case"path2Dpattern":if(this.defs){const n=t.size,r=i.createElementNS("http://www.w3.org/2000/svg","pattern"),o=`rough-${Math.floor(Math.random()*(Number.MAX_SAFE_INTEGER||999999))}`;r.setAttribute("id",o),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("width","1"),r.setAttribute("height","1"),r.setAttribute("height","1"),r.setAttribute("viewBox",`0 0 ${Math.round(n[0])} ${Math.round(n[1])}`),r.setAttribute("patternUnits","objectBoundingBox");const a=this.fillSketch(i,t,s);r.appendChild(a),this.defs.appendChild(r),(e=i.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t.path||""),e.style.stroke="none",e.style.strokeWidth="0",e.style.fill=`url(#${o})`}else console.error("Cannot render path2Dpattern. No defs/document defined.")}e&&n.appendChild(e)}return n}fillSketch(t,e,s){let i=s.fillWeight;i<0&&(i=s.strokeWidth/2);const n=t.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",this.opsToPath(e)),n.style.stroke=s.fill||null,n.style.strokeWidth=i+"",n.style.fill="none",n}}var W={canvas:(t,e)=>e&&e.async?new class extends B{constructor(t,e){super(t),this.genAsync=new R(e||null,this.canvas)}get generator(){return this.genAsync}getDefaultOptions(){return this.genAsync.defaultOptions}async line(t,e,s,i,n){const r=await this.genAsync.line(t,e,s,i,n);return this.draw(r),r}async rectangle(t,e,s,i,n){const r=await this.genAsync.rectangle(t,e,s,i,n);return this.draw(r),r}async ellipse(t,e,s,i,n){const r=await this.genAsync.ellipse(t,e,s,i,n);return this.draw(r),r}async circle(t,e,s,i){const n=await this.genAsync.circle(t,e,s,i);return this.draw(n),n}async linearPath(t,e){const s=await this.genAsync.linearPath(t,e);return this.draw(s),s}async polygon(t,e){const s=await this.genAsync.polygon(t,e);return this.draw(s),s}async arc(t,e,s,i,n,r,o=!1,a){const h=await this.genAsync.arc(t,e,s,i,n,r,o,a);return this.draw(h),h}async curve(t,e){const s=await this.genAsync.curve(t,e);return this.draw(s),s}async path(t,e){const s=await this.genAsync.path(t,e);return this.draw(s),s}}(t,e):new I(t,e),svg:(t,e)=>e&&e.async?new class extends G{constructor(t,e){super(t),this.genAsync=new R(e||null,this.svg)}get generator(){return this.genAsync}getDefaultOptions(){return this.genAsync.defaultOptions}opsToPath(t){return this.genAsync.opsToPath(t)}async line(t,e,s,i,n){const r=await this.genAsync.line(t,e,s,i,n);return this.draw(r)}async rectangle(t,e,s,i,n){const r=await this.genAsync.rectangle(t,e,s,i,n);return this.draw(r)}async ellipse(t,e,s,i,n){const r=await this.genAsync.ellipse(t,e,s,i,n);return this.draw(r)}async circle(t,e,s,i){const n=await this.genAsync.circle(t,e,s,i);return this.draw(n)}async linearPath(t,e){const s=await this.genAsync.linearPath(t,e);return this.draw(s)}async polygon(t,e){const s=await this.genAsync.polygon(t,e);return this.draw(s)}async arc(t,e,s,i,n,r,o=!1,a){const h=await this.genAsync.arc(t,e,s,i,n,r,o,a);return this.draw(h)}async curve(t,e){const s=await this.genAsync.curve(t,e);return this.draw(s)}async path(t,e){const s=await this.genAsync.path(t,e);return this.draw(s)}}(t,e):new class extends G{constructor(t,e){super(t),this.gen=new z(e||null,this.svg)}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t){return this.gen.opsToPath(t)}line(t,e,s,i,n){const r=this.gen.line(t,e,s,i,n);return this.draw(r)}rectangle(t,e,s,i,n){const r=this.gen.rectangle(t,e,s,i,n);return this.draw(r)}ellipse(t,e,s,i,n){const r=this.gen.ellipse(t,e,s,i,n);return this.draw(r)}circle(t,e,s,i){const n=this.gen.circle(t,e,s,i);return this.draw(n)}linearPath(t,e){const s=this.gen.linearPath(t,e);return this.draw(s)}polygon(t,e){const s=this.gen.polygon(t,e);return this.draw(s)}arc(t,e,s,i,n,r,o=!1,a){const h=this.gen.arc(t,e,s,i,n,r,o,a);return this.draw(h)}curve(t,e){const s=this.gen.curve(t,e);return this.draw(s)}path(t,e){const s=this.gen.path(t,e);return this.draw(s)}}(t,e),createRenderer:()=>I.createRenderer(),generator:(t,e)=>t&&t.async?new R(t,e):new z(t,e)},j="http://www.w3.org/2000/svg";function U(t){return document.createElementNS(j,t)}function q(t,e,s){var i=t.getBBox();return{width:i.width||Math.min(e,window.innerWidth),height:i.height||s}}var F=function(){function t(t){this.svg=t;var e=q(t,400,400);t.setAttribute("width",e.width+""),t.setAttribute("height",e.height+""),this.width=e.width,this.height=e.height,this.barCnt=100,this.isPainted=!1}return t.prototype.paint=function(t,e){this.isPainted=!0},t.prototype.clear=function(){var t=this;Array.prototype.slice.call(this.svg.children).forEach(function(e){"defs"!==e.tagName&&t.svg.removeChild(e)})},t}(),Z=function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(e,s)};return function(e,s){function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),Q=function(t){function e(e){var s=t.call(this,e)||this;return s.barCnt=160,s.rc=W.svg(e),s._text=null,s._textStr="",s}return Z(e,t),e.prototype.paint=function(e,s){var i=.5*Math.min(this.width,this.height),n=.9*i,r=.45*i;this._innerR=r;var o=e.length,a=2*Math.PI/o,h=n-r,l=.2*a;this.clear(),this._drawBars(e,r,h,a,l),s&&this._drawText(s),t.prototype.paint.call(this,e,s)},e.prototype.paintLoading=function(){this.clear();var t=.4*this.width,e=this._drawSVGText("M43.0234375,2.390625 L69.5859375,2.390625 L69.5859375,13.1328125 C69.7161465,20.4245156 69.651043,24.6562441 69.390625,25.828125 C69.130207,27.0000059 68.8046895,27.9114551 68.4140625,28.5625 C68.1536445,29.2135449 68.0234375,29.604166 68.0234375,29.734375 C68.0234375,29.864584 71.2135098,29.9296875 77.59375,29.9296875 L87.1640625,29.9296875 L87.1640625,33.4453125 L49.859375,33.4453125 L49.859375,39.3046875 L51.6171875,41.453125 C52.6588594,43.0156328 53.7005156,44.3828066 54.7421875,45.5546875 C56.0442773,46.9869863 56.9557266,47.8984355 57.4765625,48.2890625 L58.453125,49.0703125 L60.015625,48.484375 C60.9270879,47.9635391 61.9036406,47.4427109 62.9453125,46.921875 C63.8567754,46.4010391 64.9635352,45.6197969 66.265625,44.578125 C67.4375059,43.5364531 68.6744727,42.3645898 69.9765625,41.0625 C71.2786523,39.7604102 72.2552051,38.6536504 72.90625,37.7421875 L73.8828125,36.375 L74.6640625,36.8632812 C75.1848984,37.1888037 76.0963477,37.7421836 77.3984375,38.5234375 C78.7005273,39.3046914 79.416666,39.8255195 79.546875,40.0859375 C79.677084,40.3463555 79.3515664,40.8671836 78.5703125,41.6484375 C77.6588496,42.5599004 76.6171934,43.4713496 75.4453125,44.3828125 C74.5338496,45.1640664 73.3619863,46.0104121 71.9296875,46.921875 C71.0182246,47.5729199 70.0416719,48.2239551 69,48.875 C68.2187461,49.265627 67.1770898,49.656248 65.875,50.046875 C64.5729102,50.437502 63.4010469,50.697916 62.359375,50.828125 C61.3177031,50.828125 60.796875,50.8932285 60.796875,51.0234375 C60.796875,51.1536465 61.8385312,51.9348887 63.921875,53.3671875 C66.2656367,55.1901133 67.6979141,56.2317695 68.21875,56.4921875 C69.0000039,57.0130234 70.4322812,57.8593691 72.515625,59.03125 C74.7291777,60.3333398 77.5286289,61.8958242 80.9140625,63.71875 C84.5599141,65.5416758 86.447916,66.453125 86.578125,66.453125 L86.1875,66.84375 C85.927082,67.104168 85.5364609,67.4622373 85.015625,67.9179688 C84.4947891,68.3737002 83.9088574,68.796873 83.2578125,69.1875 L79.9375,71.7265625 L77.3984375,70.359375 C76.2265566,69.7083301 74.0781406,68.4713633 70.953125,66.6484375 C68.3489453,65.0859297 66.3307363,63.7838594 64.8984375,62.7421875 C63.5963477,61.9609336 62.1640703,60.7239668 60.6015625,59.03125 C58.9088457,57.4687422 57.4765684,55.9713613 56.3046875,54.5390625 C55.1328066,52.9765547 54.2213574,51.4791738 53.5703125,50.046875 C52.7890586,48.7447852 52.0729199,47.0520938 51.421875,44.96875 C50.6406211,43.1458242 50.1848965,42.1692715 50.0546875,42.0390625 L49.9570312,44.0898438 C49.8919268,45.4570381 49.859375,47.4101436 49.859375,49.9492188 L49.859375,68.3085938 C49.859375,70.587251 49.8268232,72.2473906 49.7617188,73.2890625 C49.6966143,74.3307344 49.6640625,75.046873 49.6640625,75.4375 C49.4036445,76.3489629 49.078127,77.1953086 48.6875,77.9765625 C48.296873,78.7578164 47.8085967,79.4414033 47.2226562,80.0273438 C46.6367158,80.6132842 45.9856807,81.0690088 45.2695312,81.3945312 C44.5533818,81.7200537 43.7395879,81.8828125 42.828125,81.8828125 L41.265625,81.8828125 L41.265625,33.4453125 L0.640625,33.4453125 L0.640625,29.9296875 L30.71875,29.9296875 L60.9921875,29.734375 L60.9921875,19.96875 L19.390625,19.96875 L19.390625,16.2578125 L60.9921875,16.2578125 L60.9921875,6.1015625 L16.265625,6.1015625 L16.265625,2.1953125 L43.0234375,2.390625 Z M23.1015625,40.28125 L37.5546875,40.28125 L37.359375,43.9921875 C37.229166,46.3359492 36.968752,48.4192617 36.578125,50.2421875 C36.317707,51.9349043 35.9270859,53.6926992 35.40625,55.515625 C34.7552051,57.0781328 34.0390664,58.7057207 33.2578125,60.3984375 C32.4765586,62.0911543 31.6953164,63.5234316 30.9140625,64.6953125 C30.1328086,66.1276113 29.2864629,67.3645781 28.375,68.40625 C27.4635371,69.5781309 26.1614668,71.0104082 24.46875,72.703125 C22.7760332,74.3958418 21.2135488,75.7630156 19.78125,76.8046875 C18.3489512,77.8463594 16.9817773,78.7578086 15.6796875,79.5390625 C14.2473887,80.4505254 13.0755254,80.8411465 12.1640625,80.7109375 L10.6992188,80.7109375 C10.5039053,80.7109375 10.40625,80.6783857 10.40625,80.6132812 C10.40625,80.5481768 10.5039053,80.4505215 10.6992188,80.3203125 C10.8945322,80.1901035 11.1549463,79.9622412 11.4804688,79.6367188 L12.5546875,78.5625 C14.1171953,77.2604102 15.6145762,75.8932363 17.046875,74.4609375 C18.4791738,72.8984297 19.6510371,71.5963594 20.5625,70.5546875 C21.4739629,69.3828066 22.3203086,68.2109434 23.1015625,67.0390625 C23.8828164,65.8671816 24.5989551,64.5651113 25.25,63.1328125 C25.9010449,61.7005137 26.4869766,60.2682363 27.0078125,58.8359375 C27.5286484,57.2734297 27.984373,55.7760488 28.375,54.34375 C28.635418,52.6510332 28.8307285,51.3489629 28.9609375,50.4375 C29.0911465,49.2656191 29.15625,47.9635488 29.15625,46.53125 L29.15625,44.3828125 C29.15625,44.2526035 25.7708672,44.1875 19,44.1875 L8.84375,43.9921875 L8.6484375,42.4296875 C8.6484375,41.5182246 8.71354102,40.932293 8.84375,40.671875 C8.84375,40.411457 13.5963066,40.28125 23.1015625,40.28125 Z M144.195312,0.6328125 L148.492188,0.6328125 L148.296875,2.5859375 C148.296875,3.75781836 148.231771,4.66926758 148.101562,5.3203125 C147.971354,5.97135742 147.710939,6.68749609 147.320312,7.46875 C146.929686,8.25000391 146.539064,8.90103906 146.148438,9.421875 L145.367188,10.3984375 L177.398438,10.3984375 L177.398438,12.15625 L177.59375,14.109375 L110.992188,14.109375 L110.992188,10.3984375 L139.898438,10.3984375 L139.898438,0.4375 L144.195312,0.6328125 Z M123.296875,17.625 C124.989592,17.625 126.486973,17.755207 127.789062,18.015625 C129.221361,18.276043 130.588535,18.5690088 131.890625,18.8945312 C133.192715,19.2200537 134.559889,19.7734336 135.992188,20.5546875 C137.424486,21.2057324 138.661453,21.9869746 139.703125,22.8984375 C140.744797,23.9401094 141.265625,24.526041 141.265625,24.65625 C141.265625,24.786459 140.744797,25.4374941 139.703125,26.609375 C138.010408,28.4323008 136.968752,29.6041641 136.578125,30.125 C135.666662,31.1666719 135.145834,31.6875 135.015625,31.6875 C134.885416,31.6875 134.690105,31.3619824 134.429688,30.7109375 C134.16927,30.1901016 133.713545,29.4739629 133.0625,28.5625 C132.541664,27.6510371 131.955732,26.8046914 131.304688,26.0234375 C130.783852,25.3723926 129.937506,24.5260469 128.765625,23.484375 C127.723953,22.5729121 126.649745,21.7916699 125.542969,21.140625 C124.436192,20.4895801 123.361984,19.9036484 122.320312,19.3828125 C121.278641,18.8619766 120.757812,18.406252 120.757812,18.015625 L120.757812,17.4296875 L123.296875,17.625 Z M154.15625,17.4296875 C154.546877,17.5598965 155.816396,17.6575518 157.964844,17.7226562 C160.113292,17.7877607 161.643225,17.885416 162.554688,18.015625 L163.921875,18.2109375 L163.726562,18.9921875 C163.726562,19.3828145 163.531252,20.1640566 163.140625,21.3359375 C162.880207,22.3776094 162.619793,23.1588516 162.359375,23.6796875 C162.098957,24.3307324 161.643232,25.0468711 160.992188,25.828125 C160.471352,26.6093789 159.690109,27.3906211 158.648438,28.171875 C157.736975,28.9531289 156.630215,29.7343711 155.328125,30.515625 C153.895826,31.1666699 152.593756,31.687498 151.421875,32.078125 L149.859375,32.859375 L182.867188,32.859375 L182.867188,36.5703125 L104.9375,36.5703125 L104.9375,32.859375 L148.882812,32.859375 L150.054688,30.7109375 C150.575523,29.2786387 151.031248,28.0416719 151.421875,27 C151.812502,25.9583281 152.13802,24.9166719 152.398438,23.875 C152.658855,22.7031191 152.91927,21.4010488 153.179688,19.96875 C153.440105,18.5364512 153.570312,17.755209 153.570312,17.625 C153.700521,17.494791 153.895832,17.4296875 154.15625,17.4296875 Z M120.757813,43.2109375 L129.15625,43.2109375 L129.15625,44.1875 L129.351563,45.1640625 L159.625,45.1640625 L159.625,44.1875 L159.820313,43.2109375 L168.21875,43.2109375 L168.21875,59.2265625 C168.21875,69.9036992 168.088543,75.6979121 167.828125,76.609375 C167.567707,77.6510469 167.307293,78.4973926 167.046875,79.1484375 C166.786457,79.7994824 166.330732,80.5156211 165.679688,81.296875 C165.028643,81.9479199 164.345056,82.468748 163.628906,82.859375 C162.912757,83.250002 162.098963,83.4453125 161.1875,83.4453125 L159.820313,83.4453125 L159.625,80.7109375 L159.625,77.9765625 L144.195313,77.78125 L128.765625,77.78125 L128.179688,79.1484375 C127.658852,80.1901094 127.138023,80.9713516 126.617188,81.4921875 C125.966143,82.1432324 125.315107,82.6315088 124.664063,82.9570312 C124.013018,83.2825537 123.166672,83.4453125 122.125,83.4453125 L120.757813,83.4453125 L120.757813,43.2109375 Z M159.625,49.0703125 L129.15625,49.0703125 L129.15625,59.03125 L159.625,59.03125 L159.625,49.0703125 Z M159.625,62.9375 L129.15625,62.9375 L129.15625,74.0703125 L159.625,74.0703125 L159.625,62.9375 Z M239.898438,3.171875 L248.296875,3.171875 L248.296875,11.5703125 L248.492188,19.96875 L259.234375,19.96875 L270.171875,20.1640625 L270.171875,17.4296875 L274.46875,17.4296875 L278.765625,17.625 L278.765625,30.515625 C278.765625,39.3698359 278.700521,44.2525996 278.570312,45.1640625 C278.440104,46.0755254 278.244793,46.9869746 277.984375,47.8984375 C277.593748,48.6796914 277.007816,49.5260371 276.226562,50.4375 C275.445309,51.2187539 274.664066,51.739582 273.882812,52 C273.101559,52.260418 272.320316,52.390625 271.539062,52.390625 L270.171875,52.390625 L270.171875,48.09375 L248.296875,48.09375 L248.296875,71.4335938 C248.296875,73.191415 248.231771,74.3958301 248.101562,75.046875 C247.841145,75.8281289 247.58073,76.5442676 247.320312,77.1953125 L246.148438,78.7578125 C245.627602,79.2786484 244.911463,79.7994766 244,80.3203125 C243.088537,80.7109395 242.177088,80.90625 241.265625,80.90625 L239.898438,80.90625 L239.898438,48.09375 L216.851562,48.09375 L216.265625,49.0703125 C216.005207,49.5911484 215.614586,50.1119766 215.09375,50.6328125 C214.572914,51.0234395 213.986982,51.3815088 213.335938,51.7070312 C212.684893,52.0325537 211.838547,52.260416 210.796875,52.390625 L209.234375,52.390625 L209.234375,17.4296875 L217.632812,17.4296875 L217.632812,20.1640625 L228.765625,19.96875 L239.703125,19.96875 L239.898438,11.5703125 L239.898438,3.171875 Z M239.703125,23.6796875 L217.632813,23.6796875 L217.632813,44.3828125 L228.765625,44.3828125 L239.703125,44.1875 L239.703125,23.6796875 Z M270.171875,23.6796875 L248.296875,23.6796875 L248.296875,44.3828125 L270.171875,44.3828125 L270.171875,23.6796875 Z",h,t,"center","middle");this.svg.appendChild(e)},e.prototype.paintTitle=function(){var t=.25*this.width,e=this._drawSVGText(a,o,t,"center","center");this.svg.appendChild(e),this._title=e},e.prototype.updateText=function(t){this._text&&this.svg.removeChild(this._text),this._drawText(t)},e.prototype.exportImage=function(){var t=this,e=function(){var t=!1;return function(e){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(t=!0)}(navigator.userAgent||navigator.vendor||window.opera),t}(),s=document.createElement("svg");s.setAttribute("width","400"),s.setAttribute("height","600"),this._text&&this.svg.removeChild(this._text);var i=U("g");i.innerHTML=this.svg.innerHTML,i.setAttribute("transform","translate(0, 90)"),s.appendChild(i);(function(t,e){var s=+t.getAttribute("width"),i=+t.getAttribute("height"),n=document.createElement("canvas");n.width=s*e,n.height=i*e;var r=n.getContext("2d");r.fillStyle="white",r.fillRect(0,0,n.width,n.height),t.setAttribute("xmlns",j);var o=new Image;return new Promise(function(a,h){o.onload=function(){r.drawImage(o,0,0,s,i,0,0,s*e,i*e),a(n)},o.onerror=function(t){alert("保存图片失败,建议使用截图生成图片。"),h(t)},o.src="data:image/svg+xml,"+encodeURIComponent(t.outerHTML)})})(s,2).then(function(s){t._wrapCanvas(s,2).then(function(){var i=s.toDataURL("image/png");if(e){var n=document.createElement("img");n.setAttribute("src",i),n.setAttribute("class","full-img");for(var r=document.getElementsByTagName("svg"),o=r.length,a=0;a<o;++a)document.body.removeChild(r[0]);document.body.appendChild(n),document.getElementById("hint").style.display="block"}else{var h=document.createElement("a");h.download="moonight.png",h.href=i.replace(/^data:image\/[^;]/,"data:application/octet-stream"),h.click(),t.svg.appendChild(t._text)}})})},e.prototype._wrapCanvas=function(t,e){var s=t.getContext("2d"),i=W.canvas(t),n=.4*e;s.save(),s.translate(25*e,505*e),s.scale(n,n),i.path(a,{fill:"black",fillStyle:"zigzag"}),s.restore(),s.font="22px Arial, sans-serif",s.fillStyle="#777",s.fillText("https://umeecorn.com/moonight",25*e,560*e),s.fillText("GitHub: Ovilia/moonight",25*e,575*e);var r=parseInt(this._text.style.font,10);s.font=r*e+"px xiaowei";var o=+this._text.getAttribute("x"),h=+this._text.getAttribute("y")+90;s.fillStyle="black",s.textAlign="center",s.textBaseline="middle",s.fillText(this._textStr,o*e,h*e);var l=new Image;return new Promise(function(t,i){l.onload=function(){s.drawImage(l,310*e,510*e,70*e,70*e),t()},l.onerror=function(){i()},l.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAIAAABMXPacAAADsElEQVR4nO2dUW7cMAxEN0Xuumfa06Z/jlFIpjikPAb63lcRKLKyA1JcmmS/fn5+XuDjj/sA/zsIYOb7+Nf7/W7c9/P5XC84HndeecMZzo84FsyeGy6oHwwLMIMAZhDAzPfwp6EHHxI6Ss3/pp4b+v2Q8Lm9Hw4WYAYBzIxd0EFovCl7HEacYRg68zBaINsb9dY/HyzADAKYQQAzwR3wNMKI84wWL94MFmAGAcwggJntd8DMa6876FnkPozBU18UNmWbU2ABZhDATOCC6pFcyvxTkeXQw2w65MovamABZhDADAKYGd8BjWGZnEzWLonUDtot0huzYgFmEMAMApj5vQNuSN6m0gDrl8Smg53Z9+FgAWYQwMzXdX9AqmpKq0iQyxRSIWnjDr3pECzADAKYQQAzQSpCLlu73jb8YWo3uTpveIZNu80egQWYQQAzCGCmszo6jJpTi8Pz1PPV2oIU4W5YgBkEMPObitB8wozGzo56OqQ329HbtIIFmEEAMwhgJugTlocobOo0TqGdQcs2zxaEO2ABZhDADAKY6WzQqEfNm/qwZ/5XS03X89VnsAAzCGBmXJilmb/mH+RhM9prO42wvHcGLujpIIAZBDDTObayt2RMy3akbrJ67nq905iqiIeCAGYQwEwiFbFpDEOYyJ1Rf4dan3G5fkjS0Q8FAcwEVRFnNvVJyYWxvQUQ6zv0pmyxADMIYAYBzCTmBaV8rhbhpSLL+jCfxnyJvBILMIMAZhDATOJ7wJn1UTzhDjPW74Pe9u7hznJrSbgYCzCDAGbGsyIaG7jCbWeP0N5GaakIubRWeNYLF/QoEMAMApgZV0XcGSMakxkh9RaPg9nJsQAzCGAGAcwEM+POaK8A5RD7zrnCcphfvyyxADMIYCYxskzzNnLV6jqpZuawSeR6q38W16NeLMAMAphBADNBKmLmPddrb8/Uy9bO3DBX+PpZs+emwALMIIAZBDCTSEVohDH4DWPp5Cy3VluX+nKABZhBADOdfcJn6mPF69YdLlj/k/c5MSzADAKYQQAzwdjKFPU3YqlO43qUuU5vrMwbsQeBAGYQwEzn/6AREg50691tfdtwLF0dUhEPBQHMdE7OHSLX/B6L61VT8tCz9UOmFpzBAswggBkEMLP9DpjRW+p7vYNcjdHb7jEECzCDAGYQwExiXpBGfeJQ7/h6Lcyvj6NgdPFDQQAzQYPGzawPRH9l/IM8S2b9t8JHkw19KAhgBgHMbC/OhWuwADMIYAYBzPwFJ/DSUkYe4GEAAAAASUVORK5CYII="})},e.prototype._drawBars=function(t,e,s,i,n){for(var r=this.width/2,o=this.height/2,a=0;a<t.length;++a){var h=t[a]||0,l=Math.max(s*h,4),c=i*a+Math.PI,p=Math.cos(c-n),u=Math.sin(c-n),f=Math.cos(c+n),d=Math.sin(c+n),g=this.rc.polygon([[r+p*e,o+u*e],[r+p*(e+l),o+u*(e+l)],[r+f*(e+l),o+d*(e+l)],[r+f*e,o+d*e]],{bowing:3});this.svg.appendChild(g)}var y=this.rc.circle(r,o,2*e-14,{roughness:.5});this.svg.appendChild(y)},e.prototype._drawText=function(t){var e=this;if(t.length<1||t.length>9)console.warn("Illegal word length");else{var s=U("text");s.onclick=function(){var t=window.prompt("输入 1-9 个文字","今夜月色真美");t.length>0&&t.length<10?e.updateText(t):alert("文字应在 1-9 个字符")},s.setAttribute("x",this.width/2+""),s.setAttribute("y",this.height/2+""),s.setAttribute("fill","black"),s.setAttribute("text-anchor","middle"),s.setAttribute("alignment-baseline","central"),s.textContent=t,this.svg.appendChild(s);var i=[80,64,46,34,28,22,20,16,14][t.length-1];s.style.font=i+"px xiaowei",this._text=s,this._textStr=t}},e.prototype._drawSVGText=function(t,e,s,i,n,r){var o=this.rc.path(t,{fill:"black",fillStyle:"zigzag",roughness:.8}),a=s/e[0],h=a*e[1],l="translate("+("left"===i?r:"right"===i?this.width-s-r:(this.width-s)/2)+" "+("top"===n?r:"bottom"===n?this.height-h-r:(this.height-h)/2)+")",c="scale("+a+")";return o.setAttribute("transform",l+" "+c),o},e}(F);function Y(t){var e=function(t){for(var e=Number.NEGATIVE_INFINITY,s=0;s<t.length;++s)t[s]>e&&(e=t[s]);return e}(t);if(e>0)for(var s=0;s<t.length;++s)t[s]=t[s]/e;return t}function V(){return!!X()}function X(){var t=window;return t.AudioContext||t.webkitAudioContext||null}function $(){return navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function H(){return!!MediaRecorder}function J(t,e,s){0}var K=function(){function t(){this.recorder=null}return t.prototype.fromRecord=function(t){var e=this;return new Promise(function(e,s){var i=new FileReader;i.onloadend=function(){e(i.result)},i.onerror=function(t){J(0,0,JSON.stringify(t)),s(t)},i.readAsArrayBuffer(t.getData())}).then(function(t){return e.fromArrayBuffer(t)})},t.prototype.fromFile=function(t){var e=this;return new Promise(function(e,s){var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){e(i.response)},i.onerror=function(t){J(0,0,JSON.stringify(t)),s(t)},i.send()}).then(function(t){return e.fromArrayBuffer(t)})},t.prototype.fromArrayBuffer=function(t){return new Promise(function(e,s){(new(X())).decodeAudioData(t,function(t){var s=t.getChannelData(0);e(s)},function(t){console.error(t),J(0,0,JSON.stringify(t)),s(t)})})},t.prototype.recordStart=function(){this.recorder||(this.recorder=new r,this.recorder.start())},t.prototype.recordStop=function(){this.recorder&&this.recorder.stop()},t.prototype.getDisplayTimeDomainData=function(t,e){return J(0,0,t.length),Y(function(t,e){for(var s=0,i=Math.ceil(t.length/e),n=new Array(e),r=0,o=0;o<e;++r)if(s+=Math.abs(t[r]),r%i==i-1){var a=s/i;n[o]=isNaN(a)?0:a,++o,s=0}return n}(function(t,e){for(var s=t,i=0;i<t.length;++i)if(t[i]>e&&i>0){s=t.slice(i);break}for(i=s.length-1;i>=0;--i)if(t[i]>e&&i<s.length-1){s=s.slice(0,i+1);break}return s}(Y(function(t){for(var e=0;e<t.length;++e)t[e]=Math.abs(t[e]);return t}(Array.prototype.slice.call(t))),.05),e))},t}(),tt=function(){function t(e,s,i){this.svg=e,this.rc=s,this.isDown=!1,this._svgGroup=U("g"),this.svg.appendChild(this._svgGroup),this.isShow=!1,i?this.setStyle(i):this.style=t.defaultStyle,this._initEvent()}return t.prototype.show=function(){this.isShow=!0,this._svgGroup.style.visibility="visible",this.redraw()},t.prototype.hide=function(){this.isShow=!1,this._svgGroup.style.visibility="hidden"},t.prototype.redraw=function(){this.isShow&&this._isDirty?(this.clear(),this._drawBackground(),this._drawIcon(),this._setClickable()):this._isDirty=!0},t.prototype.setDown=function(t){this.isDown!==t&&(this.isDown=t,this.redraw())},t.prototype.setStyle=function(e){this.style=Object.assign({},t.defaultStyle,this.style,e),this.redraw()},t.prototype.clear=function(){this._svgGroup.innerHTML=""},t.prototype.onclick=function(t){this._onClick=t},t.prototype._drawIcon=function(){},t.prototype._drawBackground=function(){var t=this.style.x,e=this.style.y,s=2*this.style.radius,i=this.style.depth;if(this.isDown){a=this.rc.circle(t,e+i,s);this._svgGroup.appendChild(a)}else{var n=this.rc.arc(t,e+i,s,s,0,Math.PI,!0,{fill:"black",fillStyle:"zigzag"});this._svgGroup.appendChild(n);var r=this.rc.line(t-this.style.radius,e,t-this.style.radius,e+i,{roughness:.2});this._svgGroup.appendChild(r);var o=this.rc.line(t+this.style.radius,e,t+this.style.radius,e+i,{roughness:.2});this._svgGroup.appendChild(o);var a=this.rc.circle(t,e,s,{fill:"white",fillStyle:"solid"});this._svgGroup.appendChild(a)}},t.prototype._initEvent=function(){var t=this;this._svgGroup.addEventListener("mousedown",function(){t.setDown(!0)}),this._svgGroup.addEventListener("mouseup",function(e){"function"==typeof t._onClick&&t._onClick(e),t.setDown(!1)})},t.prototype._setClickable=function(){for(var t=this._svgGroup.children,e=0;e<t.length;++e)t[e].setAttribute("pointer-events","visible")},t.defaultStyle={x:0,y:0,radius:25,padding:10,depth:8},t}(),et=function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(e,s)};return function(e,s){function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),st=function(t){function e(e,s,i){var n=t.call(this,e,s,i)||this;return n.svg=e,n.rc=s,n}return et(e,t),e.prototype._drawIcon=function(){var t=2*(this.style.radius-this.style.padding)*.9,e=this.isDown?this.style.depth:0,s=this.rc.circle(this.style.x,this.style.y+e,t,{fill:"black",fillStyle:"zigzag"});this._svgGroup.appendChild(s)},e}(tt),it=function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(e,s)};return function(e,s){function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),nt=function(t){function e(e,s,i){var n=t.call(this,e,s,i)||this;return n.svg=e,n.rc=s,n}return it(e,t),e.prototype._drawIcon=function(){var t=2*(this.style.radius-this.style.padding)*.85/2,e=this.style.x,s=this.style.y,i=this.isDown?this.style.depth:0,n=this.rc.linearPath([[e,s-t+i],[e,s+t+i],[e-t,s+i],[e,s+t+i],[e+t,s+i],[e,s+t+i],[e-t,s+t+i],[e+t,s+t+i]]);this._svgGroup.appendChild(n)},e}(tt),rt=function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(e,s)};return function(e,s){function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),ot=function(t){function e(e,s,i){var n=t.call(this,e,s,i)||this;return n.svg=e,n.rc=s,n}return rt(e,t),e.prototype._drawIcon=function(){var t=2*(this.style.radius-this.style.padding)*.8,e=this.isDown?this.style.depth:0,s=this.rc.linearPath([[this.style.x-t/2,this.style.y-t/2+e],[this.style.x+t/2,this.style.y+t/2+e]]);this._svgGroup.appendChild(s);var i=this.rc.linearPath([[this.style.x-t/2,this.style.y+t/2+e],[this.style.x+t/2,this.style.y-t/2+e]]);this._svgGroup.appendChild(i)},e}(tt),at=function(){var t=function(e,s){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(e,s)};return function(e,s){function i(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(i.prototype=s.prototype,new i)}}(),ht=function(t){function e(e,s,i){var n=t.call(this,e,s,i)||this;return n.svg=e,n.rc=s,n}return at(e,t),e.prototype._drawIcon=function(){var t=2*(this.style.radius-this.style.padding)*.8,e=this.isDown?this.style.depth:0,s=this.rc.rectangle(this.style.x-t/2,this.style.y+e-t/2,t,t,{fill:"black",fillStyle:"zigzag"});this._svgGroup.appendChild(s)},e}(tt),lt=function(){function t(t){this.svg=t,this.buttons=[];var e=q(t,400,80);this.width=e.width,this.height=e.height,t.setAttribute("width",this.width+""),t.setAttribute("height",this.height+""),this.btnRadius=25,this.btnMargin=10,this.rc=W.svg(t)}return t.prototype.addButton=function(t,e){null==e&&(e=this.buttons.length),this.buttons.splice(e,0,t),this._renderButtons(),t.setDown(!1),t.show()},t.prototype.removeButton=function(t){if(t)for(var e=0;e<this.buttons.length;++e)if(this.buttons[e]===t)return this.buttons.splice(e,1),t.hide(),void this._renderButtons()},t.prototype._renderButtons=function(){for(var t=this.buttons.length,e=2*(this.btnRadius+this.btnMargin),s=e*t,i=(this.width-s)/2,n=0;n<t;++n)this.buttons[n].setStyle({x:i+e*n+this.btnRadius,y:this.height/2})},t}();s(1);var ct,pt,ut,ft,dt=new K;function gt(){ct.paint(i,""),ct.paintTitle()}window.onload=function(){if("undefined"!=typeof wx||/micromessenger/i.test(navigator.userAgent)){var t=document.getElementById("hint");t.innerHTML="右上角在 Safari 中打开",t.style.display="block"}else!function(){ft={};var t=document.getElementById("gui");window.innerWidth<400&&(t.style["margin-left"]=-window.innerWidth/2+"px");function e(){J(),pt.stop().then(function(){return dt.fromRecord(pt)}).then(function(e){var s=dt.getDisplayTimeDomainData(e,64);ct.paint(s,"点击修改文字"),ft.download||(ft.download=new nt(t,ut.rc),ft.download.onclick(n)),ut.addButton(ft.download)}).catch(function(t){console.log(t),gt()}),i()}function s(){J(),gt(),i(),pt.stop().catch(function(t){console.log(t),gt()})}function i(){ut.removeButton(ft.cancel),ut.removeButton(ft.stop),ut.removeButton(ft.download),ut.addButton(ft.record)}function n(){J(),ct.exportImage()}ut=new lt(t),ft.record=new st(t,ut.rc),ft.record.onclick(function(){J(),ct.paintLoading(),ft.stop||(ft.stop=new ht(t,ut.rc),ft.stop.onclick(e));ft.cancel||(ft.cancel=new ot(t,ut.rc),ft.cancel.onclick(s));ut.addButton(ft.stop),ut.addButton(ft.cancel),ut.removeButton(ft.record),ut.removeButton(ft.download),pt.start().catch(function(t){console.log(t),gt()})}),ut.addButton(ft.record)}();J(0,0,H()),J(0,0,V()),J(0,0,$()),H()&&V()&&$()||(location.href="not-supported.html");n({audio:!0,video:!1}).then(function(t){t.getTracks().forEach(function(t){return t.stop()})});var e=document.getElementById("main-svg");window.innerWidth<400&&(e.style["margin-left"]=-window.innerWidth/2+"px");ct=new Q(e),gt(),pt=new r}}]);