cnchar-draw
Version:
功能全面、多端支持的汉字拼音笔画 js 库
2 lines • 56.7 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.cncharDraw=e():t.cncharDraw=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){(function(t,e){!function(){"use strict";function n(t){var e=this.constructor;return this.then((function(n){return e.resolve(t()).then((function(){return n}))}),(function(n){return e.resolve(t()).then((function(){return e.reject(n)}))}))}function r(t){return!(!t||void 0===t.length)}function i(){}function o(t){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(t,this)}function s(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,o._immediateFn((function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void h(e.promise,t)}a(e.promise,r)}else(1===t._state?a:h)(e.promise,t._value)}))):t._deferreds.push(e)}function a(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof n)return void c(function(t,e){return function(){t.apply(e,arguments)}}(n,e),t)}t._state=1,t._value=e,u(t)}catch(e){h(t,e)}}function h(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&o._immediateFn((function(){t._handled||o._unhandledRejectionFn(t._value)}));for(var e=0,n=t._deferreds.length;n>e;e++)s(t,t._deferreds[e]);t._deferreds=null}function c(t,e){var n=!1;try{t((function(t){n||(n=!0,a(e,t))}),(function(t){n||(n=!0,h(e,t))}))}catch(t){if(n)return;n=!0,h(e,t)}}var l=setTimeout;o.prototype.catch=function(t){return this.then(null,t)},o.prototype.then=function(t,e){var n=new this.constructor(i);return s(this,new function(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}(t,e,n)),n},o.prototype.finally=n,o.all=function(t){return new o((function(e,n){function i(t,r){try{if(r&&("object"==typeof r||"function"==typeof r)){var a=r.then;if("function"==typeof a)return void a.call(r,(function(e){i(t,e)}),n)}o[t]=r,0==--s&&e(o)}catch(t){n(t)}}if(!r(t))return n(new TypeError("Promise.all accepts an array"));var o=Array.prototype.slice.call(t);if(0===o.length)return e([]);for(var s=o.length,a=0;o.length>a;a++)i(a,o[a])}))},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o((function(e){e(t)}))},o.reject=function(t){return new o((function(e,n){n(t)}))},o.race=function(t){return new o((function(e,n){if(!r(t))return n(new TypeError("Promise.race accepts an array"));for(var i=0,s=t.length;s>i;i++)o.resolve(t[i]).then(e,n)}))},o._immediateFn="function"==typeof t&&function(e){t(e)}||function(t){l(t,0)},o._unhandledRejectionFn=function(t){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var f=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw Error("unable to locate global object")}();"Promise"in f?f.Promise.prototype.finally||(f.Promise.prototype.finally=n):f.Promise=o}()}).call(this,n(2).setImmediate,n(0))},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(3),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(0))},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,s,a,h=1,u={},c=!1,l=t.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(t);f=f&&f.setTimeout?f:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){d(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){d(t.data)},r=function(t){o.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,r=function(t){var e=l.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(d,0,t)}:(s="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(s)&&d(+e.data.slice(s.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),r=function(e){t.postMessage(s+e,"*")}),f.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var i={callback:t,args:e};return u[h]=i,r(h),h++},f.clearImmediate=p}function p(t){delete u[t]}function d(t){if(c)setTimeout(d,0,t);else{var e=u[t];if(e){c=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(void 0,n)}}(e)}finally{p(t),c=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n(0),n(4))},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var h,u=[],c=!1,l=-1;function f(){c&&h&&(c=!1,h.length?u=h.concat(u):l=-1,u.length&&p())}function p(){if(!c){var t=a(f);c=!0;for(var e=u.length;e;){for(h=u,u=[];++l<e;)h&&h[l].run();l=-1,e=u.length}h=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function g(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];u.push(new d(t,e)),1!==u.length||c||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){"use strict";n.r(e);var r;n(1);var i,o,s,a,h=(o="https://unpkg.com/cnchar-data@latest/"+(i="draw")+"/",s=function(){return o},a="",(r={setResourceBase:function(t){a=t},getResourceBase:function(){return a||s()||o},initResourceFromCnchar:function(t){var e=t._.getResourceBase();e&&(s=function(){return""+e+i+"/"})}}).getResourceBase),u=r.setResourceBase,c=r.initResourceFromCnchar;
/*! Hanzi Writer v2.2.2 | https://chanind.github.io/hanzi-writer */const l=[];function f(t){l.forEach(e=>{e(t)})}var p=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.t?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e,n){(function(e){var n="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},r=e.performance&&function(){return e.performance.now()}||function(){return Date.now()},i=e.requestAnimationFrame||function(t){return setTimeout((function(){return t(r())}),1e3/60)},o=e.cancelAnimationFrame||clearTimeout,s=function(t){for(var e=Object(t),n=arguments.length,r=Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.forEach((function(t){if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})),e},a=Object.assign||s,h=0,u=e.navigator&&e.navigator.userAgent||"",c=0<u.indexOf("MSIE ")||0<u.indexOf("Trident/")||0<u.indexOf("Edge/");t.exports={e:s,arrLast:function(t){return t[t.length-1]},assign:a,average:function(t){return t.reduce((function(t,e){return e+t}),0)/t.length},callIfExists:function(t,e){return t&&t(e),e},cancelAnimationFrame:o,colorStringToVals:function(t){var e=t.toUpperCase().trim();if(/^#([A-F0-9]{3}){1,2}$/.test(e)){var n=e.substring(1).split("");3===n.length&&(n=[n[0],n[0],n[1],n[1],n[2],n[2]]);var r=""+n.join("");return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16),a:1}}var i=e.match(/^RGBA?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d*\.?\d+))?\)$/);if(i)return{r:parseInt(i[1],10),g:parseInt(i[2],10),b:parseInt(i[3],10),a:parseFloat(i[4]||1,10)};throw new Error("Invalid color: "+t)},copyAndMergeDeep:function t(e,r){var i=a({},e);for(var o in r){var s=e[o],h=r[o];s!==h&&(s&&h&&"object"===(void 0===s?"undefined":n(s))&&"object"===(void 0===h?"undefined":n(h))&&!Array.isArray(h)?i[o]=t(s,h):i[o]=h)}return i},counter:function(){return++h},emptyFunc:function(){},inflate:function(t,e){for(var n=t.split("."),r={},i=r,o=0;o<n.length;o++){var s=o===n.length-1?e:{};i[n[o]]=s,i=s}return r},objRepeat:function(t,e){for(var n={},r=0;r<e;r++)n[r]=t;return n},performanceNow:r,requestAnimationFrame:i,timeout:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(e,n){setTimeout(e,t)}))},trim:function(t){return t.replace(/^\s+/,"").replace(/\s+$/,"")},isMsBrowser:c}}).call(e,n(1))},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var r=n(0),i=r.average,o=r.arrLast,s=function(t,e){return{x:t.x-e.x,y:t.y-e.y}},a=function(t){return Math.sqrt(Math.pow(t.x,2)+Math.pow(t.y,2))},h=function(t,e){return a(s(t,e))},u=function(t){var e=10*(1<arguments.length&&void 0!==arguments[1]?arguments[1]:1);return{x:Math.round(e*t.x)/e,y:Math.round(e*t.y)/e}},c=function(t){var e=t[0];return t.slice(1).reduce((function(t,n){var r=h(n,e);return e=n,t+r}),0)},l=function(t,e,n){var r=s(e,t),i=n/a(r);return{x:e.x+i*r.x,y:e.y+i*r.y}},f=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.05,n=t.slice(0,1);return t.slice(1).forEach((function(t){var r=n[n.length-1],i=h(t,r);if(e<i)for(var o=Math.ceil(i/e),s=i/o,a=0;a<o;a++)n.push(l(t,r,-1*s*(a+1)));else n.push(t)})),n},p=function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:30,n=c(t)/(e-1),r=[t[0]],i=o(t),s=t.slice(1),a=0;a<e-2;a++)for(var u=o(r),f=n,p=!1;!p;){var d=h(u,s[0]);if(d<f)f-=d,u=s.shift();else{var g=l(u,s[0],f-d);r.push(g),p=!0}}return r.push(i),r},d=function(t){if(t.length<3)return t;var e=[t[0],t[1]];return t.slice(2).forEach((function(t,n){var r=e.length,i=s(t,e[r-1]),o=s(e[r-1],e[r-2]);i.y*o.x-i.x*o.y==0&&e.pop(),e.push(t)})),e};t.exports={round:u,equals:function(t,e){return t.x===e.x&&t.y===e.y},distance:h,getPathString:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=u(t[0]),r=t.slice(1),i="M "+n.x+" "+n.y;return r.forEach((function(t){var e=u(t);i+=" L "+e.x+" "+e.y})),e&&(i+="Z"),i},frechetDist:function(t,e){for(var n=[],r=0;r<t.length;r++){n.push([]);for(var i=0;i<e.length;i++)n[r].push(-1)}return function r(i,o){return-1<n[i][o]||(n[i][o]=0===i&&0===o?h(t[0],e[0]):0<i&&0===o?Math.max(r(i-1,0),h(t[i],e[0])):0===i&&0<o?Math.max(r(0,o-1),h(t[0],e[o])):0<i&&0<o?Math.max(Math.min(r(i-1,o),r(i-1,o-1),r(i,o-1)),h(t[i],e[o])):1/0),n[i][o]}(t.length-1,e.length-1)},length:c,rotate:function(t,e){return t.map((function(t){return{x:Math.cos(e)*t.x-Math.sin(e)*t.y,y:Math.sin(e)*t.x+Math.cos(e)*t.y}}))},subtract:s,extendStart:function(t,e){var n=d(t);if(n.length<2)return n;var r=n[1],i=n[0],o=l(r,i,e),s=n.slice(1);return s.unshift(o),s},cosineSimilarity:function(t,e){return(t.x*e.x+t.y*e.y)/a(t)/a(e)},outlineCurve:p,u:l,h:d,subdivideCurve:f,normalizeCurve:function(t){var e=p(t),n={x:i(e.map((function(t){return t.x}))),y:i(e.map((function(t){return t.y})))},r=e.map((function(t){return s(t,n)})),a=Math.sqrt(i([Math.pow(r[0].x,2)+Math.pow(r[0].y,2),Math.pow(o(r).x,2)+Math.pow(o(r).y,2)])),h=r.map((function(t){return{x:t.x/a,y:t.y/a}}));return f(h)}}},function(t,e,n){(function(e){function n(t,e,n){t.setAttributeNS(null,e,n)}t.exports={createElm:function(t){return e.document.createElementNS("http://www.w3.org/2000/svg",t)},attrs:function(t,e){Object.keys(e).forEach((function(r){return n(t,r,e[r])}))},attr:n,removeElm:function(t){t&&t.parentNode.removeChild(t)},urlIdRef:function(t){var n="";return e.location&&e.location.href&&(n=e.location.href.replace(/#[^#]*$/,"")),"url("+n+"#"+t+")"}}}).call(e,n(1))},function(t,e,n){function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var i=n(5),o=n(0).objRepeat,s=function(t,e,n){return[new i("character."+t+".strokes",o({opacity:1,displayPortion:1},e.strokes.length),{duration:n,force:!0})]},a=function(t,e,n){return[new i("character."+t+".opacity",0,{duration:n,force:!0})].concat(s(t,e,0))},h=function(t,e,n){var o=e.strokeNum,s=(e.getLength()+600)/(3*n);return[new i("character."+t,{opacity:1,strokes:r({},o,{displayPortion:0,opacity:1})}),new i("character."+t+".strokes."+o+".displayPortion",1,{duration:s})]},u=function(t,e,n,r,u){var c=a(t,e,n);return(c=c.concat(s(t,e,0))).push(new i("character."+t,{opacity:1,strokes:o({opacity:0},e.strokes.length)},{force:!0})),e.strokes.forEach((function(e,n){0<n&&c.push(new i.Delay(u)),c=c.concat(h(t,e,r))})),c};t.exports={showStrokes:s,showCharacter:function(t,e,n){return[new i("character."+t,{opacity:1,strokes:o({opacity:1,displayPortion:1},e.strokes.length)},{duration:n,force:!0})]},hideCharacter:a,highlightStroke:function(t,e,n){var o=t.strokeNum,s=(t.getLength()+600)/(3*n);return[new i("character.highlight.strokeColor",e),new i("character.highlight",{opacity:1,strokes:r({},o,{displayPortion:0,opacity:0})}),new i("character.highlight.strokes."+o,{displayPortion:1,opacity:1},{duration:s}),new i("character.highlight.strokes."+o+".opacity",0,{duration:s})]},animateCharacter:u,animateCharacterLoop:function(t,e,n,r,o,s){var a=u(t,e,n,r,o);return a.push(new i.Delay(s)),a},animateStroke:h,animateSingleStroke:function(t,e,n,r){return[new i("character."+t,(function(n){for(var r=n.character[t],i={opacity:1,strokes:{}},o=0;o<e.strokes.length;o++)i.strokes[o]={opacity:r.opacity*r.strokes[o].opacity};return i}))].concat(h(t,e.strokes[n],r))},showStroke:function(t,e,n){return[new i("character."+t+".strokes."+e,{displayPortion:1,opacity:1},{duration:n,force:!0})]},updateColor:function(t,e,n){return[new i("options."+t,e,{duration:n})]}}},function(t,e,n){var r=n(0),i=r.inflate,o=r.performanceNow,s=r.requestAnimationFrame,a=r.cancelAnimationFrame;function h(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.scope=t,this.f=e,this.v=n.duration||0,this.w=n.force,this.k=0,this.C=this.M.bind(this),this.S=null}function u(t){this.v=t,this.j=null,this.P=!1}h.prototype.run=function(t){var e=this;return this.O||this.A(t),0===this.v&&t.updateState(this.O),0===this.v||function t(e,n){for(var r in n)if(n.hasOwnProperty(r)){var i=n[r],o=e[r];if(0<=i){if(i!==o)return!1}else if(!t(o,i))return!1}return!0}(t.state,this.O)?Promise.resolve():(this.F=t,this.D=t.state,this.j=o(),this.T=s(this.C),new Promise((function(t){e.I=t})))},h.prototype.pause=function(){null===this.S&&(this.T&&a(this.T),this.S=o())},h.prototype.resume=function(){null!==this.S&&(this.T=s(this.C),this.k+=o()-this.S,this.S=null)},h.prototype.M=function(t){if(null===this.S){var e,n=Math.min(1,(t-this.j-this.k)/this.v);if(1===n)this.F.updateState(this.O),this.T=null,this.cancel(this.F);else{var r=(e=n,-Math.cos(e*Math.PI)/2+.5);this.F.updateState(function t(e,n,r){var i={};for(var o in n){var s=n[o],a=e[o];i[o]=0<=s?r*(s-a)+a:t(a,s,r)}return i}(this.D,this.O,r)),this.T=s(this.C)}}},h.prototype.A=function(t){var e=this.f;"function"==typeof this.f&&(e=this.f(t.state)),this.O=i(this.scope,e)},h.prototype.cancel=function(t){this.I&&this.I(),this.I=null,this.T&&a(this.T),this.T=null,this.w&&(this.O||this.A(t),t.updateState(this.O))},u.prototype.pause=function(){if(!this.P){var t=o()-this.j;this.v=Math.max(0,this.v-t),clearTimeout(this.W),this.P=!0}},u.prototype.resume=function(){var t=this;this.P&&(this.j=o(),this.W=setTimeout((function(){return t.cancel()}),this.v),this.P=!1)},u.prototype.run=function(){var t=this,e=new Promise((function(e){t.I=e}));return this.j=o(),this.W=setTimeout((function(){return t.cancel()}),this.v),e},u.prototype.cancel=function(){clearTimeout(this.W),this.I&&this.I(),this.I=!1},h.Delay=u,t.exports=h},function(t,e,n){function r(){}r.prototype.z=function(t){return.999*this.R*(1-t)},r.prototype.H=function(t){var e=t.strokeColor,n=t.radicalColor;return n&&this.L.isInRadical?n:e},t.exports=r},function(t,e,n){(function(e){function n(){}n.prototype.addPointerStartListener=function(t){var e=this;this.node.addEventListener("mousedown",(function(n){t(e.U(n,e._))})),this.node.addEventListener("touchstart",(function(n){t(e.U(n,e.K))}))},n.prototype.addPointerMoveListener=function(t){var e=this;this.node.addEventListener("mousemove",(function(n){t(e.U(n,e._))})),this.node.addEventListener("touchmove",(function(n){t(e.U(n,e.K))}))},n.prototype.addPointerEndListener=function(t){e.document.addEventListener("mouseup",t),e.document.addEventListener("touchend",t)},n.prototype.getBoundingClientRect=function(){return this.node.getBoundingClientRect()},n.prototype.U=function(t,e){var n=this;return{getPoint:function(){return e.call(n,t)},preventDefault:function(){return t.preventDefault()}}},n.prototype._=function(t){var e=this.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}},n.prototype.K=function(t){var e=this.getBoundingClientRect();return{x:t.touches[0].clientX-e.left,y:t.touches[0].clientY-e.top}},t.exports=n}).call(e,n(1))},function(t,e,n){t.exports={drawPath:function(t,e){t.beginPath();var n=e[0],r=e.slice(1);t.moveTo(n.x,n.y),r.forEach((function(e){t.lineTo(e.x,e.y)})),t.stroke()},pathStringToCanvas:function(t){var e=t.split(/(^|\s+)(?=[A-Z])/).filter((function(t){return" "!==t})),n=[function(t){return t.beginPath()}];return e.forEach((function(t){var e,r=(e=t.split(/\s+/),Array.isArray(e)?e:Array.from(e)),i=r[0],o=r.slice(1).map((function(t){return parseFloat(t)}));"M"===i?n.push((function(t){return t.moveTo.apply(t,o)})):"L"===i?n.push((function(t){return t.lineTo.apply(t,o)})):"C"===i?n.push((function(t){return t.bezierCurveTo.apply(t,o)})):"Q"===i&&n.push((function(t){return t.quadraticCurveTo.apply(t,o)}))})),function(t){return n.forEach((function(e){return e(t)}))}}}},function(t,e,n){var r=n(10),i=n(11),o=n(14),s=n(15),a=n(19),h=n(25),u=n(31),c=n(32),l=n(4),f=n(0),p=f.assign,d=f.callIfExists,g=f.trim,y=f.colorStringToVals,v={charDataLoader:u,onLoadCharDataError:null,onLoadCharDataSuccess:null,showOutline:!0,showCharacter:!0,renderer:"svg",width:null,height:null,padding:20,strokeAnimationSpeed:1,strokeFadeDuration:400,strokeHighlightDuration:200,strokeHighlightSpeed:2,delayBetweenStrokes:1e3,delayBetweenLoops:2e3,strokeColor:"#555",radicalColor:null,highlightColor:"#AAF",outlineColor:"#DDD",drawingColor:"#333",leniency:1,showHintAfterMisses:3,highlightOnComplete:!0,highlightCompleteColor:null,drawingFadeDuration:300,drawingWidth:4,strokeWidth:2,outlineWidth:2,rendererOverride:{}};function m(){if(0<arguments.length){var t=void 0,e={},n=arguments.length<=0?void 0:arguments[0];1<arguments.length&&(e="string"==typeof(arguments.length<=1?void 0:arguments[1])?(console.warn("Using new HanziWriter() to set a character is deprecated. Use HanziWriter.create() instead"),t=arguments.length<=1?void 0:arguments[1],(arguments.length<=2?void 0:arguments[2])||{}):arguments.length<=1?void 0:arguments[1]),this.N(n,e),t&&this.setCharacter(t)}}m.prototype.showCharacter=function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return this.B.showCharacter=!0,this.G((function(){return t.F.run(l.showCharacter("main",t.V,"number"==typeof e.duration?e.duration:t.B.strokeFadeDuration)).then((function(t){return d(e.onComplete,t)}))}))},m.prototype.hideCharacter=function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return this.B.showCharacter=!1,this.G((function(){return t.F.run(l.hideCharacter("main",t.V,"number"==typeof e.duration?e.duration:t.B.strokeFadeDuration)).then((function(t){return d(e.onComplete,t)}))}))},m.prototype.animateCharacter=function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return this.cancelQuiz(),this.G((function(){return t.F.run(l.animateCharacter("main",t.V,t.B.strokeFadeDuration,t.B.strokeAnimationSpeed,t.B.delayBetweenStrokes)).then((function(t){return d(e.onComplete,t)}))}))},m.prototype.animateStroke=function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.cancelQuiz(),this.G((function(){return e.F.run(l.animateSingleStroke("main",e.V,t,e.B.strokeAnimationSpeed)).then((function(t){return d(n.onComplete,t)}))}))},m.prototype.highlightStroke=function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.G((function(){return e.F.run(l.highlightStroke(e.V.strokes[t],e.B.highlightColor,e.B.strokeHighlightSpeed)).then((function(t){return d(n.onComplete,t)}))}))},m.prototype.loopCharacterAnimation=function(){var t=this;return this.cancelQuiz(),this.G((function(){return t.F.run(l.animateCharacterLoop("main",t.V,t.B.strokeFadeDuration,t.B.strokeAnimationSpeed,t.B.delayBetweenStrokes,t.B.delayBetweenLoops),{loop:!0})}))},m.prototype.pauseAnimation=function(){var t=this;return this.G((function(){return t.F.pauseAll()}))},m.prototype.resumeAnimation=function(){var t=this;return this.G((function(){return t.F.resumeAll()}))},m.prototype.showOutline=function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return this.B.showOutline=!0,this.G((function(){return t.F.run(l.showCharacter("outline",t.V,"number"==typeof e.duration?e.duration:t.B.strokeFadeDuration)).then((function(t){return d(e.onComplete,t)}))}))},m.prototype.hideOutline=function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return this.B.showOutline=!1,this.G((function(){return t.F.run(l.hideCharacter("outline",t.V,"number"==typeof e.duration?e.duration:t.B.strokeFadeDuration)).then((function(t){return d(e.onComplete,t)}))}))},m.prototype.updateColor=function(t,e){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return this.G((function(){var i="number"==typeof r.duration?r.duration:n.B.strokeFadeDuration,o=e;"radicalColor"!==t||e||(o=n.B.strokeColor);var s=y(o);n.B[t]=e;var a=l.updateColor(t,s,i);return"radicalColor"!==t||e||(a=a.concat(l.updateColor(t,null,0))),n.F.run(a).then((function(t){return d(r.onComplete,t)}))}))},m.prototype.quiz=function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.G((function(){t.cancelQuiz(),t.$=new s(t.V,t.F,t.q),t.$.startQuiz(p({},t.B,e))}))},m.prototype.cancelQuiz=function(){this.$&&(this.$.cancel(),this.$=null)},m.prototype.setCharacter=function(t){var e=this;return this.cancelQuiz(),this.text=t,this.Q&&this.Q.destroy(),this.F&&this.F.cancelAll(),this.Q=null,this.Z=this.X.loadCharData(t).then((function(n){if(!e.X.loadingFailed){e.V=i(t,n),e.q=new o(e.B);var s=new e.Y.HanziWriterRenderer(e.V,e.q);e.Q=s,e.F=new r(e.V,e.B,(function(t){s.render(t)})),e.Q.mount(e.target,e.F.state),e.Q.render(e.F.state)}})),this.Z},m.prototype.N=function(t,e){var n="canvas"===e.renderer?h:a,r=e.rendererOverride||{};return this.Y={HanziWriterRenderer:r.HanziWriterRenderer||n.HanziWriterRenderer,createRenderTarget:r.createRenderTarget||n.createRenderTarget},this.target=this.Y.createRenderTarget(t,e.width,e.height),this.B=this.tt(e),this.X=new c(this.B),this.it(),this.$=null,this},m.prototype.tt=function(t){var e=p({},v,t);return t.strokeAnimationDuration&&!t.strokeAnimationSpeed&&(e.strokeAnimationSpeed=500/e.strokeAnimationDuration),t.strokeHighlightDuration&&!t.strokeHighlightSpeed&&(e.strokeHighlightSpeed=500/e.strokeHighlightDuration),t.highlightCompleteColor||(e.highlightCompleteColor=e.highlightColor),this.nt(e)},m.prototype.nt=function(t){var e=p({},t);if(e.width&&!e.height)e.height=e.width;else if(e.height&&!e.width)e.width=e.height;else if(!e.width&&!e.height){var n=this.target.getBoundingClientRect(),r=n.width,i=n.height,o=Math.min(r,i);e.width=o,e.height=o}return e},m.prototype.G=function(t){var e=this;if(this.X.loadingFailed)throw Error("Failed to load character data. Call setCharacter and try again.");return this.Z.then((function(){if(!e.X.loadingFailed)return t()}))},m.prototype.it=function(){var t=this;this.target.addPointerStartListener((function(e){!t.isLoadingCharData&&t.$&&(e.preventDefault(),t.rt("startUserStroke",e.getPoint()))})),this.target.addPointerMoveListener((function(e){!t.isLoadingCharData&&t.$&&(e.preventDefault(),t.rt("continueUserStroke",e.getPoint()))})),this.target.addPointerEndListener((function(){return t.rt("endUserStroke")}))},m.prototype.rt=function(t){var e;if(this.$){for(var n=arguments.length,r=Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];(e=this.$)[t].apply(e,r)}},m.create=function(t,e){var n=new m(t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:{});return n.setCharacter(e),n};var w=null,k=null;m.loadCharacterData=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=void 0;return n=w&&k===e?w:new c(p({},v,e)),k=e,(w=n).loadCharData(t)},m.getScalingTransform=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=new o({width:t,height:e,padding:n});return{x:r.xOffset,y:r.yOffset,scale:r.scale,transform:g("\n translate("+r.xOffset+", "+(r.height-r.yOffset)+")\n scale("+r.scale+", "+-1*r.scale+")\n ").replace(/\s+/g," ")}},t.exports=m},function(t,e,n){var r=n(0),i=r.copyAndMergeDeep,o=r.colorStringToVals;function s(t,e,n){this.ot=n,this.st=[],this.state={options:{drawingFadeDuration:e.drawingFadeDuration,drawingWidth:e.drawingWidth,drawingColor:o(e.drawingColor),strokeColor:o(e.strokeColor),outlineColor:o(e.outlineColor),radicalColor:o(e.radicalColor||e.strokeColor),highlightColor:o(e.highlightColor)},character:{main:{opacity:e.showCharacter?1:0,strokes:{}},outline:{opacity:e.showOutline?1:0,strokes:{}},highlight:{opacity:1,strokes:{}}},userStrokes:null};for(var r=0;r<t.strokes.length;r++)this.state.character.main.strokes[r]={opacity:1,displayPortion:1},this.state.character.outline.strokes[r]={opacity:1,displayPortion:1},this.state.character.highlight.strokes[r]={opacity:0,displayPortion:1}}s.prototype.updateState=function(t){var e=i(this.state,t);this.ot(e,this.state),this.state=e},s.prototype.run=function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=t.map((function(t){return t.scope})).filter((function(t){return t}));return this.cancelMutations(r),new Promise((function(i){var o={et:!0,ut:0,I:i,ht:t,at:n.loop,ct:r};e.st.push(o),e.ft(o)}))},s.prototype.ft=function(t){var e=this;if(t.et){var n=t.ht;if(t.ut>=n.length){if(!t.at)return t.et=!1,this.st=this.st.filter((function(e){return e!==t})),void t.I({canceled:!1});t.ut=0}t.ht[t.ut].run(this).then((function(){t.et&&(t.ut++,e.ft(t))}))}},s.prototype.vt=function(){return this.st.map((function(t){return t.ht[t.ut]}))},s.prototype.pauseAll=function(){this.vt().forEach((function(t){return t.pause()}))},s.prototype.resumeAll=function(){this.vt().forEach((function(t){return t.resume()}))},s.prototype.cancelMutations=function(t){var e=this;this.st.forEach((function(n){n.ct.forEach((function(r){t.forEach((function(t){(0<=r.indexOf(t)||0<=t.indexOf(r))&&e.lt(n)}))}))}))},s.prototype.cancelAll=function(){this.cancelMutations([""])},s.prototype.lt=function(t){t.et=!1;for(var e=t.ut;e<t.ht.length;e++)t.ht[e].cancel(this);t.I&&t.I({canceled:!0}),this.st=this.st.filter((function(e){return e!==t}))},t.exports=s},function(t,e,n){var r=n(12),i=n(13),o=function(t){return t.strokes.map((function(e,n){var i,o=t.medians[n].map((function(t){var e=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}(t,2);return{x:e[0],y:e[1]}}));return new r(e,o,n,(i=n,t.radStrokes&&0<=t.radStrokes.indexOf(i)))}))};t.exports=function(t,e){var n=o(e);return new i(t,n)}},function(t,e,n){var r=n(2),i=r.subtract,o=r.distance,s=r.length;function a(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]&&arguments[3];this.path=t,this.points=e,this.strokeNum=n,this.isInRadical=r}a.prototype.getStartingPoint=function(){return this.points[0]},a.prototype.getEndingPoint=function(){return this.points[this.points.length-1]},a.prototype.getLength=function(){return s(this.points)},a.prototype.getVectors=function(){var t=this.points[0];return this.points.slice(1).map((function(e){var n=i(e,t);return t=e,n}))},a.prototype.getDistance=function(t){var e=this.points.map((function(e){return o(e,t)}));return Math.min.apply(Math,e)},a.prototype.getAverageDistance=function(t){var e=this;return t.reduce((function(t,n){return t+e.getDistance(n)}),0)/t.length},t.exports=a},function(t,e,n){t.exports=function(t,e){this.symbol=t,this.strokes=e}},function(t,e,n){var r=[{x:0,y:-124},{x:1024,y:900}];function i(t){this.B=t,this.width=t.width,this.height=t.height,this.dt()}i.prototype.convertExternalPoint=function(t){return{x:(t.x-this.xOffset)/this.scale,y:(this.height-this.yOffset-t.y)/this.scale}},i.prototype.dt=function(){var t=r,e=t[1].x-t[0].x,n=t[1].y-t[0].y,i=this.width-2*this.B.padding,o=this.height-2*this.B.padding,s=i/e,a=o/n;this.scale=Math.min(s,a);var h=this.B.padding+(i-this.scale*e)/2,u=this.B.padding+(o-this.scale*n)/2;this.xOffset=-1*t[0].x*this.scale+h,this.yOffset=-1*t[0].y*this.scale+u},t.exports=i},function(t,e,n){var r=n(16),i=n(17),o=n(0),s=o.callIfExists,a=o.counter,h=n(18),u=n(2),c=n(4),l=function(t){return{pathString:u.getPathString(t.externalPoints),points:t.points.map((function(t){return u.round(t)}))}};function f(t,e,n){this.V=t,this.F=e,this.et=!1,this.q=n}f.prototype.startQuiz=function(t){this.et=!0,this.B=t,this.pt=0,this.yt=0,this.wt=0,this.gt=[],this.F.run(h.startQuiz(this.V,t.strokeFadeDuration))},f.prototype.startUserStroke=function(t){var e=this.q.convertExternalPoint(t);if(!this.et)return null;if(this.kt)return this.endUserStroke();var n=a();this.kt=new i(n,e,t),this.F.run(h.startUserStroke(n,e))},f.prototype.continueUserStroke=function(t){if(this.kt){var e=this.q.convertExternalPoint(t);this.kt.appendPoint(e,t);var n=this.kt.points.slice(0);this.F.run(h.updateUserStroke(this.kt.id,n))}},f.prototype.endUserStroke=function(){if(this.kt)if(this.F.run(h.removeUserStroke(this.kt.id,this.B.drawingFadeDuration)),1!==this.kt.points.length){var t=this.mt(),e=0<this.F.state.character.outline.opacity;r(this.kt,this.V,this.pt,{isOutlineVisible:e,leniency:this.B.leniency})?this.bt(t):(this.Ct(),this.yt>=this.B.showHintAfterMisses&&this.F.run(h.highlightStroke(t,this.B.highlightColor,this.B.strokeHighlightSpeed))),this.kt=null}else this.kt=null},f.prototype.cancel=function(){this.et=!1,this.kt&&this.F.run(h.removeUserStroke(this.kt.id,this.B.drawingFadeDuration))},f.prototype.bt=function(t){s(this.B.onCorrectStroke,{character:this.V.symbol,strokeNum:this.pt,mistakesOnStroke:this.yt,totalMistakes:this.wt,strokesRemaining:this.V.strokes.length-this.pt-1,drawnPath:l(this.kt)});var e=c.showStroke("main",this.pt,this.B.strokeFadeDuration);this.pt+=1,this.yt=0,this.pt===this.V.strokes.length&&(this.et=!1,s(this.B.onComplete,{character:this.V.symbol,totalMistakes:this.wt}),this.B.highlightOnComplete&&(e=e.concat(h.highlightCompleteChar(this.V,this.B.highlightCompleteColor,2*this.B.strokeHighlightDuration)))),this.F.run(e)},f.prototype.Ct=function(){this.yt+=1,this.wt+=1,s(this.B.onMistake,{character:this.V.symbol,strokeNum:this.pt,mistakesOnStroke:this.yt,totalMistakes:this.wt,strokesRemaining:this.V.strokes.length-this.pt,drawnPath:l(this.kt)})},f.prototype.mt=function(){return this.V.strokes[this.pt]},t.exports=f},function(t,e,n){var r=n(0),i=r.average,o=r.assign,s=n(2),a=s.cosineSimilarity,h=s.equals,u=s.frechetDist,c=s.distance,l=s.subtract,f=s.normalizeCurve,p=s.rotate,d=s.length,g=function(t,e){var n,r,o,s=(r=[],o=(n=t)[0],n.slice(1).forEach((function(t){r.push(l(t,o)),o=t})),r),h=e.getVectors(),u=s.map((function(t){var e=h.map((function(e){return a(e,t)}));return Math.max.apply(Math,e)}));return 0<i(u)},y=[Math.PI/16,Math.PI/32,0,-1*Math.PI/32,-1*Math.PI/16],v=function(t,e,n){var r=n.leniency,i=void 0===r?1:r,o=n.isOutlineVisible,s=void 0!==o&&o,a=e.getAverageDistance(t),h=a<=350*(s||0<e.strokeNum?.5:1)*i;if(!h)return{isMatch:!1,avgDist:a};var l,v,m,w,k,C,S,x,b,T,O,E,P=(l=t,m=i,w=c((v=e).getStartingPoint(),l[0]),k=c(v.getEndingPoint(),l[l.length-1]),w<=250*m&&k<=250*m),M=g(t,e),A=(C=t,S=e.points,x=i,b=f(C),T=f(S),O=1/0,y.forEach((function(t){var e=u(b,p(T,t));e<O&&(O=e)})),O<=.4*x),_=(E=e,.35<=i*(d(t)+25)/(E.getLength()+25));return{isMatch:h&&P&&M&&A&&_,avgDist:a}};t.exports=function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},i=function(t){if(t.length<2)return t;var e=[t[0]];return t.slice(1).forEach((function(t){h(t,e[e.length-1])||e.push(t)})),e}(t.points);if(i.length<2)return null;var s=v(i,e.strokes[n],r);if(!s.isMatch)return!1;for(var a=e.strokes.slice(n+1),u=s.avgDist,c=0;c<a.length;c++){var l=v(i,a[c],r);l.isMatch&&l.avgDist<u&&(u=l.avgDist)}if(u<s.avgDist){var f=.6*(u+s.avgDist)/(2*s.avgDist),p=(r.leniency||1)*f,d=o({},r,{leniency:p});return v(i,e.strokes[n],d).isMatch}return!0}},function(t,e,n){function r(t,e,n){this.id=t,this.points=[e],this.externalPoints=[n]}r.prototype.appendPoint=function(t,e){this.points.push(t),this.externalPoints.push(e)},t.exports=r},function(t,e,n){var r=n(5),i=n(4),o=n(0).objRepeat;t.exports={highlightCompleteChar:function(t,e,n){return[new r("character.highlight.strokeColor",e)].concat(i.hideCharacter("highlight",t)).concat(i.showCharacter("highlight",t,n/2)).concat(i.hideCharacter("highlight",t,n/2))},highlightStroke:i.highlightStroke,startQuiz:function(t,e){return i.hideCharacter("main",t,e).concat([new r("character.highlight",{opacity:1,strokes:o({opacity:0},t.strokes.length)},{force:!0}),new r("character.main",{opacity:1,strokes:o({opacity:0},t.strokes.length)},{force:!0})])},startUserStroke:function(t,e){return[new r("quiz.activeUserStrokeId",t,{force:!0}),new r("userStrokes."+t,{points:[e],opacity:1},{force:!0})]},updateUserStroke:function(t,e){return[new r("userStrokes."+t+".points",e,{force:!0})]},removeUserStroke:function(t,e){return[new r("userStrokes."+t+".opacity",0,{duration:e}),new r("userStrokes."+t,null,{force:!0})]}}},function(t,e,n){var r=n(20),i=n(24);t.exports={HanziWriterRenderer:r,createRenderTarget:i.init}},function(t,e,n){var r=n(21),i=n(23),o=n(0).assign,s=n(3);function a(t,e){this.V=t,this.q=e,this.Mt=new r(t),this.St=new r(t),this.jt=new r(t),this.Pt={}}a.prototype.mount=function(t){var e=t.createSubRenderTarget(),n=e.svg;s.attr(n,"transform","\n translate("+this.q.xOffset+", "+(this.q.height-this.q.yOffset)+")\n scale("+this.q.scale+", "+-1*this.q.scale+")\n "),this.St.mount(e),this.Mt.mount(e),this.jt.mount(e),this.xt=e},a.prototype.render=function(t){var e=this;this.St.render({opacity:t.character.outline.opacity,strokes:t.character.outline.strokes,strokeColor:t.options.outlineColor}),this.Mt.render({opacity:t.character.main.opacity,strokes:t.character.main.strokes,strokeColor:t.options.strokeColor,radicalColor:t.options.radicalColor}),this.jt.render({opacity:t.character.highlight.opacity,strokes:t.character.highlight.strokes,strokeColor:t.options.highlightColor});var n=t.userStrokes||{};Object.keys(this.Pt).forEach((function(t){n[t]||(e.Pt[t].destroy(),delete e.Pt[t])})),Object.keys(n).forEach((function(r){if(n[r]){var s=o({strokeWidth:t.options.drawingWidth,strokeColor:t.options.drawingColor},n[r]),a=e.Pt[r];a||((a=new i).mount(e.xt,s),e.Pt[r]=a),a.render(s)}}))},a.prototype.destroy=function(){s.removeElm(this.xt.svg),this.xt.defs.innerHTML=""},t.exports=a},function(t,e,n){var r=n(0).isMsBrowser,i=n(22);function o(t){this.Ot={},this.At=t.strokes.map((function(t){return new i(t)}))}o.prototype.mount=function(t){var e=t.createSubRenderTarget();this.Ft=e.svg,this.At.forEach((function(t,n){t.mount(e)}))},o.prototype.render=function(t){if(t!==this.Ot){t.opacity!==this.Ot.opacity&&(this.Ft.style.opacity=t.opacity,r||(0===t.opacity?this.Ft.style.display="none":0===this.Ot.opacity&&this.Ft.style.removeProperty("display")));var e=!this.Ot||t.strokeColor!==this.Ot.strokeColor||t.radicalColor!==this.Ot.radicalColor;if(e||t.strokes!==this.Ot.strokes)for(var n=0;n<this.At.length;n++)!e&&this.Ot.strokes&&t.strokes[n]===this.Ot.strokes[n]||this.At[n].render({strokeColor:t.strokeColor,radicalColor:t.radicalColor,opacity:t.strokes[n].opacity,displayPortion:t.strokes[n].displayPortion});this.Ot=t}},t.exports=o},function(t,e,n){var r=n(0).counter,i=n(3),o=n(2),s=o.extendStart,a=o.getPathString,h=n(6);function u(t){this.Ot={},this.L=t,this.R=t.getLength()+100}(u.prototype=Object.create(h.prototype)).mount=function(t){this.Dt=i.createElm("path"),this.Tt=i.createElm("clipPath"),this.Et=i.createElm("path");var e="mask-"+r();i.attr(this.Tt,"id",e),i.attr(this.Et,"d",this.L.path),this.Dt.style.opacity=0,i.attr(this.Dt,"clip-path",i.urlIdRef(e));var n=s(this.L.points,100);return i.attr(this.Dt,"d",a(n)),i.attrs(this.Dt,{stroke:"#FFFFFF","stroke-width":200,fill:"none","stroke-linecap":"round","stroke-linejoin":"miter","stroke-dasharray":this.R+","+this.R}),this.Tt.appendChild(this.Et),t.defs.appendChild(this.Tt),t.svg.appendChild(this.Dt),this},u.prototype.render=function(t){if(t!==this.Ot){t.displayPortion!==this.Ot.displayPortion&&(this.Dt.style.strokeDashoffset=this.z(t.displayPortion));var e=this.H(t);if(e!==this.H(this.Ot)){var n=e.r,r=e.g,o=e.b,s=e.a;i.attrs(this.Dt,{stroke:"rgba("+n+","+r+","+o+","+s+")"})}t.opacity!==this.Ot.opacity&&(this.Dt.style.opacity=t.opacity),this.Ot=t}},t.exports=u},function(t,e,n){var r=n(3),i=n(2).getPathString;function o(){this.Ot={}}o.prototype.mount=function(t){this.It=r.createElm("path"),t.svg.appendChild(this.It)},o.prototype.render=function(t){if(t!==this.Ot){if(t.strokeColor!==this.Ot.strokeColor||t.strokeWidth!==this.Ot.strokeWidth){var e=t.strokeColor,n=e.r,o=e.g,s=e.b,a=e.a;r.attrs(this.It,{fill:"none",stroke:"rgba("+n+","+o+","+s+","+a+")","stroke-width":t.strokeWidth,"stroke-linecap":"round","stroke-linejoin":"round"})}t.opacity!==this.Ot.opacity&&r.attr(this.It,"opacity",t.opacity),t.points!==this.Ot.points&&r.attr(this.It,"d",i(t.points)),this.Ot=t}},o.prototype.destroy=function(){r.removeElm(this.It)},t.exports=o},function(t,e,n){(function(e){var r=n(3),i=r.createElm,o=r.attrs,s=n(7);function a(t,e){this.svg=t,this.defs=e,this.node=t,this.node.createSVGPoint&&(this.Wt=this.node.createSVGPoint())}(a.prototype=Object.create(s.prototype)).createSubRenderTarget=function(){var t=i("g");return this.svg.appendChild(t),new a(t,this.defs)},a.prototype._=function(t){if(this.Wt){this.Wt.x=t.clientX,this.Wt.y=t.clientY;var e=this.Wt.matrixTransform(this.node.getScreenCTM().inverse());return{x:e.x,y:e.y}}return s.prototype._.call(this,t)},a.prototype.K=function(t){if(this.Wt){this.Wt.x=t.touches[0].clientX,this.Wt.y=t.touches[0].clientY;var e=this.Wt.matrixTransform(this.node.getScreenCTM().inverse());return{x:e.x,y:e.y}}return s.prototype.K.call(this,t)},a.init=function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"100%",r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"100%",s=void 0,h=t;if("string"==typeof t&&(h=e.document.getElementById(t)),!h)throw new Error("HanziWriter target element not found: "+t);var u=h.nodeName.toUpperCase();"SVG"===u||"G"===u?s=h:(s=i("svg"),h.appendChild(s)),o(s,{width:n,height:r});var c=i("defs");return s.appendChild(c),new a(s,c)},t.exports=a}).call(e,n(1))},function(t,e,n){var r=n(26),i=n(30);t.exports={HanziWriterRenderer:r,createRenderTarget:i.init}},function(t,e,n){var r=n(27),i=n(29),o=n(0).assign;function s(t,e){this.V=t,this.q=e,this.Mt=new r(t),this.St=new r(t),this.jt=new r(t)}s.prototype.mount=function(t){this.zt=t},s.prototype.Rt=function(t){var e=this.zt.getContext();e.clearRect(0,0,this.q.width,this.q.height),e.save(),e.translate(this.q.xOffset,this.q.height-this.q.yOffset),e.transform(1,0,0,-1,0,0),e.scale(this.q.scale,this.q.scale),t(e),e.restore(),e.draw&&e.draw()},s.prototype.render=function(t){var e=this;this.Rt((function(n){e.St.render(n,{opacity:t.character.outline.opacity,strokes:t.character.outline.strokes,strokeColor:t.options.outlineColor}),e.Mt.render(n,{opacity:t.character.main.opacity,strokes:t.character.main.strokes,strokeColor:t.options.strokeColor,radicalColor:t.options.radicalColor}),e.jt.render(n,{opacity:t.character.highlight.opacity,strokes:t.character.highlight.strokes,strokeColor:t.options.highlightColor});var r=t.userStrokes||{};Object.keys(r).forEach((function(e){if(r[e]){var s=o({strokeWidth:t.options.drawingWidth,strokeColor:t.options.drawingColor},r[e]);i(n,s)}}))}))},s.prototype.destroy=function(){},t.exports=s},function(t,e,n){var r=n(28);function i(t){this.At=t.strokes.map((function(t){return new r(t)}))}i.prototype.render=function(t,e){if(!(e.opacity<.05))for(var n=0;n<this.At.length;n++)this.At[n].render(t,{strokeColor:e.strokeColor,radicalColor:e.radicalColor,opacity:e.strokes[n].opacity*e.opacity,displayPortion:e.strokes[n].displayPortion})},t.exports=i},function(t,e,n){(function(e){var r=n(2).extendStart,i=n(8),o=i.drawPath,s=i.pathStringToCanvas,a=n(6);function h(t){var n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];this.L=t,this.R=t.getLength()+100,n&&e.Path2D?this.Ht=new e.Path2D(this.L.path):this.Lt=s(this.L.path),this.Ut=r(this.L.points,100)}(h.prototype=Object.create(a.prototype)).render=function(t,e){if(!(e.opacity<.05)){t.save(),this.Ht?t.clip(this.Ht):(this.Lt(t),t.globalAlpha=0,t.stroke(),t.clip());var n=this.H(e),r=n.r,i=n.g,s=n.b,a=n.a,h=1===a?"rgb("+r+","+i+","+s+")":"rgb("+r+","+i+","+s+","+a+")",u=this.z(e.displayPortion);t.globalAlpha=e.opacity,t.strokeStyle=h,t.fillStyle=h,t.lineWidth=200,t.lineCap="round",t.lineJoin="round",t.setLineDash([this.R,this.R],u),t.lineDashOffset=u,o(t,this.Ut),t.restore()}},t.exports=h}).call(e,n(1))},function(t,e,n){var r=n(8).drawPath;t.exports=function(t,e){if(!(e.opacity<.05)){var n=e.strokeColor,i=n.r,o=n.g,s=n.b,a=n.a;t.save(),t.globalAlpha=e.opacity,t.lineWidth=e.strokeWidth,t.strokeStyle="rgba("+i+","+o+","+s+","+a+")",t.lineCap="round",t.lineJoin="round",r(t,e.points),t.restore()}}},function(t,e,n){(function(e){var r=n(7);function i(t){this.node=t}(i.prototype=Object.create(r.prototype)).getContext=function(){return this.node.getContext("2d")},i.init=function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"100%",r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"100%",o=void 0,s=t;if("string"==typeof t&&(s=e.document.getElementById(t)),!s)throw new Error("HanziWriter target element not found: "+t);return"CANVAS"===s.nodeName.toUpperCase()?o=s:(o=e.document.createElement("canvas"),s.appendChild(o)),o.setAttribute("width",n),o.setAttribute("height",r),new i(o)},t.exports=i}).call(e,n(1))},function(t,e,n){(function(e){t.exports=function(t,n,r){var i=new e.XMLHttpRequest;i.overrideMimeType&&i.overrideMimeType("application/json"),i.open("GET",h()+t+".json",!0),i.onerror=function(t){r(i,t)},i.onreadystatechange=function(){4===i.readyState&&(200===i.status?n(JSON.parse(i.responseText)):0!==i.status&&r&&r(i))},i.send(null)}}).call(e,n(1))},function(t,e,n){var r=n(0).callIfExists;function i(t){this._t=0,this.B=t,this.Kt=!1,this.loadingFailed=!1}i.prototype.Nt=function(t,e){var n=this,r=function(t){e===n._t&&n.I(t)},i=this.B.charDataLoader(t,r,(function(t){e===n._t&&n.Bt(t)}));i&&r(i)},i.prototype.Gt=function(){var t=this;return new Promise((function(e,n){t.I=e,t.Bt=n})).then((function(e){return t.Kt=!1,r(t.B.onLoadCharDataSuccess,e),e}),(function(e){if(t.Kt=!1,t.loadingFailed=!0,r(t.B.onLoadCharDataError,e),!t.B.onLoadCharDataError){const e=t.Vt;console.warn("Failed to load char data for "+e),f(e)}}))},i.prototype.loadCharData=function(t){this.Vt=t;var e=this.Gt();return this.loadingFailed=!1,this.Kt=!0,this._t++,this.Nt(t,this._t),e},t.exports=i}]),d={NORMAL:"normal",ANIMATION:"animation",STROKE:"stroke",TEST:"test"},g={MISTAKE:"mistake",CORRECT:"correct",COMPLETE:"complete"},y={showOutline:!0,showCharacter:!0,currentColor:"#b44",clear:!0,length:60,padding:5,outlineColor:"#ddd",backgroundColor:"#fff",strokeColor:"#555",radicalColor:null,strokeFadeDuration:400,lineStraight:!0,lineCross:!0,lineWidth:1,lineColor:"#ddd",lineDash:!0,border:!0,borderWidth:1,borderColor:"#ccc",borderDash:!1,strokeAnimationSpeed:1,delayBetweenStrokes:1e3,delayBetweenLoops:200,autoAnimate:!0,animateComplete:function(){},stepByStep:!0,loopAnimate:!1,strokeHighlightSpeed:20,highlightColor:"#aaf",drawingColor:"#333",drawingWidth:4,showHintAfterMisses:3,highlightOnComplete:!0,highlightCompleteColor:null,onTestStatus:null};function v(t){return void 0===t}function m(t,e){var n={};for(var r in e){var i=e[r];for(var o in i)v(i[o])||(n[o]=i[o])}return function(t,e){(e=e||Object.keys(y)).forEach((function(e){v(t[e])&&(t[e]=y[e])}))}(n),n.width=n.length,n.height=n.length,function(t,e,n){t===d.ANIMATION?e.animation&&!v(e.animation.showCharacter)||(n.showCharacter=!1):t===d.STROKE&&(n.showCharacter=!1)}(t,e,n),n}var w=function(t){var e;return 1===t.length?!!t.match(/[\u4e00-\u9fa5]/):(null===(e=t.match(/[\u4e00-\u9fa5]/g))||void 0===e?void 0:e.join("").length)===t.length};function k(t){var e=t.option,n=t.target,r=t.strokes,i=t.radStrokes,o=t.cloneSvg,s=t.current,a=t.width,h=i.length>0&&e.radicalColor?e.radicalColor:null,u=o(e);n.appendChild(u);var c=document.createElementNS("http://www.w3.org/2000/svg","g"),l=p.getScalingTransform(a,a,e.padding);c.setAttributeNS(null,"transform",l.transform),u.appendChild(c);for(var f=0;f<=s;f++){var d=e.strokeColor;f===s&&e.currentColor?d=e.currentColor:h&&-1!==i.indexOf(f)&&(d=h),C(r[f],c,d)}if(e.showOutline&&s+1<=r.length)for(f=s+1;f<r.length;f++)C(r[f],c,e.outlineColor)}function C(t,e,n){void 0===n&&(n="");var r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttributeNS(null,"d",t),r.style.fill=n,e.appendChild(r)}function S(t){if("string"!=typeof t)return t;var e,n=document.querySelector(t);return null===n&&(e="div",n=document.createElement(e),document.body.appendChild(n)),n}var x=0,b=1,T=2,O=function(){function t(t){this._strokeTimer=null,this.writer=t,this.option=t.option,this.writers=t.writers,this.isPaused=!1,this.drawMode=x,this.currentCharIndex=0,this.currentStrokeIndex=0,this.strokeDrawLocked=!1}return t.prototype._getCurrentCharStrokeNumber=function(){return this.curWriter.V.strokes.length},t.prototype._isStepMode=function(){return this.option.stepByStep},t.prototype._animate=function(t){var e=this;if(void 0===t&&(t=function(){}),this._isStepMode())!1===this.option.showCharacter&&this.writers.forEach((functio