!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Painter={})}(this,(function(t){"use strict";var e=function(){return e=Object.assign||function(t){for(var e,i=1,n=arguments.length;i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=360&&(s-=360);s<0&&(s+=360);if(0===(s=Math.round(s)))return{x0:Math.round(e/2)+n,y0:i+r,x1:Math.round(e/2)+n,y1:r};if(180===s)return{x0:Math.round(e/2)+n,y0:r,x1:Math.round(e/2)+n,y1:i+r};if(90===s)return{x0:n,y0:Math.round(i/2)+r,x1:e+n,y1:Math.round(i/2)+r};if(270===s)return{x0:e+n,y0:Math.round(i/2)+r,x1:n,y1:Math.round(i/2)+r};var a=Math.round(180*Math.asin(e/Math.sqrt(Math.pow(e,2)+Math.pow(i,2)))/Math.PI);if(s===a)return{x0:n,y0:i+r,x1:e+n,y1:r};if(s===180-a)return{x0:n,y0:r,x1:e+n,y1:i+r};if(s===180+a)return{x0:e+n,y0:r,x1:n,y1:i+r};if(s===360-a)return{x0:e+n,y0:i+r,x1:n,y1:r};var h=0,d=0,c=0,f=0;if(s180-a&&s<180||s>180&&s<180+a||s>360-a){var l=s*Math.PI/180,u=s360-a?i/2:-i/2,p=Math.tan(l)*u,g=s180-a&&s<180?e/2-p:-e/2-p;h=-(c=p+(v=Math.pow(Math.sin(l),2)*g)),d=-(f=u+v/Math.tan(l))}if(s>a&&s<90||s>90&&s<90+a||s>180+a&&s<270||s>270&&s<360-a){var v;l=(90-s)*Math.PI/180,p=s>a&&s<90||s>90&&s<90+a?e/2:-e/2,u=Math.tan(l)*p,g=s>a&&s<90||s>270&&s<360-a?i/2-u:-i/2-u;h=-(c=p+(v=Math.pow(Math.sin(l),2)*g)/Math.tan(l)),d=-(f=u+v)}return h=Math.round(h+e/2)+n,d=Math.round(i/2-d)+r,c=Math.round(c+e/2)+n,f=Math.round(i/2-f)+r,{x0:h,y0:d,x1:c,y1:f}}(r,t,e,i,n),a=s.x0,h=s.y0,d=s.x1,c=s.y1,f=o.createLinearGradient(a,h,d,c),l=r.match(/linear-gradient\((.+)\)/)[1],u=E(l.substring(l.indexOf(",")+1)),p=0;pt.length)&&(e=t.length);for(var i=0,n=new Array(e);i=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(t){return"number"==typeof t}function X(t){return"auto"===t||null===t}function N(t){return/%$/.test(t)}var q=v,V=g,G=p,J=y,Q=x,Z=S,K=z;function et(t){t=t.trim();for(var e=new Array,i="+",n="",r=t.length,o=0;o0;)"("===t[a+=1]&&(s+=1),")"===t[a]&&(s-=1);n="".concat(et(t.slice(o+1,a))),o=a}if(isNaN(Number(t[o]))&&"."!==t[o]||o===r-1){var h=parseFloat(n);switch(i){case"+":e.push(h);break;case"-":e.push(-h);break;case"*":e.push(e.pop()*h);break;case"/":e.push(e.pop()/h)}i=t[o],n=""}}for(var d=0;e.length;)d+=e.pop();return d}var it,nt=0,rt=function(){function t(){H(this,"elements",[]),H(this,"afterElements",[]),H(this,"beforeElements",[]),H(this,"ids",[]),H(this,"width",0),H(this,"height",0),H(this,"top",0),H(this,"left",0),H(this,"pre",null),H(this,"offsetX",0),H(this,"offsetY",0),nt++,this.id=nt}var e=t.prototype;return e.fixedBind=function(t,e){void 0===e&&(e=0),this.container=e?t.parent:t.root,this.container.fixedLine=this,this.fixedAdd(t)},e.fixedAdd=function(t){if(!this.ids.includes(t.id)){this.ids.push(t.id),this.elements.push(t);var e=t.computedStyle.zIndex;(void 0===e?0:e)>=0?this.afterElements.push(t):this.beforeElements.push(t),this.refreshLayout()}},e.bind=function(t){this.container=t.parent,this.container.line=null,this.container.lines?(this.container.lines.push(this),this.pre=this.getPreLine(),this.top=this.pre.top+this.pre.height,this.left=this.container.contentSize.left):(this.top=this.container.contentSize.top,this.left=this.container.contentSize.left,this.container.lines=[this]),this.isInline=t.isInline(),this.container.line=this,this.outerWidth=t.parent&&t.parent.contentSize.width?t.parent.contentSize.width:1/0,this.add(t)},e.getPreLine=function(){return this.container.lines[this.container.lines.length-2]},e.canIEnter=function(t){return this.outerWidth||t.parent&&t.parent.contentSize.width,!((100*t.offsetSize.width+100*this.width)/100>this.outerWidth)||(this.closeLine(),!1)},e.closeLine=function(){delete this.container.line},e.add=function(t){this.ids.includes(t.id)||(this.ids.push(t.id),this.elements.push(t),this.refreshWidthHeight(t))},e.refreshWidthHeight=function(t){t.offsetSize.height>this.height&&(this.height=t.offsetSize.height),this.width+=t.offsetSize.width||0,(this.container.lineMaxWidth||0)this[this.key.height]&&(this.container[this.key.lineMaxHeight]=this[this.key.height]=i),this[this.key.width]+=this.getWidth(t.offsetSize);var n=Math.min(this.getWidth(this),!this.getWidth(this.container.contentSize)&&1/0);(this.container[this.key.lineMaxWidth]||0)1)return 0;var e=t.style.alignSelf,i=this.getHeight(this.container.contentSize),n=i-this.getHeight(t.offsetSize);return"flex-end"===e?n:"center"===e?n/2:"stretch"===e?(n&&"view"==t.name&&(t.style[this.key.width]=this.getWidth(t.offsetSize),t.style[this.key.height]=i,delete t.line,delete t.lines,t.getBoxWidthHeight()),0):0},r.layout=function(t,e){var i=this;this.refreshXAlign(),this.pre?(this.top=this.pre.top+this.pre.height+this.offsetY,this.left=e+this.offsetX):(this.top=Math.max(this.top,this.container.contentSize.top,t)+this.offsetY,this.left=Math.max(this.left,this.container.contentSize.left,e)+this.offsetX),this.elements.forEach((function(t,e){i.setIndent(t);var n=i.elements[e-1],r=i.getOffsetY(t);t.style[i.key.top]=i[i.key.top]+r,t.style[i.key.left]=n?n.offsetSize[i.key.left]+i.getWidth(n.offsetSize):i[i.key.left],t.getBoxPosition()}))},n}(rt),at=v,ht=g,dt=p,ct=b,ft=x,lt=w,ut=S,pt=z,gt=0,vt={left:null,top:null,width:null,height:null},yt=function(){function t(t,i,n,r){var o=this;H(this,"id",gt++),H(this,"style",{left:null,top:null,width:null,height:null}),H(this,"computedStyle",{}),H(this,"originStyle",{}),H(this,"children",{}),H(this,"layoutBox",Y({},vt)),H(this,"contentSize",Y({},vt)),H(this,"clientSize",Y({},vt)),H(this,"borderSize",Y({},vt)),H(this,"offsetSize",Y({},vt)),this.ctx=r,this.root=n,i&&(this.parent=i),this.name=t.name||t.type,this.attributes=this.getAttributes(t);var s=function(t,i){var n=["color","fontSize","lineHeight","verticalAlign","fontWeight","textAlign"],r=t.css,o=void 0===r?{}:r,s=t.type,a=void 0===s?G:s,h=(i||{}).computedStyle,d=e({},W);if([V,q,J].includes(a)&&!o.display&&(d.display=Q),h)for(var c=0;c=0&&f<0,$=d>=0&&u<0;return i==o[0]&&(this[i].left=t.left+a+v+j+(Y?2*-f:0),this[i].top=t.top+d+b+B+($?2*-u:0),this[i].width=t.width+(this[i].widthAdd?0:E),this[i].height=t.height+(this[i].heightAdd?0:H),this[i].widthAdd=E,this[i].heightAdd=H),i==o[1]&&(this[i].left=t.left+a+j+(Y<0?-f:0),this[i].top=t.top+d+B+($?-u:0),this[i].width=t.width+v+m,this[i].height=t.height+b+S),i==o[2]&&(this[i].left=t.left+a+j/2+(Y<0?-f:0),this[i].top=t.top+d+B/2+($?-u:0),this[i].width=t.width+v+m+j/2+F/2,this[i].height=t.height+b+S+L/2+B/2),i==o[3]&&(this[i].left=t.left+(Y<0?-f:0),this[i].top=t.top+($?-u:0),this[i].width=t.width+v+m+j+F+a+f,this[i].height=t.height+b+S+L+B+u+d),this[i]},i.layoutBoxUpdate=function(t,e,i,n){var r=this;if(void 0===i&&(i=-1),"border-box"==e.boxSizing){var s=e||{},a=s.border,h=(a=void 0===a?{}:a).borderWidth,d=void 0===h?0:h,c=s.borderTop,f=(c=void 0===c?{}:c).borderTopWidth,l=void 0===f?d:f,u=s.borderBottom,p=(u=void 0===u?{}:u).borderBottomWidth,g=void 0===p?d:p,v=s.borderRight,y=(v=void 0===v?{}:v).borderRightWidth,b=void 0===y?d:y,x=s.borderLeft,m=(x=void 0===x?{}:x).borderLeftWidth,w=void 0===m?d:m,S=s.padding,z=(S=void 0===S?{}:S).paddingTop,M=void 0===z?0:z,I=S.paddingRight,W=void 0===I?0:I,k=S.paddingBottom,B=void 0===k?0:k,P=S.paddingLeft,R=void 0===P?0:P;i||(t.width-=R+W+b+w),1!==i||n||(t.height-=M+B+l+g)}this.layoutBox&&(o.forEach((function(i){return r.layoutBox[i]=r.getOffsetSize(t,e,i)})),this.layoutBox=Object.assign({},this.layoutBox,this.layoutBox.borderSize))},i.getBoxPosition=function(){var t=this.computedStyle,e=this.fixedLine,i=this.lines,n=t.left,r=void 0===n?0:n,o=t.top,s=void 0===o?0:o,a=t.padding||{},h=a.paddingBottom,d=void 0===h?0:h,c=a.paddingRight,f=void 0===c?0:c,l=Y({},this.contentSize,{left:r,top:s}),u=this.contentSize.top-this.offsetSize.top,p=this.contentSize.left-this.offsetSize.left;if(this.root.fixedLine&&!this.root.isDone){this.root.isDone=!0;for(var g,v=U(this.root.fixedLine.elements);!(g=v()).done;){var y=g.value;y.setPosition(y,this.root.offsetSize),y.getBoxPosition()}}if(e)for(var b,x=U(e.elements);!(b=x()).done;){var m=b.value;m.setPosition(m,l),m.style.left+=r+p+f,m.style.top+=s+u+d,m.getBoxPosition()}if(i)for(var w,S=U(i);!(w=S()).done;){w.value.layout(l.top+u,l.left+p)}return this.layoutBoxUpdate(l,t),this.layoutBox},i.getBoxState=function(t,e){return this.isBlock(t)||this.isBlock(e)},i.isBlock=function(t){return void 0===t&&(t=this),t&&t.style.display==ct},i.isFlex=function(t){return void 0===t&&(t=this),t&&t.style.display==lt},i.isInFlow=function(){return!(this.isAbsolute||this.isFixed)},i.inFlexBox=function(t){return void 0===t&&(t=this),!!t.isInFlow()&&(!!t.parent&&(!(!t.parent||t.parent.style.display!==lt)||void 0))},i.isInline=function(t){return void 0===t&&(t=this),t&&t.style.display==ft},i.contrastSize=function(t,e,i){var n=t;return i&&(n=Math.min(n,i)),e&&(n=Math.max(n,e)),n},i.measureText=function(t,e){var i=this.ctx.measureText(t),n=i.width,r=i.actualBoundingBoxAscent,o=i.actualBoundingBoxDescent;return{ascent:r,descent:o,width:n,fontHeight:r+o||.7*e+1}},i.getBoxWidthHeight=function(){var t=this,e=this.name,i=this.computedStyle,n=this.attributes,r=this.parent,o=void 0===r?{}:r,s=this.ctx,a=this.getChildren(),h=i.left,d=void 0===h?0:h,c=i.top,f=void 0===c?0:c,l=i.bottom,u=i.right,p=i.width,g=void 0===p?0:p,v=i.minWidth,y=i.maxWidth,b=i.minHeight,x=i.maxHeight,m=i.height,w=void 0===m?0:m,S=i.fontSize,z=void 0===S?14:S,M=i.fontWeight,I=i.fontFamily,W=i.fontStyle,k=i.position,B=i.lineClamp,P=i.lineHeight,R=i.padding,L=void 0===R?{}:R,O=i.margin,T=void 0===O?{}:O,A=i.border,C=(A=void 0===A?{}:A).borderWidth,j=void 0===C?0:C,E=i.borderRight,H=(E=void 0===E?{}:E).borderRightWidth,Y=void 0===H?j:H,$=i.borderLeft,D=($=void 0===$?{}:$).borderLeftWidth,U=void 0===D?j:D,_=o.contentSize&&o.contentSize.width,X=o.contentSize&&o.contentSize.height;if(N(g)&&_&&(g=F(g,_)),N(g)&&!_&&(g=null),N(w)&&X&&(w=F(w,X)),N(w)&&!X&&(w=null),N(v)&&_&&(v=F(v,_)),N(y)&&_&&(y=F(y,_)),N(b)&&X&&(b=F(b,X)),N(x)&&X&&(x=F(x,X)),i.padding&&_)for(var q in i.padding)Object.hasOwnProperty.call(i.padding,q)&&(i.padding[q]=F(i.padding[q],_));var V=L.paddingRight,G=void 0===V?0:V,J=L.paddingLeft,Q=void 0===J?0:J;if(i.margin&&[i.margin.marginLeft,i.margin.marginRight].includes("auto"))if(g){var Z=_&&_-g-G-Q-U-Y||0;i.margin.marginLeft==i.margin.marginRight?i.margin.marginLeft=i.margin.marginRight=Z/2:"auto"==i.margin.marginLeft?i.margin.marginLeft=Z:i.margin.marginRight=Z}else i.margin.marginLeft=i.margin.marginRight=0;var K=T.marginRight,tt=void 0===K?0:K,et=T.marginLeft,it={width:g,height:w,left:0,top:0},nt=Q+G+U+Y+(void 0===et?0:et)+tt;if(this.offsetWidth=nt,e==ht&&!this.attributes.widths){var ot=n.text||"";s.save(),s.setFonts({fontFamily:I,fontSize:z,fontWeight:M,fontStyle:W});var ct=new Map;ot.split("\n").map((function(e){var i=e.split("").map((function(e){var i=/^[\u4e00-\u9fa5]+$/.test(e)?"cn":e,n=ct.get(i);if(n)return{width:n,text:e};var r=t.measureText(e,z).width;return ct.set(i,r),{width:r,text:e}})),n=t.measureText(e,z),r=n.fontHeight,o=n.ascent,s=n.descent;t.attributes.fontHeight=r,t.attributes.ascent=o,t.attributes.descent=s,t.attributes.widths||(t.attributes.widths=[]),t.attributes.widths.push({widths:i,total:i.reduce((function(t,e){return t+e.width}),0)})})),s.restore()}if(e==at&&null==g){var ft=n.width,lt=n.height;it.width=this.contrastSize(Math.round(ft*w/lt)||0,v,y),this.layoutBoxUpdate(it,i,0)}if(e==ht&&null==g){var pt=this.attributes.widths,gt=Math.max.apply(Math,pt.map((function(t){return t.total})));if(o&&_>0&&(gt>_||this.isBlock(this))&&!this.isAbsolute&&!this.isFixed)gt=_;it.width=this.contrastSize(gt,v,y),this.layoutBoxUpdate(it,i,0)}if(e==ht&&(o.style.flex||!this.attributes.lines)){var vt=this.attributes.widths.length;this.attributes.widths.forEach((function(t){return t.widths.reduce((function(t,e,i){return t+e.width>it.width?(vt++,e.width):t+e.width}),0)})),vt=B&&vt>B?B:vt,this.attributes.lines=vt}if(e==at&&null==w){var yt=n.width,bt=n.height;it.height=this.contrastSize(F(it.width*bt/yt)||0,b,x),this.layoutBoxUpdate(it,i,1)}e==ht&&null==w&&(P=F(P,z),it.height=this.contrastSize(F(this.attributes.lines*P),b,x),this.layoutBoxUpdate(it,i,1,!0)),!g&&o&&o.children&&_&&(!this.isFlex(o)||o.isFlexCalc)&&([dt,ht].includes(e)&&this.isFlex()||e==dt&&this.isBlock(this)&&this.isInFlow())&&(it.width=this.contrastSize(_-(o.isFlexCalc?0:nt),v,y),this.layoutBoxUpdate(it,i)),g&&!N(g)&&(it.width=this.contrastSize(g,v,y),this.layoutBoxUpdate(it,i,0)),w&&!N(w)&&(it.height=this.contrastSize(it.height,b,x),this.layoutBoxUpdate(it,i,1));var xt=0;if(a.length){var mt=null;a.forEach((function(e,n){e.getBoxWidthHeight();var r=a[n+1];if(r&&r.isInFlow()&&(e.next=r),e.isInFlow()&&!e.inFlexBox()){var o=t.getBoxState(mt,e);t.line&&t.line.canIEnter(e)&&!o?t.line.add(e):(new rt).bind(e),mt=e}else e.inFlexBox()?t.line&&(t.line.canIEnter(e)||"nowrap"==i.flexWrap)?t.line.add(e):(new st).bind(e):e.isFixed?t.root.fixedLine?t.root.fixedLine.fixedAdd(e):(new rt).fixedBind(e):t.fixedLine?t.fixedLine.fixedAdd(e):(new rt).fixedBind(e,1)})),this.lines&&(xt=this.lines.reduce((function(t,e){return t+e.height}),0))}var wt=0,St=0;if(!g&&(this.isAbsolute||this.isFixed)&&_){var zt=k==ut?_:this.root.width,Mt=zt-(N(d)?F(d,zt):d)-(N(u)?F(u,zt):u);wt=i.left?Mt:this.lineMaxWidth}if(!w&&(null!=f?f:this.isAbsolute||this.isFixed&&X)){var It=k==ut?X:this.root.height,Wt=It-(N(f)?F(f,It):f)-(N(l)?F(l,It):l);St=i.top?Wt:0}if(g&&!N(g)||it.width||(it.width=wt||this.contrastSize((this.isBlock(this)&&!this.isInFlow()?_||o.lineMaxWidth:this.lineMaxWidth)||this.lineMaxWidth,v,y),this.layoutBoxUpdate(it,i,0)),w||!xt&&!St||(it.height=St||this.contrastSize(xt,b,x),this.layoutBoxUpdate(it,i)),i.borderRadius&&this.borderSize&&this.borderSize.width)for(var q in i.borderRadius)Object.hasOwnProperty.call(i.borderRadius,q)&&(i.borderRadius[q]=F(i.borderRadius[q],this.borderSize.width));return this.layoutBox},i.layout=function(){return this.getBoxWidthHeight(),this.root.offsetSize=this.offsetSize,this.getBoxPosition(),this.offsetSize},t}(),bt=function(){var t,e,i,n,r,o,s=[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28],a=[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177],h=[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107],d=[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,26,2,0,17,18,2,0,13,22,1,0,80,20,2,0,32,18,2,0,24,26,4,0,9,16,1,0,108,26,2,0,43,24,2,2,15,18,2,2,11,22,2,0,68,18,4,0,27,16,4,0,19,24,4,0,15,28,2,0,78,20,4,0,31,18,2,4,14,18,4,1,13,26,2,0,97,24,2,2,38,22,4,2,18,22,4,2,14,26,2,0,116,30,3,2,36,22,4,4,16,20,4,4,12,24,2,2,68,18,4,1,43,26,6,2,19,24,6,2,15,28,4,0,81,20,1,4,50,30,4,4,22,28,3,8,12,24,2,2,92,24,6,2,36,22,4,6,20,26,7,4,14,28,4,0,107,26,8,1,37,22,8,4,20,24,12,4,11,22,3,1,115,30,4,5,40,24,11,5,16,20,11,5,12,24,5,1,87,22,5,5,41,24,5,7,24,30,11,7,12,24,5,1,98,24,7,3,45,28,15,2,19,24,3,13,15,30,1,5,107,28,10,1,46,28,1,15,22,28,2,17,14,28,5,1,120,30,9,4,43,26,17,1,22,28,2,19,14,28,3,4,113,28,3,11,44,26,17,4,21,26,9,16,13,26,3,5,107,28,3,13,41,26,15,5,24,30,15,10,15,28,4,4,116,28,17,0,42,26,17,6,22,28,19,6,16,30,2,7,111,28,17,0,46,28,7,16,24,30,34,0,13,24,4,5,121,30,4,14,47,28,11,14,24,30,16,14,15,30,6,4,117,30,6,14,45,28,11,16,24,30,30,2,16,30,8,4,106,26,8,13,47,28,7,22,24,30,22,13,15,30,10,2,114,28,19,4,46,28,28,6,22,28,33,4,16,30,8,4,122,30,22,3,45,28,8,26,23,30,12,28,15,30,3,10,117,30,3,23,45,28,4,31,24,30,11,31,15,30,7,7,116,30,21,7,45,28,1,37,23,30,19,26,15,30,5,10,115,30,19,10,47,28,15,25,24,30,23,25,15,30,13,3,115,30,2,29,46,28,42,1,24,30,23,28,15,30,17,0,115,30,10,23,46,28,10,35,24,30,19,35,15,30,17,1,115,30,14,21,46,28,29,19,24,30,11,46,15,30,13,6,115,30,14,23,46,28,44,7,24,30,59,1,16,30,12,7,121,30,12,26,47,28,39,14,24,30,22,41,15,30,6,14,121,30,6,34,47,28,46,10,24,30,2,64,15,30,17,4,122,30,29,14,46,28,49,10,24,30,24,46,15,30,4,18,122,30,13,32,46,28,48,14,24,30,42,32,15,30,20,4,117,30,40,7,47,28,43,22,24,30,10,67,15,30,19,6,118,30,18,31,47,28,34,34,24,30,20,61,15,30],c=[255,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175],f=[1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142,0],l=[],u=[],p=[],g=[],v=[],y=2;function b(t,e){var i;t>e&&(i=t,t=e,e=i),i=e,i*=e,i+=e,i>>=1,g[i+=t]=1}function x(t,i){var n;for(p[t+e*i]=1,n=-2;n<2;n++)p[t+n+e*(i-2)]=1,p[t-2+e*(i+n+1)]=1,p[t+2+e*(i+n)]=1,p[t+n+1+e*(i+2)]=1;for(n=0;n<2;n++)b(t-1,i+n),b(t+1,i-n),b(t-n,i-1),b(t+n,i+1)}function m(t){for(;t>=255;)t=((t-=255)>>8)+(255&t);return t}var w=[];function S(t,e,i,n){var r,o,s;for(r=0;re&&(i=t,t=e,e=i),i=e,i+=e*e,i>>=1,g[i+=t]}function M(t){var i,n,r,o;switch(t){case 0:for(n=0;n>1&1,i=0;i=5&&(i+=3+v[e]-5);for(e=3;et||3*v[e-3]>=4*v[e]||3*v[e+3]>=4*v[e])&&(i+=40);return i}function W(){var t,i,n,r,o,s=0,a=0;for(i=0;ie*e;)h-=e*e,d++;for(s+=10*d,t=0;t1)for(P=s[t],k=e-7;;){for(I=e-7;I>P-3&&(x(I,k),!(I6)for(P=a[t-7],B=17,I=0;I<6;I++)for(k=0;k<3;k++,B--)1&(B>11?t>>B-12:P>>B)?(p[5-I+e*(2-k+e-11)]=1,p[2-k+e-11+e*(5-I)]=1):(b(5-I,2-k+e-11),b(2-k+e-11,5-I));for(k=0;k=(I=r*(i+n)+n)-2&&(R=I-2,t>9&&R--),L=R,t>9){for(l[L+2]=0,l[L+3]=0;L--;)P=l[L],l[L+3]|=255&P<<4,l[L+2]=P>>4;l[2]|=255&R<<4,l[1]=R>>4,l[0]=64|R>>12}else{for(l[L+1]=0,l[L+2]=0;L--;)P=l[L],l[L+2]|=255&P<<4,l[L+1]=P>>4;l[1]|=255&R<<4,l[0]=64|R>>4}for(L=R+3-(t<10);L0;O--)w[O]=w[O]?w[O-1]^f[m(c[w[O]]+L)]:w[O-1];w[0]=f[m(c[w[0]]+L)]}for(L=0;L<=o;L++)w[L]=c[w[L]];for(B=I,k=0,L=0;L>=1)1&k&&(p[e-1-B+8*e]=1,B<6?p[8+e*B]=1:p[8+e*(B+1)]=1);for(B=0;B<7;B++,k>>=1)1&k&&(p[8+e*(e-7+B)]=1,B?p[6-B+8*e]=1:p[7+8*e]=1);return p}(v)},utf16to8:function(t){var e,i,n,r;for(e="",n=t.length,i=0;i=1&&r<=127?e+=t.charAt(i):r>2047?(e+=String.fromCharCode(224|r>>12&15),e+=String.fromCharCode(128|r>>6&63),e+=String.fromCharCode(128|r>>0&63)):(e+=String.fromCharCode(192|r>>6&31),e+=String.fromCharCode(128|r>>0&63));return e},draw:function(t,i,n,r,o){i.drawView(n,r);var s=i.ctx,a=n.contentSize,h=a.width,d=a.height,c=a.left,f=a.top;r.borderRadius,r.backgroundColor;var l=r.color,u=void 0===l?"#000000":l;r.border,n.contentSize.left,n.borderSize.left,n.contentSize.top,n.borderSize.top;if(y=o||y,s){s.save(),i.setOpacity(r),i.setTransform(n,r);var p=Math.min(h,d);t=this.utf16to8(t);var g=this.getFrame(t),v=p/e;s.setFillStyle(u);for(var b=0;b=s||"cover"==n&&o=s)&&(a=e.width/i.width);var h=i.width*a,d=i.height*a,c=r||[],f=c[0],l=c[1],u=function(t){return/^\d+px|rpx$/.test(t)},p=u(f)?F(f,e.width):(e.width-h)*(A(f)?F(f,1):{left:0,center:.5,right:1}[f||"center"]),g=u(l)?F(l,e.height):(e.height-d)*(A(l)?F(l,1):{top:0,center:.5,bottom:1}[l||"center"]),v=function(t,e){return[(t-p)/a,(e-g)/a]},y=v(0,0),b=y[0],x=y[1],m=v(e.width,e.height),w=m[0],S=m[1];return{sx:Math.max(b,0),sy:Math.max(x,0),sw:Math.min(w-b,i.width),sh:Math.min(S-x,i.height),dx:Math.max(p,0),dy:Math.max(g,0),dw:Math.min(h,e.width),dh:Math.min(d,e.height)}}({objectFit:u,objectPosition:v},e.contentSize,t),o=n.sx,s=n.sy,a=n.sh,h=n.sw,d=n.dx,c=n.dy,f=n.dh,l=n.dw;R==r.MP_BAIDU?i.drawImage(t.src,d+w,c+S,l,f,o,s,h,a):i.drawImage(t.src,o,s,h,a,d+w,c+S,l,f)}else i.drawImage(t.src,w,S,x,m)},B=function(){i.restore(),L.drawView(e,o,!1,!0,!1),h(1)},P=function(t){k(t),B()},P(t),[2]}))}))}))];case 1:return h.sent(),[2]}}))}))},t.prototype.drawText=function(t,e,i,n){var r=this,o=this.ctx,s=e.borderSize,a=e.contentSize,h=e.left,d=e.top,c=a.width,f=a.height,l=a.left-s.left,u=a.top-s.top,p=i.color,g=void 0===p?"#000000":p,v=i.lineHeight,y=void 0===v?"1.4em":v,b=i.fontSize,x=void 0===b?14:b,m=i.fontWeight,w=i.fontFamily,S=i.fontStyle,z=i.textIndent,M=void 0===z?0:z,I=i.textAlign,W=void 0===I?"left":I,k=i.textStroke,B=i.verticalAlign,P=void 0===B?Mt:B,R=i.backgroundColor,L=i.lineClamp,O=i.backgroundClip,A=i.textShadow,C=i.textDecoration;if(M=T(M)?M:0,this.drawView(e,i,O!=mt),y=F(y,x),t){o.save(),h+=l,d+=u;var j=n.fontHeight,E=n.descent+n.ascent;switch(o.setFonts({fontFamily:w,fontSize:x,fontWeight:m,fontStyle:S}),o.setTextBaseline(Mt),o.setTextAlign(W),O?this.setBackground(R,c,f,h,d):o.setFillStyle(g),W){case Wt:break;case kt:h+=.5*c;break;case Bt:h+=c}var H=n.lines*y,Y=Math.ceil((f-H)/2);switch(Y<0&&(Y=0),P){case zt:break;case Mt:d+=Y;break;case It:d+=2*Y}var $=(y-j)/2,D=y/2,U=function(t){var e=o.measureText(t),i=e.actualBoundingBoxDescent,n=void 0===i?0:i,r=e.actualBoundingBoxAscent;return P==zt?{fix:E?void 0===r?0:r:D-$/2,lineY:E?0:$-$/2}:P==Mt?{fix:E?D+n/4:D,lineY:E?0:$}:P==It?{fix:E?y-n:D+$/2,lineY:E?2*$:$+$/2}:{fix:0,height:0,lineY:0}},_=function(t,e,i){var r=t;switch(W){case Wt:r+=i;break;case kt:r=(t-=i/2)+i;break;case Bt:r=t,t-=i}if(C){o.setLineWidth(x/13),o.beginPath();var s=.1*n.fontHeight;/\bunderline\b/.test(C)&&(o.moveTo(t,e+n.fontHeight+s),o.lineTo(r,e+n.fontHeight+s)),/\boverline\b/.test(C)&&(o.moveTo(t,e-s),o.lineTo(r,e-s)),/\bline-through\b/.test(C)&&(o.moveTo(t,e+.5*n.fontHeight),o.lineTo(r,e+.5*n.fontHeight)),o.closePath(),o.setStrokeStyle(g),o.stroke()}},X=function(t,e,i){var n=function(){o.setLineWidth(k.width),o.setStrokeStyle(k.color),o.strokeText(t,e,i)},s="outset";k&&k.type!==s?(o.save(),r.setShadow({boxShadow:A}),o.fillText(t,e,i),o.restore(),n()):k&&k.type==s?(o.save(),r.setShadow({boxShadow:A}),n(),o.restore(),o.save(),o.fillText(t,e,i),o.restore()):(r.setShadow({boxShadow:A}),o.fillText(t,e,i))};if(!n.widths||1==n.widths.length&&n.widths[0].total+M<=a.width){var N=U(t),q=N.fix,V=N.lineY;return X(t,h+M,d+q),_(h+M,d+V,n&&n.widths&&n.widths[0].total||n.text),d+=y,o.restore(),void this.setBorder(e,i)}for(var G=d,J=h,Q="",Z=0,K=o.measureText("...").width,tt=0;tta.width){Z>=L&&(Q+="…"),Z++,it=0;var ht=U(Q);q=ht.fix,V=ht.lineY;X(Q,J,d+q),_(J,d+V,it),d+=y,Q=""}else if(nt==et.length-1){Z==L&&K+itG+f||Z>L)break}}o.restore()}},t.prototype.source=function(t){return i(this,void 0,void 0,(function(){var e,i,r,o,s=this;return n(this,(function(n){switch(n.label){case 0:if(this.node=null,e=+new Date,"{}"==JSON.stringify(t))return[2];if(!t.type)for(i in t.type=St,t.css=t.css||{},t)["views","children","type","css"].includes(i)||(t.css[i]=t[i],delete t[i]);return t.css.boxSizing||(t.css.boxSizing="border-box"),[4,this.create(t)];case 1:return(r=n.sent())?(o=r.layout()||{},this.size=o,this.node=r,this.onEffectFinished().then((function(t){return s.lifecycle("onEffectSuccess",t)})).catch((function(t){return s.lifecycle("onEffectFail",t)})),this.performance&&console.log("布局用时:"+(+new Date-e)+"ms"),[2,this.size]):[2,console.warn("no node")]}}))}))},t.prototype.getImageInfo=function(t){return this.imageBus[t]||(this.imageBus[t]=this.createImage(t,this.useCORS)),this.imageBus[t]},t.prototype.create=function(t,r){return i(this,void 0,void 0,(function(){var i,o,s,a,h,d,c,f,l,u,p,g,v,y,b,x,w;return n(this,(function(n){switch(n.label){case 0:if(i=t.type==xt,o=[mt,wt].includes(t.type),s=t.css||{},a=s.backgroundImage,h=s.display,i&&!t.src&&!t.url||o&&!t.text)return[2];if(h==m)return[2];if(o&&(t.text=String(t.text)),!(i||t.type==St&&a))return[3,4];d=i?t.src:"",c=/url\((.+)\)/.exec(a),a&&c&&c[1]&&(d=c[1]||""),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.getImageInfo(d)];case 2:return f=n.sent(),l=f.width,u=f.height,!(p=f.path)&&i?[2]:(p&&(t.attributes=Object.assign(t.attributes||{},{width:l,height:u,path:p,src:p,naturalSrc:d})),[3,4]);case 3:return g=n.sent(),t.type!=St?[2]:(this.lifecycle("onEffectFail",e(e({},g),{src:d})),[3,4]);case 4:if(this.count+=1,v=new yt(t,r,this.root,this.ctx),!(y=t.views||t.children))return[3,8];b=0,n.label=5;case 5:return b