lodash.6e5eb596.js 806 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. var Gx=Object.defineProperty;var Zx=(e,t,i)=>t in e?Gx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var W=(e,t,i)=>(Zx(e,typeof t!="symbol"?t+"":t,i),i);import{G as Le,I as Jx,E as mr}from"./index.a42176ff.js";function qn(e,t){const i=t||new Path2D;let n=e.calculative.borderRadius||0,r=n;const{x:s,y:a,width:l,height:c,ex:u,ey:h}=e.calculative.worldRect;n<1&&(n=l*n,r=c*r);let d=n<r?n:r;if(l<2*d&&(d=l/2),c<2*d&&(d=c/2),i.moveTo(s+d,a),i.arcTo(u,a,u,h,d),i.arcTo(u,h,s,h,d),i.arcTo(s,h,s,a,d),i.arcTo(s,a,u,a,d),i.closePath(),i instanceof Path2D)return i}const Qx=qn;function t_(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.ellipse(n+s/2,r+a/2,s/2,a/2,0,0,Math.PI*2),i instanceof Path2D)return i}var jt;(function(e){e[e.Node=0]="Node",e[e.Line=1]="Line"})(jt||(jt={}));var Ot;(function(e){e[e.None=0]="None",e[e.DisableEdit=1]="DisableEdit",e[e.DisableMove=2]="DisableMove",e[e.DisableScale=3]="DisableScale",e[e.DisableMoveScale=4]="DisableMoveScale",e[e.Disable=10]="Disable"})(Ot||(Ot={}));var Lf;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out"})(Lf||(Lf={}));var Br;(function(e){e[e.None=0]="None",e[e.Linear=1]="Linear",e[e.Radial=2]="Radial"})(Br||(Br={}));var zt;(function(e){e[e.CanvasTemplate=1]="CanvasTemplate",e[e.CanvasImageBottom=2]="CanvasImageBottom",e[e.CanvasMain=3]="CanvasMain",e[e.CanvasImage=4]="CanvasImage"})(zt||(zt={}));const e_=["text","textWidth","textHeight","textLeft","textTop","fontFamily","fontSize","lineHeight","fontStyle","fontWeight","textAlign","textBaseline","whiteSpace","ellipsis","keepDecimal"],i_=["x","y","width","height","flipX","flipY"],n_=["paddingTop","paddingRight","paddingBottom","paddingLeft","flipX","flipY","visible","showChild"],r_=["iconLeft","iconTop","iconRotate"];var Je;(function(e){e[e.Normal=0]="Normal",e[e.Beads=1]="Beads",e[e.Dot=2]="Dot",e[e.Arrow=3]="Arrow",e[e.WaterDrop=4]="WaterDrop"})(Je||(Je={}));const s_=["gif","iframe","video","echarts","highcharts","lightningCharts"],Tl=["radio","checkbox","button","inputDom","slider","echarts"],is=new Set(["borderRadius","paddingLeft","paddingRight","paddingTop","paddingBottom","progress","progressColor","verticalProgress","reverseProgress","flipX","flipY","input","lineDash","lineCap","lineJoin","strokeType","lineGradientFromColor","lineGradientToColor","lineGradientAngle","color","hoverColor","activeColor","lineWidth","bkType","gradientFromColor","gradientToColor","gradientAngle","gradientRadius","hoverBackground","activeBackground","globalAlpha","anchorColor","anchorRadius","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","textHasShadow","fontFamily","fontSize","textColor","hoverTextColor","activeTextColor","textBackground","fontStyle","fontWeight","textAlign","textBaseline","lineHeight","whiteSpace","textWidth","textHeight","textLeft","textTop","ellipsis","hiddenText","keepDecimal","borderWidth","borderColor","animateLineWidth","lineAnimateType","frames","animateColor","animateType","animateReverse","background","gradientColors","lineGradientColors","animateLineWidth","gradientSmooth","lineSmooth","animations"]);function a_(e){e.onAdd=void 0,e.onValue=void 0,e.onBeforeValue=void 0,e.onDestroy=void 0,e.onMove=void 0,e.onResize=void 0,e.onRotate=void 0,e.onClick=void 0,e.onMouseEnter=void 0,e.onMouseLeave=void 0,e.onMouseDown=void 0,e.onMouseMove=void 0,e.onMouseUp=void 0,e.onShowInput=void 0,e.onInput=void 0,e.onChangeId=void 0,e.onBinds=void 0,e.onStartVideo=void 0,e.onPauseVideo=void 0,e.onStopVideo=void 0,e.onRenderPenRaw=void 0,e.onKeyDown=void 0,e.onContextmenu=void 0,e.onScale=void 0,e.onWheel=void 0,e.onConnectLine=void 0}var xt;(function(e){e[e.None=0]="None",e[e.LineAnchor=1]="LineAnchor",e[e.NodeAnchor=2]="NodeAnchor",e[e.Line=3]="Line",e[e.Node=4]="Node",e[e.Resize=5]="Resize",e[e.Rotate=6]="Rotate",e[e.LineAnchorPrev=7]="LineAnchorPrev",e[e.LineAnchorNext=8]="LineAnchorNext"})(xt||(xt={}));var Kt;(function(e){e[e.None=0]="None",e[e.Translate=1]="Translate",e[e.Select=2]="Select",e[e.Resize=3]="Resize",e[e.AddAnchor=4]="AddAnchor"})(Kt||(Kt={}));var $i;(function(e){e[e.None=0]="None",e[e.Down=1]="Down",e[e.Translate=2]="Translate"})($i||($i={}));var Lt;(function(e){e[e.None=-1]="None",e[e.Up=0]="Up",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left"})(Lt||(Lt={}));const Df=["nw-resize","ne-resize","se-resize","sw-resize"],Mf=["n-resize","e-resize","s-resize","w-resize"],o_=["curve","polyline","line"],_v=["dash","lineWidth","lineCap","lineJoin","strokeType","color","lineGradientFromColor","lineGradientToColor","lineGradientAngle","globalAlpha","bkType","background","gradientFromColor","gradientToColor","gradientAngle","gradientRadius","fontFamily","fontSize","textColor","hoverTextColor","activeTextColor","textBackground","fontStyle","fontWeight","textAlign","textBaseline","lineHeight","whiteSpace","textLeft","textTop","flipX","flipY","lineDash","visible","iconColor"];var jn;(function(e){e[e.Mirror=0]="Mirror",e[e.Bilateral=1]="Bilateral",e[e.Free=2]="Free"})(jn||(jn={}));var Ee;(function(e){e[e.Default=0]="Default",e[e.In=1]="In",e[e.Out=2]="Out",e[e.DisableConnected=3]="DisableConnected",e[e.DisableConnectTo=4]="DisableConnectTo",e[e.Disable=10]="Disable"})(Ee||(Ee={}));var Ki;(function(e){e[e.Default=0]="Default",e[e.Line=1]="Line"})(Ki||(Ki={}));function Gt(e,t,i){if(!t||t%360===0)return;const n=t*Math.PI/180,r=(e.x-i.x)*Math.cos(n)-(e.y-i.y)*Math.sin(n)+i.x,s=(e.x-i.x)*Math.sin(n)+(e.y-i.y)*Math.cos(n)+i.y;e.x=r,e.y=s,e.prev&&Gt(e.prev,t,i),e.next&&Gt(e.next,t,i)}function Ar(e,t,i=5,n){if(t.type===Ki.Line){let r=n.rotate;n.flipX&&(r*=-1),n.flipY&&(r*=-1);let s=t.rotate+r;return n.flipX&&(s*=-1),n.flipY&&(s*=-1),yn(e,{x:t.x-t.length*n.calculative.canvas.store.data.scale/2,y:t.y-i,width:t.length*n.calculative.canvas.store.data.scale,height:i*2,rotate:s})}else return e.x>t.x-i&&e.x<t.x+i&&e.y>t.y-i&&e.y<t.y+i}function Wa(e,t,i){e.x=i.x-(i.x-e.x)*t,e.y=i.y-(i.y-e.y)*t}function hi(e,t){if(e.x===t.x)return e.y<=t.y?0:180;if(e.y===t.y)return e.x<t.x?270:90;const i=e.x-t.x,n=e.y-t.y;let r=Math.atan(Math.abs(i/n))/(2*Math.PI)*360;return i>0&&n>0?r=180-r:i<0&&n>0?r+=180:i<0&&n<0&&(r=360-r),r}function Za(e,t){const i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)}function l_(e,t){let i=Lt.None;if(!t)return i;const n=e.x-t.x,r=e.y-t.y;return Math.abs(n)>Math.abs(r)?n>0?i=Lt.Right:i=Lt.Left:r>0?i=Lt.Bottom:i=Lt.Up,i}function ls(e,t,i){!e||(e.x+=t,e.y+=i,e.next&&(e.next.x+=t,e.next.y+=i),e.prev&&(e.prev.x+=t,e.prev.y+=i))}function Bf(e,t){return e.anchorId===t.anchorId&&e.connectTo===t.connectTo}function wa(e,t,i){let n=Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))/i.data.scale;t.rotate===0?e.x<t.x?i.pens[t.penId].flipX||(n*=-1):i.pens[t.penId].flipX&&(n*=-1):e.y<t.y?i.pens[t.penId].flipY||(n*=-1):i.pens[t.penId].flipY&&(n*=-1),e.distance=n}const c_="@meta2d/core",h_="1.0.63",u_="@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",f_="index.js",d_="index.d.ts",v_={copy:"copyfiles package.json ../../dist/core/",build:"tsc && npm run copy"},g_=["meta2d","diagram","2D","canvas"],y_="alsmile123@qq.com",m_="MIT",p_={type:"git",url:"git+https://github.com/le5le-com/meta2d.js.git"},w_={url:"https://github.com/le5le-com/meta2d.js/issues"},b_="https://github.com/le5le-com/meta2d.js#readme",x_={"@types/marked":"^4.0.3","@types/offscreencanvas":"latest"},__={mitt:"^2.1.0",mqtt:"^4.2.6"},k_={access:"public"},E_="78f2a53ca1839c89b56e2e498d17ba4eb987ad14",kv={name:c_,version:h_,description:u_,main:f_,types:d_,scripts:v_,keywords:g_,author:y_,license:m_,repository:p_,bugs:w_,homepage:b_,devDependencies:x_,dependencies:__,publishConfig:k_,gitHead:E_},At={version:kv.version,path2dDraws:{},canvasDraws:{},anchors:{},htmlElements:{}};function A_(e){Object.assign(At.path2dDraws,e)}function R_(e){Object.assign(At.canvasDraws,e)}function C_(e){Object.assign(At.anchors,e)}function T_(e){return{all:e=e||new Map,on:function(t,i){var n=e.get(t);n&&n.push(i)||e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&n.splice(n.indexOf(i)>>>0,1)},emit:function(t,i){(e.get(t)||[]).slice().map(function(n){n(i)}),(e.get("*")||[]).slice().map(function(n){n(t,i)})}}}var zn;(function(e){e[e.None=-1]="None",e[e.Document=0]="Document",e[e.Canvas=1]="Canvas"})(zn||(zn={}));const S_={fontFamily:'"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial',fontSize:12,lineHeight:1.5,textAlign:"center",textBaseline:"middle",color:"#222222",activeColor:"#278df8",hoverColor:"rgba(39,141,248,0.50)",anchorColor:"#278DF8",hoverAnchorColor:"#FF4101",anchorRadius:4,anchorBackground:"#fff",dockColor:"rgba(39,141,248,0.50)",dockPenColor:"#1890FF",dragColor:"#1890ff",rotateCursor:"rotate.cur",rightCursor:"right.cur",downCursor:"down.cur",hoverCursor:"pointer",minScale:.1,maxScale:10,keydown:zn.Document,gridSize:20,gridColor:"#e2e2e2",ruleColor:"#888888",drawingLineName:"curve",interval:30,animateInterval:30,autoPolyline:!0,autoAnchor:!0,autoAlignGrid:!1,animateColor:"#30EEDC",ruleLineColor:"#FF4101",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:64,shadowColor:"#00000014",globalAlpha:1,defaultAnchors:[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}],measureTextWidth:!0,moveConnectedLine:!0,mouseRightActive:!0,disableClipboard:!1,drawingLineLength:0,disableTouchPadScale:!1,cdn:"",polylineSpace:10,domShapes:[],containerShapes:["tablePlus"],textFlip:!0,textRotate:!0,unavailableKeys:[],diagramOptions:{},svgPathStroke:!0},P_={dark:{color:"#bdc7db",background:"#1e2430",parentBackground:"#080b0f",ruleColor:"#222E47",ruleOptions:{background:"#121924",textColor:"#6E7B91"}},light:{color:"#222222",background:"#FFFFFF",parentBackground:"#F0F1F2",ruleColor:"#C8D0E1",ruleOptions:{background:"#F7F8FA",textColor:"#C8D0E1"}}};var bt;(function(e){e[e.Add=0]="Add",e[e.Update=1]="Update",e[e.Delete=2]="Delete",e[e.Replace=3]="Replace"})(bt||(bt={}));const I_=()=>({data:{x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{},theme:"light"},histories:[],pens:{},path2dMap:new WeakMap,animateMap:new WeakMap,active:[],animates:new Set,options:{...S_},theme:{...P_},emitter:T_(),bindDatas:{},bind:{},pensNetwork:{},cacheDatas:[],messageEvents:{},templatePens:{},globalTriggers:{}}),L_=(e="default")=>(At[e]||(At[e]=I_(),At[e].id=e),At[e]),D_=(e,t)=>{const i=e.data.template===t;if(i)for(const n of e.data.pens)n.canvasLayer===zt.CanvasTemplate&&(e.templatePens[n.id]=n);e.lastScale=e.data.scale,e.data={x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{},template:i?t:null},e.sameTemplate=i,e.pens={},e.histories=[],e.historyIndex=null,e.path2dMap=new WeakMap,e.animateMap=new WeakMap,e.bindDatas={},e.bind={},e.pensNetwork={},e.active=[],e.hover=void 0,e.lastHover=void 0,e.animates.clear()};function Ti(e){const{paddingTop:t,paddingBottom:i,paddingLeft:n,paddingRight:r,worldRect:s,canvas:a}=e.calculative;let{textLeft:l,textTop:c,textWidth:u,textHeight:h}=e.calculative,d=n,g=t;const v=s.width-n-r,y=s.height-t-i;u&&u<1&&(u*=s.width),h&&h<1&&(h*=s.height),u<e.calculative.fontSize&&(u=e.calculative.fontSize),d+=(l||0)+s.x,g+=(c||0)+s.y;const w=e.textAlign||a.store.options.textAlign,p=e.textBaseline||a.store.options.textBaseline;switch(w){case"center":d+=(v-(u||v))/2;break;case"right":d+=v-(u||v);break}switch(p){case"middle":g+=(y-(h||y))/2;break;case"bottom":g+=y-(h||y);break}const _={x:d,y:g,width:u||v,height:h||y};ae(_),e.calculative.worldTextRect=_,Es(e),e.calculative.textDrawRect=void 0}function Ev(e,t){const i=t.calculative.fontSize*t.calculative.lineHeight,n=t.calculative.textLines.length*i,r=M_(e,t),s=t.calculative.worldTextRect;let a=s.x+(s.width-r)/2,l=s.y+(s.height-n)/2;const c=t.calculative.canvas.store.options;switch(t.textAlign||c.textAlign){case"left":a=s.x;break;case"right":a=s.x+s.width-r;break}switch(t.textBaseline||c.textBaseline){case"top":l=s.y;break;case"bottom":l=s.ey-n;break}t.calculative.textDrawRect={x:a,y:l,width:r,height:n},ae(t.calculative.textDrawRect)}function Es(e,t=e.calculative.text){if(t==null){e.calculative.textLines=[];return}t=t.toString();let i=[];const n=e.calculative.fontSize*e.calculative.lineHeight,r=e.calculative.worldTextRect.height,s=Math.floor(r/n),a=s>1?s:1;switch(e.whiteSpace){case"nowrap":if(e.ellipsis!==!1){const h=Of(t.split(""),e);h[0]&&(i.push(h[0]),h.length>1&&Sl(i))}else i.push(t);break;case"pre-line":i=t.split(/[\n]/g),e.ellipsis!==!1&&i.length>a&&(i=i.slice(0,a),Sl(i));break;case"break-all":default:const c=t.split(/[\n]/g);let u=0;t:for(const h of c){const d=e.whiteSpace==="break-all"?h.split(""):Av(h);let g=Of(d,e);if(g.length===0&&(g=[""]),e.ellipsis!=!1)for(const v of g)if(u++,u>a){Sl(i);break t}else i.push(v);else i.push(...g)}break}const l=e.calculative.keepDecimal;return l!=null&&i.forEach((c,u)=>{const h=Number(c);isNaN(h)||(i[u]=h.toFixed(l))}),e.calculative.textLines=i,i}function Av(e=""){const t=[];let i="";for(let n=0;n<e.length;++n){const r=e.charCodeAt(n);r<33||r>126?(i&&(t.push(i),i=""),t.push(e[n])):i+=e[n]}return i&&t.push(i),t}function Of(e,t){const i=t.calculative.canvas,n=i.offscreen.getContext("2d"),{fontStyle:r,fontWeight:s,fontSize:a,fontFamily:l,lineHeight:c}=t.calculative;n.save();const u=[];let h=e[0]||"";for(let d=1;d<e.length;++d){const g=e[d]||"",v=h+g;let y=0;if(i.store.options.measureTextWidth)n.font=Rn({fontStyle:r,fontWeight:s,fontFamily:l||i.store.options.fontFamily,fontSize:a,lineHeight:c}),y=n.measureText(v).width;else{const p=v.match(/[^\x00-\xff]/g)||"",_=p.length*a,A=v.match(/\s/g)||"",x=A.length*a*.3,E=(v.length-p.length-A.length)*a*.6;y=_+x+E}const w=t.calculative.worldTextRect.width;y<=w+.1?h+=g:(h.length&&u.push(h),h=g)}return h.length&&u.push(h),n.restore(),u}function M_(e,t){let i=0;return t.calculative.textLineWidths=[],t.calculative.textLines.forEach(n=>{const r=e.measureText(n).width;t.calculative.textLineWidths.push(r),i<r&&(i=r)}),i}function Sl(e){e[e.length-1]=e[e.length-1].slice(0,-3)+"..."}function B_(e){let t=e.text.split(`
  2. `);const i=e.calculative.canvas,n=i.offscreen.getContext("2d"),{fontStyle:r,fontWeight:s,fontSize:a,fontFamily:l,lineHeight:c}=e.calculative;let u=0,h=0;n.save();for(let g=0;g<t.length;g++){if(i.store.options.measureTextWidth)n.font=Rn({fontStyle:r,fontWeight:s,fontFamily:l||i.store.options.fontFamily,fontSize:a,lineHeight:c}),h=n.measureText(t[g]).width;else{const v=t[g].match(/[^\x00-\xff]/g)||"",y=v.length*a,w=t[g].match(/\s/g)||"",p=w.length*a*.3,_=(t[g].length-v.length-w.length)*a*.6;h=y+p+_}h>u&&(u=h)}n.restore();let d=t.length*a*c;e.textAlign==="left"||(e.textAlign==="right"?e.x=e.x-(u-e.width):e.x=e.x-(u-e.width)/2),e.textBaseline==="top"||(e.textBaseline==="bottom"?e.y=e.y-(d-e.height):e.y=e.y-(d-e.height)/2),e.height=d+2,e.width=u+2,e.calculative.canvas.updatePenRect(e),e.calculative.canvas.calcActiveRect()}function ct(e,t=!1){if(Array.isArray(e)){const i=[];return e.forEach(n=>{i.push(ct(n,t))}),i}else if(typeof e=="object"){if(e===null)return null;if(e.constructor===RegExp)return e;const i={};for(const n in e)if(!(["canvas","lastFrame"].includes(n)||e[n]instanceof HTMLImageElement||e[n]instanceof HTMLMediaElement)){{if(n==="calculative"&&!t)continue;if(n==="singleton"){t?i[n]={}:i[n]=e[n];continue}}i[n]=ct(e[n],t)}return i}return e}const ei={};function Rv(e,t,i){if(!ei[t.fromArrow])return;const n=le(t),{x:r,y:s}=n,a={x:r,y:s};if(a.step=(t.fromArrowSize||10)*i.data.scale,n.next)a.rotate=hi(n.next,n)+90;else{const c=t.calculative.worldAnchors[1];if(!c)return;c.prev?a.rotate=hi(c.prev,n)+90:a.rotate=hi(c,n)+90}e.save(),e.beginPath(),e.setLineDash([]);const l=t.fromArrowColor||t.calculative.color;l&&(e.strokeStyle=l),ei[t.fromArrow](e,t,i,a),e.restore()}function Cv(e,t,i){if(!ei[t.toArrow]||t.calculative.worldAnchors.length<2)return;e.save();const n=qt(t),{x:r,y:s}=n,a={x:r,y:s};if(a.step=(t.toArrowSize||10)*i.data.scale,n.prev)a.rotate=hi(n.prev,n)+90;else{const c=t.calculative.worldAnchors[t.calculative.worldAnchors.length-2];c.next?a.rotate=hi(c.next,n)+90:a.rotate=hi(c,n)+90}e.beginPath(),e.setLineDash([]);const l=t.toArrowColor||t.calculative.color;l&&(e.strokeStyle=l),ei[t.toArrow](e,t,i,a),e.restore()}ei.triangleSolid=(e,t,i,n)=>{e.save(),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.x-n.step;e.moveTo(r,n.y-n.step/4),e.lineTo(n.x,n.y),e.lineTo(r,n.y+n.step/4),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};ei.triangle=(e,t,i,n)=>{e.save(),e.lineWidth<2&&(e.lineWidth=2),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.x-n.step;e.moveTo(r,n.y-n.step/4),e.lineTo(n.x,n.y),e.lineTo(r,n.y+n.step/4),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};ei.circleSolid=(e,t,i,n)=>{e.save(),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.step/2;e.arc(n.x-r,n.y,r,0,2*Math.PI),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};ei.circle=(e,t,i,n)=>{e.save(),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.step/2;e.arc(n.x-r,n.y,r,0,2*Math.PI),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};ei.diamondSolid=(e,t,i,n)=>{e.save(),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.x-n.step,s=n.step/2;e.moveTo(r,n.y),e.lineTo(r+s,n.y-s/2),e.lineTo(n.x,n.y),e.lineTo(r+s,n.y+s/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};ei.diamond=(e,t,i,n)=>{e.save(),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.x-n.step,s=n.step/2;e.moveTo(r,n.y),e.lineTo(r+s,n.y-s/2),e.lineTo(n.x,n.y),e.lineTo(r+s,n.y+s/2),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};ei.line=(e,t,i,n)=>{e.save(),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.x-n.step;e.moveTo(r,n.y-n.step/3),e.lineTo(n.x,n.y),e.lineTo(r,n.y+n.step/3),e.stroke(),e.restore()};ei.lineUp=(e,t,i,n)=>{e.save(),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.x-n.step;e.moveTo(r,n.y-n.step/3),e.lineTo(n.x,n.y),e.stroke(),e.restore()};ei.lineDown=(e,t,i,n)=>{e.save(),e.translate(n.x,n.y),e.rotate(n.rotate*Math.PI/180),e.translate(-n.x,-n.y);const r=n.x-n.step;e.moveTo(r,n.y+n.step/3),e.lineTo(n.x,n.y),e.stroke(),e.restore()};function gc(e){const t=parseInt,i=Math.round;let n=e.length,r={};if(n>9){const[s,a,l,c]=e=e.split(",");if(n=e.length,n<3||n>4)return null;r.r=t(s[3]=="a"?s.slice(5):s.slice(4)),r.g=t(a),r.b=t(l),r.a=c?parseFloat(c):-1}else{if(n==8||n==6||n<4)return null;n<6&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(n>4?e[4]+e[4]:"")),e=t(e.slice(1),16),n==9||n==5?(r.r=e>>24&255,r.g=e>>16&255,r.b=e>>8&255,r.a=i((e&255)/.255)/1e3):(r.r=e>>16,r.g=e>>8&255,r.b=e&255,r.a=-1)}return r}function Ae(e,t,i,n){let r,s,a,l,c,u,h,d=Math.round,g=typeof i=="string";return typeof e!="number"||e<-1||e>1||typeof t!="string"||t[0]!="r"&&t[0]!="#"||i&&!g||(h=t.length>9,h=g?i.length>9?!0:i=="c"?!h:!1:h,c=gc(t),l=e<0,u=i&&i!="c"?gc(i):l?{r:0,g:0,b:0,a:-1}:{r:255,g:255,b:255,a:-1},e=l?e*-1:e,l=1-e,!c||!u)?null:(n?(r=d(l*c.r+e*u.r),s=d(l*c.g+e*u.g),a=d(l*c.b+e*u.b)):(r=d((l*c.r**2+e*u.r**2)**.5),s=d((l*c.g**2+e*u.g**2)**.5),a=d((l*c.b**2+e*u.b**2)**.5)),g=c.a,u=u.a,c=g>=0||u>=0,g=c?g<0?u:u<0?g:g*l+u*e:0,h?"rgb"+(c?"a(":"(")+r+","+s+","+a+(c?","+d(g*1e3)/1e3:"")+")":"#"+(4294967296+r*16777216+s*65536+a*256+(c?d(g*255):0)).toString(16).slice(1,c?void 0:-2))}globalThis.pSBC=Ae;function qa(e,t){const i=gc(e)||{r:0,g:0,b:0};return i.a<0?`rgba(${i.r},${i.g},${i.b},${t})`:`rgba(${i.r},${i.g},${i.b},${t+i.a})`}function pr(e,t){if(isNaN(e)){console.warn("realValue not number");return}if(typeof t!="string"){console.warn("collection must be string");return}const[i,n]=[t[0],t[t.length-1]];if(!["[","("].includes(i)){console.warn('collection must start with "[" or "("');return}if(!["]",")"].includes(n)){console.warn('collection must end with "]" or ")"');return}const r=t.substring(1,t.length-1).split(",");if(r.length!==2){console.warn("collection must have 2 numbers");return}const[s,a]=[+r[0],+r[1]];if(s>=a){console.warn("startNum must less than endNum");return}return e>s||i==="["&&e===s?e<a||n==="]"&&e===a:!1}function wr(e,t){if(typeof t!="string"){console.warn("collection must be string");return}const[i,n]=[t[0],t[t.length-1]];if(i!=="["||n!=="]"){console.warn('collection must start with "[" and end with "]"');return}const r=t.substring(1,t.length-1).split(",");for(const s of r)if(s.includes("..")){const[a,l]=s.split(".."),[c,u]=[+a,+l];if(c>=u){console.warn("startNum must less than endNum");return}if(e>=c&&e<=u)return!0}else if(e==s)return!0;return!1}function It(){return((1+Math.random())*4294967296|0).toString(16).substring(1)}const Xi=e=>{let t=0,i=0,n=0,r=0;return typeof e=="number"?t=i=n=r=e:typeof e=="string"?t=i=n=r=parseInt(e,10):Array.isArray(e)&&(t=e[0],n=Pl(e[1])?e[0]:e[1],r=Pl(e[2])?e[0]:e[2],i=Pl(e[3])?n:e[3]),[t,n,r,i]};function Pl(e){return e==null}async function O_(e){return new Promise((t,i)=>{const n=new FileReader;n.onload=r=>{t(r.target.result)},n.onerror=r=>{i(r)},n.readAsDataURL(e)})}async function N_(e,t,i,n){const r=new FormData;if(r.append("file",e),i)for(const a in i)i.hasOwnProperty(a)&&r.append(a,i[a]);return(await(await fetch(t,{method:"POST",headers:n,body:r})).json()).url}function F_(e,t,i){var n=document.createElement("link");n.href=e,n.rel="stylesheet",t&&(n.onload=t),i&&(n.onerror=i),document.head.appendChild(n)}function Il(e){let t=e||window.location.search.split("?")[1];const i=new URLSearchParams(t);return Object.fromEntries(i.entries())}function Nf(e,t){if(t==null)return e;const i=t.split(".");for(;i.length&&(e=e[i.shift()]););return e}function z_(e,t,i){t!=null&&t.split(".").reduce((n,r,s)=>n[r]=t.split(".").length===++s?i:n[r]||{},e)}function H_(e,t){if(!e||!t)return!1;let i=Ze(e);for(;i;){if(i.id===t.id)return!0;i=Ze(i)}return!1}function Ze(e,t){if(!e||!e.parentId||!e.calculative)return;const n=e.calculative.canvas.store.pens[e.parentId];return t&&Ze(n,t)||n}function Ci(e,t){if(!e||!e.children)return[];const i=[];return e.children.forEach(n=>{const r=t.pens[n];r&&(i.push(r),i.push(...Ci(r,t)))}),i}function Bc(e,t){if(!e||!e.followers)return[];const i=[];return e.followers.forEach(n=>{const r=t.pens[n];r&&!r.parentId&&(i.push(r),i.push(...Bc(r,t)))}),i}function U_(e,t){const{worldRect:i,gradientFromColor:n,gradientToColor:r,gradientAngle:s}=t.calculative;return Sv(e,i,n,r,s)}function W_(e,t){const{worldRect:i,gradientFromColor:n,gradientToColor:r,gradientRadius:s}=t.calculative;if(!n||!r)return;const{width:a,height:l,center:c}=i,{x:u,y:h}=c;let d=a;d<l&&(d=l),d*=.5;const g=e.createRadialGradient(u,h,d*(s||0),u,h,d);return g.addColorStop(0,n),g.addColorStop(1,r),g}function q_(e,t,i,n,r){let s=0;s=Math.PI/2-Math.atan2(n-t,i-e);const a=(e+i)/2,l=(t+n)/2,c=a+r*Math.sin(90*Math.PI/180-s),u=l+r*-Math.cos(90*Math.PI/180-s),h=a+r*Math.sin(270*Math.PI/180-s),d=l+r*-Math.cos(270*Math.PI/180-s);return[c,u,h,d]}function j_(e,t){const{worldRect:i,gradientColors:n,gradientRadius:r}=t.calculative;if(!n)return;let s=t.calculative.gradientColors;t.calculative.checked&&(s=t.calculative.onGradientColors);const{width:a,height:l,center:c}=i,{x:u,y:h}=c;let d=a;d<l&&(d=l),d*=.5;const{colors:g}=Qn(s),v=e.createRadialGradient(u,h,d*(r||0),u,h,d);return g.forEach(y=>{v.addColorStop(y.i,y.color)}),v}function V_(e,t){const{x:i,y:n,ex:r,width:s,height:a,center:l}=t.calculative.worldRect;let c=[{x:r,y:n+a/2},{x:i,y:n+a/2}],u=t.calculative.gradientColors;t.calculative.checked&&(u=t.calculative.onGradientColors);const{angle:h,colors:d}=Qn(u);let g=Oc(h,s,a);return c.forEach(v=>{Gt(v,h,l)}),Ja(e,c,d,g)}function $_(e,t){const{worldRect:i,textGradientColors:n}=t.calculative;if(!n)return;const{width:r,height:s,center:a}=i,{x:l,y:c}=a;let u=r;u<s&&(u=s),u*=.5;const{colors:h}=Qn(n),d=e.createRadialGradient(l,c,0,l,c,u);return h.forEach(g=>{d.addColorStop(g.i,g.color)}),d}function K_(e,t){const{x:i,y:n,ex:r,width:s,height:a,center:l}=t.calculative.worldRect;let c=[{x:r,y:n+a/2},{x:i,y:n+a/2}];const{angle:u,colors:h}=Qn(t.calculative.textGradientColors);let d=Oc(u,s,a);return c.forEach(g=>{Gt(g,u,l)}),Ja(e,c,h,d)}function Oc(e,t,i){const n=Math.atan(i/t)/Math.PI*180;let r=(e-90)%360,s=0;return r>n&&r<180-n||r>180+n&&r<360-n||r<0?(r>270?r=360-r:r>180?r=r-180:r>90&&(r=180-r),s=Math.abs(i/Math.sin(r/180*Math.PI)/2)):(r>270?r=360-r:r>180?r=r-180:r>90&&(r=180-r),s=Math.abs(t/Math.cos(r/180*Math.PI)/2)),s}function Qn(e){if(typeof e=="string"&&e.startsWith("linear-gradient")){let t=e.slice(16,-2).split("deg,");if(t.length>1){let i=t[1].split("%,");const n=[];return i.forEach(r=>{if(/rgba?/.test(r)){let s=r.split(") ");n.push({color:Y_(s[0]+")"),i:parseFloat(s[1])/100})}else{let s=r.split(" ");s.length>2?n.push({color:s[1],i:parseFloat(s[2])/100}):n.push({color:s[0],i:parseFloat(s[1])/100})}}),{angle:parseFloat(t[0]),colors:n}}else return{angle:parseFloat(t[0]),colors:[]}}else return{angle:0,colors:[]}}function Y_(e){if(/rgba?/.test(e)){let t=e.split(",");if(t.length<3)return"";e="#";for(let i=0,n;n=t[i++];)if(i<4)n=parseInt(n.replace(/[^\d]/gi,""),10).toString(16),e+=n.length==1?"0"+n:n;else{n=n.replace(")","");let s=parseInt(n*255+"").toString(16);s=s.length===2?s:"0"+s,e+=s}e=e.toUpperCase()}return e}function X_(e,t){const{x:i,y:n,ex:r,width:s,height:a,center:l}=t.calculative.worldRect;let c=[{x:r,y:n+a/2},{x:i,y:n+a/2}];const{angle:u,colors:h}=Qn(t.calculative.lineGradientColors);let d=Oc(u,s,a);return c.forEach(g=>{Gt(g,u,l)}),Ja(e,c,h,d)}function Ja(e,t,i,n){let r=q_(t[0].x,t[0].y,t[1].x,t[1].y,n),s=e.createLinearGradient(r[0],r[1],r[2],r[3]);return i.forEach(a=>{s.addColorStop(a.i,a.color)}),s}function gn(e,t,i){let n=[];t.calculative.gradientColorStop?n=t.calculative.gradientColorStop:(n=Qn(t.calculative.lineGradientColors).colors,t.calculative.gradientColorStop=n),e.strokeStyle=Ja(e,i,n,t.calculative.lineWidth/2),e.beginPath(),e.moveTo(i[0].x,i[0].y),e.lineTo(i[1].x,i[1].y),e.stroke()}function Tv(e,t){const i=t.calculative.worldAnchors;let n=t.calculative.lineWidth*(t.calculative.gradientSmooth||t.calculative.lineSmooth||0);for(let r=0;r<i.length-1;r++)if((t.lineName==="curve"||t.lineName==="mind")&&i[r].curvePoints){if(r>0){let l=i[r-1].curvePoints;l?ba(e,t,n,l[l.length-1],i[r],i[r].curvePoints[0]):ba(e,t,n,i[r-1],i[r],i[r].curvePoints[0]);let c=Zi(n,i[r],i[r].curvePoints[0]);gn(e,t,[c,i[r].curvePoints[1]])}else gn(e,t,[i[r],i[r].curvePoints[0]]),gn(e,t,[i[r].curvePoints[0],i[r].curvePoints[1]]);let s=i[r].curvePoints.length-1;for(let l=1;l<s;l++)gn(e,t,[i[r].curvePoints[l],i[r].curvePoints[l+1]]);let a=Zi(n,i[r+1],i[r].curvePoints[s]);gn(e,t,[i[r].curvePoints[s],a])}else{let s=i[r],a=i[r+1];if(r>0&&r<i.length-1){let c=i[r-1].curvePoints;c?ba(e,t,n,c[c.length-1],i[r],i[r+1]):ba(e,t,n,i[r-1],i[r],i[r+1])}r>0&&r<i.length-1&&(s=Zi(n,i[r],i[r+1])),r<i.length-2&&(a=Zi(n,i[r+1],i[r]));let l=!1;if(r===0&&t.fromLineCap&&t.fromLineCap!=="butt"&&(e.save(),l=!0,e.lineCap=t.fromLineCap),r!==0&&r===i.length-2&&t.toLineCap&&t.toLineCap!=="butt"&&(e.save(),l=!0,e.lineCap=t.toLineCap),gn(e,t,[s,a]),l&&e.restore(),i.length===2&&r===0){e.save(),l=!0,e.lineCap=t.toLineCap;let c=.1,u=.1;s.x-a.x===0?u=0:c=(s.y-a.y)/(s.x-a.x)*.1,gn(e,t,[{x:a.x-u,y:a.y-c},a]),e.restore()}}}function Zi(e,t,i){let n=Math.sqrt((i.x-t.x)*(i.x-t.x)+(i.y-t.y)*(i.y-t.y));return n===0?{x:t.x,y:t.y}:e<n?{x:t.x+(i.x-t.x)*e/n,y:t.y+(i.y-t.y)*e/n}:{x:t.x+(i.x-t.x)/n/2,y:t.y+(i.y-t.y)/n/2}}function ba(e,t,i,n,r,s){let a=Zi(i,r,n),l=Zi(i,r,s),c={x:r.x,y:r.y},u=G_(t.calculative.canvas.store.data.smoothNum||20,a,c,l);for(let h=0;h<u.length-1;h++)gn(e,t,[{x:u[h].x,y:u[h].y},{x:u[h+1].x,y:u[h+1].y}])}function Ff(e,t,i,n){let r=Zi(t,i,n),s={x:i.x,y:i.y};e.quadraticCurveTo(s.x,s.y,r.x,r.y)}function Nc(e){const t=e.calculative.worldAnchors;let i=e.calculative.lineWidth*(e.calculative.gradientSmooth||e.calculative.lineSmooth||0);const n=new Path2D;for(let r=0;r<t.length-1;r++){t[r];let s=t[r+1];if(r==0&&n.moveTo(t[r].x,t[r].y),r>0&&r<t.length-1){let a=t[r-1].curvePoints;Ff(n,i,t[r],t[r+1])}r>0&&r<t.length-1&&Zi(i,t[r],t[r+1]),r<t.length-2&&(s=Zi(i,t[r+1],t[r])),n.lineTo(s.x,s.y)}return n}function G_(e=100,t,i,n,r){let s=null;const a=[];!n&&!r?s=Z_:n&&!r?s=J_:n&&r&&(s=Q_);for(let l=0;l<e;l++)a.push(s(l/e,t,i,n,r));return r?a.push(r):n&&a.push(n),a}function Z_(e,t,i){const{x:n,y:r}=t,{x:s,y:a}=i;let l=n+(s-n)*e,c=r+(a-r)*e;return{x:l,y:c}}function J_(e,t,i,n){const{x:r,y:s}=t,{x:a,y:l}=i,{x:c,y:u}=n;let h=(1-e)*(1-e)*r+2*e*(1-e)*a+e*e*c,d=(1-e)*(1-e)*s+2*e*(1-e)*l+e*e*u;return{x:h,y:d}}function Q_(e,t,i,n,r){const{x:s,y:a}=t,{x:l,y:c}=r,{x:u,y:h}=i,{x:d,y:g}=n;let v=s*(1-e)*(1-e)*(1-e)+3*u*e*(1-e)*(1-e)+3*d*e*e*(1-e)+l*e*e*e,y=a*(1-e)*(1-e)*(1-e)+3*h*e*(1-e)*(1-e)+3*g*e*e*(1-e)+c*e*e*e;return{x:v,y}}function t2(e,t){const{worldRect:i,lineGradientFromColor:n,lineGradientToColor:r,lineGradientAngle:s}=t.calculative;return Sv(e,i,n,r,s)}function Sv(e,t,i,n,r){if(!i||!n)return;const{x:s,y:a,center:l,ex:c,ey:u}=t,h={x:s,y:l.y},d={x:c,y:l.y};r%90===0&&r%180?(h.x=l.x,d.x=l.x,r%270?(h.y=a,d.y=u):(h.y=u,d.y=a)):r&&(Gt(h,r,t.center),Gt(d,r,t.center));const g=e.createLinearGradient(h.x,h.y,d.x,d.y);return g.addColorStop(0,i),g.addColorStop(1,n),g}function e2(e){const{worldIconRect:t,iconWidth:i,iconHeight:n,imgNaturalWidth:r,imgNaturalHeight:s}=e.calculative;let{x:a,y:l,width:c,height:u}=t;if(i&&(c=i),n&&(u=n),r&&s&&e.imageRatio){const h=t.width/r,d=t.height/s,g=Math.min(h,d),v=r/s;i?u=i/v:n?c=n*v:(c=g*r,u=g*s)}switch(a+=(t.width-c)/2,l+=(t.height-u)/2,e.iconAlign){case"top":l=t.y;break;case"bottom":l=t.ey-u;break;case"left":a=t.x;break;case"right":a=t.ex-c;break;case"left-top":a=t.x,l=t.y;break;case"right-top":a=t.ex-c,l=t.y;break;case"left-bottom":a=t.x,l=t.ey-u;break;case"right-bottom":a=t.ex-c,l=t.ey-u;break}return{x:a,y:l,width:c,height:u}}function Pr(e,t){const{x:i,y:n,width:r,height:s}=e2(t),{worldIconRect:a,iconRotate:l,img:c}=t.calculative;if(l){const{x:u,y:h}=a.center;e.translate(u,h),e.rotate(l*Math.PI/180),e.translate(-u,-h)}if(t.imageRadius){e.save();let u=t.calculative.imageRadius||0,h=u;const{x:d,y:g,width:v,height:y,ex:w,ey:p}=t.calculative.worldRect;u<1&&(u=v*u,h=y*h);let _=u<h?u:h;v<2*_&&(_=v/2),y<2*_&&(_=y/2),e.beginPath(),e.moveTo(d+_,g),e.arcTo(w,g,w,p,_),e.arcTo(w,p,d,p,_),e.arcTo(d,p,d,g,_),e.arcTo(d,g,w,g,_),e.clip(),e.drawImage(c,i,n,r,s),e.restore()}else e.drawImage(c,i,n,r,s)}function An(e,t){const{textColor:i,color:n}=e.calculative,{data:r,options:s}=t;return i||n||r.textColor||r.color||s.textColor||s.color}function Pv(e,t){const{fontStyle:i,fontWeight:n,fontSize:r,fontFamily:s,lineHeight:a,text:l,hiddenText:c,canvas:u,textHasShadow:h,textBackground:d,textType:g}=t.calculative;if(l==null||c)return;const v=u.store;e.save(),h||(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0);let y;t.calculative.disabled?y=t.disabledTextColor||t.disabledColor||Ae(.4,An(t,v)):t.calculative.hover?y=t.hoverTextColor||t.hoverColor||v.options.hoverColor:t.calculative.active&&(y=t.activeTextColor||t.activeColor||v.options.activeColor);let w;g===Br.Linear?w=K_(e,t):g===Br.Radial&&(w=$_(e,t)),e.fillStyle=y||w||An(t,v),e.font=Rn({fontStyle:i,fontWeight:n,fontFamily:s||v.options.fontFamily,fontSize:r,lineHeight:a}),!t.calculative.textDrawRect&&Ev(e,t);const{x:p,y:_,width:A,height:x}=t.calculative.textDrawRect;d&&(e.save(),e.fillStyle=d,e.fillRect(p,_,A,x),e.restore());const E=.55,I=t.textAlign||v.options.textAlign,M=r*a;t.calculative.textLines.forEach((B,D)=>{const q=t.calculative.textLineWidths[D];let Q=0;I==="center"?Q=(A-q)/2:I==="right"&&(Q=A-q),e.fillText(B,p+Q,_+(D+E)*M);const{textDecorationColor:C,textDecorationDash:T,textDecoration:S}=t;S&&i2(e,{x:p+Q,y:_+(D+E)*M,width:q},{textDecorationColor:C,textDecorationDash:T,fontSize:r});const{textStrickoutColor:O,textStrickoutDash:K,textStrickout:Z}=t;Z&&n2(e,{x:p+Q,y:_+(D+E)*M,width:q},{textStrickoutColor:O,textStrickoutDash:K,fontSize:r})}),e.restore()}function i2(e,t,i){const{textDecorationColor:n,textDecorationDash:r,fontSize:s}=i;let{x:a,y:l,width:c}=t;switch(e.textBaseline){case"top":l+=s;break;case"middle":l+=s/2;break}e.save(),e.beginPath(),e.strokeStyle=n||e.fillStyle,e.lineWidth=1,e.moveTo(a,l),e.setLineDash(r||[]),e.lineTo(a+c,l),e.stroke(),e.restore()}function n2(e,t,i){const{textStrickoutColor:n,textStrickoutDash:r,fontSize:s}=i;let{x:a,y:l,width:c}=t;switch(e.textBaseline){case"top":l+=s/2;break;case"bottom":l-=s/2;break}e.save(),e.beginPath(),e.strokeStyle=n||e.fillStyle,e.lineWidth=1,e.moveTo(a,l),e.setLineDash(r||[]),e.lineTo(a+c,l),e.stroke(),e.restore()}function Iv(e,t,i){if(i==null)return;const{fontStyle:n,fontWeight:r,fontSize:s,fontFamily:a,lineHeight:l,canvas:c}=t.calculative,u=c.store;e.save();let h;t.calculative.hover?h=t.hoverTextColor||t.hoverColor||u.options.hoverColor:t.calculative.active&&(h=t.activeTextColor||t.activeColor||u.options.activeColor),e.fillStyle=h||An(t,u),e.font=Rn({fontStyle:n,fontWeight:r,fontFamily:a||u.options.fontFamily,fontSize:s,lineHeight:l});const d=e.measureText(i).width;let g,v;for(const y of t.calculative.worldAnchors){if(!v){v=y;continue}const w=Za(v,y),p=Math.floor(w/d);g="";for(let A=0;A<p;A++)g+=i;const _=hi(v,y)-270;if(e.save(),_%360!==0){const{x:A,y:x}=v;e.translate(A,x);let E=_*Math.PI/180;e.rotate(E),e.translate(-A,-x)}e.fillText(g,v.x,v.y+l/2),e.restore(),v=y}e.restore()}function Lv(e,t){const i=t.calculative.canvas.store;e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.textAlign="center",e.textBaseline="middle";const n=t.calculative.worldIconRect;let r=n.x+n.width/2,s=n.y+n.height/2;switch(t.iconAlign){case"top":s=n.y,e.textBaseline="top";break;case"bottom":s=n.ey,e.textBaseline="bottom";break;case"left":r=n.x,e.textAlign="left";break;case"right":r=n.ex,e.textAlign="right";break;case"left-top":r=n.x,s=n.y,e.textAlign="left",e.textBaseline="top";break;case"right-top":r=n.ex,s=n.y,e.textAlign="right",e.textBaseline="top";break;case"left-bottom":r=n.x,s=n.ey,e.textAlign="left",e.textBaseline="bottom";break;case"right-bottom":r=n.ex,s=n.ey,e.textAlign="right",e.textBaseline="bottom";break}const a=t.calculative.iconWeight;let l;const c=t.calculative.iconFamily;t.calculative.iconSize>0?l=t.calculative.iconSize:n.width>n.height?l=n.height:l=n.width,e.font=Rn({fontSize:l,fontWeight:a,fontFamily:c}),e.fillStyle=t.calculative.iconColor||An(t,i),t.calculative.iconRotate&&(e.translate(n.center.x,n.center.y),e.rotate(t.calculative.iconRotate*Math.PI/180),e.translate(-n.center.x,-n.center.y)),e.beginPath(),e.fillText(t.calculative.icon,r,s),e.restore()}function Dv(e,t){const i=t.calculative.canvas.store.data.scale,n=t.calculative.canvas.inputDiv.dataset.penId,{x:r,y:s,width:a,height:l}=t.calculative.worldRect;e.save(),e.beginPath(),t.id===n?(e.moveTo(r+a-20*i,s+l/2+2*i),e.lineTo(r+a-14*i,s+l/2-4*i),e.lineTo(r+a-8*i,s+l/2+2*i)):(e.moveTo(r+a-20*i,s+l/2-4*i),e.lineTo(r+a-14*i,s+l/2+2*i),e.lineTo(r+a-8*i,s+l/2-4*i)),e.stroke(),e.restore()}function Rn({fontStyle:e="normal",textDecoration:t="normal",fontWeight:i="normal",fontSize:n=12,fontFamily:r="Arial",lineHeight:s=1}={}){return`${e} ${t} ${i} ${n}px/${s} ${r}`}function Vn(e,t){const{x:i,ex:n,y:r,ey:s}=t.calculative.worldRect||{};t.calculative.flipX&&(e.translate(i+n+.5,.5),e.scale(-1,1)),t.calculative.flipY&&(e.translate(.5,r+s+.5),e.scale(1,-1))}function Qi(e,t,i=!1){const{x:n,y:r}=t.calculative.worldRect.pivot||t.calculative.worldRect.center;e.translate(n,r);let s=t.calculative.rotate*Math.PI/180;i||(t.calculative.flipX&&(s*=-1),t.calculative.flipY&&(s*=-1)),e.rotate(s),e.translate(-n,-r)}function Nn(e,t,i){e.save(),e.translate(.5,.5),e.beginPath();const n=t.calculative.canvas.store,r=t.textFlip||n.options.textFlip,s=t.textRotate||n.options.textRotate;(!r||!s)&&e.save(),Vn(e,t),t.calculative.rotate&&t.name!=="line"&&Qi(e,t),(t.calculative.lineWidth>1||i)&&(e.lineWidth=t.calculative.lineWidth),d2(e,n,t);let a,l=!1,c;t.calculative.disabled?(c=t.disabledColor||n.options.disabledColor||Ae(.4,t.calculative.color||cs(n)),a=t.disabledBackground||n.options.disabledBackground||Ae(.4,t.calculative.background||n.data.penBackground)):t.mouseDownValid&&t.calculative.mouseDown?(c=t.mouseDownColor||Ae(-.4,t.calculative.color||cs(n)),a=t.mouseDownBackground||Ae(-.4,t.calculative.background||n.data.penBackground)):t.switch&&t.calculative.checked?t.calculative.bkType||(a=t.onBackground):t.calculative.hover?(c=t.hoverColor||n.options.hoverColor,a=t.hoverBackground||n.options.hoverBackground):t.calculative.active?(c=t.activeColor||n.options.activeColor,a=t.activeBackground||n.options.activeBackground):t.calculative.isDock&&(t.type===jt.Line?c=n.options.dockPenColor:a=qa(n.options.dockPenColor,.2));const u=t.calculative.strokeImg;if(t.calculative.strokeImage&&u)e.strokeStyle=c||e.createPattern(u,"repeat");else{let d;t.calculative.strokeType?t.calculative.lineGradientColors?t.name==="line"?l=!0:t.calculative.lineGradient?d=t.calculative.lineGradient:(d=X_(e,t),t.calculative.lineGradient=d):d=t2(e,t):d=t.calculative.color||(t.type?n.data.lineColor:"")||cs(n),e.strokeStyle=c||d}const h=t.calculative.backgroundImg;if(t.calculative.backgroundImage&&h)e.fillStyle=a||e.createPattern(h,"repeat"),a=!0;else{let d;t.calculative.bkType===Br.Linear?t.calculative.gradientColors?t.calculative.gradient?d=t.calculative.gradient:(d=V_(e,t),t.calculative.gradient=d):d=U_(e,t):t.calculative.bkType===Br.Radial?t.calculative.gradientColors?t.calculative.radialGradient?d=t.calculative.radialGradient:(d=j_(e,t),t.calculative.radialGradient=d):d=W_(e,t):d=t.calculative.background||n.data.penBackground,e.fillStyle=a||d,a=!!d}if(Mv(e,t),Bv(e,t),$n(e,t),t.calculative.lineDash&&e.setLineDash(t.calculative.lineDash.map(d=>d*t.calculative.canvas.store.data.scale)),t.calculative.lineDashOffset&&(e.lineDashOffset=t.calculative.lineDashOffset),t.calculative.shadowColor&&(e.shadowColor=t.calculative.shadowColor,e.shadowOffsetX=t.calculative.shadowOffsetX,e.shadowOffsetY=t.calculative.shadowOffsetY,e.shadowBlur=t.calculative.shadowBlur),l?(Tv(e,t),Nv(!0,e,t,n)):(Ov(!0,e,t,n,a),jv(e,t)),!(t.image&&t.calculative.img)&&t.calculative.icon&&Lv(e,t),t.dropdownList&&Dv(e,t),(!r||!s)&&e.restore(),r&&!s&&Vn(e,t),!r&&s&&t.calculative.rotate&&t.name!=="line"&&Qi(e,t,!0),Pv(e,t),t.type===jt.Line&&t.fillTexts)for(const d of t.fillTexts)Iv(e,t,d);e.restore()}function Mv(e,t){const i=t.lineCap||(t.type?"round":"square");i?e.lineCap=i:t.type&&(e.lineCap="round")}function Bv(e,t){const i=t.lineJoin;i?e.lineJoin=i:t.type&&(e.lineJoin="round")}function ja(e,t,i,n){var u;e.save(),i&&e.translate(-i.x,-i.y),(u=e.setAttrs)==null||u.call(e,t);let r=!1;const s=t.calculative.canvas.store,a=t.textFlip||s.options.textFlip,l=t.textRotate||s.options.textRotate;e.beginPath(),(!a||!l)&&e.save(),t.calculative.flipX&&(e.translate(t.calculative.worldRect.x+t.calculative.worldRect.ex,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,t.calculative.worldRect.y+t.calculative.worldRect.ey),e.scale(1,-1)),t.calculative.rotate&&t.name!=="line"&&Qi(e,t),(t.calculative.lineWidth>1||n)&&(e.lineWidth=t.calculative.lineWidth);let c;if(t.calculative.hover)e.strokeStyle=t.hoverColor||s.options.hoverColor,e.fillStyle=t.hoverBackground||s.options.hoverBackground,c=t.hoverBackground||s.options.hoverBackground;else if(t.calculative.active)e.strokeStyle=t.activeColor||s.options.activeColor,e.fillStyle=t.activeBackground||s.options.activeBackground,c=t.activeBackground||s.options.activeBackground;else{if(t.strokeImage)t.calculative.strokeImg&&(e.strokeStyle=e.createPattern(t.calculative.strokeImg,"repeat"),c=!0);else{let h;t.calculative.strokeType&&t.calculative.lineGradientColors&&t.name==="line"?r=!0:h=t.calculative.color||cs(s),e.strokeStyle=h}t.backgroundImage?t.calculative.backgroundImg&&(e.fillStyle=e.createPattern(t.calculative.backgroundImg,"repeat"),c=!0):(e.fillStyle=t.background,c=!!t.background)}if(Mv(e,t),Bv(e,t),$n(e,t),t.calculative.lineDash&&e.setLineDash(t.calculative.lineDash),t.calculative.lineDashOffset&&(e.lineDashOffset=t.calculative.lineDashOffset),t.calculative.shadowColor&&(e.shadowColor=t.calculative.shadowColor,e.shadowOffsetX=t.calculative.shadowOffsetX,e.shadowOffsetY=t.calculative.shadowOffsetY,e.shadowBlur=t.calculative.shadowBlur),r?(Tv(e,t),Nv(!0,e,t,s)):(Ov(!1,e,t,s,c),jv(e,t)),t.calculative.img?(e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,Pr(e,t),e.restore()):t.calculative.icon&&Lv(e,t),t.dropdownList&&Dv(e,t),(!a||!l)&&e.restore(),a&&!l&&(t.calculative.flipX&&(e.translate(t.calculative.worldRect.x+t.calculative.worldRect.ex,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,t.calculative.worldRect.y+t.calculative.worldRect.ey),e.scale(1,-1))),!a&&l&&t.calculative.rotate&&t.name!=="line"&&Qi(e,t,!0),Pv(e,t),t.type===jt.Line&&t.fillTexts)for(const h of t.fillTexts)Iv(e,t,h);e.restore()}function Ov(e=!0,t,i,n,r){if(i.name==="drawCommand")return;const s=e?n.path2dMap.get(i):At.path2dDraws[i.name];let a=null,l=null;if(i.type===jt.Line&&(i.fromLineCap&&i.fromLineCap!=="butt"&&(t.lineCap="butt",a=new Path2D,a.moveTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y),a.lineTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y)),i.toLineCap&&i.toLineCap!=="butt"&&(t.lineCap="butt",l=new Path2D,l.moveTo(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].x,i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].y),l.lineTo(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].x,i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].y))),s){if(i.type===jt.Line&&i.borderWidth){t.save(),t.beginPath();const u=i.calculative.lineWidth+i.calculative.borderWidth;t.lineWidth=u,t.strokeStyle=i.borderColor,a&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(a),t.restore()),s instanceof Path2D?(r&&t.fill(s),u&&t.stroke(s)):(s(i,t),r&&t.fill(),u&&t.stroke()),l&&(t.save(),t.lineCap=i.toLineCap,t.stroke(l),t.restore()),t.restore()}s instanceof Path2D?i.type?i.close&&r&&t.fill(s):r&&t.fill(s):(t.save(),s(i,t),r&&t.fill(),t.restore());const c=i.calculative.progress;if(c!=null){t.save();const{ex:u,x:h,y:d,width:g,height:v,ey:y}=i.calculative.worldRect;let w=null;if(i.calculative.verticalProgress?w=i.reverseProgress?t.createLinearGradient(h,d,h,d+v*c):t.createLinearGradient(h,y,h,d+v*(1-c)):w=i.reverseProgress?t.createLinearGradient(u,d,h+g*(1-c),d):t.createLinearGradient(h,d,h+g*c,d),i.calculative.progressGradientColors){const{colors:p}=Qn(i.calculative.progressGradientColors);p.forEach(_=>{w.addColorStop(_.i,_.color)})}else{const p=i.calculative.progressColor||i.calculative.color||n.options.activeColor;w.addColorStop(0,p),w.addColorStop(1,p)}w.addColorStop(1,"transparent"),t.fillStyle=w,s instanceof Path2D?t.fill(s):(s(i,t),t.fill()),t.restore()}if(i.calculative.lineWidth&&(s instanceof Path2D?(n.options.svgPathStroke||i.name!=="svgPath")&&(a&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(a),t.restore()),t.stroke(s),l&&(t.save(),t.lineCap=i.toLineCap,t.stroke(l),t.restore())):(s(i,t),t.stroke())),i.type){if(i.calculative.animatePos){if(t.save(),Fv(t,i,n),i.lineAnimateType===Je.Arrow||i.lineAnimateType===Je.WaterDrop){let u=Zv(i,t);u instanceof Path2D?(t.stroke(u),t.fill(u)):(t.stroke(),t.fill())}else s instanceof Path2D?(a&&!i.lineAnimateType&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(a),t.restore()),t.lineCap=i.lineCap,t.stroke(s)):(s(i,t),t.stroke());t.restore()}i.fromArrow&&Rv(t,i,n),i.toArrow&&Cv(t,i,n),i.calculative.active&&!i.calculative.pencil&&!n.options.disableAnchor&&!n.data.locked&&zv(t,i)}}}function Nv(e=!0,t,i,n){const r=e?n.path2dMap.get(i):At.path2dDraws[i.name];if(r&&i.type){if(i.calculative.animatePos){if(t.save(),Fv(t,i,n),t.beginPath(),r instanceof Path2D)if(i.lineName==="polyline"||i.lineName==="line")if(i.lineAnimateType===Je.Arrow||i.lineAnimateType===Je.WaterDrop){const s=Zv(i);t.stroke(s),t.fill(s)}else i.calculative.gradientSmooth||i.calculative.lineSmooth?(i.calculative.gradientAnimatePath||(i.calculative.gradientAnimatePath=Nc(i)),i.calculative.gradientAnimatePath instanceof Path2D&&t.stroke(i.calculative.gradientAnimatePath)):t.stroke(r);else t.stroke(r);else r(i,t),t.stroke();t.restore()}i.fromArrow&&Rv(t,i,n),i.toArrow&&Cv(t,i,n),i.calculative.active&&!i.calculative.pencil&&!n.options.disableAnchor&&!n.data.locked&&zv(t,i)}}function Fv(e,t,i){e.strokeStyle=t.animateColor||i.options.animateColor,t.animateShadow&&(e.shadowBlur=t.animateShadowBlur||t.animateLineWidth||6,e.shadowColor=t.animateShadowColor||t.animateColor||i.options.animateColor),t.calculative.animateLineWidth&&(e.lineWidth=t.calculative.animateLineWidth*i.data.scale);let n=0;switch(t.lineAnimateType){case Je.Beads:t.animateReverse?e.lineDashOffset=t.calculative.animatePos:e.lineDashOffset=t.length-t.calculative.animatePos,n=t.calculative.lineWidth||5,n<5&&(n=5);const r=t.animateLineDash&&t.animateLineDash.map(s=>s*n/5);e.setLineDash(r||[n,n*2]);break;case Je.Dot:t.animateReverse?e.lineDashOffset=t.calculative.animatePos:e.lineDashOffset=t.length-t.calculative.animatePos,n=t.calculative.animateDotSize||t.calculative.lineWidth*2||6,n<6&&(n=6),n>40&&(n=40),e.lineWidth=(t.calculative.animateLineWidth||n)*i.data.scale,e.setLineDash([.1,t.length]);break;case Je.Arrow:e.fillStyle=t.animateColor||i.options.animateColor,e.lineWidth=1;break;case Je.WaterDrop:e.fillStyle=t.animateColor||i.options.animateColor,e.lineWidth=1;break;default:t.animateReverse?(e.lineDashOffset=Number.EPSILON,e.setLineDash([0,t.length-t.calculative.animatePos+1,t.calculative.animatePos])):e.setLineDash([t.calculative.animatePos,t.length+.01-t.calculative.animatePos]);break}}function cs(e){const{data:t,options:i}=e;return t.color||i.color}function zv(e,t){const i=t.calculative.canvas.store;e.save(),e.lineWidth=1,e.fillStyle=t.activeColor||i.options.activeColor,t.calculative.worldAnchors.forEach(n=>{!n.hidden&&!n.isTemp&&r2(e,n,t)}),e.restore()}function r2(e,t,i){if(!t)return;const n=i.calculative.canvas.store.activeAnchor===i.calculative.activeAnchor&&i.calculative.activeAnchor===t;let r=3;i.calculative.lineWidth>3&&(r=i.calculative.lineWidth),i.anchorRadius&&(r=i.anchorRadius),t.radius&&(r=t.radius),n?(t.prev&&(e.save(),e.strokeStyle="#4dffff",e.beginPath(),e.moveTo(t.prev.x,t.prev.y),e.lineTo(t.x,t.y),e.stroke(),e.restore(),e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.prev.x,t.prev.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore()),t.next&&(e.save(),e.strokeStyle="#4dffff",e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.next.x,t.next.y),e.stroke(),e.restore(),e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.next.x,t.next.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke()),e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke()):(e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.x,t.y,r,0,Math.PI*2),e.fill(),e.stroke(),e.restore())}function Hv(e){const t=e.calculative.canvas.store;let i={x:e.x,y:e.y};if(!e.parentId||e.parentId&&!t.pens[e.parentId])e.parentId=void 0,i.width=e.width,i.height=e.height,i.rotate=e.rotate,ae(i),ee(i),e.pivot&&mc(i,e.pivot);else{const n=t.pens[e.parentId];let r=n.calculative.worldRect;r||(r=Hv(n)),i.x=r.x+r.width*e.x,i.y=r.y+r.height*e.y,i.width=r.width*e.width,i.height=r.height*e.height,n.flipX&&(i.x=r.width-(i.x-r.x+i.width)+r.x),n.flipY&&(i.y=r.height-(i.y-r.y+i.height)+r.y),ae(i),i.rotate=r.rotate+e.rotate,ee(i),e.pivot&&mc(i,e.pivot)}return e.calculative.worldRect=i,Fc(e,i),i}function Fc(e,t){!e.paddingTop&&(e.calculative.paddingTop=0),!e.paddingBottom&&(e.calculative.paddingBottom=0),!e.paddingLeft&&(e.calculative.paddingLeft=0),!e.paddingRight&&(e.calculative.paddingRight=0),Math.abs(e.calculative.paddingTop)<1&&(e.calculative.paddingTop*=t.height),Math.abs(e.calculative.paddingBottom)<1&&(e.calculative.paddingBottom*=t.height),Math.abs(e.calculative.paddingLeft)<1&&(e.calculative.paddingLeft*=t.width),Math.abs(e.calculative.paddingRight)<1&&(e.calculative.paddingRight*=t.width)}function Da(e){const t=ct(e.calculative.worldRect);if(delete t.pivot,!e.parentId){Object.assign(e,t);return}const n=e.calculative.canvas.store.pens[e.parentId].calculative.worldRect;Object.assign(e,mn(t,n))}function Ir(e){const t=e.calculative.canvas.store;let i=[];if(e.anchors){let n=ct(e.anchors);e.flipX&&n.forEach(r=>{r.x=.5-(r.x-.5)}),e.flipY&&n.forEach(r=>{r.y=.5-(r.y-.5)}),n.forEach(r=>{i.push(s2(e,r))})}if(!i.length&&!e.type&&!e.calculative.canvas.parent.isCombine(e)){const{x:n,y:r,width:s,height:a}=e.calculative.worldRect;i=t.options.defaultAnchors.map((l,c)=>({id:`${c}`,penId:e.id,x:n+s*l.x,y:r+a*l.y}))}e.calculative.rotate&&i.forEach(n=>{Gt(n,e.calculative.rotate,e.calculative.worldRect.pivot||e.calculative.worldRect.center)}),(!e.type||e.anchors)&&(e.calculative.worldAnchors=i),e.calculative.activeAnchor&&i.length&&(e.calculative.activeAnchor=i.find(n=>{n.id,e.calculative.activeAnchor.id})),e.calculative.gradientAnimatePath=void 0}function Uv(e){var t;if((t=e.children)!=null&&t.length){let i=e.calculative.worldRect;e.children.forEach(n=>{const r=e.calculative.canvas.store.pens[n];r.calculative.initRect&&r.calculative.initRelativeRect&&(r.calculative.initRect.x=i.x+i.width*r.calculative.initRelativeRect.x,r.calculative.initRect.y=i.y+i.height*r.calculative.initRelativeRect.y,r.calculative.initRect.ex=r.calculative.initRect.x+i.width*r.calculative.initRelativeRect.width,r.calculative.initRect.ey=r.calculative.initRect.y+i.height+r.calculative.initRelativeRect.height,ee(r.calculative.initRect)),Uv(r)})}}function s2(e,t){const i={...t},{x:n,y:r,width:s,height:a}=e.calculative.worldRect;return i.x=n+s*t.x,i.y=r+a*t.y,t.prev&&(i.prev={penId:e.id,connectTo:t.prev.connectTo,x:n+s*t.prev.x,y:r+a*t.prev.y}),t.next&&(i.next={penId:e.id,connectTo:t.next.connectTo,x:n+s*t.next.x,y:r+a*t.next.y}),i}function zf(e,t){const{paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:s}=t.calculative;let a=r,l=i,c=t.calculative.worldRect.width-r-s,u=t.calculative.worldRect.height-i-n,h=t.calculative.iconLeft,d=t.calculative.iconTop;h&&Math.abs(h)<1&&(h=t.calculative.worldRect.width*h),d&&Math.abs(d)<1&&(d=t.calculative.worldRect.height*d),a+=h||0,l+=d||0,c-=h||0,u-=d||0;let g=t.calculative.iconRotate||0;if(t.parentId){const v=e[t.parentId].calculative;v&&(g+=v.rotate,g%=360)}a=t.calculative.worldRect.x+a,l=t.calculative.worldRect.y+l,t.calculative.worldIconRect={x:a,y:l,width:c,height:u,rotate:g},ae(t.calculative.worldIconRect),ee(t.calculative.worldIconRect)}function br(e,t,i){ms(e.calculative.worldRect,t,i,e.pivot),e.calculative.initRect&&ms(e.calculative.initRect,t,i,e.pivot),Wv(e,t,i),e.calculative.x&&Wa(e.calculative,t,i),e.type&&Ir(e)}function Wv(e,t,i){var n;!e||(n=e.children)!=null&&n.length&&e.children.forEach(r=>{const s=e.calculative.canvas.store.pens[r];s&&(s.calculative.initRect&&ms(s.calculative.initRect,t,i),Wv(s,t,i))})}function a2(e,t){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);const i={id:t.id,penId:e.id,x:t.x,y:t.y};if(e.calculative.worldAnchors.push(i),e.calculative.worldRect){e.rotate%360&&Gt(t,-e.rotate,e.calculative.worldRect.center);const n={id:t.id,penId:e.id,x:(t.x-e.calculative.worldRect.x)/e.calculative.worldRect.width,y:(t.y-e.calculative.worldRect.y)/e.calculative.worldRect.height};e.anchors.push(n)}return i}function o2(e,t,i){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);const n=nk(e,t,i);return e.calculative.worldAnchors.splice(i+1,0,n),e.anchors.splice(i+1,0,hs(n,e.calculative.worldRect)),e.calculative.activeAnchor=n,n}function l2(e,t){if(!e||!e.calculative.worldAnchors)return;let i=e.calculative.worldAnchors.findIndex(n=>n.id===t.id);i>-1&&e.calculative.worldAnchors.splice(i,1),i=e.anchors.findIndex(n=>n.id===t.id),i>-1&&e.anchors.splice(i,1)}function Or(e,t){if(!t||!t.calculative||!t.calculative.worldRect.center)return Lt.None;if(e.anchorId){let i=t.anchors.filter(n=>n.id===e.anchorId);if(i.length&&i[0].direction>-1)return i[0].direction}return l_(e,t.calculative.worldRect.center)}function Cr(e,t){let i=1/0,n;return e.calculative.worldAnchors.forEach(r=>{const s=Za(t,r);i>s&&(i=s,n=r)}),n}function Hf(e,t,i){e.x+=t,e.y+=i,e.anchors&&e.anchors.forEach(n=>{ls(n,t,i)}),e.calculative.worldAnchors&&e.calculative.worldAnchors.forEach(n=>{ls(n,t,i)})}function zc(e){if(e&&e.calculative&&e.calculative.worldAnchors.length){let t=qt(e);if(!e.anchors||!e.anchors.length)for(;e.calculative.worldAnchors.length&&t!==e.calculative.activeAnchor;)e.calculative.worldAnchors.pop(),t=qt(e);else t===e.calculative.activeAnchor?e.calculative.worldAnchors=[e.calculative.worldAnchors[0]]:e.calculative.worldAnchors[0]===e.calculative.activeAnchor&&(e.calculative.worldAnchors=[e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]])}}function we(e,t,i,n){var l,c,u,h,d,g;if(!e||!t||!i||!n||t.twoWay===Ee.DisableConnected||t.twoWay===Ee.Disable||n.twoWay===Ee.DisableConnectTo||n.twoWay===Ee.Disable)return;if(t.twoWay===Ee.In){if(i.calculative.worldAnchors.length===1)return;const v=qt(i);if(n.id!==v.id)return}if(t.twoWay===Ee.Out){const v=le(i);if(n.id!==v.id)return}if(n.connectTo===e.id&&n.anchorId===t.id)return;if(n.connectTo){const v=e.calculative.canvas.store.pens[n.connectTo];Tr(v,Fn(v,n.anchorId),i,n)}e.connectedLines||(e.connectedLines=[]),e.connectedLines.findIndex(v=>v.lineId===i.id&&v.lineAnchor===n.id&&v.anchor===t.id)<0&&e.connectedLines.push({lineId:i.id,lineAnchor:n.id,anchor:t.id}),n.connectTo=e.id,n.anchorId=t.id,e.type&&we(i,n,e,t),e.calculative.canvas.store.emitter.emit("connectLine",{line:i,lineAnchor:n,pen:e,anchor:t});let s=((l=i.calculative.worldAnchors)==null?void 0:l.length)>=2?(c=i.calculative.worldAnchors)==null?void 0:c[0].connectTo:void 0,a=((u=i.calculative.worldAnchors)==null?void 0:u.length)>=2?(d=i.calculative.canvas.store.pens[(h=i.calculative.worldAnchors)==null?void 0:h[0].connectTo])==null?void 0:d.anchors.find(v=>{var y;return v.id===((y=i.calculative.worldAnchors)==null?void 0:y[0].anchorId)}):void 0;return(g=e.onConnectLine)==null||g.call(e,e,{line:i,lineAnchor:n,pen:e,anchor:t,fromPen:s,fromAnchor:a}),!0}function Tr(e,t,i,n){if(!(!e||!t||!i||!n)&&!(!e.connectedLines||!e.connectedLines.length))return i.lastConnected||(i.lastConnected={}),i.lastConnected[e.id]||(i.lastConnected[e.id]=ct(e.connectedLines)),e.connectedLines.forEach((r,s,a)=>{(r.lineId===i.id||r.lineId===i.id)&&r.lineAnchor===n.id&&r.anchor===t.id&&a.splice(s,1)}),n.connectTo=void 0,n.anchorId=void 0,e.type&&t.connectTo===i.id&&t.anchorId===n.id&&Tr(i,n,e,t),e.calculative.canvas.store.emitter.emit("disconnectLine",{line:i,lineAnchor:n,pen:e,anchor:t}),!0}function Fn(e,t){var i;if(!(!e||!t))return(i=e.calculative.worldAnchors)==null?void 0:i.find(n=>n.id===t)}function le(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[0]}function qt(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]}function c2(e,t){var n,r;if(e.calculative.start===0||!e.frames||!e.frames.length)return e.calculative.start=void 0,0;if(!e.calculative.duration){e.calculative.duration=0;for(const s of e.frames){e.calculative.duration+=s.duration;for(const a in s)a!=="duration"&&!e[a]&&a==="scale"&&(e[a]=1)}}if(e.animateCycle||(e.animateCycle=1/0),e.calculative.start){let s=0;const a=Math.ceil((t-e.calculative.start)/e.calculative.duration);if(a>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,Wf(e,1),0;const l=(t-e.calculative.start)%e.calculative.duration;let c=0;for(const d of e.frames)if(c+=d.duration,l>c)++s;else break;if(!e.frames[s])return!0;e.calculative.frameDuration=e.frames[s].duration,e.calculative.frameStart=e.calculative.start+e.calculative.duration*(a-1),e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration;const u=s!==e.calculative.frameIndex,h=a>e.calculative.cycleIndex;if(u&&(e.calculative.frameIndex=s),h&&(e.calculative.cycleIndex=a),u||h)if(e.calculative.x=e.calculative.initRect.x,e.calculative.y=e.calculative.initRect.y,((r=e.children)==null?void 0:r.length)&&!e.parentId?e.calculative.canvas.rotatePen(e,(e.calculative.initRect.rotate||0)-(e.calculative.rotate||0),e.calculative.initRect):e.calculative.rotate=e.calculative.initRect.rotate||0,s>0){e.prevFrame={};const d=e.frames[s-1];for(const g in d)e.prevFrame[g]=d[g];Object.assign(e.prevFrame,{rotate:d.rotate||0,x:d.x||0,y:d.y||0,scale:d.scale||1})}else Uf(e)}else{if(e.calculative.start=t,e.calculative.frameIndex=0,e.calculative.frameStart=e.calculative.start,e.calculative.frameDuration=e.frames[0].duration,e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration,e.calculative.cycleIndex=1,e.calculative.x=e.calculative.worldRect.x,e.calculative.y=e.calculative.worldRect.y,e.calculative.initRect=ct(e.calculative.worldRect),e.parentId&&(e.calculative.initRelativeRect={x:e.x,y:e.y,width:e.width,height:e.height}),(n=e.children)!=null&&n.length){const s=e.calculative.canvas.store;e.calculative.childrenVisible={},e.children.forEach(a=>{e.calculative.childrenVisible[a]=s.pens[a].visible})}e.calculative.initRect.rotate=e.calculative.rotate||0,Uf(e)}const i=(t-e.calculative.frameStart)/e.calculative.frameDuration%1;return Wf(e,i),!0}function Uf(e){e.prevFrame={};for(const t in e)(typeof e[t]!="object"||t==="lineDash")&&(e.prevFrame[t]=e[t]);e.prevFrame.rotate=0,e.prevFrame.x=0,e.prevFrame.y=0,e.prevFrame.scale=1}function Wf(e,t){var n,r;if(t<0)return;t>1&&(t=1);const i=e.frames[e.calculative.frameIndex];for(const s in i)if(s!=="duration"){if(s==="scale"){e.calculative.worldRect=ct(e.calculative.initRect),ms(e.calculative.worldRect,e.prevFrame.scale,e.calculative.worldRect.center);const a=e.prevFrame.scale+(i[s]-e.prevFrame.scale)*t;ms(e.calculative.worldRect,a/e.prevFrame.scale,e.calculative.worldRect.center),e.calculative.patchFlags=!0}else if(s==="x"){const a=Dl(e,s,e.calculative.frameIndex);e.calculative.worldRect.x=e.calculative.initRect.x+a,e.calculative.worldRect.ex=e.calculative.initRect.ex+a,Hn(e.calculative.worldRect,i[s]*t*e.calculative.canvas.store.data.scale,0),e.calculative.patchFlags=!0}else if(s==="y"){const a=Dl(e,s,e.calculative.frameIndex);e.calculative.worldRect.y=e.calculative.initRect.y+a,e.calculative.worldRect.ey=e.calculative.initRect.ey+a,Hn(e.calculative.worldRect,0,i[s]*t*e.calculative.canvas.store.data.scale),e.calculative.patchFlags=!0}else if(s==="rotate"){e.prevFrame[s]>=360&&(e.prevFrame[s]%=360);const a=Dl(e,s,e.calculative.frameIndex),l=(e.calculative.initRect.rotate+a+i[s]*t)%360-(e.calculative.rotate||0);(n=e.children)!=null&&n.length?e.calculative.canvas.rotatePen(e,l,e.calculative.initRect):e.calculative.rotate=(e.calculative.initRect.rotate+a+i[s]*t)%360,e.calculative.patchFlags=!0}else if(s==="image")e.image=i.image,e.calculative.image=void 0,e.calculative.canvas.loadImage(e),e.canvasLayer===zt.CanvasImageBottom?e.calculative.canvas.canvasImageBottom.init():e.canvasLayer===zt.CanvasImage&&e.calculative.canvas.canvasImage.init();else if(h2(i[s],s,e)){e.prevFrame[s]==null&&(s==="globalAlpha"?e.prevFrame[s]=1:e.prevFrame[s]=0);const a=e.prevFrame[s]+(i[s]-e.prevFrame[s])*t;e.calculative[s]=Math.round(a*100)/100}else{if(s==="visible"){if(e.calculative.image)e.canvasLayer===zt.CanvasImageBottom?e.calculative.canvas.canvasImageBottom.init():e.canvasLayer===zt.CanvasImage&&e.calculative.canvas.canvasImage.init();else if((r=e.children)!=null&&r.length){const l=Ci(e,e.calculative.canvas.store);e.calculative.canvas.initImageCanvas(l)}}e.calculative[s]=i[s];const a={};a[s]=i[s],Hc(e,a)}s==="text"&&Es(e)}}function h2(e,t,i){const n=["strokeType","bkType","showChild"];return typeof e=="number"&&i.linear!==!1&&!n.includes(t)}function u2(e,t){if(e.calculative.start===0)return e.calculative.start=void 0,0;if(e.animateCycle||(e.animateCycle=1/0),e.animateSpan||(e.animateSpan=1),e.calculative.animatePos+=e.animateSpan*(e.calculative.canvas.store.data.scale||1),!e.calculative.start)e.calculative.start=Date.now(),e.calculative.animatePos=e.animateSpan*(e.calculative.canvas.store.data.scale||1),e.calculative.cycleIndex=1;else if(e.calculative.animatePos>e.length){if(++e.calculative.cycleIndex,e.calculative.cycleIndex>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,0;e.calculative.animatePos=e.animateSpan}return!0}function Rr(e,t=!0){if(!e.children||e.childActive===!1)return;const i=e.calculative.canvas.store;e.children.forEach(n=>{const r=i.pens[n];r&&(r.calculative.active=t,Rr(r,t))})}function rs(e,t=!0){if(!e)return;const i=e.calculative.canvas.store;e.calculative.hover=t,e.childHover!==!1&&e.children&&e.children.forEach(n=>{var r,s;((r=i.pens[n])==null?void 0:r.hoverColor)==null&&((s=i.pens[n])==null?void 0:s.hoverBackground)==null&&rs(i.pens[n],t)})}function ti(e,t){if(!t)return;const i=e.calculative.canvas.store,n=e.calculative.worldRect;t.style.opacity=e.globalAlpha+"",t.style.position="absolute",t.style.outline="none",t.style.left=n.x+i.data.x+"px",t.style.top=n.y+i.data.y+"px",t.style.width=n.width+"px",t.style.height=n.height+"px",t.style.display=e.calculative.inView!=!1?e.calculative.cssDisplay||"inline":"none",!e.calculative.rotate&&(e.calculative.rotate=0),t.style.transform=`rotate(${e.calculative.rotate}deg)`,e.calculative.rotate||(e.calculative.flipX&&(t.style.transform="rotateY(180deg)"),e.calculative.flipY&&(t.style.transform="rotateX(180deg)"),e.calculative.flipX&&e.calculative.flipY&&(t.style.transform="rotateZ(180deg)")),t.style.zIndex=e.calculative.zIndex!==void 0?e.calculative.zIndex+"":"5",e.calculative.zIndex>e.calculative.canvas.maxZindex&&(e.calculative.canvas.maxZindex=e.calculative.zIndex),e.locked===Ot.DisableEdit||e.locked===Ot.DisableMove||i.data.locked?(t.style.userSelect="initial",t.style.pointerEvents="initial",e.name==="gif"&&(t.style.userSelect="none",t.style.pointerEvents="none")):(t.style.userSelect="none",t.style.pointerEvents="none")}function Ll(e){return e.every(t=>t.locked)}function qf(e){return e.every(t=>t.disableRotate)}function qv(e,t,i){var n;e.type?(e.calculative.worldAnchors.forEach(r=>{Gt(r,t,i.center)}),f2(e),Da(e)):(e.calculative.rotate?e.calculative.rotate+=t:e.calculative.rotate=t,Gt(e.calculative.worldRect.center,t,i.center),e.parentId&&(e.calculative.worldRect.x=e.calculative.worldRect.center.x-e.calculative.worldRect.width/2,e.calculative.worldRect.y=e.calculative.worldRect.center.y-e.calculative.worldRect.height/2,e.x=(e.calculative.worldRect.x-i.x)/i.width,e.y=(e.calculative.worldRect.y-i.y)/i.height)),(n=e.children)==null||n.forEach(r=>{const s=e.calculative.canvas.store.pens[r];qv(s,t,i)})}function f2(e){var r;if(!((r=e.calculative.worldAnchors)!=null&&r.length)||!isFinite(e.x)||!isFinite(e.x)||e.x==null||e.y==null)return;const t=bc(e);e.parentId||Object.assign(e,t);const{fontSize:i,lineHeight:n}=e.calculative.canvas.store.options;e.fontSize?e.fontSize<0&&(e.fontSize=0,e.calculative.fontSize=0):(e.fontSize=i>=0?i:12,e.calculative.fontSize=e.fontSize*e.calculative.canvas.store.data.scale),e.lineHeight||(e.lineHeight=n,e.calculative.lineHeight=e.lineHeight),ee(t),e.calculative.worldRect=t,Fc(e,t),Ti(e),e.calculative.worldAnchors&&(e.anchors=e.calculative.worldAnchors.map(s=>hs(s,e.calculative.worldRect)))}function jf(e){return e.every(t=>t.disableSize||t.pivot)}function Dl(e,t,i){if(!e.frames||!t)return 0;let n=0;for(let r=0;r<i;r++)e.frames[r]&&(n+=e.frames[r][t]||0);return n}function Va(e,t){var n;let i=e;for(;i&&i.parentId;){const r=i;i=t.pens[i.parentId];const s=(n=i==null?void 0:i.calculative)==null?void 0:n.showChild;if(s!=null&&i.children[s]!==r.id)return!1}return!0}function Gi(e,t=!1){var r,s;const{store:i,canvasRect:n}=e.calculative.canvas;if(t&&((r=e.children)==null||r.forEach(a=>{const l=i.pens[a];l&&Gi(l,!0)})),e.calculative.inView=!0,!Va(e,i)||e.visible==!1||e.calculative.visible==!1)e.calculative.inView=!1;else{const{x:a,y:l,width:c,height:u,rotate:h}=e.calculative.worldRect,d={x:a+i.data.x,y:l+i.data.y,width:c,height:u,rotate:h};ae(d),Ji(d,n)||(e.calculative.inView=!1)}(s=e.calculative.singleton)!=null&&s.div&&ti(e,e.calculative.singleton.div)}function d2(e,t,i){if(t.fillWorldTextRect){e.save(),e.fillStyle="#c3deb7";const{x:n,y:r,width:s,height:a}=i.calculative.worldTextRect;e.fillRect(n,r,s,a),e.restore()}}function $n(e,t){const i=t.calculative.globalAlpha;typeof i=="number"&&i<1&&!isNaN(i)&&(e.globalAlpha=i)}function jv(e,t){const i=v2(e,t)||At.canvasDraws[t.name];i&&(e.save(),i(e,t),e.restore())}function v2(e,t){const i=t.drawCommand;if(!(!i||t.name==="line"))return(n,r)=>{i.forEach(s=>{try{s.steps=s.steps.flat(1/0),s.steps.reduce((a,l)=>{const c=g2(l,r,a.x,a.y);try{if(c.c){if(c.c.startsWith("_")){const h=c.c.split("_")[1];return typeof c.v.value=="number"&&(c.v.value*=r.calculative.canvas.store.data.scale),(c.p||n)[h]=c.v.value,{x:a.x,y:a.y}}let u=[];for(const h in c.v)u.push(c.v[h]);return(c.p||n)[c.c](...u),{x:c.startX||c.v.x,y:c.startY||c.v.y}}return{x:a.x,y:a.y}}catch{}},{})}catch{}}),n.stroke()}}function g2(e,t,i,n){return{visio:m2,dxf:y2}[t.parseType](e,t,i,n)}function y2(e,t,i,n){var h,d;const{x:r,y:s,width:a,height:l}=t.calculative.worldRect,{originWidth:c,originHeight:u}=t.dxfOrigin;switch(e.c){case"beginPath":return{c:"beginPath",v:{}};case"closePath":return{c:"closePath",v:{}};case"moveTo":return{c:"moveTo",v:{x:e.v.x*(a/c)+r,y:e.v.y*(l/u)+s}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(a/c)+r,y:e.v.y*(l/u)+s}};case"arc":return{c:"ellipse",v:{x:e.v.x*(a/c)+r,y:e.v.y*(l/u)+s,rx:e.v.xr*(a/c),ry:e.v.yr*(l/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(h=e.v.aclockwise)!=null?h:!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(a/c)+r,y:e.v.y*(l/u)+s,rx:e.v.xr*(a/c),ry:e.v.yr*(l/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(d=e.v.aclockwise)!=null?d:!0}};case"_font":return{c:"_font",v:{value:e.v.fontSize*t.calculative.canvas.store.data.scale+"px "+(e.v.fontFamily||t.calculative.canvas.store.options.fontFamily)}};case"_fillStyle":return{c:"_fillStyle",v:{value:t.color||e.v.value}};default:const g={c:e.c,v:{...e.v}};return g.v.x!==void 0&&(g.v.x=e.v.x*(a/c)+r),g.v.y!==void 0&&(g.v.y=e.v.y*(l/u)+s),g}}function m2(e,t,i,n){const{x:r,y:s,width:a,height:l}=t.calculative.worldRect,{width:c,height:u}=t.origin;switch(e.c){case"MoveTo":return{c:"moveTo",v:{x:+e.v.X*100*(a/c)+r,y:+e.v.Y*100*(l/u)+s}};case"RelMoveTo":return{c:"moveTo",v:{x:+e.v.X*c*(a/c)+r,y:+e.v.Y*u*(l/u)+s}};case"LineTo":return{c:"lineTo",v:{x:+e.v.X*100*(a/c)+r,y:+e.v.Y*100*(l/u)+s}};case"RelLineTo":return{c:"lineTo",v:{x:+e.v.X*c*(a/c)+r,y:+e.v.Y*u*(l/u)+s}};case"Ellipse":let h=e.v.X,d=e.v.Y,g=Math.abs(e.v.A-e.v.C),v=Math.abs(e.v.B-e.v.D);return{c:"ellipse",v:{x:h*100*(a/c)+r,y:d*100*(l/u)+s,radiuX:g*100*(a/c),radiuY:v*100*(l/u),rotation:0,startAngle:0,endAngle:Math.PI*2,anticlockwise:!0}};case"EllipticalArcTo":const y=e.v.X*100*(a/c)+r,w=e.v.Y*100*(l/u)+s,p=e.v.A*100*(a/c)+r,_=e.v.B*100*(l/u)+s;e.v.C;const A=e.v.D*(a/l)*(u/c),x=(y-i)*(_-n)-(w-n)*(p-i)>0,E=Vf(i,n,y,w,p,_,A);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=xa(E.x0,E.y0,i,n)),!e.orign.endA&&(e.orign.endA=xa(E.x0,E.y0,y,w)),{c:"ellipse",v:{centerX:E.x0,centerY:E.y0,radiuX:E.a,radiuY:E.b,rotation:0,startAngle:e.orign.startA,endAngle:e.orign.endA,anticlockwise:x},startX:y,startY:w};case"RelEllipticalArcTo":const I=e.v.X*c*(a/c)+r,M=e.v.Y*u*(l/u)+s,B=e.v.A*c*(a/c)+r,D=e.v.B*u*(l/u)+s;e.v.C;const q=e.v.D*(a/l)*(u/c),Q=(I-i)*(D-n)-(M-n)*(B-i)>0,C=Vf(i,n,I,M,B,D,q);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=xa(C.x0,C.y0,i,n)),!e.orign.endA&&(e.orign.endA=xa(C.x0,C.y0,I,M)),{c:"ellipse",v:{centerX:C.x0,centerY:C.y0,radiuX:C.a,radiuY:C.b,rotation:0,startAngle:e.orign.startA,endAngle:e.orign.endA,anticlockwise:Q},startX:I,startY:M};case"ArcTo":let T=e.v.X*100*a/c+r,S=e.v.Y*100*l/u+s,O=e.v.A*100*(a/l)*(u/c),K=(i+T)/2,Z=(n+S)/2,st=Math.sqrt((T-i)**2+(S-n)**2),$=st**2/(8*O)+O/2,z=-(S-n)/st,V=(T-i)/st,Y=K+z*$,U=Z+V*$,tt=Y,rt=U,nt=Math.atan2(n-rt,i-tt),ft=Math.atan2(S-rt,T-tt);return{c:"arc",v:{x:tt,y:rt,radius:$,startAngle:nt,endAngle:ft,aclockwise:!0}};default:const lt=ct(e);return Object.entries(lt.v).forEach(([ut,b])=>{var k,P;(k=ut.endsWith)!=null&&k.call(ut,"_x")?typeof b=="number"&&(lt.v[ut]=b*(a/c)+r):(P=ut.endsWith)!=null&&P.call(ut,"_y")?typeof b=="number"&&(lt.v[ut]=b*(l/u)+s):typeof b=="number"&&(lt.v[ut]=b)}),lt}}function Hc(e,t){for(const i in t)_v.includes(i)&&(i=="fontSize"&&t[i]<0&&(t[i]=0),e[i]=t[i],["fontSize","lineWidth"].includes(i)?(e.calculative[i]=t[i]*e.calculative.canvas.store.data.scale,Ti(e)):e.calculative[i]=t[i]);if(e.calculative.canvas.parent.isCombine(e)){const i=e.children;i==null||i.forEach(n=>{let r=ct(t);e.calculative.childrenVisible&&e.calculative.childrenVisible[n]===!1&&delete r.visible;const s=e.calculative.canvas.store.pens[n];s&&Hc(s,r)})}}function Vf(e,t,i,n,r,s,a){let l=(e-i)*(e+i)*(n-s)-(i-r)*(i+r)*(t-n)+a*a*(t-n)*(n-s)*(t-s),c=2*((e-i)*(n-s)-(i-r)*(t-n)),u=l/c,h=(e-i)*(i-r)*(e-r)+a*a*((i-r)*(t-n)*(t+n)-(e-i)*(n-s)*(n+s)),d=2*a*a*((i-r)*(t-n)-(e-i)*(n-s)),g=h/d,v=Math.sqrt(Math.pow(e-u,2)+Math.pow(a*(t-g),2)),y=v/a;return{x0:u,y0:g,a:v,b:y}}function xa(e,t,i,n){let r=i-e,s=n-t,a=Math.atan2(s,r);return a<0&&(a+=2*Math.PI),a}function $f(e,t,i){let n,r,s=1/0,a=1/0;const l=8;for(const c of e.data.pens){if(c.calculative.inView===!1)continue;Uc(c).forEach(h=>{if(h===t||h===i)return;let d=(c.calculative.worldRect.center.x-t.x)*(c.calculative.worldRect.center.x-t.x)+(c.calculative.worldRect.center.y-t.y)*(c.calculative.worldRect.center.y-t.y);const g=Math.abs(h.x-t.x);g>0&&g<l&&d<s&&(n={x:Math.round(h.x)+.5,y:Math.round(h.y)+.5,prev:{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5},step:h.x-t.x},s=d);const v=Math.abs(h.y-t.y);v>0&&v<l&&d<a&&(r={x:Math.round(h.x)+.5,y:Math.round(h.y)+.5,prev:{x:Math.round(t.x)+.5,y:Math.round(t.y)+.5},step:h.y-t.y},a=d)})}return{xDock:n,yDock:r}}function p2(e,t,i,n){let r=[];return i.length===1?(r=ct(Uc(i[0])),r.forEach(s=>{s.x+=n.x,s.y+=n.y})):(ee(t),r=[t.center,...tn(t)]),Vv(e,r,t,!0)}function Uc(e){if(e.type){if(e.type===jt.Line)return e.calculative.worldAnchors}else{const t=tn(e.calculative.worldRect);return ee(e.calculative.worldRect),[...e.calculative.worldAnchors,...t,e.calculative.worldRect.center]}}function w2(e,t,i,n){const r=tn(t);return Vv(e,r,t)}function Vv(e,t,i,n=!1){let r,s,a=1/0,l=1/0;const c=10,u=A2(i,c);return e.data.pens.forEach(h=>{const{inView:d,worldRect:g,active:v}=h.calculative;if(d===!1||!n&&v||E2(u,g)||h.type&&e.active.some(w=>$v(e,w,h)))return;const y=Uc(h);if(!!y)for(const w of y)for(const p of t){const _=w.x-p.x,A=w.y-p.y,x=Math.abs(_),E=Math.abs(A);i.center||(i.center={x:i.x+i.width/2,y:i.y+i.height/2}),x<c&&x<a&&(r={x:Math.round(w.x)+.5,y:Math.round(w.y)+.5,step:_,prev:{x:Math.round(p.x)+.5,y:Math.round(p.y)+.5},penId:h.id,anchorId:p.id,dockAnchorId:w.id},a=x),E<c&&E<l&&(s={x:Math.round(w.x)+.5,y:Math.round(w.y)+.5,step:A,prev:{x:Math.round(p.x)+.5,y:Math.round(p.y)+.5},penId:h.id,anchorId:p.id,dockAnchorId:w.id},l=E)}}),{xDock:r,yDock:s}}function $v(e,t,i){if(!i.type)return!1;if(Array.isArray(t==null?void 0:t.connectedLines)){for(const n of t==null?void 0:t.connectedLines)if(n.lineId===i.id)return!0}if(Array.isArray(t==null?void 0:t.children))for(const n of t.children){const r=e.pens[n];if($v(e,r,i))return!0}return!1}function yc(e,t){return e.toFixed(12)==t}function Kf(e){if(e.id=It(),Array.isArray(e.anchors))for(const t of e.anchors)e.type&&(t.id=It()),t.penId=e.id,t.prev&&(e.type&&(t.prev.id=It()),t.prev.penId=e.id),t.next&&(e.type&&(t.next.id=It()),t.next.penId=e.id)}function b2(){let e=null,t=new Map;return(i,n,r,s=!1)=>{if(t.has(i)&&t.get(i)?e=t.get(i):t.set(i,e=new Map),typeof r!="function")return()=>{console.warn("[rewritePenLifeCycle] warn: not a function ")};let a=new Set,l=new Map;e.has(n)&&e.get(n)?a=e.get(n):(l.set(n,i[n]),e.set(n,a)),s?a.delete(r):a.add(r);let c=l.get(n),u=(...h)=>{c==null||c(...h),a.forEach(d=>{d(...h)})};i[n]=u}}let x2=b2();function _2(e){return!e.name&&!e.install?(console.error("installPenPlugin Error: Validation Failed"),!1):!0}function yn(e,t){if(!t)return;if(t.ex==null&&ae(t),!t.rotate||t.rotate%360===0)return e.x>t.x&&e.x<t.ex&&e.y>t.y&&e.y<t.ey;t.center||ee(t);const i=[{x:t.x,y:t.y},{x:t.ex,y:t.y},{x:t.ex,y:t.ey},{x:t.x,y:t.ey}];return i.forEach(n=>{Gt(n,t.rotate,t.pivot||t.center)}),k2(e,i)}function Kn(e,t,i=0){const{x:n,y:r,ex:s,ey:a}=t;return e.x>=n-i&&e.x<=s+i&&e.y>=r-i&&e.y<=a+i}function ee(e){e.center||(e.center={}),e.center.x=e.x+e.width/2,e.center.y=e.y+e.height/2}function ae(e){e.ex=e.x+e.width,e.ey=e.y+e.height}function mc(e,t){e.pivot||(e.pivot={}),e.pivot.x=e.x+e.width*t.x,e.pivot.y=e.y+e.height*t.y}function k2(e,t){if(t.length<3)return!1;let i=!1,n=t[t.length-1];for(const r of t)n.y>e.y!=r.y>e.y&&r.x+(e.y-r.y)*(n.x-r.x)/(n.y-r.y)>e.x&&(i=!i),n=r;return i}function pi(e){const t=[];e.forEach(n=>{if(n.isRuleLine)return;const r=n.calculative.worldRect;if(r){const s=tn(r);t.push(...s)}});const i=As(t);return ee(i),i}function tn(e){const t=[{x:e.x,y:e.y},{x:e.ex,y:e.y},{x:e.ex,y:e.ey},{x:e.x,y:e.ey}];return e.rotate&&(e.center||ee(e),t.forEach(i=>{Gt(i,e.rotate,e.pivot||e.center)})),t}function As(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;return e==null||e.forEach(s=>{!isFinite(s.x)||!isFinite(s.y)||(t=Math.min(t,s.x),i=Math.min(i,s.y),n=Math.max(n,s.x),r=Math.max(r,s.y))}),{x:t,y:i,ex:n,ey:r,width:n-t,height:r-i}}function Ji(e,t,i){return e.rotate&&(e=As(tn(e))),i?e.x>t.x&&e.ex<t.ex&&e.y>t.y&&e.ey<t.ey:!(e.x>t.ex||e.ex<t.x||e.ey<t.y||e.y>t.ey)}function E2(e,t){return(t.x>e.ex||t.ex<e.x)&&(t.y>e.ey||t.ey<e.y)}function A2(e,t){const i=Xi(t),n={x:e.x-i[3],y:e.y-i[0],width:e.width+i[1]+i[3],height:e.height+i[0]+i[2]};return ae(n),n}function Hn(e,t,i){e.x+=t,e.y+=i,e.ex+=t,e.ey+=i,e.center&&(e.center.x+=t,e.center.y+=i),e.pivot&&(e.pivot.x+=t,e.pivot.y+=i)}function R2(e,t){const i=(e.to.y-e.from.y)/(e.to.x-e.from.x),n=(t.to.y-t.from.y)/(t.to.x-t.from.x);return pc({k:i,point:e.from},{k:n,point:t.from})}function pc(e,t){if(yc(e.k,0))return{x:t.point.x,y:e.point.y};if(yc(t.k,0))return{x:e.point.x,y:t.point.y};const i=e.point.y-e.k*e.point.x,r=(t.point.y-t.k*t.point.x-i)/(e.k-t.k),s=e.k*r+i;return{x:r,y:s}}function C2(e,t){const i=R2({from:e[0],to:e[2]},{from:e[1],to:e[3]});for(const n of e)Gt(n,-t,i);return As(e)}function Yf(e,t,i,n){let r=e.rotate?e.rotate%360:0;if(r){const s=tn(e),a=(s[0].y-s[1].y)/(s[0].x-s[1].x),l=(s[1].y-s[2].y)/(s[1].x-s[2].x);if(n<4){if(s[n].x+=t,e.ratio)if(n===0||n===2){let h=t*Math.tan((90-(360-r)-Math.atan(e.width/e.height)/Math.PI*180)/180*Math.PI);s[n].y+=h}else{let h=t*Math.tan((90-(360-r)+Math.atan(e.width/e.height)/Math.PI*180)/180*Math.PI);s[n].y+=h}else s[n].y+=i;const u=s[(n+2)%4];s[(n+1)%4]=pc({k:n%2?l:a,point:s[n]},{k:n%2?a:l,point:u}),s[(n+4-1)%4]=pc({k:n%2?a:l,point:s[n]},{k:n%2?l:a,point:u})}else{const u=[4,6].includes(n)?l:a;yc(u,0)?(s[n%4].x+=t,s[(n+1)%4].x+=t):(s[n%4].y+=i,s[n%4].x+=i/u,s[(n+1)%4].y+=i,s[(n+1)%4].x+=i/u)}if((s[0].x-s[1].x)**2+(s[0].y-s[1].y)**2<25||(s[1].x-s[2].x)**2+(s[1].y-s[2].y)**2<25)return;const c=C2(s,e.rotate);ee(c),Object.assign(e,c);return}switch(n){case 0:if(e.width-t<5||e.height-i<5)break;e.x+=t,e.y+=i,e.width-=t,e.height-=i;break;case 1:if(e.width+t<5||e.height-i<5)break;e.ex+=t,e.y+=i,e.width+=t,e.height-=i;break;case 2:if(e.width+t<5||e.height+i<5)break;e.ex+=t,e.ey+=i,e.width+=t,e.height+=i;break;case 3:if(e.width-t<5||e.height+i<5)break;e.x+=t,e.ey+=i,e.width-=t,e.height+=i;break;case 4:if(e.height-i<5)break;e.y+=i,e.height-=i;break;case 5:if(e.width+t<5)break;e.ex+=t,e.width+=t;break;case 6:if(e.height+i<5)break;e.ey+=i,e.height+=i;break;case 7:if(e.width-t<5)break;e.x+=t,e.width-=t;break}}function ms(e,t,i,n){!e||(e.width*=t,e.height*=t,Wa(e,t,i),ae(e),ee(e),n&&mc(e,n))}function mn(e,t){const i={x:(e.x-t.x)/t.width,y:(e.y-t.y)/t.height,width:e.width/t.width,height:e.height/t.height};return ae(i),i}function hs(e,t){const{x:i,y:n,width:r,height:s}=t,{penId:a,connectTo:l}=e,c=Object.assign({},e,{x:r?(e.x-i)/r:0,y:s?(e.y-n)/s:0});return e.prev&&(c.prev={penId:a,connectTo:l,x:r?(e.prev.x-i)/r:0,y:s?(e.prev.y-n)/s:0}),e.next&&(c.next={penId:a,connectTo:l,x:r?(e.next.x-i)/r:0,y:s?(e.next.y-n)/s:0}),c}function T2(e,t){let i=!1;for(let n=0,r=t.length-1;n<t.length;r=n++){let s=t[n].x,a=t[n].y,l=t[r].x,c=t[r].y;a>e.y!=c>e.y&&e.x<(l-s)*(e.y-a)/(c-a)+s&&(i=!i)}return i}const S2=/^[\t\n\f\r ]*([MLHVZCSQTAmlhvzcsqta])[\t\n\f\r ]*/,Xf=/^[01]/,Jt=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,P2=/^(([\t\n\f\r ]+,?[\t\n\f\r ]*)|(,[\t\n\f\r ]*))/,I2={M:[Jt,Jt],L:[Jt,Jt],H:[Jt],V:[Jt],Z:[],C:[Jt,Jt,Jt,Jt,Jt,Jt],S:[Jt,Jt,Jt,Jt],Q:[Jt,Jt,Jt,Jt],T:[Jt,Jt],A:[Jt,Jt,Jt,Xf,Xf,Jt,Jt]};function L2(e){let t=0;const i=[];for(;t<e.length;){const n=e.slice(t).match(S2);if(n!==null){const r=n[1];t+=n[0].length;const s=O2(r,e,t);t=s.cursor,i.push(...s.commands)}else throw new Error("malformed path (first error at "+t+")")}return{commands:i}}function Gf(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;return F2(e),e.commands.forEach(s=>{s.worldPoints.forEach((a,l)=>{l%2===0?(a<t&&(t=a),a>n&&(n=a)):(a<i&&(i=a),a>r&&(r=a))})}),--t,--i,{x:t,y:i,ex:n,ey:r,width:n-t+1,height:r-i+1}}function D2(e,t,i){i==null&&(i=t),e.commands.forEach((n,r)=>{if(!(n.relative&&r))switch(n.key){case"A":case"a":n.values[5]+=t,n.values[6]+=i;break;case"V":case"v":n.values[0]+=i;break;default:n.values.forEach((s,a)=>{n.values[a]=s+(a%2===0?t:i)});break}})}function M2(e,t,i){i==null&&(i=t),e.commands.forEach(n=>{switch(n.key){case"A":case"a":const r=n.values[0],s=n.values[1],a=Math.PI*n.values[2]/180,l=Math.cos(a),c=Math.sin(a),u=s*s*i*i*l*l+r*r*i*i*c*c,h=2*t*i*l*c*(s*s-r*r),d=r*r*t*t*l*l+s*s*t*t*c*c,g=-(r*r*s*s*t*t*i*i),v=h*h-4*u*d,y=Math.sqrt((u-d)*(u-d)+h*h);n.values[2]=h!==0?Math.atan((d-u-y)/h)*180/Math.PI:u<d?0:90,n.values[0]=-Math.sqrt(2*v*g*(u+d+y))/v,n.values[1]=-Math.sqrt(2*v*g*(u+d-y))/v,n.values[5]*=t,n.values[6]*=i,n.values[4]=t*i>=0?n.values[4]:1-n.values[4];break;case"V":case"v":n.values[0]*=i;break;default:n.values.forEach((w,p)=>{n.values[p]=w*(p%2===0?t:i)});break}})}function B2(e){let t="";return e.commands.forEach(i=>{t+=i.key+" ",i.values.forEach(n=>{t+=n+" "})}),t}function O2(e,t,i){const n=I2[e.toUpperCase()],r=[];for(;i<=t.length;){const s={key:e,values:[]};for(const a of n){const l=t.slice(i).match(a);if(l!==null){s.values.push(+l[0]),i+=l[0].length;const c=t.slice(i).match(P2);c!==null&&(i+=c[0].length)}else{if(s.values.length===0)return{cursor:i,commands:r};throw new Error("malformed path (first error at "+i+")")}}if(s.relative=s.key.toUpperCase()!==s.key,r.push(s),n.length===0)return{cursor:i,commands:r};e==="m"&&(e="l"),e==="M"&&(e="L")}throw new Error("malformed path (first error at "+i+")")}function N2(e,t){const i=[];let n=e.relative&&t?{x:t.worldPoints[t.worldPoints.length-2],y:t.worldPoints[t.worldPoints.length-1]}:{x:0,y:0};for(let r=0;r<e.values.length-1;r+=2)i.push(n.x+e.values[r]),i.push(n.y+e.values[r+1]);e.worldPoints=i}function F2(e){let t,i=0,n=0;e.commands.forEach(r=>{switch(r.key){case"Z":case"z":r.worldPoints=[i,n];break;case"H":r.worldPoints=[r.values[0],t.worldPoints[t.worldPoints.length-1]];break;case"h":r.worldPoints=[r.values[0]+t.worldPoints[t.worldPoints.length-2],t.worldPoints[t.worldPoints.length-1]];break;case"V":r.worldPoints=[t.worldPoints[t.worldPoints.length-2],r.values[0]];break;case"v":r.worldPoints=[t.worldPoints[t.worldPoints.length-2],r.values[0]+t.worldPoints[t.worldPoints.length-1]];break;case"A":r.worldPoints=[t.worldPoints[t.worldPoints.length-2],r.values[0]+t.worldPoints[t.worldPoints.length-1]];break;default:N2(r,t);break}(r.key==="M"||r.key==="m"||r.key==="Z"||r.key==="z")&&(i=r.worldPoints[r.worldPoints.length-2],n=r.worldPoints[r.worldPoints.length-1]),t=r})}function z2(e,t){var c;const n=e.calculative.canvas.store.data.paths[e.pathId];if(!n)return new Path2D;const r=L2(n);e.calculative.svgRect=Gf(r),ee(e.calculative.svgRect),(e.calculative.svgRect.width!==e.calculative.worldRect.width||e.calculative.svgRect.height!==e.calculative.worldRect.height)&&M2(r,e.calculative.worldRect.width/e.calculative.svgRect.width,e.calculative.worldRect.height/e.calculative.svgRect.height);const s=Gf(r);ee(s),D2(r,e.calculative.worldRect.x-s.x,e.calculative.worldRect.y-s.y);const a=B2(r);if(t){(c=t.svgPath)==null||c.call(t,a);return}return new Path2D(a)}function H2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n+s/2,r),i.lineTo(n+s,r+a/2),i.lineTo(n+s/2,r+a),i.lineTo(n,r+a/2),i.lineTo(n+s/2,r),i.closePath(),i instanceof Path2D)return i}function U2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n+s/2,r),i.lineTo(n+s,r+a),i.lineTo(n,r+a),i.lineTo(n+s/2,r),i.closePath(),i instanceof Path2D)return i}function W2(e){const t=[{x:.5,y:0},{x:.75,y:.5},{x:.5,y:1},{x:.25,y:.5}];e.anchors=t.map(({x:i,y:n},r)=>({id:`${r}`,penId:e.id,x:i,y:n}))}function q2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n+s/2,r),i.lineTo(n+s,r+a*2/5),i.lineTo(n+s*4/5,r+a),i.lineTo(n+s/5,r+a),i.lineTo(n,r+a*2/5),i.closePath(),i instanceof Path2D)return i}function j2(e){const t=[{x:.5,y:0},{x:1,y:.4},{x:.8,y:1},{x:.2,y:1},{x:0,y:.4}];e.anchors=t.map(({x:i,y:n},r)=>({id:`${r}`,penId:e.id,x:i,y:n}))}function V2(e,t){e.onResize||(e.onResize=$2);const i=t||new Path2D,{width:n,height:r,center:s}=e.calculative.worldRect,a=n>r?r:n,l=s.x,c=s.y,u=c-a/2,h=c-a/4,d=-(h-c)*Math.sin(Math.PI/180*324)+l,g=(h-c)*Math.cos(Math.PI/180*324)+c;i.moveTo(d,g);for(let v=0;v<5;++v)i.lineTo(-(u-c)*Math.sin(Math.PI/180*72*v)+l,(u-c)*Math.cos(Math.PI/180*72*v)+c),i.lineTo((d-l)*Math.cos(Math.PI/180*72*(v+1))-(g-c)*Math.sin(Math.PI/180*72*(v+1))+l,(d-l)*Math.sin(Math.PI/180*72*(v+1))+(g-c)*Math.cos(Math.PI/180*72*(v+1))+c);if(i.closePath(),i instanceof Path2D)return i}function Kv(e){const{width:t,height:i}=e,n=t>i?i:t,r=[];for(let s=0;s<5;++s)r.push({flag:1,id:String(s),penId:e.id,x:.5+n/2*Math.sin(Math.PI/180*72*s)/t,y:-n/2*Math.cos(Math.PI/180*72*s)/i+.5});e.anchors=r}function $2(e){const t=e.anchors.filter(i=>i.flag!==1);Kv(e),e.anchors=e.anchors.concat(...t)}function K2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n+s/4,r),i.lineTo(n+s*3/4,r),i.lineTo(n+s,r+a/2),i.lineTo(n+s*3/4,r+a),i.lineTo(n+s*1/4,r+a),i.lineTo(n,r+a/2),i.lineTo(n+s/4,r),i.closePath(),i instanceof Path2D)return i}function Y2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n,r+a/2),i.lineTo(n+a/2,r),i.lineTo(n+a/2,r+a/3),i.lineTo(n+s,r+a/3),i.lineTo(n+s,r+a*2/3),i.lineTo(n+a/2,r+a*2/3),i.lineTo(n+a/2,r+a*2/3),i.lineTo(n+a/2,r+a),i.closePath(),i instanceof Path2D)return i}function X2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n,r+a/3),i.lineTo(n+(s-a/2),r+a/3),i.lineTo(n+(s-a/2),r),i.lineTo(n+s,r+a/2),i.lineTo(n+(s-a/2),r+a),i.lineTo(n+(s-a/2),r+a*2/3),i.lineTo(n,r+a*2/3),i.closePath(),i instanceof Path2D)return i}function G2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n,r+a/2),i.lineTo(n+a/2,r),i.lineTo(n+a/2,r+a/3),i.lineTo(n+(s-a/2),r+a/3),i.lineTo(n+(s-a/2),r),i.lineTo(n+s,r+a/2),i.lineTo(n+(s-a/2),r+a),i.lineTo(n+(s-a/2),r+a*2/3),i.lineTo(n+a/2,r+a*2/3),i.lineTo(n+a/2,r+a),i.closePath(),i instanceof Path2D)return i}function Z2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a,ey:l}=e.calculative.worldRect;if(i.moveTo(n,r),i.lineTo(n+s,r),i.lineTo(n+s,r+a*3/4),i.lineTo(n+s*8/16,r+a*3/4),i.lineTo(n+s/4,l),i.lineTo(n+s*5/16,r+a*3/4),i.lineTo(n,r+a*3/4),i.closePath(),i instanceof Path2D)return i}function J2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n+s/5,r+a*13/16),i.bezierCurveTo(n-s/15,r+a*13/16,n-s/15,r+a*7/16,n+s/5,r+a*7/16),i.bezierCurveTo(n+s/5,r,n+s*4/5,r,n+s*4/5,r+a*7/16),i.bezierCurveTo(n+s*16/15,r+a*7/16,n+s*16/15,r+a*13/16,n+s*4/5,r+a*13/16),i.closePath(),i instanceof Path2D)return i}function Q2(e,t){const i=t||new Path2D,{x:n,y:r,width:s,ex:a,ey:l}=e.calculative.worldRect,c=s/6;if(i.moveTo(n,r),i.lineTo(a-c,r),i.lineTo(a,r+c),i.lineTo(a,l),i.lineTo(n,l),i.closePath(),i.moveTo(a-c,r),i.lineTo(a-c,r+c),i.lineTo(a,r+c),i.closePath(),i instanceof Path2D)return i}function tk(e,t){const{x:i,y:n,width:r,ex:s,ey:a}=t.calculative.worldRect;let l=r*.25;const c=t.z;c>1?l=c:c>0&&(l=r*c);const u={x:i,y:n+l},h={x:s-l,y:n+l},d={x:s-l,y:a};Ml(e,[u,h,d,{x:i,y:a}],t.backgroundFront||t.background,t.color),Ml(e,[u,{x:i+l,y:n},{x:s,y:n},h],t.backgroundUp||t.background,t.color),Ml(e,[h,{x:s,y:n},{x:s,y:a-l},d],t.backgroundRight||t.background,t.color)}function Ml(e,t,i="",n=""){e.save(),i&&(e.fillStyle=i),n&&(e.strokeStyle=n),e.beginPath();for(let r=0;r<t.length;++r)r?e.lineTo(t[r].x,t[r].y):e.moveTo(t[r].x,t[r].y);e.closePath(),i&&e.fill(),e.stroke(),e.restore()}function ek(e,t){const i=t||new Path2D,{x:n,y:r,width:s,ex:a,ey:l}=e.calculative.worldRect,c=s/4,u=n+s/2;if(i.arc(u,r+c,c,0,Math.PI*2),i.moveTo(n,r+c*3),i.lineTo(a,r+c*3),i.moveTo(u,r+c*2),i.lineTo(u,r+c*4),i.moveTo(u,r+c*4),i.lineTo(n,l),i.moveTo(u,r+c*4),i.lineTo(a,l),i.closePath(),i instanceof Path2D)return i}function ik(e,t,i){if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),i)t.calculative.activeAnchor&&(t.calculative.activeAnchor.next={penId:t.id,x:i.x,y:i.y},Za(t.calculative.activeAnchor.next,t.calculative.activeAnchor)<5?t.calculative.activeAnchor.next=void 0:(t.calculative.activeAnchor.prev={...t.calculative.activeAnchor.next},Gt(t.calculative.activeAnchor.prev,180,t.calculative.activeAnchor)));else{const n=t.calculative.worldAnchors[0];if(!n.next){const s=Or(n,e.pens[n.connectTo]);Zf(n,s,50),n.prev=void 0}const r=t.calculative.worldAnchors[t.calculative.worldAnchors.length-1];if(r&&r!==n&&!r.prev){const s=Or(r,e.pens[r.connectTo]);Zf(r,s,-50),r.next=void 0}}}function Zf(e,t,i){switch(t){case Lt.Up:e.prev={penId:e.penId,x:e.x,y:e.y+i},e.next={penId:e.penId,x:e.x,y:e.y-i};break;case Lt.Right:e.prev={penId:e.penId,x:e.x-i,y:e.y},e.next={penId:e.penId,x:e.x+i,y:e.y};break;case Lt.Bottom:e.prev={penId:e.penId,x:e.x,y:e.y-i},e.next={penId:e.penId,x:e.x,y:e.y+i};break;case Lt.Left:e.prev={penId:e.penId,x:e.x+i,y:e.y},e.next={penId:e.penId,x:e.x-i,y:e.y};break}}function wc(e,t,i,n){const r=1-e,s=r*r*t.x+2*r*e*i.x+e*e*n.x,a=r*r*t.y+2*r*e*i.y+e*e*n.y;return{x:s,y:a,step:e}}function Yv(e,t,i,n,r){const{x:s,y:a}=t,{x:l,y:c}=r,{x:u,y:h}=i,{x:d,y:g}=n,v=1-e,y=s*v*v*v+3*u*e*v*v+3*d*e*e*v+l*e*e*e,w=a*v*v*v+3*h*e*v*v+3*g*e*e*v+c*e*e*e;return{x:y,y:w,step:e}}function dn(e,t,i){return{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}}function nk(e,t,i){let n=e.calculative.worldAnchors[i],r=e.calculative.worldAnchors[i+1];!r&&e.close&&(r=e.calculative.worldAnchors[0]);const s=t.step;let a;if(n.next&&r.prev){const l=n,c=n.next,u=r.prev,h=r,d=dn(l,c,s),g=dn(c,u,s),v=dn(u,h,s),y=dn(d,g,s),w=dn(g,v,s);a=dn(y,w,s),y.penId=e.id,a.prev=y,w.penId=e.id,a.next=w,n.next.x=d.x,n.next.y=d.y,r.prev.x=v.x,r.prev.y=v.y}else if(n.next||r.prev){const l=n,c=n.next||r.prev,u=r,h=dn(l,c,s),d=dn(c,u,s);a=t,h.penId=e.id,d.penId=e.id,a.prev=h,a.next=d,n.next=void 0,r.prev=void 0}else a=t;return a.penId=e.id,a.id=It(),a.prevNextType=jn.Bilateral,a}function rk(e,t,i){if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2)return;let n=t.calculative.activeAnchor,r=i||qt(t);if(!n||!r)return;const s=20,a=e.pens[n.connectTo];let l=Or(n,a);switch(l===Lt.None&&(r.x>n.x?l=Lt.Right:l=Lt.Left),n.next={id:It(),penId:t.id,x:n.x,y:n.y,prevNextType:2},r.prev={id:It(),penId:t.id,x:r.x,y:r.y,prevNextType:2},l){case Lt.Up:n.next.y-=s,r.prev.y=n.y;break;case Lt.Bottom:n.next.y+=s,r.prev.y=n.y;break;case Lt.Left:n.next.x-=s,r.prev.x=n.x;break;default:n.next.x+=s,r.prev.x=n.x;break}}function sk(e,t){const i=t||new Path2D;if((e.lineName==="line"||e.lineName==="polyline")&&e.calculative.lineSmooth){let r=Nc(e);if(i.addPath(r),i instanceof Path2D)return i}const n=e.calculative.worldAnchors;if(n.length>1){let r;n.forEach(s=>{r?Jf(i,r,s):s.start=!0,r=s}),e.close&&(e.lineName==="curve"?Jf(i,r,n[0]):i.closePath())}if(i instanceof Path2D)return i}function ak(e,t,i){var s;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2||((s=t.anchors)==null?void 0:s.length)>1)return;const n=le(t),r=qt(t);!n||!r||!r.id||n===r||(n.next=void 0,zc(t),r.prev=void 0,t.calculative.worldAnchors.push(r))}function Jf(e,t,i){!i||i.isTemp||(t.start&&e.moveTo(t.x,t.y),t.next?i.prev?e.bezierCurveTo(t.next.x,t.next.y,i.prev.x,i.prev.y,i.x,i.y):e.quadraticCurveTo(t.next.x,t.next.y,i.x,i.y):i.prev?e.quadraticCurveTo(i.prev.x,i.prev.y,i.x,i.y):e.lineTo(i.x,i.y))}function bc(e){return xc(e),As(Xv(e))}function Xv(e){const t=[];let i;return e.calculative.worldAnchors.forEach(n=>{t.push(n),i&&t.push(...Qf(i,n,e)),i=n}),e.close&&e.calculative.worldAnchors.length>1&&t.push(...Qf(i,e.calculative.worldAnchors[0],e)),t}function $a(e){return e!=null&&e.lineWidth?e.lineWidth/2+4:4}function Qf(e,t,i){const n=[];if(!t)return n;let r=.02;if(e.lineLength&&(r=$a(i)/e.lineLength),e.next)if(t.prev)for(let s=r;s<1;s+=r)n.push(Yv(s,e,e.next,t.prev,t));else for(let s=r;s<1;s+=r)n.push(wc(s,e,e.next,t));else if(t.prev)for(let s=r;s<1;s+=r)n.push(wc(s,e,t.prev,t));else n.push({x:t.x,y:t.y});return n.length>1&&(e.curvePoints=n),n}function ok(e,t){const i=$a(t);let n=0,r,s;for(const a of t.calculative.worldAnchors){if(r){if(s=td(e,r,a,i),s)return{i:n,point:s};++n}r=a}if(t.close&&t.calculative.worldAnchors.length>1&&(s=td(e,r,t.calculative.worldAnchors[0],i)))return{i:n,point:s}}function td(e,t,i,n=4){if(!t.next&&!i.prev){const{x:r,y:s}=t,{x:a,y:l}=i,c=Math.min(r,a),u=Math.max(r,a),h=Math.min(s,l),d=Math.max(s,l);return e.x>=c-n&&e.x<=u+n&&e.y>=h-n&&e.y<=d+n?lk(e,t,i,n):void 0}else if(t.curvePoints){for(const r of t.curvePoints)if(Ar(e,r,n))return r}}function lk(e,t,i,n=4){if(t.x===i.x){if(Math.abs(e.x-t.x)<=n)return{x:t.x,y:e.y}}else{const r=(t.y-i.y)/(t.x-i.x),s=t.y-r*t.x;if(Math.abs((r*e.x+s-e.y)/Math.sqrt(r*r+1))<=n){const c=(e.x+r*e.y-r*s)/(r*r+1);return{x:c,y:r*c+s}}}}function ed(e,t,i,n){if(!t&&!i)return Math.sqrt(Math.pow(Math.abs(e.x-n.x),2)+Math.pow(Math.abs(e.y-n.y),2))||0;const r=document.createElementNS("http://www.w3.org/2000/svg","path");return t&&i?r.setAttribute("d",`M${e.x} ${e.y} C${t.x} ${t.y} ${i.x} ${i.y} ${n.x} ${n.y}`):t?r.setAttribute("d",`M${e.x} ${e.y} Q${t.x} ${t.y} ${n.x} ${n.y}`):r.setAttribute("d",`M${e.x} ${e.y} Q${i.x} ${i.y} ${n.x} ${n.y}`),r.getTotalLength()||0}function xc(e){if(e.calculative.worldAnchors.length<2)return 0;let t=0,i;if(e.calculative.worldAnchors.forEach(n=>{i&&(i.lineLength=ed(i,i.next,n.prev,n),t+=i.lineLength),i=n}),e.close){const n=le(e);i.lineLength=ed(i,i.next,n.prev,n),t+=i.lineLength}return e.calculative.animatePos&&(e.calculative.animatePos=t/e.length*e.calculative.animatePos),e.length=t,t}function Bl(e,t){const i=e.calculative.worldAnchors;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];if(!r.next&&!s.prev){if(Gv(r,s,t))return!0}else if(ck(r,s,t))return!0}return!1}function Gv(e,t,i){if(Kn(e,i)||Kn(t,i))return!0;const n=e.x,r=e.y,s=t.x,a=t.y;let l=i.x,c=i.y,u=i.ex,h=i.ey;const d=r-a,g=s-n,v=n*a-s*r;if(d*l+g*c+v>=0&&d*u+g*h+v<=0||d*l+g*c+v<=0&&d*u+g*h+v>=0||d*l+g*h+v>=0&&d*u+g*c+v<=0||d*l+g*h+v<=0&&d*u+g*c+v>=0){if(l>u){const y=l;l=u,u=y}if(c<h){const y=c;c=h,h=y}return!(n<l&&s<l||n>u&&s>u||r>c&&a>c||r<h&&a<h)}else return!1}function ck(e,t,i){if(!e.next&&!t.prev)return Gv(e,t,i);if(e.next&&t.prev)for(let r=.02;r<1;r+=.02){const s=Yv(r,e,e.next,t.prev,t);if(Kn(s,i))return!0}else if(e.next||t.prev)for(let r=.02;r<1;r+=.02){const s=wc(r,e,e.next||t.prev,t);if(Kn(s,i))return!0}return!1}let ze=10;function hk(e,t,i){var w;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),ze=e.options.polylineSpace||10,t.calculative.worldAnchors.length<2)return;let n=le(t),r=qt(t);if(!n||!r)return;let s;if(((w=t.anchors)==null?void 0:w.length)&&n===t.calculative.activeAnchor?(s=!0,n=r,r=le(t)):(!t.anchors||!t.anchors.length)&&n!==t.calculative.activeAnchor&&(n=t.calculative.activeAnchor),!n||!r)return;n.next=void 0,r.prev=void 0;const a=r.connectTo;zc(t);const l=[],c=e.pens[n.connectTo],u=e.pens[r.connectTo],h=Or(n,c),d=Or(r,u);let g=id(n,h,ze);g&&(n=g,l.push(g)),g=id(r,d,ze);const v=r;let y;if(g&&(r=g,v.connectTo&&(g.y>v.y&&n.y<v.y||g.y<v.y&&n.y>v.y))){y=g;let p=ze;n.x<g.x&&(p=-p),Math.abs(n.x-g.x)<p&&(p=-p),r={x:g.x+p,y:g.y,id:It()}}switch(h){case Lt.Up:l.push(...uk(n,r,d));break;case Lt.Right:l.push(...fk(n,r,d));break;case Lt.Bottom:l.push(...dk(n,r,d));break;case Lt.Left:l.push(...vk(n,r,d));break;default:l.push(...gk(t,n,r));break}if(l.forEach(p=>{p.id=It(),p.penId=t.id,t.calculative.worldAnchors.push(p)}),t.calculative.worldAnchors.push(r),y&&t.calculative.worldAnchors.push(y),g&&t.calculative.worldAnchors.push(v),s&&t.calculative.worldAnchors.reverse(),a){const p=t.calculative.worldAnchors.length-2;t.calculative.worldAnchors[p].isTemp=!1,t.calculative.worldAnchors[1].isTemp=!1}}function id(e,t,i){const n={x:e.x,y:e.y,id:It()};switch(t){case Lt.Up:n.y-=i;break;case Lt.Right:n.x+=i;break;case Lt.Bottom:n.y+=i;break;case Lt.Left:n.x-=i;break;default:return}return n}function uk(e,t,i){if(e.x===t.x||e.y===t.y)return[];const n=[];let r,s;switch(i){case Lt.Up:e.y<t.y?(r=t.x,s=e.y):(r=e.x,s=t.y),n.push({x:r,y:s});break;case Lt.Bottom:if(r=t.x,s=e.y,t.y>e.y)r=e.x+(t.x-e.x)/2,n.push({x:r,y:e.y},{x:r,y:t.y});else{const a=(e.y+t.y)/2;n.push({x:e.x,y:a},{x:t.x,y:a})}break;case Lt.Right:r=t.x,s=e.y,t.x<e.x&&t.y<e.y&&(r=e.x,s=t.y),n.push({x:r,y:s});break;case Lt.Left:r=t.x,s=e.y,t.x>e.x&&t.y<e.y&&(r=e.x,s=t.y),n.push({x:r,y:s});break;default:if(t.y>e.y-ze)r=e.x+(t.x-e.x)/2,n.push({x:r,y:e.y},{x:r,y:t.y});else{const a=(e.y+t.y+ze)/2;n.push({x:e.x,y:a},{x:t.x,y:a})}break}return n}function fk(e,t,i){if(e.x===t.x||e.y===t.y)return[];const n=[];let r,s;switch(i){case Lt.Up:r=e.x,s=t.y,t.x>e.x&&t.y>e.y&&(r=t.x,s=e.y),n.push({x:r,y:s});break;case Lt.Bottom:r=e.x,s=t.y,t.x>e.x&&t.y<e.y&&(r=t.x,s=e.y),n.push({x:r,y:s});break;case Lt.Left:if(r=t.x,s=e.y,t.x<e.x)s=e.y+(t.y-e.y)/2,n.push({x:e.x,y:s},{x:t.x,y:s});else{const a=(e.x+t.x)/2;n.push({x:a,y:s},{x:a,y:t.y})}break;case Lt.Right:t.x<e.x?n.push({x:e.x,y:t.y}):n.push({x:t.x,y:e.y});break;default:if(r=t.x,s=t.y,t.x<e.x+ze)n.push({x:e.x,y:s});else{const a=(e.x+t.x-ze)/2;n.push({x:a,y:e.y},{x:a,y:s})}break}return n}function dk(e,t,i){if(e.x===t.x||e.y===t.y)return[];const n=[];let r,s;switch(i){case Lt.Up:if(r=e.x,s=t.y,t.y<e.y)r=e.x+(t.x-e.x)/2,n.push({x:r,y:e.y},{x:r,y:t.y});else{const a=(e.y+t.y)/2;n.push({x:r,y:a},{x:t.x,y:a})}break;case Lt.Right:r=t.x,s=e.y,t.x<e.x&&t.y>e.y&&(r=e.x,s=t.y),n.push({x:r,y:s});break;case Lt.Bottom:e.y>t.y?(r=t.x,s=e.y):(r=e.x,s=t.y),n.push({x:r,y:s});break;case Lt.Left:r=t.x,s=e.y,t.x>e.x&&t.y>e.y&&(r=e.x,s=t.y),n.push({x:r,y:s});break;default:if(r=e.x,t.y<e.y+ze)r=e.x+(t.x-e.x)/2,n.push({x:r,y:e.y},{x:r,y:t.y});else{const a=(e.y+t.y-ze)/2;n.push({x:r,y:a},{x:t.x,y:a})}break}return n}function vk(e,t,i){if(e.x===t.x||e.y===t.y)return[];const n=[];let r,s;switch(i){case Lt.Up:r=e.x,s=t.y,t.x<e.x&&t.y>e.y&&(r=t.x,s=e.y),n.push({x:r,y:s});break;case Lt.Bottom:r=e.x,s=t.y,t.x<e.x&&t.y<e.y&&(r=t.x,s=e.y),n.push({x:r,y:s});break;case Lt.Right:if(r=e.x,s=t.y,t.x>e.x)r=t.x,s=e.y+(t.y-e.y)/2,n.push({x:e.x,y:s},{x:t.x,y:s});else{const a=(e.x+t.x)/2;n.push({x:a,y:e.y},{x:a,y:t.y})}break;case Lt.Left:t.x>e.x?n.push({x:e.x,y:t.y}):n.push({x:t.x,y:e.y});break;default:if(r=e.x,s=t.y,t.x<e.x-ze){const a=(e.x+t.x+ze)/2;n.push({x:a,y:e.y},{x:a,y:s})}else n.push({x:e.x,y:s});break}return n}function gk(e,t,i){const n=[];e.calculative.drawlineH==null&&(e.calculative.drawlineH=Math.abs(i.x-t.x)>Math.abs(i.y-t.y));let r=e.calculative.worldAnchors.findIndex(s=>s.id==t.id);if(r>1){let s=e.calculative.worldAnchors[r-1];if(s.x===t.x&&s.y!==t.y)return n.push({x:i.x,y:t.y}),n;if(s.y===t.y&&s.x!==t.x)return n.push({x:t.x,y:i.y}),n}return e.calculative.worldAnchors.length&&(i.isTemp=void 0,e.calculative.drawlineH?(n.push({x:i.x,y:t.y}),Math.abs(i.y-t.y)<ze&&(i.isTemp=!0)):(n.push({x:t.x,y:i.y}),Math.abs(i.x-t.x)<ze&&(i.isTemp=!0))),n}function _a(e,t,i=!0){var r,s;let n=e.calculative.worldAnchors;i||(n=[],e.calculative.worldAnchors.forEach(a=>{n.unshift(a)}));for(let a=0;a<n.length&&n[a].id!==t.id;a++)if(n[a].y!==t.y||n[a].x===((r=n[a+1])==null?void 0:r.x)&&n[a].y!==((s=n[a+1])==null?void 0:s.y))return!1;return!0}function ka(e,t,i=!0){var r,s;let n=e.calculative.worldAnchors;i||(n=[],e.calculative.worldAnchors.forEach(a=>{n.unshift(a)}));for(let a=0;a<n.length&&n[a].id!==t.id;a++)if(n[a].x!==t.x||n[a].y===((r=n[a+1])==null?void 0:r.y)&&n[a].x!==((s=n[a+1])==null?void 0:s.x))return!1;return!0}function yk(e,t,i){if(!e.calculative.worldAnchors)return;const n=e.calculative.worldAnchors.findIndex(c=>c.id===t.id),r=le(e),s=qt(e);let a=e.calculative.worldAnchors[n-1],l=e.calculative.worldAnchors[n+1];if(e.calculative.h==null&&(r.connectTo&&(_a(e,t,!0)?e.calculative.h=!0:ka(e,t,!0)&&(e.calculative.h=!1)),e.calculative.h==null&&s.connectTo&&(_a(e,t,!1)?e.calculative.h=!0:ka(e,t,!1)&&(e.calculative.h=!1)),e.calculative.h==null&&(a?e.calculative.h=a.y===t.y:l&&(e.calculative.h=l.y===t.y))),e.calculative.h){if(t.x=i.x,r.connectTo&&_a(e,t,!0)){l&&l.y!==t.y&&(l.x=t.x);return}if(s.connectTo&&_a(e,t,!1)){a&&a.y!==t.y&&(a.x=t.x);return}const c=e.anchors[n];let u;for(let h=n-1;h>-1;h--)if(a=e.anchors[h],u==null&&(u=a.y===c.y),u===!0)if(a.y===c.y)e.calculative.worldAnchors[h].y=i.y;else break;else if(a.x===c.x)e.calculative.worldAnchors[h].x=i.x;else break;u=void 0;for(let h=n+1;h<e.calculative.worldAnchors.length&&(l=e.anchors[h],l);h++)if(u==null&&(u=l.y===c.y),u===!0)if(l.y===c.y)e.calculative.worldAnchors[h].y=i.y;else break;else if(l.x===c.x)e.calculative.worldAnchors[h].x=i.x;else break;t.y=i.y}else{if(t.y=i.y,r.connectTo&&ka(e,t,!0)){l&&l.x!==t.x&&(l.y=t.y);return}if(s.connectTo&&ka(e,t,!1)){a&&a.x!==t.x&&(a.y=t.y);return}const c=e.anchors[n];let u;for(let h=n-1;h>-1;h--)if(a=e.anchors[h],u==null&&(u=a.x===c.x),u===!0)if(a.x===c.x)e.calculative.worldAnchors[h].x=i.x;else break;else if(a.y===c.y)e.calculative.worldAnchors[h].y=i.y;else break;u=void 0;for(let h=n+1;h<e.calculative.worldAnchors.length&&(l=e.anchors[h],l);h++)if(u==null&&(u=l.x===c.x),u===!0)if(l.x===c.x)e.calculative.worldAnchors[h].x=i.x;else break;else if(l.y===c.y)e.calculative.worldAnchors[h].y=i.y;else break;t.x=i.x}}function _c(e,t,i,n){const r=[];let s,a,l,c,u,h,d,g,v,y,w,p,_,A;v=e[i],y=e[n],l=v.x,c=v.y,d=y.x-l,g=y.y-c,A=d*d+g*g,s=t;for(let x=i+1;x<n;x++)w=e[x],d!==0||g!==0?(p=((w.x-l)*d+(w.y-c)*g)/A,p>1?(u=w.x-y.x,h=w.y-y.y):p>0?(u=w.x-(l+d*p),h=w.y-(c+g*p)):(u=w.x-l,h=w.y-c)):(u=w.x-l,h=w.y-c),_=u*u+h*h,_>s&&(a=x,s=_);return s>t&&(a-i>1&&r.push(..._c(e,t,i,a)),r.push({id:e[a].id,penId:e[a].penId,x:e[a].x,y:e[a].y}),n-a>1&&r.push(..._c(e,t,a,n))),r}function mk(e,t=.8,i=!1){if(e.length<3)return e;let n,r,s,a,l,c,u,h,d,g,v,y,w,p,_;const A=(x,E,I,M)=>(a=Math.sqrt(x*x+E*E),a>0?(y=x/a,p=E/a):(y=1,p=0),l=Math.sqrt(I*I+M*M),l>0?(w=I/l,_=M/l):(w=1,_=0),Math.acos(y*w+p*_));g=[],v=e.length,n=e[0],e[v-1],g.push({...e[0]});for(let x=0;x<v-1;x++){if(r=e[x],s=e[x+1],d=Math.abs(A(r.x-n.x,r.y-n.y,s.x-r.x,s.y-r.y)),a)if(d<t*3.14)if(i&&(a=Math.min(a,l),l=a),c=(y+w)/2,u=(p+_)/2,h=Math.sqrt(c*c+u*u),h===0)g.push({...r});else{c/=h,u/=h;const E={...r};E.prevNextType=jn.Bilateral,E.prev={penId:E.penId,x:r.x-c*a*.25,y:r.y-u*a*.25},E.next={penId:E.penId,x:r.x+c*l*.25,y:r.y+u*l*.25},g.push(E)}else g.push({...r});n=r}return g.push({...e[e.length-1]}),g}function Zv(e,t){const i=t||new Path2D,n=e.calculative.worldAnchors;let r=e.calculative.canvas.store.data.scale,s=(e.calculative.animateLineWidth||6)*r,a=(e.animateLineWidth*2||12)*r;e.lineAnimateType===Je.WaterDrop&&(a=(e.animateLineWidth*4||24)*r);let l=(e.animateInterval||100)*r,c=e.calculative.lineWidth*(e.calculative.lineSmooth||0),u=(e.calculative.animateLineWidth/2||3)*r;if(e.animateReverse&&(a=-a,s=-s),n.length>1){let h,d=0;for(let g=0;g<n.length;g++){let v=n[g];if(h){let y=pk(h,v),w={x:h.x+(e.calculative.animatePos-d)%l*Math.cos(y*Math.PI/180),y:h.y-(e.calculative.animatePos-d)%l*Math.sin(y*Math.PI/180)};e.animateReverse&&(w={x:h.x+(e.length-(e.calculative.animatePos+d))%l*Math.cos(y*Math.PI/180),y:h.y-(e.length-(e.calculative.animatePos+d))%l*Math.sin(y*Math.PI/180)});let p=Math.sqrt((w.x-h.x)**2+(w.y-h.y)**2),_=Math.sqrt((v.x-h.x)**2+(v.y-h.y)**2);for(;p<_;)(e.animateReverse&&p-a<_||!e.animateReverse&&p>a)&&p>c+a&&_-p>c&&(e.lineAnimateType===Je.Arrow?wk(i,w,s,y,u,a):e.lineAnimateType===Je.WaterDrop&&bk(i,w,e.animateReverse,y,u,a)),w.x+=l*Math.cos(y*Math.PI/180),w.y-=l*Math.sin(y*Math.PI/180),p=Math.sqrt((w.x-h.x)**2+(w.y-h.y)**2)}h=v}}if(i instanceof Path2D)return i}function pk(e,t){let i=t.x-e.x,n=t.y-e.y,r=Math.atan(n/i)*180/Math.PI;return t.x>=e.x?r=-r:r=180-r,r}function bn(e,t,i){let n=(180-i)*Math.PI/180;return{x:(e.x-t.x)*Math.cos(n)-(e.y-t.y)*Math.sin(n)+t.x,y:(e.x-t.x)*Math.sin(n)+(e.y-t.y)*Math.cos(n)+t.y}}function wk(e,t,i,n,r,s){let a=bn({x:t.x+i,y:t.y+.57*i},{x:t.x,y:t.y},n),l=bn({x:t.x+i,y:t.y-.57*i},{x:t.x,y:t.y},n),c=bn({x:t.x+i,y:t.y+r/2},{x:t.x,y:t.y},n),u=bn({x:t.x+s,y:t.y+r/2},{x:t.x,y:t.y},n),h=bn({x:t.x+i,y:t.y-r/2},{x:t.x,y:t.y},n),d=bn({x:t.x+s,y:t.y-r/2},{x:t.x,y:t.y},n);e.moveTo(a.x,a.y),e.lineTo(t.x,t.y),e.lineTo(l.x,l.y),e.lineTo(h.x,h.y),e.lineTo(d.x,d.y),e.lineTo(u.x,u.y),e.lineTo(c.x,c.y),e.lineTo(a.x,a.y)}function bk(e,t,i,n,r,s){let a=r/2;i&&(a=-r/2);let l=bn({x:t.x,y:t.y+a},{x:t.x,y:t.y},n),c=bn({x:t.x+s,y:t.y},{x:t.x,y:t.y},n),u=Math.PI/2;i&&(u=-Math.PI/2),e.moveTo(t.x,t.y),e.arc(t.x,t.y,r/2,-u-n/180*Math.PI,u-n/180*Math.PI,!1),e.lineTo(c.x,c.y),e.lineTo(l.x,l.y)}function xk(e){var i;e.onDestroy||(e.onDestroy=_k,e.onMove=Ea,e.onResize=Ea,e.onRotate=Ea,e.onValue=Ea,e.onMouseMove=Ek,e.onBeforeValue=kk,e.onRenderPenRaw=Ak),e.calculative.singleton||(e.calculative.singleton={});const t=e.calculative.worldRect;if(!e.calculative.singleton.div){const n=document.createElement("div");n.style.position="absolute",n.style.outline="none",n.style.left="-9999px",n.style.top="-9999px",n.style.width=t.width+"px",n.style.height=t.height+"px",document.body.appendChild(n),(i=e.calculative.canvas.externalElements)==null||i.parentElement.appendChild(n),ti(e,n),e.calculative.singleton.div=n;const r=document.createElement("iframe");r.style.width="100%",r.style.height="100%",r.scrolling=e.scrolling||"no",r.frameBorder="0",r.style.border="none",r.src=e.iframe,e.calculative.iframe=e.iframe,n.appendChild(r),Qv(e),r.onload=()=>{r.setAttribute("document.domain","")}}return e.calculative.patchFlags&&ti(e,e.calculative.singleton.div),e.onRenderPenRaw(e),new Path2D}function _k(e){tg(e),e.calculative.singleton&&e.calculative.singleton.div&&(e.calculative.singleton.div.remove(),delete e.calculative.singleton.div)}function Ea(e){e.calculative.singleton.div&&ti(e,e.calculative.singleton.div)}function kk(e,t){if(t.iframe&&e.calculative.singleton.div&&(e.calculative.singleton.div.children[0].src=t.iframe,e.calculative.iframe=t.iframe),t.operationalRect||t["operationalRect.x"]!==void 0||t["operationalRect.y"]!==void 0||t["operationalRect.width"]!==void 0||t["operationalRect.height"]!==void 0){e.operationalRect||(e.operationalRect={});let i=ct(t);i.operationalRect||(i.operationalRect={}),i["operationalRect.x"]!==void 0&&(i.operationalRect.x=i["operationalRect.x"]),i["operationalRect.y"]!==void 0&&(i.operationalRect.y=i["operationalRect.y"]),i["operationalRect.width"]!==void 0&&(i.operationalRect.width=i["operationalRect.width"]),i["operationalRect.height"]!==void 0&&(i.operationalRect.height=i["operationalRect.height"]),Object.assign(e.operationalRect,i.operationalRect),e.calculative.singleton.div&&(e.calculative.singleton.div.children.length===1?Qv(e):(e.calculative.singleton.div.children[1].style.height=e.operationalRect.y*100+"%",e.calculative.singleton.div.children[1].style.left=e.operationalRect.x*100+"%",e.calculative.singleton.div.children[1].style.width=e.operationalRect.width*100+"%",e.calculative.singleton.div.children[2].style.width=(1-e.operationalRect.x-e.operationalRect.width)*100+"%",e.calculative.singleton.div.children[3].style.height=(1-e.operationalRect.y-e.operationalRect.height)*100+"%",e.calculative.singleton.div.children[3].style.left=e.operationalRect.x*100+"%",e.calculative.singleton.div.children[3].style.width=e.operationalRect.width*100+"%",e.calculative.singleton.div.children[4].style.width=e.operationalRect.x*100+"%"))}if(t.blur!==void 0)for(let i=1;i<5;i++)e.calculative.singleton.div.children[i].style["backdrop-filter"]=`blur(${t.blur||2}px)`;if(t.blurBackground!==void 0)for(let i=1;i<5;i++)e.calculative.singleton.div.children[i].style.backgroundColor=t.blurBackground;return t}function Ek(e,t){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&Jv(e.operationalRect)&&e.calculative.zIndex<5&&t.x>e.x+e.width*e.operationalRect.x&&t.x<e.x+e.width*(e.operationalRect.x+e.operationalRect.width)&&t.y>e.y+e.height*e.operationalRect.y&&t.y<e.y+e.height*(e.operationalRect.y+e.operationalRect.height)&&e.calculative.singleton.div){let i=e.calculative.singleton.div.parentNode.children;for(let n=0;n<6;n++)i[n].style.pointerEvents="none"}}function Jv(e){return e?!e.width||!e.height?!1:(e.x===void 0&&(e.x=(1-e.width)/2),e.y===void 0&&(e.y=(1-e.height)/2),!0):!1}function Qv(e){if(!Jv(e.operationalRect))return;const t=e.calculative.singleton.div;if(!t)return;const i=document.createElement("div");i.style.position="absolute",i.style.left=e.operationalRect.x*100+"%",i.style.top="0px",i.style.width=e.operationalRect.width*100+"%",i.style.height=e.operationalRect.y*100+"%",i.style["backdrop-filter"]=`blur(${e.blur||2}px)`,i.style.backgroundColor=e.blurBackground,t.appendChild(i);const n=document.createElement("div");n.style.position="absolute",n.style.right="0px",n.style.top="0px",n.style.width=(1-e.operationalRect.x-e.operationalRect.width)*100+"%",n.style.height="100%",n.style["backdrop-filter"]=`blur(${e.blur||2}px)`,n.style.backgroundColor=e.blurBackground,t.appendChild(n);const r=document.createElement("div");r.style.position="absolute",r.style.left=e.operationalRect.x*100+"%",r.style.bottom="0px",r.style.width=e.operationalRect.width*100+"%",r.style.height=(1-e.operationalRect.y-e.operationalRect.height)*100+"%",r.style["backdrop-filter"]=`blur(${e.blur||2}px)`,r.style.backgroundColor=e.blurBackground,t.appendChild(r);const s=document.createElement("div");s.style.position="absolute",s.style.left="0px",s.style.top="0px",s.style.width=e.operationalRect.x*100+"%",s.style.height="100%",s.style["backdrop-filter"]=`blur(${e.blur||2}px)`,s.style.backgroundColor=e.blurBackground,t.appendChild(s);let a=()=>{tg(e)};i.onmouseenter=a,r.onmouseenter=a,n.onmouseenter=a,s.onmouseenter=a,t.onmouseleave=a}function tg(e){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&e.calculative.zIndex<5){let t=e.calculative.singleton.div.parentNode.children;for(let i=1;i<6;i++)t[i].style.pointerEvents="initial"}}function Ak(e){if(e.thumbImg&&!e.calculative.img){const t=new Image;t.crossOrigin=e.crossOrigin==="undefined"?void 0:e.crossOrigin||"anonymous",e.calculative.canvas.store.options.cdn&&!(e.thumbImg.startsWith("http")||e.thumbImg.startsWith("//")||e.thumbImg.startsWith("data:image"))?t.src=e.calculative.canvas.store.options.cdn+e.thumbImg:t.src=e.thumbImg,t.onerror=i=>{t.remove(),e.calculative.img=void 0},e.calculative.img=t}}const He={},Ma=['<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M473.088 125.44L256 256H52.224C23.552 256 0 279.552 0 308.224V716.8c0 28.16 23.04 51.2 51.2 51.2h204.8l217.088 130.56c16.896 10.24 38.912-2.048 38.912-22.016V147.456c0-19.968-21.504-32.256-38.912-22.016zM699.904 320.512c-20.992-18.944-53.248-17.408-72.192 3.584-18.944 20.992-17.408 53.248 3.584 72.192 0.512 0.512 58.368 54.784 58.368 121.344 0 37.888-19.456 74.752-58.368 110.08-20.992 18.944-22.528 51.2-3.584 72.192 10.24 11.264 24.064 16.896 37.888 16.896 12.288 0 24.576-4.608 34.304-13.312 61.44-55.296 92.16-117.76 92.16-185.856 0-112.64-88.576-193.536-92.16-197.12z" fill="" p-id="2434"></path><path d="M853.504 166.4c-20.992-18.944-53.248-16.896-72.192 4.096-18.944 20.992-16.896 53.248 4.096 72.192 1.536 1.024 135.68 122.88 135.68 280.576 0 90.624-45.568 177.152-135.68 257.536-20.992 18.944-23.04 51.2-4.096 72.192 10.24 11.264 24.064 16.896 38.4 16.896 12.288 0 24.576-4.096 34.304-12.8 112.64-100.864 169.984-212.992 169.984-333.824-1.024-202.752-163.84-350.208-170.496-356.864z"></path></svg>','<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" ><path d="M256 768H51.2c-28.16 0-51.2-23.04-51.2-51.2V308.224C0 279.552 23.552 256 52.224 256H256v512zM512 147.456v728.576c0 19.968-21.504 32.256-38.912 22.016L256 768V256l217.088-130.56c17.408-10.24 38.912 2.048 38.912 22.016zM623.104 656.896c-19.968-19.968-19.968-52.224 0-72.192l217.088-217.088c19.968-19.968 52.224-19.968 72.192 0 19.968 19.968 19.968 52.224 0 72.192l-217.088 217.088c-19.456 19.968-52.224 19.968-72.192 0z" fill="" p-id="2582"></path><path d="M623.104 367.104c19.968-19.968 52.224-19.968 72.192 0l217.088 217.088c19.968 19.968 19.968 52.224 0 72.192-19.968 19.968-52.224 19.968-72.192 0l-217.088-217.088c-19.968-19.456-19.968-52.224 0-72.192z"></path></svg>'];function Rk(e){var t;if(e.onDestroy||(e.onDestroy=Ck,e.onMove=Ol,e.onResize=Ol,e.onRotate=Ol,e.onClick=nd,e.onValue=Sk,e.onChangeId=Tk),He[e.id])e.video&&e.calculative.media&&e.video!==e.calculative.video?(console.warn("video \u66F4\u6539, \u6B64\u5904\u662F\u5426\u6267\u884C\uFF1F"),e.calculative.media.src=e.video,e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop,e.calculative.video=e.video):e.audio&&e.calculative.media&&e.audio!==e.calculative.audio&&(e.calculative.media.src=e.audio,e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop,e.calculative.audio=e.audio);else{const i=document.createElement("div"),n=document.createElement("div");n.style.position="absolute",n.style.outline="none",n.style.left="0",n.style.bottom="0",n.style.width="0",n.style.height="2px",n.style.background="#52c41a",n.style.zIndex="1",e.hideProgress&&(n.style.display="none");const r=document.createElement("div");r.innerHTML=Ma[1],r.style.position="absolute",r.style.right="0",r.style.bottom="0",r.style.width="20px",r.style.height="20px",r.style.fill="hsla(0, 0%, 100%, .8)",r.style.zIndex="1",r.style.display="none",i.appendChild(n),i.appendChild(r),r.onclick=a=>{a.stopPropagation(),e.calculative.media.muted?(r.innerHTML=Ma[0],e.calculative.media.muted=!1):(r.innerHTML=Ma[1],e.calculative.media.muted=!0)},e.calculative.singleton||(e.calculative.singleton={}),e.calculative.singleton.muted=r,i.onmouseenter=a=>{r.style.display="block"},i.onmouseleave=a=>{r.style.display="none"},i.onclick=a=>{a.stopPropagation(),nd(e)};let s;e.video?(s=document.createElement("video"),s.src=e.video):e.audio&&(s=document.createElement("audio"),s.src=e.audio),s.loop=e.playLoop,s.ontimeupdate=()=>{eg(n,s,e.calculative.worldRect.width)},s.onended=()=>{e.calculative.onended&&e.calculative.onended(e)},e.calculative.media=s,s.style.position="absolute",s.style.outline="none",s.style.left="0",s.style.top="0",s.style.width="100%",s.style.height="100%",i.appendChild(s),He[e.id]=i,(t=e.calculative.canvas.externalElements)==null||t.parentElement.appendChild(i),ti(e,i),e.autoPlay&&(s.autoplay=!0,s.muted=!0)}return e.calculative.patchFlags&&ti(e,He[e.id]),new Path2D}function Ck(e){He[e.id].onclick=null,He[e.id].remove(),He[e.id]=void 0}function Ol(e){ti(e,He[e.id]);const t=He[e.id].children[0],i=He[e.id].children[1];eg(t,i,e.calculative.worldRect.width)}function nd(e){e.calculative.media&&(e.calculative.media.muted=!1,e.calculative.singleton.muted.innerHTML=Ma[0],e.calculative.media.paused?e.calculative.media.play():e.calculative.media.pause())}function eg(e,t,i){e.style.width=t.currentTime/t.duration*i+"px"}function Tk(e,t,i){!He[t]||(He[i]=He[t],delete He[t])}function Sk(e){const t=He[e.id];if(!t)return;ti(e,t);const i=e.calculative.media.getAttribute("src");e.video?i!==e.video&&(e.calculative.media.src=e.video):e.audio&&i!==e.audio&&(e.calculative.media.src=e.audio),e.autoPlay&&(e.calculative.media.muted=!0,e.calculative.media.autoplay=!0),e.calculative.media.loop=e.playLoop}function Ii(){try{const e=new OffscreenCanvas(0,0),t=e.getContext("2d");return t&&t.arc?e:document.createElement("canvas")}catch{return document.createElement("canvas")}}class us{constructor(t,i){W(this,"parentElement");W(this,"store");W(this,"box");W(this,"text");W(this,"arrowUp");W(this,"arrowDown");W(this,"x");W(this,"y");W(this,"currentPen");this.parentElement=t,this.store=i,this.box=document.createElement("div"),this.text=document.createElement("div"),this.arrowUp=document.createElement("div"),this.arrowDown=document.createElement("div"),this.box.className="meta2d-tooltip",this.text.className="text",this.arrowUp.className="arrow",this.arrowDown.className="arrow down",this.box.appendChild(this.text),this.box.appendChild(this.arrowUp),this.box.appendChild(this.arrowDown),t.appendChild(this.box),this.box.onmouseleave=()=>{this.hide(),this.store.lastHover=void 0};let n;for(let r=0;r<document.styleSheets.length;r++)document.styleSheets[r].title==="le5le.com/tooltip"&&(n=document.styleSheets[r]);if(!n){let r=document.createElement("style");r.type="text/css",r.title="le5le.com/tooltip",document.head.appendChild(r),r=document.createElement("style"),r.type="text/css",document.head.appendChild(r),n=r.sheet,n.insertRule(".meta2d-tooltip{position:absolute;padding:8px 0;z-index:10;left: -9999px;top: -9999px;}"),n.insertRule(".meta2d-tooltip .text{max-width:320px;min-height:30px;max-height:400px;outline:none;padding:8px 16px;border-radius:4px;background:#777777;color:#ffffff;line-height:1.8;overflow-y:auto;}"),n.insertRule(".meta2d-tooltip .arrow{position:absolute;border:10px solid transparent;background:transparent;top:-5px;left:50%;transform:translateX(-50%)}"),n.insertRule(".meta2d-tooltip .arrow.down{top:initial;bottom: -1px;}")}}static getTitle(t){if(t.titleFnJs&&!t.titleFn)try{t.titleFn=new Function("pen",t.titleFnJs)}catch(i){console.log("titleFnJs",i)}return t.titleFn?t.titleFn(t):String(t.title)}setText(t){const i=this.box.getBoundingClientRect();let n=globalThis.marked;const r=us.getTitle(t);if(n){this.text.innerHTML=n(r);const s=this.text.getElementsByTagName("A");for(let a=0;a<s.length;++a)s[a].setAttribute("target","_blank")}else this.text.innerHTML=r;return i}updateText(t){var r;if(((r=this.currentPen)==null?void 0:r.id)!==t.id||us.titleEmpty(t))return;const i=this.setText(t),n=this.box.getBoundingClientRect();this.changePositionByText(i,n)}changePositionByText(t,i){this.x-=(i.width-t.width)/2,this.y-=i.height-t.height,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"}static titleEmpty(t){return!t.title&&!t.titleFn&&!t.titleFnJs}show(t,i){if(this.currentPen=t,us.titleEmpty(t)){let l=Ze(t,!0);l&&this.show(l,i);return}this.setText(t);const n=this.box.getBoundingClientRect(),r=t.calculative.worldRect;let s=t.calculative.canvas.store.data.x+i.x-n.width/2,a=t.calculative.canvas.store.data.y+i.y-n.height;t.type||(s=t.calculative.canvas.store.data.x+r.x-(n.width-r.width)/2,a=t.calculative.canvas.store.data.y+r.ey-n.height-r.height),a>0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#777777"):(a+=n.height+r.height+5,this.arrowUp.style.borderBottomColor="#777777",this.arrowDown.style.borderTopColor="transparent"),this.x=s,this.y=a,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"}hide(){this.currentPen=null,this.x=-9999,this.box.style.left="-9999px"}translate(t,i){this.x<-1e3||(this.x+=t,this.y+=i,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px")}destroy(){this.box.onmouseleave=null}}class ig{constructor(t){W(this,"parent");W(this,"h");W(this,"v");W(this,"isDownH");W(this,"isDownV");W(this,"x");W(this,"y");W(this,"hSize");W(this,"vSize");W(this,"scrollX");W(this,"scrollY");W(this,"lastScrollX");W(this,"lastScrollY");W(this,"rect");W(this,"isShow");W(this,"pageMode");W(this,"onMouseDownH",t=>{t.preventDefault(),t.stopPropagation(),this.isDownH=t.x,this.x=this.parent.store.data.x||0,this.lastScrollX=this.scrollX});W(this,"onMouseDownV",t=>{t.preventDefault(),t.stopPropagation(),this.isDownV=t.y,this.y=this.parent.store.data.y||0,this.lastScrollY=this.scrollY});W(this,"onMouseMove",t=>{if(this.isDownH){const i=t.x-this.isDownH;this.scrollX=this.lastScrollX+i,this.h.style.left=`${this.scrollX}px`,this.parent.store.data.x=this.x-i*this.rect.width/this.parent.parentElement.clientWidth}if(this.isDownV){const i=t.y-this.isDownV;if(this.pageMode&&this.canMouseMove(i))return;this.scrollY=this.lastScrollY+i,this.v.style.top=`${this.scrollY}px`,this.parent.store.data.y=this.y-i*this.rect.height/this.parent.parentElement.clientHeight}(this.isDownH||this.isDownV)&&(this.parent.onMovePens(),this.parent.canvasTemplate.init(),this.parent.canvasImage.init(),this.parent.canvasImageBottom.init(),this.parent.render())});W(this,"onMouseUp",t=>{!this.isDownH&&!this.isDownV||(this.isDownH=void 0,this.isDownV=void 0,this.scrollX<20?(this.scrollX=20,this.h.style.left=`${this.scrollX}px`):this.scrollX>this.parent.parentElement.clientWidth-this.hSize-20&&(this.scrollX=this.parent.parentElement.clientWidth-this.hSize-20,this.h.style.left=`${this.scrollX}px`),this.scrollY<20?(this.scrollY=20,this.v.style.top=`${this.scrollY}px`):this.scrollY>this.parent.parentElement.clientHeight-this.vSize-20&&(this.scrollY=this.parent.parentElement.clientHeight-this.vSize-20,this.v.style.top=`${this.scrollY}px`),this.resize())});this.parent=t,this.h=document.createElement("div"),this.v=document.createElement("div"),this.parent.externalElements.appendChild(this.h),this.parent.externalElements.appendChild(this.v),this.h.className="meta2d-scroll h",this.h.onmousedown=this.onMouseDownH,this.v.className="meta2d-scroll v",this.v.onmousedown=this.onMouseDownV,document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp);let i;for(let n=0;n<document.styleSheets.length;n++)document.styleSheets[n].title==="le5le/scroll"&&(i=document.styleSheets[n]);if(!i){let n=document.createElement("style");n.type="text/css",n.title="le5le.com/scroll",document.head.appendChild(n),n=document.createElement("style"),n.type="text/css",document.head.appendChild(n),i=n.sheet,i.insertRule(".meta2d-scroll{position:absolute;width:8px;height:200px;background:#dddddd;border-radius:10px;z-index:20;cursor:default;}"),i.insertRule(".meta2d-scroll:hover{background:#cccccc;cursor:pointer}"),i.insertRule(".meta2d-scroll.v{right:0;top:calc(50% - 100px);}"),i.insertRule(".meta2d-scroll.h{bottom:2px;left:calc(50% - 100px);width:200px;height:8px;}")}this.init()}init(){this.isShow=!0,this.resize(),this.initPos()}canMouseMove(t){const i=this.parent.parent.getRect();return t<0&&i.y+this.parent.store.data.y>=0||t>0&&i.ey-this.parent.height+this.parent.store.data.y<=0}changeMode(){this.pageMode=!0,this.h.style.display="none",this.parent.parent.getRect().height<this.parent.height&&(this.v.style.display="none")}initPos(){this.scrollX=(this.parent.parentElement.clientWidth-this.hSize)/2,this.scrollY=(this.parent.parentElement.clientHeight-this.vSize)/2,this.h.style.left=`${this.scrollX}px`,this.v.style.top=`${this.scrollY}px`}resize(){this.rect=pi(this.parent.store.data.pens),this.rect.width<1400&&(this.rect.width=1400),this.rect.height<900&&(this.rect.height=900),this.parent.store.data.x>0?this.rect.width+=this.parent.store.data.x+(this.rect.x>0?0:this.rect.x):this.rect.width-=this.parent.store.data.x+(this.rect.x>0?0:this.rect.x),this.parent.store.data.y>0?this.rect.height+=this.parent.store.data.y+(this.rect.y>0?0:this.rect.y):this.rect.height-=this.parent.store.data.y+(this.rect.y>0?0:this.rect.y),this.rect.width<1400&&(this.rect.width=1400),this.rect.height<900&&(this.rect.height=900),this.hSize=1e3*this.parent.parentElement.clientWidth/this.rect.width/3,this.vSize=1e3*this.parent.parentElement.clientHeight/this.rect.height/3,this.h.style.width=this.hSize+"px",this.v.style.height=this.vSize+"px"}show(){this.isShow=!0,this.h.style.display="block",this.v.style.display="block",document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp)}hide(){this.isShow=!1,this.h.style.display="none",this.v.style.display="none",this.destroy()}translate(t,i){t&&(this.scrollX-=t*this.parent.parentElement.clientWidth/this.rect.width,this.h.style.left=`${this.scrollX}px`),i&&(this.scrollY-=i*this.parent.parentElement.clientHeight/this.rect.height,this.v.style.top=`${this.scrollY}px`)}wheel(t){let i=10;t&&(i=-10),!(this.pageMode&&this.canMouseMove(i))&&(this.scrollY+=i,this.v.style.top=`${this.scrollY}px`,this.parent.store.data.y-=i*this.rect.height/this.parent.parentElement.clientHeight,this.parent.onMovePens(),this.parent.canvasTemplate.init(),this.parent.canvasImage.init(),this.parent.canvasImageBottom.init(),this.parent.render())}destroy(){document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp)}}class rd{constructor(t,i,n){W(this,"parentElement");W(this,"store");W(this,"isBottom");W(this,"canvas",document.createElement("canvas"));W(this,"otherOffsreen",Ii());W(this,"offscreen",Ii());W(this,"animateOffsScreen",Ii());W(this,"fitOffscreen",Ii());W(this,"fitFlag",!1);W(this,"currentFit");W(this,"activeFit");this.parentElement=t,this.store=i,this.isBottom=n,t.appendChild(this.canvas),this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0"}resize(t,i){this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.otherOffsreen.width=t,this.otherOffsreen.height=i,this.offscreen.width=t,this.offscreen.height=i,this.animateOffsScreen.width=t,this.animateOffsScreen.height=i,this.fitOffscreen.width=t,this.fitOffscreen.height=i,this.otherOffsreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.otherOffsreen.getContext("2d").textBaseline="middle",this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle",this.animateOffsScreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.animateOffsScreen.getContext("2d").textBaseline="middle",this.fitOffscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.fitOffscreen.getContext("2d").textBaseline="middle",this.init()}init(){this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.animateOffsScreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.fitOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.store.data.pens)this.hasImage(t)&&(t.calculative.imageDrawed=!1);this.isBottom?this.store.patchFlagsBackground=!0:this.store.patchFlagsTop=!0}clear(){this.otherOffsreen.getContext("2d").clearRect(0,0,this.otherOffsreen.width,this.otherOffsreen.height),this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.animateOffsScreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.fitOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height)}hasImage(t){return t.calculative.hasImage=t.calculative&&t.calculative.inView&&(this.isBottom&&t.canvasLayer===zt.CanvasImageBottom||!this.isBottom&&t.canvasLayer===zt.CanvasImage)&&t.image&&t.calculative.img&&t.name!=="gif",t.calculative.hasImage}render(){var a;let t=!1,i=!1;for(const l of this.store.data.pens)this.hasImage(l)&&(this.store.animates.has(l)?i=!0:l.calculative.imageDrawed||(t=!0),l.parentId&&this.store.animates.has(Ze(l,!0))&&(i=!0));const n=this.store.patchFlagsBackground,r=this.store.patchFlagsTop;if(r&&!this.isBottom){const l=this.otherOffsreen.getContext("2d");l.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderRule(l)}if(this.store.patchFlagsLast&&this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),t){const l=this.offscreen.getContext("2d");l.save(),l.clearRect(0,0,this.canvas.width,this.canvas.height),l.translate(this.store.data.x,this.store.data.y);for(const c of this.store.data.pens)!c.calculative.hasImage||this.store.animates.has(c)||this.store.animates.has(Ze(c,!0))||c.canvasLayer!==zt.CanvasTemplate&&(c.name==="combine"&&!c.draw||(c.calculative.imageDrawed=!0,l.save(),Vn(l,c),c.calculative.rotate&&Qi(l,c),$n(l,c),Pr(l,c),l.restore()));l.restore()}if(i){const l=this.animateOffsScreen.getContext("2d");l.save(),l.clearRect(0,0,this.canvas.width,this.canvas.height),l.translate(this.store.data.x,this.store.data.y);for(const c of this.store.animates)!c.calculative.hasImage||c.canvasLayer!==zt.CanvasTemplate&&(c.calculative.imageDrawed=!0,l.save(),Vn(l,c),c.calculative.rotate&&Qi(l,c),$n(l,c),Pr(l,c),l.restore());for(const c of this.store.data.pens)!c.calculative.hasImage||!c.parentId||c.canvasLayer!==zt.CanvasTemplate&&this.store.animates.has(Ze(c,!0))&&(c.calculative.imageDrawed=!0,l.save(),Vn(l,c),c.calculative.rotate&&Qi(l,c),$n(l,c),Pr(l,c),l.restore());l.restore()}if(!this.isBottom&&!this.store.data.locked&&this.fitFlag){const l=(this.store.data.width||this.store.options.width)*this.store.data.scale,c=(this.store.data.height||this.store.options.height)*this.store.data.scale,u=this.store.data.origin.x+this.store.data.x||this.store.options.x||0,h=this.store.data.origin.y+this.store.data.y||this.store.options.y||0,d=this.fitOffscreen.getContext("2d");d.save(),d.clearRect(0,0,this.canvas.width,this.canvas.height),d.fillStyle="#ffffff66",d.strokeStyle=this.store.options.activeColor,(a=this.store.data.fits)==null||a.forEach((g,v)=>{d.fillRect(u+l*g.x,h+c*g.y,l*g.width,c*g.height),g.active&&d.strokeRect(u+l*g.x,h+c*g.y,l*g.width,c*g.height)}),d.restore()}if(t||i||n&&this.isBottom||r&&!this.isBottom){const l=this.canvas.getContext("2d");l.clearRect(0,0,this.canvas.width,this.canvas.height),this.isBottom&&(this.store.patchFlagsBackground=!1),l.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),l.drawImage(this.animateOffsScreen,0,0,this.canvas.width,this.canvas.height),this.isBottom||(l.drawImage(this.otherOffsreen,0,0,this.canvas.width,this.canvas.height),this.store.patchFlagsTop=!1,!this.store.data.locked&&this.fitFlag&&l.drawImage(this.fitOffscreen,0,0,this.canvas.width,this.canvas.height))}}renderRule(t){var x,E,I,M,B,D,q,Q;const{data:i,options:n}=this.store,{rule:r,ruleColor:s,scale:a,origin:l}=i;if(!(r!=null?r:n.rule))return;const c=a*10;t.save();const u=s||n.ruleColor;t.strokeStyle=qa(u,.7);const h=l.x+i.x,d=l.y+i.y,{width:g,height:v}=this.canvas;let y=((x=n.ruleOptions)==null?void 0:x.height)||20;(E=n.ruleOptions)!=null&&E.background&&(t.beginPath(),t.fillStyle=(I=n.ruleOptions)==null?void 0:I.background,t.rect(0,0,g,y),t.fill(),t.rect(0,0,y,v),t.fill()),(M=n.ruleOptions)!=null&&M.underline&&(t.beginPath(),t.fillStyle=qa(u,.7),t.moveTo(0,y),t.lineTo(g,y),t.stroke(),t.moveTo(y,0),t.lineTo(y,v),t.stroke());let w=y/4;((B=n.ruleOptions)==null?void 0:B.baseline)==="bottom"&&(w=y*3/4),t.beginPath(),t.lineWidth=y/2,t.lineDashOffset=-h%c,t.setLineDash([1,c-1]),t.moveTo(0,w),t.lineTo(g,w),t.stroke(),t.beginPath(),t.lineDashOffset=-d%c,t.moveTo(w,0),t.lineTo(w,v),t.stroke(),t.strokeStyle=u,t.beginPath(),t.lineWidth=y,t.lineDashOffset=-h%(c*10),t.setLineDash([1,c*10-1]),t.moveTo(0,y/2),t.lineTo(g,y/2),t.stroke(),t.beginPath(),t.lineDashOffset=-d%(c*10),t.moveTo(y/2,0),t.lineTo(y/2,v),t.stroke(),t.beginPath(),t.fillStyle=((D=n.ruleOptions)==null?void 0:D.textColor)||t.strokeStyle;let p=0-Math.floor(h/c/10)*100,_=((q=n.ruleOptions)==null?void 0:q.textTop)||16,A=((Q=n.ruleOptions)==null?void 0:Q.textLeft)||4;h<0&&(p-=100);for(let C=h%(c*10);C<g;C+=10*c,p+=100)c<3&&p%500||t.fillText(p.toString(),C+A,_);p=0-Math.floor(d/c/10)*100,d<0&&(p-=100);for(let C=d%(c*10);C<v;C+=10*c,p+=100)c<3&&p%500||(t.save(),t.beginPath(),t.translate(_,C-A),t.rotate(270*Math.PI/180),t.fillText(p.toString(),0,0),t.restore());t.restore()}}class Pk{constructor(t,i,n){W(this,"parentCanvas");W(this,"parentElement");W(this,"store");W(this,"canvas",document.createElement("canvas"));W(this,"magnifierScreen",Ii());W(this,"offscreen",Ii());W(this,"domOffscreen",Ii());W(this,"magnifierSize",300);W(this,"magnifier");this.parentCanvas=t,this.parentElement=i,this.store=n,i.appendChild(this.canvas),this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0"}resize(t,i){this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.offscreen.width=t,this.offscreen.height=i,this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle",this.domOffscreen.width=t,this.domOffscreen.height=i,this.domOffscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.domOffscreen.getContext("2d").textBaseline="middle",this.magnifierScreen.width=this.magnifierSize+5,this.magnifierScreen.height=this.magnifierSize+5}renderMagnifier(){if(!this.magnifier)return;const t=this.magnifierSize/2,i=this.magnifierSize+5,n=this.magnifierScreen.getContext("2d");n.clearRect(0,0,i,i),n.lineWidth=5,n.save(),n.translate(2.5,2.5),n.save(),n.arc(t,t,t,0,Math.PI*2,!1),n.clip(),n.translate(-t,-t),n.scale(2,2);const r={x:(this.parentCanvas.mousePos.x+this.store.data.x)*this.store.dpiRatio,y:(this.parentCanvas.mousePos.y+this.store.data.y)*this.store.dpiRatio};[this.parentCanvas.canvasTemplate.bgOffscreen,this.parentCanvas.canvasTemplate.offscreen,this.parentCanvas.canvasImageBottom.offscreen,this.parentCanvas.canvasImageBottom.animateOffsScreen,this.parentCanvas.offscreen,this.parentCanvas.canvasImage.offscreen,this.parentCanvas.canvasImage.animateOffsScreen,this.domOffscreen].forEach(c=>{n.drawImage(c,r.x-t,r.y-t,this.magnifierSize,this.magnifierSize,0,0,this.magnifierSize,this.magnifierSize)}),n.restore(),n.beginPath();const a=n.createRadialGradient(t,t,t-5,t,t,t);a.addColorStop(0,"rgba(0,0,0,0.2)"),a.addColorStop(.8,"rgb(200,200,200)"),a.addColorStop(.9,"rgb(200,200,200)"),a.addColorStop(1,"rgba(200,200,200,0.9)"),n.strokeStyle=a,n.arc(t,t,t,0,Math.PI*2,!1),n.stroke(),n.restore(),this.offscreen.getContext("2d").drawImage(this.magnifierScreen,0,0,this.magnifierSize+5,this.magnifierSize+5,(r.x-t-2.5)/this.store.dpiRatio,(r.y-t-2.5)/this.store.dpiRatio,(this.magnifierSize+5)/this.store.dpiRatio,(this.magnifierSize+5)/this.store.dpiRatio)}updateDomOffscreen(){const t=this.domOffscreen.getContext("2d");t.clearRect(0,0,this.domOffscreen.width,this.domOffscreen.height);for(const i of this.store.data.pens)if((i.externElement||i.name==="gif")&&i.calculative.img){t.save(),t.translate(this.store.data.x,this.store.data.y);const{x:n,y:r,width:s,height:a}=i.calculative.worldRect;t.drawImage(i.calculative.img,n,r,s,a),t.restore()}}render(){this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.renderMagnifier();const t=this.canvas.getContext("2d");t.clearRect(0,0,this.canvas.width,this.canvas.height),t.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height)}}function ng(e){if(e.data.locked)throw new Error("canvas is locked")}class Ik{constructor(t){W(this,"parentElement");W(this,"box");W(this,"iframe");W(this,"dialog");W(this,"close");W(this,"title");W(this,"body");W(this,"x");W(this,"y");W(this,"url");this.parentElement=t,this.box=document.createElement("div"),this.dialog=document.createElement("div");let i=document.createElement("div");this.title=document.createElement("div"),this.close=document.createElement("span"),this.close.innerHTML=`
  3. <svg fill="none" viewBox="0 0 16 16" width="1em" height="1em">
  4. <path
  5. fill="currentColor"
  6. d="M8 8.92L11.08 12l.92-.92L8.92 8 12 4.92 11.08 4 8 7.08 4.92 4 4 4.92 7.08 8 4 11.08l.92.92L8 8.92z"
  7. fill-opacity="0.9"
  8. ></path>
  9. </svg>`,this.body=document.createElement("div"),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.box.className="meta2d-dialog_mask",this.dialog.className="meta2d-dialog",this.body.className="meta2d-dialog_body",i.className="meta2d-dialog_header",this.title.className="meta2d-dialog-content",this.close.className="meta2d-dialog-close",i.appendChild(this.title),i.appendChild(this.close),this.body.appendChild(this.iframe),this.dialog.appendChild(i),this.dialog.appendChild(this.body),this.box.appendChild(this.dialog),t.appendChild(this.box),this.dialog.onclick=r=>{r.stopPropagation()},this.box.onclick=()=>{this.hide()},this.close.onclick=()=>{this.hide()};let n;for(let r=0;r<document.styleSheets.length;r++)document.styleSheets[r].title==="le5le.com/dialog"&&(n=document.styleSheets[r]);if(!n){let r=document.createElement("style");r.type="text/css",r.title="le5le.com/dialog",document.head.appendChild(r),r=document.createElement("style"),r.type="text/css",document.head.appendChild(r),n=r.sheet,n.insertRule(`.meta2d-dialog_mask {
  10. display: none;
  11. position: absolute;
  12. top: 0%;
  13. left: 0%;
  14. width: 100%;
  15. height: 100%;
  16. background-color: #0000006f;
  17. z-index: 9999;`),n.insertRule(`.meta2d-dialog_mask .meta2d-dialog {
  18. position: absolute;
  19. top: 15vh;
  20. left: 10%;
  21. width: 80%;
  22. height:420px;
  23. padding: 16px 20px;
  24. border-radius: 9px;
  25. background-color: #1e2430;
  26. z-index: 19999;
  27. overflow: auto;
  28. }`),n.insertRule(`.meta2d-dialog_header {
  29. display: flex;
  30. }`),n.insertRule(`.meta2d-dialog-content {
  31. width: calc(100% - 20px);
  32. font-weight: 600;
  33. font-size: 14px;
  34. color: #bdc7db;
  35. padding-bottom:8px;
  36. }`),n.insertRule(`.meta2d-dialog-close {
  37. width: 20px;
  38. height: 20px;
  39. line-height: 20px;
  40. text-align: center;
  41. color: #617b91;
  42. position: absolute;
  43. right:20px;
  44. top:18px;
  45. }`),n.insertRule(`.meta2d-dialog-close :hover{
  46. cursor: pointer;
  47. }`),n.insertRule(`.meta2d-dialog_body{
  48. // margin-top: 4px;
  49. } `),n.insertRule(`.meta2d-dialog_body iframe{
  50. width: 100%;
  51. height: 100%;
  52. }`)}}show(t,i,n){!i||(i!==this.url&&(this.iframe.setAttribute("src",i),this.url=i),t&&(this.title.innerText=t),t?(this.dialog.style.padding="16px 20px",this.title.style.display="block",this.body.style.height="calc(100% - 26px)"):(this.dialog.style.padding="0px",this.title.style.display="none",this.body.style.height="100%",this.body.style.overflow="hidden"),n&&(this.dialog.style.width=n.width?n.width+"px":"80%",this.dialog.style.height=n.height?n.height+"px":"420px",this.dialog.style.top=n.y?n.y+"px":"15vh",this.dialog.style.left=n.x?n.x+"px":`calc( 50% - ${n.width?n.width/2+"px":"40%"} )`),this.box.style.display="block")}hide(){this.box.style.display="none"}destroy(){this.dialog.onclick=void 0,this.box.onclick=void 0,this.close.onclick=void 0}}class Ka{constructor(t){W(this,"parentElement");W(this,"box");W(this,"currentAnchor");this.parentElement=t,this.box=document.createElement("div"),this.box.className="meta2d-title",t.appendChild(this.box);let i;for(let n=0;n<document.styleSheets.length;n++)document.styleSheets[n].title==="le5le.com/title"&&(i=document.styleSheets[n]);if(!i){let n=document.createElement("style");n.type="text/css",n.title="le5le.com/title",document.head.appendChild(n),n=document.createElement("style"),n.type="text/css",document.head.appendChild(n),i=n.sheet,i.insertRule(".meta2d-title{position:absolute;padding:0;z-index:10;left: -9999px;top: -9999px;background:#fff;color:#000; cursor: crosshair;border: 1px solid black;}")}}static getTitle(t){}setText(t){this.box.innerText=t.title}updateText(t){var i;((i=this.currentAnchor)==null?void 0:i.id)===t.id&&(Ka.titleEmpty(t)||(this.setText(t),this.changePositionByAnchor(t)))}changePositionByAnchor(t){this.box.style.left=t.x+10+"px",this.box.style.top=t.y+10+"px"}static titleEmpty(t){return!t.title}show(t,i){if(Ka.titleEmpty(t))return;this.currentAnchor=t,this.setText(t);let n={x:i.calculative.canvas.store.data.x+t.x,y:i.calculative.canvas.store.data.y+t.y};this.changePositionByAnchor(n)}hide(){this.box.style.left="-9999px",this.box.innerText="",this.currentAnchor=null}destroy(){this.box.onmouseleave=null}}class Lk{constructor(t,i){W(this,"parentElement");W(this,"store");W(this,"canvas",document.createElement("canvas"));W(this,"offscreen",Ii());W(this,"bgOffscreen",Ii());W(this,"patchFlags");W(this,"bgPatchFlags");this.parentElement=t,this.store=i,t.appendChild(this.canvas),this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0"}resize(t,i){this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.bgOffscreen.width=t,this.bgOffscreen.height=i,this.offscreen.width=t,this.offscreen.height=i,this.bgOffscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.bgOffscreen.getContext("2d").textBaseline="middle",this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle",this.init()}init(){this.bgOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.patchFlags=!0,this.bgPatchFlags=!0}hidden(){this.canvas.style.display="none"}show(){this.canvas.style.display="block"}clear(){this.bgOffscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.offscreen.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.bgPatchFlags=!0,this.patchFlags=!0}render(){var t;if(this.bgPatchFlags){const i=this.bgOffscreen.getContext("2d");i.clearRect(0,0,this.canvas.width,this.canvas.height);const n=this.store.data.width||this.store.options.width,r=this.store.data.height||this.store.options.height,s=this.store.data.x||this.store.options.x||0,a=this.store.data.y||this.store.options.y||0,l=this.store.data.background||this.store.options.background;l&&(i.save(),i.fillStyle=l,i.globalAlpha=(t=this.store.data.globalAlpha)!=null?t:this.store.options.globalAlpha,n&&r?(i.shadowOffsetX=this.store.options.shadowOffsetX,i.shadowOffsetY=this.store.options.shadowOffsetY,i.shadowBlur=this.store.options.shadowBlur,i.shadowColor=this.store.options.shadowColor,i.fillRect(this.store.data.origin.x+s,this.store.data.origin.y+a,n*this.store.data.scale,r*this.store.data.scale)):i.fillRect(0,0,this.canvas.width,this.canvas.height),i.restore()),n&&r&&this.store.bkImg&&(i.save(),i.drawImage(this.store.bkImg,this.store.data.origin.x+s,this.store.data.origin.y+a,n*this.store.data.scale,r*this.store.data.scale),i.restore()),this.renderGrid(i)}if(this.patchFlags){const i=this.offscreen.getContext("2d");i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.translate(this.store.data.x,this.store.data.y);for(const n of this.store.data.pens)if(!!isFinite(n.x)&&n.canvasLayer===zt.CanvasTemplate&&n.calculative.inView){if(n.name==="combine"&&!n.draw)continue;Nn(i,n),n.image&&n.name!=="gif"&&n.calculative.img&&(i.save(),Vn(i,n),n.calculative.rotate&&Qi(i,n),$n(i,n),Pr(i,n),i.restore())}i.restore()}if(this.patchFlags||this.bgPatchFlags){const i=this.canvas.getContext("2d");i.clearRect(0,0,this.canvas.width,this.canvas.height),i.drawImage(this.bgOffscreen,0,0,this.canvas.width,this.canvas.height),i.drawImage(this.offscreen,0,0,this.canvas.width,this.canvas.height),this.patchFlags=!1,this.bgPatchFlags=!1}}renderGrid(t){const{data:i,options:n}=this.store,{grid:r,gridRotate:s,gridColor:a,gridSize:l,scale:c,origin:u}=i;if(!(r!=null?r:n.grid))return;t.save();const h=(i.width||n.width)*c,d=(i.height||n.height)*c,g=(i.x||n.x||0)+u.x,v=(i.y||n.y||0)+u.y;s&&(t.translate(h/2,d/2),t.rotate(s*Math.PI/180),t.translate(-h/2,-d/2)),t.lineWidth=1,t.strokeStyle=a||n.gridColor,t.beginPath();let y=(l||n.gridSize)*c;if(y=y<0?0:y,!h||!d){const w=this.store.dpiRatio,p=this.canvas.width/w,_=this.canvas.height/w,A=g/y,x=v/y,E=y*10,I=g-Math.ceil(A)*y,M=v-Math.ceil(x)*y,B=p+I+E,D=_+M+E;for(let q=I;q<=B;q+=y)t.moveTo(q,M),t.lineTo(q,_+M+E);for(let q=M;q<=D;q+=y)t.moveTo(I,q),t.lineTo(p+I+E,q)}else{const w=h+g,p=d+v;for(let _=g;_<=w;_+=y)t.moveTo(_,v),t.lineTo(_,d+v);for(let _=v;_<=p;_+=y)t.moveTo(g,_),t.lineTo(h+g,_)}t.stroke(),t.restore()}}const Dk={success:{},info:{icon:'<svg fill="none" viewBox="0 0 24 24"><path fill="#0052d9" d="M12 23a11 11 0 100-22 11 11 0 000 22zM11 8.5v-2h2v2h-2zm2 1.5v7.5h-2V10h2z"></path></svg>'},warning:{},error:{}};class Mk{constructor(t,i){W(this,"parentElement");W(this,"store");W(this,"box");W(this,"text");W(this,"arrowUp");W(this,"arrowDown");W(this,"icon");W(this,"confirm");W(this,"cancel");W(this,"x");W(this,"y");this.parentElement=t,this.store=i,this.box=document.createElement("div"),this.text=document.createElement("div"),this.arrowUp=document.createElement("div"),this.arrowDown=document.createElement("div"),this.icon=document.createElement("div"),this.confirm=document.createElement("button"),this.cancel=document.createElement("button"),this.box.className="meta2d-popconfirm",this.text.className="text",this.arrowUp.className="arrow",this.arrowDown.className="arrow down",this.icon.className="icon",this.confirm.className="confirm",this.cancel.className="cancel",this.confirm.innerHTML="\u786E\u5B9A",this.cancel.innerHTML="\u53D6\u6D88",this.icon.innerHTML=Dk.info.icon,this.box.appendChild(this.text),this.box.appendChild(this.arrowUp),this.box.appendChild(this.arrowDown),this.box.appendChild(this.confirm),this.box.appendChild(this.cancel),this.box.appendChild(this.icon),t.appendChild(this.box);let n;for(let r=0;r<document.styleSheets.length;r++)document.styleSheets[r].title==="le5le.com/popconfirm"&&(n=document.styleSheets[r]);if(!n){let r=document.createElement("style");r.type="text/css",r.title="le5le.com/popconfirm",document.head.appendChild(r),r=document.createElement("style"),r.type="text/css",document.head.appendChild(r),n=r.sheet,n.insertRule(".meta2d-popconfirm{position:absolute;z-index:999;left: -9999px;top: -9999px;padding:16px;max-width:400px;background:#fff;border-radius:6px;box-shadow:0 3px 14px 2px rgba(0, 0, 0, .05),0 8px 10px 1px rgba(0, 0, 0, 6%),0 5px 5px -3px rgba(0, 0, 0, 10%);}"),n.insertRule(".meta2d-popconfirm .text{outline:none;padding:0px 0px 40px 28px;border-radius:4px;color:rgba(0, 0, 0, 0.9);overflow-y:auto;line-height:22px;font-size:13px;}"),n.insertRule(".meta2d-popconfirm .arrow{position:absolute;border:10px solid transparent;background:transparent;top:-18px;left:50%;transform:translateX(-50%)}"),n.insertRule(".meta2d-popconfirm .arrow.down{top:initial;bottom: -18px;}"),n.insertRule(".meta2d-popconfirm .icon{position:absolute;width:22px;height:22px;left:16px;top:16px;}"),n.insertRule(".meta2d-popconfirm .confirm{position:absolute;right:16px;bottom:16px;width:40px;height:24px;text-align:center;background:#4582e6;color:#fff;border-radius:3px;border-color:transparent}"),n.insertRule(".meta2d-popconfirm .confirm:hover{background:#003cab;}"),n.insertRule(".meta2d-popconfirm .cancel{position:absolute;right:64px;bottom:16px;width:40px;height:24px;text-align:center;background:#dcdcdc;color:rgba(0, 0, 0, 0.9);border-radius:3px;border-color:transparent}"),n.insertRule(".meta2d-popconfirm .cancel:hover{background:#a6a6a6;}")}}show(t,i){if(!t)return;const n=this.box.getBoundingClientRect(),r=t.calculative.worldRect;let s=t.calculative.canvas.store.data.x+i.x-n.width/2,a=t.calculative.canvas.store.data.y+i.y-n.height-20;t.type||(s=t.calculative.canvas.store.data.x+r.x-(n.width-r.width)/2,a=t.calculative.canvas.store.data.y+r.ey-n.height-r.height),a>0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#fff",a-=10):(a+=n.height+r.height+5,a+=10,this.arrowUp.style.borderBottomColor="#fff",this.arrowDown.style.borderTopColor="transparent"),this.x=s,this.y=a,this.box.style.left=this.x+"px",this.box.style.top=this.y+"px"}hide(){this.x=-9999,this.box.style.left="-9999px"}showModal(t,i,n){return new Promise(r=>{this.text.innerHTML=n||"\u786E\u8BA4\u6267\u884C\u64CD\u4F5C\u5417\uFF1F",this.show(t,i),this.confirm.onclick=()=>{r(!0),this.hide()},this.cancel.onclick=()=>{r(!1),this.hide()}})}destroy(){this.box=null}}const Fe="-moving";class sd{constructor(t,i,n){W(this,"parent");W(this,"parentElement");W(this,"store");W(this,"canvas",document.createElement("canvas"));W(this,"offscreen",Ii());W(this,"width");W(this,"height");W(this,"externalElements",document.createElement("div"));W(this,"clientRect");W(this,"canvasRect");W(this,"activeRect");W(this,"initActiveRect");W(this,"dragRect");W(this,"lastRotate",0);W(this,"sizeCPs");W(this,"activeInitPos");W(this,"hoverType",xt.None);W(this,"resizeIndex",0);W(this,"mouseDown");W(this,"hotkeyType");W(this,"mouseRight");W(this,"addCaches");W(this,"touchCenter");W(this,"initTouchDis");W(this,"initScale");W(this,"touchScaling");W(this,"touchMoving");W(this,"startTouches");W(this,"lastOffsetX",0);W(this,"lastOffsetY",0);W(this,"drawingLineName");W(this,"drawLineFns",[...o_]);W(this,"drawingLine");W(this,"pencil");W(this,"pencilLine");W(this,"movingPens");W(this,"patchFlagsLines",new Set);W(this,"dock");W(this,"prevAnchor");W(this,"nextAnchor");W(this,"lastMouseTime",0);W(this,"hoverTimer",0);W(this,"fitTimer",0);W(this,"willInactivePen");W(this,"patchFlags",!1);W(this,"lastRender",0);W(this,"touchStart",0);W(this,"touchStartTimer");W(this,"timer");W(this,"lastAnimateRender",0);W(this,"animateRendering",!1);W(this,"renderTimer");W(this,"initPens");W(this,"pointSize",8);W(this,"pasteOffset",!0);W(this,"opening",!1);W(this,"maxZindex",5);W(this,"canMoveLine",!1);W(this,"randomIdObj");W(this,"keyOptions");W(this,"beforeAddPen");W(this,"beforeAddPens");W(this,"beforeAddAnchor");W(this,"beforeRemovePens");W(this,"beforeRemoveAnchor");W(this,"customResizeDock");W(this,"customMoveDock");W(this,"inputParent",document.createElement("div"));W(this,"inputDiv",document.createElement("div"));W(this,"dropdown",document.createElement("ul"));W(this,"tooltip");W(this,"popconfirm");W(this,"title");W(this,"mousePos",{x:0,y:0});W(this,"scroll");W(this,"movingAnchor");W(this,"canvasTemplate");W(this,"canvasImage");W(this,"canvasImageBottom");W(this,"magnifierCanvas");W(this,"dialog");W(this,"autoPolylineFlag",!1);W(this,"stopPropagation",t=>{t.stopPropagation()});W(this,"curve",ik);W(this,"polyline",hk);W(this,"mind",rk);W(this,"line",ak);W(this,"onCopy",t=>{this.store.options.disableClipboard||t.target!==this.externalElements&&t.target!==document.body&&t.target.offsetParent!==this.externalElements||this.copy()});W(this,"onCut",t=>{this.store.options.disableClipboard||t.target!==this.externalElements&&t.target!==document.body&&t.target.offsetParent!==this.externalElements||this.cut()});W(this,"onPaste",t=>{if(this.store.data.locked||this.store.options.disableClipboard||t.target!==this.externalElements&&t.target!==document.body&&t.target.offsetParent!==this.externalElements)return;let i;if(navigator.clipboard&&t.clipboardData){const n=t.clipboardData.items;if(n){for(let r=0;r<n.length;r++)if(n[r].type.indexOf("image")!==-1&&n[r].getAsFile()){i=!0;break}}}if(i){const n=t.clipboardData.items;if(n){for(let r=0;r<n.length;r++)if(n[r].type.indexOf("image")!==-1&&n[r].getAsFile()){const{x:s,y:a}=this.mousePos,l=n[r].getAsFile();let c=n[r].type.slice(6)==="gif"?"gif":"image";if(l!==null){let u;const h=new FileReader;h.onload=d=>{u=d.target.result;const g=new Image;g.src=u,g.onload=()=>{const{width:v,height:y}=g,w={name:c,x:s-50/2,y:a-y/v*50,externElement:c==="gif",width:100,height:y/v*100,image:u};this.addPens([w]),this.active([w]),this.copy([w])}},h.readAsDataURL(l)}}}}else this.paste()});W(this,"onMessage",t=>{if(typeof t.data!="string"||!t.data||t.data.startsWith("setImmediate"))return;let i=JSON.parse(t.data);typeof i=="object"?this.parent.doMessageEvent(i.name,i.value):this.parent.doMessageEvent(i)});W(this,"onwheel",t=>{if(this.inputDiv.contentEditable==="true"||this.drawingLine||this.pencil)return;if(this.store.hover&&this.store.hover.onWheel){this.store.hover.onWheel(this.store.hover,t);return}if(this.store.data.disableScale||this.store.options.disableScale||(t.preventDefault(),t.stopPropagation(),this.mouseDown&&(this.hoverType===xt.Node||this.hoverType===xt.Line))||this.store.data.locked===Ot.Disable||this.store.data.locked===Ot.DisableScale||this.store.data.locked===Ot.DisableMoveScale)return;if(!t.ctrlKey&&Math.abs(t.wheelDelta)<100&&t.deltaY.toString().indexOf(".")===-1){if(this.store.options.scroll&&!t.metaKey&&this.scroll){this.scroll.wheel(t.deltaY<0);return}const s=this.store.data.scale||1;this.translate(-t.deltaX/s,-t.deltaY/s);return}if(Math.abs(t.wheelDelta)>100&&this.store.options.scroll&&this.scroll&&!this.store.options.scrollButScale&&!(t.ctrlKey||t.metaKey)){this.scroll.wheel(t.deltaY<0);return}if(this.store.options.disableTouchPadScale)return;let i=.015;if(this.store.options.scaleOff)i=this.store.options.scaleOff,t.deltaY>0&&(i=-this.store.options.scaleOff);else if(/mac os /i.test(navigator.userAgent))t.ctrlKey?t.deltaY>0&&(i*=-1):i*=t.wheelDeltaY/240;else{let a=.2;t.deltaY.toString().indexOf(".")!==-1&&(a=.01),t.deltaY>0?i=-a:i=a}let{offsetX:n,offsetY:r}=t;this.scale(this.store.data.scale+i,{x:n,y:r}),this.externalElements.focus()});W(this,"onkeydown",t=>{var s,a,l;if(this.store.data.locked>=Ot.DisableEdit&&t.target.tagName!=="INPUT"&&t.target.tagName!=="TEXTAREA"&&!t.target.dataset.meta2dIgnore&&this.store.active.forEach(c=>{var u;(u=c.onKeyDown)==null||u.call(c,c,t.key)}),this.store.data.locked>=Ot.DisableEdit||t.target.tagName==="INPUT"||t.target.tagName==="TEXTAREA"||t.target.dataset.meta2dIgnore||this.store.options.unavailableKeys.includes(t.key))return;this.keyOptions||(this.keyOptions={}),this.keyOptions.altKey=t.altKey,this.keyOptions.shiftKey=t.shiftKey,this.keyOptions.ctrlKey=t.ctrlKey,this.keyOptions.metaKey=t.metaKey;let i=10,n=10,r=null;if(this.store.options.strictScope){const c=this.store.data.width||this.store.options.width,u=this.store.data.height||this.store.options.height;c&&u&&(r={x:this.store.data.origin.x,y:this.store.data.origin.y,width:c*this.store.data.scale,height:u*this.store.data.scale})}switch(t.key){case" ":this.hotkeyType=Kt.Translate;break;case"Control":this.drawingLine?this.drawingLine.calculative.drawlineH=!this.drawingLine.calculative.drawlineH:this.hotkeyType||(this.patchFlags=!0,this.hotkeyType=Kt.Select);break;case"Meta":break;case"Shift":this.store.active.length===1&&this.store.active[0].type&&this.store.activeAnchor?this.toggleAnchorHand():this.hotkeyType||(this.patchFlags=!0,this.store.options.resizeMode||(this.hotkeyType=Kt.Resize));break;case"Alt":if(!t.ctrlKey&&!t.shiftKey&&this.drawingLine){const c=qt(this.drawingLine);c!==this.drawingLine.calculative.activeAnchor?(zc(this.drawingLine),this.drawingLine.calculative.worldAnchors.push(c)):this.drawingLine.calculative.worldAnchors.push({x:c.x,y:c.y});const u=this.drawLineFns.indexOf(this.drawingLineName);this.drawingLineName=this.drawLineFns[(u+1)%this.drawLineFns.length],this.drawingLine.lineName=this.drawingLineName,this.drawline(),this.patchFlags=!0}t.preventDefault();break;case"a":case"A":t.ctrlKey||t.metaKey?(this.active(this.store.data.pens.filter(c=>!c.parentId&&c.locked!==Ot.Disable)),t.preventDefault()):this.toggleAnchorMode();break;case"Delete":case"Backspace":if(this.canvasImage.fitFlag&&this.canvasImage.activeFit){this.deleteFit();break}!this.store.data.locked&&this.delete();break;case"ArrowLeft":if(this.movingAnchor){this.translateAnchor(-1,0);break}if(i=-1,t.shiftKey&&(i=-5),(t.ctrlKey||t.metaKey)&&(i=-10),i=i*this.store.data.scale,this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){this.moveLineAnchor({x:this.store.activeAnchor.x+i,y:this.store.activeAnchor.y},{});break}r&&this.activeRect.x+i<r.x&&(i=r.x-this.activeRect.x),this.translatePens(this.store.active,i,0);break;case"ArrowUp":if(this.movingAnchor){this.translateAnchor(0,-1);break}if(n=-1,t.shiftKey&&(n=-5),(t.ctrlKey||t.metaKey)&&(n=-10),n=n*this.store.data.scale,r&&this.activeRect.y+n<r.y&&(n=r.y-this.activeRect.y),this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){this.moveLineAnchor({x:this.store.activeAnchor.x,y:this.store.activeAnchor.y+n},{});break}this.translatePens(this.store.active,0,n);break;case"ArrowRight":if(this.movingAnchor){this.translateAnchor(1,0);break}if(i=1,t.shiftKey&&(i=5),(t.ctrlKey||t.metaKey)&&(i=10),i=i*this.store.data.scale,this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){this.moveLineAnchor({x:this.store.activeAnchor.x+i,y:this.store.activeAnchor.y},{});break}r&&this.activeRect.x+this.activeRect.width+i>r.x+r.width&&(i=r.x+r.width-(this.activeRect.x+this.activeRect.width)),this.translatePens(this.store.active,i,0);break;case"ArrowDown":if(this.movingAnchor){this.translateAnchor(0,1);break}if(n=1,t.shiftKey&&(n=5),(t.ctrlKey||t.metaKey)&&(n=10),n=n*this.store.data.scale,r&&this.activeRect.y+this.activeRect.height+n>r.y+r.height&&(n=r.y+r.height-(this.activeRect.y+this.activeRect.height)),this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){this.moveLineAnchor({x:this.store.activeAnchor.x,y:this.store.activeAnchor.y+n},{});break}this.translatePens(this.store.active,0,n);break;case"d":case"D":(s=this.store.active[0])!=null&&s.locked||this.removeAnchorHand();break;case"h":case"H":(a=this.store.active[0])!=null&&a.locked||this.addAnchorHand();break;case"m":case"M":this.toggleMagnifier();break;case"g":case"G":this.hoverType===xt.NodeAnchor&&(this.movingAnchor=this.store.hoverAnchor,this.externalElements.style.cursor="move");break;case"s":case"S":!this.store.data.locked&&this.hoverType===xt.LineAnchor&&this.store.hover===this.store.active[0]&&this.splitLine(this.store.active[0],this.store.hoverAnchor),(t.ctrlKey||t.metaKey)&&this.store.emitter.emit("save",{event:t});break;case"c":case"C":(t.ctrlKey||t.metaKey)&&this.store.options.disableClipboard&&this.copy();break;case"x":case"X":(t.ctrlKey||t.metaKey)&&this.store.options.disableClipboard&&this.cut();break;case"\u221A":case"v":case"V":!t.ctrlKey&&!t.metaKey&&(this.pencil&&this.stopPencil(),this.drawingLineName?(this.finishDrawline(),this.drawingLineName=""):this.drawingLineName=this.store.options.drawingLineName),!this.store.data.locked&&(t.ctrlKey||t.metaKey)&&(this.store.options.disableClipboard||!this.store.options.disableClipboard&&t.altKey)&&this.paste();break;case"b":case"B":this.drawingLineName&&(this.finishDrawline(),this.drawingLineName=""),this.pencil?this.stopPencil():this.drawingPencil();break;case"y":case"Y":(t.ctrlKey||t.metaKey)&&this.redo();break;case"z":case"Z":t.ctrlKey||t.metaKey?this.undo():t.shiftKey&&this.redo();break;case"Enter":this.drawingLineName&&(this.finishDrawline(!0),this.store.active[0].anchors[0].connectTo?this.drawingLineName="":this.drawingLineName=this.store.options.drawingLineName),this.store.active&&(this.store.active.forEach(c=>{c.type?(c.close=!c.close,c.close&&Xv(c),this.store.path2dMap.set(c,At.path2dDraws.line(c)),xc(c)):c.calculative.focus=!0}),this.render());break;case"Escape":this.drawingLineName&&this.finishDrawline(),this.drawingLineName=void 0,this.stopPencil(),this.store.active&&this.store.active.forEach(c=>{c.type||(c.calculative.focus=!1)}),this.movingPens&&(this.getAllByPens(this.movingPens).forEach(c=>{this.store.pens[c.id]=void 0}),this.movingPens=void 0,this.mouseDown=void 0,this.clearDock(),(l=this.store.active)==null||l.forEach(c=>{this.updateLines(c)}),this.calcActiveRect(),this.patchFlags=!0),this.hotkeyType=Kt.None,this.movingAnchor=void 0,this.magnifierCanvas.magnifier&&(this.magnifierCanvas.magnifier=!1,this.patchFlags=!0);break;case"E":case"e":this.store.options.disableAnchor=!this.store.options.disableAnchor,this.store.emitter.emit("disableAnchor",this.store.options.disableAnchor);break;case"=":(t.ctrlKey||t.metaKey)&&(this.scale(this.store.data.scale+.1),t.preventDefault(),t.stopPropagation());break;case"-":(t.ctrlKey||t.metaKey)&&(this.scale(this.store.data.scale-.1),t.preventDefault(),t.stopPropagation());break;case"l":case"L":this.canMoveLine=!0;break;case"[":this.parent.down();break;case"]":this.parent.up();break;case"{":this.parent.bottom();break;case"}":this.parent.top();break;case"F":case"f":this.setFollowers();break}this.render(!1)});W(this,"onkeyup",t=>{switch(t.key){case"l":case"L":this.canMoveLine=!1;break}this.hotkeyType&&this.render(),this.hotkeyType<Kt.AddAnchor&&(this.hotkeyType=Kt.None)});W(this,"ondrop",async t=>{if(this.store.data.locked){console.warn("canvas is locked, can not drop");return}t.preventDefault(),t.stopPropagation();const i=t.dataTransfer.getData("Meta2d")||t.dataTransfer.getData("Text");let n=null;try{i&&(n=JSON.parse(i))}catch{}if(!n){const{files:r}=t.dataTransfer;if(r.length&&r[0].type.match("image.*")&&!(this.addCaches&&this.addCaches.length)){const s=r[0].type==="image/gif";n=await this.fileToPen(r[0],s)}else if(this.addCaches&&this.addCaches.length)n=this.addCaches,this.addCaches=[];else{this.store.emitter.emit("drop",void 0);return}}if(n=Array.isArray(n)?n:[n],n[0]&&n[0].draggable!==!1){const r={x:t.offsetX,y:t.offsetY};this.calibrateMouse(r),this.dropPens(n,r),this.addCaches=[],this.getContainerHover(r),this.mousePos.x=r.x,this.mousePos.y=r.y,this.store.emitter.emit("mouseup",{x:r.x,y:r.y,pen:this.store.hoverContainer})}this.store.emitter.emit("drop",n||i)});W(this,"ontouchstart",t=>{this.store.data.locked!==Ot.Disable&&(this.touchStartTimer&&clearTimeout(this.touchStartTimer),this.touchStartTimer=setTimeout(()=>{this.touchStart=performance.now();const i=t.touches[0].pageX-this.clientRect.x,n=t.touches[0].pageY-this.clientRect.y,r={x:i,y:n};if(this.calibrateMouse(r),this.getHover(r),this.onMouseDown({x:i,y:n,clientX:t.touches[0].clientX,clientY:t.touches[0].clientY,pageX:t.touches[0].pageX,pageY:t.touches[0].pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:1}),t.touches.length===2){this.initTouchDis=Math.hypot(t.touches[0].pageX-t.touches[1].pageX,t.touches[0].pageY-t.touches[1].pageY),this.initScale=this.store.data.scale,this.startTouches=t.touches,this.touchCenter={x:t.touches[0].pageX+(t.touches[1].pageX-t.touches[0].pageX)/2-this.clientRect.x,y:t.touches[0].pageY+(t.touches[1].pageY-t.touches[0].pageY)/2-this.clientRect.y};return}else t.touches.length===3&&(this.store.emitter.emit("contextmenu",{e:{x:i,y:n,clientX:t.touches[0].clientX,clientY:t.touches[0].clientY,pageX:t.touches[0].pageX,pageY:t.touches[0].pageY},clientRect:this.clientRect}),t.preventDefault(),t.stopPropagation());this.touchStartTimer=void 0},50))});W(this,"ontouchmove",t=>{var l;if(this.store.data.locked===Ot.Disable)return;t.stopPropagation(),t.preventDefault();const i=performance.now();if(i-this.touchStart<50)return;this.touchStart=i;const n=t.touches,r=n.length,s=t.touches[0].pageX-this.clientRect.x,a=t.touches[0].pageY-this.clientRect.y;if(r===1)this.onMouseMove({x:s,y:a,clientX:t.changedTouches[0].clientX,clientY:t.changedTouches[0].clientY,pageX:t.changedTouches[0].pageX,pageY:t.changedTouches[0].pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:1});else if(r===2&&((l=this.startTouches)==null?void 0:l.length)===2){if(!this.touchMoving&&!this.touchScaling){const c=this.startTouches[0].pageX-n[0].pageX,u=this.startTouches[1].pageX-n[1].pageX,h=this.startTouches[0].pageY-n[0].pageY,d=this.startTouches[1].pageY-n[1].pageY;(c>=0&&u<0||c<=0&&u>0)&&(h>=0&&d<0||h<=0&&d>0)?this.touchScaling=!0:this.touchMoving=!0}if(this.touchScaling){if(this.store.data.disableScale||this.store.options.disableScale)return;const c=Math.hypot(n[0].pageX-n[1].pageX,n[0].pageY-n[1].pageY)/this.initTouchDis;this.scale(this.initScale*c,ct(this.touchCenter))}if(this.touchMoving){if(this.store.data.locked>=Ot.DisableMove&&this.store.data.locked!==Ot.DisableScale||this.store.data.disableScale||this.store.options.disableScale)return;if(this.lastOffsetX){const{scale:c}=this.store.data;this.translate((s-this.lastOffsetX)/c,(a-this.lastOffsetY)/c)}this.lastOffsetX=s,this.lastOffsetY=a}}});W(this,"ontouchend",t=>{if(this.store.data.locked===Ot.Disable)return;this.touchCenter=void 0,this.touchScaling=void 0,this.touchMoving=void 0,this.startTouches=void 0,this.lastOffsetX=0,this.lastOffsetY=0;const i=t.changedTouches[0].pageX-this.clientRect.x,n=t.changedTouches[0].pageY-this.clientRect.y;this.onMouseUp({x:i,y:n,clientX:t.changedTouches[0].clientX,clientY:t.changedTouches[0].clientY,pageX:t.changedTouches[0].pageX,pageY:t.changedTouches[0].pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:1}),setTimeout(()=>{this.render()},20)});W(this,"onGesturestart",t=>{t.preventDefault()});W(this,"onMouseDown",t=>{var i,n,r,s,a;if(t.buttons===2&&!this.drawingLine&&(this.mouseRight=$i.Down),this.hideInput(),this.popconfirm.hide(),this.store.data.locked===Ot.Disable||t.buttons!==1&&t.buttons!==2){this.hoverType=xt.None;return}if(!this.magnifierCanvas.magnifier){if(this.calibrateMouse(t),this.mousePos.x=t.x,this.mousePos.y=t.y,this.mouseDown=t,this.lastMouseTime=performance.now(),this.canvasImage.fitFlag){this.canvasImage.currentFit||this.calcuActiveFit();return}if(this.hotkeyType===Kt.AddAnchor){this.setAnchor(this.store.pointAt);return}if(!this.store.options.autoAnchor&&!this.drawingLine&&t.shiftKey&&t.ctrlKey&&t.altKey){this.setAnchor(this.store.pointAt),this.drawingLineName=this.store.options.drawingLineName;const l=this.store.activeAnchor;if(!l)return;const c={id:It(),x:l.x,y:l.y};this.drawingLine=this.createDrawingLine(c);let u=le(this.drawingLine);this.drawingLine.calculative.activeAnchor=u,we(this.store.hover,l,this.drawingLine,c),this.drawline();return}if(!(this.hotkeyType===Kt.Translate||this.mouseRight===$i.Down&&!this.store.options.mouseRightActive)){if(this.drawingLine){if(this.store.hoverAnchor){const c=qt(this.drawingLine);this.store.hoverAnchor.type===Ki.Line?wa(c,this.store.hoverAnchor,this.store):(c.x=this.store.hoverAnchor.x,c.y=this.store.hoverAnchor.y),we(this.store.hover,this.store.hoverAnchor,this.drawingLine,c),this.drawline(),this.finishDrawline(!0);return}if(!this.store.options.autoAnchor&&t.shiftKey&&t.altKey&&t.ctrlKey){this.setAnchor(this.store.pointAt);const c=qt(this.drawingLine),u=this.store.activeAnchor;if(!u)return;c.x=u.x,c.y=u.y,we(this.store.hover,u,this.drawingLine,c),this.drawline(),this.finishDrawline(!0);return}if(t.buttons===2||this.drawingLineName==="mind"&&((i=this.drawingLine)==null?void 0:i.calculative.worldAnchors.length)>1||this.store.options.drawingLineLength&&((n=this.drawingLine)==null?void 0:n.calculative.worldAnchors.length)>this.store.options.drawingLineLength){this.finishDrawline(!0),((r=this.store.active[0])==null?void 0:r.anchors[0].connectTo)||this.store.active.length==0?this.drawingLineName="":this.drawingLineName=this.store.options.drawingLineName;return}if(this.store.options.autoAnchor&&this.hoverType===xt.Node){const c=qt(this.drawingLine),u=Cr(this.store.hover,t);c.x=u.x,c.y=u.y,this.drawingLine.autoTo=!0,we(this.store.hover,u,this.drawingLine,c),this.drawline(),this.finishDrawline(!0);return}const l=qt(this.drawingLine);l.isTemp?(this.drawingLine.calculative.activeAnchor=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2],l.isTemp=void 0):(this.drawingLine.calculative.activeAnchor=l,this.drawingLine.calculative.worldAnchors.push({x:l.x,y:l.y,penId:l.penId})),this.drawingLine.calculative.drawlineH=void 0,this.drawingLineName!=="polyline"&&this.drawline()}if(this.drawingLineName){if(this.hoverType===xt.Node)if(this.store.options.autoAnchor){this.inactive(!0);const l=Cr(this.store.hover,t);this.store.hoverAnchor=l;const c={id:It(),x:l.x,y:l.y};this.drawingLine=this.createDrawingLine(c),this.drawingLine.autoFrom=!0,we(this.store.hover,l,this.drawingLine,c)}else this.inactive(),this.hoverType=xt.None;else if(this.hoverType===xt.NodeAnchor){this.drawingLineName=this.store.options.drawingLineName;const l={id:It(),x:this.store.hoverAnchor.x,y:this.store.hoverAnchor.y};this.drawingLine=this.createDrawingLine(l),this.drawingLine.calculative.activeAnchor=l,we(this.store.hover,this.store.hoverAnchor,this.drawingLine,l)}else if(!this.drawingLine&&this.drawingLineName!=="curve"){this.inactive(!0);const l={id:It(),x:t.x,y:t.y};this.drawingLine=this.createDrawingLine(l),this.drawingLine.calculative.activeAnchor=l}}else if(this.pencil){this.inactive(!0);const l=It(),c={x:t.x,y:t.y,id:It(),penId:l};this.pencilLine=this.getInitPencilLine(c)}else{switch(this.hoverType){case xt.None:(this.store.data.rule||this.store.options.rule)&&!this.store.options.disableRuleLine&&this.addRuleLine(t),this.store.options.resizeMode&&(this.hotkeyType=Kt.None),this.inactive();break;case xt.Node:case xt.Line:if(this.store.hover){if(((s=this.store.active)==null?void 0:s.length)&&this.store.active.length===1&&this.store.hover.id===this.store.active[0].id){this.calcActiveRect();break}const l=Ze(this.store.hover,!0);let c=l||this.store.hover;l&&(l.container||((a=this.store.options.containerShapes)==null?void 0:a.includes(l.name)))&&(c=this.store.hover),t.ctrlKey&&!t.shiftKey?(c.calculative.active?this.willInactivePen=c:this.store.active.length>0&&(c.calculative.active=!0,Rr(c),this.store.active.push(c),this.store.emitter.emit("active",this.store.active)),this.patchFlags=!0):t.ctrlKey&&t.shiftKey&&this.store.hover.parentId?this.active([this.store.hover]):(!(this.activeRect&&yn({x:t.x,y:t.y},this.activeRect))||this.store.active.length==1)&&(c.calculative.active||(this.active([c]),this.store.options.resizeMode&&(this.hotkeyType=Kt.Resize))),this.calcActiveRect()}break;case xt.LineAnchor:this.store.activeAnchor=this.store.hoverAnchor,this.store.hover.calculative.activeAnchor=this.store.hoverAnchor,this.active([this.store.hover]);break;case xt.LineAnchorPrev:case xt.LineAnchorNext:this.store.activeAnchor&&(this.prevAnchor={...this.store.activeAnchor.prev},this.nextAnchor={...this.store.activeAnchor.next});break;case xt.Resize:this.activeInitPos=[],this.store.active.forEach(l=>{this.activeInitPos.push({x:(l.calculative.worldRect.x-this.activeRect.x)/this.activeRect.width,y:(l.calculative.worldRect.y-this.activeRect.y)/this.activeRect.height})});break}this.store.hover&&(this.store.hover.calculative.mouseDown=!0),this.store.emitter.emit("mousedown",{x:t.x,y:t.y,pen:this.store.hover})}this.render()}}});W(this,"onMouseMove",t=>{var n,r,s,a,l,c,u,h;if(this.store.data.locked===Ot.Disable){this.hoverType=xt.None;return}if(this.mouseDown&&!this.mouseDown.restore&&t.buttons!==1&&t.buttons!==2){this.onMouseUp(t);return}if(this.lastMouseTime){if(performance.now()-this.lastMouseTime<50){this.lastMouseTime=0;return}this.lastMouseTime=0}if(this.calibrateMouse(t),this.mousePos.x=t.x,this.mousePos.y=t.y,this.magnifierCanvas.magnifier){this.render();return}if(this.canvasImage.fitFlag&&this.canvasImage.activeFit){const d=performance.now();d-this.fitTimer>100&&(this.mouseDown?this.updateFit(t):this.inFitBorder(this.mousePos),this.fitTimer=d);return}if(this.mouseDown&&!this.store.options.disableTranslate&&!this.store.data.disableTranslate){if(this.mouseRight===$i.Down&&(this.mouseRight=$i.Translate),this.store.data.locked===Ot.DisableEdit||this.store.data.locked===Ot.DisableScale||this.hotkeyType===Kt.Translate||this.mouseRight===$i.Translate){const{scale:d}=this.store.data;let g=(t.x-this.mouseDown.x)/d,v=(t.y-this.mouseDown.y)/d;t.shiftKey&&!t.ctrlKey&&(v=0),t.ctrlKey&&(g=0),this.translate(g,v);return}if(this.store.data.locked)return;if(!this.drawingLine&&!this.pencil){if(!this.drawingLineName&&!this.movingAnchor){if(this.hoverType===xt.NodeAnchor){if(!this.store.hoverAnchor)return;this.drawingLineName=this.store.options.drawingLineName;const d={id:It(),x:this.store.hoverAnchor.x,y:this.store.hoverAnchor.y};this.drawingLine=this.createDrawingLine(d),this.drawingLine.calculative.activeAnchor=d,we(this.store.hover,this.store.hoverAnchor,this.drawingLine,d),this.drawline();return}}else if(this.drawingLineName&&this.hoverType===xt.None){const d={id:It(),x:t.x,y:t.y};this.drawingLine=this.createDrawingLine(d),this.drawingLine.calculative.activeAnchor=d,this.drawline();return}if(t.buttons===1&&(t.ctrlKey||!this.hoverType&&!this.hotkeyType)&&!(t.ctrlKey&&(this.store.activeAnchor||((n=this.store.active)==null?void 0:n.length)))){this.dragRect={x:Math.min(this.mouseDown.x,t.x),y:Math.min(this.mouseDown.y,t.y),ex:Math.max(this.mouseDown.x,t.x),ey:Math.max(this.mouseDown.y,t.y),width:Math.abs(t.x-this.mouseDown.x),height:Math.abs(t.y-this.mouseDown.y)},this.render();return}if(this.movingAnchor){const d=t.x-this.movingAnchor.x,g=t.y-this.movingAnchor.y;this.translateAnchor(d,g),this.render();return}else if(!((r=this.store.active[0])!=null&&r.locked)){const d={x:t.x,y:t.y};if(this.hoverType===xt.LineAnchor){(this.dockInAnchor(t)||((s=this.store.active[0])==null?void 0:s.lineName)==="line")&&!this.store.options.disableDock&&!this.store.options.disableLineDock&&(this.clearDock(),this.dock=$f(this.store,d,this.store.activeAnchor),(a=this.dock)!=null&&a.xDock&&(d.x+=this.dock.xDock.step),(l=this.dock)!=null&&l.yDock&&(d.y+=this.dock.yDock.step)),this.moveLineAnchor(d,t);return}if(this.hoverType===xt.LineAnchorPrev){this.moveLineAnchorPrev(t);return}if(this.hoverType===xt.LineAnchorNext){this.moveLineAnchorNext(t);return}}if(this.hoverType===xt.Rotate){this.rotatePens({x:t.x,y:t.y});return}if(this.hoverType===xt.Resize){this.resizePens(t);return}if(this.hoverType===xt.Node||this.hoverType===xt.Line){const d=t.x-this.mouseDown.x,g=t.y-this.mouseDown.y,v=20;if(t.ctrlKey&&!t.shiftKey&&(Math.abs(d)>=v||Math.abs(g)>=v)&&(this.willInactivePen=void 0),this.store.active.length===1){const y=this.store.active[0];if((y.locked===void 0||y.locked<Ot.DisableMove)&&((c=y==null?void 0:y.onMouseMove)==null||c.call(y,y,this.mousePos)),y.calculative.focus)return}this.movePens(t),this.getContainerHover(t);return}}else if(this.pencil){const{x:d,y:g}=t,v={x:d,y:g};v.id=It(),v.penId=this.pencilLine.id,this.pencilLine.calculative.worldAnchors.push(v),this.store.path2dMap.set(this.pencilLine,At.path2dDraws[this.pencilLine.name](this.pencilLine)),this.patchFlags=!0}}if(this.drawingLine){const{x:d,y:g}=t,v={x:d,y:g};if(v.id=It(),v.penId=this.drawingLine.id,!this.store.options.disableDock&&!this.store.options.disableLineDock&&(this.clearDock(),this.dock=$f(this.store,v),(u=this.dock)!=null&&u.xDock&&(v.x+=this.dock.xDock.step),(h=this.dock)!=null&&h.yDock&&(v.y+=this.dock.yDock.step)),this.mouseDown&&this.drawingLineName==="curve"&&!this.drawingLine.calculative.worldAnchors[0].connectTo)this.drawline(v);else{let y;if(this.drawingLine.calculative.worldAnchors.length>1&&(y=qt(this.drawingLine)),y?(y.prev=void 0,y.next=void 0,y.id||(y.id=It()),y.x=v.x,y.y=v.y,y.connectTo=void 0):(y={...v},this.drawingLine.calculative.worldAnchors.push(y)),(this.hoverType===xt.NodeAnchor||this.hoverType===xt.LineAnchor)&&(this.store.hoverAnchor.type!==Ki.Line&&(y.x=this.store.hoverAnchor.x,y.y=this.store.hoverAnchor.y),y.connectTo=this.store.hoverAnchor.penId,this.drawingLineName==="polyline"&&(y.isTemp=!1)),this.drawingLineName==="line"){if(t.ctrlKey&&!t.shiftKey)y.x=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2].x;else if(t.shiftKey&&!t.ctrlKey)y.y=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2].y;else if(t.shiftKey&&t.ctrlKey){let w=this.drawingLine.calculative.worldAnchors[this.drawingLine.calculative.worldAnchors.length-2];this.getSpecialAngle(y,w)}}this.drawline()}}globalThis.debug&&console.time("hover");const i=performance.now();i-this.hoverTimer>50&&(this.hoverTimer=i,this.getHover(t)),globalThis.debug&&console.timeEnd("hover"),this.hotkeyType===Kt.AddAnchor&&(this.patchFlags=!0),this.render(!1)});W(this,"onMouseUp",t=>{if(this.store.data.locked===Ot.Disable){this.hoverType=xt.None;return}if(!!this.mouseDown){if(this.mouseRight===$i.Down&&(this.store.hover&&this.store.hover.onContextmenu?this.store.hover.onContextmenu(this.store.hover,t):this.store.emitter.emit("contextmenu",{e:t,clientRect:this.clientRect,pen:this.store.hover})),this.mouseRight=$i.None,this.calibrateMouse(t),this.mousePos.x=t.x,this.mousePos.y=t.y,this.pencil&&this.finishPencil(),this.drawingLine){if(this.store.hoverAnchor){const i=qt(this.drawingLine);this.store.hoverAnchor.type===Ki.Line?wa(i,this.store.hoverAnchor,this.store):(i.x=this.store.hoverAnchor.x,i.y=this.store.hoverAnchor.y),we(this.store.hover,this.store.hoverAnchor,this.drawingLine,i),this.drawline(),this.finishDrawline(!0);return}if(this.store.options.autoAnchor&&this.hoverType===xt.Node){const i=qt(this.drawingLine),n=Cr(this.store.hover,t);i.x=n.x,i.y=n.y,this.drawingLine.autoTo=!0,we(this.store.hover,n,this.drawingLine,i),this.drawline(),this.finishDrawline(!0);return}}if(this.hoverType===xt.LineAnchor&&this.store.hover&&this.store.active[0]&&this.store.active[0].name==="line"&&this.store.active[0]!==this.store.hover){const i=this.store.active[0],n=le(i),r=qt(i);if(this.store.hoverAnchor){const s=this.store.hover,a=le(s)===this.store.hoverAnchor,l=qt(s)===this.store.hoverAnchor,c=n===this.store.activeAnchor,u=r===this.store.activeAnchor;if((t.ctrlKey||t.altKey)&&s.type===jt.Line&&(a||l)&&(c||u)){const h=s.calculative.worldAnchors.map(d=>({...d,penId:i.id}));a?h.shift():l&&h.pop(),(a&&c||l&&u)&&h.reverse(),c?(i.calculative.worldAnchors[0].connectTo=void 0,i.calculative.worldAnchors.unshift(...h)):u&&(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].connectTo=void 0,i.calculative.worldAnchors.push(...h)),this.delete([s]),this.render()}else this.store.activeAnchor&&(this.store.hoverAnchor.type===Ki.Line?wa(this.store.activeAnchor,this.store.hoverAnchor,this.store):(this.store.activeAnchor.x=this.store.hoverAnchor.x,this.store.activeAnchor.y=this.store.hoverAnchor.y),we(this.store.hover,this.store.hoverAnchor,i,this.store.activeAnchor));this[i.lineName]&&i.lineName!=="polyline"&&this[i.lineName](this.store,i),this.store.path2dMap.set(i,At.path2dDraws.line(i)),this.initLineRect(i)}else n===this.store.activeAnchor&&i.autoFrom?this.calcAutoAnchor(i,n,this.store.hover):r===this.store.activeAnchor&&i.autoTo&&this.calcAutoAnchor(i,r,this.store.hover)}if(this.addCaches&&this.addCaches.length){if(!this.store.data.locked){if(this.dragRect&&this.addCaches.length===1){const i=this.addCaches[0];i.width=this.dragRect.width/this.store.data.scale,i.height=this.dragRect.height/this.store.data.scale,t.x=(this.dragRect.x+this.dragRect.ex)/2,t.y=(this.dragRect.y+this.dragRect.ey)/2}this.dropPens(this.addCaches,t)}this.addCaches=void 0}if(this.hoverType===xt.Rotate&&(this.getSizeCPs(),this.store.active.forEach(i=>{i.rotate=i.calculative.rotate})),this.patchFlagsLines.forEach(i=>{i.type&&this.initLineRect(i)}),this.patchFlagsLines.clear(),this.dragRect)if(this.canvasImage.fitFlag)this.makeFit();else{const i=this.store.data.pens.filter(n=>{if(n.visible===!1||n.locked>=Ot.DisableMove||n.parentId||n.isRuleLine)return!1;if(Ji(n.calculative.worldRect,this.dragRect,t.ctrlKey||this.store.options.dragAllIn))return n.type===jt.Line&&!this.store.options.dragAllIn?Bl(n,this.dragRect):!0});this.active(i)}if(t.button!==2&&(Za(this.mouseDown,t)<2&&(this.store.hover&&this.store.hover.input&&this.showInput(this.store.hover),this.store.emitter.emit("click",{x:t.x,y:t.y,pen:this.store.hover})),this.store.hover&&(this.store.hover.calculative.mouseDown=!1),this.store.hover!=this.store.hoverContainer&&this.store.emitter.emit("mouseup",{x:t.x,y:t.y,pen:this.store.hover}),this.store.emitter.emit("mouseup",{x:t.x,y:t.y,pen:this.store.hoverContainer})),this.willInactivePen){this.willInactivePen.calculative.active=void 0,Rr(this.willInactivePen,!1);const i=this.store.active.findIndex(n=>n===this.willInactivePen);i>=0&&this.store.active.splice(i,1),this.calcActiveRect(),this.willInactivePen=void 0,this.store.emitter.emit("inactive",[this.willInactivePen]),this.render()}this.movingPens&&(t.altKey&&!t.shiftKey?this.copyMovedPens():this.movedActivePens(t.ctrlKey&&t.shiftKey),this.getAllByPens(this.movingPens).forEach(i=>{this.store.pens[i.id]=void 0}),this.movingPens=void 0),this.store.active&&this.store.active[0]&&(this.store.active[0].calculative.h=void 0),this.mouseDown=void 0,this.lastOffsetX=0,this.lastOffsetY=0,this.clearDock(),this.dragRect=void 0,this.initActiveRect=void 0,this.render()}});W(this,"clearDock",()=>{var s,a,l,c;const t=(a=(s=this.dock)==null?void 0:s.xDock)==null?void 0:a.penId,i=(c=(l=this.dock)==null?void 0:l.yDock)==null?void 0:c.penId,n=this.store.pens[t];n&&(n.calculative.isDock=!1);const r=this.store.pens[i];r&&(r.calculative.isDock=!1),this.dock=void 0});W(this,"onResize",()=>{this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.resize(),this.timer=void 0},100)});W(this,"onScroll",()=>{this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.clientRect=this.canvas.getBoundingClientRect(),this.timer=void 0},100)});W(this,"calibrateMouse",t=>(t.x-=this.store.data.x,t.y-=this.store.data.y,t));W(this,"getContainerHover",t=>{var n;if(this.dragRect)return;this.store.hoverContainer=void 0;const i=this.store.data.pens.filter(r=>{var s;return r.container||((s=this.store.options.containerShapes)==null?void 0:s.includes(r.name))});if(i.length)for(let r=i.length-1;r>=0;--r){const s=i[r];if(!(s.visible==!1||s.calculative.inView==!1||s.locked===Ot.Disable)){if(yn(t,s.calculative.worldRect))this.store.hoverContainer=s,(n=s==null?void 0:s.onMouseMove)==null||n.call(s,s,t),this.store.lastHoverContainer!==this.store.hoverContainer&&(this.patchFlags=!0,this.store.lastHoverContainer&&(this.store.lastHoverContainer.calculative.containerHover=!1,this.store.emitter.emit("leave",this.store.lastHoverContainer)),this.store.hoverContainer&&(this.store.hoverContainer.calculative.containerHover=!0,this.store.emitter.emit("enter",this.store.hoverContainer)),this.store.lastHoverContainer=this.store.hoverContainer);else if(s===this.store.hoverContainer&&(this.store.hoverContainer=void 0,this.store.lastHoverContainer!==this.store.hoverContainer)){this.patchFlags=!0;const a=this.store.lastHoverContainer.calculative.canvas.store.pens[this.store.lastHoverContainer.id+Fe];this.store.lastHoverContainer&&!a&&(this.store.lastHoverContainer.calculative.containerHover=!1,this.store.emitter.emit("leave",this.store.lastHoverContainer)),this.store.lastHoverContainer=this.store.hoverContainer}}}});W(this,"getHover",t=>{var r,s;if(this.dragRect||this.canvasImage.fitFlag)return;let i=xt.None;this.store.hover=void 0,this.store.hoverAnchor=void 0,this.title.hide(),this.store.pointAt=void 0,this.store.pointAtIndex=void 0;const n=this.store.active.length===1&&this.store.active[0].type;if(!this.drawingLineName&&this.hotkeyType!==Kt.AddAnchor&&this.activeRect&&!n&&!this.store.data.locked){const a=Ll(this.store.active),l=qf(this.store.active)||this.store.options.disableRotate,c=jf(this.store.active)||this.store.options.disableSize;if(!a&&!l){const u={x:this.activeRect.center.x,y:this.activeRect.y-30};this.activeRect.rotate&&Gt(u,this.activeRect.rotate,this.activeRect.pivot||this.activeRect.center),!this.hotkeyType&&Ar(t,u,this.pointSize)&&(i=xt.Rotate,this.externalElements.style.cursor=`url("${this.store.options.rotateCursor}"), auto`)}if(!a&&!c)for(let u=0;u<8;u++){const h=u<4;if((this.hotkeyType===Kt.Resize||h&&!this.hotkeyType)&&Ar(t,this.sizeCPs[u],this.pointSize)){let g=h?Df:Mf,v=0;Math.abs(this.activeRect.rotate%90-45)<25?(g=h?Mf:Df,v=Math.round((this.activeRect.rotate-45)/90)+(h?0:1)):v=Math.round(this.activeRect.rotate/90),i=xt.Resize,this.resizeIndex=u,this.externalElements.style.cursor=g[(u+v)%4];break}}}i===xt.None&&(i=this.inPens(t,this.store.data.pens)),!i&&!n&&yn(t,this.activeRect)&&(i=xt.Node,this.externalElements.style.cursor="move"),this.hoverType=i,i===xt.None&&(this.drawingLineName||this.pencil?this.externalElements.style.cursor="crosshair":this.mouseDown||(this.externalElements.style.cursor="default"),this.store.hover=void 0),this.store.lastHover!==this.store.hover&&(this.patchFlags=!0,this.store.lastHover&&(this.store.lastHover.calculative.hover=!1,rs(Ze(this.store.lastHover,!0)||this.store.lastHover,!1),this.store.emitter.emit("leave",this.store.lastHover),this.tooltip.hide()),this.store.hover&&(this.store.hover.calculative.hover=!0,rs(Ze(this.store.hover,!0)||this.store.hover),this.store.emitter.emit("enter",this.store.hover),this.tooltip.show(this.store.hover,t)),this.store.lastHover=this.store.hover),(s=(r=this.store.hover)==null?void 0:r.onMouseMove)==null||s.call(r,this.store.hover,this.mousePos)});W(this,"inPens",(t,i)=>{var r;let n=xt.None;t:for(let s=i.length-1;s>=0;--s){const a=i[s];if(a.visible==!1||a.calculative.inView==!1||a.locked===Ot.Disable)continue;const l=$a(a);if(!(!a.calculative.active&&!Kn(t,a.calculative.worldRect,l)&&!yn(t,a.calculative.worldRect))){if(!this.store.data.locked&&this.hotkeyType!==Kt.Resize&&a.calculative.worldAnchors){for(const c of a.calculative.worldAnchors)if(n=this.inAnchor(t,a,c),n){let u=ct(c);Object.assign(u,t),this.title.show(u,a);break t}}if(a.type){if(a.isRuleLine){let u=((r=this.store.options.ruleOptions)==null?void 0:r.height)||20;if(t.x+this.store.data.x>u&&t.y+this.store.data.y>u)break}const c=ok(t,a);if(c){!this.store.data.locked&&!a.locked?this.hotkeyType===Kt.AddAnchor?this.externalElements.style.cursor="pointer":this.externalElements.style.cursor="move":this.externalElements.style.cursor=this.store.options.hoverCursor,a.calculative.disabled&&(this.externalElements.style.cursor="not-allowed"),this.store.hover=a,this.store.pointAt=c.point,this.store.pointAtIndex=c.i,this.initTemplateCanvas([this.store.hover]),n=xt.Line;break}}else{if(a.children){const u=[];if(a.children.forEach(h=>{this.store.pens[h]&&u.push(this.store.pens[h])}),n=this.inPens(t,u),n)break}let c=!1;if(a.name==="line"?c=Kn(t,a.calculative.worldRect,a.lineWidth):c=yn(t,a.calculative.worldRect),c){if(a.type===jt.Node&&a.name==="line"&&!T2(t,a.calculative.worldAnchors))continue;if(!this.store.data.locked&&!a.locked?this.hotkeyType===Kt.AddAnchor?this.externalElements.style.cursor="pointer":this.externalElements.style.cursor="move":this.externalElements.style.cursor=this.store.options.hoverCursor,a.calculative.disabled&&(this.externalElements.style.cursor="not-allowed"),this.store.hover=a,this.initTemplateCanvas([this.store.hover]),n=xt.Node,this.store.pointAt=t,!t.ctrlKey){let{x:u,y:h,ex:d,ey:g,rotate:v,center:y}=this.store.hover.calculative.worldRect;if(v){const w=[{x:u,y:h},{x:d,y:h},{x:d,y:g},{x:u,y:g}];w.forEach(_=>{Gt(_,v,y)});let p=w[w.length-1];for(const _ of w){if(p.y>t.y!=_.y>t.y){const A=_.x+(t.y-_.y)*(p.x-_.x)/(p.y-_.y);Math.abs(A-this.store.pointAt.x)<10&&(this.store.pointAt.x=A)}p=_}}else this.store.pointAt.x-10<u?this.store.pointAt.x=u:this.store.pointAt.x+10>d&&(this.store.pointAt.x=d),this.store.pointAt.y-10<h?this.store.pointAt.y=h:this.store.pointAt.y+10>g&&(this.store.pointAt.y=g)}break}}}}return n});W(this,"dockInAnchor",t=>{var i,n;this.store.hover=void 0;for(let r=this.store.data.pens.length-1;r>=0;--r){const s=this.store.data.pens[r];if(s.visible==!1||s.locked===Ot.Disable||s===this.store.active[0])continue;let a=$a(s);if(a+=2*this.store.options.anchorRadius,!!Kn(t,s.calculative.worldRect,a)&&(this.store.hover=s,this.hotkeyType!==Kt.Resize&&s.calculative.worldAnchors))for(const l of s.calculative.worldAnchors){if(l.twoWay===Ee.In){const c=qt(this.store.active[0]);if(this.store.activeAnchor.id!==c.id)continue}if(l.twoWay===Ee.Out){const c=le(this.store.active[0]);if(this.store.activeAnchor.id!==c.id)continue}if(!(l.twoWay===Ee.DisableConnected||l.twoWay===Ee.Disable||((i=this.store.activeAnchor)==null?void 0:i.twoWay)===Ee.DisableConnectTo||((n=this.store.activeAnchor)==null?void 0:n.twoWay)===Ee.Disable)&&(this.title.hide(),this.inAnchor(t,s,l))){let c=ct(l);return Object.assign(c,t),this.title.show(c,s),!0}}}});W(this,"imageTimer");W(this,"templateImageTimer");W(this,"render",t=>{if(t&&(this.opening=!1),this.opening)return;let i;if(t==null||t===!0||t===1/0?(i=performance.now(),this.patchFlags=!0):t>1?i=t:i=performance.now(),!this.patchFlags)return;if(i-this.lastRender<this.store.options.interval){this.renderTimer&&cancelAnimationFrame(this.renderTimer),this.renderTimer=requestAnimationFrame(this.render);return}this.renderTimer=void 0,this.lastRender=i;const n=this.offscreen.getContext("2d");n.clearRect(0,0,this.offscreen.width,this.offscreen.height),n.save(),n.translate(this.store.data.x,this.store.data.y),globalThis.debugRender&&console.time("renderPens"),this.renderPens(),globalThis.debugRender&&console.timeEnd("renderPens"),this.renderBorder(),this.renderHoverPoint(),n.restore(),this.magnifierCanvas.render();const r=this.canvas.getContext("2d");r.clearRect(0,0,this.canvas.width,this.canvas.height),r.drawImage(this.offscreen,0,0,this.width,this.height),this.canvasTemplate.render(),this.canvasImageBottom.render(),this.canvasImage.render(),this.patchFlags=!1});W(this,"renderPens",()=>{const t=this.offscreen.getContext("2d");t.strokeStyle=cs(this.store);for(const i of this.store.data.pens)!isFinite(i.x)||i.canvasLayer!==zt.CanvasTemplate&&(i.name==="combine"&&!i.draw||i.calculative.inView&&(i.canvasLayer===zt.CanvasMain&&i.name!=="gif"&&i.image&&i.calculative.img&&(t.save(),Vn(t,i),i.calculative.rotate&&Qi(t,i),$n(t,i),Pr(t,i),t.restore()),Nn(t,i)));this.drawingLine&&Nn(t,this.drawingLine),this.pencilLine&&Nn(t,this.pencilLine),this.movingPens&&this.movingPens.forEach(i=>{this.renderPenContainChild(t,i)})});W(this,"renderPenContainChild",(t,i)=>{var n;i.calculative.inView&&Nn(t,i),(n=i.children)==null||n.forEach(r=>{const s=this.store.pens[r];s&&this.renderPenContainChild(t,s)})});W(this,"renderBorder",()=>{if(!this.store.data.locked&&this.activeRect&&!(this.store.active.length===1&&this.store.active[0].type)&&!this.movingPens){const t=this.offscreen.getContext("2d");t.save(),t.translate(.5,.5);const i=this.activeRect.pivot||this.activeRect.center;if(this.activeRect.rotate&&(t.translate(i.x,i.y),t.rotate(this.activeRect.rotate*Math.PI/180),t.translate(-i.x,-i.y)),t.strokeStyle=this.store.options.activeColor,t.globalAlpha=this.store.options.activeGlobalAlpha===void 0?.3:this.store.options.activeGlobalAlpha,t.beginPath(),t.lineWidth=this.store.options.activeLineWidth||1,t.setLineDash(this.store.options.activeLineDash||[]),t.strokeRect(this.activeRect.x,this.activeRect.y,this.activeRect.width,this.activeRect.height),t.setLineDash([]),t.lineWidth=1,t.globalAlpha=1,Ll(this.store.active)||qf(this.store.active)||this.store.options.disableRotate){t.restore();return}t.beginPath(),t.moveTo(this.activeRect.center.x,this.activeRect.y),t.lineTo(this.activeRect.center.x,this.activeRect.y-30),t.stroke(),t.beginPath(),t.strokeStyle=this.store.options.activeColor,t.fillStyle="#ffffff",t.arc(this.activeRect.center.x,this.activeRect.y-30,5,0,Math.PI*2),t.fill(),t.stroke(),t.restore()}});W(this,"renderHoverPoint",()=>{if(this.store.data.locked)return;const t=this.offscreen.getContext("2d");if(t.save(),t.translate(.5,.5),!this.store.options.disableAnchor&&this.store.hover&&!this.store.hover.disableAnchor&&(this.hotkeyType!==Kt.Resize||this.store.active.length!==1||this.store.active[0]!==this.store.hover)){const i=[...this.store.hover.calculative.worldAnchors];this.store.pointAt&&this.hotkeyType===Kt.AddAnchor&&i.push(this.store.pointAt),i&&(t.strokeStyle=this.store.hover.anchorColor||this.store.options.anchorColor,t.fillStyle=this.store.hover.anchorBackground||this.store.options.anchorBackground,i.forEach(n=>{if(n.hidden&&n.locked>Ot.DisableEdit)return;if(n===this.store.hoverAnchor){t.save();const s=this.store.hover.hoverAnchorColor||this.store.options.hoverAnchorColor;t.strokeStyle=s,t.fillStyle=s}t.beginPath();let r=n.radius||this.store.hover.anchorRadius||this.store.options.anchorRadius;if(this.store.hover.type&&!n.radius&&!this.store.hover.anchorRadius&&(r=3,this.store.hover.calculative.lineWidth>3&&(r=this.store.hover.calculative.lineWidth)),n.type===Ki.Line){let s=this.store.pens[n.penId].rotate||0;this.store.pens[n.penId].calculative.flipX&&(s*=-1),this.store.pens[n.penId].calculative.flipY&&(s*=-1);let a=n.rotate+s;this.store.pens[n.penId].calculative.flipX&&(a*=-1),this.store.pens[n.penId].calculative.flipY&&(a*=-1),t.save(),t.translate(n.x,n.y),t.rotate(a*Math.PI/180),t.translate(-n.x,-n.y),t.rect(n.x-n.length*this.store.data.scale/2,n.y-r,n.length*this.store.data.scale,r*2),t.restore()}else t.arc(n.x,n.y,r,0,Math.PI*2);if(this.store.hover.type&&this.store.hoverAnchor===n?(t.save(),t.strokeStyle=this.store.hover.activeColor||this.store.options.activeColor,t.fillStyle=t.strokeStyle):(n.color||n.background)&&(t.save(),t.strokeStyle=n.color,t.fillStyle=n.background),t.fill(),t.stroke(),n===this.store.hoverAnchor&&t.restore(),(this.store.hover.type&&this.store.hoverAnchor===n||n.color||n.background)&&t.restore(),!this.store.hover.parentId&&this.store.hover.children&&this.store.hover.children.length>0&&n===this.store.hoverAnchor){t.save(),t.beginPath(),t.lineWidth=3;const s=this.store.hover.hoverAnchorColor||this.store.options.hoverAnchorColor;globalThis.pSBC&&(t.strokeStyle=globalThis.pSBC(.5,s)),t.arc(n.x,n.y,r+1.5,0,Math.PI*2),t.stroke(),t.restore()}}))}this.hotkeyType!==Kt.AddAnchor&&!this.movingPens&&this.activeRect&&!(this.store.active.length===1&&this.store.active[0].type)&&!Ll(this.store.active)&&!jf(this.store.active)&&!this.store.options.disableSize&&(t.strokeStyle=this.store.options.activeColor,t.fillStyle="#ffffff",this.sizeCPs.forEach((i,n)=>{this.activeRect.rotate&&(t.save(),t.translate(i.x,i.y),t.rotate(this.activeRect.rotate*Math.PI/180),t.translate(-i.x,-i.y)),(n<4||this.hotkeyType===Kt.Resize)&&(t.beginPath(),t.fillRect(i.x-4.5,i.y-4.5,8,8),t.strokeRect(i.x-5.5,i.y-5.5,10,10)),this.activeRect.rotate&&t.restore()})),!this.store.data.locked&&this.dragRect&&(t.save(),t.fillStyle=qa(this.store.options.dragColor,.2),t.strokeStyle=this.store.options.dragColor,t.beginPath(),t.strokeRect(this.dragRect.x,this.dragRect.y,this.dragRect.width,this.dragRect.height),t.fillRect(this.dragRect.x,this.dragRect.y,this.dragRect.width,this.dragRect.height),t.restore()),this.dock&&(t.strokeStyle=this.store.options.dockColor,this.dock.xDock&&(t.beginPath(),t.moveTo(this.dock.xDock.x,this.dock.xDock.y),t.lineTo(this.dock.xDock.x,this.dock.xDock.prev.y),t.stroke()),this.dock.yDock&&(t.beginPath(),t.moveTo(this.dock.yDock.x,this.dock.yDock.y),t.lineTo(this.dock.yDock.prev.x,this.dock.yDock.y),t.stroke())),t.restore()});W(this,"pastePen",(t,i)=>{const n=t.id;if(Kf(t),t.parentId=i,t.type===jt.Line?this.changeNodeConnectedLine(n,t,this.store.clipboard.pens):this.changeLineAnchors(n,t,this.store.clipboard.pens),!t.parentId){const s=this.getPenRect(t,this.store.clipboard.origin,this.store.clipboard.scale),a=this.getPenRect(this.store.clipboard.initRect,this.store.clipboard.origin,this.store.clipboard.scale),{origin:l,scale:c}=this.store.data;t.x=l.x+s.x*c,t.y=l.y+s.y*c,t.width=s.width*c,t.height=s.height*c,a.x=l.x+a.x*c,a.y=l.y+a.y*c,ee(a),this.store.clipboard.pos&&(t.x-=a.center.x-this.store.clipboard.pos.x,t.y-=a.center.y-this.store.clipboard.pos.y),this.keyOptions&&this.keyOptions.altKey&&(this.keyOptions.ctrlKey||this.keyOptions.metaKey)?(t.x=-this.store.data.x+this.width/2-t.width/2,t.y=-this.store.data.y+this.height/2-t.height/2):this.keyOptions&&this.keyOptions.shiftKey&&(this.keyOptions.ctrlKey||this.keyOptions.metaKey)||(t.x+=this.store.clipboard.offset*this.store.data.scale,t.y+=this.store.clipboard.offset*this.store.data.scale)}this.makePen(t);const r=[];if(Array.isArray(t.children))for(const s of t.children){const a=this.store.clipboard.pens.find(l=>l.id===s);a&&r.push(this.pastePen(a,t.id).id)}return t.children=r,Gi(t,!0),t});W(this,"ondblclick",t=>{var i;this.store.hover&&(!this.store.data.locked||this.store.hover.dbInput)&&!this.store.options.disableInput&&(this.store.hover.onShowInput?this.store.hover.onShowInput(this.store.hover,t):this.store.hover&&this.store.hover.parentId?((i=this.store.active)==null?void 0:i.length)===1&&this.store.active[0].id===this.store.hover.id?this.showInput(this.store.hover):(this.store.pens[this.store.hover.parentId].children.forEach(n=>{this.store.pens[n].calculative.active=!1,this.store.pens[n].calculative.hover=!1}),this.active([this.store.hover])):this.showInput(this.store.hover)),this.store.emitter.emit("dblclick",{x:t.x,y:t.y,pen:this.store.hover})});W(this,"showInput",(t,i,n="transparent")=>{if(!window||!this.store.hover||this.store.hover.locked||this.store.hover.externElement||this.store.hover.disableInput||this.store.hover.disabled)return;if(this.inputDiv.dataset.penId===t.id){this.inputDiv.dataset.isInput="true",this.inputDiv.contentEditable="true",this.inputDiv.focus();const h=window.getSelection();h.selectAllChildren(this.inputDiv),h.collapseToEnd(),this.inputDiv.scrollTop=this.inputDiv.scrollHeight,this.inputDiv.scrollLeft=this.inputDiv.scrollWidth;return}!i&&!t.dbInput?this.setInputStyle(t):(this.inputDiv.style.width="100%",this.inputDiv.style.height="100%");const r=i||t.calculative.worldTextRect,l=`${(t.calculative.tempText===void 0?t.text+""||"":t.calculative.tempText).replace(/\x20/g,"&nbsp;").split(/[\s\n]/).join("</div><div>")}</div>`.replace("</div>","").replace(/\<div\>\<\/div\>/g,"<div><br></div>");this.inputDiv.innerHTML=l,this.inputParent.style.left=r.x+this.store.data.x-(t.textLeft||0)+"px",this.inputParent.style.top=r.y+this.store.data.y-(t.textTop||0)+"px";let c=r.width;this.inputParent.style.width=(c<0?12:c)+"px",this.inputParent.style.height=r.height+(t.textTop||0)+"px",this.inputParent.style.zIndex="9999",this.inputParent.style.background=n,t.rotate%360?this.inputParent.style.transform=`rotate(${t.rotate}deg)`:this.inputParent.style.transform=null,this.inputParent.style.display="flex",this.inputDiv.dataset.penId=t.id,this.inputDiv.contentEditable=t.disableInput==null?"true":t.disableInput.toString(),t.dropdownList&&this.dropdown.style.display!=="block"&&(this.dropdown.style.background=t.dropdownBackground||"#fff",this.dropdown.style.color=t.dropdownColor||"#bdc7db",this.setDropdownList()),this.inputDiv.contentEditable="true",this.inputDiv.focus();const u=window.getSelection();u.selectAllChildren(this.inputDiv),u.collapseToEnd(),this.inputDiv.scrollTop=this.inputDiv.scrollHeight,this.inputDiv.scrollLeft=this.inputDiv.scrollWidth,t.calculative.text=void 0,this.initTemplateCanvas([t]),this.render()});W(this,"setInputStyle",t=>{t.text||(t.text="");let i;for(let c=0;c<document.styleSheets.length;c++)document.styleSheets[c].title==="le5le.com"&&(i=document.styleSheets[c]);let n="overflow: scroll;",r="",s=1;const{scale:a}=this.store.data;if(t.fontSize<12&&(s=12/t.fontSize),t.textAlign?n+=`text-align: ${t.textAlign};`:n+="text-align: center;",t.textAlign&&t.whiteSpace==="pre-line"&&(n+=`align-items: ${{left:"start",center:"center",right:"end"}[t.textAlign]};`),t.textBaseline?n+=`justify-content: ${{top:"start",middle:"center",bottom:"end"}[t.textBaseline]};`:n+="justify-content: center;",t.fontFamily&&(n+=`font-family: ${t.fontFamily};`),t.fontSize&&(t.fontSize*a<12?(n+=`font-size:${t.fontSize}px;`,n+=`zoom:${t.fontSize/12*a};`):n+=`font-size:${t.fontSize*a}px;`),n+=`color:${An(t,this.store)};`,t.fontStyle&&(n+=`font-style: ${t.fontStyle};`),t.fontWeight&&(n+=`font-weight: ${t.fontWeight};`),t.textLeft&&(n+=`margin-left:${a>1?t.textLeft*s:t.textLeft*s/a}px;`),t.textTop&&(n+=`margin-top:${a>1?t.textTop*s:t.textTop*s/a}px;`),t.lineHeight&&(n+=`line-height:${a>1?t.fontSize*t.lineHeight*a:t.fontSize*t.lineHeight*s}px;`),t.textHeight)n+=`height:${a>1?t.textHeight*s*a:t.textHeight*s}px;`;else{let c=t.calculative.worldRect.height/a;c<0&&(c=0);let u=t.fontSize*a<12?c*s:c*a*s;u<t.fontSize*t.lineHeight*a&&(u=t.fontSize*t.lineHeight*a,n+=`top:-${u/2}px;`),n+=`height:${u}px;`}let l=null;if(t.textWidth)l=t.textWidth<1&&t.textWidth>-1?t.textWidth*t.calculative.worldRect.width:t.textWidth,t.whiteSpace!=="pre-line"&&(l<t.fontSize?n+=`width:${t.fontSize*1.2*s}px;`:n+=`width:${a>1?l*s*a:l*s}px;`);else if(t.whiteSpace===void 0||t.whiteSpace==="break-all"){let c=(t.calculative.worldTextRect.width||12)/a;c<0&&(c=0),n+=`width:${t.fontSize*a<12?c*s:c*a}px;`}if(t.whiteSpace&&(t.whiteSpace==="pre-line"?n+="white-space:pre;":(n+=`white-space:${t.whiteSpace};`,t.whiteSpace==="nowrap"&&(r+="display:contents;"))),t.whiteSpace!=="nowrap"){let c=t.fontSize*1.2*t.text.length,u=(l||t.calculative.worldRect.width/a)*Math.floor(t.calculative.worldRect.height/a/(t.lineHeight*t.fontSize));c>u&&(n+="justify-content: start;")}i.deleteRule(0),i.deleteRule(0),i.insertRule(`.meta2d-input
  53. .input-div{
  54. resize:none;border:none;outline:none;background:transparent;position:absolute;flex-grow:1;height:100%;width: 100%;position:absolute;left:0;top:0;display:flex;flex-direction: column;cursor: text;${n}}`),i.insertRule(`.input-div div{${r}}`)});W(this,"hideInput",()=>{if(this.inputParent.style.display==="flex"){this.inputParent.style.display="none";const t=this.store.pens[this.inputDiv.dataset.penId];if(!t)return;if(t.calculative.text=t.text,this.inputDiv.dataset.value=this.inputDiv.innerHTML.replace(/\<div\>/g,`
  55. `).replace(/\<\/div\>/g,"").replace(/\<br\>/g,"").replace(/&nbsp;/g," ").replace(/(<([^>]+)>)/gi,""),this.inputDiv.dataset.value=this.convertSpecialCharacter(this.inputDiv.dataset.value),t.onInput)t.onInput(t,this.inputDiv.dataset.value);else if(t.text!==this.inputDiv.dataset.value){const i=[ct(t,!0)];t.text=this.inputDiv.dataset.value,t.calculative.text=t.text,this.inputDiv.dataset.penId=void 0,t.text&&t.textAutoAdjust&&B_(t),Ti(t),this.patchFlags=!0,this.pushHistory({type:bt.Update,pens:[ct(t,!0)],initPens:i}),this.store.emitter.emit("change",t),this.store.emitter.emit("valueUpdate",t)}else t.text===this.inputDiv.dataset.value&&t.calculative.textLines.length==0&&Ti(t);this.initTemplateCanvas([t])}this.inputDiv.dataset.penId=void 0,this.dropdown.style.display="none",this.inputDiv.dataset.isInput="false",this.inputDiv.contentEditable="false",this.render()});W(this,"setDropdownList",t=>{this.clearDropdownList();const i=this.store.pens[this.inputDiv.dataset.penId];if(!this.store.data.locked&&!["tablePlus"].includes(i.name))return;if(this.dropdown.style.display="block",!i||!i.dropdownList){this.dropdown.style.display="none";return}if(!i.dropdownList.length){const s=document.createElement("div");s.innerText="None",s.style.padding="5px 12px",s.style.color="#ddd",this.dropdown.appendChild(s);return}const n=this.inputDiv.innerHTML.replace(/\<div\>/g,`
  56. `).replace(/\<\/div\>/g,"").replace(/\<br\>/g,"");let r=0;for(const s of i.dropdownList){const a=typeof s=="string"?s:s.text;t&&n?a.includes(n)&&this.dropdownAppendOption(a,r):this.dropdownAppendOption(a,r),++r}if(!this.dropdown.hasChildNodes()){const s=document.createElement("div");s.innerText="None",s.style.padding="5px 12px",s.style.color="#ddd",this.dropdown.appendChild(s)}});W(this,"selectDropdown",t=>{const i=t.target,n=this.store.pens[this.inputDiv.dataset.penId];if(!i||!n||!n.dropdownList)return;const r=+i.dataset.i,s=n.dropdownList[r];if(!s)return;const a=[ct(n,!0)];typeof s=="object"?(this.updateValue(n,{...s}),n.calculative.text=void 0,this.calcActiveRect()):n.text=s+"",this.inputDiv.innerText=n.text,this.hideInput(),this.pushHistory({type:bt.Update,pens:[ct(n,!0)],initPens:a}),this.render(),this.store.emitter.emit("change",n),this.store.emitter.emit("valueUpdate",n)});W(this,"inFitBorder",t=>{let i;const n=this.store.data.width||this.store.options.width,r=this.store.data.height||this.store.options.height;let s={x:(t.x-this.store.data.origin.x)/this.store.data.scale,y:(t.y-this.store.data.origin.y)/this.store.data.scale};const a=this.canvasImage.activeFit;this.externalElements.style.cursor="default",s.y>r*a.y-10&&s.y<r*a.y+10&&(i="top",this.externalElements.style.cursor="row-resize"),s.y>r*(a.y+a.height)-10&&s.y<r*(a.y+a.height)+10&&(i="bottom",this.externalElements.style.cursor="row-resize"),s.x>n*a.x-10&&s.x<n*a.x&&(i="left",this.externalElements.style.cursor="col-resize"),s.x>n*(a.x+a.width)-10&&s.x<n*(a.x+a.width)+10&&(i="right",this.externalElements.style.cursor="col-resize"),this.canvasImage.currentFit=i});this.parent=t,this.parentElement=i,this.store=n,this.canvasTemplate=new Lk(i,n),this.canvasTemplate.canvas.style.zIndex="1",this.canvasImageBottom=new rd(i,n,!0),this.canvasImageBottom.canvas.style.zIndex="2",i.appendChild(this.canvas),this.canvas.style.position="absolute",this.canvas.style.backgroundRepeat="no-repeat",this.canvas.style.backgroundSize="100% 100%",this.canvas.style.zIndex="3",this.canvasImage=new rd(i,n),this.canvasImage.canvas.style.zIndex="4",this.magnifierCanvas=new Pk(this,i,n),this.magnifierCanvas.canvas.style.zIndex="5",this.externalElements.style.position="absolute",this.externalElements.style.left="0",this.externalElements.style.top="0",this.externalElements.style.outline="none",this.externalElements.style.background="transparent",this.externalElements.style.zIndex="5",i.style.position="relative",i.appendChild(this.externalElements),this.createInput(),this.tooltip=new us(i,n),this.tooltip.box.onmouseleave=r=>{this.patchFlags=!0,this.store.lastHover&&(this.store.lastHover.calculative.hover=!1);let s=this.store.data.pens.find(a=>a.calculative.hover===!0);rs(s,!1)},this.popconfirm=new Mk(i,n),this.dialog=new Ik(i),this.title=new Ka(i),this.store.options.scroll&&(this.scroll=new ig(this)),this.store.dpiRatio=globalThis.devicePixelRatio||1,this.store.dpiRatio<1?this.store.dpiRatio=1:this.store.dpiRatio>1&&this.store.dpiRatio<1.5&&(this.store.dpiRatio=1.5),this.clientRect=this.externalElements.getBoundingClientRect(),this.listen(),window==null||window.addEventListener("resize",this.onResize),window==null||window.addEventListener("scroll",this.onScroll),window==null||window.addEventListener("message",this.onMessage)}listen(){switch(this.externalElements.addEventListener("gesturestart",this.onGesturestart),this.externalElements.ondragover=t=>t.preventDefault(),this.externalElements.ondrop=this.ondrop,this.externalElements.oncontextmenu=t=>t.preventDefault(),this.store.options.interval=50,this.externalElements.ontouchstart=this.ontouchstart,this.externalElements.ontouchmove=this.ontouchmove,this.externalElements.ontouchend=this.ontouchend,this.externalElements.onmousedown=t=>{this.onMouseDown({x:t.offsetX,y:t.offsetY,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:t.buttons})},this.externalElements.onmousemove=t=>{t.target===this.externalElements&&this.onMouseMove({x:t.offsetX,y:t.offsetY,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:t.buttons})},this.externalElements.onmouseup=t=>{this.onMouseUp({x:t.offsetX,y:t.offsetY,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,altKey:t.altKey,buttons:t.buttons,button:t.button})},this.externalElements.onmouseleave=t=>{this.store.data.pens.forEach(i=>{i.calculative.hover&&(i.calculative.hover=!1)}),this.store.hover&&(this.store.hover.calculative.hover=!1,this.store.hover=void 0),this.render(),t.toElement!==this.tooltip.box&&t.toElement!==this.tooltip.arrowUp&&t.toElement!==this.tooltip.arrowDown&&(this.tooltip.hide(),this.store.lastHover=void 0)},this.externalElements.ondblclick=this.ondblclick,this.externalElements.tabIndex=0,this.externalElements.onblur=()=>{this.mouseDown=void 0},this.externalElements.onwheel=this.onwheel,document.addEventListener("copy",this.onCopy),document.addEventListener("cut",this.onCut),document.addEventListener("paste",this.onPaste),this.store.options.keydown){case zn.Document:document.addEventListener("keydown",this.onkeydown),document.addEventListener("keyup",this.onkeyup);break;case zn.Canvas:this.externalElements.addEventListener("keydown",this.onkeydown),this.externalElements.addEventListener("keyup",this.onkeyup);break}}splitLine(t,i){const n=t.calculative.worldAnchors,r=n.findIndex(h=>h===i);if([-1,0,n.length-1].includes(r))return;const s=ct(t,!0),a=ct(t,!0),l=It();a.id=l,a.calculative.canvas=this,a.calculative.active=!1,a.calculative.hover=!1;const c=ct(n.slice(0,r+1)),u=ct(n.slice(r)).map(h=>(h.penId=l,h));t.calculative.worldAnchors=c,a.calculative.worldAnchors=u,this.initLineRect(t),this.initLineRect(a),this.store.data.pens.push(a),this.store.pens[l]=a,this.pushHistory({type:bt.Add,pens:[ct(a,!0)],step:2}),this.pushHistory({type:bt.Update,initPens:[s],pens:[ct(t,!0)],step:2})}translateAnchor(t,i){this.movingAnchor.x+=t,this.movingAnchor.y+=i;const n=this.movingAnchor.penId;if(n){const r=this.store.pens[n],s=r.calculative.worldRect;this.movingAnchor.x<s.x?this.movingAnchor.x=s.x:this.movingAnchor.x>s.ex&&(this.movingAnchor.x=s.ex),this.movingAnchor.y<s.y?this.movingAnchor.y=s.y:this.movingAnchor.y>s.ey&&(this.movingAnchor.y=s.ey);const a=hs(this.movingAnchor,s),l=r.anchors.findIndex(c=>c.id===this.movingAnchor.id);r.anchors[l]=a,this.patchFlags=!0}}async fileToPen(t,i){let n="";return this.store.options.uploadFn?n=await this.store.options.uploadFn(t):this.store.options.uploadUrl?n=await N_(t,this.store.options.uploadUrl,this.store.options.uploadParams,this.store.options.uploadHeaders):n=await O_(t),new Promise((r,s)=>{const a=new Image;a.onload=()=>{At.htmlElements[n]=a,r({width:a.width,height:a.height,name:i?"gif":"image",image:n})},a.onerror=l=>{s(l)},a.crossOrigin="anonymous",a.src=n})}async dropPens(t,i){var c;this.randomIdObj={};for(const u of t)!u.parentId&&this.randomCombineId(u,t);if(Object.keys(this.randomIdObj).length!==0)for(const u of t)u.type?(u.anchors[0].connectTo=this.randomIdObj[u.anchors[0].connectTo],u.anchors[u.anchors.length-1].connectTo=this.randomIdObj[u.anchors[u.anchors.length-1].connectTo]):(c=u.connectedLines)==null||c.forEach(h=>{h.lineAnchor=this.randomIdObj[h.lineAnchor],h.lineId=this.randomIdObj[h.lineId]});for(const u of t)u.id||(u.id=It()),!u.calculative&&(u.calculative={canvas:this}),this.store.pens[u.id]=u;let n=0,r=0,s=0;for(const u of t)u.parentId||(u.width*=this.store.data.scale,u.height*=this.store.data.scale,u.x=i.x-u.width/2+s,u.y=i.y-u.height/2+r,u.tags&&u.tags.includes("meta3d")&&(u.x=this.store.data.origin.x,u.y=this.store.data.origin.y),u.dataset&&(n%2===0?s=u.width-40*this.store.data.scale:s=0,n++,n%2===0&&(r+=u.height+10*this.store.data.scale)));const a=this.store.data.width||this.store.options.width,l=this.store.data.height||this.store.options.height;if(a&&l){let u={x:this.store.data.origin.x,y:this.store.data.origin.y,width:a*this.store.data.scale,height:l*this.store.data.scale},h=!0;for(const d of t)if(!d.parentId){let g=[{x:d.x,y:d.y},{x:d.x+d.width,y:d.y},{x:d.x,y:d.y+d.height},{x:d.x+d.width,y:d.y+d.height},{x:d.x+d.width/2,y:d.y+d.height/2}];if(d.x===u.x&&d.y===u.y&&d.width===u.width&&d.height===u.height||g.some(v=>yn(v,u))){h=!1,this.store.options.strictScope&&(d.x<u.x&&(d.x=u.x),d.y<u.y&&(d.y=u.y),d.x+d.width>u.x+u.width&&(d.x=u.x+u.width-d.width),d.y+d.height>u.y+u.height&&(d.y=u.y+u.height-d.height));break}}if(h){console.info("\u753B\u7B14\u5728\u5927\u5C4F\u8303\u56F4\u5916");return}}await this.addPens(t,!0),this.active(t.filter(u=>!u.parentId)),this.render(),this.externalElements.focus()}randomCombineId(t,i,n){let r=null;t.type?(t.anchors[0].connectTo||t.anchors[t.anchors.length-1].connectTo)&&(r=[t.id,t.anchors[0].id,t.anchors[t.anchors.length-1].id]):t.connectedLines&&t.connectedLines.length&&(r=[t.id]),Kf(t),r&&(r.length===1?this.randomIdObj[r[0]]=t.id:(this.randomIdObj[r[0]]=t.id,this.randomIdObj[r[1]]=t.anchors[0].id,this.randomIdObj[r[2]]=t.anchors[t.anchors.length-1].id)),t.parentId=n;const s=[];if(Array.isArray(t.children))for(const a of t.children){const l=i.find(c=>c.id===a);l&&s.push(this.randomCombineId(l,i,t.id).id)}return t.children=s,t}async addPens(t,i,n){if(this.beforeAddPens&&await this.beforeAddPens(t)!=!0)return[];const r=[];for(const s of t)this.beforeAddPen&&this.beforeAddPen(s)!=!0||(n&&(s.x=s.x*this.store.data.scale+this.store.data.origin.x,s.y=s.y*this.store.data.scale+this.store.data.origin.y,s.width=s.width*this.store.data.scale,s.height=s.height*this.store.data.scale),this.makePen(s),r.push(s));return this.render(),this.store.emitter.emit("add",r),i&&this.pushHistory({type:bt.Add,pens:ct(r,!0)}),r}getInitPencilLine(t){const{data:i,options:n}=this.store,r=i.scale,s=i.lineWidth||1;return{id:t.penId,name:"line",x:t.x,y:t.y,type:jt.Line,calculative:{canvas:this,pencil:!0,active:!0,worldAnchors:[t],lineWidth:s*r},fromArrow:i.fromArrow||n.fromArrow,toArrow:i.toArrow||n.toArrow,lineWidth:s}}createDrawingLine(t){this.inactive();const{data:i,options:n}=this.store,r=i.scale,s=i.lineWidth||1;return t.penId=It(),{id:t.penId,name:"line",lineName:this.drawingLineName,x:t.x,y:t.y,type:jt.Line,calculative:{canvas:this,active:!0,worldAnchors:[t],lineWidth:s*r},fromArrow:i.fromArrow||n.fromArrow,toArrow:i.toArrow||n.toArrow,lineWidth:s}}addRuleLine(t){const{x:i,y:n,scale:r,origin:s}=this.store.data,a=t.x+i,l=t.y+n;let c=t.x,u=t.y,h=0,d=0,g=0,v=0;if(a<=l&&a<20)c=-i,h=this.width,g=1,t.ctrlKey||(u=Math.round((u-s.y)/(r*10))*(r*10)+s.y);else if(l<a&&l<20)u=-n,d=this.height,v=1,t.ctrlKey||(c=Math.round((c-s.x)/(r*10))*(r*10)+s.x);else return;this.addPen({isRuleLine:!0,type:jt.Line,name:"line",lineName:"line",x:c,y:u,width:h,height:d,color:this.store.options.ruleLineColor,anchors:[{x:0,y:0},{x:g,y:v}]})}clearRuleLines(){this.delete(this.ruleLines)}get ruleLines(){return this.store.data.pens.filter(t=>t.isRuleLine)}alignPenToGrid(t){var n;if(this.store.options.autoAlignGrid&&this.store.data.grid&&!t.type){const r=this.store.data.gridSize||this.store.options.gridSize,{origin:s,scale:a}=this.store.data,{x:l,y:c}=t,u={x:l,y:c},h=this.getPenRect(t),d=parseInt((h.x/r).toFixed()),g=parseInt((h.y/r).toFixed()),v=d*r,y=g*r;u.x=s.x+v*a,u.y=s.y+y*a,Object.assign(t,u),(n=t.onMove)==null||n.call(t,t),this.updatePenRect(t),this.calcActiveRect(),this.getSizeCPs()}}movedActivePens(t){let i=this.getAllFollowersByPens(this.store.active,!1);const n=ct(i,!0),r=this.store.data.gridSize||this.store.options.gridSize,{origin:s,scale:a}=this.store.data,l=this.store.options.autoAlignGrid&&this.store.data.grid;if(i.forEach(g=>{var _;const v=this.movingPens.findIndex(A=>A.id===g.id+Fe);if(v<0)return;const{x:y,y:w}=this.movingPens[v],p={x:y,y:w};if(l&&!this.movingPens[v].type){const A=this.getPenRect(this.movingPens[v]),x=parseInt((A.x/r).toFixed()),E=parseInt((A.y/r).toFixed()),I=x*r,M=E*r;p.x=s.x+I*a,p.y=s.y+M*a}Object.assign(g,p),(_=g.onMove)==null||_.call(g,g),this.updatePenRect(g),this.updateLines(g),this.store.emitter.emit("updateLines",g),this.patchFlagsLines.forEach(A=>{A.type&&this.initLineRect(A)}),this.patchFlagsLines.clear(),g.calculative.x=g.x,g.calculative.y=g.y,g.calculative.initRect&&(g.calculative.initRect.x=g.calculative.x,g.calculative.initRect.y=g.calculative.y,g.calculative.initRect.ex=g.calculative.x+g.calculative.width,g.calculative.initRect.ey=g.calculative.y+g.calculative.height),Uv(g),g.parentId&&this.parent.updateRectbyChild(g.calculative.worldRect,g,this.store.pens[g.parentId])}),this.initImageCanvas(this.store.active),this.initTemplateCanvas(this.store.active),!this.dock)return;const{xDock:c,yDock:u}=this.dock;let h;c&&(h=this.store.pens[c.penId]),!h&&u&&(h=this.store.pens[u.penId]);const d=ct(this.store.active,!0);if(t&&this.store.active.length===1&&(h==null?void 0:h.type)===1&&((c==null?void 0:c.anchorId)||(u==null?void 0:u.anchorId))){const g=le(h),v=qt(h);if(c!=null&&c.anchorId){const y=this.store.pens[this.store.active[0].id+Fe].calculative.worldAnchors.find(w=>w.id===c.anchorId);y.x===g.x&&y.y===g.y?(n.push(ct(h,!0)),we(this.store.active[0],y,h,g),d.push(ct(h,!0))):y.x===v.x&&y.y===v.y&&(n.push(ct(h,!0)),we(this.store.active[0],y,h,v),d.push(ct(h,!0)))}else if(u!=null&&u.anchorId){const y=this.store.pens[this.store.active[0].id+Fe].calculative.worldAnchors.find(w=>w.id===u.anchorId);y.x===g.x&&y.y===g.y?(n.push(ct(h,!0)),we(this.store.active[0],y,h,g),d.push(ct(h,!0))):y.x===v.x&&y.y===v.y&&(n.push(ct(h,!0)),we(this.store.active[0],y,h,v),d.push(ct(h,!0)))}}l&&(this.calcActiveRect(),this.getSizeCPs()),this.pushHistory({type:bt.Update,pens:d,initPens:n}),this.store.emitter.emit("translatePens",d)}copyMovedPens(){this.copy(this.store.active.map((t,i)=>{const{x:n,y:r}=this.movingPens[i];return this.updateLines(t),{...t,x:n,y:r}})),this.pasteOffset=!1,this.paste()}initImageCanvas(t){t.some(i=>this.hasImage(i,!1))&&this.canvasImage.init(),t.some(i=>this.hasImage(i,!0))&&this.canvasImageBottom.init()}initTemplateCanvas(t){t.some(i=>i.canvasLayer===zt.CanvasTemplate)&&this.canvasTemplate.init()}hasImage(t,i){var n;return t.image&&t.name!=="gif"?i?t.canvasLayer===zt.CanvasImageBottom:t.canvasLayer===zt.CanvasImage:(n=t.children)==null?void 0:n.some(r=>{const s=this.store.pens[r];return s&&this.hasImage(s,i)})}inactive(t){!this.store.active.length||(this.initTemplateCanvas(this.store.active),this.store.active.forEach(i=>{i.calculative.active=void 0,i.calculative.activeAnchor=void 0,i.calculative.hover=!1,Rr(i,!1)}),!t&&this.store.emitter.emit("inactive",this.store.active),this.store.active=[],this.activeRect=void 0,this.sizeCPs=void 0,this.store.activeAnchor=void 0,this.patchFlags=!0)}active(t,i=!0){if(this.store.active){i&&this.store.emitter.emit("inactive",this.store.active);for(const n of this.store.active)n.calculative.active=void 0,n.calculative.hover=!1,Rr(n,!1)}this.store.active=[],t.forEach(n=>{n.calculative.active=!0,Rr(n)}),this.store.active.push(...t),this.activeRect=void 0,this.calcActiveRect(),this.initTemplateCanvas(t),this.patchFlags=!0,i&&this.store.emitter.emit("active",this.store.active)}getSizeCPs(){this.sizeCPs=tn(this.activeRect);const t=[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}],{x:i,y:n,width:r,height:s,rotate:a,center:l}=this.activeRect;t.forEach(c=>{const u={x:c.x*r+i,y:c.y*s+n};Gt(u,a,l),this.sizeCPs.push(u)})}getSpecialAngle(t,i){let n=0;t.x-i.x!==0?(n=Math.atan((i.y-t.y)/(t.x-i.x))*180/Math.PI,t.x<i.x&&(n>0?n-=180:n+=180)):i.y>t.y?n=90:i.y<t.y&&(n=-90),n=Math.round(n/15)*15;let r=Math.sqrt((i.x-t.x)*(i.x-t.x)+(i.y-t.y)*(i.y-t.y));t.x=i.x+Math.cos(n/180*Math.PI)*r,t.y=i.y-Math.sin(n/180*Math.PI)*r}clearHover(){this.hoverType=xt.None,this.store.hover=null,this.store.hoverAnchor=null}inAnchor(t,i,n){var r;if(this.store.hoverAnchor=void 0,this.movingAnchor=void 0,!n||n.locked>Ot.DisableEdit||!(i.type&&i.calculative.active)&&this.store.options.disableAnchor||i.disableAnchor)return xt.None;if((this.mouseDown||this.drawingLine)&&i.name==="line"&&n.connectTo){const s=this.findOne(n.connectTo);if((s==null?void 0:s.calculative)&&!(s!=null&&s.calculative.active)){i=s;const a=s.calculative.worldAnchors.find(l=>l.id===n.anchorId);a&&(n=a)}}if(n.twoWay===Ee.Disable&&i.name!=="line")return xt.None;if(i.name==="line"&&n.connectTo){let s=(r=this.findOne(n.connectTo))==null?void 0:r.anchors.find(a=>a.id===n.anchorId);if(s&&s.twoWay)return xt.None}if(this.drawingLine){if(n.twoWay===Ee.Out)return xt.None}else if(!(this.mouseDown&&this.hoverType===xt.LineAnchor)){if(n.twoWay===Ee.In)return xt.None}if(Ar(t,n,this.pointSize,n.penId?this.store.pens[n.penId]:void 0))return n!==this.store.hoverAnchor&&(this.patchFlags=!0),this.store.hoverAnchor=n,this.store.hover=i,i.type?n.connectTo&&!i.calculative.active&&(this.store.hover=this.store.pens[n.connectTo],this.store.hover)?(this.store.hoverAnchor=this.store.hover.calculative.worldAnchors.find(s=>s.id===n.anchorId),this.store.hoverAnchor?(this.externalElements.style.cursor="crosshair",xt.NodeAnchor):xt.None):(this.hotkeyType===Kt.AddAnchor?this.externalElements.style.cursor="vertical-text":this.externalElements.style.cursor="pointer",xt.LineAnchor):(this.hotkeyType===Kt.AddAnchor?this.externalElements.style.cursor="vertical-text":this.externalElements.style.cursor="crosshair",xt.NodeAnchor);if(!this.mouseDown&&i.type){if(i.calculative.active&&n.prev&&Ar(t,n.prev,this.pointSize))return this.store.hoverAnchor=n,this.store.hover=i,this.externalElements.style.cursor="pointer",xt.LineAnchorPrev;if(i.calculative.active&&n.next&&Ar(t,n.next,this.pointSize))return this.store.hoverAnchor=n,this.store.hover=i,this.externalElements.style.cursor="pointer",xt.LineAnchorNext}return xt.None}resize(t,i){t=t||this.parentElement.clientWidth,i=i||this.parentElement.clientHeight,this.width=t,this.height=i,this.canvasRect={x:0,y:0,width:t,height:i},ae(this.canvasRect),this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",this.externalElements.style.width=t+"px",this.externalElements.style.height=i+"px",this.canvasTemplate.resize(t,i),this.canvasImage.resize(t,i),this.canvasImageBottom.resize(t,i),this.magnifierCanvas.resize(t,i),t=t*this.store.dpiRatio|0,i=i*this.store.dpiRatio|0,this.canvas.width=t,this.canvas.height=i,this.offscreen.width=t,this.offscreen.height=i,this.clientRect=this.externalElements.getBoundingClientRect(),this.canvas.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").scale(this.store.dpiRatio,this.store.dpiRatio),this.offscreen.getContext("2d").textBaseline="middle";for(const n of this.store.data.pens)n.isRuleLine&&(n.width?n.height||(n.width=this.width):n.height=this.height),Gi(n);this.render()}clearCanvas(){this.activeRect=void 0,this.sizeCPs=void 0,this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height),this.offscreen.getContext("2d").clearRect(0,0,this.offscreen.width,this.offscreen.height),this.store.data.template||this.canvasTemplate.clear(),this.canvasImage.clear(),this.canvasImageBottom.clear()}async addPen(t,i,n,r){if(!(this.beforeAddPens&&await this.beforeAddPens([t])!=!0)&&!(this.beforeAddPen&&this.beforeAddPen(t)!=!0))return r&&(t.x=t.x*this.store.data.scale+this.store.data.origin.x,t.y=t.y*this.store.data.scale+this.store.data.origin.y,t.width=t.width*this.store.data.scale,t.height=t.height*this.store.data.scale),this.makePen(t),this.active([t]),this.render(),n&&this.store.emitter.emit("add",[t]),i&&this.pushHistory({type:bt.Add,pens:[t]}),t}pushHistory(t){var r;if(this.store.data.locked)return;const{origin:i,scale:n}=this.store.data;t.origin=ct(i),t.scale=n,t.type!==bt.Update&&t.pens&&t.pens.forEach(s=>{s.calculative&&(s.calculative.layer=this.store.data.pens.findIndex(a=>a.id===s.id))}),this.store.historyIndex<this.store.histories.length-1&&this.store.histories.splice(this.store.historyIndex+1,this.store.histories.length-this.store.historyIndex-1),(r=t.pens)==null||r.forEach(s=>{let a;if(t.initPens)for(const l of t.initPens)l.id===s.id&&(a=l);if(a)for(const l in s)a[l]==null&&(a[l]=void 0)}),this.store.histories.push(t),this.store.historyIndex=this.store.histories.length-1,this.store.emitter.emit("update",{previous:t.initPens,current:t.pens})}undo(){if(this.store.data.locked||this.store.historyIndex==null||this.store.historyIndex<0)return;const t=this.store.histories[this.store.historyIndex--];this.doEditAction(t,!0);let i=t.step;for(;i>1;){const n=this.store.histories[this.store.historyIndex--];this.doEditAction(n,!0),i--}(t.type==bt.Add||t.type==bt.Delete||t.type==bt.Update)&&this.activeHistory()}redo(){if(this.store.data.locked||this.store.historyIndex==null||this.store.historyIndex>this.store.histories.length-2)return;const t=this.store.histories[++this.store.historyIndex];this.doEditAction(t,!1);let i=t.step;for(;i>1;){const n=this.store.histories[++this.store.historyIndex];this.doEditAction(n,!1),i--}(t.type==bt.Add||t.type==bt.Delete||t.type==bt.Update)&&this.activeHistory()}activeHistory(){let t=this.store.histories[this.store.historyIndex+1];const i=[];if(t&&t.type===bt.Update){t.pens.forEach(r=>{i.push(this.store.pens[r.id])}),this.active(i);return}let n=this.store.histories[this.store.historyIndex];n&&(n.type===bt.Add||n.type===bt.Delete)&&(n.pens.forEach(r=>{i.push(this.store.pens[r.id])}),this.active(i))}doEditAction(t,i){switch(this.inactive(),this.store.hoverAnchor=void 0,this.store.hover=void 0,t.type){case bt.Add:t.pens.forEach(s=>{var c;const a=ct(s,!0),l=this.store.data.pens.findIndex(u=>u.id===a.id);l>-1&&((c=a.onDestroy)==null||c.call(a,this.store.pens[a.id]),this.store.data.pens.splice(l,1),this.store.pens[a.id]=void 0,a.calculative||(a.calculative={}),a.calculative.canvas=this,this.store.animates.delete(a),this.store.animateMap.delete(a))}),t.type=bt.Delete;break;case bt.Update:const n=i?t.initPens:t.pens,r=i?t.pens:t.initPens;n.forEach(s=>{const a=ct(s,!0),l=this.store.data.pens.findIndex(c=>c.id===a.id);if(l>-1){if(a.calculative=this.store.data.pens[l].calculative,this.store.data.pens[l].type&&this.store.data.pens[l].lastConnected){for(let u in this.store.data.pens[l].lastConnected)if(this.store.pens[u]){let h=ct(this.store.data.pens[l].lastConnected[u]);this.store.pens[u].connectedLines=h,a.anchors.forEach(d=>{h.forEach(g=>{d.id===g.lineAnchor&&(d.connectTo=u)})})}}this.store.data.pens[l]=a,this.store.pens[a.id]=a;for(const u in a)(typeof a[u]!="object"||u==="lineDash")&&(a.calculative[u]=a[u]);a.calculative.image=void 0;const c=this.getPenRect(a,t.origin,t.scale);if(this.setPenRect(a,c,!1),this.updateLines(a,!0),a.calculative.canvas.parent.isCombine(a)){let u=r.find(h=>h.id===a.id);_v.forEach(h=>{a[h]!==u[h]&&this.parent.setValue({id:a.id,[h]:a[h]},{render:!0,doEvent:!1})})}}});break;case bt.Delete:t.pens.reverse().forEach(s=>{var l,c;const a=ct(s,!0);if(a.calculative||(a.calculative={}),this.store.data.pens.splice(((l=a.calculative)==null?void 0:l.layer)!==-1?(c=a.calculative)==null?void 0:c.layer:this.store.data.pens.length,0,a),this.store.pens[a.id]=a,a.type&&a.lastConnected)for(let u in a.lastConnected)this.store.pens[u]&&(this.store.pens[u].connectedLines=a.lastConnected[u]);a.calculative.canvas=this}),t.pens.reverse().forEach(s=>{const a=this.store.pens[s.id],l=this.getPenRect(a,t.origin,t.scale);this.setPenRect(a,l,!1),a.calculative.image=void 0,a.calculative.backgroundImage=void 0,a.calculative.strokeImage=void 0,this.loadImage(a)}),t.type=bt.Add;break;case bt.Replace:{const s=i?t.initPens:t.pens;(i?t.pens:t.initPens).forEach(l=>{var h;const c=ct(l,!0);if(this.store.data.pens.findIndex(d=>d.id===c.id)>-1){(h=c.onDestroy)==null||h.call(c,this.store.data.pens.find(g=>g.id===c.id));const d=this.store.data.pens.findIndex(g=>g.id===c.id);this.store.data.pens.splice(d,1),this.store.pens[c.id]=void 0,c.calculative||(c.calculative={}),c.calculative.canvas=this,this.store.animates.delete(c),this.store.animateMap.delete(c)}}),s.reverse().forEach(l=>{var u,h;const c=ct(l,!0);if(c.calculative||(c.calculative={}),this.store.data.pens.splice(((u=c.calculative)==null?void 0:u.layer)!==-1?(h=c.calculative)==null?void 0:h.layer:this.store.data.pens.length,0,c),this.store.pens[c.id]=c,c.type&&c.lastConnected)for(let d in c.lastConnected)this.store.pens[d]&&(this.store.pens[d].connectedLines=c.lastConnected[d]);c.calculative.canvas=this}),s.reverse().forEach(l=>{const c=this.store.data.pens.find(h=>h.id===l.id),u=this.getPenRect(c,t.origin,t.scale);this.setPenRect(c,u,!1),c.calculative.image=void 0,c.calculative.backgroundImage=void 0,c.calculative.strokeImage=void 0,this.loadImage(c)}),t.type=bt.Replace;break}}if(t.type===bt.Update){let n=[...t.pens,...t.initPens];this.initImageCanvas(n),this.initTemplateCanvas(n)}else this.initImageCanvas(t.pens),this.initTemplateCanvas(t.pens);this.parent.onSizeUpdate(),this.render(),this.store.emitter.emit(i?"undo":"redo",t)}makePen(t){var r;if(t.id||(t.id=It()),Math.abs(this.store.lastScale-this.store.data.scale)<1e-4&&this.store.sameTemplate&&this.store.templatePens[t.id]&&t.canvasLayer===zt.CanvasTemplate){t=this.store.templatePens[t.id],this.store.data.pens.push(t),this.updatePenRect(t);return}if(this.store.data.pens.push(t),this.store.pens[t.id]=t,t.path){!t.pathId&&(t.pathId=It());const s=this.store.data.paths;!s[t.pathId]&&(s[t.pathId]=t.path),t.path=void 0}t.lineWidth==null&&(t.lineWidth=1);const{fontSize:i,lineHeight:n}=this.store.options;t.fontSize?t.fontSize<0&&(t.fontSize=0):t.fontSize=i>=0?i:12,t.lineHeight||(t.lineHeight=n),t.image&&t.name!=="gif"&&t.canvasLayer===void 0&&(t.isBottom?t.canvasLayer=zt.CanvasImageBottom:t.canvasLayer=zt.CanvasImage,delete t.isBottom),t.template&&(t.canvasLayer=zt.CanvasTemplate),t.calculative={canvas:this,singleton:(r=t.calculative)==null?void 0:r.singleton},(t.video||t.audio)&&(t.calculative.onended=s=>{this.nextAnimate(s)});for(const s in t)(typeof t[s]!="object"||s==="lineDash")&&(t.calculative[s]=t[s]);if(t.calculative.image=void 0,t.calculative.backgroundImage=void 0,t.calculative.strokeImage=void 0,!t.anchors&&At.anchors[t.name]&&(t.anchors||(t.anchors=[]),At.anchors[t.name](t)),!t.anchors){const s=ct(this.store.options.defaultAnchors);s.forEach((a,l)=>{a.id=`${l}`,a.penId=t.id}),t.anchors=s}this.updatePenRect(t),!t.anchors&&t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(s=>hs(s,t.calculative.worldRect))),!t.rotate&&(t.rotate=0),this.loadImage(t),this.parent.penNetwork(t)}drawline(t){var i;!this.drawingLine||((i=this[this.drawingLineName])==null||i.call(this,this.store,this.drawingLine,t),this.store.path2dMap.set(this.drawingLine,At.path2dDraws.line(this.drawingLine)),this.patchFlags=!0)}initLineRect(t){var s;if(!t)return;if(!((s=t.calculative.worldAnchors)!=null&&s.length)){this._del([t]);return}if(!isFinite(t.x)||!isFinite(t.x)||t.x==null||t.y==null)return;const i=bc(t);t.parentId||Object.assign(t,i);const{fontSize:n,lineHeight:r}=this.store.options;t.fontSize||(t.fontSize=n>=0?n:12,t.calculative.fontSize=t.fontSize*this.store.data.scale),t.lineHeight||(t.lineHeight=r,t.calculative.lineHeight=t.lineHeight),ee(i),t.calculative.worldRect=i,Fc(t,i),Ti(t),Gi(t),t.calculative&&(t.calculative.gradientAnimatePath=void 0),this.store.path2dMap.set(t,At.path2dDraws[t.name](t)),t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(a=>hs(a,t.calculative.worldRect)))}drawingPencil(){ng(this.store),this.pencil=!0,this.externalElements.style.cursor="crosshair"}stopPencil(){this.pencil=!1,this.pencilLine=void 0,this.externalElements.style.cursor="default"}async finishDrawline(t){if(!this.drawingLine)return;const i=le(this.drawingLine);let n=qt(this.drawingLine);if(n.isTemp&&(this.drawingLine.calculative.worldAnchors.pop(),n=qt(this.drawingLine)),!t&&(!n.connectTo&&this.drawingLine.calculative.worldAnchors.pop(),le(this.drawingLine)===this.drawingLine.calculative.activeAnchor)){this.drawingLine=void 0,this.render();return}if(!i.connectTo||!n.connectTo){if(this.store.options.disableEmptyLine){i.connectTo&&(this.store.pens[i.connectTo].connectedLines=this.store.pens[i.connectTo].connectedLines.filter(a=>a.lineId!==this.drawingLine.id)),this.drawingLine=void 0,this.render();return}}else if(this.store.options.disableRepeatLine&&this.store.data.pens.find(l=>{if(l.type){const c=le(l),u=qt(l);return Bf(c,i)&&Bf(u,n)}})){this.drawingLine=void 0,this.render();return}const r=bc(this.drawingLine);Object.assign(this.drawingLine,r),this.drawingLine.calculative.worldRect=r,this.drawingLine.calculative.activeAnchor=qt(this.drawingLine),this.store.activeAnchor=this.drawingLine.calculative.activeAnchor,(!this.beforeAddPens||await this.beforeAddPens([this.drawingLine]))&&(!this.beforeAddPen||this.beforeAddPen(this.drawingLine))&&(this.initLineRect(this.drawingLine),this.store.data.pens.push(this.drawingLine),this.store.pens[this.drawingLine.id]=this.drawingLine,this.store.emitter.emit("add",[this.drawingLine]),this.active([this.drawingLine]),this.pushHistory({type:bt.Add,pens:ct([this.drawingLine],!0)})),this.store.path2dMap.set(this.drawingLine,At.path2dDraws[this.drawingLine.name](this.drawingLine)),this.drawingLine=void 0,this.drawingLineName=void 0,this.render()}async finishPencil(){if(this.pencilLine){const t=_c(this.pencilLine.calculative.worldAnchors,10,0,this.pencilLine.calculative.worldAnchors.length-1);let i=le(this.pencilLine);t.unshift({id:i.id,penId:i.penId,x:i.x,y:i.y}),i=qt(this.pencilLine),t.push({id:i.id,penId:i.penId,x:i.x,y:i.y}),this.pencilLine.calculative.worldAnchors=mk(t),this.pencilLine.calculative.worldAnchors.length>1&&(this.pencilLine.calculative.pencil=!1,this.store.path2dMap.set(this.pencilLine,At.path2dDraws[this.pencilLine.name](this.pencilLine)),(!this.beforeAddPens||await this.beforeAddPens([this.pencilLine]))&&(!this.beforeAddPen||this.beforeAddPen(this.pencilLine))&&(this.initLineRect(this.pencilLine),this.store.data.pens.push(this.pencilLine),this.store.pens[this.pencilLine.id]=this.pencilLine,this.store.emitter.emit("add",[this.pencilLine]),this.active([this.pencilLine]),this.pushHistory({type:bt.Add,pens:ct([this.pencilLine],!0)}))),this.pencilLine=void 0,this.render()}}firefoxLoadSvg(t){const i=new Image,n=new XMLHttpRequest;n.open("GET",t.image,!0),n.onload=()=>{const a=new DOMParser().parseFromString(n.responseText,"text/xml").getElementsByTagName("svg")[0],{width:l,height:c}=t.calculative.worldRect;a.setAttribute("width",`${l}px`),a.setAttribute("height",`${c}px`);const h="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(new XMLSerializer().serializeToString(a))));i.src=h,i.onload=()=>{t.calculative.img=i,t.calculative.imgNaturalWidth=i.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=i.naturalHeight||t.iconHeight,At.htmlElements[t.image]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}},n.send()}loadImage(t){if(t.image!==t.calculative.image||!t.calculative.img){if(t.calculative.img=void 0,t.image)if(At.htmlElements[t.image]){const i=At.htmlElements[t.image];t.calculative.img=i,t.calculative.imgNaturalWidth=i.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=i.naturalHeight||t.iconHeight,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}else if(navigator.userAgent.includes("Firefox")&&t.image.endsWith(".svg"))this.firefoxLoadSvg(t);else{const i=new Image;i.crossOrigin=t.crossOrigin==="undefined"?void 0:t.crossOrigin||"anonymous",i.src=t.image,this.store.options.cdn&&!(t.image.startsWith("http")||t.image.startsWith("//")||t.image.startsWith("data:image"))&&(i.src=this.store.options.cdn+t.image),i.onload=()=>{t.calculative.img=i,t.calculative.imgNaturalWidth=i.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=i.naturalHeight||t.iconHeight,At.htmlElements[t.image]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}}t.calculative.image=t.image}if(t.backgroundImage!==t.calculative.backgroundImage){if(t.calculative.backgroundImg=void 0,t.backgroundImage)if(At.htmlElements[t.backgroundImage]){const i=At.htmlElements[t.backgroundImage];t.calculative.backgroundImg=i}else{const i=new Image;i.crossOrigin="anonymous",i.src=t.backgroundImage,this.store.options.cdn&&!(t.backgroundImage.startsWith("http")||t.backgroundImage.startsWith("//")||t.backgroundImage.startsWith("data:image"))&&(i.src=this.store.options.cdn+t.backgroundImage),i.onload=()=>{t.calculative.backgroundImg=i,At.htmlElements[t.backgroundImage]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}}t.calculative.backgroundImage=t.backgroundImage}if(t.strokeImage!==t.calculative.strokeImage){if(t.calculative.strokeImg=void 0,t.strokeImage)if(At.htmlElements[t.strokeImage]){const i=At.htmlElements[t.strokeImage];t.calculative.strokeImg=i}else{const i=new Image;i.crossOrigin="anonymous",i.src=t.strokeImage,this.store.options.cdn&&!(t.strokeImage.startsWith("http")||t.strokeImage.startsWith("//")||t.strokeImage.startsWith("data:image"))&&(i.src=this.store.options.cdn+t.strokeImage),i.onload=()=>{t.calculative.strokeImg=i,At.htmlElements[t.strokeImage]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&t.name!=="gif"&&this.templateImageLoaded()}}t.calculative.strokeImage=t.strokeImage}}imageLoaded(){this.imageTimer&&clearTimeout(this.imageTimer),this.imageTimer=setTimeout(()=>{this.canvasImage.init(),this.canvasImageBottom.init(),this.render()},100)}templateImageLoaded(){this.templateImageTimer&&clearTimeout(this.templateImageTimer),this.templateImageTimer=setTimeout(()=>{this.canvasTemplate.init(),this.render()},100)}setCalculativeByScale(t){const i=this.store.data.scale;t.calculative.lineWidth=t.lineWidth*i,t.calculative.fontSize=t.fontSize*i,t.fontSize<1&&t.fontSize>0&&(t.calculative.fontSize=t.fontSize*t.calculative.worldRect.height),t.calculative.iconSize=t.iconSize*i,t.calculative.iconWidth=t.iconWidth*i,t.calculative.iconHeight=t.iconHeight*i,t.calculative.iconLeft=t.iconLeft<1&&t.iconLeft>-1?t.iconLeft:t.iconLeft*i,t.calculative.iconTop=t.iconTop<1&&t.iconTop>-1?t.iconTop:t.iconTop*i,t.calculative.textWidth=t.textWidth<1&&t.textWidth>-1?t.textWidth:t.textWidth*i,t.calculative.textHeight=t.textHeight<1&&t.textHeight>-1?t.textHeight:t.textHeight*i,t.calculative.textLeft=t.textLeft<1&&t.textLeft>-1?t.textLeft*t.calculative.worldRect.width:t.textLeft*i,t.calculative.textTop=t.textTop<1&&t.textTop>-1?t.textTop*t.calculative.worldRect.height:t.textTop*i,t.type===jt.Line&&t.borderWidth&&(t.calculative.borderWidth=t.borderWidth*i)}updatePenRect(t,{worldRectIsReady:i,playingAnimate:n}={}){i?Da(t):Hv(t),n||this.setCalculativeByScale(t),Ir(t),zf(this.store.pens,t),Ti(t),Gi(t),At.path2dDraws[t.name]&&this.store.path2dMap.set(t,At.path2dDraws[t.name](t)),t.calculative.patchFlags=!0,this.patchFlags=!0,t.children&&t.children.forEach(r=>{const s=this.store.pens[r];s&&this.updatePenRect(s,{worldRectIsReady:!1})}),t.type&&this.initLineRect(t),t.calculative.gradientTimer&&clearTimeout(t.calculative.gradientTimer),t.calculative.gradientTimer=setTimeout(()=>{t.calculative.lineGradient&&(t.calculative.lineGradient=null),t.calculative.gradient&&(t.calculative.gradient=null),t.calculative.radialGradient&&(t.calculative.radialGradient=null),this.patchFlags=!0,t.calculative.gradientTimer=void 0},50)}translate(t=0,i=0){if(this.store.data.x+=t*this.store.data.scale,this.store.data.y+=i*this.store.data.scale,this.store.data.x=Math.round(this.store.data.x),this.store.data.y=Math.round(this.store.data.y),this.store.options.padding){let n=Xi(this.store.options.padding);const r=this.store.data.width||this.store.options.width,s=this.store.data.height||this.store.options.height;this.width<(r+n[1]+n[3])*this.store.data.scale&&(this.store.data.x+this.store.data.origin.x>n[3]*this.store.data.scale&&(this.store.data.x=n[3]*this.store.data.scale-this.store.data.origin.x),this.store.data.x+this.store.data.origin.x+r*this.store.data.scale<this.width-n[1]*this.store.data.scale&&(this.store.data.x=this.width-n[1]*this.store.data.scale-(this.store.data.origin.x+r*this.store.data.scale))),this.height<(s+n[0]+n[2])*this.store.data.scale&&(this.store.data.y+this.store.data.origin.y>n[0]*this.store.data.scale&&(this.store.data.y=n[0]*this.store.data.scale-this.store.data.origin.y),this.store.data.y+this.store.data.origin.y+s*this.store.data.scale<this.height-n[2]*this.store.data.scale&&(this.store.data.y=this.height-n[2]*this.store.data.scale-(this.store.data.origin.y+s*this.store.data.scale)))}this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init(),this.render(),this.store.emitter.emit("translate",{x:this.store.data.x,y:this.store.data.y}),this.tooltip.translate(t,i),this.scroll&&this.scroll.isShow&&this.scroll.translate(t,i),this.onMovePens()}onMovePens(){var i;const t=this.parent.map;t&&t.isShow&&t.setView();for(const n of this.store.data.pens)Gi(n),(i=n.onMove)==null||i.call(n,n),n.isRuleLine&&(n.width?n.height||(n.x=-this.store.data.x):n.y=-this.store.data.y,this.updatePenRect(n))}scale(t,i={x:0,y:0}){var l;const n=this.store.data.minScale||this.store.options.minScale,r=this.store.data.maxScale||this.store.options.maxScale;if(!(t>=n&&t<=r))return;this.calibrateMouse(i);const s=t/this.store.data.scale;this.store.data.scale=t,this.store.data.center=i,(l=this.store.clipboard)!=null&&l.pos&&Wa(this.store.clipboard.pos,s,i),Wa(this.store.data.origin,s,i),this.store.data.pens.forEach(c=>{if(!c.parentId){if(br(c,s,i),c.onScale&&c.onScale(c),c.isRuleLine){const u=1/s,h=c.calculative.worldRect.center;c.width&&c.height||br(c,u,h)}this.updatePenRect(c,{worldRectIsReady:!0}),this.execPenResize(c)}}),this.onMovePens(),this.calcActiveRect(),this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init();const a=this.parent.map;a&&a.isShow&&a.setView(),this.render(),this.store.emitter.emit("scale",this.store.data.scale)}templateScale(t,i={x:0,y:0}){const{minScale:n,maxScale:r}=this.store.options;if(!(t>=n&&t<=r))return;const s=t/this.store.data.scale;this.store.data.scale=t,this.store.data.center={x:0,y:0},this.store.data.origin={x:0,y:0},this.store.data.pens.forEach(a=>{if(!a.parentId){if(br(a,s,i),a.onScale&&a.onScale(a),a.isRuleLine){const l=s>1?1:1/s/s,c=a.calculative.worldRect.center;a.width&&a.height||br(a,l,c)}this.execPenResize(a)}}),this.calcActiveRect()}rotatePens(t){this.initPens||(this.initPens=ct(this.getAllByPens(this.store.active))),this.activeRect.rotate=hi(t,this.activeRect.center),this.activeRect.rotate%90<10&&(this.activeRect.rotate-=this.activeRect.rotate%90),this.activeRect.rotate%90>80&&(this.activeRect.rotate+=90-this.activeRect.rotate%90),this.store.active.length===1&&(this.lastRotate=this.store.active[0].rotate||0);const i=this.activeRect.rotate-this.lastRotate;for(const n of this.store.active){if(n.parentId)return;this.rotatePen(n,i,this.activeRect),n.onRotate&&n.onRotate(n),this.updateLines(n)}this.lastRotate=this.activeRect.rotate,this.getSizeCPs(),this.initImageCanvas(this.store.active),this.initTemplateCanvas(this.store.active),this.render(),this.store.emitter.emit("rotatePens",this.store.active),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ct(this.getAllByPens(this.store.active)),initPens:this.initPens}),this.initPens=void 0},200)}resizePens(t){if(this.initPens||(this.initPens=ct(this.store.active,!0)),!this.initActiveRect){this.initActiveRect=ct(this.activeRect);return}const i={x:this.mouseDown.x,y:this.mouseDown.y},n={x:t.x,y:t.y};let r=n.x-i.x,s=n.y-i.y;const a=ct(this.initActiveRect);if(Yf(a,r,s,this.resizeIndex),ee(a),!this.store.options.disableDock){this.clearDock();const v=this.customResizeDock||w2;this.dock=v(this.store,a,this.store.active,this.resizeIndex);const{xDock:y,yDock:w}=this.dock;if(y){r+=y.step;const p=this.store.pens[y.penId];p.calculative.isDock=!0}if(w){s+=w.step;const p=this.store.pens[w.penId];p.calculative.isDock=!0}}const l=this.activeRect.width,c=this.activeRect.height;let u=r-this.lastOffsetX,h=s-this.lastOffsetY;if(this.lastOffsetX=r,this.lastOffsetY=s,(t.ctrlKey||this.initPens.length===1&&this.initPens[0].ratio)&&(h=([1,3].includes(this.resizeIndex)?-1:1)*(u*c)/l),this.activeRect.ratio=this.initPens[0].ratio,Yf(this.activeRect,u,h,this.resizeIndex),this.store.options.strictScope){const v=this.store.data.width||this.store.options.width,y=this.store.data.height||this.store.options.height;if(v&&y){let w={x:this.store.data.origin.x,y:this.store.data.origin.y,width:v*this.store.data.scale,height:y*this.store.data.scale};this.activeRect.x<w.x&&(this.activeRect.width=this.activeRect.width-(w.x-this.activeRect.x),this.activeRect.x=w.x),this.activeRect.y<w.y&&(this.activeRect.height=this.activeRect.height-(w.y-this.activeRect.y),this.activeRect.y=w.y),this.activeRect.x+this.activeRect.width>w.x+w.width&&(this.activeRect.width=this.activeRect.width-(this.activeRect.x+this.activeRect.width-(w.x+w.width)),this.activeRect.x=w.x+w.width-this.activeRect.width,this.activeRect.ex=this.activeRect.x+this.activeRect.width),this.activeRect.y+this.activeRect.height>w.y+w.height&&(this.activeRect.height=this.activeRect.height-(this.activeRect.y+this.activeRect.height-(w.y+w.height)),this.activeRect.y=w.y+w.height-this.activeRect.height,this.activeRect.ey=this.activeRect.y+this.activeRect.height)}}ee(this.activeRect);const d=this.activeRect.width/l,g=this.activeRect.height/c;this.store.active.forEach((v,y)=>{v.calculative.worldRect.x=this.activeInitPos[y].x*this.activeRect.width+this.activeRect.x,v.calculative.worldRect.y=this.activeInitPos[y].y*this.activeRect.height+this.activeRect.y,v.calculative.worldRect.width*=d,v.calculative.iconWidth&&(v.calculative.iconWidth*=d),v.calculative.worldRect.height*=g,v.calculative.iconHeight&&(v.calculative.iconHeight*=g),ae(v.calculative.worldRect),ee(v.calculative.worldRect),this.updatePenRect(v,{worldRectIsReady:!0}),this.execPenResize(v),this.updateLines(v)}),this.getSizeCPs(),this.initImageCanvas(this.store.active),this.initTemplateCanvas(this.store.active),this.render(),this.store.emitter.emit("resizePens",this.store.active),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ct(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},200)}movePens(t){var l,c;if(!this.activeRect||this.store.data.locked)return;if(!this.initActiveRect){this.initActiveRect=ct(this.activeRect);return}if(!this.store.options.moveConnectedLine&&!this.canMoveLine&&this.store.active.length===1&&(((l=this.store.active[0].anchors[0])==null?void 0:l.connectTo)||((c=this.store.active[0].anchors[this.store.active[0].anchors.length-1])==null?void 0:c.connectTo))||(this.movingPens||(this.initMovingPens(),this.store.active.forEach(u=>{rs(u,!1)}),this.store.hover=void 0),!this.mouseDown))return;let i=t.x-this.mouseDown.x,n=t.y-this.mouseDown.y;t.shiftKey&&!t.ctrlKey&&(n=0),t.ctrlKey&&(i=0);const r=ct(this.initActiveRect);Hn(r,i,n);let s=!1;if(this.store.options.strictScope){const u=this.store.data.width||this.store.options.width,h=this.store.data.height||this.store.options.height;if(u&&h){let d={x:this.store.data.origin.x,y:this.store.data.origin.y,width:u*this.store.data.scale,height:h*this.store.data.scale};r.x<d.x&&(r.x=d.x,s=!0),r.y<d.y&&(r.y=d.y,s=!0),r.x+r.width>d.x+d.width&&(r.x=d.x+d.width-r.width,s=!0),r.y+r.height>d.y+d.height&&(r.y=d.y+d.height-r.height,s=!0)}}const a={x:r.x-this.activeRect.x,y:r.y-this.activeRect.y};if(!this.store.options.disableDock&&!s){this.clearDock();const u=this.customMoveDock||p2;this.dock=u(this.store,r,this.movingPens,a);const{xDock:h,yDock:d}=this.dock;let g;h&&(a.x+=h.step,g=this.store.pens[h.penId],g.calculative.isDock=!0),d&&(a.y+=d.step,g=this.store.pens[d.penId],g.calculative.isDock=!0)}this.translatePens(this.movingPens,a.x,a.y,!0)}changeIdsByMoving(t,i){t.id+=Fe,t.parentId&&i.find(n=>n.id===t.parentId)&&(t.parentId+=Fe),t.children&&(t.children=t.children.map(n=>n+Fe)),t.connectedLines&&(t.connectedLines=t.connectedLines.map(n=>(i.find(r=>r.id===n.lineId)&&(n.lineId+=Fe),n))),t.type&&t.calculative.worldAnchors&&(t.calculative.worldAnchors=t.calculative.worldAnchors.map(n=>(n.connectTo&&i.find(r=>r.id===n.connectTo)&&(n.connectTo+=Fe),n)))}initMovingPens(){var n,r;if(!this.store.options.moveConnectedLine&&!this.canMoveLine)for(let s=0;s<this.store.active.length;s++){const a=this.store.active[s];(((n=a.anchors[0])==null?void 0:n.connectTo)||((r=a.anchors[a.anchors.length-1])==null?void 0:r.connectTo))&&(this.store.active.splice(s,1),a.calculative.active=void 0,--s)}this.movingPens=ct(this.store.active,!0),this.movingPens=this.getAllFollowersByPens(this.movingPens);const t=this.getAllByPens(this.movingPens),i=ct(t,!0);t.forEach(s=>{this.changeIdsByMoving(s,i),this.store.pens[s.id]=s,s.calculative.canvas=this;const a={globalAlpha:.5};s.lineWidth===0&&(a.lineWidth=1),(s.name.endsWith("Dom")||s_.includes(s.name)||this.store.options.domShapes.includes(s.name)||s.image)&&(a.name="rectangle",a.onDestroy=void 0),this.updateValue(s,a),s.calculative.image=void 0})}moveLineAnchor(t,i){var l,c,u,h,d;if(!this.activeRect||this.store.data.locked)return;if(this.initPens||(this.initPens=ct(this.store.active,!0)),(l=this.store.activeAnchor)!=null&&l.connectTo){const g=this.store.pens[this.store.activeAnchor.connectTo];Tr(g,Fn(g,this.store.activeAnchor.anchorId),this.store.pens[this.store.activeAnchor.penId],this.store.activeAnchor)}let n=(c=this.store.activeAnchor)==null?void 0:c.id,r=(h=(u=this.store.pens[this.store.activeAnchor.penId])==null?void 0:u.connectedLines)==null?void 0:h.filter(g=>g.anchor===n);r&&r.length>0&&r.forEach(g=>{const v=this.store.pens[g.lineId];Tr(this.store.pens[this.store.activeAnchor.penId],this.store.activeAnchor,v,Fn(v,g.lineAnchor))});const s=this.store.active[0];le(s);const a=qt(s);if(s.lineName==="polyline"&&!i.shiftKey)yk(s,this.store.activeAnchor,t);else{let g=0,v=0;if(s.lineName==="line"){let y=s.calculative.worldAnchors.findIndex(p=>p.id===this.store.activeAnchor.id);y===0&&(y=2);let w=s.calculative.worldAnchors[y-1];if(i.ctrlKey&&i.shiftKey){let p=ct(t);this.getSpecialAngle(p,w),g=p.x-this.store.activeAnchor.x,v=p.y-this.store.activeAnchor.y}else if(!i.ctrlKey&&i.shiftKey){let p={x:t.x,y:w.y};g=p.x-this.store.activeAnchor.x,v=p.y-this.store.activeAnchor.y}else if(i.ctrlKey&&!i.shiftKey){let p={x:w.x,y:t.y};g=p.x-this.store.activeAnchor.x,v=p.y-this.store.activeAnchor.y}else g=t.x-this.store.activeAnchor.x,v=t.y-this.store.activeAnchor.y}else!i.ctrlKey&&i.shiftKey?(g=t.x-this.store.activeAnchor.x,v=0):i.ctrlKey&&!i.shiftKey?(g=0,v=t.y-this.store.activeAnchor.y):(g=t.x-this.store.activeAnchor.x,v=t.y-this.store.activeAnchor.y);ls(this.store.activeAnchor,g,v),this.store.hover&&this.store.hoverAnchor&&this.store.hoverAnchor.penId!==this.store.activeAnchor.penId&&(this.store.hoverAnchor.type===Ki.Line?(g=t.x-this.store.activeAnchor.x,v=t.y-this.store.activeAnchor.y,wa(this.store.activeAnchor,this.store.hoverAnchor,this.store)):(g=this.store.hoverAnchor.x-this.store.activeAnchor.x,v=this.store.hoverAnchor.y-this.store.activeAnchor.y),ls(this.store.activeAnchor,g,v),a.prev=void 0,s.lineName!=="polyline"&&((d=this[s.lineName])==null||d.call(this,this.store,s)))}this.patchFlagsLines.add(s),this.store.path2dMap.set(s,At.path2dDraws[s.name](s)),this.render(),this.store.active[0].calculative&&(this.store.active[0].calculative.gradientAnimatePath=void 0),this.store.emitter.emit("moveLineAnchor",{pen:this.store.active[0],anchor:this.store.activeAnchor}),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ct(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},500)}moveLineAnchorPrev(t){if(!this.activeRect||this.store.data.locked||!this.store.activeAnchor)return;if(this.initPens||(this.initPens=ct(this.store.active,!0)),this.store.activeAnchor.prev.x=t.x,this.store.activeAnchor.prev.y=t.y,this.store.activeAnchor.next){if(!this.store.activeAnchor.prevNextType)this.store.activeAnchor.next.x=t.x,this.store.activeAnchor.next.y=t.y,Gt(this.store.activeAnchor.next,180,this.store.activeAnchor);else if(this.store.activeAnchor.prevNextType===jn.Bilateral&&this.prevAnchor){const n=hi(t,this.store.activeAnchor),r=hi(this.prevAnchor,this.store.activeAnchor);this.store.activeAnchor.next.x=this.nextAnchor.x,this.store.activeAnchor.next.y=this.nextAnchor.y,Gt(this.store.activeAnchor.next,n-r,this.store.activeAnchor)}}const i=this.store.active[0];this.patchFlagsLines.add(i),this.store.path2dMap.set(i,At.path2dDraws[i.name](i)),this.render(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ct(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},200)}moveLineAnchorNext(t){if(!this.activeRect||this.store.data.locked||!this.store.activeAnchor)return;if(this.initPens||(this.initPens=ct(this.store.active,!0)),this.store.activeAnchor.next.x=t.x,this.store.activeAnchor.next.y=t.y,this.store.activeAnchor.prev){if(!this.store.activeAnchor.prevNextType)this.store.activeAnchor.prev.x=t.x,this.store.activeAnchor.prev.y=t.y,Gt(this.store.activeAnchor.prev,180,this.store.activeAnchor);else if(this.store.activeAnchor.prevNextType===jn.Bilateral&&this.nextAnchor){const n=hi(t,this.store.activeAnchor),r=hi(this.nextAnchor,this.store.activeAnchor);this.store.activeAnchor.prev.x=this.prevAnchor.x,this.store.activeAnchor.prev.y=this.prevAnchor.y,Gt(this.store.activeAnchor.prev,n-r,this.store.activeAnchor)}}const i=this.store.active[0];this.patchFlagsLines.add(i),this.store.path2dMap.set(i,At.path2dDraws[i.name](i)),this.render(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ct(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},200)}async setAnchor(t){var r;const i=[ct(this.store.hover,!0)],n=this.store.hover;if(this.store.hoverAnchor){if(this.beforeRemoveAnchor&&!await this.beforeRemoveAnchor(n,this.store.hoverAnchor))return;n.type===jt.Line&&((r=n.calculative.worldAnchors)==null?void 0:r.length)<=2?this.delete([n]):(l2(n,this.store.hoverAnchor),n.type===jt.Line&&this.initLineRect(n)),this.store.hoverAnchor=void 0,this.store.activeAnchor=void 0,this.externalElements.style.cursor="default"}else if(n){if(this.beforeAddAnchor&&!await this.beforeAddAnchor(n,this.store.pointAt))return;if(n.type===jt.Line){this.store.activeAnchor=o2(n,this.store.pointAt,this.store.pointAtIndex),this.initLineRect(n);const s={x:t.x,y:t.y};this.getHover(s)}else{const s={id:It(),x:t.x,y:t.y};this.store.activeAnchor=a2(n,s)}}this.hotkeyType=Kt.None,this.render(),n&&this.pushHistory({type:bt.Update,pens:[ct(n,!0)],initPens:i})}checkDisconnect(t,i){if(t.id.indexOf(Fe)>0){const n=t.id;t=this.store.pens[n.replace(Fe,"")]}t.anchors.forEach(n=>{if(n.connectTo&&!i.find(r=>r.id===n.connectTo||r.id===n.connectTo+Fe)){const r=this.store.pens[n.connectTo];if(!r||r.type)return;Tr(r,Fn(r,n.anchorId),t,n)}})}translatePens(t=this.store.active,i,n,r){if(!t||!t.length||t.some(c=>{if(c.locked>=Ot.DisableMove)return!0}))return;const a=!r&&ct(t,!0);this.activeRect&&Hn(this.activeRect,i,n);const l=this.getAllByPens(t);t.forEach(c=>{var u,h;if(!(c.locked>=Ot.DisableMove)){if(c.type===jt.Line){if(!this.store.options.moveConnectedLine&&!this.canMoveLine||c.isRuleLine)return;Hf(c,i,n),this.checkDisconnect(c,l),this.store.path2dMap.set(c,At.path2dDraws[c.name](c)),r||(this.initLineRect(c),(u=c.connectedLines)==null||u.forEach(d=>{const g=this.store.pens[d.lineId];this.initLineRect(g)}))}else Hn(c.calculative.worldRect,i,n),this.updatePenRect(c,{worldRectIsReady:!0}),c.calculative.x=c.x,c.calculative.y=c.y,c.calculative.initRect&&(c.calculative.initRect.x=c.calculative.x,c.calculative.initRect.y=c.calculative.y,c.calculative.initRect.ex=c.calculative.x+c.calculative.width,c.calculative.initRect.ey=c.calculative.y+c.calculative.height);this.updateLines(c),(h=c.onMove)==null||h.call(c,c)}}),this.activeRect&&this.getSizeCPs(),this.render(),this.tooltip.translate(i,n),r||(this.pushHistory({type:bt.Update,pens:ct(t,!0),initPens:a}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.store.emitter.emit("translatePens",t)),this.store.emitter.emit("translatingPens",t)}templateTranslatePens(t=this.store.active,i,n){if(!t||!t.length)return;const r=this.getAllByPens(t);t.forEach(s=>{var a;if(s.type===jt.Line){if(!this.store.options.moveConnectedLine&&!this.canMoveLine)return;Hf(s,i,n),this.checkDisconnect(s,r),this.store.path2dMap.set(s,At.path2dDraws[s.name](s))}else Hn(s.calculative.worldRect,i,n),this.updatePenRect(s,{worldRectIsReady:!0}),s.calculative.x=s.x,s.calculative.y=s.y,s.calculative.initRect&&(s.calculative.initRect.x=s.calculative.x,s.calculative.initRect.y=s.calculative.y,s.calculative.initRect.ex=s.calculative.x+s.calculative.width,s.calculative.initRect.ey=s.calculative.y+s.calculative.height);(a=s.onMove)==null||a.call(s,s)})}calcAutoAnchor(t,i,n,r){const s=le(t),a=qt(t),l=Cr(n,i===s?a:s);!l||(i.x=l.x,i.y=l.y,i.prev=void 0,i.next=void 0,r?r.anchor=l.id:we(n,l,t,i),this[t.lineName]&&this[t.lineName](this.store,t),this.store.path2dMap.set(t,At.path2dDraws.line(t)),this.initLineRect(t))}restoreNodeAnimate(t){var i,n;if(t.calculative.initRect){if(t.keepAnimateState)for(const r in t)t.calculative[r]!==void 0&&r!=="x"&&r!=="y"&&r!=="width"&&r!=="height"&&r!=="initRect"&&(typeof t[r]!="object"||r==="lineDash")&&(r==="fontSize"||r==="lineWidth"?t[r]=t.calculative[r]/t.calculative.canvas.store.data.scale:t[r]=t.calculative[r]);else{const r=t.calculative.initRect.rotate-t.calculative.rotate;for(const a in t)a!=="x"&&a!=="y"&&a!=="width"&&a!=="height"&&a!=="initRect"&&a!=="rotate"&&(typeof t[a]!="object"||a==="lineDash")&&(t.calculative[a]=t[a]);(i=t.children)!=null&&i.length?r&&qv(t,r,t.calculative.worldRect):t.calculative.rotate=t.rotate;const s=ct(this.store.animateMap.get(t));s&&(s.id=t.id,this.parent.setValue(s,{doEvent:!1,render:!0,history:!1})),t.calculative.worldRect=t.calculative.initRect}this.updatePenRect(t,{worldRectIsReady:!0}),this.updateLines(t),t.image&&t.name!=="gif"&&(this.canvasImage.init(),this.canvasImageBottom.init()),t.calculative.text!==t.text&&(t.calculative.text=t.text,Es(t)),(n=this.store.active)!=null&&n.length&&this.calcActiveRect(),t.calculative.initRect=void 0}}updateLines(t,i){var n;(n=t.children)==null||n.forEach(r=>{const s=this.store.pens[r];s&&this.updateLines(s,i)}),t.connectedLines&&t.connectedLines.forEach((r,s)=>{const a=this.store.pens[r.lineId];if(!a||a.calculative.active)return;const l=Fn(a,r.lineAnchor);if(!l)return;if(!l.connectTo){t.connectedLines.splice(s,1);return}if(a.autoFrom){const g=le(a);g.id===l.id&&this.calcAutoAnchor(a,g,t,r)}if(a.autoTo){const g=qt(a);g.id===l.id&&this.calcAutoAnchor(a,g,t,r)}const c=Fn(t,r.anchor);if(!c)return;let u=t.rotate;t.flipX&&(u*=-1),t.flipY&&(u*=-1);let h=l.distance*this.store.data.scale*Math.cos((u+c.rotate)/180*Math.PI)||0,d=l.distance*this.store.data.scale*Math.sin((u+c.rotate)/180*Math.PI)||0;if(t.flipX&&(h=-h),t.flipY&&(d=-d),ls(l,c.x-l.x+h,c.y-l.y+d),this.store.options.autoPolyline&&!this.autoPolylineFlag&&a.autoPolyline!==!1&&a.lineName==="polyline"){let g=le(a),v=qt(a),y=!1;g.id===l.id?(g=l,y=!0):v.id===l.id&&(v=l,y=!0),y&&(a.calculative.worldAnchors=[g,v],a.calculative.activeAnchor=g,this.polyline(this.store,a,v),this.initLineRect(a))}this.store.path2dMap.set(a,At.path2dDraws[a.name](a)),this.patchFlagsLines.add(a),a.calculative.gradientSmooth&&(a.calculative.gradientAnimatePath=Nc(a)),i&&xc(a)})}calcActiveRect(){const t=this.store.active.filter(i=>(!i.locked||i.locked<Ot.DisableMove)&&i.visible!=!1);if(t.length)t.length===1?(this.activeRect=ct(t[0].calculative.worldRect),this.activeRect.rotate=t[0].calculative.rotate||0,ee(this.activeRect)):(this.activeRect=pi(t),this.activeRect.rotate=0);else return;this.lastRotate=0,this.getSizeCPs()}rotatePen(t,i,n){t.type?(t.calculative.worldAnchors.forEach(r=>{Gt(r,i,n.center)}),this.initLineRect(t),Da(t)):(t.calculative.rotate?t.calculative.rotate+=i:t.calculative.rotate=i,Gt(t.calculative.worldRect.center,i,n.center),t.parentId?(t.calculative.worldRect.x=t.calculative.worldRect.center.x-t.calculative.worldRect.width/2,t.calculative.worldRect.y=t.calculative.worldRect.center.y-t.calculative.worldRect.height/2,t.x=(t.calculative.worldRect.x-n.x)/n.width,t.y=(t.calculative.worldRect.y-n.y)/n.height):(t.x=t.calculative.worldRect.center.x-t.width/2,t.y=t.calculative.worldRect.center.y-t.height/2),t.rotate=t.calculative.rotate,this.updatePenRect(t),t.children&&t.children.forEach(r=>{const s=this.store.pens[r];this.rotatePen(s,i,t.calculative.worldRect)}))}nextAnimate(t){if(!t)return;this.store.emitter.emit("animateEnd",t);let i;t.nextAnimate&&(i=this.store.data.pens.filter(n=>n.id===t.nextAnimate||n.tags&&n.tags.indexOf(t.nextAnimate)>-1)),i&&(i.forEach(n=>{var r,s,a,l,c;if(n.calculative.pause){const u=Date.now()-n.calculative.pause;n.calculative.pause=void 0,n.calculative.frameStart+=u,n.calculative.frameEnd+=u}else if(n.name==="video")n.calculative.media.currentTime=0,(r=n.calculative.media)==null||r.play(),(s=n.onStartVideo)==null||s.call(n,n);else if(n.type||((a=n.frames)==null?void 0:a.length)||n.animations&&n.animations.length){if(n.type){if((c=n.animations)!=null&&c.length){const u=ct(n.animations[0]);delete u.name,u.currentAnimation=0,this.parent.setValue({id:n.id,...u},{doEvent:!1,history:!1})}}else{if(!n.frames&&n.animations&&n.animations.length){let u=(l=n.animations)==null?void 0:l.findIndex(g=>g.autoPlay),h=u===-1?0:u;const d=ct(n.animations[h]);delete d.name,d.currentAnimation=h,!n.type&&d.frames&&(d.showDuration=this.parent.calcAnimateDuration(d)),this.parent.setValue({id:n.id,...d},{doEvent:!1,history:!1})}this.store.animateMap.set(n,this.getFrameProps(n))}this.store.animates.add(n)}}),this.animate())}getFrameProps(t){let i={};return t.frames&&t.frames.forEach(n=>{for(let r in n)!["duration","x","y","width","height","rotate"].includes(r)&&!i[r]&&(i[r]=t[r])}),i}animate(){this.animateRendering||requestAnimationFrame(()=>{const t=Date.now();if(t-this.lastAnimateRender<this.store.options.animateInterval){this.store.animates.size>0&&this.animate();return}this.lastAnimateRender=t,this.animateRendering=!0;const i=[];let n=!1;for(const r of this.store.animates)if(!r.calculative.pause){if(r.calculative.active&&!r.type&&!this.movingPens&&(n=!0),!r.type)c2(r,t)?r.calculative.patchFlags&&(ee(r.calculative.worldRect),this.updatePenRect(r,{worldRectIsReady:!0,playingAnimate:!0})):(requestAnimationFrame(()=>{this.restoreNodeAnimate(r)}),i.push(r),this.nextAnimate(r)),this.updateLines(r,!0);else if(!u2(r)){if(r.keepAnimateState){for(const s in r)r.calculative[s]!==void 0&&s!=="length"&&(typeof r[s]!="object"||s==="lineDash")&&(s==="lineWidth"?r[s]=r.calculative[s]/r.calculative.canvas.store.data.scale:r[s]=r.calculative[s]);Da(r)}else for(const s in r)(typeof r[s]!="object"||s==="lineDash")&&(s==="lineWidth"?r.calculative[s]=r[s]*r.calculative.canvas.store.data.scale:r.calculative[s]=r[s]);i.push(r),this.nextAnimate(r)}this.patchFlags=!0}n&&this.calcActiveRect(),i.forEach(r=>{this.store.animates.delete(r)}),this.render(!1),this.animateRendering=!1,this.animate()})}get clipboardName(){return"meta2d-clipboard"}async copy(t,i=!0){const n=It(),{origin:r,scale:s}=this.store.data;this.store.clipboard=void 0,localStorage.removeItem(this.clipboardName),sessionStorage.setItem("page",n);let a=this.getAllByPens(ct(t||this.store.active,!0));a.forEach(c=>{c.copyIndex=this.store.data.pens.findIndex(u=>u.id===c.id),c.pathId&&(c.path=this.store.data.paths[c.pathId])}),a.sort((c,u)=>c.copyIndex-u.copyIndex),a.forEach(c=>{delete c.copyIndex});const l={meta2d:!0,pens:a,origin:ct(r),scale:s,page:n,initRect:ct(this.activeRect),offset:10};if(navigator.clipboard&&!this.store.options.disableClipboard&&!navigator.userAgent.includes("Firefox"))try{await navigator.clipboard.writeText(JSON.stringify(l))}catch{localStorage.setItem(this.clipboardName,JSON.stringify(l))}else localStorage.setItem(this.clipboardName,JSON.stringify(l));i&&this.store.emitter.emit("copy",l.pens)}cut(t){this.copy(t,!1),this.delete(t),this.store.emitter.emit("cut",t)}async paste(){var l;let t,i;if(navigator.clipboard&&!this.store.options.disableClipboard&&!navigator.userAgent.includes("Firefox"))try{t=await((l=navigator.clipboard)==null?void 0:l.readText())}catch{t=localStorage.getItem(this.clipboardName)}else t=localStorage.getItem(this.clipboardName);if(t){try{i=JSON.parse(t)}catch(c){console.warn("\u526A\u5207\u677F\u6570\u636E\u4E0D\u662Fjson",c.message);return}if(!i||!i.meta2d)return}else return;if(this.beforeAddPens&&await this.beforeAddPens(i.pens)!=!0)return;let n,r;this.store.clipboard&&(n=this.store.clipboard.offset+10,r=this.store.clipboard.pos),this.store.clipboard=ct(i),sessionStorage.getItem("page")!==i.page?(this.store.clipboard.pos={x:this.mousePos.x,y:this.mousePos.y},this.store.clipboard.offset=0):this.pasteOffset?(n&&(this.store.clipboard.offset=n),r&&(this.store.clipboard.pos=r)):(this.store.clipboard.offset=0,this.pasteOffset=!0);const a=this.store.clipboard.pens.filter(c=>!c.parentId);for(const c of a)this.pastePen(c,void 0);sessionStorage.setItem("page",i.page),this.active(a),this.pushHistory({type:bt.Add,pens:this.store.clipboard.pens}),this.render(),this.store.emitter.emit("add",this.store.clipboard.pens),this.store.emitter.emit("paste",this.store.clipboard.pens)}getAllByPens(t){const i=[];for(const n of t)i.push(...ct(Ci(n,this.store),!0));return i.concat(t)}getAllFollowersByPens(t,i=!0){const n=t;for(const r of t){let s=Bc(r,this.store);i&&(s=ct(s,!0));for(const a of s)n.find(l=>l.id===a.id)||n.push(a)}return n}setFollowers(t=this.store.active){if(!!t)if(t.length<2)t[0].followers=[];else{let i=t.map(r=>r.id);i.pop();const n=t[t.length-1];n.followers?i.forEach(r=>{n.followers.includes(r)||n.followers.push(r)}):n.followers=i}}changeLineAnchors(t,i,n){if(!!Array.isArray(i.connectedLines))for(let r=0;r<i.connectedLines.length;r++){const{lineId:s}=i.connectedLines[r],a=n.find(l=>l.id===s);if(a){const l=a.anchors[0],c=a.anchors[a.anchors.length-1];l.connectTo===t&&(l.connectTo=i.id),c.connectTo===t&&(c.connectTo=i.id)}else i.connectedLines.splice(r,1),r--}}changeNodeConnectedLine(t,i,n){var l;const r=i.anchors[0],s=i.anchors[i.anchors.length-1],a=[r,s];for(const c of a){const u=c.connectTo;if(u){const h=n.find(d=>d.id===u);h?(l=h.connectedLines)==null||l.forEach(d=>{d.lineId===t&&(d.lineId=i.id,d.lineAnchor=c.id)}):(c.connectTo=void 0,c.prev&&(c.prev.connectTo=void 0),c.next&&(c.next.connectTo=void 0))}}}async delete(t=this.store.active,i=!1,n=!0){if(!t||!t.length||this.beforeRemovePens&&await this.beforeRemovePens(t)!=!0||(i||(t=t.filter(s=>!s.locked)),!t||!t.length))return;const r=[];if(this._del(t,r,i),this.initImageCanvas(r),this.initTemplateCanvas(r),this.inactive(),this.clearHover(),this.render(),n){if(r.length===0)return;this.pushHistory({type:bt.Delete,pens:r})}this.store.emitter.emit("delete",t)}_del(t,i,n){!t||t.forEach(r=>{if(r.type&&(r.lastConnected={}),r.parentId)if(this.getLockedParent(r)){console.warn("\u7236\u8282\u70B9\u9501\u5B9A");return}else{const a=Ze(r),l=a.children.indexOf(r.id);a.children.splice(l,1),i&&this.getDelPens(r,i),this.delForce(r)}else{if(!n&&r.locked)return;i&&this.getDelPens(r,i),this.delForce(r)}})}getDelPens(t,i){if(!t)return;if(this.store.data.pens.findIndex(r=>r.id===t.id)>-1){const r=this.store.pens[t.id];r.calculative.active=void 0,i.push(r)}t.children&&t.children.forEach(r=>{this.getDelPens(this.store.pens[r],i)})}getLockedParent(t){if(!t.parentId)return!1;const i=Ze(t);if(i.locked)return i;this.getLockedParent(i)}delForce(t){var n;if(!t)return;const i=this.store.data.pens.findIndex(r=>r.id===t.id);i>-1&&(this.delConnectedLines(this.store.data.pens[i]),this.store.data.pens.splice(i,1),this.store.pens[t.id]=void 0,delete this.store.pens[t.id],t.pathId&&delete this.store.data.paths[t.pathId]),this.store.animates.delete(t),this.store.animateMap.delete(t),t.children&&t.children.forEach(r=>{this.delForce(this.store.pens[r])}),(n=t.onDestroy)==null||n.call(t,t)}delConnectedLines(t){var i;if(t.connectedLines)for(let n=0;n<t.connectedLines.length;n++){const{lineId:r,lineAnchor:s}=t.connectedLines[n],a=this.store.pens[r];if(a){let l=a.anchors.find(c=>c.id===s);(l==null?void 0:l.connectTo)===t.id&&(l.connectTo=void 0,l.anchorId=void 0,l.prev&&(l.prev.connectTo=void 0),l.next&&(l.next.connectTo=void 0)),l=Fn(a,s),l&&(l.connectTo=void 0,l.anchorId=void 0,l.prev&&(l.prev.connectTo=void 0),l.next&&(l.next.connectTo=void 0))}}!t.type||(i=t.calculative.worldAnchors)==null||i.forEach((n,r)=>{var a;if(!n.connectTo)return;const s=this.store.pens[n.connectTo];s&&((a=s.calculative.worldAnchors)==null||a.forEach(l=>{Tr(s,l,t,n)}))})}convertSpecialCharacter(t){var i={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"'};return t.replace(/&(lt|gt|nbsp|amp|quot);/gi,function(n,r){return i[r]})}createInput(){this.inputParent.classList.add("meta2d-input"),this.inputDiv.classList.add("input-div"),this.inputParent.appendChild(this.inputDiv),this.dropdown.onmouseleave=()=>{this.store.hover=null},this.inputParent.appendChild(this.dropdown),this.externalElements.appendChild(this.inputParent),this.inputParent.onmousedown=this.stopPropagation,this.inputDiv.onmousedown=this.stopPropagation,this.inputDiv.contentEditable="false",this.dropdown.onmousedown=this.stopPropagation;let t;for(let i=0;i<document.styleSheets.length;i++)document.styleSheets[i].title==="le5le.com"&&(t=document.styleSheets[i]);if(!t){const i=document.createElement("style");i.title="le5le.com",document.head.appendChild(i),t=i.sheet,t.insertRule(".meta2d-input{display:none;position:absolute;outline:none;align-items: center;}"),t.insertRule(".meta2d-input textarea{resize:none;border:none;outline:none;background:transparent;flex-grow:1;height:100%;left:0;top:0}"),t.insertRule(".meta2d-input .right{width:10px;height:10px;flex-shrink:0;border-top: 1px solid;border-right: 1px solid;margin-right: 5px;transition: all .3s cubic-bezier(.645,.045,.355,1);position:absolute;right:1px;}"),t.insertRule(".meta2d-input ul{position:absolute;top:100%;left:-5px;width:calc(100% + 10px);min-height:30px;border-radius: 2px;box-shadow: 0 2px 8px #00000026;list-style-type: none;background-color: #fff;padding: 4px 0;max-height: 105px;overflow-y: auto;}"),t.insertRule(".meta2d-input ul li{padding: 5px 12px;line-height: 22px;white-space: nowrap;cursor: pointer;}"),t.insertRule(".meta2d-input ul li:hover{background: #eeeeee;}"),t.insertRule(".input-div::-webkit-scrollbar {display:none}"),t.insertRule(".input-div{scrollbar-width: none;}"),t.insertRule(".meta2d-input .input-div{resize:none;border:none;outline:none;background:transparent;flex-grow:1;height:100%;width: 100%;left:0;top:0;display:flex;text-align: center;justify-content: center;flex-direction: column;}"),t.insertRule(".input-div div{}")}this.inputDiv.onfocus=i=>{if(navigator.userAgent.includes("Firefox")){if(!i.target.innerText){let n=this.inputDiv.offsetWidth/2;window.getComputedStyle(this.inputDiv,null).textAlign!=="center"&&(n=0),this.inputDiv.innerHTML=`<br style="margin-left:${n}px;margin-top:4px;" />`}}else if(i.target.innerText)this.inputDiv.style.paddingTop="";else{let n=window.getComputedStyle(this.inputDiv,null);n.justifyContent==="center"&&(this.inputDiv.style.paddingTop=` ${this.inputDiv.offsetHeight/2-parseFloat(n.lineHeight)/2}px`)}},this.inputDiv.onblur=()=>{setTimeout(()=>{this.hideInput()},300)},this.inputDiv.oninput=i=>{const n=this.store.pens[this.inputDiv.dataset.penId];if(n&&n.inputType==="number"){const r=i.target.innerText,s=r.replace(/[^0-9]/g,"");r!==s&&(i.preventDefault(),i.target.innerText=s)}if(navigator.userAgent.includes("Firefox")){if(!i.target.innerText.trim()){let r=this.inputDiv.offsetWidth/2;window.getComputedStyle(this.inputDiv,null).textAlign!=="center"&&(r=0),this.inputDiv.innerHTML=`<br style="margin-left:${r}px;margin-top:4px;" />`}}else if(i.target.innerText)this.inputDiv.style.paddingTop="";else{let r=window.getComputedStyle(this.inputDiv,null);r.justifyContent==="center"&&(this.inputDiv.style.paddingTop=` ${this.inputDiv.offsetHeight/2-parseFloat(r.lineHeight)/2}px`)}this.store.emitter.emit("input",n)},this.inputDiv.onclick=i=>{i.stopPropagation();const n=this.store.pens[this.inputDiv.dataset.penId];this.dropdown.style.display==="block"?this.dropdown.style.display="none":(n==null?void 0:n.dropdownList)&&this.store.data.locked&&(this.dropdown.style.display="block"),this.store.emitter.emit("clickInput",n)},this.inputDiv.onkeyup=i=>{this.setDropdownList(!0);const n=this.store.pens[this.inputDiv.dataset.penId];this.store.emitter.emit("input",{pen:n,text:i.key}),i.stopPropagation()},this.inputDiv.onkeydown=i=>{i.stopPropagation()},this.inputDiv.onmousedown=this.stopPropagation,this.inputDiv.onwheel=i=>{i.stopPropagation()},this.inputDiv.onpaste=i=>{i.preventDefault();let n="";i.clipboardData&&i.clipboardData.getData&&(n=i.clipboardData.getData("text/plain")),document.execCommand("insertHTML",!1,n)}}clearDropdownList(){if(this.dropdown.hasChildNodes())for(let t=0;t<this.dropdown.childNodes.length;t++)this.dropdown.childNodes[t].remove(),--t}dropdownAppendOption(t,i){const n=document.createElement("li");n.onwheel=this.stopPropagation,n.innerText=t,n.style.overflow="hidden",n.style.textOverflow="ellipsis",n.title=t,n.style.zoom=this.store.data.scale,n.onmousedown=this.stopPropagation,n.dataset.i=i+"",n.onclick=this.selectDropdown;const r=this.store.pens[this.inputDiv.dataset.penId];n.onmouseenter=()=>{n.style.background=r.dropdownHoverBackground||"#eee",n.style.color=r.dropdownHoverColor||"#bdc7db"},n.onmouseleave=()=>{n.style.background=r.dropdownBackground||"#fff",n.style.color=r.dropdownColor||"#bdc7db"},this.dropdown.appendChild(n)}find(t){return this.store.data.pens.filter(i=>i.id==t||i.tags&&i.tags.indexOf(t)>-1)}findOne(t){return this.store.data.pens.find(i=>i.id==t||i.tags&&i.tags.indexOf(t)>-1)}changePenId(t,i){var r,s,a,l,c,u,h;if(t===i)return;const n=this.store.pens[t];if(!!n&&!this.store.pens[i]){if(n.id=i,this.store.pens[i]=this.store.pens[t],(r=n.onChangeId)==null||r.call(n,n,t,i),delete this.store.pens[t],n.parentId){const d=this.store.pens[n.parentId],g=(s=d.children)==null?void 0:s.findIndex(v=>v===t);g!==-1&&((a=d.children)==null||a.splice(g,1,i))}(l=n.children)==null||l.forEach(d=>{const g=this.store.pens[d];g.parentId=i}),n.type===jt.Line?this.changeNodeConnectedLine(t,n,this.store.data.pens):(this.changeLineAnchors(t,n,this.store.data.pens),(c=n.connectedLines)==null||c.forEach(({lineId:d})=>{const g=this.store.pens[d];Ir(g)})),(u=n.anchors)==null||u.forEach(d=>d.penId=i),(h=n.calculative.worldAnchors)==null||h.forEach(d=>d.penId=i)}}updateValue(t,i){var y,w,p,_,A,x;const n=this.getPenRect(t),r=t.name;Object.assign(t,i);const s=r!==t.name;i.newId&&this.changePenId(t.id,i.newId);let a=!1,l=!1,c=!1,u=!1,h=!1,d=!1,g,v=!1;for(const E in i)E.indexOf(".")===-1?(E==="rotate"?t.disableRotate?t.rotate=t.calculative.rotate||0:g=t.calculative.rotate||0:E==="canvasLayer"||E==="isBottom"||E==="showChild"?d=!0:E==="image"&&(v=!0),(typeof t[E]!="object"||E==="lineDash")&&(!t.disableRotate||E!=="rotate")&&(t.calculative[E]=i[E]),e_.includes(E)&&(l=!0),["name","borderRadius","lineSmooth","close"].includes(E)&&(a=!0),i_.includes(E)&&(h=!0),n_.includes(E)&&(c=!0),r_.includes(E)&&(u=!0),t.image&&t.name!=="gif"&&["globalAlpha","flipY","flipX","x","y","width","height","iconWidth","iconHeight","imageRatio","iconLeft","iconTop","iconAlign","rotate"].includes(E)&&(v=!0)):(delete t[E],z_(t,E,i[E])),E.split(".")[0]==="anchors"&&Ir(t);if(this.setCalculativeByScale(t),s&&((y=t.onDestroy)==null||y.call(t,t),a_(t)),h){const E={x:(w=i.x)!=null?w:n.x,y:(p=i.y)!=null?p:n.y,width:(_=i.width)!=null?_:n.width,height:(A=i.height)!=null?A:n.height};this.setPenRect(t,E,!1),this.updateLines(t,!0),this.store.active&&this.store.active.length&&t.id===this.store.active[0].id&&this.calcActiveRect()}else c?this.updatePenRect(t):(l&&Ti(t),u&&zf(this.store.pens,t),a&&At.path2dDraws[t.name]&&this.store.path2dMap.set(t,At.path2dDraws[t.name](t)));if(g!==void 0){const E=t.calculative.rotate;t.calculative.rotate=g,this.rotatePen(t,E-g,t.calculative.worldRect)}(i.image||i.backgroundImage||i.strokeImage)&&(t.calculative.image=void 0,t.calculative.backgroundImage=void 0,t.calculative.strokeImage=void 0,this.loadImage(t)),i.lineGradientColors&&(t.calculative.lineGradient=void 0,t.calculative.gradientColorStop=void 0),i.gradientColors&&(t.calculative.gradient=void 0,t.calculative.radialGradient=void 0),i.gradientRadius&&(t.calculative.gradient=void 0,t.calculative.radialGradient=void 0),i.animateLineWidth&&(t.calculative.gradientAnimatePath=void 0),i.gradientSmooth&&(t.calculative.gradientAnimatePath=void 0),d?(this.canvasImage.init(),this.canvasImageBottom.init()):v&&(t.canvasLayer===void 0&&(t.canvasLayer=zt.CanvasImageBottom,t.calculative.canvasLayer=zt.CanvasImageBottom),t.canvasLayer===zt.CanvasImageBottom?this.canvasImageBottom.init():t.canvasLayer===zt.CanvasImage&&this.canvasImage.init()),(i.canvasLayer!==void 0||t.canvasLayer===zt.CanvasTemplate)&&this.initTemplateCanvas([t]),i.zIndex!==void 0&&(x=t.calculative.singleton)!=null&&x.div&&ti(t,t.calculative.singleton.div)}execPenResize(t){var i,n;(i=t.onResize)==null||i.call(t,t),(n=t.children)==null||n.forEach(r=>{const s=this.store.pens[r];s&&this.execPenResize(s)})}setPenRect(t,i,n=!0){if(t.parentId)Object.assign(t,i);else{const{origin:r,scale:s}=this.store.data;t.x=r.x+i.x*s,t.y=r.y+i.y*s,t.width=i.width*s,t.height=i.height*s}this.updatePenRect(t),this.execPenResize(t),n&&this.render()}getPenRect(t,i=this.store.data.origin,n=this.store.data.scale){if(!!t)return t.parentId?{x:t.x,y:t.y,width:t.width,height:t.height}:{x:(t.x-i.x)/n,y:(t.y-i.y)/n,width:t.width/n,height:t.height/n}}toPng(t=2,i,n=!1,r){const s=pi(this.store.data.pens),a=this.store.data.scale;if(!isFinite(s.width))throw new Error("can not to png, because width is not finite");const l=ct(s),c=this.store.data,u=n&&!c.background&&this.store.bkImg;let h=!1,d=!1;if(u){if(s.x+=c.x,s.y+=c.y,ae(s),Ji(s,this.canvasRect,!0))Object.assign(s,this.canvasRect);else{const I=As([...tn(s),...tn(this.canvasRect)]);Object.assign(s,I)}h=s.x===0,d=s.y===0}const g=this.store.data.width||this.store.options.width,v=this.store.data.height||this.store.options.height;let y=!1;g&&v&&!this.store.data.component&&(y=!0),y&&(s.x=this.store.data.origin.x,s.y=this.store.data.origin.y,s.width=g*this.store.data.scale,s.height=v*this.store.data.scale);const w=ct(s),p=Xi(t);s.x-=p[3]*a,s.y-=p[0]*a,s.width+=(p[3]+p[1])*a,s.height+=(p[0]+p[2])*a;const _=(r||1920)/s.width;s.width*=_,s.height*=_,ae(s);const A=document.createElement("canvas");if(A.width=s.width,A.height=s.height,A.width>32767||A.height>32767||!navigator.userAgent.includes("Firefox")&&A.height*A.width>268435456||navigator.userAgent.includes("Firefox")&&A.height*A.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");const x=A.getContext("2d");x.textBaseline="middle",x.scale(_,_);const E=this.store.data.background||this.store.options.background;if(E&&(x.save(),x.fillStyle=E,y?x.fillRect(0,0,w.width+(p[1]+p[3])*a,w.height+(p[0]+p[2])*a):x.fillRect(0,0,l.width+(p[3]+p[1])*a,l.height+(p[0]+p[2])*a),x.restore()),u)if(y)x.drawImage(this.store.bkImg,p[3]*a||0,p[0]*a||0,w.width,w.height);else{const I=s.x<0?-s.x:0,M=s.y<0?-s.y:0;x.drawImage(this.store.bkImg,I,M,this.canvasRect.width,this.canvasRect.height)}u?y?x.translate(-l.x+p[3]*a||0,-l.y+p[0]*a||0):x.translate((h?c.x:-l.x)+p[3]*a||0,(d?c.y:-l.y)+p[0]*a||0):x.translate(-s.x,-s.y);for(const I of this.store.data.pens){if(!Va(I,this.store)||I.visible==!1)continue;const{active:M}=I.calculative;I.calculative.active=!1,I.calculative.img?ja(x,I):Nn(x,I,!0),I.calculative.active=M}if(i){A.toBlob(i);return}return A.toDataURL()}activeToPng(t=2,i){return this.pensToPng(this.store.active,t,i)}pensToPng(t=this.store.active,i=2,n){if(t.length===0)return;const r=this.getAllByPens(t);let s=r.map(v=>v.id);const a=pi(r);if(!isFinite(a.width))throw new Error("can not to png, because width is not finite");const l=ct(a),c=Xi(i);a.x-=c[3],a.y-=c[0],a.width+=c[3]+c[1],a.height+=c[0]+c[2],ae(a);const u=(n||a.width)/a.width;a.width*=u,a.height*=u;const h=document.createElement("canvas");if(h.width=a.width,h.height=a.height,h.width>32767||h.height>32767||!navigator.userAgent.includes("Firefox")&&h.height*h.width>268435456||navigator.userAgent.includes("Firefox")&&h.height*h.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");const d=h.getContext("2d");d.textBaseline="middle",d.scale(u,u);const g=this.store.data.background||this.store.options.background;g&&(d.save(),d.fillStyle=g,d.fillRect(0,0,l.width+(c[3]+c[1]),l.height+(c[0]+c[2])),d.restore()),d.translate(-l.x+c[3],-l.y+c[0]);for(const v of this.store.data.pens)if(s.includes(v.id)){if(!Va(v,this.store)||v.visible==!1)continue;const{active:y}=v.calculative;v.calculative.active=!1,v.calculative.img?ja(d,v):Nn(d,v),v.calculative.active=y}return h.toDataURL()}toggleAnchorMode(){var t;if(this.hotkeyType)this.hotkeyType===Kt.AddAnchor&&(this.hotkeyType=Kt.None,this.store.hoverAnchor?this.externalElements.style.cursor="vertical-text":this.store.hover&&(this.externalElements.style.cursor="move"));else{if(this.store.options.disableAnchor||((t=this.store.hover)==null?void 0:t.disableAnchor))return;this.hotkeyType=Kt.AddAnchor,this.store.hover&&(this.externalElements.style.cursor="pointer")}this.patchFlags=!0}addAnchorHand(){if(this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){const t=[ct(this.store.active[0],!0)];this.store.activeAnchor.prev?this.store.activeAnchor.next||(this.store.activeAnchor.next={...this.store.activeAnchor.prev},Gt(this.store.activeAnchor.next,180,this.store.activeAnchor),this.initLineRect(this.store.active[0]),this.patchFlags=!0):(this.store.activeAnchor.next||(this.store.activeAnchor.next={penId:this.store.activeAnchor.penId,x:this.store.activeAnchor.x+50,y:this.store.activeAnchor.y}),this.store.activeAnchor.prev={...this.store.activeAnchor.next},Gt(this.store.activeAnchor.prev,180,this.store.activeAnchor),this.initLineRect(this.store.active[0]),this.patchFlags=!0),this.pushHistory({type:bt.Update,pens:[ct(this.store.active[0],!0)],initPens:t})}}removeAnchorHand(){if(this.store.activeAnchor&&this.store.active&&this.store.active.length===1&&this.store.active[0].type){const t=[ct(this.store.active[0],!0)];this.hoverType===xt.LineAnchorPrev?(this.store.activeAnchor.prev=void 0,this.initLineRect(this.store.active[0]),this.patchFlags=!0):this.hoverType===xt.LineAnchorNext?(this.store.activeAnchor.next=void 0,this.initLineRect(this.store.active[0]),this.patchFlags=!0):(this.store.activeAnchor.prev=void 0,this.store.activeAnchor.next=void 0,this.initLineRect(this.store.active[0]),this.patchFlags=!0),this.pushHistory({type:bt.Update,pens:[ct(this.store.active[0])],initPens:t})}}toggleAnchorHand(){this.store.active.length===1&&this.store.active[0].type&&this.store.activeAnchor&&(this.store.activeAnchor.prevNextType||(this.store.activeAnchor.prevNextType=jn.Mirror),this.store.activeAnchor.prevNextType=(this.store.activeAnchor.prevNextType+1)%3)}gotoView(t,i){let n=pi(this.store.data.pens);if(!isFinite(n.width))throw new Error("can not move view, because width is not finite");const r=this.store.data.width||this.store.options.width,s=this.store.data.height||this.store.options.height;r&&s&&(n={x:this.store.data.origin.x,y:this.store.data.origin.y,width:r*this.store.data.scale,height:s*this.store.data.scale}),this.store.data.x=this.canvas.clientWidth/2-t*n.width-n.x,this.store.data.y=this.canvas.clientHeight/2-i*n.height-n.y,this.onMovePens(),this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init(),this.render()}showMagnifier(){this.magnifierCanvas.canvas.style.zIndex="100",this.externalElements.style.zIndex="101",this.magnifierCanvas.magnifier=!0,this.magnifierCanvas.updateDomOffscreen(),this.externalElements.style.cursor="default",this.render()}hideMagnifier(){this.magnifierCanvas.canvas.style.zIndex="5",this.externalElements.style.zIndex="5",this.magnifierCanvas.magnifier=!1,this.externalElements.style.cursor="default",this.render()}showFit(){this.store.data.locked=0,this.canvasImage.fitFlag=!0,this.canvasImage.activeFit=void 0,this.canvasImage.currentFit=void 0,this.store.data.fits||(this.store.data.fits=[]),this.store.data.fits.forEach(t=>t.active=!1),this.canvasImage.init(),this.canvasImage.render()}hideFit(){this.canvasImage.fitFlag=!1,this.canvasImage.activeFit=void 0,this.canvasImage.currentFit=void 0,this.canvasImage.init(),this.canvasImage.render()}makeFit(){if(this.dragRect.width<100&&this.dragRect.height<100)return;const t=this.store.data.pens.filter(u=>{if(u.parentId||u.isRuleLine)return!1;if(Ji(u.calculative.worldRect,this.dragRect,!0))return u.type===jt.Line&&!this.store.options.dragAllIn?Bl(u,this.dragRect):!0});if(!t.length)return;const i=this.parent.getRect(t),n=this.store.data.scale,r=this.store.data.width||this.store.options.width,s=this.store.data.height||this.store.options.height;let a=(Math.floor(i.x)-this.store.data.origin.x)/n/r,l=(Math.floor(i.y)-this.store.data.origin.y)/n/s,c={x:a,y:l,width:(Math.ceil(i.width)+1)/n/r,height:(Math.ceil(i.height)+1)/n/s,children:t.map(u=>u.id),id:It(),active:!0};c.x<-.1&&(c.x=-.1),c.y<-.1&&(c.y=-.1),c.width>.5?(c.left=!0,c.right=!0,c.leftValue=(c.x-0)*n*r,c.rightValue=(1-(c.x+c.width))*n*r):c.x<.5?(c.left=!0,c.leftValue=(c.x-0)*n*r):(c.right=!0,c.rightValue=(1-(c.x+c.width))*n*r),c.leftValue<1&&(c.leftValue=0),c.rightValue<1&&(c.rightValue=0),c.height>.5?(c.top=!0,c.bottom=!0,c.topValue=(c.y-0)*n*s,c.bottomValue=(1-(c.y+c.height))*n*s):c.y<.5?(c.top=!0,c.topValue=(c.y-0)*n*s):(c.bottom=!0,c.bottomValue=(1-(c.y+c.height))*n*s),c.topValue<1&&(c.topValue=0),c.bottomValue<1&&(c.bottomValue=0),this.store.data.fits||(this.store.data.fits=[]),this.store.data.fits.forEach(u=>{u.active=!1}),this.store.data.fits.push(c),this.canvasImage.activeFit=c,this.store.emitter.emit("fit",c),this.canvasImage.init(),this.canvasImage.render()}updateFit(t){const i=this.store.data.scale,n=this.store.data.width||this.store.options.width,r=this.store.data.height||this.store.options.height;let s=(t.x-this.store.data.origin.x)/i/n,a=(t.y-this.store.data.origin.y)/i/r;if(this.canvasImage.currentFit){const l=this.canvasImage.activeFit;if(this.canvasImage.currentFit==="top"){a<-.1&&(a=-.1);let h=a-l.y;if(l.height-=h,l.height<.01){l.height=.01;return}l.y=a}if(this.canvasImage.currentFit==="bottom"&&(a>1.1&&(a=1.1),l.height=a-l.y,l.height<=.01&&(l.height=.01)),this.canvasImage.currentFit==="left"){s<-.1&&(s=-.1);let h=s-l.x;if(l.width-=h,l.width<.01){l.width=.01;return}l.x=s}this.canvasImage.currentFit==="right"&&(s>1.1&&(s=1.1),l.width=s-l.x,l.width<=.01&&(l.width=.01));let c={x:l.x*n*i+this.store.data.origin.x,y:l.y*r*i+this.store.data.origin.y,width:l.width*n*i,height:l.height*r*i};ae(c);const u=this.store.data.pens.filter(h=>{if(h.parentId||h.isRuleLine)return!1;if(Ji(h.calculative.worldRect,c,!0))return h.type===jt.Line&&!this.store.options.dragAllIn?Bl(h,c):!0});l.left=void 0,l.leftValue=void 0,l.right=void 0,l.rightValue=void 0,l.top=void 0,l.topValue=void 0,l.bottom=void 0,l.bottomValue=void 0,l.width>.5?(l.left=!0,l.right=!0,l.leftValue=(l.x-0)*i*n,l.rightValue=(1-(l.x+l.width))*i*n):l.x<.5?(l.left=!0,l.leftValue=(l.x-0)*i*n):(l.right=!0,l.rightValue=(1-(l.x+l.width))*i*n),Math.abs(l.leftValue)<1&&(l.leftValue=0),Math.abs(l.rightValue)<1&&(l.rightValue=0),l.height>.5?(l.top=!0,l.bottom=!0,l.topValue=(l.y-0)*i*r,l.bottomValue=(1-(l.y+l.height))*i*r):l.y<.5?(l.top=!0,l.topValue=(l.y-0)*i*r):(l.bottom=!0,l.bottomValue=(1-(l.y+l.height))*i*r),Math.abs(l.topValue)<1&&(l.topValue=0),Math.abs(l.bottomValue)<1&&(l.bottomValue=0),l.children=u.map(h=>h.id),this.store.emitter.emit("fit",l),this.mouseDown.x=t.x,this.mouseDown.y=t.y,this.canvasImage.init(),this.canvasImage.render()}}updateFitRect(t=this.canvasImage.activeFit){const i=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height;t.left&&(t.leftValue?t.x=Math.abs(t.leftValue)<1?t.leftValue:t.leftValue/i:t.x=0),t.right&&(t.rightValue?t.width=1-(Math.abs(t.rightValue)<1?t.rightValue:t.rightValue/i)-t.x:t.width=1-t.x),t.top&&(t.topValue?t.y=Math.abs(t.topValue)<1?t.topValue:t.topValue/n:t.y=0),t.bottom&&(t.bottomValue?t.height=1-(Math.abs(t.bottomValue)<1?t.bottomValue:t.bottomValue/n)-t.y:t.height=1-t.y),this.canvasImage.init(),this.canvasImage.render()}deleteFit(t=this.canvasImage.activeFit){if(!t)return;const i=this.store.data.fits.findIndex(n=>n.id===t.id);this.store.data.fits.splice(i,1),this.canvasImage.activeFit=void 0,this.canvasImage.init(),this.canvasImage.render(),this.store.emitter.emit("fit",void 0)}calcuActiveFit(){var l;const t=this.store.data.width||this.store.options.width,i=this.store.data.height||this.store.options.height;let n=(this.mouseDown.x-this.store.data.origin.x)/this.store.data.scale/t,r=(this.mouseDown.y-this.store.data.origin.y)/this.store.data.scale/i,s=-1,a=-1;(l=this.store.data.fits)==null||l.forEach((c,u)=>{c.ex=null,c.ey=null,yn({x:n,y:r},c)&&(s=u),c.active&&(a=u)}),s!==-1&&s!==a?(this.canvasImage.activeFit=this.store.data.fits[s],this.store.data.fits[s].active=!0,a!==-1&&(this.store.data.fits[a].active=!1),this.store.emitter.emit("fit",this.store.data.fits[s])):s===-1&&a!==-1&&(this.store.data.fits[a].active=!1,this.store.emitter.emit("fit",void 0),this.canvasImage.activeFit=null),this.inactive(),this.canvasImage.init(),this.canvasImage.render()}toggleMagnifier(){this.magnifierCanvas.magnifier=!this.magnifierCanvas.magnifier,this.magnifierCanvas.magnifier&&(this.externalElements.style.cursor="default"),this.render()}destroy(){var t,i,n,r;switch(this.scroll&&this.scroll.destroy(),(t=this.tooltip)==null||t.destroy(),(i=this.dialog)==null||i.destroy(),(n=this.title)==null||n.destroy(),(r=this.popconfirm)==null||r.destroy(),this.externalElements.removeEventListener("gesturestart",this.onGesturestart),this.externalElements.ondragover=s=>s.preventDefault(),this.externalElements.ondrop=void 0,this.externalElements.ontouchstart=void 0,this.externalElements.ontouchmove=void 0,this.externalElements.ontouchend=void 0,this.externalElements.onmousedown=void 0,this.externalElements.onmousemove=void 0,this.externalElements.onmouseup=void 0,this.externalElements.onmouseleave=void 0,this.externalElements.ondblclick=void 0,this.store.options.keydown){case zn.Document:document.removeEventListener("keydown",this.onkeydown),document.removeEventListener("keyup",this.onkeyup);break;case zn.Canvas:this.externalElements.removeEventListener("keydown",this.onkeydown),this.externalElements.removeEventListener("keyup",this.onkeyup);break}document.removeEventListener("copy",this.onCopy),document.removeEventListener("cut",this.onCut),document.removeEventListener("paste",this.onPaste),window&&window.removeEventListener("message",this.onMessage),window&&window.removeEventListener("resize",this.onResize),window&&window.removeEventListener("scroll",this.onScroll),this.parentElement.innerHTML=""}}function Bk(e,t){const i=t||new Path2D;e.onDestroy||(e.onDestroy=Fk,e.onMove=ad,e.onRotate=ad,e.onMouseEnter=zk,e.onMouseLeave=Hk,e.onMouseMove=Wk,e.onMouseUp=Uk,e.onInput=Nk);let n=e.calculative.borderRadius||0,r=n;const{x:s,y:a,width:l,height:c,ex:u,ey:h}=e.calculative.worldRect,{x:d}=e.calculative.worldTextRect;n<1&&(n=l*n,r=c*r);let g=n<r?n:r;l<2*g&&(g=l/2),c<2*g&&(g=c/2);const v=Ok(e.text,e.calculative.fontSize);if(i.moveTo(s+g,a),i.lineTo(d-5,a),i.moveTo(d+v+5,a),i.lineTo(d+v+5,a),i.arcTo(u,a,u,h,g),i.arcTo(u,h,s,h,g),i.arcTo(s,h,s,a,g),i.arcTo(s,a,u,a,g),i instanceof Path2D)return i}function Ok(e,t){const i=e.match(/[^\x00-\xff]/g)||"",n=i.length*t,r=e.match(/\s/g)||"",s=r.length*t*.3,a=(e.length-i.length-r.length)*t*.6;return n+s+a}function Nk(e,t){e.text=t,e.calculative.text=e.text,e.calculative.canvas.updatePenRect(e)}function Fk(e){}function ad(e){}function zk(e){}function Hk(e){const t=e.calculative.canvas.store.active;t&&t.length&&t.forEach(i=>{if(e.followers){let n=e.followers.findIndex(r=>r===i.id);if(n!==-1){const r=e.calculative.canvas.store.pens[i.id+Fe];r&&r.calculative&&(Ji(r.calculative.worldRect,e.calculative.worldRect,!0)||e.followers.splice(n,1))}}})}function Uk(e){const t=e.calculative.canvas.store.active;t&&t.length&&t.forEach(i=>{const n=e.calculative.canvas.store.pens[i.id+Fe];if(n&&n.calculative){let r=ct(e.calculative.worldRect);r.x-=1,r.y-=1,r.width+=2,r.height+=2,Ji(n.calculative.worldRect,r,!0)&&(e.followers||(e.followers=[]),e.followers.includes(i.id)||e.followers.push(i.id))}})}function Wk(e,t){}const ve={};function qk(e){e.onDestroy||(e.onDestroy=jk,e.onMove=od,e.onResize=Vk,e.onRotate=od,e.onValue=$k,e.onChangeId=Kk);const t=new Path2D;if(!!e.image){if(!ve[e.id]){const i=new Image;i.crossOrigin="anonymous",i.src=e.image,e.calculative.canvas.parent.store.options.cdn&&!(e.image.startsWith("http")||e.image.startsWith("//")||e.image.startsWith("data:image"))&&(i.src=e.calculative.canvas.parent.store.options.cdn+e.image),ve[e.id]=i,i.onload=()=>{var n;ve[e.id]===i&&(e.calculative.img=i,e.calculative.imgNaturalWidth=i.naturalWidth||e.iconWidth,e.calculative.imgNaturalHeight=i.naturalHeight||e.iconHeight,(n=e.calculative.canvas.externalElements)==null||n.parentElement.appendChild(i),ps(e,i))}}return e.calculative.patchFlags&&ve[e.id]&&ps(e,ve[e.id]),t}}function jk(e){ve[e.id]&&(ve[e.id].remove(),ve[e.id]=void 0)}function od(e){!ve[e.id]||ps(e,ve[e.id])}function Vk(e){!ve[e.id]||ps(e,ve[e.id])}function $k(e){!ve[e.id]||(ps(e,ve[e.id]),ve[e.id].getAttribute("src")!==e.image&&(ve[e.id].src=e.image))}function Kk(e,t,i){!ve[t]||(ve[i]=ve[t],delete ve[t])}function ps(e,t){t.style.objectFit=e.imageRatio?"contain":"fill",ti(e,t)}function Yk(e,t){return e.onResize||(e.onResize=rg,e.onValue=Xk),qn(e,t)}function rg(e){const t=e.anchors.filter(i=>i.flag!==1);sg(e),e.anchors=e.anchors.concat(...t)}function Xk(e){rg(e),Ir(e)}function sg(e){const t=[],{x:i,y:n,width:r,height:s}=e,a=Gk(e),l=5;for(let d=0;d<l;d++){if(d===2)continue;let g=i+r*(d+1)/(l+1),v=n;g<i+a?v=Ra(i+a,v+a,g,a,-1):g>i+r-a&&(v=Ra(i+r-a,v+a,g,a,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(g-i)/r,y:(v-n)/s})}const c=3;for(let d=0;d<c;d++){let g=n+s*(d+1)/(c+1),v=i+r;g<n+a?v=Aa(v-a,n+a,g,a):g>n+s-a&&(v=Aa(v-a,n+s-a,g,a)),t.push({id:String(t.length),flag:1,penId:e.id,x:(v-i)/r,y:(g-n)/s})}const u=5;for(let d=0;d<u;d++){if(d===2)continue;let g=i+r*(d+1)/(u+1),v=n+s;g<i+a?v=Ra(i+a,v-a,g,a):g>i+r-a&&(v=Ra(i+r-a,v-a,g,a)),t.push({id:String(t.length),flag:1,penId:e.id,x:(g-i)/r,y:(v-n)/s})}const h=3;for(let d=0;d<h;d++){let g=n+s*(d+1)/(h+1),v=i;g<n+a?v=Aa(v+a,n+a,g,a,-1):g>n+s-a&&(v=Aa(v+a,n+s-a,g,a,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(v-i)/r,y:(g-n)/s})}e.anchors=t}function Gk(e){let t=e.calculative.borderRadius||0,i=e.calculative.borderRadius||0;const{width:n,height:r}=e;e.calculative.borderRadius<1&&(t=n*e.calculative.borderRadius,i=r*e.calculative.borderRadius);let s=t<i?t:i;return n<2*s&&(s=n/2),r<2*s&&(s=r/2),s}function Aa(e,t,i,n,r=1){return r*Math.sqrt(n**2-(i-t)**2)+e}function Ra(e,t,i,n,r=1){return r*Math.sqrt(n**2-(i-e)**2)+t}function Zk(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.moveTo(n,r+a),i.lineTo(n+s,r+a),i.closePath(),i instanceof Path2D)return i}function Jk(e){const t=[{x:0,y:1},{x:1,y:1}];e.anchors=t.map(({x:i,y:n},r)=>({id:r+"",x:i,y:n,penId:e.id}))}function Qk(){return{rectangle:qn,square:Qx,circle:t_,svgPath:z2,diamond:H2,triangle:U2,pentagon:q2,pentagram:V2,hexagon:K2,leftArrow:Y2,rightArrow:X2,twowayArrow:G2,message:Z2,cloud:J2,file:Q2,people:ek,line:sk,iframe:xk,video:Rk,gif:qk,mindNode:Yk,mindLine:Zk,mindNode2:qn,panel:Bk,combine:qn}}function tE(){return{triangle:W2,pentagon:j2,pentagram:Kv,mindNode:sg,mindLine:Jk}}var fe;(function(e){e[e.Link=0]="Link",e[e.SetProps=1]="SetProps",e[e.StartAnimate=2]="StartAnimate",e[e.PauseAnimate=3]="PauseAnimate",e[e.StopAnimate=4]="StopAnimate",e[e.JS=5]="JS",e[e.GlobalFn=6]="GlobalFn",e[e.Emit=7]="Emit",e[e.StartVideo=8]="StartVideo",e[e.PauseVideo=9]="PauseVideo",e[e.StopVideo=10]="StopVideo",e[e.SendPropData=11]="SendPropData",e[e.SendVarData=12]="SendVarData",e[e.Navigator=13]="Navigator",e[e.Dialog=14]="Dialog",e[e.SendData=15]="SendData",e[e.PostMessage=16]="PostMessage",e[e.PostMessageToParent=17]="PostMessageToParent",e[e.Message=18]="Message"})(fe||(fe={}));class eE{constructor(t){W(this,"parent");W(this,"box");W(this,"boxWidth",320);W(this,"boxHeight",180);W(this,"ratio",this.boxWidth/this.boxHeight);W(this,"padding",5);W(this,"img");W(this,"isShow");W(this,"isDown");W(this,"view");W(this,"onMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.isDown=!0});W(this,"onMouseMove",t=>{if(t.preventDefault(),t.stopPropagation(),this.isDown)try{this.parent.gotoView(t.offsetX/this.box.clientWidth,t.offsetY/this.box.clientHeight)}catch(i){console.warn(i.message),this.isDown=!1}});W(this,"onMouseUp",t=>{t.preventDefault(),t.stopPropagation();try{this.parent.gotoView(t.offsetX/this.box.clientWidth,t.offsetY/this.box.clientHeight)}catch(i){console.warn(i.message)}finally{this.isDown=!1}});W(this,"onWheel",t=>{let i=.015;if(this.parent.store.options.scaleOff)i=this.parent.store.options.scaleOff,t.deltaY>0&&(i=-this.parent.store.options.scaleOff);else if(/mac os /i.test(navigator.userAgent))t.ctrlKey?t.deltaY>0&&(i*=-1):i*=t.wheelDeltaY/240;else{let c=.2;t.deltaY.toString().indexOf(".")!==-1&&(c=.01),t.deltaY>0?i=-c:i=c}let{offsetX:n,offsetY:r}=t;const s=this.parent.store.data.width||this.parent.store.options.width,a=this.parent.store.data.height||this.parent.store.options.height;if(s&&a)n=n/this.boxWidth*s*this.parent.store.data.scale+this.parent.store.data.origin.x+this.parent.store.data.x,r=r/this.boxHeight*a*this.parent.store.data.scale+this.parent.store.data.origin.y+this.parent.store.data.y;else{const l=this.parent.parent.getRect();n=n/this.boxWidth*l.width+l.x+this.parent.store.data.x,r=r/this.boxHeight*l.height+l.y+this.parent.store.data.y}this.parent.scale(this.parent.store.data.scale+i,{x:n,y:r})});var n;this.parent=t,this.box=document.createElement("div"),this.img=new Image,this.view=document.createElement("div"),this.box.appendChild(this.img),this.box.appendChild(this.view),(n=this.parent.externalElements)==null||n.parentElement.appendChild(this.box),this.box.className="meta2d-map",this.box.onmousedown=this.onMouseDown,this.box.onmousemove=this.onMouseMove,this.box.onmouseup=this.onMouseUp,this.box.onwheel=this.onWheel;let i;for(let r=0;r<document.styleSheets.length;r++)document.styleSheets[r].title==="le5le/map"&&(i=document.styleSheets[r]);if(!i){let r=document.createElement("style");r.type="text/css",r.title="le5le.com/map",document.head.appendChild(r),r=document.createElement("style"),r.type="text/css",document.head.appendChild(r),i=r.sheet,i.insertRule(`.meta2d-map{display:flex;width:${this.boxWidth+2*this.padding}px;height:${this.boxHeight+2*this.padding}px;padding:${this.padding}px;background:#f4f4f4;border:1px solid #ffffff;box-shadow: 0px 0px 14px 0px rgba(0,10,38,0.30);border-radius:8px;position:absolute;z-index:9999;right:0;bottom:0;justify-content:center;align-items:center;cursor:default;user-select:none;overflow: hidden;}`),i.insertRule(".meta2d-map img{max-width:100%;max-height:100%;pointer-events: none;}"),i.insertRule(".meta2d-map div{pointer-events: none;border:1px solid #1890ff;position:absolute}")}}show(){this.box.style.display="flex",this.parent.store.data.pens.length?(this.img.style.display="block",this.img.src=this.parent.toPng(),this.setView()):this.img.style.display="none",this.isShow=!0}hide(){this.box.style.display="none",this.isShow=!1}setView(){const t=this.parent.store.data;if(t.pens.length){let i=pi(t.pens);const n=this.parent.store.data.width||this.parent.store.options.width,r=this.parent.store.data.height||this.parent.store.options.height;if(n&&r&&(i={x:this.parent.store.data.origin.x,y:this.parent.store.data.origin.y,width:n*this.parent.store.data.scale,height:r*this.parent.store.data.scale}),Hn(i,t.x,t.y),i.width/i.height>this.ratio){const d=i.width/this.ratio;i.y-=(d-i.height)/2,i.height=d,ae(i)}else{const d=i.height*this.ratio;i.x-=(d-i.width)/2,i.width=d,ae(i)}const a=this.parent.canvasRect;let l=0,c=0;if(i.x<0)l=-i.x/i.width;else if(i.x+i.width>a.width){let d=0;a.width>i.width&&(d=a.width-i.width),l=(-i.x+d)/i.width}if(i.y<0)c=-i.y/i.height;else if(i.y+i.height>a.height){let d=0;a.height>i.height&&(d=a.height-i.height),c=(-i.y+d)/i.height}const u=a.width>i.width?1:a.width/i.width,h=a.height>i.height?1:a.height/i.height;this.view.style.left=this.padding+l*this.boxWidth+"px",this.view.style.width=u*this.boxWidth+"px",this.view.style.top=this.padding+c*this.boxHeight+"px",this.view.style.height=h*this.boxHeight+"px"}}}function Ca(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ss={exports:{}};(function(e,t){(function(i){e.exports=i()})(function(){return function(){return function i(n,r,s){function a(u,h){if(!r[u]){if(!n[u]){var d=typeof Ca=="function"&&Ca;if(!h&&d)return d(u,!0);if(l)return l(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var v=r[u]={exports:{}};n[u][0].call(v.exports,function(y){return a(n[u][1][y]||y)},v,v.exports,i,n,r,s)}return r[u].exports}for(var l=typeof Ca=="function"&&Ca,c=0;c<s.length;c++)a(s[c]);return a}}()({1:[function(i,n,r){(function(s,a){(function(){const l=i("events").EventEmitter,c=i("./store"),u=i("./topic-alias-recv"),h=i("./topic-alias-send"),d=i("mqtt-packet"),g=i("./default-message-id-provider"),v=i("readable-stream").Writable,y=i("inherits"),w=i("reinterval"),p=i("rfdc/default"),_=i("./validations"),A=i("xtend"),x=i("debug")("mqttjs:client"),E=s?s.nextTick:function(S){setTimeout(S,0)},I=a.setImmediate||function(S){E(S)},M={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},B={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function D(S,O){let K;O.properties&&(K=O.properties.topicAlias);let Z=O.topic.toString();if(Z.length===0){if(K===void 0)return new Error("Unregistered Topic Alias");if((Z=S.topicAliasSend.getTopicByAlias(K))===void 0)return new Error("Unregistered Topic Alias");O.topic=Z}K&&delete O.properties.topicAlias}function q(S,O,K){x("sendPacket :: packet: %O",O),x("sendPacket :: emitting `packetsend`"),S.emit("packetsend",O),x("sendPacket :: writing to stream");const Z=d.writeToStream(O,S.stream,S.options);x("sendPacket :: writeToStream result %s",Z),!Z&&K&&K!==C?(x("sendPacket :: handle events on `drain` once through callback."),S.stream.once("drain",K)):K&&(x("sendPacket :: invoking cb"),K())}function Q(S,O,K,Z){x("storeAndSend :: store packet with cmd %s to outgoingStore",O.cmd);let st,$=O;if($.cmd==="publish"&&($=p(O),st=D(S,$)))return K&&K(st);S.outgoingStore.put($,function(z){if(z)return K&&K(z);Z(),q(S,O,K)})}function C(S){x("nop ::",S)}function T(S,O){let K;const Z=this;if(!(this instanceof T))return new T(S,O);for(K in this.options=O||{},M)this.options[K]===void 0?this.options[K]=M[K]:this.options[K]=O[K];x("MqttClient :: options.protocol",O.protocol),x("MqttClient :: options.protocolVersion",O.protocolVersion),x("MqttClient :: options.username",O.username),x("MqttClient :: options.keepalive",O.keepalive),x("MqttClient :: options.reconnectPeriod",O.reconnectPeriod),x("MqttClient :: options.rejectUnauthorized",O.rejectUnauthorized),x("MqttClient :: options.topicAliasMaximum",O.topicAliasMaximum),this.options.clientId=typeof O.clientId=="string"?O.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),x("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=O.protocolVersion===5&&O.customHandleAcks?O.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=S,this.messageIdProvider=this.options.messageIdProvider===void 0?new g:this.options.messageIdProvider,this.outgoingStore=O.outgoingStore||new c,this.incomingStore=O.incomingStore||new c,this.queueQoSZero=O.queueQoSZero===void 0||O.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,O.topicAliasMaximum>0&&(O.topicAliasMaximum>65535?x("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new u(O.topicAliasMaximum)),this.on("connect",function(){const st=this.queue;x("connect :: sending queued packets"),function $(){const z=st.shift();x("deliver :: entry %o",z);let V=null;if(!z)return void Z._resubscribe();V=z.packet,x("deliver :: call _sendPacket for %o",V);let Y=!0;V.messageId&&V.messageId!==0&&(Z.messageIdProvider.register(V.messageId)||(Y=!1)),Y?Z._sendPacket(V,function(U){z.cb&&z.cb(U),$()}):(x("messageId: %d has already used. The message is skipped and removed.",V.messageId),$())}()}),this.on("close",function(){x("close :: connected set to `false`"),this.connected=!1,x("close :: clearing connackTimer"),clearTimeout(this.connackTimer),x("close :: clearing ping timer"),Z.pingTimer!==null&&(Z.pingTimer.clear(),Z.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),x("close :: calling _setupReconnect"),this._setupReconnect()}),l.call(this),x("MqttClient :: setting up stream"),this._setupStream()}y(T,l),T.prototype._setupStream=function(){const S=this,O=new v,K=d.parser(this.options);let Z=null;const st=[];function $(){if(st.length)E(z);else{const Y=Z;Z=null,Y()}}function z(){x("work :: getting next packet in queue");const Y=st.shift();if(Y)x("work :: packet pulled from queue"),S._handlePacket(Y,$);else{x("work :: no packets in queue");const U=Z;Z=null,x("work :: done flag is %s",!!U),U&&U()}}x("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),x("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),K.on("packet",function(Y){x("parser :: on packet push to packets array."),st.push(Y)}),O._write=function(Y,U,tt){Z=tt,x("writable stream :: parsing buffer"),K.parse(Y),z()},x("_setupStream :: pipe stream to writable stream"),this.stream.pipe(O),this.stream.on("error",function(Y){x("streamErrorHandler :: error",Y.message),Y.code?(x("streamErrorHandler :: emitting error"),S.emit("error",Y)):C(Y)}),this.stream.on("close",function(){var Y;x("(%s)stream :: on close",S.options.clientId),(Y=S.outgoing)&&(x("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(Y).forEach(function(U){Y[U].volatile&&typeof Y[U].cb=="function"&&(Y[U].cb(new Error("Connection closed")),delete Y[U])})),x("stream: emit close to MqttClient"),S.emit("close")}),x("_setupStream: sending packet `connect`");const V=Object.create(this.options);if(V.cmd="connect",this.topicAliasRecv&&(V.properties||(V.properties={}),this.topicAliasRecv&&(V.properties.topicAliasMaximum=this.topicAliasRecv.max)),q(this,V),K.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return S.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"&&q(this,A({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){x("!!connectTimeout hit!! Calling _cleanUp with force `true`"),S._cleanUp(!0)},this.options.connectTimeout)},T.prototype._handlePacket=function(S,O){const K=this.options;if(K.protocolVersion===5&&K.properties&&K.properties.maximumPacketSize&&K.properties.maximumPacketSize<S.length)return this.emit("error",new Error("exceeding packets size "+S.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(x("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",S),S.cmd){case"publish":this._handlePublish(S,O);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(S),O();break;case"pubrel":this._handlePubrel(S,O);break;case"connack":this._handleConnack(S),O();break;case"auth":this._handleAuth(S),O();break;case"pingresp":this._handlePingresp(S),O();break;case"disconnect":this._handleDisconnect(S),O()}},T.prototype._checkDisconnecting=function(S){return this.disconnecting&&(S&&S!==C?S(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},T.prototype.publish=function(S,O,K,Z){x("publish :: message `%s` to topic `%s`",O,S);const st=this.options;if(typeof K=="function"&&(Z=K,K=null),K=A({qos:0,retain:!1,dup:!1},K),this._checkDisconnecting(Z))return this;const $=this,z=function(){let V=0;if((K.qos===1||K.qos===2)&&(V=$._nextId())===null)return x("No messageId left"),!1;const Y={cmd:"publish",topic:S,payload:O,qos:K.qos,retain:K.retain,messageId:V,dup:K.dup};switch(st.protocolVersion===5&&(Y.properties=K.properties),x("publish :: qos",K.qos),K.qos){case 1:case 2:$.outgoing[Y.messageId]={volatile:!1,cb:Z||C},x("MqttClient:publish: packet cmd: %s",Y.cmd),$._sendPacket(Y,void 0,K.cbStorePut);break;default:x("MqttClient:publish: packet cmd: %s",Y.cmd),$._sendPacket(Y,Z,K.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!z())&&this._storeProcessingQueue.push({invoke:z,cbStorePut:K.cbStorePut,callback:Z}),this},T.prototype.subscribe=function(){const S=this,O=new Array(arguments.length);for(let rt=0;rt<arguments.length;rt++)O[rt]=arguments[rt];const K=[];let Z=O.shift();const st=Z.resubscribe;let $=O.pop()||C,z=O.pop();const V=this.options.protocolVersion;delete Z.resubscribe,typeof Z=="string"&&(Z=[Z]),typeof $!="function"&&(z=$,$=C);const Y=_.validateTopics(Z);if(Y!==null)return I($,new Error("Invalid topic "+Y)),this;if(this._checkDisconnecting($))return x("subscribe: discconecting true"),this;const U={qos:0};if(V===5&&(U.nl=!1,U.rap=!1,U.rh=0),z=A(U,z),Array.isArray(Z)?Z.forEach(function(rt){if(x("subscribe: array topic %s",rt),!Object.prototype.hasOwnProperty.call(S._resubscribeTopics,rt)||S._resubscribeTopics[rt].qos<z.qos||st){const nt={topic:rt,qos:z.qos};V===5&&(nt.nl=z.nl,nt.rap=z.rap,nt.rh=z.rh,nt.properties=z.properties),x("subscribe: pushing topic `%s` and qos `%s` to subs list",nt.topic,nt.qos),K.push(nt)}}):Object.keys(Z).forEach(function(rt){if(x("subscribe: object topic %s",rt),!Object.prototype.hasOwnProperty.call(S._resubscribeTopics,rt)||S._resubscribeTopics[rt].qos<Z[rt].qos||st){const nt={topic:rt,qos:Z[rt].qos};V===5&&(nt.nl=Z[rt].nl,nt.rap=Z[rt].rap,nt.rh=Z[rt].rh,nt.properties=z.properties),x("subscribe: pushing `%s` to subs list",nt),K.push(nt)}}),!K.length)return $(null,[]),this;const tt=function(){const rt=S._nextId();if(rt===null)return x("No messageId left"),!1;const nt={cmd:"subscribe",subscriptions:K,qos:1,retain:!1,dup:!1,messageId:rt};if(z.properties&&(nt.properties=z.properties),S.options.resubscribe){x("subscribe :: resubscribe true");const ft=[];K.forEach(function(lt){if(S.options.reconnectPeriod>0){const ut={qos:lt.qos};V===5&&(ut.nl=lt.nl||!1,ut.rap=lt.rap||!1,ut.rh=lt.rh||0,ut.properties=lt.properties),S._resubscribeTopics[lt.topic]=ut,ft.push(lt.topic)}}),S.messageIdToTopic[nt.messageId]=ft}return S.outgoing[nt.messageId]={volatile:!0,cb:function(ft,lt){if(!ft){const ut=lt.granted;for(let b=0;b<ut.length;b+=1)K[b].qos=ut[b]}$(ft,K)}},x("subscribe :: call _sendPacket"),S._sendPacket(nt),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!tt())&&this._storeProcessingQueue.push({invoke:tt,callback:$}),this},T.prototype.unsubscribe=function(){const S=this,O=new Array(arguments.length);for(let V=0;V<arguments.length;V++)O[V]=arguments[V];let K=O.shift(),Z=O.pop()||C,st=O.pop();typeof K=="string"&&(K=[K]),typeof Z!="function"&&(st=Z,Z=C);const $=_.validateTopics(K);if($!==null)return I(Z,new Error("Invalid topic "+$)),this;if(S._checkDisconnecting(Z))return this;const z=function(){const V=S._nextId();if(V===null)return x("No messageId left"),!1;const Y={cmd:"unsubscribe",qos:1,messageId:V};return typeof K=="string"?Y.unsubscriptions=[K]:Array.isArray(K)&&(Y.unsubscriptions=K),S.options.resubscribe&&Y.unsubscriptions.forEach(function(U){delete S._resubscribeTopics[U]}),typeof st=="object"&&st.properties&&(Y.properties=st.properties),S.outgoing[Y.messageId]={volatile:!0,cb:Z},x("unsubscribe: call _sendPacket"),S._sendPacket(Y),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!z())&&this._storeProcessingQueue.push({invoke:z,callback:Z}),this},T.prototype.end=function(S,O,K){const Z=this;function st(){x("end :: (%s) :: finish :: calling _cleanUp with force %s",Z.options.clientId,S),Z._cleanUp(S,()=>{x("end :: finish :: calling process.nextTick on closeStores"),E(function(){x("end :: closeStores: closing incoming and outgoing stores"),Z.disconnected=!0,Z.incomingStore.close(function($){Z.outgoingStore.close(function(z){if(x("end :: closeStores: emitting end"),Z.emit("end"),K){const V=$||z;x("end :: closeStores: invoking callback with args"),K(V)}})}),Z._deferredReconnect&&Z._deferredReconnect()}.bind(Z))},O)}return x("end :: (%s)",this.options.clientId),S!=null&&typeof S=="boolean"||(K=O||C,O=S,S=!1,typeof O!="object"&&(K=O,O=null,typeof K!="function"&&(K=C))),typeof O!="object"&&(K=O,O=null),x("end :: cb? %s",!!K),K=K||C,this.disconnecting?(K(),this):(this._clearReconnect(),this.disconnecting=!0,!S&&Object.keys(this.outgoing).length>0?(x("end :: (%s) :: calling finish in 10ms once outgoing is empty",Z.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,st,10))):(x("end :: (%s) :: immediately calling finish",Z.options.clientId),st()),this)},T.prototype.removeOutgoingMessage=function(S){const O=this.outgoing[S]?this.outgoing[S].cb:null;return delete this.outgoing[S],this.outgoingStore.del({messageId:S},function(){O(new Error("Message removed"))}),this},T.prototype.reconnect=function(S){x("client reconnect");const O=this,K=function(){S?(O.options.incomingStore=S.incomingStore,O.options.outgoingStore=S.outgoingStore):(O.options.incomingStore=null,O.options.outgoingStore=null),O.incomingStore=O.options.incomingStore||new c,O.outgoingStore=O.options.outgoingStore||new c,O.disconnecting=!1,O.disconnected=!1,O._deferredReconnect=null,O._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=K:K(),this},T.prototype._reconnect=function(){x("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),x("client already connected. disconnecting first.")):(x("_reconnect: calling _setupStream"),this._setupStream())},T.prototype._setupReconnect=function(){const S=this;!S.disconnecting&&!S.reconnectTimer&&S.options.reconnectPeriod>0?(this.reconnecting||(x("_setupReconnect :: emit `offline` state"),this.emit("offline"),x("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),x("_setupReconnect :: setting reconnectTimer for %d ms",S.options.reconnectPeriod),S.reconnectTimer=setInterval(function(){x("reconnectTimer :: reconnect triggered!"),S._reconnect()},S.options.reconnectPeriod)):x("_setupReconnect :: doing nothing...")},T.prototype._clearReconnect=function(){x("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},T.prototype._cleanUp=function(S,O){const K=arguments[2];if(O&&(x("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",O)),x("_cleanUp :: forced? %s",S),S)this.options.reconnectPeriod===0&&this.options.clean&&(Z=this.outgoing)&&(x("flush: queue exists? %b",!!Z),Object.keys(Z).forEach(function(st){typeof Z[st].cb=="function"&&(Z[st].cb(new Error("Connection closed")),delete Z[st])})),x("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const st=A({cmd:"disconnect"},K);x("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(st,I.bind(null,this.stream.end.bind(this.stream)))}var Z;this.disconnecting||(x("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this.pingTimer!==null&&(x("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),O&&!this.connected&&(x("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",O),O())},T.prototype._sendPacket=function(S,O,K){x("_sendPacket :: (%s) :: start",this.options.clientId),K=K||C,O=O||C;const Z=function(st,$){if(st.options.protocolVersion===5&&$.cmd==="publish"){let z;$.properties&&(z=$.properties.topicAlias);const V=$.topic.toString();if(st.topicAliasSend)if(z){if(V.length!==0&&(x("applyTopicAlias :: register topic: %s - alias: %d",V,z),!st.topicAliasSend.put(V,z)))return x("applyTopicAlias :: error out of range. topic: %s - alias: %d",V,z),new Error("Sending Topic Alias out of range")}else V.length!==0&&(st.options.autoAssignTopicAlias?(z=st.topicAliasSend.getAliasByTopic(V))?($.topic="",$.properties={...$.properties,topicAlias:z},x("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",V,z)):(z=st.topicAliasSend.getLruAlias(),st.topicAliasSend.put(V,z),$.properties={...$.properties,topicAlias:z},x("applyTopicAlias :: auto assign topic: %s - alias: %d",V,z)):st.options.autoUseTopicAlias&&(z=st.topicAliasSend.getAliasByTopic(V))&&($.topic="",$.properties={...$.properties,topicAlias:z},x("applyTopicAlias :: auto use topic: %s - alias: %d",V,z)));else if(z)return x("applyTopicAlias :: error out of range. topic: %s - alias: %d",V,z),new Error("Sending Topic Alias out of range")}}(this,S);if(Z)O(Z);else{if(!this.connected)return S.cmd==="auth"?(this._shiftPingInterval(),void q(this,S,O)):(x("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(S,O,K));switch(this._shiftPingInterval(),S.cmd){case"publish":break;case"pubrel":return void Q(this,S,O,K);default:return void q(this,S,O)}switch(S.qos){case 2:case 1:Q(this,S,O,K);break;case 0:default:q(this,S,O)}x("_sendPacket :: (%s) :: end",this.options.clientId)}},T.prototype._storePacket=function(S,O,K){x("_storePacket :: packet: %o",S),x("_storePacket :: cb? %s",!!O),K=K||C;let Z=S;if(Z.cmd==="publish"){const st=D(this,Z=p(S));if(st)return O&&O(st)}(Z.qos||0)===0&&this.queueQoSZero||Z.cmd!=="publish"?this.queue.push({packet:Z,cb:O}):Z.qos>0?(O=this.outgoing[Z.messageId]?this.outgoing[Z.messageId].cb:null,this.outgoingStore.put(Z,function(st){if(st)return O&&O(st);K()})):O&&O(new Error("No connection to broker"))},T.prototype._setupPingTimer=function(){x("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const S=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=w(function(){S._checkPing()},1e3*this.options.keepalive))},T.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},T.prototype._checkPing=function(){x("_checkPing :: checking ping..."),this.pingResp?(x("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(x("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},T.prototype._handlePingresp=function(){this.pingResp=!0},T.prototype._handleConnack=function(S){x("_handleConnack");const O=this.options,K=O.protocolVersion===5?S.reasonCode:S.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,S.properties){if(S.properties.topicAliasMaximum){if(S.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));S.properties.topicAliasMaximum>0&&(this.topicAliasSend=new h(S.properties.topicAliasMaximum))}S.properties.serverKeepAlive&&O.keepalive&&(O.keepalive=S.properties.serverKeepAlive,this._shiftPingInterval()),S.properties.maximumPacketSize&&(O.properties||(O.properties={}),O.properties.maximumPacketSize=S.properties.maximumPacketSize)}if(K===0)this.reconnecting=!1,this._onConnect(S);else if(K>0){const Z=new Error("Connection refused: "+B[K]);Z.code=K,this.emit("error",Z)}},T.prototype._handleAuth=function(S){const O=this.options.protocolVersion,K=O===5?S.reasonCode:S.returnCode;if(O!==5){const st=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+O);return st.code=K,void this.emit("error",st)}const Z=this;this.handleAuth(S,function(st,$){if(st)Z.emit("error",st);else if(K===24)Z.reconnecting=!1,Z._sendPacket($);else{const z=new Error("Connection refused: "+B[K]);st.code=K,Z.emit("error",z)}})},T.prototype.handleAuth=function(S,O){O()},T.prototype._handlePublish=function(S,O){x("_handlePublish: packet %o",S),O=O!==void 0?O:C;let K=S.topic.toString();const Z=S.payload,st=S.qos,$=S.messageId,z=this,V=this.options,Y=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let U;if(S.properties&&(U=S.properties.topicAlias),U!==void 0)if(K.length===0){if(!(U>0&&U<=65535))return x("_handlePublish :: topic alias out of range. alias: %d",U),void this.emit("error",new Error("Received Topic Alias is out of range"));{const tt=this.topicAliasRecv.getTopicByAlias(U);if(!tt)return x("_handlePublish :: unregistered topic alias. alias: %d",U),void this.emit("error",new Error("Received unregistered Topic Alias"));x("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",K=tt,U)}}else{if(!this.topicAliasRecv.put(K,U))return x("_handlePublish :: topic alias out of range. alias: %d",U),void this.emit("error",new Error("Received Topic Alias is out of range"));x("_handlePublish :: registered topic: %s - alias: %d",K,U)}}switch(x("_handlePublish: qos %d",st),st){case 2:V.customHandleAcks(K,Z,S,function(U,tt){return U instanceof Error||(tt=U,U=null),U?z.emit("error",U):Y.indexOf(tt)===-1?z.emit("error",new Error("Wrong reason code for pubrec")):void(tt?z._sendPacket({cmd:"pubrec",messageId:$,reasonCode:tt},O):z.incomingStore.put(S,function(){z._sendPacket({cmd:"pubrec",messageId:$},O)}))});break;case 1:V.customHandleAcks(K,Z,S,function(U,tt){return U instanceof Error||(tt=U,U=null),U?z.emit("error",U):Y.indexOf(tt)===-1?z.emit("error",new Error("Wrong reason code for puback")):(tt||z.emit("message",K,Z,S),void z.handleMessage(S,function(rt){if(rt)return O&&O(rt);z._sendPacket({cmd:"puback",messageId:$,reasonCode:tt},O)}))});break;case 0:this.emit("message",K,Z,S),this.handleMessage(S,O);break;default:x("_handlePublish: unknown QoS. Doing nothing.")}},T.prototype.handleMessage=function(S,O){O()},T.prototype._handleAck=function(S){const O=S.messageId,K=S.cmd;let Z=null;const st=this.outgoing[O]?this.outgoing[O].cb:null,$=this;let z;if(st){switch(x("_handleAck :: packet type",K),K){case"pubcomp":case"puback":{const V=S.reasonCode;V&&V>0&&V!==16&&((z=new Error("Publish error: "+B[V])).code=V,st(z,S)),delete this.outgoing[O],this.outgoingStore.del(S,st),this.messageIdProvider.deallocate(O),this._invokeStoreProcessingQueue();break}case"pubrec":{Z={cmd:"pubrel",qos:2,messageId:O};const V=S.reasonCode;V&&V>0&&V!==16?((z=new Error("Publish error: "+B[V])).code=V,st(z,S)):this._sendPacket(Z);break}case"suback":delete this.outgoing[O],this.messageIdProvider.deallocate(O);for(let V=0;V<S.granted.length;V++)if((128&S.granted[V])!=0){const Y=this.messageIdToTopic[O];Y&&Y.forEach(function(U){delete $._resubscribeTopics[U]})}this._invokeStoreProcessingQueue(),st(null,S);break;case"unsuback":delete this.outgoing[O],this.messageIdProvider.deallocate(O),this._invokeStoreProcessingQueue(),st(null);break;default:$.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&Object.keys(this.outgoing).length===0&&this.emit("outgoingEmpty")}else x("_handleAck :: Server sent an ack in error. Ignoring.")},T.prototype._handlePubrel=function(S,O){x("handling pubrel packet"),O=O!==void 0?O:C;const K=this,Z={cmd:"pubcomp",messageId:S.messageId};K.incomingStore.get(S,function(st,$){st?K._sendPacket(Z,O):(K.emit("message",$.topic,$.payload,$),K.handleMessage($,function(z){if(z)return O(z);K.incomingStore.del($,C),K._sendPacket(Z,O)}))})},T.prototype._handleDisconnect=function(S){this.emit("disconnect",S)},T.prototype._nextId=function(){return this.messageIdProvider.allocate()},T.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},T.prototype._resubscribe=function(){x("_resubscribe");const S=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion===5&&!this.connackPacket.sessionPresent)&&S.length>0)if(this.options.resubscribe)if(this.options.protocolVersion===5){x("_resubscribe: protocolVersion 5");for(let O=0;O<S.length;O++){const K={};K[S[O]]=this._resubscribeTopics[S[O]],K.resubscribe=!0,this.subscribe(K,{properties:K[S[O]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},T.prototype._onConnect=function(S){if(this.disconnected)return void this.emit("connect",S);const O=this;this.connackPacket=S,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,function K(){let Z=O.outgoingStore.createStream();function st(){O._storeProcessing=!1,O._packetIdsDuringStoreProcessing={}}function $(){Z.destroy(),Z=null,O._flushStoreProcessingQueue(),st()}O.once("close",$),Z.on("error",function(z){st(),O._flushStoreProcessingQueue(),O.removeListener("close",$),O.emit("error",z)}),Z.on("end",function(){let z=!0;for(const V in O._packetIdsDuringStoreProcessing)if(!O._packetIdsDuringStoreProcessing[V]){z=!1;break}z?(st(),O.removeListener("close",$),O._invokeAllStoreProcessingQueue(),O.emit("connect",S)):K()}),function z(){if(!Z)return;O._storeProcessing=!0;const V=Z.read(1);let Y;V?O._packetIdsDuringStoreProcessing[V.messageId]?z():O.disconnecting||O.reconnectTimer?Z.destroy&&Z.destroy():(Y=O.outgoing[V.messageId]?O.outgoing[V.messageId].cb:null,O.outgoing[V.messageId]={volatile:!1,cb:function(U,tt){Y&&Y(U,tt),z()}},O._packetIdsDuringStoreProcessing[V.messageId]=!0,O.messageIdProvider.register(V.messageId)?O._sendPacket(V):x("messageId: %d has already used.",V.messageId)):Z.once("readable",z)}()}()},T.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const S=this._storeProcessingQueue[0];if(S&&S.invoke())return this._storeProcessingQueue.shift(),!0}return!1},T.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},T.prototype._flushStoreProcessingQueue=function(){for(const S of this._storeProcessingQueue)S.cbStorePut&&S.cbStorePut(new Error("Connection closed")),S.callback&&S.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},n.exports=T}).call(this)}).call(this,i("_process"),typeof Le<"u"?Le:typeof self<"u"?self:typeof window<"u"?window:{})},{"./default-message-id-provider":7,"./store":8,"./topic-alias-recv":9,"./topic-alias-send":10,"./validations":11,_process:50,debug:18,events:22,inherits:24,"mqtt-packet":40,"readable-stream":69,reinterval:70,"rfdc/default":71,xtend:81}],2:[function(i,n,r){const{Buffer:s}=i("buffer"),a=i("readable-stream").Transform,l=i("duplexify");let c,u,h,d=!1;n.exports=function(g,v){if(v.hostname=v.hostname||v.host,!v.hostname)throw new Error("Could not determine host. Specify host manually.");const y=v.protocolId==="MQIsdp"&&v.protocolVersion===3?"mqttv3.1":"mqtt";(function(p){p.hostname||(p.hostname="localhost"),p.path||(p.path="/"),p.wsOptions||(p.wsOptions={})})(v);const w=function(p,_){const A=p.protocol==="alis"?"wss":"ws";let x=A+"://"+p.hostname+p.path;return p.port&&p.port!==80&&p.port!==443&&(x=A+"://"+p.hostname+":"+p.port+p.path),typeof p.transformWsUrl=="function"&&(x=p.transformWsUrl(x,p,_)),x}(v,g);return(c=v.my).connectSocket({url:w,protocols:y}),u=function(){const p=new a;return p._write=function(_,A,x){c.sendSocketMessage({data:_.buffer,success:function(){x()},fail:function(){x(new Error)}})},p._flush=function(_){c.closeSocket({success:function(){_()}})},p}(),h=l.obj(),d||(d=!0,c.onSocketOpen(function(){h.setReadable(u),h.setWritable(u),h.emit("connect")}),c.onSocketMessage(function(p){if(typeof p.data=="string"){const _=s.from(p.data,"base64");u.push(_)}else{const _=new FileReader;_.addEventListener("load",function(){let A=_.result;A=A instanceof ArrayBuffer?s.from(A):s.from(A,"utf8"),u.push(A)}),_.readAsArrayBuffer(p.data)}}),c.onSocketClose(function(){h.end(),h.destroy()}),c.onSocketError(function(p){h.destroy(p)})),h}},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(i,n,r){const s=i("net"),a=i("debug")("mqttjs:tcp");n.exports=function(l,c){c.port=c.port||1883,c.hostname=c.hostname||c.host||"localhost";const u=c.port,h=c.hostname;return a("port %d and host %s",u,h),s.createConnection(u,h)}},{debug:18,net:16}],4:[function(i,n,r){const s=i("tls"),a=i("net"),l=i("debug")("mqttjs:tls");n.exports=function(c,u){u.port=u.port||8883,u.host=u.hostname||u.host||"localhost",a.isIP(u.host)===0&&(u.servername=u.host),u.rejectUnauthorized=u.rejectUnauthorized!==!1,delete u.path,l("port %d host %s rejectUnauthorized %b",u.port,u.host,u.rejectUnauthorized);const h=s.connect(u);function d(g){u.rejectUnauthorized&&c.emit("error",g),h.end()}return h.on("secureConnect",function(){u.rejectUnauthorized&&!h.authorized?h.emit("error",new Error("TLS not authorized")):h.removeListener("error",d)}),h.on("error",d),h}},{debug:18,net:16,tls:16}],5:[function(i,n,r){(function(s){(function(){const{Buffer:a}=i("buffer"),l=i("ws"),c=i("debug")("mqttjs:ws"),u=i("duplexify"),h=i("readable-stream").Transform,d=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],g=s!==void 0&&s.title==="browser"||typeof __webpack_require__=="function";function v(w,p){let _=w.protocol+"://"+w.hostname+":"+w.port+w.path;return typeof w.transformWsUrl=="function"&&(_=w.transformWsUrl(_,w,p)),_}function y(w){const p=w;return w.hostname||(p.hostname="localhost"),w.port||(w.protocol==="wss"?p.port=443:p.port=80),w.path||(p.path="/"),w.wsOptions||(p.wsOptions={}),g||w.protocol!=="wss"||d.forEach(function(_){Object.prototype.hasOwnProperty.call(w,_)&&!Object.prototype.hasOwnProperty.call(w.wsOptions,_)&&(p.wsOptions[_]=w[_])}),p}n.exports=g?function(w,p){let _;c("browserStreamBuilder");const A=function(S){const O=y(S);if(O.hostname||(O.hostname=O.host),!O.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");const K=new URL(document.URL);O.hostname=K.hostname,O.port||(O.port=K.port)}return O.objectMode===void 0&&(O.objectMode=!(O.binary===!0||O.binary===void 0)),O}(p).browserBufferSize||524288,x=p.browserBufferTimeout||1e3,E=!p.objectMode,I=function(S,O){const K=O.protocolId==="MQIsdp"&&O.protocolVersion===3?"mqttv3.1":"mqtt",Z=v(O,S),st=new WebSocket(Z,[K]);return st.binaryType="arraybuffer",st}(w,p),M=function(S,O,K){const Z=new h({objectModeMode:S.objectMode});return Z._write=O,Z._flush=K,Z}(p,function S(O,K,Z){I.bufferedAmount>A&&setTimeout(S,x,O,K,Z),E&&typeof O=="string"&&(O=a.from(O,"utf8"));try{I.send(O)}catch(st){return Z(st)}Z()},function(S){I.close(),S()});p.objectMode||(M._writev=T),M.on("close",()=>{I.close()});const B=I.addEventListener!==void 0;function D(){_.setReadable(M),_.setWritable(M),_.emit("connect")}function q(){_.end(),_.destroy()}function Q(S){_.destroy(S)}function C(S){let O=S.data;O=O instanceof ArrayBuffer?a.from(O):a.from(O,"utf8"),M.push(O)}function T(S,O){const K=new Array(S.length);for(let Z=0;Z<S.length;Z++)typeof S[Z].chunk=="string"?K[Z]=a.from(S[Z],"utf8"):K[Z]=S[Z].chunk;this._write(a.concat(K),"binary",O)}return I.readyState===I.OPEN?_=M:(_=_=u(void 0,void 0,p),p.objectMode||(_._writev=T),B?I.addEventListener("open",D):I.onopen=D),_.socket=I,B?(I.addEventListener("close",q),I.addEventListener("error",Q),I.addEventListener("message",C)):(I.onclose=q,I.onerror=Q,I.onmessage=C),_}:function(w,p){c("streamBuilder");const _=y(p),A=v(_,w),x=function(I,M,B){c("createWebSocket"),c("protocol: "+B.protocolId+" "+B.protocolVersion);const D=B.protocolId==="MQIsdp"&&B.protocolVersion===3?"mqttv3.1":"mqtt";return c("creating new Websocket for url: "+M+" and protocol: "+D),new l(M,[D],B.wsOptions)}(0,A,_),E=l.createWebSocketStream(x,_.wsOptions);return E.url=A,x.on("close",()=>{E.destroy()}),E}}).call(this)}).call(this,i("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(i,n,r){const{Buffer:s}=i("buffer"),a=i("readable-stream").Transform,l=i("duplexify");let c,u,h;n.exports=function(d,g){if(g.hostname=g.hostname||g.host,!g.hostname)throw new Error("Could not determine host. Specify host manually.");const v=g.protocolId==="MQIsdp"&&g.protocolVersion===3?"mqttv3.1":"mqtt";(function(p){p.hostname||(p.hostname="localhost"),p.path||(p.path="/"),p.wsOptions||(p.wsOptions={})})(g);const y=function(p,_){const A=p.protocol==="wxs"?"wss":"ws";let x=A+"://"+p.hostname+p.path;return p.port&&p.port!==80&&p.port!==443&&(x=A+"://"+p.hostname+":"+p.port+p.path),typeof p.transformWsUrl=="function"&&(x=p.transformWsUrl(x,p,_)),x}(g,d);c=wx.connectSocket({url:y,protocols:[v]}),u=function(){const p=new a;return p._write=function(_,A,x){c.send({data:_.buffer,success:function(){x()},fail:function(E){x(new Error(E))}})},p._flush=function(_){c.close({success:function(){_()}})},p}(),(h=l.obj())._destroy=function(p,_){c.close({success:function(){_&&_(p)}})};const w=h.destroy;return h.destroy=function(){h.destroy=w;const p=this;setTimeout(function(){c.close({fail:function(){p._destroy(new Error)}})},0)}.bind(h),c.onOpen(function(){h.setReadable(u),h.setWritable(u),h.emit("connect")}),c.onMessage(function(p){let _=p.data;_=_ instanceof ArrayBuffer?s.from(_):s.from(_,"utf8"),u.push(_)}),c.onClose(function(){h.end(),h.destroy()}),c.onError(function(p){h.destroy(new Error(p.errMsg))}),h}},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(i,n,r){function s(){if(!(this instanceof s))return new s;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}s.prototype.allocate=function(){const a=this.nextId++;return this.nextId===65536&&(this.nextId=1),a},s.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1},s.prototype.register=function(a){return!0},s.prototype.deallocate=function(a){},s.prototype.clear=function(){},n.exports=s},{}],8:[function(i,n,r){const s=i("xtend"),a=i("readable-stream").Readable,l={objectMode:!0},c={clean:!0};function u(h){if(!(this instanceof u))return new u(h);this.options=h||{},this.options=s(c,h),this._inflights=new Map}u.prototype.put=function(h,d){return this._inflights.set(h.messageId,h),d&&d(),this},u.prototype.createStream=function(){const h=new a(l),d=[];let g=!1,v=0;return this._inflights.forEach(function(y,w){d.push(y)}),h._read=function(){!g&&v<d.length?this.push(d[v++]):this.push(null)},h.destroy=function(){if(g)return;const y=this;g=!0,setTimeout(function(){y.emit("close")},0)},h},u.prototype.del=function(h,d){return(h=this._inflights.get(h.messageId))?(this._inflights.delete(h.messageId),d(null,h)):d&&d(new Error("missing packet")),this},u.prototype.get=function(h,d){return(h=this._inflights.get(h.messageId))?d(null,h):d&&d(new Error("missing packet")),this},u.prototype.close=function(h){this.options.clean&&(this._inflights=null),h&&h()},n.exports=u},{"readable-stream":69,xtend:81}],9:[function(i,n,r){function s(a){if(!(this instanceof s))return new s(a);this.aliasToTopic={},this.max=a}s.prototype.put=function(a,l){return!(l===0||l>this.max)&&(this.aliasToTopic[l]=a,this.length=Object.keys(this.aliasToTopic).length,!0)},s.prototype.getTopicByAlias=function(a){return this.aliasToTopic[a]},s.prototype.clear=function(){this.aliasToTopic={}},n.exports=s},{}],10:[function(i,n,r){const s=i("lru-cache"),a=i("number-allocator").NumberAllocator;function l(c){if(!(this instanceof l))return new l(c);c>0&&(this.aliasToTopic=new s({max:c}),this.topicToAlias={},this.numberAllocator=new a(1,c),this.max=c,this.length=0)}l.prototype.put=function(c,u){if(u===0||u>this.max)return!1;const h=this.aliasToTopic.get(u);return h&&delete this.topicToAlias[h],this.aliasToTopic.set(u,c),this.topicToAlias[c]=u,this.numberAllocator.use(u),this.length=this.aliasToTopic.length,!0},l.prototype.getTopicByAlias=function(c){return this.aliasToTopic.get(c)},l.prototype.getAliasByTopic=function(c){const u=this.topicToAlias[c];return u!==void 0&&this.aliasToTopic.get(u),u},l.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},l.prototype.getLruAlias=function(){return this.numberAllocator.firstVacant()||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},n.exports=l},{"lru-cache":37,"number-allocator":46}],11:[function(i,n,r){function s(a){const l=a.split("/");for(let c=0;c<l.length;c++)if(l[c]!=="+"){if(l[c]==="#")return c===l.length-1;if(l[c].indexOf("+")!==-1||l[c].indexOf("#")!==-1)return!1}return!0}n.exports={validateTopics:function(a){if(a.length===0)return"empty_topic_list";for(let l=0;l<a.length;l++)if(!s(a[l]))return a[l];return null}}},{}],12:[function(i,n,r){(function(s){(function(){const a=i("../client"),l=i("../store"),c=i("url"),u=i("xtend"),h=i("debug")("mqttjs"),d={};function g(v,y){if(h("connecting to an MQTT broker..."),typeof v!="object"||y||(y=v,v=null),y=y||{},v){const p=c.parse(v,!0);if(p.port!=null&&(p.port=Number(p.port)),(y=u(p,y)).protocol===null)throw new Error("Missing protocol");y.protocol=y.protocol.replace(/:$/,"")}if(function(p){let _;p.auth&&((_=p.auth.match(/^(.+):(.+)$/))?(p.username=_[1],p.password=_[2]):p.username=p.auth)}(y),y.query&&typeof y.query.clientId=="string"&&(y.clientId=y.query.clientId),y.cert&&y.key){if(!y.protocol)throw new Error("Missing secure protocol key");if(["mqtts","wss","wxs","alis"].indexOf(y.protocol)===-1)switch(y.protocol){case"mqtt":y.protocol="mqtts";break;case"ws":y.protocol="wss";break;case"wx":y.protocol="wxs";break;case"ali":y.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+y.protocol+'"!')}}if(!d[y.protocol]){const p=["mqtts","wss"].indexOf(y.protocol)!==-1;y.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter(function(_,A){return(!p||A%2!=0)&&typeof d[_]=="function"})[0]}if(y.clean===!1&&!y.clientId)throw new Error("Missing clientId for unclean clients");y.protocol&&(y.defaultProtocol=y.protocol);const w=new a(function(p){return y.servers&&(p._reconnectCount&&p._reconnectCount!==y.servers.length||(p._reconnectCount=0),y.host=y.servers[p._reconnectCount].host,y.port=y.servers[p._reconnectCount].port,y.protocol=y.servers[p._reconnectCount].protocol?y.servers[p._reconnectCount].protocol:y.defaultProtocol,y.hostname=y.host,p._reconnectCount++),h("calling streambuilder for",y.protocol),d[y.protocol](p,y)},y);return w.on("error",function(){}),w}s!==void 0&&s.title!=="browser"||typeof __webpack_require__!="function"?(d.mqtt=i("./tcp"),d.tcp=i("./tcp"),d.ssl=i("./tls"),d.tls=i("./tls"),d.mqtts=i("./tls")):(d.wx=i("./wx"),d.wxs=i("./wx"),d.ali=i("./ali"),d.alis=i("./ali")),d.ws=i("./ws"),d.wss=i("./ws"),n.exports=g,n.exports.connect=g,n.exports.MqttClient=a,n.exports.Store=l}).call(this)}).call(this,i("_process"))},{"../client":1,"../store":8,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:50,debug:18,url:76,xtend:81}],13:[function(i,n,r){r.byteLength=function(v){var y=d(v),w=y[0],p=y[1];return 3*(w+p)/4-p},r.toByteArray=function(v){var y,w,p=d(v),_=p[0],A=p[1],x=new l(function(M,B,D){return 3*(B+D)/4-D}(0,_,A)),E=0,I=A>0?_-4:_;for(w=0;w<I;w+=4)y=a[v.charCodeAt(w)]<<18|a[v.charCodeAt(w+1)]<<12|a[v.charCodeAt(w+2)]<<6|a[v.charCodeAt(w+3)],x[E++]=y>>16&255,x[E++]=y>>8&255,x[E++]=255&y;return A===2&&(y=a[v.charCodeAt(w)]<<2|a[v.charCodeAt(w+1)]>>4,x[E++]=255&y),A===1&&(y=a[v.charCodeAt(w)]<<10|a[v.charCodeAt(w+1)]<<4|a[v.charCodeAt(w+2)]>>2,x[E++]=y>>8&255,x[E++]=255&y),x},r.fromByteArray=function(v){for(var y,w=v.length,p=w%3,_=[],A=0,x=w-p;A<x;A+=16383)_.push(g(v,A,A+16383>x?x:A+16383));return p===1?(y=v[w-1],_.push(s[y>>2]+s[y<<4&63]+"==")):p===2&&(y=(v[w-2]<<8)+v[w-1],_.push(s[y>>10]+s[y>>4&63]+s[y<<2&63]+"=")),_.join("")};for(var s=[],a=[],l=typeof Uint8Array<"u"?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,h=c.length;u<h;++u)s[u]=c[u],a[c.charCodeAt(u)]=u;function d(v){var y=v.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var w=v.indexOf("=");return w===-1&&(w=y),[w,w===y?0:4-w%4]}function g(v,y,w){for(var p,_,A=[],x=y;x<w;x+=3)p=(v[x]<<16&16711680)+(v[x+1]<<8&65280)+(255&v[x+2]),A.push(s[(_=p)>>18&63]+s[_>>12&63]+s[_>>6&63]+s[63&_]);return A.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],14:[function(i,n,r){const{Buffer:s}=i("buffer"),a=Symbol.for("BufferList");function l(c){if(!(this instanceof l))return new l(c);l._init.call(this,c)}l._init=function(c){Object.defineProperty(this,a,{value:!0}),this._bufs=[],this.length=0,c&&this.append(c)},l.prototype._new=function(c){return new l(c)},l.prototype._offset=function(c){if(c===0)return[0,0];let u=0;for(let h=0;h<this._bufs.length;h++){const d=u+this._bufs[h].length;if(c<d||h===this._bufs.length-1)return[h,c-u];u=d}},l.prototype._reverseOffset=function(c){const u=c[0];let h=c[1];for(let d=0;d<u;d++)h+=this._bufs[d].length;return h},l.prototype.get=function(c){if(c>this.length||c<0)return;const u=this._offset(c);return this._bufs[u[0]][u[1]]},l.prototype.slice=function(c,u){return typeof c=="number"&&c<0&&(c+=this.length),typeof u=="number"&&u<0&&(u+=this.length),this.copy(null,0,c,u)},l.prototype.copy=function(c,u,h,d){if((typeof h!="number"||h<0)&&(h=0),(typeof d!="number"||d>this.length)&&(d=this.length),h>=this.length||d<=0)return c||s.alloc(0);const g=!!c,v=this._offset(h),y=d-h;let w=y,p=g&&u||0,_=v[1];if(h===0&&d===this.length){if(!g)return this._bufs.length===1?this._bufs[0]:s.concat(this._bufs,this.length);for(let A=0;A<this._bufs.length;A++)this._bufs[A].copy(c,p),p+=this._bufs[A].length;return c}if(w<=this._bufs[v[0]].length-_)return g?this._bufs[v[0]].copy(c,u,_,_+w):this._bufs[v[0]].slice(_,_+w);g||(c=s.allocUnsafe(y));for(let A=v[0];A<this._bufs.length;A++){const x=this._bufs[A].length-_;if(!(w>x)){this._bufs[A].copy(c,p,_,_+w),p+=x;break}this._bufs[A].copy(c,p,_),p+=x,w-=x,_&&(_=0)}return c.length>p?c.slice(0,p):c},l.prototype.shallowSlice=function(c,u){if(c=c||0,u=typeof u!="number"?this.length:u,c<0&&(c+=this.length),u<0&&(u+=this.length),c===u)return this._new();const h=this._offset(c),d=this._offset(u),g=this._bufs.slice(h[0],d[0]+1);return d[1]===0?g.pop():g[g.length-1]=g[g.length-1].slice(0,d[1]),h[1]!==0&&(g[0]=g[0].slice(h[1])),this._new(g)},l.prototype.toString=function(c,u,h){return this.slice(u,h).toString(c)},l.prototype.consume=function(c){if(c=Math.trunc(c),Number.isNaN(c)||c<=0)return this;for(;this._bufs.length;){if(!(c>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(c),this.length-=c;break}c-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},l.prototype.duplicate=function(){const c=this._new();for(let u=0;u<this._bufs.length;u++)c.append(this._bufs[u]);return c},l.prototype.append=function(c){if(c==null)return this;if(c.buffer)this._appendBuffer(s.from(c.buffer,c.byteOffset,c.byteLength));else if(Array.isArray(c))for(let u=0;u<c.length;u++)this.append(c[u]);else if(this._isBufferList(c))for(let u=0;u<c._bufs.length;u++)this.append(c._bufs[u]);else typeof c=="number"&&(c=c.toString()),this._appendBuffer(s.from(c));return this},l.prototype._appendBuffer=function(c){this._bufs.push(c),this.length+=c.length},l.prototype.indexOf=function(c,u,h){if(h===void 0&&typeof u=="string"&&(h=u,u=void 0),typeof c=="function"||Array.isArray(c))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof c=="number"?c=s.from([c]):typeof c=="string"?c=s.from(c,h):this._isBufferList(c)?c=c.slice():Array.isArray(c.buffer)?c=s.from(c.buffer,c.byteOffset,c.byteLength):s.isBuffer(c)||(c=s.from(c)),u=Number(u||0),isNaN(u)&&(u=0),u<0&&(u=this.length+u),u<0&&(u=0),c.length===0)return u>this.length?this.length:u;const d=this._offset(u);let g=d[0],v=d[1];for(;g<this._bufs.length;g++){const y=this._bufs[g];for(;v<y.length;)if(y.length-v>=c.length){const w=y.indexOf(c,v);if(w!==-1)return this._reverseOffset([g,w]);v=y.length-c.length+1}else{const w=this._reverseOffset([g,v]);if(this._match(w,c))return w;v++}v=0}return-1},l.prototype._match=function(c,u){if(this.length-c<u.length)return!1;for(let h=0;h<u.length;h++)if(this.get(c+h)!==u[h])return!1;return!0},function(){const c={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const u in c)(function(h){l.prototype[h]=c[h]===null?function(d,g){return this.slice(d,d+g)[h](0,g)}:function(d=0){return this.slice(d,d+c[h])[h](0)}})(u)}(),l.prototype._isBufferList=function(c){return c instanceof l||l.isBufferList(c)},l.isBufferList=function(c){return c!=null&&c[a]},n.exports=l},{buffer:17}],15:[function(i,n,r){const s=i("readable-stream").Duplex,a=i("inherits"),l=i("./BufferList");function c(u){if(!(this instanceof c))return new c(u);if(typeof u=="function"){this._callback=u;const h=function(d){this._callback&&(this._callback(d),this._callback=null)}.bind(this);this.on("pipe",function(d){d.on("error",h)}),this.on("unpipe",function(d){d.removeListener("error",h)}),u=null}l._init.call(this,u),s.call(this)}a(c,s),Object.assign(c.prototype,l.prototype),c.prototype._new=function(u){return new c(u)},c.prototype._write=function(u,h,d){this._appendBuffer(u),typeof d=="function"&&d()},c.prototype._read=function(u){if(!this.length)return this.push(null);u=Math.min(u,this.length),this.push(this.slice(0,u)),this.consume(u)},c.prototype.end=function(u){s.prototype.end.call(this,u),this._callback&&(this._callback(null,this.slice()),this._callback=null)},c.prototype._destroy=function(u,h){this._bufs.length=0,this.length=0,h(u)},c.prototype._isBufferList=function(u){return u instanceof c||u instanceof l||c.isBufferList(u)},c.isBufferList=l.isBufferList,n.exports=c,n.exports.BufferListStream=c,n.exports.BufferList=l},{"./BufferList":14,inherits:24,"readable-stream":69}],16:[function(i,n,r){},{}],17:[function(i,n,r){(function(s){(function(){var a=i("base64-js"),l=i("ieee754");r.Buffer=h,r.SlowBuffer=function(b){return+b!=b&&(b=0),h.alloc(+b)},r.INSPECT_MAX_BYTES=50;var c=2147483647;function u(b){if(b>c)throw new RangeError('The value "'+b+'" is invalid for option "size"');var k=new Uint8Array(b);return k.__proto__=h.prototype,k}function h(b,k,P){if(typeof b=="number"){if(typeof k=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(b)}return d(b,k,P)}function d(b,k,P){if(typeof b=="string")return function(J,at){if(typeof at=="string"&&at!==""||(at="utf8"),!h.isEncoding(at))throw new TypeError("Unknown encoding: "+at);var mt=0|p(J,at),yt=u(mt),kt=yt.write(J,at);return kt!==mt&&(yt=yt.slice(0,kt)),yt}(b,k);if(ArrayBuffer.isView(b))return y(b);if(b==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(lt(b,ArrayBuffer)||b&&lt(b.buffer,ArrayBuffer))return function(J,at,mt){if(at<0||J.byteLength<at)throw new RangeError('"offset" is outside of buffer bounds');if(J.byteLength<at+(mt||0))throw new RangeError('"length" is outside of buffer bounds');var yt;return yt=at===void 0&&mt===void 0?new Uint8Array(J):mt===void 0?new Uint8Array(J,at):new Uint8Array(J,at,mt),yt.__proto__=h.prototype,yt}(b,k,P);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var H=b.valueOf&&b.valueOf();if(H!=null&&H!==b)return h.from(H,k,P);var X=function(J){if(h.isBuffer(J)){var at=0|w(J.length),mt=u(at);return mt.length===0||J.copy(mt,0,0,at),mt}if(J.length!==void 0)return typeof J.length!="number"||ut(J.length)?u(0):y(J);if(J.type==="Buffer"&&Array.isArray(J.data))return y(J.data)}(b);if(X)return X;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return h.from(b[Symbol.toPrimitive]("string"),k,P);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}function g(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(b<0)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function v(b){return g(b),u(b<0?0:0|w(b))}function y(b){for(var k=b.length<0?0:0|w(b.length),P=u(k),H=0;H<k;H+=1)P[H]=255&b[H];return P}function w(b){if(b>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return 0|b}function p(b,k){if(h.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||lt(b,ArrayBuffer))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);var P=b.length,H=arguments.length>2&&arguments[2]===!0;if(!H&&P===0)return 0;for(var X=!1;;)switch(k){case"ascii":case"latin1":case"binary":return P;case"utf8":case"utf-8":return rt(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*P;case"hex":return P>>>1;case"base64":return nt(b).length;default:if(X)return H?-1:rt(b).length;k=(""+k).toLowerCase(),X=!0}}function _(b,k,P){var H=b[k];b[k]=b[P],b[P]=H}function A(b,k,P,H,X){if(b.length===0)return-1;if(typeof P=="string"?(H=P,P=0):P>2147483647?P=2147483647:P<-2147483648&&(P=-2147483648),ut(P=+P)&&(P=X?0:b.length-1),P<0&&(P=b.length+P),P>=b.length){if(X)return-1;P=b.length-1}else if(P<0){if(!X)return-1;P=0}if(typeof k=="string"&&(k=h.from(k,H)),h.isBuffer(k))return k.length===0?-1:x(b,k,P,H,X);if(typeof k=="number")return k&=255,typeof Uint8Array.prototype.indexOf=="function"?X?Uint8Array.prototype.indexOf.call(b,k,P):Uint8Array.prototype.lastIndexOf.call(b,k,P):x(b,[k],P,H,X);throw new TypeError("val must be string, number or Buffer")}function x(b,k,P,H,X){var J,at=1,mt=b.length,yt=k.length;if(H!==void 0&&((H=String(H).toLowerCase())==="ucs2"||H==="ucs-2"||H==="utf16le"||H==="utf-16le")){if(b.length<2||k.length<2)return-1;at=2,mt/=2,yt/=2,P/=2}function kt(xe,Vt){return at===1?xe[Vt]:xe.readUInt16BE(Vt*at)}if(X){var Tt=-1;for(J=P;J<mt;J++)if(kt(b,J)===kt(k,Tt===-1?0:J-Tt)){if(Tt===-1&&(Tt=J),J-Tt+1===yt)return Tt*at}else Tt!==-1&&(J-=J-Tt),Tt=-1}else for(P+yt>mt&&(P=mt-yt),J=P;J>=0;J--){for(var be=!0,ne=0;ne<yt;ne++)if(kt(b,J+ne)!==kt(k,ne)){be=!1;break}if(be)return J}return-1}function E(b,k,P,H){P=Number(P)||0;var X=b.length-P;H?(H=Number(H))>X&&(H=X):H=X;var J=k.length;H>J/2&&(H=J/2);for(var at=0;at<H;++at){var mt=parseInt(k.substr(2*at,2),16);if(ut(mt))return at;b[P+at]=mt}return at}function I(b,k,P,H){return ft(rt(k,b.length-P),b,P,H)}function M(b,k,P,H){return ft(function(X){for(var J=[],at=0;at<X.length;++at)J.push(255&X.charCodeAt(at));return J}(k),b,P,H)}function B(b,k,P,H){return M(b,k,P,H)}function D(b,k,P,H){return ft(nt(k),b,P,H)}function q(b,k,P,H){return ft(function(X,J){for(var at,mt,yt,kt=[],Tt=0;Tt<X.length&&!((J-=2)<0);++Tt)at=X.charCodeAt(Tt),mt=at>>8,yt=at%256,kt.push(yt),kt.push(mt);return kt}(k,b.length-P),b,P,H)}function Q(b,k,P){return k===0&&P===b.length?a.fromByteArray(b):a.fromByteArray(b.slice(k,P))}function C(b,k,P){P=Math.min(b.length,P);for(var H=[],X=k;X<P;){var J,at,mt,yt,kt=b[X],Tt=null,be=kt>239?4:kt>223?3:kt>191?2:1;if(X+be<=P)switch(be){case 1:kt<128&&(Tt=kt);break;case 2:(192&(J=b[X+1]))==128&&(yt=(31&kt)<<6|63&J)>127&&(Tt=yt);break;case 3:J=b[X+1],at=b[X+2],(192&J)==128&&(192&at)==128&&(yt=(15&kt)<<12|(63&J)<<6|63&at)>2047&&(yt<55296||yt>57343)&&(Tt=yt);break;case 4:J=b[X+1],at=b[X+2],mt=b[X+3],(192&J)==128&&(192&at)==128&&(192&mt)==128&&(yt=(15&kt)<<18|(63&J)<<12|(63&at)<<6|63&mt)>65535&&yt<1114112&&(Tt=yt)}Tt===null?(Tt=65533,be=1):Tt>65535&&(Tt-=65536,H.push(Tt>>>10&1023|55296),Tt=56320|1023&Tt),H.push(Tt),X+=be}return function(ne){var xe=ne.length;if(xe<=T)return String.fromCharCode.apply(String,ne);for(var Vt="",Qt=0;Qt<xe;)Vt+=String.fromCharCode.apply(String,ne.slice(Qt,Qt+=T));return Vt}(H)}r.kMaxLength=c,h.TYPED_ARRAY_SUPPORT=function(){try{var b=new Uint8Array(1);return b.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},b.foo()===42}catch{return!1}}(),h.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}}),typeof Symbol<"u"&&Symbol.species!=null&&h[Symbol.species]===h&&Object.defineProperty(h,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),h.poolSize=8192,h.from=function(b,k,P){return d(b,k,P)},h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array,h.alloc=function(b,k,P){return function(H,X,J){return g(H),H<=0?u(H):X!==void 0?typeof J=="string"?u(H).fill(X,J):u(H).fill(X):u(H)}(b,k,P)},h.allocUnsafe=function(b){return v(b)},h.allocUnsafeSlow=function(b){return v(b)},h.isBuffer=function(b){return b!=null&&b._isBuffer===!0&&b!==h.prototype},h.compare=function(b,k){if(lt(b,Uint8Array)&&(b=h.from(b,b.offset,b.byteLength)),lt(k,Uint8Array)&&(k=h.from(k,k.offset,k.byteLength)),!h.isBuffer(b)||!h.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(b===k)return 0;for(var P=b.length,H=k.length,X=0,J=Math.min(P,H);X<J;++X)if(b[X]!==k[X]){P=b[X],H=k[X];break}return P<H?-1:H<P?1:0},h.isEncoding=function(b){switch(String(b).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(b,k){if(!Array.isArray(b))throw new TypeError('"list" argument must be an Array of Buffers');if(b.length===0)return h.alloc(0);var P;if(k===void 0)for(k=0,P=0;P<b.length;++P)k+=b[P].length;var H=h.allocUnsafe(k),X=0;for(P=0;P<b.length;++P){var J=b[P];if(lt(J,Uint8Array)&&(J=h.from(J)),!h.isBuffer(J))throw new TypeError('"list" argument must be an Array of Buffers');J.copy(H,X),X+=J.length}return H},h.byteLength=p,h.prototype._isBuffer=!0,h.prototype.swap16=function(){var b=this.length;if(b%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var k=0;k<b;k+=2)_(this,k,k+1);return this},h.prototype.swap32=function(){var b=this.length;if(b%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var k=0;k<b;k+=4)_(this,k,k+3),_(this,k+1,k+2);return this},h.prototype.swap64=function(){var b=this.length;if(b%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var k=0;k<b;k+=8)_(this,k,k+7),_(this,k+1,k+6),_(this,k+2,k+5),_(this,k+3,k+4);return this},h.prototype.toString=function(){var b=this.length;return b===0?"":arguments.length===0?C(this,0,b):function(k,P,H){var X=!1;if((P===void 0||P<0)&&(P=0),P>this.length||((H===void 0||H>this.length)&&(H=this.length),H<=0)||(H>>>=0)<=(P>>>=0))return"";for(k||(k="utf8");;)switch(k){case"hex":return K(this,P,H);case"utf8":case"utf-8":return C(this,P,H);case"ascii":return S(this,P,H);case"latin1":case"binary":return O(this,P,H);case"base64":return Q(this,P,H);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Z(this,P,H);default:if(X)throw new TypeError("Unknown encoding: "+k);k=(k+"").toLowerCase(),X=!0}}.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(b){if(!h.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||h.compare(this,b)===0},h.prototype.inspect=function(){var b="",k=r.INSPECT_MAX_BYTES;return b=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(b+=" ... "),"<Buffer "+b+">"},h.prototype.compare=function(b,k,P,H,X){if(lt(b,Uint8Array)&&(b=h.from(b,b.offset,b.byteLength)),!h.isBuffer(b))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof b);if(k===void 0&&(k=0),P===void 0&&(P=b?b.length:0),H===void 0&&(H=0),X===void 0&&(X=this.length),k<0||P>b.length||H<0||X>this.length)throw new RangeError("out of range index");if(H>=X&&k>=P)return 0;if(H>=X)return-1;if(k>=P)return 1;if(k>>>=0,P>>>=0,H>>>=0,X>>>=0,this===b)return 0;for(var J=X-H,at=P-k,mt=Math.min(J,at),yt=this.slice(H,X),kt=b.slice(k,P),Tt=0;Tt<mt;++Tt)if(yt[Tt]!==kt[Tt]){J=yt[Tt],at=kt[Tt];break}return J<at?-1:at<J?1:0},h.prototype.includes=function(b,k,P){return this.indexOf(b,k,P)!==-1},h.prototype.indexOf=function(b,k,P){return A(this,b,k,P,!0)},h.prototype.lastIndexOf=function(b,k,P){return A(this,b,k,P,!1)},h.prototype.write=function(b,k,P,H){if(k===void 0)H="utf8",P=this.length,k=0;else if(P===void 0&&typeof k=="string")H=k,P=this.length,k=0;else{if(!isFinite(k))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");k>>>=0,isFinite(P)?(P>>>=0,H===void 0&&(H="utf8")):(H=P,P=void 0)}var X=this.length-k;if((P===void 0||P>X)&&(P=X),b.length>0&&(P<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");H||(H="utf8");for(var J=!1;;)switch(H){case"hex":return E(this,b,k,P);case"utf8":case"utf-8":return I(this,b,k,P);case"ascii":return M(this,b,k,P);case"latin1":case"binary":return B(this,b,k,P);case"base64":return D(this,b,k,P);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,b,k,P);default:if(J)throw new TypeError("Unknown encoding: "+H);H=(""+H).toLowerCase(),J=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function S(b,k,P){var H="";P=Math.min(b.length,P);for(var X=k;X<P;++X)H+=String.fromCharCode(127&b[X]);return H}function O(b,k,P){var H="";P=Math.min(b.length,P);for(var X=k;X<P;++X)H+=String.fromCharCode(b[X]);return H}function K(b,k,P){var H=b.length;(!k||k<0)&&(k=0),(!P||P<0||P>H)&&(P=H);for(var X="",J=k;J<P;++J)X+=tt(b[J]);return X}function Z(b,k,P){for(var H=b.slice(k,P),X="",J=0;J<H.length;J+=2)X+=String.fromCharCode(H[J]+256*H[J+1]);return X}function st(b,k,P){if(b%1!=0||b<0)throw new RangeError("offset is not uint");if(b+k>P)throw new RangeError("Trying to access beyond buffer length")}function $(b,k,P,H,X,J){if(!h.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(k>X||k<J)throw new RangeError('"value" argument is out of bounds');if(P+H>b.length)throw new RangeError("Index out of range")}function z(b,k,P,H,X,J){if(P+H>b.length)throw new RangeError("Index out of range");if(P<0)throw new RangeError("Index out of range")}function V(b,k,P,H,X){return k=+k,P>>>=0,X||z(b,0,P,4),l.write(b,k,P,H,23,4),P+4}function Y(b,k,P,H,X){return k=+k,P>>>=0,X||z(b,0,P,8),l.write(b,k,P,H,52,8),P+8}h.prototype.slice=function(b,k){var P=this.length;b=~~b,k=k===void 0?P:~~k,b<0?(b+=P)<0&&(b=0):b>P&&(b=P),k<0?(k+=P)<0&&(k=0):k>P&&(k=P),k<b&&(k=b);var H=this.subarray(b,k);return H.__proto__=h.prototype,H},h.prototype.readUIntLE=function(b,k,P){b>>>=0,k>>>=0,P||st(b,k,this.length);for(var H=this[b],X=1,J=0;++J<k&&(X*=256);)H+=this[b+J]*X;return H},h.prototype.readUIntBE=function(b,k,P){b>>>=0,k>>>=0,P||st(b,k,this.length);for(var H=this[b+--k],X=1;k>0&&(X*=256);)H+=this[b+--k]*X;return H},h.prototype.readUInt8=function(b,k){return b>>>=0,k||st(b,1,this.length),this[b]},h.prototype.readUInt16LE=function(b,k){return b>>>=0,k||st(b,2,this.length),this[b]|this[b+1]<<8},h.prototype.readUInt16BE=function(b,k){return b>>>=0,k||st(b,2,this.length),this[b]<<8|this[b+1]},h.prototype.readUInt32LE=function(b,k){return b>>>=0,k||st(b,4,this.length),(this[b]|this[b+1]<<8|this[b+2]<<16)+16777216*this[b+3]},h.prototype.readUInt32BE=function(b,k){return b>>>=0,k||st(b,4,this.length),16777216*this[b]+(this[b+1]<<16|this[b+2]<<8|this[b+3])},h.prototype.readIntLE=function(b,k,P){b>>>=0,k>>>=0,P||st(b,k,this.length);for(var H=this[b],X=1,J=0;++J<k&&(X*=256);)H+=this[b+J]*X;return H>=(X*=128)&&(H-=Math.pow(2,8*k)),H},h.prototype.readIntBE=function(b,k,P){b>>>=0,k>>>=0,P||st(b,k,this.length);for(var H=k,X=1,J=this[b+--H];H>0&&(X*=256);)J+=this[b+--H]*X;return J>=(X*=128)&&(J-=Math.pow(2,8*k)),J},h.prototype.readInt8=function(b,k){return b>>>=0,k||st(b,1,this.length),128&this[b]?-1*(255-this[b]+1):this[b]},h.prototype.readInt16LE=function(b,k){b>>>=0,k||st(b,2,this.length);var P=this[b]|this[b+1]<<8;return 32768&P?4294901760|P:P},h.prototype.readInt16BE=function(b,k){b>>>=0,k||st(b,2,this.length);var P=this[b+1]|this[b]<<8;return 32768&P?4294901760|P:P},h.prototype.readInt32LE=function(b,k){return b>>>=0,k||st(b,4,this.length),this[b]|this[b+1]<<8|this[b+2]<<16|this[b+3]<<24},h.prototype.readInt32BE=function(b,k){return b>>>=0,k||st(b,4,this.length),this[b]<<24|this[b+1]<<16|this[b+2]<<8|this[b+3]},h.prototype.readFloatLE=function(b,k){return b>>>=0,k||st(b,4,this.length),l.read(this,b,!0,23,4)},h.prototype.readFloatBE=function(b,k){return b>>>=0,k||st(b,4,this.length),l.read(this,b,!1,23,4)},h.prototype.readDoubleLE=function(b,k){return b>>>=0,k||st(b,8,this.length),l.read(this,b,!0,52,8)},h.prototype.readDoubleBE=function(b,k){return b>>>=0,k||st(b,8,this.length),l.read(this,b,!1,52,8)},h.prototype.writeUIntLE=function(b,k,P,H){b=+b,k>>>=0,P>>>=0,H||$(this,b,k,P,Math.pow(2,8*P)-1,0);var X=1,J=0;for(this[k]=255&b;++J<P&&(X*=256);)this[k+J]=b/X&255;return k+P},h.prototype.writeUIntBE=function(b,k,P,H){b=+b,k>>>=0,P>>>=0,H||$(this,b,k,P,Math.pow(2,8*P)-1,0);var X=P-1,J=1;for(this[k+X]=255&b;--X>=0&&(J*=256);)this[k+X]=b/J&255;return k+P},h.prototype.writeUInt8=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,1,255,0),this[k]=255&b,k+1},h.prototype.writeUInt16LE=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,2,65535,0),this[k]=255&b,this[k+1]=b>>>8,k+2},h.prototype.writeUInt16BE=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,2,65535,0),this[k]=b>>>8,this[k+1]=255&b,k+2},h.prototype.writeUInt32LE=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,4,4294967295,0),this[k+3]=b>>>24,this[k+2]=b>>>16,this[k+1]=b>>>8,this[k]=255&b,k+4},h.prototype.writeUInt32BE=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,4,4294967295,0),this[k]=b>>>24,this[k+1]=b>>>16,this[k+2]=b>>>8,this[k+3]=255&b,k+4},h.prototype.writeIntLE=function(b,k,P,H){if(b=+b,k>>>=0,!H){var X=Math.pow(2,8*P-1);$(this,b,k,P,X-1,-X)}var J=0,at=1,mt=0;for(this[k]=255&b;++J<P&&(at*=256);)b<0&&mt===0&&this[k+J-1]!==0&&(mt=1),this[k+J]=(b/at>>0)-mt&255;return k+P},h.prototype.writeIntBE=function(b,k,P,H){if(b=+b,k>>>=0,!H){var X=Math.pow(2,8*P-1);$(this,b,k,P,X-1,-X)}var J=P-1,at=1,mt=0;for(this[k+J]=255&b;--J>=0&&(at*=256);)b<0&&mt===0&&this[k+J+1]!==0&&(mt=1),this[k+J]=(b/at>>0)-mt&255;return k+P},h.prototype.writeInt8=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,1,127,-128),b<0&&(b=255+b+1),this[k]=255&b,k+1},h.prototype.writeInt16LE=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,2,32767,-32768),this[k]=255&b,this[k+1]=b>>>8,k+2},h.prototype.writeInt16BE=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,2,32767,-32768),this[k]=b>>>8,this[k+1]=255&b,k+2},h.prototype.writeInt32LE=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,4,2147483647,-2147483648),this[k]=255&b,this[k+1]=b>>>8,this[k+2]=b>>>16,this[k+3]=b>>>24,k+4},h.prototype.writeInt32BE=function(b,k,P){return b=+b,k>>>=0,P||$(this,b,k,4,2147483647,-2147483648),b<0&&(b=4294967295+b+1),this[k]=b>>>24,this[k+1]=b>>>16,this[k+2]=b>>>8,this[k+3]=255&b,k+4},h.prototype.writeFloatLE=function(b,k,P){return V(this,b,k,!0,P)},h.prototype.writeFloatBE=function(b,k,P){return V(this,b,k,!1,P)},h.prototype.writeDoubleLE=function(b,k,P){return Y(this,b,k,!0,P)},h.prototype.writeDoubleBE=function(b,k,P){return Y(this,b,k,!1,P)},h.prototype.copy=function(b,k,P,H){if(!h.isBuffer(b))throw new TypeError("argument should be a Buffer");if(P||(P=0),H||H===0||(H=this.length),k>=b.length&&(k=b.length),k||(k=0),H>0&&H<P&&(H=P),H===P||b.length===0||this.length===0)return 0;if(k<0)throw new RangeError("targetStart out of bounds");if(P<0||P>=this.length)throw new RangeError("Index out of range");if(H<0)throw new RangeError("sourceEnd out of bounds");H>this.length&&(H=this.length),b.length-k<H-P&&(H=b.length-k+P);var X=H-P;if(this===b&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(k,P,H);else if(this===b&&P<k&&k<H)for(var J=X-1;J>=0;--J)b[J+k]=this[J+P];else Uint8Array.prototype.set.call(b,this.subarray(P,H),k);return X},h.prototype.fill=function(b,k,P,H){if(typeof b=="string"){if(typeof k=="string"?(H=k,k=0,P=this.length):typeof P=="string"&&(H=P,P=this.length),H!==void 0&&typeof H!="string")throw new TypeError("encoding must be a string");if(typeof H=="string"&&!h.isEncoding(H))throw new TypeError("Unknown encoding: "+H);if(b.length===1){var X=b.charCodeAt(0);(H==="utf8"&&X<128||H==="latin1")&&(b=X)}}else typeof b=="number"&&(b&=255);if(k<0||this.length<k||this.length<P)throw new RangeError("Out of range index");if(P<=k)return this;var J;if(k>>>=0,P=P===void 0?this.length:P>>>0,b||(b=0),typeof b=="number")for(J=k;J<P;++J)this[J]=b;else{var at=h.isBuffer(b)?b:h.from(b,H),mt=at.length;if(mt===0)throw new TypeError('The value "'+b+'" is invalid for argument "value"');for(J=0;J<P-k;++J)this[J+k]=at[J%mt]}return this};var U=/[^+/0-9A-Za-z-_]/g;function tt(b){return b<16?"0"+b.toString(16):b.toString(16)}function rt(b,k){var P;k=k||1/0;for(var H=b.length,X=null,J=[],at=0;at<H;++at){if((P=b.charCodeAt(at))>55295&&P<57344){if(!X){if(P>56319){(k-=3)>-1&&J.push(239,191,189);continue}if(at+1===H){(k-=3)>-1&&J.push(239,191,189);continue}X=P;continue}if(P<56320){(k-=3)>-1&&J.push(239,191,189),X=P;continue}P=65536+(X-55296<<10|P-56320)}else X&&(k-=3)>-1&&J.push(239,191,189);if(X=null,P<128){if((k-=1)<0)break;J.push(P)}else if(P<2048){if((k-=2)<0)break;J.push(P>>6|192,63&P|128)}else if(P<65536){if((k-=3)<0)break;J.push(P>>12|224,P>>6&63|128,63&P|128)}else{if(!(P<1114112))throw new Error("Invalid code point");if((k-=4)<0)break;J.push(P>>18|240,P>>12&63|128,P>>6&63|128,63&P|128)}}return J}function nt(b){return a.toByteArray(function(k){if((k=(k=k.split("=")[0]).trim().replace(U,"")).length<2)return"";for(;k.length%4!=0;)k+="=";return k}(b))}function ft(b,k,P,H){for(var X=0;X<H&&!(X+P>=k.length||X>=b.length);++X)k[X+P]=b[X];return X}function lt(b,k){return b instanceof k||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===k.name}function ut(b){return b!=b}}).call(this)}).call(this,i("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(i,n,r){(function(s){(function(){r.formatArgs=function(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const c="color: "+this.color;l.splice(1,0,c,"color: inherit");let u=0,h=0;l[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&d==="%c"&&(h=++u)}),l.splice(h,0,c)},r.save=function(l){try{l?r.storage.setItem("debug",l):r.storage.removeItem("debug")}catch{}},r.load=function(){let l;try{l=r.storage.getItem("debug")}catch{}return!l&&s!==void 0&&"env"in s&&(l=s.env.DEBUG),l},r.useColors=function(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage=function(){try{return localStorage}catch{}}(),r.destroy=(()=>{let l=!1;return()=>{l||(l=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),n.exports=i("./common")(r);const{formatters:a}=n.exports;a.j=function(l){try{return JSON.stringify(l)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}}}).call(this)}).call(this,i("_process"))},{"./common":19,_process:50}],19:[function(i,n,r){n.exports=function(s){function a(u){let h,d,g,v=null;function y(...w){if(!y.enabled)return;const p=y,_=Number(new Date),A=_-(h||_);p.diff=A,p.prev=h,p.curr=_,h=_,w[0]=a.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let x=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(E,I)=>{if(E==="%%")return"%";x++;const M=a.formatters[I];if(typeof M=="function"){const B=w[x];E=M.call(p,B),w.splice(x,1),x--}return E}),a.formatArgs.call(p,w),(p.log||a.log).apply(p,w)}return y.namespace=u,y.useColors=a.useColors(),y.color=a.selectColor(u),y.extend=l,y.destroy=a.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(d!==a.namespaces&&(d=a.namespaces,g=a.enabled(u)),g),set:w=>{v=w}}),typeof a.init=="function"&&a.init(y),y}function l(u,h){const d=a(this.namespace+(h===void 0?":":h)+u);return d.log=this.log,d}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}return a.debug=a,a.default=a,a.coerce=function(u){return u instanceof Error?u.stack||u.message:u},a.disable=function(){const u=[...a.names.map(c),...a.skips.map(c).map(h=>"-"+h)].join(",");return a.enable(""),u},a.enable=function(u){let h;a.save(u),a.namespaces=u,a.names=[],a.skips=[];const d=(typeof u=="string"?u:"").split(/[\s,]+/),g=d.length;for(h=0;h<g;h++)d[h]&&((u=d[h].replace(/\*/g,".*?"))[0]==="-"?a.skips.push(new RegExp("^"+u.substr(1)+"$")):a.names.push(new RegExp("^"+u+"$")))},a.enabled=function(u){if(u[u.length-1]==="*")return!0;let h,d;for(h=0,d=a.skips.length;h<d;h++)if(a.skips[h].test(u))return!1;for(h=0,d=a.names.length;h<d;h++)if(a.names[h].test(u))return!0;return!1},a.humanize=i("ms"),a.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(s).forEach(u=>{a[u]=s[u]}),a.names=[],a.skips=[],a.formatters={},a.selectColor=function(u){let h=0;for(let d=0;d<u.length;d++)h=(h<<5)-h+u.charCodeAt(d),h|=0;return a.colors[Math.abs(h)%a.colors.length]},a.enable(a.load()),a}},{ms:45}],20:[function(i,n,r){(function(s,a){(function(){var l=i("readable-stream"),c=i("end-of-stream"),u=i("inherits"),h=i("stream-shift"),d=a.from&&a.from!==Uint8Array.from?a.from([0]):new a([0]),g=function(p,_){p._corked?p.once("uncork",_):_()},v=function(p,_){return function(A){A?function(x,E){x._autoDestroy&&x.destroy(E)}(p,A.message==="premature close"?null:A):_&&!p._ended&&p.end()}},y=function(){},w=function(p,_,A){if(!(this instanceof w))return new w(p,_,A);l.Duplex.call(this,A),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!A||A.autoDestroy!==!1,this._forwardDestroy=!A||A.destroy!==!1,this._forwardEnd=!A||A.end!==!1,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,p&&this.setWritable(p),_&&this.setReadable(_)};u(w,l.Duplex),w.obj=function(p,_,A){return A||(A={}),A.objectMode=!0,A.highWaterMark=16,new w(p,_,A)},w.prototype.cork=function(){++this._corked==1&&this.emit("cork")},w.prototype.uncork=function(){this._corked&&--this._corked==0&&this.emit("uncork")},w.prototype.setWritable=function(p){if(this._unwrite&&this._unwrite(),this.destroyed)p&&p.destroy&&p.destroy();else if(p!==null&&p!==!1){var _=this,A=c(p,{writable:!0,readable:!1},v(this,this._forwardEnd)),x=function(){var E=_._ondrain;_._ondrain=null,E&&E()};this._unwrite&&s.nextTick(x),this._writable=p,this._writable.on("drain",x),this._unwrite=function(){_._writable.removeListener("drain",x),A()},this.uncork()}else this.end()},w.prototype.setReadable=function(p){if(this._unread&&this._unread(),this.destroyed)p&&p.destroy&&p.destroy();else{if(p===null||p===!1)return this.push(null),void this.resume();var _,A=this,x=c(p,{writable:!1,readable:!0},v(this)),E=function(){A._forward()},I=function(){A.push(null)};this._drained=!0,this._readable=p,this._readable2=p._readableState?p:(_=p,new l.Readable({objectMode:!0,highWaterMark:16}).wrap(_)),this._readable2.on("readable",E),this._readable2.on("end",I),this._unread=function(){A._readable2.removeListener("readable",E),A._readable2.removeListener("end",I),x()},this._forward()}},w.prototype._read=function(){this._drained=!0,this._forward()},w.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var p;for(this._forwarding=!0;this._drained&&(p=h(this._readable2))!==null;)this.destroyed||(this._drained=this.push(p));this._forwarding=!1}},w.prototype.destroy=function(p,_){if(_||(_=y),this.destroyed)return _(null);this.destroyed=!0;var A=this;s.nextTick(function(){A._destroy(p),_(null)})},w.prototype._destroy=function(p){if(p){var _=this._ondrain;this._ondrain=null,_?_(p):this.emit("error",p)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},w.prototype._write=function(p,_,A){if(!this.destroyed)return this._corked?g(this,this._write.bind(this,p,_,A)):p===d?this._finish(A):this._writable?void(this._writable.write(p)===!1?this._ondrain=A:this.destroyed||A()):A()},w.prototype._finish=function(p){var _=this;this.emit("preend"),g(this,function(){var A,x;A=_._forwardEnd&&_._writable,x=function(){_._writableState.prefinished===!1&&(_._writableState.prefinished=!0),_.emit("prefinish"),g(_,p)},A?A._writableState&&A._writableState.finished?x():A._writableState?A.end(x):(A.end(),x()):x()})},w.prototype.end=function(p,_,A){return typeof p=="function"?this.end(null,null,p):typeof _=="function"?this.end(p,null,_):(this._ended=!0,p&&this.write(p),this._writableState.ending||this._writableState.destroyed||this.write(d),l.Writable.prototype.end.call(this,A))},n.exports=w}).call(this)}).call(this,i("_process"),i("buffer").Buffer)},{_process:50,buffer:17,"end-of-stream":21,inherits:24,"readable-stream":69,"stream-shift":74}],21:[function(i,n,r){(function(s){(function(){var a=i("once"),l=function(){},c=function(u,h,d){if(typeof h=="function")return c(u,null,h);h||(h={}),d=a(d||l);var g=u._writableState,v=u._readableState,y=h.readable||h.readable!==!1&&u.readable,w=h.writable||h.writable!==!1&&u.writable,p=!1,_=function(){u.writable||A()},A=function(){w=!1,y||d.call(u)},x=function(){y=!1,w||d.call(u)},E=function(q){d.call(u,q?new Error("exited with error code: "+q):null)},I=function(q){d.call(u,q)},M=function(){s.nextTick(B)},B=function(){if(!p)return(!y||v&&v.ended&&!v.destroyed)&&(!w||g&&g.ended&&!g.destroyed)?void 0:d.call(u,new Error("premature close"))},D=function(){u.req.on("finish",A)};return function(q){return q.setHeader&&typeof q.abort=="function"}(u)?(u.on("complete",A),u.on("abort",M),u.req?D():u.on("request",D)):w&&!g&&(u.on("end",_),u.on("close",_)),function(q){return q.stdio&&Array.isArray(q.stdio)&&q.stdio.length===3}(u)&&u.on("exit",E),u.on("end",x),u.on("finish",A),h.error!==!1&&u.on("error",I),u.on("close",M),function(){p=!0,u.removeListener("complete",A),u.removeListener("abort",M),u.removeListener("request",D),u.req&&u.req.removeListener("finish",A),u.removeListener("end",_),u.removeListener("close",_),u.removeListener("finish",A),u.removeListener("exit",E),u.removeListener("end",x),u.removeListener("error",I),u.removeListener("close",M)}};n.exports=c}).call(this)}).call(this,i("_process"))},{_process:50,once:48}],22:[function(i,n,r){var s=Object.create||function(x){var E=function(){};return E.prototype=x,new E},a=Object.keys||function(x){var E=[];for(var I in x)Object.prototype.hasOwnProperty.call(x,I)&&E.push(I);return I},l=Function.prototype.bind||function(x){var E=this;return function(){return E.apply(x,arguments)}};function c(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=s(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}n.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0;var u,h=10;try{var d={};Object.defineProperty&&Object.defineProperty(d,"x",{value:0}),u=d.x===0}catch{u=!1}function g(x){return x._maxListeners===void 0?c.defaultMaxListeners:x._maxListeners}function v(x,E,I,M){var B,D,q;if(typeof I!="function")throw new TypeError('"listener" argument must be a function');if((D=x._events)?(D.newListener&&(x.emit("newListener",E,I.listener?I.listener:I),D=x._events),q=D[E]):(D=x._events=s(null),x._eventsCount=0),q){if(typeof q=="function"?q=D[E]=M?[I,q]:[q,I]:M?q.unshift(I):q.push(I),!q.warned&&(B=g(x))&&B>0&&q.length>B){q.warned=!0;var Q=new Error("Possible EventEmitter memory leak detected. "+q.length+' "'+String(E)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');Q.name="MaxListenersExceededWarning",Q.emitter=x,Q.type=E,Q.count=q.length,typeof console=="object"&&console.warn&&console.warn("%s: %s",Q.name,Q.message)}}else q=D[E]=I,++x._eventsCount;return x}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var x=new Array(arguments.length),E=0;E<x.length;++E)x[E]=arguments[E];this.listener.apply(this.target,x)}}function w(x,E,I){var M={fired:!1,wrapFn:void 0,target:x,type:E,listener:I},B=l.call(y,M);return B.listener=I,M.wrapFn=B,B}function p(x,E,I){var M=x._events;if(!M)return[];var B=M[E];return B?typeof B=="function"?I?[B.listener||B]:[B]:I?function(D){for(var q=new Array(D.length),Q=0;Q<q.length;++Q)q[Q]=D[Q].listener||D[Q];return q}(B):A(B,B.length):[]}function _(x){var E=this._events;if(E){var I=E[x];if(typeof I=="function")return 1;if(I)return I.length}return 0}function A(x,E){for(var I=new Array(E),M=0;M<E;++M)I[M]=x[M];return I}u?Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return h},set:function(x){if(typeof x!="number"||x<0||x!=x)throw new TypeError('"defaultMaxListeners" must be a positive number');h=x}}):c.defaultMaxListeners=h,c.prototype.setMaxListeners=function(x){if(typeof x!="number"||x<0||isNaN(x))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=x,this},c.prototype.getMaxListeners=function(){return g(this)},c.prototype.emit=function(x){var E,I,M,B,D,q,Q=x==="error";if(q=this._events)Q=Q&&q.error==null;else if(!Q)return!1;if(Q){if(arguments.length>1&&(E=arguments[1]),E instanceof Error)throw E;var C=new Error('Unhandled "error" event. ('+E+")");throw C.context=E,C}if(!(I=q[x]))return!1;var T=typeof I=="function";switch(M=arguments.length){case 1:(function(S,O,K){if(O)S.call(K);else for(var Z=S.length,st=A(S,Z),$=0;$<Z;++$)st[$].call(K)})(I,T,this);break;case 2:(function(S,O,K,Z){if(O)S.call(K,Z);else for(var st=S.length,$=A(S,st),z=0;z<st;++z)$[z].call(K,Z)})(I,T,this,arguments[1]);break;case 3:(function(S,O,K,Z,st){if(O)S.call(K,Z,st);else for(var $=S.length,z=A(S,$),V=0;V<$;++V)z[V].call(K,Z,st)})(I,T,this,arguments[1],arguments[2]);break;case 4:(function(S,O,K,Z,st,$){if(O)S.call(K,Z,st,$);else for(var z=S.length,V=A(S,z),Y=0;Y<z;++Y)V[Y].call(K,Z,st,$)})(I,T,this,arguments[1],arguments[2],arguments[3]);break;default:for(B=new Array(M-1),D=1;D<M;D++)B[D-1]=arguments[D];(function(S,O,K,Z){if(O)S.apply(K,Z);else for(var st=S.length,$=A(S,st),z=0;z<st;++z)$[z].apply(K,Z)})(I,T,this,B)}return!0},c.prototype.addListener=function(x,E){return v(this,x,E,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(x,E){return v(this,x,E,!0)},c.prototype.once=function(x,E){if(typeof E!="function")throw new TypeError('"listener" argument must be a function');return this.on(x,w(this,x,E)),this},c.prototype.prependOnceListener=function(x,E){if(typeof E!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(x,w(this,x,E)),this},c.prototype.removeListener=function(x,E){var I,M,B,D,q;if(typeof E!="function")throw new TypeError('"listener" argument must be a function');if(!(M=this._events))return this;if(!(I=M[x]))return this;if(I===E||I.listener===E)--this._eventsCount==0?this._events=s(null):(delete M[x],M.removeListener&&this.emit("removeListener",x,I.listener||E));else if(typeof I!="function"){for(B=-1,D=I.length-1;D>=0;D--)if(I[D]===E||I[D].listener===E){q=I[D].listener,B=D;break}if(B<0)return this;B===0?I.shift():function(Q,C){for(var T=C,S=T+1,O=Q.length;S<O;T+=1,S+=1)Q[T]=Q[S];Q.pop()}(I,B),I.length===1&&(M[x]=I[0]),M.removeListener&&this.emit("removeListener",x,q||E)}return this},c.prototype.removeAllListeners=function(x){var E,I,M;if(!(I=this._events))return this;if(!I.removeListener)return arguments.length===0?(this._events=s(null),this._eventsCount=0):I[x]&&(--this._eventsCount==0?this._events=s(null):delete I[x]),this;if(arguments.length===0){var B,D=a(I);for(M=0;M<D.length;++M)(B=D[M])!=="removeListener"&&this.removeAllListeners(B);return this.removeAllListeners("removeListener"),this._events=s(null),this._eventsCount=0,this}if(typeof(E=I[x])=="function")this.removeListener(x,E);else if(E)for(M=E.length-1;M>=0;M--)this.removeListener(x,E[M]);return this},c.prototype.listeners=function(x){return p(this,x,!0)},c.prototype.rawListeners=function(x){return p(this,x,!1)},c.listenerCount=function(x,E){return typeof x.listenerCount=="function"?x.listenerCount(E):_.call(x,E)},c.prototype.listenerCount=_,c.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(i,n,r){r.read=function(s,a,l,c,u){var h,d,g=8*u-c-1,v=(1<<g)-1,y=v>>1,w=-7,p=l?u-1:0,_=l?-1:1,A=s[a+p];for(p+=_,h=A&(1<<-w)-1,A>>=-w,w+=g;w>0;h=256*h+s[a+p],p+=_,w-=8);for(d=h&(1<<-w)-1,h>>=-w,w+=c;w>0;d=256*d+s[a+p],p+=_,w-=8);if(h===0)h=1-y;else{if(h===v)return d?NaN:1/0*(A?-1:1);d+=Math.pow(2,c),h-=y}return(A?-1:1)*d*Math.pow(2,h-c)},r.write=function(s,a,l,c,u,h){var d,g,v,y=8*h-u-1,w=(1<<y)-1,p=w>>1,_=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=c?0:h-1,x=c?1:-1,E=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(g=isNaN(a)?1:0,d=w):(d=Math.floor(Math.log(a)/Math.LN2),a*(v=Math.pow(2,-d))<1&&(d--,v*=2),(a+=d+p>=1?_/v:_*Math.pow(2,1-p))*v>=2&&(d++,v/=2),d+p>=w?(g=0,d=w):d+p>=1?(g=(a*v-1)*Math.pow(2,u),d+=p):(g=a*Math.pow(2,p-1)*Math.pow(2,u),d=0));u>=8;s[l+A]=255&g,A+=x,g/=256,u-=8);for(d=d<<u|g,y+=u;y>0;s[l+A]=255&d,A+=x,d/=256,y-=8);s[l+A-x]|=128*E}},{}],24:[function(i,n,r){typeof Object.create=="function"?n.exports=function(s,a){a&&(s.super_=a,s.prototype=Object.create(a.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}))}:n.exports=function(s,a){if(a){s.super_=a;var l=function(){};l.prototype=a.prototype,s.prototype=new l,s.prototype.constructor=s}}},{}],25:[function(i,n,r){Object.defineProperty(r,"__esModule",{value:!0});var s=function(){function a(l,c){this.color=!0,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=l,this.value=c}return a.prototype.rotateLeft=function(){var l=this.parent,c=this.brother,u=this.leftChild,h=this.rightChild;if(!h)throw new Error("unknown error");var d=h.leftChild,g=h.rightChild;return l&&(l.leftChild===this?l.leftChild=h:l.rightChild===this&&(l.rightChild=h)),h.parent=l,h.brother=c,h.leftChild=this,h.rightChild=g,c&&(c.brother=h),this.parent=h,this.brother=g,this.leftChild=u,this.rightChild=d,g&&(g.parent=h,g.brother=this),u&&(u.parent=this,u.brother=d),d&&(d.parent=this,d.brother=u),h},a.prototype.rotateRight=function(){var l=this.parent,c=this.brother,u=this.leftChild;if(!u)throw new Error("unknown error");var h=this.rightChild,d=u.leftChild,g=u.rightChild;return l&&(l.leftChild===this?l.leftChild=u:l.rightChild===this&&(l.rightChild=u)),u.parent=l,u.brother=c,u.leftChild=d,u.rightChild=this,c&&(c.brother=u),d&&(d.parent=u,d.brother=this),this.parent=u,this.brother=d,this.leftChild=g,this.rightChild=h,g&&(g.parent=this,g.brother=h),h&&(h.parent=this,h.brother=g),u},a.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0},a.TreeNodeColorType={red:!0,black:!1},a}();Object.freeze(s),r.default=s},{}],26:[function(i,n,r){var s=this&&this.__generator||function(l,c){var u,h,d,g,v={label:0,sent:function(){if(1&d[0])throw d[1];return d[1]},trys:[],ops:[]};return g={next:y(0),throw:y(1),return:y(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function y(w){return function(p){return function(_){if(u)throw new TypeError("Generator is already executing.");for(;v;)try{if(u=1,h&&(d=2&_[0]?h.return:_[0]?h.throw||((d=h.return)&&d.call(h),0):h.next)&&!(d=d.call(h,_[1])).done)return d;switch(h=0,d&&(_=[2&_[0],d.value]),_[0]){case 0:case 1:d=_;break;case 4:return v.label++,{value:_[1],done:!1};case 5:v.label++,h=_[1],_=[0];continue;case 7:_=v.ops.pop(),v.trys.pop();continue;default:if(!(d=(d=v.trys).length>0&&d[d.length-1])&&(_[0]===6||_[0]===2)){v=0;continue}if(_[0]===3&&(!d||_[1]>d[0]&&_[1]<d[3])){v.label=_[1];break}if(_[0]===6&&v.label<d[1]){v.label=d[1],d=_;break}if(d&&v.label<d[2]){v.label=d[2],v.ops.push(_);break}d[2]&&v.ops.pop(),v.trys.pop();continue}_=c.call(l,v)}catch(A){_=[6,A],h=0}finally{u=d=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([w,p])}}};function a(l){var c=this;l===void 0&&(l=[]);var u=[],h=0,d=0,g=0,v=0,y=0,w=0;this.size=function(){return w},this.empty=function(){return w===0},this.clear=function(){h=g=d=v=y=w=0,_.call(this,a.bucketSize),w=0},this.front=function(){return u[h][d]},this.back=function(){return u[g][v]},this.forEach=function(A){if(!this.empty()){var x=0;if(h!==g){for(I=d;I<a.bucketSize;++I)A(u[h][I],x++);for(I=h+1;I<g;++I)for(var E=0;E<a.bucketSize;++E)A(u[I][E],x++);for(I=0;I<=v;++I)A(u[g][I],x++)}else for(var I=d;I<=v;++I)A(u[h][I],x++)}};var p=function(A){var x=h*a.bucketSize+d,E=x+A,I=g*a.bucketSize+v;if(E<x||E>I)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(E/a.bucketSize),curNodePointerIndex:E%a.bucketSize}};this.getElementByPos=function(A){var x=p(A),E=x.curNodeBucketIndex,I=x.curNodePointerIndex;return u[E][I]},this.eraseElementByPos=function(A){var x=this;if(A<0||A>w)throw new Error("pos should more than 0 and less than queue's size");if(A===0)this.popFront();else if(A===this.size())this.popBack();else{for(var E=[],I=A+1;I<w;++I)E.push(this.getElementByPos(I));this.cut(A),this.popBack(),E.forEach(function(M){return x.pushBack(M)})}},this.eraseElementByValue=function(A){if(!this.empty()){var x=[];this.forEach(function(M){M!==A&&x.push(M)});for(var E=x.length,I=0;I<E;++I)this.setElementByPos(I,x[I]);this.cut(E-1)}};var _=function(A){for(var x=[],E=A*a.sigma,I=Math.max(Math.ceil(E/a.bucketSize),2),M=0;M<I;++M)x.push(new Array(a.bucketSize));var B=Math.ceil(A/a.bucketSize),D=Math.floor(I/2)-Math.floor(B/2),q=D,Q=0;if(this.size())for(M=0;M<B;++M){for(var C=0;C<a.bucketSize;++C)if(x[D+M][C]=this.front(),this.popFront(),this.empty()){q=D+M,Q=C;break}if(this.empty())break}u=x,h=D,d=0,g=q,v=Q,y=I,w=A};this.pushBack=function(A){this.empty()||(g===y-1&&v===a.bucketSize-1&&_.call(this,this.size()),v<a.bucketSize-1?++v:g<y-1&&(++g,v=0)),++w,u[g][v]=A},this.popBack=function(){this.empty()||(this.size()!==1&&(v>0?--v:h<g&&(--g,v=a.bucketSize-1)),w>0&&--w)},this.setElementByPos=function(A,x){var E=p(A),I=E.curNodeBucketIndex,M=E.curNodePointerIndex;u[I][M]=x},this.insert=function(A,x,E){var I=this;if(E===void 0&&(E=1),A===0)for(;E--;)this.pushFront(x);else if(A===this.size())for(;E--;)this.pushBack(x);else{for(var M=[],B=A;B<w;++B)M.push(this.getElementByPos(B));for(this.cut(A-1),B=0;B<E;++B)this.pushBack(x);M.forEach(function(D){return I.pushBack(D)})}},this.find=function(A){if(h===g){for(var x=d;x<=v;++x)if(u[h][x]===A)return!0;return!1}for(x=d;x<a.bucketSize;++x)if(u[h][x]===A)return!0;for(x=h+1;x<g;++x)for(var E=0;E<a.bucketSize;++E)if(u[x][E]===A)return!0;for(x=0;x<=v;++x)if(u[g][x]===A)return!0;return!1},this.reverse=function(){for(var A=0,x=w-1;A<x;){var E=this.getElementByPos(A);this.setElementByPos(A,this.getElementByPos(x)),this.setElementByPos(x,E),++A,--x}},this.unique=function(){if(!this.empty()){var A=[],x=this.front();this.forEach(function(I,M){M!==0&&I===x||(A.push(I),x=I)});for(var E=0;E<w;++E)this.setElementByPos(E,A[E]);this.cut(A.length-1)}},this.sort=function(A){var x=[];this.forEach(function(I){x.push(I)}),x.sort(A);for(var E=0;E<w;++E)this.setElementByPos(E,x[E])},this.pushFront=function(A){this.empty()||(h===0&&d===0&&_.call(this,this.size()),d>0?--d:h>0&&(--h,d=a.bucketSize-1)),++w,u[h][d]=A},this.popFront=function(){this.empty()||(this.size()!==1&&(d<a.bucketSize-1?++d:h<g&&(++h,d=0)),w>0&&--w)},this.shrinkToFit=function(){var A=this,x=[];this.forEach(function(B){x.push(B)});var E=x.length;u=[];for(var I=Math.ceil(E/a.bucketSize),M=0;M<I;++M)u.push(new Array(a.bucketSize));this.clear(),x.forEach(function(B){return A.pushBack(B)})},this.cut=function(A){if(A<0)this.clear();else{var x=p(A),E=x.curNodeBucketIndex,I=x.curNodePointerIndex;g=E,v=I,w=A+1}},this[Symbol.iterator]=function(){return function(){var A,x;return s(this,function(E){switch(E.label){case 0:if(w===0)return[2];if(h!==g)return[3,5];x=d,E.label=1;case 1:return x<=v?[4,u[h][x]]:[3,4];case 2:E.sent(),E.label=3;case 3:return++x,[3,1];case 4:return[2];case 5:x=d,E.label=6;case 6:return x<a.bucketSize?[4,u[h][x]]:[3,9];case 7:E.sent(),E.label=8;case 8:return++x,[3,6];case 9:x=h+1,E.label=10;case 10:if(!(x<g))return[3,15];A=0,E.label=11;case 11:return A<a.bucketSize?[4,u[x][A]]:[3,14];case 12:E.sent(),E.label=13;case 13:return++A,[3,11];case 14:return++x,[3,10];case 15:x=0,E.label=16;case 16:return x<=v?[4,u[g][x]]:[3,19];case 17:E.sent(),E.label=18;case 18:return++x,[3,16];case 19:return[2]}})}()},function(){var A=a.bucketSize;l.size?A=l.size():l.length&&(A=l.length);var x=A*a.sigma;y=Math.ceil(x/a.bucketSize),y=Math.max(y,3);for(var E=0;E<y;++E)u.push(new Array(a.bucketSize));var I=Math.ceil(A/a.bucketSize);h=Math.floor(y/2)-Math.floor(I/2),g=h,l.forEach(function(M){return c.pushBack(M)})}(),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),a.sigma=3,a.bucketSize=5e3,Object.freeze(a),r.default=a},{}],27:[function(i,n,r){var s=this&&this.__generator||function(h,d){var g,v,y,w,p={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return w={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function _(A){return function(x){return function(E){if(g)throw new TypeError("Generator is already executing.");for(;p;)try{if(g=1,v&&(y=2&E[0]?v.return:E[0]?v.throw||((y=v.return)&&y.call(v),0):v.next)&&!(y=y.call(v,E[1])).done)return y;switch(v=0,y&&(E=[2&E[0],y.value]),E[0]){case 0:case 1:y=E;break;case 4:return p.label++,{value:E[1],done:!1};case 5:p.label++,v=E[1],E=[0];continue;case 7:E=p.ops.pop(),p.trys.pop();continue;default:if(!(y=(y=p.trys).length>0&&y[y.length-1])&&(E[0]===6||E[0]===2)){p=0;continue}if(E[0]===3&&(!y||E[1]>y[0]&&E[1]<y[3])){p.label=E[1];break}if(E[0]===6&&p.label<y[1]){p.label=y[1],y=E;break}if(y&&p.label<y[2]){p.label=y[2],p.ops.push(E);break}y[2]&&p.ops.pop(),p.trys.pop();continue}E=d.call(h,p)}catch(I){E=[6,I],v=0}finally{g=y=0}if(5&E[0])throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}([A,x])}}},a=this&&this.__values||function(h){var d=typeof Symbol=="function"&&Symbol.iterator,g=d&&h[d],v=0;if(g)return g.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var l=i("../LinkList/LinkList"),c=i("../Map/Map");function u(h,d,g){var v=this;if(h===void 0&&(h=[]),d===void 0&&(d=u.initSize),g=g||function(_){var A,x,E=0,I="";if(typeof _=="number")E=((E=Math.floor(_))<<5)-E,E&=E;else{I=typeof _!="string"?JSON.stringify(_):_;try{for(var M=a(I),B=M.next();!B.done;B=M.next())E=(E<<5)-E+B.value.charCodeAt(0),E&=E}catch(D){A={error:D}}finally{try{B&&!B.done&&(x=M.return)&&x.call(M)}finally{if(A)throw A.error}}}return E^=E>>>16},(d&d-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var y=0,w=[],p=Math.max(u.initSize,Math.min(u.maxSize,d));this.size=function(){return y},this.empty=function(){return y===0},this.clear=function(){y=0,p=d,w=[]},this.forEach=function(_){var A=0;w.forEach(function(x){x.forEach(function(E){_(E,A++)})})},this.setElement=function(_,A){var x,E;if(_==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(A!=null){var I=g(_)&p-1;if(w[I]){var M=w[I].size();if(w[I]instanceof l.default){try{for(var B=a(w[I]),D=B.next();!D.done;D=B.next()){var q=D.value;if(q.key===_)return void(q.value=A)}}catch(C){x={error:C}}finally{try{D&&!D.done&&(E=B.return)&&E.call(B)}finally{if(x)throw x.error}}w[I].pushBack({key:_,value:A}),w[I].size()>=u.treeifyThreshold&&(w[I]=new c.default(w[I]))}else w[I].setElement(_,A);var Q=w[I].size();y+=Q-M}else++y,w[I]=new l.default([{key:_,value:A}]);y>p*u.sigma&&function(C){if(!(C>=u.maxSize)){p=2*C;var T=[];w.forEach(function(S,O){if(!S.empty()){if(S instanceof l.default&&S.size()===1){var K=S.front(),Z=K.key,st=K.value;T[g(Z)&p-1]=new l.default([{key:Z,value:st}])}else if(S instanceof c.default){var $=new l.default,z=new l.default;S.forEach(function(U){(g(U.key)&C)==0?$.pushBack(U):z.pushBack(U)}),$.size()>u.untreeifyThreshold?T[O]=new c.default($):$.size()&&(T[O]=$),z.size()>u.untreeifyThreshold?T[O+C]=new c.default(z):z.size()&&(T[O+C]=z)}else{var V=new l.default,Y=new l.default;S.forEach(function(U){(g(U.key)&C)==0?V.pushBack(U):Y.pushBack(U)}),V.size()&&(T[O]=V),Y.size()&&(T[O+C]=Y)}w[O].clear()}}),w=T}}.call(this,p)}else this.eraseElementByKey(_)},this.getElementByKey=function(_){var A,x,E=g(_)&p-1;if(w[E]){if(w[E]instanceof c.default)return w[E].getElementByKey(_);try{for(var I=a(w[E]),M=I.next();!M.done;M=I.next()){var B=M.value;if(B.key===_)return B.value}}catch(D){A={error:D}}finally{try{M&&!M.done&&(x=I.return)&&x.call(I)}finally{if(A)throw A.error}}}},this.eraseElementByKey=function(_){var A,x,E=g(_)&p-1;if(w[E]){var I=w[E].size();if(w[E]instanceof c.default)w[E].eraseElementByKey(_),w[E].size()<=u.untreeifyThreshold&&(w[E]=new l.default(w[E]));else{var M=-1;try{for(var B=a(w[E]),D=B.next();!D.done;D=B.next())if(++M,D.value.key===_){w[E].eraseElementByPos(M);break}}catch(Q){A={error:Q}}finally{try{D&&!D.done&&(x=B.return)&&x.call(B)}finally{if(A)throw A.error}}}var q=w[E].size();y+=q-I}},this.find=function(_){var A,x,E=g(_)&p-1;if(!w[E])return!1;if(w[E]instanceof c.default)return w[E].find(_);try{for(var I=a(w[E]),M=I.next();!M.done;M=I.next())if(M.value.key===_)return!0}catch(B){A={error:B}}finally{try{M&&!M.done&&(x=I.return)&&x.call(I)}finally{if(A)throw A.error}}return!1},this[Symbol.iterator]=function(){return function(){var _,A,x,E,I,M;return s(this,function(B){switch(B.label){case 0:_=0,B.label=1;case 1:if(!(_<p))return[3,10];for(;_<p&&!w[_];)++_;if(_>=p)return[3,10];B.label=2;case 2:B.trys.push([2,7,8,9]),I=void 0,A=a(w[_]),x=A.next(),B.label=3;case 3:return x.done?[3,6]:[4,x.value];case 4:B.sent(),B.label=5;case 5:return x=A.next(),[3,3];case 6:return[3,9];case 7:return E=B.sent(),I={error:E},[3,9];case 8:try{x&&!x.done&&(M=A.return)&&M.call(A)}finally{if(I)throw I.error}return[7];case 9:return++_,[3,1];case 10:return[2]}})}()},h.forEach(function(_){var A=_.key,x=_.value;return v.setElement(A,x)}),Object.freeze(this)}u.initSize=16,u.maxSize=1<<30,u.sigma=.75,u.treeifyThreshold=8,u.untreeifyThreshold=6,u.minTreeifySize=64,Object.freeze(u),r.default=u},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(i,n,r){var s=this&&this.__generator||function(h,d){var g,v,y,w,p={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return w={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function _(A){return function(x){return function(E){if(g)throw new TypeError("Generator is already executing.");for(;p;)try{if(g=1,v&&(y=2&E[0]?v.return:E[0]?v.throw||((y=v.return)&&y.call(v),0):v.next)&&!(y=y.call(v,E[1])).done)return y;switch(v=0,y&&(E=[2&E[0],y.value]),E[0]){case 0:case 1:y=E;break;case 4:return p.label++,{value:E[1],done:!1};case 5:p.label++,v=E[1],E=[0];continue;case 7:E=p.ops.pop(),p.trys.pop();continue;default:if(!(y=(y=p.trys).length>0&&y[y.length-1])&&(E[0]===6||E[0]===2)){p=0;continue}if(E[0]===3&&(!y||E[1]>y[0]&&E[1]<y[3])){p.label=E[1];break}if(E[0]===6&&p.label<y[1]){p.label=y[1],y=E;break}if(y&&p.label<y[2]){p.label=y[2],p.ops.push(E);break}y[2]&&p.ops.pop(),p.trys.pop();continue}E=d.call(h,p)}catch(I){E=[6,I],v=0}finally{g=y=0}if(5&E[0])throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}([A,x])}}},a=this&&this.__values||function(h){var d=typeof Symbol=="function"&&Symbol.iterator,g=d&&h[d],v=0;if(g)return g.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var l=i("../Set/Set"),c=i("../LinkList/LinkList");function u(h,d,g){var v=this;if(h===void 0&&(h=[]),d===void 0&&(d=u.initSize),g=g||function(_){var A=0,x="";if(typeof _=="number")A=((A=Math.floor(_))<<5)-A,A&=A;else{x=typeof _!="string"?JSON.stringify(_):_;for(var E=0;E<x.length;E++)A=(A<<5)-A+x.charCodeAt(E),A&=A}return A^=A>>>16},(d&d-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var y=0,w=[],p=Math.max(u.initSize,Math.min(u.maxSize,d));this.size=function(){return y},this.empty=function(){return y===0},this.clear=function(){y=0,p=d,w=[]},this.forEach=function(_){var A=0;w.forEach(function(x){x.forEach(function(E){_(E,A++)})})},this.insert=function(_){if(_==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var A=g(_)&p-1;if(w[A]){var x=w[A].size();if(w[A]instanceof c.default){if(w[A].find(_))return;w[A].pushBack(_),w[A].size()>=u.treeifyThreshold&&(w[A]=new l.default(w[A]))}else w[A].insert(_);var E=w[A].size();y+=E-x}else w[A]=new c.default([_]),++y;y>p*u.sigma&&function(I){if(!(I>=u.maxSize)){p=2*I;var M=[];w.forEach(function(B,D){if(!B.empty()){if(B instanceof c.default&&B.size()===1){var q=B.front();if(q===void 0)throw new Error("unknown error");M[g(q)&p-1]=new c.default([q])}else if(B instanceof l.default){var Q=new c.default,C=new c.default;B.forEach(function(O){(g(O)&I)==0?Q.pushBack(O):C.pushBack(O)}),Q.size()>u.untreeifyThreshold?M[D]=new l.default(Q):Q.size()&&(M[D]=Q),C.size()>u.untreeifyThreshold?M[D+I]=new l.default(C):C.size()&&(M[D+I]=C)}else{var T=new c.default,S=new c.default;B.forEach(function(O){(g(O)&I)==0?T.pushBack(O):S.pushBack(O)}),T.size()&&(M[D]=T),S.size()&&(M[D+I]=S)}w[D].clear()}}),w=M}}.call(this,p)},this.eraseElementByValue=function(_){var A=g(_)&p-1;if(w[A]){var x=w[A].size();w[A].eraseElementByValue(_),w[A]instanceof l.default&&w[A].size()<=u.untreeifyThreshold&&(w[A]=new c.default(w[A]));var E=w[A].size();y+=E-x}},this.find=function(_){var A=g(_)&p-1;return!!w[A]&&w[A].find(_)},this[Symbol.iterator]=function(){return function(){var _,A,x,E,I,M;return s(this,function(B){switch(B.label){case 0:_=0,B.label=1;case 1:if(!(_<p))return[3,10];for(;_<p&&!w[_];)++_;if(_>=p)return[3,10];B.label=2;case 2:B.trys.push([2,7,8,9]),I=void 0,A=a(w[_]),x=A.next(),B.label=3;case 3:return x.done?[3,6]:[4,x.value];case 4:B.sent(),B.label=5;case 5:return x=A.next(),[3,3];case 6:return[3,9];case 7:return E=B.sent(),I={error:E},[3,9];case 8:try{x&&!x.done&&(M=A.return)&&M.call(A)}finally{if(I)throw I.error}return[7];case 9:return++_,[3,1];case 10:return[2]}})}()},h.forEach(function(_){return v.insert(_)}),Object.freeze(this)}u.initSize=16,u.maxSize=1<<30,u.sigma=.75,u.treeifyThreshold=8,u.untreeifyThreshold=6,u.minTreeifySize=64,Object.freeze(u),r.default=u},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(i,n,r){var s=this&&this.__generator||function(c,u){var h,d,g,v,y={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return v={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function w(p){return function(_){return function(A){if(h)throw new TypeError("Generator is already executing.");for(;y;)try{if(h=1,d&&(g=2&A[0]?d.return:A[0]?d.throw||((g=d.return)&&g.call(d),0):d.next)&&!(g=g.call(d,A[1])).done)return g;switch(d=0,g&&(A=[2&A[0],g.value]),A[0]){case 0:case 1:g=A;break;case 4:return y.label++,{value:A[1],done:!1};case 5:y.label++,d=A[1],A=[0];continue;case 7:A=y.ops.pop(),y.trys.pop();continue;default:if(!(g=(g=y.trys).length>0&&g[g.length-1])&&(A[0]===6||A[0]===2)){y=0;continue}if(A[0]===3&&(!g||A[1]>g[0]&&A[1]<g[3])){y.label=A[1];break}if(A[0]===6&&y.label<g[1]){y.label=g[1],g=A;break}if(g&&y.label<g[2]){y.label=g[2],y.ops.push(A);break}g[2]&&y.ops.pop(),y.trys.pop();continue}A=u.call(c,y)}catch(x){A=[6,x],d=0}finally{h=g=0}if(5&A[0])throw A[1];return{value:A[0]?A[1]:void 0,done:!0}}([p,_])}}};Object.defineProperty(r,"__esModule",{value:!0});var a=function(){return function(c){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=c}}();function l(c){var u=this;c===void 0&&(c=[]);var h=0,d=void 0,g=void 0;this.size=function(){return h},this.empty=function(){return h===0},this.clear=function(){d=g=void 0,h=0},this.front=function(){return d==null?void 0:d.value},this.back=function(){return g==null?void 0:g.value},this.forEach=function(v){for(var y=d,w=0;y;){if(y.value===void 0)throw new Error("unknown error");v(y.value,w++),y=y.next}},this.getElementByPos=function(v){if(v<0||v>=h)throw new Error("pos must more then 0 and less then the list length");for(var y=d;v--&&y;)y=y.next;if(!y||y.value===void 0)throw new Error("unknown error");return y.value},this.eraseElementByPos=function(v){if(v<0||v>=h)throw new Error("erase pos must more then 0 and less then the list length");if(v===0)this.popFront();else if(v===h-1)this.popBack();else{for(var y=d;v--;){if(!(y!=null&&y.next))throw new Error("unknown error");y=y.next}if(!y||!y.pre||!y.next)throw new Error("unknown error");var w=y.pre,p=y.next;p.pre=w,w.next=p,h>0&&--h}},this.eraseElementByValue=function(v){for(;d&&d.value===v;)this.popFront();for(;g&&g.value===v;)this.popBack();if(d)for(var y=d;y;){if(y.value===v){var w=y.pre,p=y.next;p&&(p.pre=w),w&&(w.next=p),h>0&&--h}y=y.next}},this.pushBack=function(v){if(v==null)throw new Error("you can't push null or undefined here");++h;var y=new a(v);g?(g.next=y,y.pre=g,g=y):d=g=y},this.popBack=function(){g&&(h>0&&--h,g&&(d===g?d=g=void 0:(g=g.pre)&&(g.next=void 0)))},this.setElementByPos=function(v,y){if(y==null)throw new Error("you can't set null or undefined here");if(v<0||v>=h)throw new Error("pos must more then 0 and less then the list length");for(var w=d;v--;){if(!w)throw new Error("unknown error");w=w.next}w&&(w.value=y)},this.insert=function(v,y,w){if(w===void 0&&(w=1),y==null)throw new Error("you can't insert null or undefined here");if(v<0||v>h)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(w<0)throw new Error("insert size must more than 0");if(v===0)for(;w--;)this.pushFront(y);else if(v===h)for(;w--;)this.pushBack(y);else{for(var p=d,_=1;_<v;++_){if(!(p!=null&&p.next))throw new Error("unknown error");p=p==null?void 0:p.next}if(!p)throw new Error("unknown error");var A=p.next;for(h+=w;w--;)p.next=new a(y),p.next.pre=p,p=p.next;p.next=A,A&&(A.pre=p)}},this.find=function(v){for(var y=d;y;){if(y.value===v)return!0;y=y.next}return!1},this.reverse=function(){for(var v=d,y=g,w=0;v&&y&&2*w<h;){var p=v.value;v.value=y.value,y.value=p,v=v.next,y=y.pre,++w}},this.unique=function(){for(var v=d;v;){for(var y=v;y&&y.next&&y.value===y.next.value;)y=y.next,h>0&&--h;v.next=y.next,v.next&&(v.next.pre=v),v=v.next}},this.sort=function(v){var y=[];this.forEach(function(p){y.push(p)}),y.sort(v);var w=d;y.forEach(function(p){w&&(w.value=p,w=w.next)})},this.pushFront=function(v){if(v==null)throw new Error("you can't push null or undefined here");++h;var y=new a(v);d?(y.next=d,d.pre=y,d=y):d=g=y},this.popFront=function(){d&&(h>0&&--h,d&&(d===g?d=g=void 0:(d=d.next)&&(d.pre=void 0)))},this.merge=function(v){var y=this,w=d;v.forEach(function(p){for(;w&&w.value!==void 0&&w.value<=p;)w=w.next;if(w===void 0)y.pushBack(p),w=g;else if(w===d)y.pushFront(p),w=d;else{++h;var _=w.pre;_&&(_.next=new a(p),_.next.pre=_,_.next.next=w,w&&(w.pre=_.next))}})},this[Symbol.iterator]=function(){return function(){var v;return s(this,function(y){switch(y.label){case 0:v=d,y.label=1;case 1:if(v===void 0)return[3,3];if(!v.value)throw new Error("unknown error");return[4,v.value];case 2:return y.sent(),v=v.next,[3,1];case 3:return[2]}})}()},c.forEach(function(v){return u.pushBack(v)}),Object.freeze(this)}Object.freeze(l),r.default=l},{}],30:[function(i,n,r){var s=this&&this.__generator||function(u,h){var d,g,v,y,w={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return y={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function p(_){return function(A){return function(x){if(d)throw new TypeError("Generator is already executing.");for(;w;)try{if(d=1,g&&(v=2&x[0]?g.return:x[0]?g.throw||((v=g.return)&&v.call(g),0):g.next)&&!(v=v.call(g,x[1])).done)return v;switch(g=0,v&&(x=[2&x[0],v.value]),x[0]){case 0:case 1:v=x;break;case 4:return w.label++,{value:x[1],done:!1};case 5:w.label++,g=x[1],x=[0];continue;case 7:x=w.ops.pop(),w.trys.pop();continue;default:if(!(v=(v=w.trys).length>0&&v[v.length-1])&&(x[0]===6||x[0]===2)){w=0;continue}if(x[0]===3&&(!v||x[1]>v[0]&&x[1]<v[3])){w.label=x[1];break}if(x[0]===6&&w.label<v[1]){w.label=v[1],v=x;break}if(v&&w.label<v[2]){w.label=v[2],w.ops.push(x);break}v[2]&&w.ops.pop(),w.trys.pop();continue}x=h.call(u,w)}catch(E){x=[6,E],g=0}finally{d=v=0}if(5&x[0])throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}([_,A])}}},a=this&&this.__values||function(u){var h=typeof Symbol=="function"&&Symbol.iterator,d=h&&u[h],g=0;if(d)return d.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(h?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var l=i("../Base/TreeNode");function c(u,h){var d=this;u===void 0&&(u=[]),h=h||function(C,T){return C<T?-1:C>T?1:0};var g=0,v=new l.default;v.color=l.default.TreeNodeColorType.black,this.size=function(){return g},this.empty=function(){return g===0},this.clear=function(){g=0,v.key=v.value=void 0,v.leftChild=v.rightChild=v.brother=void 0};var y=function(C){if(!C||C.key===void 0)throw new Error("unknown error");return C.leftChild?y(C.leftChild):C},w=function(C){if(!C||C.key===void 0)throw new Error("unknown error");return C.rightChild?w(C.rightChild):C};this.front=function(){if(!this.empty()){var C=y(v);if(C.key===void 0||C.value===void 0)throw new Error("unknown error");return{key:C.key,value:C.value}}},this.back=function(){if(!this.empty()){var C=w(v);if(C.key===void 0||C.value===void 0)throw new Error("unknown error");return{key:C.key,value:C.value}}},this.forEach=function(C){var T,S,O=0;try{for(var K=a(this),Z=K.next();!Z.done;Z=K.next())C(Z.value,O++)}catch(st){T={error:st}}finally{try{Z&&!Z.done&&(S=K.return)&&S.call(K)}finally{if(T)throw T.error}}},this.getElementByPos=function(C){var T,S;if(C<0||C>=this.size())throw new Error("pos must more than 0 and less than set's size");var O=0;try{for(var K=a(this),Z=K.next();!Z.done;Z=K.next()){var st=Z.value;if(O===C)return st;++O}}catch($){T={error:$}}finally{try{Z&&!Z.done&&(S=K.return)&&S.call(K)}finally{if(T)throw T.error}}throw new Error("unknown Error")};var p=function(C,T){if(C&&C.key!==void 0&&C.value!==void 0){var S=h(C.key,T);return S===0?{key:C.key,value:C.value}:S<0?p(C.rightChild,T):p(C.leftChild,T)||{key:C.key,value:C.value}}};this.lowerBound=function(C){return p(v,C)};var _=function(C,T){if(C&&C.key!==void 0&&C.value!==void 0)return h(C.key,T)<=0?_(C.rightChild,T):_(C.leftChild,T)||{key:C.key,value:C.value}};this.upperBound=function(C){return _(v,C)};var A=function(C,T){if(C&&C.key!==void 0&&C.value!==void 0){var S=h(C.key,T);return S===0?{key:C.key,value:C.value}:S>0?A(C.leftChild,T):A(C.rightChild,T)||{key:C.key,value:C.value}}};this.reverseLowerBound=function(C){return A(v,C)};var x=function(C,T){if(C&&C.key!==void 0&&C.value!==void 0)return h(C.key,T)>=0?x(C.leftChild,T):x(C.rightChild,T)||{key:C.key,value:C.value}};this.reverseUpperBound=function(C){return x(v,C)};var E=function(C){var T=C.parent;if(!T){if(C===v)return;throw new Error("unknown error")}if(C.color!==l.default.TreeNodeColorType.red){var S=C.brother;if(!S)throw new Error("unknown error");if(C===T.leftChild)if(S.color===l.default.TreeNodeColorType.red){S.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red;var O=T.rotateLeft();v===T&&(v=O),E(C)}else S.color===l.default.TreeNodeColorType.black&&(S.rightChild&&S.rightChild.color===l.default.TreeNodeColorType.red?(S.color=T.color,T.color=l.default.TreeNodeColorType.black,S.rightChild&&(S.rightChild.color=l.default.TreeNodeColorType.black),O=T.rotateLeft(),v===T&&(v=O),C.color=l.default.TreeNodeColorType.black):S.rightChild&&S.rightChild.color!==l.default.TreeNodeColorType.black||!S.leftChild||S.leftChild.color!==l.default.TreeNodeColorType.red?S.leftChild&&S.leftChild.color!==l.default.TreeNodeColorType.black||S.rightChild&&S.rightChild.color!==l.default.TreeNodeColorType.black||(S.color=l.default.TreeNodeColorType.red,E(T)):(S.color=l.default.TreeNodeColorType.red,S.leftChild&&(S.leftChild.color=l.default.TreeNodeColorType.black),O=S.rotateRight(),v===S&&(v=O),E(C)));else C===T.rightChild&&(S.color===l.default.TreeNodeColorType.red?(S.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red,O=T.rotateRight(),v===T&&(v=O),E(C)):S.color===l.default.TreeNodeColorType.black&&(S.leftChild&&S.leftChild.color===l.default.TreeNodeColorType.red?(S.color=T.color,T.color=l.default.TreeNodeColorType.black,S.leftChild&&(S.leftChild.color=l.default.TreeNodeColorType.black),O=T.rotateRight(),v===T&&(v=O),C.color=l.default.TreeNodeColorType.black):S.leftChild&&S.leftChild.color!==l.default.TreeNodeColorType.black||!S.rightChild||S.rightChild.color!==l.default.TreeNodeColorType.red?S.leftChild&&S.leftChild.color!==l.default.TreeNodeColorType.black||S.rightChild&&S.rightChild.color!==l.default.TreeNodeColorType.black||(S.color=l.default.TreeNodeColorType.red,E(T)):(S.color=l.default.TreeNodeColorType.red,S.rightChild&&(S.rightChild.color=l.default.TreeNodeColorType.black),O=S.rotateLeft(),v===S&&(v=O),E(C))))}else C.color=l.default.TreeNodeColorType.black},I=function(C){for(var T=C;T.leftChild||T.rightChild;){if(T.rightChild){T=y(T.rightChild);var S=C.key;C.key=T.key,T.key=S;var O=C.value;C.value=T.value,T.value=O,C=T}T.leftChild&&(T=w(T.leftChild),S=C.key,C.key=T.key,T.key=S,O=C.value,C.value=T.value,T.value=O,C=T)}E(T),T&&T.remove(),--g,v.color=l.default.TreeNodeColorType.black},M=function(C,T){return!(!C||C.key===void 0)&&(!!M(C.leftChild,T)||!!T(C)||M(C.rightChild,T))};this.eraseElementByPos=function(C){if(C<0||C>=g)throw new Error("pos must more than 0 and less than set's size");var T=0;M(v,function(S){return C===T?(I(S),!0):(++T,!1)})},this.eraseElementByKey=function(C){if(!this.empty()){var T=q(v,C);T!==void 0&&T.key!==void 0&&h(T.key,C)===0&&I(T)}};var B=function(C,T){if(!C||C.key===void 0)throw new Error("unknown error");var S=h(T,C.key);return S<0?C.leftChild?B(C.leftChild,T):(C.leftChild=new l.default,C.leftChild.parent=C,C.leftChild.brother=C.rightChild,C.rightChild&&(C.rightChild.brother=C.leftChild),C.leftChild):S>0?C.rightChild?B(C.rightChild,T):(C.rightChild=new l.default,C.rightChild.parent=C,C.rightChild.brother=C.leftChild,C.leftChild&&(C.leftChild.brother=C.rightChild),C.rightChild):C},D=function(C){var T=C.parent;if(!T){if(C===v)return;throw new Error("unknown error")}if(T.color!==l.default.TreeNodeColorType.black&&T.color===l.default.TreeNodeColorType.red){var S=T.brother,O=T.parent;if(!O)throw new Error("unknown error");if(S&&S.color===l.default.TreeNodeColorType.red)S.color=T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,D(O);else if(!S||S.color===l.default.TreeNodeColorType.black)if(T===O.leftChild)if(C===T.leftChild){T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red;var K=O.rotateRight();O===v&&(v=K)}else C===T.rightChild&&(K=T.rotateLeft(),O===v&&(v=K),D(T));else T===O.rightChild&&(C===T.leftChild?(K=T.rotateRight(),O===v&&(v=K),D(T)):C===T.rightChild&&(T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,K=O.rotateLeft(),O===v&&(v=K)))}};this.setElement=function(C,T){if(C==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(T!=null){if(this.empty())return++g,v.key=C,v.value=T,void(v.color=l.default.TreeNodeColorType.black);var S=B(v,C);S.key===void 0||h(S.key,C)!==0?(++g,S.key=C,S.value=T,D(S),v.color=l.default.TreeNodeColorType.black):S.value=T}else this.eraseElementByKey(C)};var q=function(C,T){if(C&&C.key!==void 0){var S=h(T,C.key);return S<0?q(C.leftChild,T):S>0?q(C.rightChild,T):C}};this.find=function(C){return!!q(v,C)},this.getElementByKey=function(C){var T=q(v,C);if((T==null?void 0:T.key)===void 0||(T==null?void 0:T.value)===void 0)throw new Error("unknown error");return T.value},this.union=function(C){var T=this;C.forEach(function(S){var O=S.key,K=S.value;return T.setElement(O,K)})},this.getHeight=function(){if(this.empty())return 0;var C=function(T){return T?Math.max(C(T.leftChild),C(T.rightChild))+1:1};return C(v)};var Q=function(C){return s(this,function(T){switch(T.label){case 0:return C&&C.key!==void 0&&C.value!==void 0?[5,a(Q(C.leftChild))]:[2];case 1:return T.sent(),[4,{key:C.key,value:C.value}];case 2:return T.sent(),[5,a(Q(C.rightChild))];case 3:return T.sent(),[2]}})};this[Symbol.iterator]=function(){return Q(v)},u.forEach(function(C){var T=C.key,S=C.value;return d.setElement(T,S)}),Object.freeze(this)}Object.freeze(c),r.default=c},{"../Base/TreeNode":25}],31:[function(i,n,r){function s(a,l){a===void 0&&(a=[]),l=l||function(g,v){return g>v?-1:g<v?1:0};var c=[];a.forEach(function(g){return c.push(g)});var u=c.length,h=function(g,v){if(g<0||g>=u)throw new Error("unknown error");if(v<0||v>=u)throw new Error("unknown error");var y=c[g];c[g]=c[v],c[v]=y},d=function(g){if(g<0||g>=u)throw new Error("unknown error");var v=2*g+1,y=2*g+2;v<u&&l(c[g],c[v])>0&&h(g,v),y<u&&l(c[g],c[y])>0&&h(g,y)};(function(){for(var g=Math.floor((u-1)/2);g>=0;--g)for(var v=g,y=2*v+1;y<u;){var w=y+1,p=y;if(w<u&&l(c[y],c[w])>0&&(p=w),l(c[v],c[p])<=0)break;h(v,p),y=2*(v=p)+1}})(),this.size=function(){return u},this.empty=function(){return u===0},this.clear=function(){u=0,c.length=0},this.push=function(g){if(c.push(g),++u!==1)for(var v=u-1;v>0;){var y=Math.floor((v-1)/2);if(l(c[y],g)<=0)break;d(y),v=y}},this.pop=function(){if(!this.empty())if(this.size()!==1){var g=c[u-1];--u;for(var v=0;v<this.size();){var y=2*v+1,w=2*v+2;if(y>=this.size())break;var p=y;if(w<this.size()&&l(c[y],c[w])>0&&(p=w),l(c[p],g)>=0)break;c[v]=c[p],v=p}c[v]=g}else--u},this.top=function(){return c[0]},Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(s),r.default=s},{}],32:[function(i,n,r){Object.defineProperty(r,"__esModule",{value:!0});var s=i("../LinkList/LinkList");function a(l){l===void 0&&(l=[]);var c=new s.default(l);this.size=function(){return c.size()},this.empty=function(){return c.empty()},this.clear=function(){c.clear()},this.push=function(u){c.pushBack(u)},this.pop=function(){c.popFront()},this.front=function(){return c.front()},Object.freeze(this)}Object.freeze(a),r.default=a},{"../LinkList/LinkList":29}],33:[function(i,n,r){var s=this&&this.__generator||function(u,h){var d,g,v,y,w={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return y={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function p(_){return function(A){return function(x){if(d)throw new TypeError("Generator is already executing.");for(;w;)try{if(d=1,g&&(v=2&x[0]?g.return:x[0]?g.throw||((v=g.return)&&v.call(g),0):g.next)&&!(v=v.call(g,x[1])).done)return v;switch(g=0,v&&(x=[2&x[0],v.value]),x[0]){case 0:case 1:v=x;break;case 4:return w.label++,{value:x[1],done:!1};case 5:w.label++,g=x[1],x=[0];continue;case 7:x=w.ops.pop(),w.trys.pop();continue;default:if(!(v=(v=w.trys).length>0&&v[v.length-1])&&(x[0]===6||x[0]===2)){w=0;continue}if(x[0]===3&&(!v||x[1]>v[0]&&x[1]<v[3])){w.label=x[1];break}if(x[0]===6&&w.label<v[1]){w.label=v[1],v=x;break}if(v&&w.label<v[2]){w.label=v[2],w.ops.push(x);break}v[2]&&w.ops.pop(),w.trys.pop();continue}x=h.call(u,w)}catch(E){x=[6,E],g=0}finally{d=v=0}if(5&x[0])throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}([_,A])}}},a=this&&this.__values||function(u){var h=typeof Symbol=="function"&&Symbol.iterator,d=h&&u[h],g=0;if(d)return d.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(h?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var l=i("../Base/TreeNode");function c(u,h){var d=this;u===void 0&&(u=[]),h=h||function(C,T){return C<T?-1:C>T?1:0};var g=0,v=new l.default;v.color=l.default.TreeNodeColorType.black,this.size=function(){return g},this.empty=function(){return g===0},this.clear=function(){g=0,v.key=void 0,v.leftChild=v.rightChild=v.brother=v.parent=void 0,v.color=l.default.TreeNodeColorType.black};var y=function(C){if(!C||C.key===void 0)throw new Error("unknown error");return C.leftChild?y(C.leftChild):C},w=function(C){if(!C||C.key===void 0)throw new Error("unknown error");return C.rightChild?w(C.rightChild):C};this.front=function(){if(!this.empty())return y(v).key},this.back=function(){if(!this.empty())return w(v).key},this.forEach=function(C){var T,S,O=0;try{for(var K=a(this),Z=K.next();!Z.done;Z=K.next())C(Z.value,O++)}catch(st){T={error:st}}finally{try{Z&&!Z.done&&(S=K.return)&&S.call(K)}finally{if(T)throw T.error}}},this.getElementByPos=function(C){var T,S;if(C<0||C>=this.size())throw new Error("pos must more than 0 and less than set's size");var O=0;try{for(var K=a(this),Z=K.next();!Z.done;Z=K.next()){var st=Z.value;if(O===C)return st;++O}}catch($){T={error:$}}finally{try{Z&&!Z.done&&(S=K.return)&&S.call(K)}finally{if(T)throw T.error}}throw new Error("unknown error")};var p=function(C){var T=C.parent;if(!T){if(C===v)return;throw new Error("unknown error")}if(C.color!==l.default.TreeNodeColorType.red){var S=C.brother;if(!S)throw new Error("unknown error");if(C===T.leftChild)if(S.color===l.default.TreeNodeColorType.red){S.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red;var O=T.rotateLeft();v===T&&(v=O),p(C)}else S.color===l.default.TreeNodeColorType.black&&(S.rightChild&&S.rightChild.color===l.default.TreeNodeColorType.red?(S.color=T.color,T.color=l.default.TreeNodeColorType.black,S.rightChild&&(S.rightChild.color=l.default.TreeNodeColorType.black),O=T.rotateLeft(),v===T&&(v=O),C.color=l.default.TreeNodeColorType.black):S.rightChild&&S.rightChild.color!==l.default.TreeNodeColorType.black||!S.leftChild||S.leftChild.color!==l.default.TreeNodeColorType.red?S.leftChild&&S.leftChild.color!==l.default.TreeNodeColorType.black||S.rightChild&&S.rightChild.color!==l.default.TreeNodeColorType.black||(S.color=l.default.TreeNodeColorType.red,p(T)):(S.color=l.default.TreeNodeColorType.red,S.leftChild&&(S.leftChild.color=l.default.TreeNodeColorType.black),O=S.rotateRight(),v===S&&(v=O),p(C)));else C===T.rightChild&&(S.color===l.default.TreeNodeColorType.red?(S.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red,O=T.rotateRight(),v===T&&(v=O),p(C)):S.color===l.default.TreeNodeColorType.black&&(S.leftChild&&S.leftChild.color===l.default.TreeNodeColorType.red?(S.color=T.color,T.color=l.default.TreeNodeColorType.black,S.leftChild&&(S.leftChild.color=l.default.TreeNodeColorType.black),O=T.rotateRight(),v===T&&(v=O),C.color=l.default.TreeNodeColorType.black):S.leftChild&&S.leftChild.color!==l.default.TreeNodeColorType.black||!S.rightChild||S.rightChild.color!==l.default.TreeNodeColorType.red?S.leftChild&&S.leftChild.color!==l.default.TreeNodeColorType.black||S.rightChild&&S.rightChild.color!==l.default.TreeNodeColorType.black||(S.color=l.default.TreeNodeColorType.red,p(T)):(S.color=l.default.TreeNodeColorType.red,S.rightChild&&(S.rightChild.color=l.default.TreeNodeColorType.black),O=S.rotateLeft(),v===S&&(v=O),p(C))))}else C.color=l.default.TreeNodeColorType.black},_=function(C){for(var T=C;T.leftChild||T.rightChild;){if(T.rightChild){T=y(T.rightChild);var S=C.key;C.key=T.key,T.key=S,C=T}T.leftChild&&(T=w(T.leftChild),S=C.key,C.key=T.key,T.key=S,C=T)}p(T),T&&T.remove(),--g,v.color=l.default.TreeNodeColorType.black},A=function(C,T){return!(!C||C.key===void 0)&&(!!A(C.leftChild,T)||!!T(C)||A(C.rightChild,T))};this.eraseElementByPos=function(C){if(C<0||C>=g)throw new Error("pos must more than 0 and less than set's size");var T=0;A(v,function(S){return C===T?(_(S),!0):(++T,!1)})},this.eraseElementByValue=function(C){if(!this.empty()){var T=I(v,C);T!==void 0&&T.key!==void 0&&h(T.key,C)===0&&_(T)}};var x=function(C,T){if(!C||C.key===void 0)throw new Error("unknown error");var S=h(T,C.key);return S<0?C.leftChild?x(C.leftChild,T):(C.leftChild=new l.default,C.leftChild.parent=C,C.leftChild.brother=C.rightChild,C.rightChild&&(C.rightChild.brother=C.leftChild),C.leftChild):S>0?C.rightChild?x(C.rightChild,T):(C.rightChild=new l.default,C.rightChild.parent=C,C.rightChild.brother=C.leftChild,C.leftChild&&(C.leftChild.brother=C.rightChild),C.rightChild):C},E=function(C){var T=C.parent;if(!T){if(C===v)return;throw new Error("unknown error")}if(T.color!==l.default.TreeNodeColorType.black&&T.color===l.default.TreeNodeColorType.red){var S=T.brother,O=T.parent;if(!O)throw new Error("unknown error");if(S&&S.color===l.default.TreeNodeColorType.red)S.color=T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,E(O);else if(!S||S.color===l.default.TreeNodeColorType.black)if(T===O.leftChild)if(C===T.leftChild){T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red;var K=O.rotateRight();O===v&&(v=K)}else C===T.rightChild&&(K=T.rotateLeft(),O===v&&(v=K),E(T));else T===O.rightChild&&(C===T.leftChild?(K=T.rotateRight(),O===v&&(v=K),E(T)):C===T.rightChild&&(T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,K=O.rotateLeft(),O===v&&(v=K)))}};this.insert=function(C){if(C==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return++g,v.key=C,void(v.color=l.default.TreeNodeColorType.black);var T=x(v,C);T.key!==void 0&&h(T.key,C)===0||(++g,T.key=C,E(T),v.color=l.default.TreeNodeColorType.black)};var I=function(C,T){if(C&&C.key!==void 0){var S=h(T,C.key);return S<0?I(C.leftChild,T):S>0?I(C.rightChild,T):C}};this.find=function(C){var T=I(v,C);return T!==void 0&&T.key!==void 0&&h(T.key,C)===0};var M=function(C,T){if(C&&C.key!==void 0){var S=h(C.key,T);if(S===0)return C.key;if(S<0)return M(C.rightChild,T);var O=M(C.leftChild,T);return O!==void 0?O:C.key}};this.lowerBound=function(C){return M(v,C)};var B=function(C,T){if(C&&C.key!==void 0){if(h(C.key,T)<=0)return B(C.rightChild,T);var S=B(C.leftChild,T);return S!==void 0?S:C.key}};this.upperBound=function(C){return B(v,C)};var D=function(C,T){if(C&&C.key!==void 0){var S=h(C.key,T);if(S===0)return C.key;if(S>0)return D(C.leftChild,T);var O=D(C.rightChild,T);return O!==void 0?O:C.key}};this.reverseLowerBound=function(C){return D(v,C)};var q=function(C,T){if(C&&C.key!==void 0){if(h(C.key,T)>=0)return q(C.leftChild,T);var S=q(C.rightChild,T);return S!==void 0?S:C.key}};this.reverseUpperBound=function(C){return q(v,C)},this.union=function(C){var T=this;C.forEach(function(S){return T.insert(S)})},this.getHeight=function(){if(this.empty())return 0;var C=function(T){return T?Math.max(C(T.leftChild),C(T.rightChild))+1:1};return C(v)};var Q=function(C){return s(this,function(T){switch(T.label){case 0:return C&&C.key!==void 0?[5,a(Q(C.leftChild))]:[2];case 1:return T.sent(),[4,C.key];case 2:return T.sent(),[5,a(Q(C.rightChild))];case 3:return T.sent(),[2]}})};this[Symbol.iterator]=function(){return Q(v)},u.forEach(function(C){return d.insert(C)}),Object.freeze(this)}Object.freeze(c),r.default=c},{"../Base/TreeNode":25}],34:[function(i,n,r){function s(a){var l=this;a===void 0&&(a=[]);var c=0,u=[];this.size=function(){return c},this.empty=function(){return c===0},this.clear=function(){c=0,u.length=0},this.push=function(h){u.push(h),++c},this.pop=function(){u.pop(),c>0&&--c},this.top=function(){return u[c-1]},a.forEach(function(h){return l.push(h)}),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(s),r.default=s},{}],35:[function(i,n,r){var s=this&&this.__generator||function(h,d){var g,v,y,w,p={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return w={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function _(A){return function(x){return function(E){if(g)throw new TypeError("Generator is already executing.");for(;p;)try{if(g=1,v&&(y=2&E[0]?v.return:E[0]?v.throw||((y=v.return)&&y.call(v),0):v.next)&&!(y=y.call(v,E[1])).done)return y;switch(v=0,y&&(E=[2&E[0],y.value]),E[0]){case 0:case 1:y=E;break;case 4:return p.label++,{value:E[1],done:!1};case 5:p.label++,v=E[1],E=[0];continue;case 7:E=p.ops.pop(),p.trys.pop();continue;default:if(!(y=(y=p.trys).length>0&&y[y.length-1])&&(E[0]===6||E[0]===2)){p=0;continue}if(E[0]===3&&(!y||E[1]>y[0]&&E[1]<y[3])){p.label=E[1];break}if(E[0]===6&&p.label<y[1]){p.label=y[1],y=E;break}if(y&&p.label<y[2]){p.label=y[2],p.ops.push(E);break}y[2]&&p.ops.pop(),p.trys.pop();continue}E=d.call(h,p)}catch(I){E=[6,I],v=0}finally{g=y=0}if(5&E[0])throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}([A,x])}}},a=this&&this.__read||function(h,d){var g=typeof Symbol=="function"&&h[Symbol.iterator];if(!g)return h;var v,y,w=g.call(h),p=[];try{for(;(d===void 0||d-- >0)&&!(v=w.next()).done;)p.push(v.value)}catch(_){y={error:_}}finally{try{v&&!v.done&&(g=w.return)&&g.call(w)}finally{if(y)throw y.error}}return p},l=this&&this.__spreadArray||function(h,d,g){if(g||arguments.length===2)for(var v,y=0,w=d.length;y<w;y++)!v&&y in d||(v||(v=Array.prototype.slice.call(d,0,y)),v[y]=d[y]);return h.concat(v||Array.prototype.slice.call(d))},c=this&&this.__values||function(h){var d=typeof Symbol=="function"&&Symbol.iterator,g=d&&h[d],v=0;if(g)return g.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")};function u(h){var d=this;h===void 0&&(h=[]);var g=0,v=[];this.size=function(){return g},this.empty=function(){return g===0},this.clear=function(){g=0,v.length=0},this.front=function(){if(!this.empty())return v[0]},this.back=function(){if(!this.empty())return v[g-1]},this.forEach=function(y){v.forEach(y)},this.getElementByPos=function(y){if(y<0||y>=g)throw new Error("pos must more than 0 and less than vector's size");return v[y]},this.eraseElementByPos=function(y){if(y<0||y>=g)throw new Error("pos must more than 0 and less than vector's size");for(var w=y;w<g-1;++w)v[w]=v[w+1];this.popBack()},this.eraseElementByValue=function(y){var w=[];this.forEach(function(_){_!==y&&w.push(_)}),w.forEach(function(_,A){v[A]=_});for(var p=w.length;g>p;)this.popBack()},this.pushBack=function(y){v.push(y),++g},this.popBack=function(){v.pop(),g>0&&--g},this.setElementByPos=function(y,w){if(y<0||y>=g)throw new Error("pos must more than 0 and less than vector's size");v[y]=w},this.insert=function(y,w,p){if(p===void 0&&(p=1),y<0||y>g)throw new Error("pos must more than 0 and less than or equal to vector's size");v.splice.apply(v,l([y,0],a(new Array(p).fill(w)),!1)),g+=p},this.find=function(y){return v.includes(y)},this.reverse=function(){v.reverse()},this.unique=function(){var y,w=[];this.forEach(function(_,A){A!==0&&_===y||(w.push(_),y=_)}),w.forEach(function(_,A){v[A]=_});for(var p=w.length;g>p;)this.popBack()},this.sort=function(y){v.sort(y)},this[Symbol.iterator]=function(){return function(){return s(this,function(y){switch(y.label){case 0:return[5,c(v)];case 1:return[2,y.sent()]}})}()},h.forEach(function(y){return d.pushBack(y)}),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(u),r.default=u},{}],36:[function(i,n,r){Object.defineProperty(r,"__esModule",{value:!0}),r.HashMap=r.HashSet=r.Map=r.Set=r.PriorityQueue=r.Deque=r.LinkList=r.Queue=r.Stack=r.Vector=void 0;var s=i("./Vector/Vector");r.Vector=s.default;var a=i("./Stack/Stack");r.Stack=a.default;var l=i("./Queue/Queue");r.Queue=l.default;var c=i("./LinkList/LinkList");r.LinkList=c.default;var u=i("./Deque/Deque");r.Deque=u.default;var h=i("./PriorityQueue/PriorityQueue");r.PriorityQueue=h.default;var d=i("./Set/Set");r.Set=d.default;var g=i("./Map/Map");r.Map=g.default;var v=i("./HashSet/HashSet");r.HashSet=v.default;var y=i("./HashMap/HashMap");r.HashMap=y.default},{"./Deque/Deque":26,"./HashMap/HashMap":27,"./HashSet/HashSet":28,"./LinkList/LinkList":29,"./Map/Map":30,"./PriorityQueue/PriorityQueue":31,"./Queue/Queue":32,"./Set/Set":33,"./Stack/Stack":34,"./Vector/Vector":35}],37:[function(i,n,r){const s=i("yallist"),a=Symbol("max"),l=Symbol("length"),c=Symbol("lengthCalculator"),u=Symbol("allowStale"),h=Symbol("maxAge"),d=Symbol("dispose"),g=Symbol("noDisposeOnSet"),v=Symbol("lruList"),y=Symbol("cache"),w=Symbol("updateAgeOnGet"),p=()=>1,_=(B,D,q)=>{const Q=B[y].get(D);if(Q){const C=Q.value;if(A(B,C)){if(E(B,Q),!B[u])return}else q&&(B[w]&&(Q.value.now=Date.now()),B[v].unshiftNode(Q));return C.value}},A=(B,D)=>{if(!D||!D.maxAge&&!B[h])return!1;const q=Date.now()-D.now;return D.maxAge?q>D.maxAge:B[h]&&q>B[h]},x=B=>{if(B[l]>B[a])for(let D=B[v].tail;B[l]>B[a]&&D!==null;){const q=D.prev;E(B,D),D=q}},E=(B,D)=>{if(D){const q=D.value;B[d]&&B[d](q.key,q.value),B[l]-=q.length,B[y].delete(q.key),B[v].removeNode(D)}};class I{constructor(D,q,Q,C,T){this.key=D,this.value=q,this.length=Q,this.now=C,this.maxAge=T||0}}const M=(B,D,q,Q)=>{let C=q.value;A(B,C)&&(E(B,q),B[u]||(C=void 0)),C&&D.call(Q,C.value,C.key,B)};n.exports=class{constructor(B){if(typeof B=="number"&&(B={max:B}),B||(B={}),B.max&&(typeof B.max!="number"||B.max<0))throw new TypeError("max must be a non-negative number");this[a]=B.max||1/0;const D=B.length||p;if(this[c]=typeof D!="function"?p:D,this[u]=B.stale||!1,B.maxAge&&typeof B.maxAge!="number")throw new TypeError("maxAge must be a number");this[h]=B.maxAge||0,this[d]=B.dispose,this[g]=B.noDisposeOnSet||!1,this[w]=B.updateAgeOnGet||!1,this.reset()}set max(B){if(typeof B!="number"||B<0)throw new TypeError("max must be a non-negative number");this[a]=B||1/0,x(this)}get max(){return this[a]}set allowStale(B){this[u]=!!B}get allowStale(){return this[u]}set maxAge(B){if(typeof B!="number")throw new TypeError("maxAge must be a non-negative number");this[h]=B,x(this)}get maxAge(){return this[h]}set lengthCalculator(B){typeof B!="function"&&(B=p),B!==this[c]&&(this[c]=B,this[l]=0,this[v].forEach(D=>{D.length=this[c](D.value,D.key),this[l]+=D.length})),x(this)}get lengthCalculator(){return this[c]}get length(){return this[l]}get itemCount(){return this[v].length}rforEach(B,D){D=D||this;for(let q=this[v].tail;q!==null;){const Q=q.prev;M(this,B,q,D),q=Q}}forEach(B,D){D=D||this;for(let q=this[v].head;q!==null;){const Q=q.next;M(this,B,q,D),q=Q}}keys(){return this[v].toArray().map(B=>B.key)}values(){return this[v].toArray().map(B=>B.value)}reset(){this[d]&&this[v]&&this[v].length&&this[v].forEach(B=>this[d](B.key,B.value)),this[y]=new Map,this[v]=new s,this[l]=0}dump(){return this[v].map(B=>!A(this,B)&&{k:B.key,v:B.value,e:B.now+(B.maxAge||0)}).toArray().filter(B=>B)}dumpLru(){return this[v]}set(B,D,q){if((q=q||this[h])&&typeof q!="number")throw new TypeError("maxAge must be a number");const Q=q?Date.now():0,C=this[c](D,B);if(this[y].has(B)){if(C>this[a])return E(this,this[y].get(B)),!1;const S=this[y].get(B).value;return this[d]&&(this[g]||this[d](B,S.value)),S.now=Q,S.maxAge=q,S.value=D,this[l]+=C-S.length,S.length=C,this.get(B),x(this),!0}const T=new I(B,D,C,Q,q);return T.length>this[a]?(this[d]&&this[d](B,D),!1):(this[l]+=T.length,this[v].unshift(T),this[y].set(B,this[v].head),x(this),!0)}has(B){if(!this[y].has(B))return!1;const D=this[y].get(B).value;return!A(this,D)}get(B){return _(this,B,!0)}peek(B){return _(this,B,!1)}pop(){const B=this[v].tail;return B?(E(this,B),B.value):null}del(B){E(this,this[y].get(B))}load(B){this.reset();const D=Date.now();for(let q=B.length-1;q>=0;q--){const Q=B[q],C=Q.e||0;if(C===0)this.set(Q.k,Q.v);else{const T=C-D;T>0&&this.set(Q.k,Q.v,T)}}}prune(){this[y].forEach((B,D)=>_(this,D,!1))}}},{yallist:83}],38:[function(i,n,r){(function(s){(function(){const a=n.exports;a.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},a.codes={};for(const c in a.types){const u=a.types[c];a.codes[u]=c}a.CMD_SHIFT=4,a.CMD_MASK=240,a.DUP_MASK=8,a.QOS_MASK=3,a.QOS_SHIFT=1,a.RETAIN_MASK=1,a.VARBYTEINT_MASK=127,a.VARBYTEINT_FIN_MASK=128,a.VARBYTEINT_MAX=268435455,a.SESSIONPRESENT_MASK=1,a.SESSIONPRESENT_HEADER=s.from([a.SESSIONPRESENT_MASK]),a.CONNACK_HEADER=s.from([a.codes.connack<<a.CMD_SHIFT]),a.USERNAME_MASK=128,a.PASSWORD_MASK=64,a.WILL_RETAIN_MASK=32,a.WILL_QOS_MASK=24,a.WILL_QOS_SHIFT=3,a.WILL_FLAG_MASK=4,a.CLEAN_SESSION_MASK=2,a.CONNECT_HEADER=s.from([a.codes.connect<<a.CMD_SHIFT]),a.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},a.propertiesCodes={};for(const c in a.properties){const u=a.properties[c];a.propertiesCodes[u]=c}function l(c){return[0,1,2].map(u=>[0,1].map(h=>[0,1].map(d=>{const g=s.alloc(1);return g.writeUInt8(a.codes[c]<<a.CMD_SHIFT|(h?a.DUP_MASK:0)|u<<a.QOS_SHIFT|d,0,!0),g})))}a.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},a.PUBLISH_HEADER=l("publish"),a.SUBSCRIBE_HEADER=l("subscribe"),a.SUBSCRIBE_OPTIONS_QOS_MASK=3,a.SUBSCRIBE_OPTIONS_NL_MASK=1,a.SUBSCRIBE_OPTIONS_NL_SHIFT=2,a.SUBSCRIBE_OPTIONS_RAP_MASK=1,a.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,a.SUBSCRIBE_OPTIONS_RH_MASK=3,a.SUBSCRIBE_OPTIONS_RH_SHIFT=4,a.SUBSCRIBE_OPTIONS_RH=[0,16,32],a.SUBSCRIBE_OPTIONS_NL=4,a.SUBSCRIBE_OPTIONS_RAP=8,a.SUBSCRIBE_OPTIONS_QOS=[0,1,2],a.UNSUBSCRIBE_HEADER=l("unsubscribe"),a.ACKS={unsuback:l("unsuback"),puback:l("puback"),pubcomp:l("pubcomp"),pubrel:l("pubrel"),pubrec:l("pubrec")},a.SUBACK_HEADER=s.from([a.codes.suback<<a.CMD_SHIFT]),a.VERSION3=s.from([3]),a.VERSION4=s.from([4]),a.VERSION5=s.from([5]),a.VERSION131=s.from([131]),a.VERSION132=s.from([132]),a.QOS=[0,1,2].map(c=>s.from([c])),a.EMPTY={pingreq:s.from([a.codes.pingreq<<4,0]),pingresp:s.from([a.codes.pingresp<<4,0]),disconnect:s.from([a.codes.disconnect<<4,0])}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],39:[function(i,n,r){(function(s){(function(){const a=i("./writeToStream"),l=i("events");class c extends l{constructor(){super(),this._array=new Array(20),this._i=0}write(h){return this._array[this._i++]=h,!0}concat(){let h=0;const d=new Array(this._array.length),g=this._array;let v,y=0;for(v=0;v<g.length&&g[v]!==void 0;v++)typeof g[v]!="string"?d[v]=g[v].length:d[v]=s.byteLength(g[v]),h+=d[v];const w=s.allocUnsafe(h);for(v=0;v<g.length&&g[v]!==void 0;v++)typeof g[v]!="string"?(g[v].copy(w,y),y+=d[v]):(w.write(g[v],y),y+=d[v]);return w}}n.exports=function(u,h){const d=new c;return a(u,d,h),d.concat()}}).call(this)}).call(this,i("buffer").Buffer)},{"./writeToStream":44,buffer:17,events:22}],40:[function(i,n,r){r.parser=i("./parser").parser,r.generate=i("./generate"),r.writeToStream=i("./writeToStream")},{"./generate":39,"./parser":43,"./writeToStream":44}],41:[function(i,n,r){(function(s){(function(){const l={},c=s.isBuffer(s.from([1,2]).subarray(0,1));function u(h){const d=s.allocUnsafe(2);return d.writeUInt8(h>>8,0),d.writeUInt8(255&h,1),d}n.exports={cache:l,generateCache:function(){for(let h=0;h<65536;h++)l[h]=u(h)},generateNumber:u,genBufVariableByteInt:function(h){let d=0,g=0;const v=s.allocUnsafe(4);do d=h%128|0,(h=h/128|0)>0&&(d|=128),v.writeUInt8(d,g++);while(h>0&&g<4);return h>0&&(g=0),c?v.subarray(0,g):v.slice(0,g)},generate4ByteBuffer:function(h){const d=s.allocUnsafe(4);return d.writeUInt32BE(h,0),d}}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],42:[function(i,n,r){n.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},{}],43:[function(i,n,r){const s=i("bl"),a=i("events"),l=i("./packet"),c=i("./constants"),u=i("debug")("mqtt-packet:parser");class h extends a{constructor(){super(),this.parser=this.constructor.parser}static parser(g){return this instanceof h?(this.settings=g||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new h().parser(g)}_resetState(){u("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new l,this.error=null,this._list=s(),this._stateCounter=0}parse(g){for(this.error&&this._resetState(),this._list.append(g),u("parse: current state: %s",this._states[this._stateCounter]);(this.packet.length!==-1||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,u("parse: state complete. _stateCounter is now: %d",this._stateCounter),u("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return u("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const g=this._list.readUInt8(0);return this.packet.cmd=c.types[g>>c.CMD_SHIFT],this.packet.retain=(g&c.RETAIN_MASK)!=0,this.packet.qos=g>>c.QOS_SHIFT&c.QOS_MASK,this.packet.dup=(g&c.DUP_MASK)!=0,u("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const g=this._parseVarByteNum(!0);return g&&(this.packet.length=g.value,this._list.consume(g.bytes)),u("_parseLength %d",g.value),!!g}_parsePayload(){u("_parsePayload: payload %O",this._list);let g=!1;if(this.packet.length===0||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}g=!0}return u("_parsePayload complete result: %s",g),g}_parseConnect(){let g,v,y,w;u("_parseConnect");const p={},_=this.packet,A=this._parseString();if(A===null)return this._emitError(new Error("Cannot parse protocolId"));if(A!=="MQTT"&&A!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(_.protocolId=A,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(_.protocolVersion=this._list.readUInt8(this._pos),_.protocolVersion>=128&&(_.bridgeMode=!0,_.protocolVersion=_.protocolVersion-128),_.protocolVersion!==3&&_.protocolVersion!==4&&_.protocolVersion!==5)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(p.username=this._list.readUInt8(this._pos)&c.USERNAME_MASK,p.password=this._list.readUInt8(this._pos)&c.PASSWORD_MASK,p.will=this._list.readUInt8(this._pos)&c.WILL_FLAG_MASK,p.will&&(_.will={},_.will.retain=(this._list.readUInt8(this._pos)&c.WILL_RETAIN_MASK)!=0,_.will.qos=(this._list.readUInt8(this._pos)&c.WILL_QOS_MASK)>>c.WILL_QOS_SHIFT),_.clean=(this._list.readUInt8(this._pos)&c.CLEAN_SESSION_MASK)!=0,this._pos++,_.keepalive=this._parseNum(),_.keepalive===-1)return this._emitError(new Error("Packet too short"));if(_.protocolVersion===5){const E=this._parseProperties();Object.getOwnPropertyNames(E).length&&(_.properties=E)}const x=this._parseString();if(x===null)return this._emitError(new Error("Packet too short"));if(_.clientId=x,u("_parseConnect: packet.clientId: %s",_.clientId),p.will){if(_.protocolVersion===5){const E=this._parseProperties();Object.getOwnPropertyNames(E).length&&(_.will.properties=E)}if((g=this._parseString())===null)return this._emitError(new Error("Cannot parse will topic"));if(_.will.topic=g,u("_parseConnect: packet.will.topic: %s",_.will.topic),(v=this._parseBuffer())===null)return this._emitError(new Error("Cannot parse will payload"));_.will.payload=v,u("_parseConnect: packet.will.paylaod: %s",_.will.payload)}if(p.username){if((w=this._parseString())===null)return this._emitError(new Error("Cannot parse username"));_.username=w,u("_parseConnect: packet.username: %s",_.username)}if(p.password){if((y=this._parseBuffer())===null)return this._emitError(new Error("Cannot parse password"));_.password=y}return this.settings=_,u("_parseConnect: complete"),_}_parseConnack(){u("_parseConnack");const g=this.packet;if(this._list.length<1)return null;if(g.sessionPresent=!!(this._list.readUInt8(this._pos++)&c.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?g.reasonCode=this._list.readUInt8(this._pos++):g.reasonCode=0;else{if(this._list.length<2)return null;g.returnCode=this._list.readUInt8(this._pos++)}if(g.returnCode===-1||g.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}u("_parseConnack: complete")}_parsePublish(){u("_parsePublish");const g=this.packet;if(g.topic=this._parseString(),g.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(g.qos>0)||this._parseMessageId()){if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}g.payload=this._list.slice(this._pos,g.length),u("_parsePublish: payload from buffer list: %o",g.payload)}}_parseSubscribe(){u("_parseSubscribe");const g=this.packet;let v,y,w,p,_,A,x;if(g.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(g.subscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const E=this._parseProperties();Object.getOwnPropertyNames(E).length&&(g.properties=E)}for(;this._pos<g.length;){if((v=this._parseString())===null)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=g.length)return this._emitError(new Error("Malformed Subscribe Payload"));w=(y=this._parseByte())&c.SUBSCRIBE_OPTIONS_QOS_MASK,A=(y>>c.SUBSCRIBE_OPTIONS_NL_SHIFT&c.SUBSCRIBE_OPTIONS_NL_MASK)!=0,_=(y>>c.SUBSCRIBE_OPTIONS_RAP_SHIFT&c.SUBSCRIBE_OPTIONS_RAP_MASK)!=0,p=y>>c.SUBSCRIBE_OPTIONS_RH_SHIFT&c.SUBSCRIBE_OPTIONS_RH_MASK,x={topic:v,qos:w},this.settings.protocolVersion===5?(x.nl=A,x.rap=_,x.rh=p):this.settings.bridgeMode&&(x.rh=0,x.rap=!0,x.nl=!0),u("_parseSubscribe: push subscription `%s` to subscription",x),g.subscriptions.push(x)}}}_parseSuback(){u("_parseSuback");const g=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){u("_parseUnsubscribe");const g=this.packet;if(g.unsubscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}for(;this._pos<g.length;){const v=this._parseString();if(v===null)return this._emitError(new Error("Cannot parse topic"));u("_parseUnsubscribe: push topic `%s` to unsubscriptions",v),g.unsubscriptions.push(v)}}}_parseUnsuback(){u("_parseUnsuback");const g=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(this.settings.protocolVersion===5){const v=this._parseProperties();for(Object.getOwnPropertyNames(v).length&&(g.properties=v),g.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){u("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const g=this.packet;if(this._parseMessageId(),this.settings.protocolVersion===5&&(g.length>2?(g.reasonCode=this._parseByte(),u("_parseConfirmation: packet.reasonCode `%d`",g.reasonCode)):g.reasonCode=0,g.length>3)){const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}return!0}_parseDisconnect(){const g=this.packet;if(u("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?g.reasonCode=this._parseByte():g.reasonCode=0;const v=this._parseProperties();Object.getOwnPropertyNames(v).length&&(g.properties=v)}return u("_parseDisconnect result: true"),!0}_parseAuth(){u("_parseAuth");const g=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));g.reasonCode=this._parseByte();const v=this._parseProperties();return Object.getOwnPropertyNames(v).length&&(g.properties=v),u("_parseAuth: result: true"),!0}_parseMessageId(){const g=this.packet;return g.messageId=this._parseNum(),g.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(u("_parseMessageId: packet.messageId %d",g.messageId),!0)}_parseString(g){const v=this._parseNum(),y=v+this._pos;if(v===-1||y>this._list.length||y>this.packet.length)return null;const w=this._list.toString("utf8",this._pos,y);return this._pos+=v,u("_parseString: result: %s",w),w}_parseStringPair(){return u("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const g=this._parseNum(),v=g+this._pos;if(g===-1||v>this._list.length||v>this.packet.length)return null;const y=this._list.slice(this._pos,v);return this._pos+=g,u("_parseBuffer: result: %o",y),y}_parseNum(){if(this._list.length-this._pos<2)return-1;const g=this._list.readUInt16BE(this._pos);return this._pos+=2,u("_parseNum: result: %s",g),g}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const g=this._list.readUInt32BE(this._pos);return this._pos+=4,u("_parse4ByteNum: result: %s",g),g}_parseVarByteNum(g){u("_parseVarByteNum");let v,y=0,w=1,p=0,_=!1;const A=this._pos?this._pos:0;for(;y<4&&A+y<this._list.length;){if(p+=w*((v=this._list.readUInt8(A+y++))&c.VARBYTEINT_MASK),w*=128,(v&c.VARBYTEINT_FIN_MASK)==0){_=!0;break}if(this._list.length<=y)break}return!_&&y===4&&this._list.length>=y&&this._emitError(new Error("Invalid variable byte integer")),A&&(this._pos+=y),u("_parseVarByteNum: result: %o",_=!!_&&(g?{bytes:y,value:p}:p)),_}_parseByte(){let g;return this._pos<this._list.length&&(g=this._list.readUInt8(this._pos),this._pos++),u("_parseByte: result: %o",g),g}_parseByType(g){switch(u("_parseByType: type: %s",g),g){case"byte":return this._parseByte()!==0;case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){u("_parseProperties");const g=this._parseVarByteNum(),v=this._pos+g,y={};for(;this._pos<v;){const w=this._parseByte();if(!w)return this._emitError(new Error("Cannot parse property code type")),!1;const p=c.propertiesCodes[w];if(!p)return this._emitError(new Error("Unknown property")),!1;if(p!=="userProperties")y[p]?Array.isArray(y[p])?y[p].push(this._parseByType(c.propertiesTypes[p])):(y[p]=[y[p]],y[p].push(this._parseByType(c.propertiesTypes[p]))):y[p]=this._parseByType(c.propertiesTypes[p]);else{y[p]||(y[p]=Object.create(null));const _=this._parseByType(c.propertiesTypes[p]);if(y[p][_.name])if(Array.isArray(y[p][_.name]))y[p][_.name].push(_.value);else{const A=y[p][_.name];y[p][_.name]=[A],y[p][_.name].push(_.value)}else y[p][_.name]=_.value}}return y}_newPacket(){return u("_newPacket"),this.packet&&(this._list.consume(this.packet.length),u("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),u("_newPacket: new packet"),this.packet=new l,this._pos=0,!0}_emitError(g){u("_emitError"),this.error=g,this.emit("error",g)}}n.exports=h},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(i,n,r){(function(s){(function(){const a=i("./constants"),l=s.allocUnsafe(0),c=s.from([0]),u=i("./numbers"),h=i("process-nextick-args").nextTick,d=i("debug")("mqtt-packet:writeToStream"),g=u.cache,v=u.generateNumber,y=u.generateCache,w=u.genBufVariableByteInt,p=u.generate4ByteBuffer;let _=q,A=!0;function x($,z,V){switch(d("generate called"),z.cork&&(z.cork(),h(E,z)),A&&(A=!1,y()),d("generate: packet.cmd: %s",$.cmd),$.cmd){case"connect":return function(Y,U,tt){const rt=Y||{},nt=rt.protocolId||"MQTT";let ft=rt.protocolVersion||4;const lt=rt.will;let ut=rt.clean;const b=rt.keepalive||0,k=rt.clientId||"",P=rt.username,H=rt.password,X=rt.properties;ut===void 0&&(ut=!0);let J=0;if(!nt||typeof nt!="string"&&!s.isBuffer(nt))return U.emit("error",new Error("Invalid protocolId")),!1;if(J+=nt.length+2,ft!==3&&ft!==4&&ft!==5)return U.emit("error",new Error("Invalid protocol version")),!1;if(J+=1,(typeof k=="string"||s.isBuffer(k))&&(k||ft>=4)&&(k||ut))J+=s.byteLength(k)+2;else{if(ft<4)return U.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*ut==0)return U.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof b!="number"||b<0||b>65535||b%1!=0)return U.emit("error",new Error("Invalid keepalive")),!1;if(J+=2,J+=1,ft===5){var at=T(U,X);if(!at)return!1;J+=at.length}if(lt){if(typeof lt!="object")return U.emit("error",new Error("Invalid will")),!1;if(!lt.topic||typeof lt.topic!="string")return U.emit("error",new Error("Invalid will topic")),!1;if(J+=s.byteLength(lt.topic)+2,J+=2,lt.payload){if(!(lt.payload.length>=0))return U.emit("error",new Error("Invalid will payload")),!1;typeof lt.payload=="string"?J+=s.byteLength(lt.payload):J+=lt.payload.length}var mt={};if(ft===5){if(!(mt=T(U,lt.properties)))return!1;J+=mt.length}}let yt=!1;if(P!=null){if(!st(P))return U.emit("error",new Error("Invalid username")),!1;yt=!0,J+=s.byteLength(P)+2}if(H!=null){if(!yt)return U.emit("error",new Error("Username is required to use password")),!1;if(!st(H))return U.emit("error",new Error("Invalid password")),!1;J+=Z(H)+2}U.write(a.CONNECT_HEADER),M(U,J),C(U,nt),rt.bridgeMode&&(ft+=128),U.write(ft===131?a.VERSION131:ft===132?a.VERSION132:ft===4?a.VERSION4:ft===5?a.VERSION5:a.VERSION3);let kt=0;return kt|=P!=null?a.USERNAME_MASK:0,kt|=H!=null?a.PASSWORD_MASK:0,kt|=lt&&lt.retain?a.WILL_RETAIN_MASK:0,kt|=lt&&lt.qos?lt.qos<<a.WILL_QOS_SHIFT:0,kt|=lt?a.WILL_FLAG_MASK:0,kt|=ut?a.CLEAN_SESSION_MASK:0,U.write(s.from([kt])),_(U,b),ft===5&&at.write(),C(U,k),lt&&(ft===5&&mt.write(),B(U,lt.topic),C(U,lt.payload)),P!=null&&C(U,P),H!=null&&C(U,H),!0}($,z);case"connack":return function(Y,U,tt){const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=rt===5?nt.reasonCode:nt.returnCode,lt=nt.properties;let ut=2;if(typeof ft!="number")return U.emit("error",new Error("Invalid return code")),!1;let b=null;if(rt===5){if(!(b=T(U,lt)))return!1;ut+=b.length}return U.write(a.CONNACK_HEADER),M(U,ut),U.write(nt.sessionPresent?a.SESSIONPRESENT_HEADER:c),U.write(s.from([ft])),b!=null&&b.write(),!0}($,z,V);case"publish":return function(Y,U,tt){d("publish: packet: %o",Y);const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=nt.qos||0,lt=nt.retain?a.RETAIN_MASK:0,ut=nt.topic,b=nt.payload||l,k=nt.messageId,P=nt.properties;let H=0;if(typeof ut=="string")H+=s.byteLength(ut)+2;else{if(!s.isBuffer(ut))return U.emit("error",new Error("Invalid topic")),!1;H+=ut.length+2}if(s.isBuffer(b)?H+=b.length:H+=s.byteLength(b),ft&&typeof k!="number")return U.emit("error",new Error("Invalid messageId")),!1;ft&&(H+=2);let X=null;if(rt===5){if(!(X=T(U,P)))return!1;H+=X.length}return U.write(a.PUBLISH_HEADER[ft][nt.dup?1:0][lt?1:0]),M(U,H),_(U,Z(ut)),U.write(ut),ft>0&&_(U,k),X!=null&&X.write(),d("publish: payload: %o",b),U.write(b)}($,z,V);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(Y,U,tt){const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=nt.cmd||"puback",lt=nt.messageId,ut=nt.dup&&ft==="pubrel"?a.DUP_MASK:0;let b=0;const k=nt.reasonCode,P=nt.properties;let H=rt===5?3:2;if(ft==="pubrel"&&(b=1),typeof lt!="number")return U.emit("error",new Error("Invalid messageId")),!1;let X=null;if(rt===5&&typeof P=="object"){if(!(X=S(U,P,tt,H)))return!1;H+=X.length}return U.write(a.ACKS[ft][b][ut][0]),M(U,H),_(U,lt),rt===5&&U.write(s.from([k])),X!==null&&X.write(),!0}($,z,V);case"subscribe":return function(Y,U,tt){d("subscribe: packet: ");const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=nt.dup?a.DUP_MASK:0,lt=nt.messageId,ut=nt.subscriptions,b=nt.properties;let k=0;if(typeof lt!="number")return U.emit("error",new Error("Invalid messageId")),!1;k+=2;let P=null;if(rt===5){if(!(P=T(U,b)))return!1;k+=P.length}if(typeof ut!="object"||!ut.length)return U.emit("error",new Error("Invalid subscriptions")),!1;for(let X=0;X<ut.length;X+=1){const J=ut[X].topic,at=ut[X].qos;if(typeof J!="string")return U.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if(typeof at!="number")return U.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(rt===5){if(typeof(ut[X].nl||!1)!="boolean")return U.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if(typeof(ut[X].rap||!1)!="boolean")return U.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const kt=ut[X].rh||0;if(typeof kt!="number"||kt>2)return U.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}k+=s.byteLength(J)+2+1}d("subscribe: writing to stream: %o",a.SUBSCRIBE_HEADER),U.write(a.SUBSCRIBE_HEADER[1][ft?1:0][0]),M(U,k),_(U,lt),P!==null&&P.write();let H=!0;for(const X of ut){const J=X.topic,at=X.qos,mt=+X.nl,yt=+X.rap,kt=X.rh;let Tt;B(U,J),Tt=a.SUBSCRIBE_OPTIONS_QOS[at],rt===5&&(Tt|=mt?a.SUBSCRIBE_OPTIONS_NL:0,Tt|=yt?a.SUBSCRIBE_OPTIONS_RAP:0,Tt|=kt?a.SUBSCRIBE_OPTIONS_RH[kt]:0),H=U.write(s.from([Tt]))}return H}($,z,V);case"suback":return function(Y,U,tt){const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=nt.messageId,lt=nt.granted,ut=nt.properties;let b=0;if(typeof ft!="number")return U.emit("error",new Error("Invalid messageId")),!1;if(b+=2,typeof lt!="object"||!lt.length)return U.emit("error",new Error("Invalid qos vector")),!1;for(let P=0;P<lt.length;P+=1){if(typeof lt[P]!="number")return U.emit("error",new Error("Invalid qos vector")),!1;b+=1}let k=null;if(rt===5){if(!(k=S(U,ut,tt,b)))return!1;b+=k.length}return U.write(a.SUBACK_HEADER),M(U,b),_(U,ft),k!==null&&k.write(),U.write(s.from(lt))}($,z,V);case"unsubscribe":return function(Y,U,tt){const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=nt.messageId,lt=nt.dup?a.DUP_MASK:0,ut=nt.unsubscriptions,b=nt.properties;let k=0;if(typeof ft!="number")return U.emit("error",new Error("Invalid messageId")),!1;if(k+=2,typeof ut!="object"||!ut.length)return U.emit("error",new Error("Invalid unsubscriptions")),!1;for(let X=0;X<ut.length;X+=1){if(typeof ut[X]!="string")return U.emit("error",new Error("Invalid unsubscriptions")),!1;k+=s.byteLength(ut[X])+2}let P=null;if(rt===5){if(!(P=T(U,b)))return!1;k+=P.length}U.write(a.UNSUBSCRIBE_HEADER[1][lt?1:0][0]),M(U,k),_(U,ft),P!==null&&P.write();let H=!0;for(let X=0;X<ut.length;X++)H=B(U,ut[X]);return H}($,z,V);case"unsuback":return function(Y,U,tt){const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=nt.messageId,lt=nt.dup?a.DUP_MASK:0,ut=nt.granted,b=nt.properties,k=nt.cmd;let P=2;if(typeof ft!="number")return U.emit("error",new Error("Invalid messageId")),!1;if(rt===5){if(typeof ut!="object"||!ut.length)return U.emit("error",new Error("Invalid qos vector")),!1;for(let X=0;X<ut.length;X+=1){if(typeof ut[X]!="number")return U.emit("error",new Error("Invalid qos vector")),!1;P+=1}}let H=null;if(rt===5){if(!(H=S(U,b,tt,P)))return!1;P+=H.length}return U.write(a.ACKS[k][0][lt][0]),M(U,P),_(U,ft),H!==null&&H.write(),rt===5&&U.write(s.from(ut)),!0}($,z,V);case"pingreq":case"pingresp":return function(Y,U,tt){return U.write(a.EMPTY[Y.cmd])}($,z);case"disconnect":return function(Y,U,tt){const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=nt.reasonCode,lt=nt.properties;let ut=rt===5?1:0,b=null;if(rt===5){if(!(b=S(U,lt,tt,ut)))return!1;ut+=b.length}return U.write(s.from([a.codes.disconnect<<4])),M(U,ut),rt===5&&U.write(s.from([ft])),b!==null&&b.write(),!0}($,z,V);case"auth":return function(Y,U,tt){const rt=tt?tt.protocolVersion:4,nt=Y||{},ft=nt.reasonCode,lt=nt.properties;let ut=rt===5?1:0;rt!==5&&U.emit("error",new Error("Invalid mqtt version for auth packet"));const b=S(U,lt,tt,ut);return b?(ut+=b.length,U.write(s.from([a.codes.auth<<4])),M(U,ut),U.write(s.from([ft])),b!==null&&b.write(),!0):!1}($,z,V);default:return z.emit("error",new Error("Unknown command")),!1}}function E($){$.uncork()}Object.defineProperty(x,"cacheNumbers",{get:()=>_===q,set($){$?(g&&Object.keys(g).length!==0||(A=!0),_=q):(A=!1,_=Q)}});const I={};function M($,z){if(z>a.VARBYTEINT_MAX)return $.emit("error",new Error(`Invalid variable byte integer: ${z}`)),!1;let V=I[z];return V||(V=w(z),z<16384&&(I[z]=V)),d("writeVarByteInt: writing to stream: %o",V),$.write(V)}function B($,z){const V=s.byteLength(z);return _($,V),d("writeString: %s",z),$.write(z,"utf8")}function D($,z,V){B($,z),B($,V)}function q($,z){return d("writeNumberCached: number: %d",z),d("writeNumberCached: %o",g[z]),$.write(g[z])}function Q($,z){const V=v(z);return d("writeNumberGenerated: %o",V),$.write(V)}function C($,z){typeof z=="string"?B($,z):z?(_($,z.length),$.write(z)):_($,0)}function T($,z){if(typeof z!="object"||z.length!=null)return{length:1,write(){K($,{},0)}};let V=0;function Y(U,tt){let rt=0;switch(a.propertiesTypes[U]){case"byte":if(typeof tt!="boolean")return $.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;rt+=2;break;case"int8":if(typeof tt!="number"||tt<0||tt>255)return $.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;rt+=2;break;case"binary":if(tt&&tt===null)return $.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;rt+=1+s.byteLength(tt)+2;break;case"int16":if(typeof tt!="number"||tt<0||tt>65535)return $.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;rt+=3;break;case"int32":if(typeof tt!="number"||tt<0||tt>4294967295)return $.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;rt+=5;break;case"var":if(typeof tt!="number"||tt<0||tt>268435455)return $.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;rt+=1+s.byteLength(w(tt));break;case"string":if(typeof tt!="string")return $.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;rt+=3+s.byteLength(tt.toString());break;case"pair":if(typeof tt!="object")return $.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;rt+=Object.getOwnPropertyNames(tt).reduce((nt,ft)=>{const lt=tt[ft];return Array.isArray(lt)?nt+=lt.reduce((ut,b)=>ut+=3+s.byteLength(ft.toString())+2+s.byteLength(b.toString()),0):nt+=3+s.byteLength(ft.toString())+2+s.byteLength(tt[ft].toString()),nt},0);break;default:return $.emit("error",new Error(`Invalid property ${U}: ${tt}`)),!1}return rt}if(z)for(const U in z){let tt=0,rt=0;const nt=z[U];if(Array.isArray(nt))for(let ft=0;ft<nt.length;ft++){if(!(rt=Y(U,nt[ft])))return!1;tt+=rt}else{if(!(rt=Y(U,nt)))return!1;tt=rt}if(!tt)return!1;V+=tt}return{length:s.byteLength(w(V))+V,write(){K($,z,V)}}}function S($,z,V,Y){const U=["reasonString","userProperties"],tt=V&&V.properties&&V.properties.maximumPacketSize?V.properties.maximumPacketSize:0;let rt=T($,z);if(tt)for(;Y+rt.length>tt;){const nt=U.shift();if(!nt||!z[nt])return!1;delete z[nt],rt=T($,z)}return rt}function O($,z,V){switch(a.propertiesTypes[z]){case"byte":$.write(s.from([a.properties[z]])),$.write(s.from([+V]));break;case"int8":$.write(s.from([a.properties[z]])),$.write(s.from([V]));break;case"binary":$.write(s.from([a.properties[z]])),C($,V);break;case"int16":$.write(s.from([a.properties[z]])),_($,V);break;case"int32":$.write(s.from([a.properties[z]])),function(Y,U){const tt=p(U);d("write4ByteNumber: %o",tt),Y.write(tt)}($,V);break;case"var":$.write(s.from([a.properties[z]])),M($,V);break;case"string":$.write(s.from([a.properties[z]])),B($,V);break;case"pair":Object.getOwnPropertyNames(V).forEach(Y=>{const U=V[Y];Array.isArray(U)?U.forEach(tt=>{$.write(s.from([a.properties[z]])),D($,Y.toString(),tt.toString())}):($.write(s.from([a.properties[z]])),D($,Y.toString(),U.toString()))});break;default:return $.emit("error",new Error(`Invalid property ${z} value: ${V}`)),!1}}function K($,z,V){M($,V);for(const Y in z)if(Object.prototype.hasOwnProperty.call(z,Y)&&z[Y]!==null){const U=z[Y];if(Array.isArray(U))for(let tt=0;tt<U.length;tt++)O($,Y,U[tt]);else O($,Y,U)}}function Z($){return $?$ instanceof s?$.length:s.byteLength($):0}function st($){return typeof $=="string"||$ instanceof s}n.exports=x}).call(this)}).call(this,i("buffer").Buffer)},{"./constants":38,"./numbers":41,buffer:17,debug:18,"process-nextick-args":49}],45:[function(i,n,r){var s=1e3,a=60*s,l=60*a,c=24*l,u=7*c,h=365.25*c;function d(g,v,y,w){var p=v>=1.5*y;return Math.round(g/y)+" "+w+(p?"s":"")}n.exports=function(g,v){v=v||{};var y=typeof g;if(y==="string"&&g.length>0)return function(w){if(!((w=String(w)).length>100)){var p=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(w);if(!!p){var _=parseFloat(p[1]);switch((p[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return _*h;case"weeks":case"week":case"w":return _*u;case"days":case"day":case"d":return _*c;case"hours":case"hour":case"hrs":case"hr":case"h":return _*l;case"minutes":case"minute":case"mins":case"min":case"m":return _*a;case"seconds":case"second":case"secs":case"sec":case"s":return _*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return _;default:return}}}}(g);if(y==="number"&&isFinite(g))return v.long?function(w){var p=Math.abs(w);return p>=c?d(w,p,c,"day"):p>=l?d(w,p,l,"hour"):p>=a?d(w,p,a,"minute"):p>=s?d(w,p,s,"second"):w+" ms"}(g):function(w){var p=Math.abs(w);return p>=c?Math.round(w/c)+"d":p>=l?Math.round(w/l)+"h":p>=a?Math.round(w/a)+"m":p>=s?Math.round(w/s)+"s":w+"ms"}(g);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(g))}},{}],46:[function(i,n,r){const s=i("./lib/number-allocator.js");n.exports.NumberAllocator=s},{"./lib/number-allocator.js":47}],47:[function(i,n,r){const s=i("js-sdsl").Set,a=i("debug")("number-allocator:trace"),l=i("debug")("number-allocator:error");function c(h,d){this.low=h,this.high=d}function u(h,d){if(!(this instanceof u))return new u(h,d);this.min=h,this.max=d,this.ss=new s([],(g,v)=>g.compare(v)),a("Create"),this.clear()}c.prototype.equals=function(h){return this.low===h.low&&this.high===h.high},c.prototype.compare=function(h){return this.low<h.low&&this.high<h.low?-1:h.low<this.low&&h.high<this.low?1:0},u.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low},u.prototype.alloc=function(){if(this.ss.size()===0)return a("alloc():empty"),null;const h=this.ss.front(),d=h.low;return d+1<=h.high?++h.low:this.ss.eraseElementByPos(0),a("alloc():"+d),d},u.prototype.use=function(h){const d=new c(h,h),g=this.ss.lowerBound(d);if(g){if(g.equals(d))return this.ss.eraseElementByValue(g),a("use():"+h),!0;if(g.low>h)return!1;if(g.low===h)return++g.low,a("use():"+h),!0;if(g.high===h)return--g.high,a("use():"+h),!0;const v=g.low;return g.low=h+1,this.ss.insert(new c(v,h-1)),a("use():"+h),!0}return a("use():failed"),!1},u.prototype.free=function(h){if(h<this.min||h>this.max)return void l("free():"+h+" is out of range");const d=new c(h,h),g=this.ss.lowerBound(d);if(g){if(g.low<=h&&h<=g.high)return void l("free():"+h+" has already been vacant");if(g===this.ss.front())h+1===g.low?--g.low:this.ss.insert(d);else{const v=this.ss.reverseLowerBound(d);v.high+1===h?h+1===g.low?(this.ss.eraseElementByValue(v),g.low=v.low):v.high=h:h+1===g.low?g.low=h:this.ss.insert(d)}}else{if(g===this.ss.front())return void this.ss.insert(d);const v=this.ss.reverseLowerBound(d);v.high+1===h?v.high=h:this.ss.insert(d)}a("free():"+h)},u.prototype.clear=function(){a("clear()"),this.ss.clear(),this.ss.insert(new c(this.min,this.max))},u.prototype.intervalCount=function(){return this.ss.size()},u.prototype.dump=function(){console.log("length:"+this.ss.size());for(const h of this.ss)console.log(h)},n.exports=u},{debug:18,"js-sdsl":36}],48:[function(i,n,r){var s=i("wrappy");function a(c){var u=function(){return u.called?u.value:(u.called=!0,u.value=c.apply(this,arguments))};return u.called=!1,u}function l(c){var u=function(){if(u.called)throw new Error(u.onceError);return u.called=!0,u.value=c.apply(this,arguments)},h=c.name||"Function wrapped with `once`";return u.onceError=h+" shouldn't be called more than once",u.called=!1,u}n.exports=s(a),n.exports.strict=s(l),a.proto=a(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return a(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return l(this)},configurable:!0})})},{wrappy:79}],49:[function(i,n,r){(function(s){(function(){s===void 0||!s.version||s.version.indexOf("v0.")===0||s.version.indexOf("v1.")===0&&s.version.indexOf("v1.8.")!==0?n.exports={nextTick:function(a,l,c,u){if(typeof a!="function")throw new TypeError('"callback" argument must be a function');var h,d,g=arguments.length;switch(g){case 0:case 1:return s.nextTick(a);case 2:return s.nextTick(function(){a.call(null,l)});case 3:return s.nextTick(function(){a.call(null,l,c)});case 4:return s.nextTick(function(){a.call(null,l,c,u)});default:for(h=new Array(g-1),d=0;d<h.length;)h[d++]=arguments[d];return s.nextTick(function(){a.apply(null,h)})}}}:n.exports=s}).call(this)}).call(this,i("_process"))},{_process:50}],50:[function(i,n,r){var s,a,l=n.exports={};function c(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function h(x){if(s===setTimeout)return setTimeout(x,0);if((s===c||!s)&&setTimeout)return s=setTimeout,setTimeout(x,0);try{return s(x,0)}catch{try{return s.call(null,x,0)}catch{return s.call(this,x,0)}}}(function(){try{s=typeof setTimeout=="function"?setTimeout:c}catch{s=c}try{a=typeof clearTimeout=="function"?clearTimeout:u}catch{a=u}})();var d,g=[],v=!1,y=-1;function w(){v&&d&&(v=!1,d.length?g=d.concat(g):y=-1,g.length&&p())}function p(){if(!v){var x=h(w);v=!0;for(var E=g.length;E;){for(d=g,g=[];++y<E;)d&&d[y].run();y=-1,E=g.length}d=null,v=!1,function(I){if(a===clearTimeout)return clearTimeout(I);if((a===u||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(I);try{a(I)}catch{try{return a.call(null,I)}catch{return a.call(this,I)}}}(x)}}function _(x,E){this.fun=x,this.array=E}function A(){}l.nextTick=function(x){var E=new Array(arguments.length-1);if(arguments.length>1)for(var I=1;I<arguments.length;I++)E[I-1]=arguments[I];g.push(new _(x,E)),g.length!==1||v||h(p)},_.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=A,l.addListener=A,l.once=A,l.off=A,l.removeListener=A,l.removeAllListeners=A,l.emit=A,l.prependListener=A,l.prependOnceListener=A,l.listeners=function(x){return[]},l.binding=function(x){throw new Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(x){throw new Error("process.chdir is not supported")},l.umask=function(){return 0}},{}],51:[function(i,n,r){(function(s){(function(){(function(a){var l=typeof r=="object"&&r&&!r.nodeType&&r,c=typeof n=="object"&&n&&!n.nodeType&&n,u=typeof s=="object"&&s;u.global!==u&&u.window!==u&&u.self!==u||(a=u);var h,d,g=2147483647,v=36,y=1,w=26,p=38,_=700,A=72,x=128,E="-",I=/^xn--/,M=/[^\x20-\x7E]/,B=/[\x2E\u3002\uFF0E\uFF61]/g,D={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},q=v-y,Q=Math.floor,C=String.fromCharCode;function T(Y){throw new RangeError(D[Y])}function S(Y,U){for(var tt=Y.length,rt=[];tt--;)rt[tt]=U(Y[tt]);return rt}function O(Y,U){var tt=Y.split("@"),rt="";return tt.length>1&&(rt=tt[0]+"@",Y=tt[1]),rt+S((Y=Y.replace(B,".")).split("."),U).join(".")}function K(Y){for(var U,tt,rt=[],nt=0,ft=Y.length;nt<ft;)(U=Y.charCodeAt(nt++))>=55296&&U<=56319&&nt<ft?(64512&(tt=Y.charCodeAt(nt++)))==56320?rt.push(((1023&U)<<10)+(1023&tt)+65536):(rt.push(U),nt--):rt.push(U);return rt}function Z(Y){return S(Y,function(U){var tt="";return U>65535&&(tt+=C((U-=65536)>>>10&1023|55296),U=56320|1023&U),tt+=C(U)}).join("")}function st(Y,U){return Y+22+75*(Y<26)-((U!=0)<<5)}function $(Y,U,tt){var rt=0;for(Y=tt?Q(Y/_):Y>>1,Y+=Q(Y/U);Y>q*w>>1;rt+=v)Y=Q(Y/q);return Q(rt+(q+1)*Y/(Y+p))}function z(Y){var U,tt,rt,nt,ft,lt,ut,b,k,P,H,X=[],J=Y.length,at=0,mt=x,yt=A;for((tt=Y.lastIndexOf(E))<0&&(tt=0),rt=0;rt<tt;++rt)Y.charCodeAt(rt)>=128&&T("not-basic"),X.push(Y.charCodeAt(rt));for(nt=tt>0?tt+1:0;nt<J;){for(ft=at,lt=1,ut=v;nt>=J&&T("invalid-input"),((b=(H=Y.charCodeAt(nt++))-48<10?H-22:H-65<26?H-65:H-97<26?H-97:v)>=v||b>Q((g-at)/lt))&&T("overflow"),at+=b*lt,!(b<(k=ut<=yt?y:ut>=yt+w?w:ut-yt));ut+=v)lt>Q(g/(P=v-k))&&T("overflow"),lt*=P;yt=$(at-ft,U=X.length+1,ft==0),Q(at/U)>g-mt&&T("overflow"),mt+=Q(at/U),at%=U,X.splice(at++,0,mt)}return Z(X)}function V(Y){var U,tt,rt,nt,ft,lt,ut,b,k,P,H,X,J,at,mt,yt=[];for(X=(Y=K(Y)).length,U=x,tt=0,ft=A,lt=0;lt<X;++lt)(H=Y[lt])<128&&yt.push(C(H));for(rt=nt=yt.length,nt&&yt.push(E);rt<X;){for(ut=g,lt=0;lt<X;++lt)(H=Y[lt])>=U&&H<ut&&(ut=H);for(ut-U>Q((g-tt)/(J=rt+1))&&T("overflow"),tt+=(ut-U)*J,U=ut,lt=0;lt<X;++lt)if((H=Y[lt])<U&&++tt>g&&T("overflow"),H==U){for(b=tt,k=v;!(b<(P=k<=ft?y:k>=ft+w?w:k-ft));k+=v)mt=b-P,at=v-P,yt.push(C(st(P+mt%at,0))),b=Q(mt/at);yt.push(C(st(b,0))),ft=$(tt,J,rt==nt),tt=0,++rt}++tt,++U}return yt.join("")}if(h={version:"1.4.1",ucs2:{decode:K,encode:Z},decode:z,encode:V,toASCII:function(Y){return O(Y,function(U){return M.test(U)?"xn--"+V(U):U})},toUnicode:function(Y){return O(Y,function(U){return I.test(U)?z(U.slice(4).toLowerCase()):U})}},l&&c)if(n.exports==l)c.exports=h;else for(d in h)h.hasOwnProperty(d)&&(l[d]=h[d]);else a.punycode=h})(this)}).call(this)}).call(this,typeof Le<"u"?Le:typeof self<"u"?self:typeof window<"u"?window:{})},{}],52:[function(i,n,r){function s(l,c){return Object.prototype.hasOwnProperty.call(l,c)}n.exports=function(l,c,u,h){c=c||"&",u=u||"=";var d={};if(typeof l!="string"||l.length===0)return d;var g=/\+/g;l=l.split(c);var v=1e3;h&&typeof h.maxKeys=="number"&&(v=h.maxKeys);var y=l.length;v>0&&y>v&&(y=v);for(var w=0;w<y;++w){var p,_,A,x,E=l[w].replace(g,"%20"),I=E.indexOf(u);I>=0?(p=E.substr(0,I),_=E.substr(I+1)):(p=E,_=""),A=decodeURIComponent(p),x=decodeURIComponent(_),s(d,A)?a(d[A])?d[A].push(x):d[A]=[d[A],x]:d[A]=x}return d};var a=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"}},{}],53:[function(i,n,r){var s=function(u){switch(typeof u){case"string":return u;case"boolean":return u?"true":"false";case"number":return isFinite(u)?u:"";default:return""}};n.exports=function(u,h,d,g){return h=h||"&",d=d||"=",u===null&&(u=void 0),typeof u=="object"?l(c(u),function(v){var y=encodeURIComponent(s(v))+d;return a(u[v])?l(u[v],function(w){return y+encodeURIComponent(s(w))}).join(h):y+encodeURIComponent(s(u[v]))}).join(h):g?encodeURIComponent(s(g))+d+encodeURIComponent(s(u)):""};var a=Array.isArray||function(u){return Object.prototype.toString.call(u)==="[object Array]"};function l(u,h){if(u.map)return u.map(h);for(var d=[],g=0;g<u.length;g++)d.push(h(u[g],g));return d}var c=Object.keys||function(u){var h=[];for(var d in u)Object.prototype.hasOwnProperty.call(u,d)&&h.push(d);return h}},{}],54:[function(i,n,r){r.decode=r.parse=i("./decode"),r.encode=r.stringify=i("./encode")},{"./decode":52,"./encode":53}],55:[function(i,n,r){var s={};function a(c,u,h){h||(h=Error);var d=function(g){var v,y;function w(p,_,A){return g.call(this,function(x,E,I){return typeof u=="string"?u:u(x,E,I)}(p,_,A))||this}return y=g,(v=w).prototype=Object.create(y.prototype),v.prototype.constructor=v,v.__proto__=y,w}(h);d.prototype.name=h.name,d.prototype.code=c,s[c]=d}function l(c,u){if(Array.isArray(c)){var h=c.length;return c=c.map(function(d){return String(d)}),h>2?"one of ".concat(u," ").concat(c.slice(0,h-1).join(", "),", or ")+c[h-1]:h===2?"one of ".concat(u," ").concat(c[0]," or ").concat(c[1]):"of ".concat(u," ").concat(c[0])}return"of ".concat(u," ").concat(String(c))}a("ERR_INVALID_OPT_VALUE",function(c,u){return'The value "'+u+'" is invalid for option "'+c+'"'},TypeError),a("ERR_INVALID_ARG_TYPE",function(c,u,h){var d,g,v;if(typeof u=="string"&&(g="not ",u.substr(0,g.length)===g)?(d="must not be",u=u.replace(/^not /,"")):d="must be",function(w,p,_){return(_===void 0||_>w.length)&&(_=w.length),w.substring(_-p.length,_)===p}(c," argument"))v="The ".concat(c," ").concat(d," ").concat(l(u,"type"));else{var y=function(w,p,_){return typeof _!="number"&&(_=0),!(_+p.length>w.length)&&w.indexOf(p,_)!==-1}(c,".")?"property":"argument";v='The "'.concat(c,'" ').concat(y," ").concat(d," ").concat(l(u,"type"))}return v+=". Received type ".concat(typeof h)},TypeError),a("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),a("ERR_METHOD_NOT_IMPLEMENTED",function(c){return"The "+c+" method is not implemented"}),a("ERR_STREAM_PREMATURE_CLOSE","Premature close"),a("ERR_STREAM_DESTROYED",function(c){return"Cannot call "+c+" after a stream was destroyed"}),a("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),a("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),a("ERR_STREAM_WRITE_AFTER_END","write after end"),a("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),a("ERR_UNKNOWN_ENCODING",function(c){return"Unknown encoding: "+c},TypeError),a("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),n.exports.codes=s},{}],56:[function(i,n,r){(function(s){(function(){var a=Object.keys||function(w){var p=[];for(var _ in w)p.push(_);return p};n.exports=g;var l=i("./_stream_readable"),c=i("./_stream_writable");i("inherits")(g,l);for(var u=a(c.prototype),h=0;h<u.length;h++){var d=u[h];g.prototype[d]||(g.prototype[d]=c.prototype[d])}function g(w){if(!(this instanceof g))return new g(w);l.call(this,w),c.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",v)))}function v(){this._writableState.ended||s.nextTick(y,this)}function y(w){w.end()}Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(g.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(g.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(g.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(w){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=w,this._writableState.destroyed=w)}})}).call(this)}).call(this,i("_process"))},{"./_stream_readable":58,"./_stream_writable":60,_process:50,inherits:24}],57:[function(i,n,r){n.exports=a;var s=i("./_stream_transform");function a(l){if(!(this instanceof a))return new a(l);s.call(this,l)}i("inherits")(a,s),a.prototype._transform=function(l,c,u){u(null,l)}},{"./_stream_transform":59,inherits:24}],58:[function(i,n,r){(function(s,a){(function(){var l;n.exports=T,T.ReadableState=C,i("events").EventEmitter;var c=function(b,k){return b.listeners(k).length},u=i("./internal/streams/stream"),h=i("buffer").Buffer,d=a.Uint8Array||function(){},g,v=i("util");g=v&&v.debuglog?v.debuglog("stream"):function(){};var y,w,p,_=i("./internal/streams/buffer_list"),A=i("./internal/streams/destroy"),x=i("./internal/streams/state").getHighWaterMark,E=i("../errors").codes,I=E.ERR_INVALID_ARG_TYPE,M=E.ERR_STREAM_PUSH_AFTER_EOF,B=E.ERR_METHOD_NOT_IMPLEMENTED,D=E.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;i("inherits")(T,u);var q=A.errorOrDestroy,Q=["error","close","destroy","pause","resume"];function C(b,k,P){l=l||i("./_stream_duplex"),b=b||{},typeof P!="boolean"&&(P=k instanceof l),this.objectMode=!!b.objectMode,P&&(this.objectMode=this.objectMode||!!b.readableObjectMode),this.highWaterMark=x(this,b,"readableHighWaterMark",P),this.buffer=new _,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=b.emitClose!==!1,this.autoDestroy=!!b.autoDestroy,this.destroyed=!1,this.defaultEncoding=b.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(y||(y=i("string_decoder/").StringDecoder),this.decoder=new y(b.encoding),this.encoding=b.encoding)}function T(b){if(l=l||i("./_stream_duplex"),!(this instanceof T))return new T(b);var k=this instanceof l;this._readableState=new C(b,this,k),this.readable=!0,b&&(typeof b.read=="function"&&(this._read=b.read),typeof b.destroy=="function"&&(this._destroy=b.destroy)),u.call(this)}function S(b,k,P,H,X){g("readableAddChunk",k);var J,at=b._readableState;if(k===null)at.reading=!1,function(mt,yt){if(g("onEofChunk"),!yt.ended){if(yt.decoder){var kt=yt.decoder.end();kt&&kt.length&&(yt.buffer.push(kt),yt.length+=yt.objectMode?1:kt.length)}yt.ended=!0,yt.sync?st(mt):(yt.needReadable=!1,yt.emittedReadable||(yt.emittedReadable=!0,$(mt)))}}(b,at);else if(X||(J=function(mt,yt){var kt;Tt=yt,h.isBuffer(Tt)||Tt instanceof d||typeof yt=="string"||yt===void 0||mt.objectMode||(kt=new I("chunk",["string","Buffer","Uint8Array"],yt));var Tt;return kt}(at,k)),J)q(b,J);else if(at.objectMode||k&&k.length>0)if(typeof k=="string"||at.objectMode||Object.getPrototypeOf(k)===h.prototype||(k=function(mt){return h.from(mt)}(k)),H)at.endEmitted?q(b,new D):O(b,at,k,!0);else if(at.ended)q(b,new M);else{if(at.destroyed)return!1;at.reading=!1,at.decoder&&!P?(k=at.decoder.write(k),at.objectMode||k.length!==0?O(b,at,k,!1):z(b,at)):O(b,at,k,!1)}else H||(at.reading=!1,z(b,at));return!at.ended&&(at.length<at.highWaterMark||at.length===0)}function O(b,k,P,H){k.flowing&&k.length===0&&!k.sync?(k.awaitDrain=0,b.emit("data",P)):(k.length+=k.objectMode?1:P.length,H?k.buffer.unshift(P):k.buffer.push(P),k.needReadable&&st(b)),z(b,k)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(b){this._readableState&&(this._readableState.destroyed=b)}}),T.prototype.destroy=A.destroy,T.prototype._undestroy=A.undestroy,T.prototype._destroy=function(b,k){k(b)},T.prototype.push=function(b,k){var P,H=this._readableState;return H.objectMode?P=!0:typeof b=="string"&&((k=k||H.defaultEncoding)!==H.encoding&&(b=h.from(b,k),k=""),P=!0),S(this,b,k,!1,P)},T.prototype.unshift=function(b){return S(this,b,null,!0,!1)},T.prototype.isPaused=function(){return this._readableState.flowing===!1},T.prototype.setEncoding=function(b){y||(y=i("string_decoder/").StringDecoder);var k=new y(b);this._readableState.decoder=k,this._readableState.encoding=this._readableState.decoder.encoding;for(var P=this._readableState.buffer.head,H="";P!==null;)H+=k.write(P.data),P=P.next;return this._readableState.buffer.clear(),H!==""&&this._readableState.buffer.push(H),this._readableState.length=H.length,this};var K=1073741824;function Z(b,k){return b<=0||k.length===0&&k.ended?0:k.objectMode?1:b!=b?k.flowing&&k.length?k.buffer.head.data.length:k.length:(b>k.highWaterMark&&(k.highWaterMark=function(P){return P>=K?P=K:(P--,P|=P>>>1,P|=P>>>2,P|=P>>>4,P|=P>>>8,P|=P>>>16,P++),P}(b)),b<=k.length?b:k.ended?k.length:(k.needReadable=!0,0))}function st(b){var k=b._readableState;g("emitReadable",k.needReadable,k.emittedReadable),k.needReadable=!1,k.emittedReadable||(g("emitReadable",k.flowing),k.emittedReadable=!0,s.nextTick($,b))}function $(b){var k=b._readableState;g("emitReadable_",k.destroyed,k.length,k.ended),k.destroyed||!k.length&&!k.ended||(b.emit("readable"),k.emittedReadable=!1),k.needReadable=!k.flowing&&!k.ended&&k.length<=k.highWaterMark,rt(b)}function z(b,k){k.readingMore||(k.readingMore=!0,s.nextTick(V,b,k))}function V(b,k){for(;!k.reading&&!k.ended&&(k.length<k.highWaterMark||k.flowing&&k.length===0);){var P=k.length;if(g("maybeReadMore read 0"),b.read(0),P===k.length)break}k.readingMore=!1}function Y(b){var k=b._readableState;k.readableListening=b.listenerCount("readable")>0,k.resumeScheduled&&!k.paused?k.flowing=!0:b.listenerCount("data")>0&&b.resume()}function U(b){g("readable nexttick read 0"),b.read(0)}function tt(b,k){g("resume",k.reading),k.reading||b.read(0),k.resumeScheduled=!1,b.emit("resume"),rt(b),k.flowing&&!k.reading&&b.read(0)}function rt(b){var k=b._readableState;for(g("flow",k.flowing);k.flowing&&b.read()!==null;);}function nt(b,k){return k.length===0?null:(k.objectMode?P=k.buffer.shift():!b||b>=k.length?(P=k.decoder?k.buffer.join(""):k.buffer.length===1?k.buffer.first():k.buffer.concat(k.length),k.buffer.clear()):P=k.buffer.consume(b,k.decoder),P);var P}function ft(b){var k=b._readableState;g("endReadable",k.endEmitted),k.endEmitted||(k.ended=!0,s.nextTick(lt,k,b))}function lt(b,k){if(g("endReadableNT",b.endEmitted,b.length),!b.endEmitted&&b.length===0&&(b.endEmitted=!0,k.readable=!1,k.emit("end"),b.autoDestroy)){var P=k._writableState;(!P||P.autoDestroy&&P.finished)&&k.destroy()}}function ut(b,k){for(var P=0,H=b.length;P<H;P++)if(b[P]===k)return P;return-1}T.prototype.read=function(b){g("read",b),b=parseInt(b,10);var k=this._readableState,P=b;if(b!==0&&(k.emittedReadable=!1),b===0&&k.needReadable&&((k.highWaterMark!==0?k.length>=k.highWaterMark:k.length>0)||k.ended))return g("read: emitReadable",k.length,k.ended),k.length===0&&k.ended?ft(this):st(this),null;if((b=Z(b,k))===0&&k.ended)return k.length===0&&ft(this),null;var H,X=k.needReadable;return g("need readable",X),(k.length===0||k.length-b<k.highWaterMark)&&g("length less than watermark",X=!0),k.ended||k.reading?g("reading or ended",X=!1):X&&(g("do read"),k.reading=!0,k.sync=!0,k.length===0&&(k.needReadable=!0),this._read(k.highWaterMark),k.sync=!1,k.reading||(b=Z(P,k))),(H=b>0?nt(b,k):null)===null?(k.needReadable=k.length<=k.highWaterMark,b=0):(k.length-=b,k.awaitDrain=0),k.length===0&&(k.ended||(k.needReadable=!0),P!==b&&k.ended&&ft(this)),H!==null&&this.emit("data",H),H},T.prototype._read=function(b){q(this,new B("_read()"))},T.prototype.pipe=function(b,k){var P=this,H=this._readableState;switch(H.pipesCount){case 0:H.pipes=b;break;case 1:H.pipes=[H.pipes,b];break;default:H.pipes.push(b)}H.pipesCount+=1,g("pipe count=%d opts=%j",H.pipesCount,k);var X=(!k||k.end!==!1)&&b!==s.stdout&&b!==s.stderr?at:xe;function J(Vt,Qt){g("onunpipe"),Vt===P&&Qt&&Qt.hasUnpiped===!1&&(Qt.hasUnpiped=!0,g("cleanup"),b.removeListener("close",be),b.removeListener("finish",ne),b.removeListener("drain",mt),b.removeListener("error",Tt),b.removeListener("unpipe",J),P.removeListener("end",at),P.removeListener("end",xe),P.removeListener("data",kt),yt=!0,!H.awaitDrain||b._writableState&&!b._writableState.needDrain||mt())}function at(){g("onend"),b.end()}H.endEmitted?s.nextTick(X):P.once("end",X),b.on("unpipe",J);var mt=function(Vt){return function(){var Qt=Vt._readableState;g("pipeOnDrain",Qt.awaitDrain),Qt.awaitDrain&&Qt.awaitDrain--,Qt.awaitDrain===0&&c(Vt,"data")&&(Qt.flowing=!0,rt(Vt))}}(P);b.on("drain",mt);var yt=!1;function kt(Vt){g("ondata");var Qt=b.write(Vt);g("dest.write",Qt),Qt===!1&&((H.pipesCount===1&&H.pipes===b||H.pipesCount>1&&ut(H.pipes,b)!==-1)&&!yt&&(g("false write response, pause",H.awaitDrain),H.awaitDrain++),P.pause())}function Tt(Vt){g("onerror",Vt),xe(),b.removeListener("error",Tt),c(b,"error")===0&&q(b,Vt)}function be(){b.removeListener("finish",ne),xe()}function ne(){g("onfinish"),b.removeListener("close",be),xe()}function xe(){g("unpipe"),P.unpipe(b)}return P.on("data",kt),function(Vt,Qt,xi){if(typeof Vt.prependListener=="function")return Vt.prependListener(Qt,xi);Vt._events&&Vt._events[Qt]?Array.isArray(Vt._events[Qt])?Vt._events[Qt].unshift(xi):Vt._events[Qt]=[xi,Vt._events[Qt]]:Vt.on(Qt,xi)}(b,"error",Tt),b.once("close",be),b.once("finish",ne),b.emit("pipe",P),H.flowing||(g("pipe resume"),P.resume()),b},T.prototype.unpipe=function(b){var k=this._readableState,P={hasUnpiped:!1};if(k.pipesCount===0)return this;if(k.pipesCount===1)return b&&b!==k.pipes?this:(b||(b=k.pipes),k.pipes=null,k.pipesCount=0,k.flowing=!1,b&&b.emit("unpipe",this,P),this);if(!b){var H=k.pipes,X=k.pipesCount;k.pipes=null,k.pipesCount=0,k.flowing=!1;for(var J=0;J<X;J++)H[J].emit("unpipe",this,{hasUnpiped:!1});return this}var at=ut(k.pipes,b);return at===-1?this:(k.pipes.splice(at,1),k.pipesCount-=1,k.pipesCount===1&&(k.pipes=k.pipes[0]),b.emit("unpipe",this,P),this)},T.prototype.on=function(b,k){var P=u.prototype.on.call(this,b,k),H=this._readableState;return b==="data"?(H.readableListening=this.listenerCount("readable")>0,H.flowing!==!1&&this.resume()):b==="readable"&&(H.endEmitted||H.readableListening||(H.readableListening=H.needReadable=!0,H.flowing=!1,H.emittedReadable=!1,g("on readable",H.length,H.reading),H.length?st(this):H.reading||s.nextTick(U,this))),P},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(b,k){var P=u.prototype.removeListener.call(this,b,k);return b==="readable"&&s.nextTick(Y,this),P},T.prototype.removeAllListeners=function(b){var k=u.prototype.removeAllListeners.apply(this,arguments);return b!=="readable"&&b!==void 0||s.nextTick(Y,this),k},T.prototype.resume=function(){var b=this._readableState;return b.flowing||(g("resume"),b.flowing=!b.readableListening,function(k,P){P.resumeScheduled||(P.resumeScheduled=!0,s.nextTick(tt,k,P))}(this,b)),b.paused=!1,this},T.prototype.pause=function(){return g("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(g("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(b){var k=this,P=this._readableState,H=!1;for(var X in b.on("end",function(){if(g("wrapped end"),P.decoder&&!P.ended){var at=P.decoder.end();at&&at.length&&k.push(at)}k.push(null)}),b.on("data",function(at){g("wrapped data"),P.decoder&&(at=P.decoder.write(at)),(!P.objectMode||at!=null)&&(P.objectMode||at&&at.length)&&(k.push(at)||(H=!0,b.pause()))}),b)this[X]===void 0&&typeof b[X]=="function"&&(this[X]=function(at){return function(){return b[at].apply(b,arguments)}}(X));for(var J=0;J<Q.length;J++)b.on(Q[J],this.emit.bind(this,Q[J]));return this._read=function(at){g("wrapped _read",at),H&&(H=!1,b.resume())},this},typeof Symbol=="function"&&(T.prototype[Symbol.asyncIterator]=function(){return w===void 0&&(w=i("./internal/streams/async_iterator")),w(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(b){this._readableState&&(this._readableState.flowing=b)}}),T._fromList=nt,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(T.from=function(b,k){return p===void 0&&(p=i("./internal/streams/from")),p(T,b,k)})}).call(this)}).call(this,i("_process"),typeof Le<"u"?Le:typeof self<"u"?self:typeof window<"u"?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/async_iterator":61,"./internal/streams/buffer_list":62,"./internal/streams/destroy":63,"./internal/streams/from":65,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,events:22,inherits:24,"string_decoder/":75,util:16}],59:[function(i,n,r){n.exports=d;var s=i("../errors").codes,a=s.ERR_METHOD_NOT_IMPLEMENTED,l=s.ERR_MULTIPLE_CALLBACK,c=s.ERR_TRANSFORM_ALREADY_TRANSFORMING,u=s.ERR_TRANSFORM_WITH_LENGTH_0,h=i("./_stream_duplex");function d(y){if(!(this instanceof d))return new d(y);h.call(this,y),this._transformState={afterTransform:function(w,p){var _=this._transformState;_.transforming=!1;var A=_.writecb;if(A===null)return this.emit("error",new l);_.writechunk=null,_.writecb=null,p!=null&&this.push(p),A(w);var x=this._readableState;x.reading=!1,(x.needReadable||x.length<x.highWaterMark)&&this._read(x.highWaterMark)}.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,y&&(typeof y.transform=="function"&&(this._transform=y.transform),typeof y.flush=="function"&&(this._flush=y.flush)),this.on("prefinish",g)}function g(){var y=this;typeof this._flush!="function"||this._readableState.destroyed?v(this,null,null):this._flush(function(w,p){v(y,w,p)})}function v(y,w,p){if(w)return y.emit("error",w);if(p!=null&&y.push(p),y._writableState.length)throw new u;if(y._transformState.transforming)throw new c;return y.push(null)}i("inherits")(d,h),d.prototype.push=function(y,w){return this._transformState.needTransform=!1,h.prototype.push.call(this,y,w)},d.prototype._transform=function(y,w,p){p(new a("_transform()"))},d.prototype._write=function(y,w,p){var _=this._transformState;if(_.writecb=p,_.writechunk=y,_.writeencoding=w,!_.transforming){var A=this._readableState;(_.needTransform||A.needReadable||A.length<A.highWaterMark)&&this._read(A.highWaterMark)}},d.prototype._read=function(y){var w=this._transformState;w.writechunk===null||w.transforming?w.needTransform=!0:(w.transforming=!0,this._transform(w.writechunk,w.writeencoding,w.afterTransform))},d.prototype._destroy=function(y,w){h.prototype._destroy.call(this,y,function(p){w(p)})}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(i,n,r){(function(s,a){(function(){function l(z){var V=this;this.next=null,this.entry=null,this.finish=function(){(function(Y,U,tt){var rt=Y.entry;for(Y.entry=null;rt;){var nt=rt.callback;U.pendingcb--,nt(tt),rt=rt.next}U.corkedRequestsFree.next=Y})(V,z)}}var c;n.exports=T,T.WritableState=C;var u={deprecate:i("util-deprecate")},h=i("./internal/streams/stream"),d=i("buffer").Buffer,g=a.Uint8Array||function(){},v,y=i("./internal/streams/destroy"),w=i("./internal/streams/state").getHighWaterMark,p=i("../errors").codes,_=p.ERR_INVALID_ARG_TYPE,A=p.ERR_METHOD_NOT_IMPLEMENTED,x=p.ERR_MULTIPLE_CALLBACK,E=p.ERR_STREAM_CANNOT_PIPE,I=p.ERR_STREAM_DESTROYED,M=p.ERR_STREAM_NULL_VALUES,B=p.ERR_STREAM_WRITE_AFTER_END,D=p.ERR_UNKNOWN_ENCODING,q=y.errorOrDestroy;function Q(){}function C(z,V,Y){c=c||i("./_stream_duplex"),z=z||{},typeof Y!="boolean"&&(Y=V instanceof c),this.objectMode=!!z.objectMode,Y&&(this.objectMode=this.objectMode||!!z.writableObjectMode),this.highWaterMark=w(this,z,"writableHighWaterMark",Y),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var U=z.decodeStrings===!1;this.decodeStrings=!U,this.defaultEncoding=z.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(tt){(function(rt,nt){var ft=rt._writableState,lt=ft.sync,ut=ft.writecb;if(typeof ut!="function")throw new x;if(function(k){k.writing=!1,k.writecb=null,k.length-=k.writelen,k.writelen=0}(ft),nt)(function(k,P,H,X,J){--P.pendingcb,H?(s.nextTick(J,X),s.nextTick($,k,P),k._writableState.errorEmitted=!0,q(k,X)):(J(X),k._writableState.errorEmitted=!0,q(k,X),$(k,P))})(rt,ft,lt,nt,ut);else{var b=Z(ft)||rt.destroyed;b||ft.corked||ft.bufferProcessing||!ft.bufferedRequest||K(rt,ft),lt?s.nextTick(O,rt,ft,b,ut):O(rt,ft,b,ut)}})(V,tt)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=z.emitClose!==!1,this.autoDestroy=!!z.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new l(this)}function T(z){var V=this instanceof(c=c||i("./_stream_duplex"));if(!V&&!v.call(T,this))return new T(z);this._writableState=new C(z,this,V),this.writable=!0,z&&(typeof z.write=="function"&&(this._write=z.write),typeof z.writev=="function"&&(this._writev=z.writev),typeof z.destroy=="function"&&(this._destroy=z.destroy),typeof z.final=="function"&&(this._final=z.final)),h.call(this)}function S(z,V,Y,U,tt,rt,nt){V.writelen=U,V.writecb=nt,V.writing=!0,V.sync=!0,V.destroyed?V.onwrite(new I("write")):Y?z._writev(tt,V.onwrite):z._write(tt,rt,V.onwrite),V.sync=!1}function O(z,V,Y,U){Y||function(tt,rt){rt.length===0&&rt.needDrain&&(rt.needDrain=!1,tt.emit("drain"))}(z,V),V.pendingcb--,U(),$(z,V)}function K(z,V){V.bufferProcessing=!0;var Y=V.bufferedRequest;if(z._writev&&Y&&Y.next){var U=V.bufferedRequestCount,tt=new Array(U),rt=V.corkedRequestsFree;rt.entry=Y;for(var nt=0,ft=!0;Y;)tt[nt]=Y,Y.isBuf||(ft=!1),Y=Y.next,nt+=1;tt.allBuffers=ft,S(z,V,!0,V.length,tt,"",rt.finish),V.pendingcb++,V.lastBufferedRequest=null,rt.next?(V.corkedRequestsFree=rt.next,rt.next=null):V.corkedRequestsFree=new l(V),V.bufferedRequestCount=0}else{for(;Y;){var lt=Y.chunk,ut=Y.encoding,b=Y.callback;if(S(z,V,!1,V.objectMode?1:lt.length,lt,ut,b),Y=Y.next,V.bufferedRequestCount--,V.writing)break}Y===null&&(V.lastBufferedRequest=null)}V.bufferedRequest=Y,V.bufferProcessing=!1}function Z(z){return z.ending&&z.length===0&&z.bufferedRequest===null&&!z.finished&&!z.writing}function st(z,V){z._final(function(Y){V.pendingcb--,Y&&q(z,Y),V.prefinished=!0,z.emit("prefinish"),$(z,V)})}function $(z,V){var Y=Z(V);if(Y&&(function(tt,rt){rt.prefinished||rt.finalCalled||(typeof tt._final!="function"||rt.destroyed?(rt.prefinished=!0,tt.emit("prefinish")):(rt.pendingcb++,rt.finalCalled=!0,s.nextTick(st,tt,rt)))}(z,V),V.pendingcb===0&&(V.finished=!0,z.emit("finish"),V.autoDestroy))){var U=z._readableState;(!U||U.autoDestroy&&U.endEmitted)&&z.destroy()}return Y}i("inherits")(T,h),C.prototype.getBuffer=function(){for(var z=this.bufferedRequest,V=[];z;)V.push(z),z=z.next;return V},function(){try{Object.defineProperty(C.prototype,"buffer",{get:u.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(v=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(z){return!!v.call(this,z)||this===T&&z&&z._writableState instanceof C}})):v=function(z){return z instanceof this},T.prototype.pipe=function(){q(this,new E)},T.prototype.write=function(z,V,Y){var U,tt=this._writableState,rt=!1,nt=!tt.objectMode&&(U=z,d.isBuffer(U)||U instanceof g);return nt&&!d.isBuffer(z)&&(z=function(ft){return d.from(ft)}(z)),typeof V=="function"&&(Y=V,V=null),nt?V="buffer":V||(V=tt.defaultEncoding),typeof Y!="function"&&(Y=Q),tt.ending?function(ft,lt){var ut=new B;q(ft,ut),s.nextTick(lt,ut)}(this,Y):(nt||function(ft,lt,ut,b){var k;return ut===null?k=new M:typeof ut=="string"||lt.objectMode||(k=new _("chunk",["string","Buffer"],ut)),!k||(q(ft,k),s.nextTick(b,k),!1)}(this,tt,z,Y))&&(tt.pendingcb++,rt=function(ft,lt,ut,b,k,P){if(!ut){var H=function(mt,yt,kt){return mt.objectMode||mt.decodeStrings===!1||typeof yt!="string"||(yt=d.from(yt,kt)),yt}(lt,b,k);b!==H&&(ut=!0,k="buffer",b=H)}var X=lt.objectMode?1:b.length;lt.length+=X;var J=lt.length<lt.highWaterMark;if(J||(lt.needDrain=!0),lt.writing||lt.corked){var at=lt.lastBufferedRequest;lt.lastBufferedRequest={chunk:b,encoding:k,isBuf:ut,callback:P,next:null},at?at.next=lt.lastBufferedRequest:lt.bufferedRequest=lt.lastBufferedRequest,lt.bufferedRequestCount+=1}else S(ft,lt,!1,X,b,k,P);return J}(this,tt,nt,z,V,Y)),rt},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var z=this._writableState;z.corked&&(z.corked--,z.writing||z.corked||z.bufferProcessing||!z.bufferedRequest||K(this,z))},T.prototype.setDefaultEncoding=function(z){if(typeof z=="string"&&(z=z.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((z+"").toLowerCase())>-1))throw new D(z);return this._writableState.defaultEncoding=z,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(z,V,Y){Y(new A("_write()"))},T.prototype._writev=null,T.prototype.end=function(z,V,Y){var U=this._writableState;return typeof z=="function"?(Y=z,z=null,V=null):typeof V=="function"&&(Y=V,V=null),z!=null&&this.write(z,V),U.corked&&(U.corked=1,this.uncork()),U.ending||function(tt,rt,nt){rt.ending=!0,$(tt,rt),nt&&(rt.finished?s.nextTick(nt):tt.once("finish",nt)),rt.ended=!0,tt.writable=!1}(this,U,Y),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(z){this._writableState&&(this._writableState.destroyed=z)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(z,V){V(z)}}).call(this)}).call(this,i("_process"),typeof Le<"u"?Le:typeof self<"u"?self:typeof window<"u"?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/destroy":63,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,inherits:24,"util-deprecate":78}],61:[function(i,n,r){(function(s){(function(){var a;function l(E,I,M){return I in E?Object.defineProperty(E,I,{value:M,enumerable:!0,configurable:!0,writable:!0}):E[I]=M,E}var c=i("./end-of-stream"),u=Symbol("lastResolve"),h=Symbol("lastReject"),d=Symbol("error"),g=Symbol("ended"),v=Symbol("lastPromise"),y=Symbol("handlePromise"),w=Symbol("stream");function p(E,I){return{value:E,done:I}}function _(E){var I=E[u];if(I!==null){var M=E[w].read();M!==null&&(E[v]=null,E[u]=null,E[h]=null,I(p(M,!1)))}}var A=Object.getPrototypeOf(function(){}),x=Object.setPrototypeOf((l(a={get stream(){return this[w]},next:function(){var E=this,I=this[d];if(I!==null)return Promise.reject(I);if(this[g])return Promise.resolve(p(void 0,!0));if(this[w].destroyed)return new Promise(function(q,Q){s.nextTick(function(){E[d]?Q(E[d]):q(p(void 0,!0))})});var M,B=this[v];if(B)M=new Promise(function(q,Q){return function(C,T){q.then(function(){Q[g]?C(p(void 0,!0)):Q[y](C,T)},T)}}(B,this));else{var D=this[w].read();if(D!==null)return Promise.resolve(p(D,!1));M=new Promise(this[y])}return this[v]=M,M}},Symbol.asyncIterator,function(){return this}),l(a,"return",function(){var E=this;return new Promise(function(I,M){E[w].destroy(null,function(B){B?M(B):I(p(void 0,!0))})})}),a),A);n.exports=function(E){var I,M=Object.create(x,(l(I={},w,{value:E,writable:!0}),l(I,u,{value:null,writable:!0}),l(I,h,{value:null,writable:!0}),l(I,d,{value:null,writable:!0}),l(I,g,{value:E._readableState.endEmitted,writable:!0}),l(I,y,{value:function(B,D){var q=M[w].read();q?(M[v]=null,M[u]=null,M[h]=null,B(p(q,!1))):(M[u]=B,M[h]=D)},writable:!0}),I));return M[v]=null,c(E,function(B){if(B&&B.code!=="ERR_STREAM_PREMATURE_CLOSE"){var D=M[h];return D!==null&&(M[v]=null,M[u]=null,M[h]=null,D(B)),void(M[d]=B)}var q=M[u];q!==null&&(M[v]=null,M[u]=null,M[h]=null,q(p(void 0,!0))),M[g]=!0}),E.on("readable",function(B){s.nextTick(_,B)}.bind(null,M)),M}}).call(this)}).call(this,i("_process"))},{"./end-of-stream":64,_process:50}],62:[function(i,n,r){function s(d,g){var v=Object.keys(d);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(d);g&&(y=y.filter(function(w){return Object.getOwnPropertyDescriptor(d,w).enumerable})),v.push.apply(v,y)}return v}function a(d,g,v){return g in d?Object.defineProperty(d,g,{value:v,enumerable:!0,configurable:!0,writable:!0}):d[g]=v,d}function l(d,g){for(var v=0;v<g.length;v++){var y=g[v];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(d,y.key,y)}}var c=i("buffer").Buffer,u=i("util").inspect,h=u&&u.custom||"inspect";n.exports=function(){function d(){(function(y,w){if(!(y instanceof w))throw new TypeError("Cannot call a class as a function")})(this,d),this.head=null,this.tail=null,this.length=0}var g,v;return g=d,(v=[{key:"push",value:function(y){var w={data:y,next:null};this.length>0?this.tail.next=w:this.head=w,this.tail=w,++this.length}},{key:"unshift",value:function(y){var w={data:y,next:this.head};this.length===0&&(this.tail=w),this.head=w,++this.length}},{key:"shift",value:function(){if(this.length!==0){var y=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,y}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(y){if(this.length===0)return"";for(var w=this.head,p=""+w.data;w=w.next;)p+=y+w.data;return p}},{key:"concat",value:function(y){if(this.length===0)return c.alloc(0);for(var w,p,_,A=c.allocUnsafe(y>>>0),x=this.head,E=0;x;)w=x.data,p=A,_=E,c.prototype.copy.call(w,p,_),E+=x.data.length,x=x.next;return A}},{key:"consume",value:function(y,w){var p;return y<this.head.data.length?(p=this.head.data.slice(0,y),this.head.data=this.head.data.slice(y)):p=y===this.head.data.length?this.shift():w?this._getString(y):this._getBuffer(y),p}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(y){var w=this.head,p=1,_=w.data;for(y-=_.length;w=w.next;){var A=w.data,x=y>A.length?A.length:y;if(x===A.length?_+=A:_+=A.slice(0,y),(y-=x)===0){x===A.length?(++p,w.next?this.head=w.next:this.head=this.tail=null):(this.head=w,w.data=A.slice(x));break}++p}return this.length-=p,_}},{key:"_getBuffer",value:function(y){var w=c.allocUnsafe(y),p=this.head,_=1;for(p.data.copy(w),y-=p.data.length;p=p.next;){var A=p.data,x=y>A.length?A.length:y;if(A.copy(w,w.length-y,0,x),(y-=x)===0){x===A.length?(++_,p.next?this.head=p.next:this.head=this.tail=null):(this.head=p,p.data=A.slice(x));break}++_}return this.length-=_,w}},{key:h,value:function(y,w){return u(this,function(p){for(var _=1;_<arguments.length;_++){var A=arguments[_]!=null?arguments[_]:{};_%2?s(Object(A),!0).forEach(function(x){a(p,x,A[x])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(A)):s(Object(A)).forEach(function(x){Object.defineProperty(p,x,Object.getOwnPropertyDescriptor(A,x))})}return p}({},w,{depth:0,customInspect:!1}))}}])&&l(g.prototype,v),d}()},{buffer:17,util:16}],63:[function(i,n,r){(function(s){(function(){function a(u,h){c(u,h),l(u)}function l(u){u._writableState&&!u._writableState.emitClose||u._readableState&&!u._readableState.emitClose||u.emit("close")}function c(u,h){u.emit("error",h)}n.exports={destroy:function(u,h){var d=this,g=this._readableState&&this._readableState.destroyed,v=this._writableState&&this._writableState.destroyed;return g||v?(h?h(u):u&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,s.nextTick(c,this,u)):s.nextTick(c,this,u)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(u||null,function(y){!h&&y?d._writableState?d._writableState.errorEmitted?s.nextTick(l,d):(d._writableState.errorEmitted=!0,s.nextTick(a,d,y)):s.nextTick(a,d,y):h?(s.nextTick(l,d),h(y)):s.nextTick(l,d)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(u,h){var d=u._readableState,g=u._writableState;d&&d.autoDestroy||g&&g.autoDestroy?u.destroy(h):u.emit("error",h)}}}).call(this)}).call(this,i("_process"))},{_process:50}],64:[function(i,n,r){var s=i("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function a(){}n.exports=function l(c,u,h){if(typeof u=="function")return l(c,null,u);u||(u={}),h=function(I){var M=!1;return function(){if(!M){M=!0;for(var B=arguments.length,D=new Array(B),q=0;q<B;q++)D[q]=arguments[q];I.apply(this,D)}}}(h||a);var d=u.readable||u.readable!==!1&&c.readable,g=u.writable||u.writable!==!1&&c.writable,v=function(){c.writable||w()},y=c._writableState&&c._writableState.finished,w=function(){g=!1,y=!0,d||h.call(c)},p=c._readableState&&c._readableState.endEmitted,_=function(){d=!1,p=!0,g||h.call(c)},A=function(I){h.call(c,I)},x=function(){var I;return d&&!p?(c._readableState&&c._readableState.ended||(I=new s),h.call(c,I)):g&&!y?(c._writableState&&c._writableState.ended||(I=new s),h.call(c,I)):void 0},E=function(){c.req.on("finish",w)};return function(I){return I.setHeader&&typeof I.abort=="function"}(c)?(c.on("complete",w),c.on("abort",x),c.req?E():c.on("request",E)):g&&!c._writableState&&(c.on("end",v),c.on("close",v)),c.on("end",_),c.on("finish",w),u.error!==!1&&c.on("error",A),c.on("close",x),function(){c.removeListener("complete",w),c.removeListener("abort",x),c.removeListener("request",E),c.req&&c.req.removeListener("finish",w),c.removeListener("end",v),c.removeListener("close",v),c.removeListener("finish",w),c.removeListener("end",_),c.removeListener("error",A),c.removeListener("close",x)}}},{"../../../errors":55}],65:[function(i,n,r){n.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],66:[function(i,n,r){var s,a=i("../../../errors").codes,l=a.ERR_MISSING_ARGS,c=a.ERR_STREAM_DESTROYED;function u(g){if(g)throw g}function h(g){g()}function d(g,v){return g.pipe(v)}n.exports=function(){for(var g=arguments.length,v=new Array(g),y=0;y<g;y++)v[y]=arguments[y];var w,p=function(A){return A.length?typeof A[A.length-1]!="function"?u:A.pop():u}(v);if(Array.isArray(v[0])&&(v=v[0]),v.length<2)throw new l("streams");var _=v.map(function(A,x){var E=x<v.length-1;return function(I,M,B,D){D=function(C){var T=!1;return function(){T||(T=!0,C.apply(void 0,arguments))}}(D);var q=!1;I.on("close",function(){q=!0}),s===void 0&&(s=i("./end-of-stream")),s(I,{readable:M,writable:B},function(C){if(C)return D(C);q=!0,D()});var Q=!1;return function(C){if(!q&&!Q)return Q=!0,function(T){return T.setHeader&&typeof T.abort=="function"}(I)?I.abort():typeof I.destroy=="function"?I.destroy():void D(C||new c("pipe"))}}(A,E,x>0,function(I){w||(w=I),I&&_.forEach(h),E||(_.forEach(h),p(w))})});return v.reduce(d)}},{"../../../errors":55,"./end-of-stream":64}],67:[function(i,n,r){var s=i("../../../errors").codes.ERR_INVALID_OPT_VALUE;n.exports={getHighWaterMark:function(a,l,c,u){var h=function(d,g,v){return d.highWaterMark!=null?d.highWaterMark:g?d[v]:null}(l,u,c);if(h!=null){if(!isFinite(h)||Math.floor(h)!==h||h<0)throw new s(u?c:"highWaterMark",h);return Math.floor(h)}return a.objectMode?16:16384}}},{"../../../errors":55}],68:[function(i,n,r){n.exports=i("events").EventEmitter},{events:22}],69:[function(i,n,r){(r=n.exports=i("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=i("./lib/_stream_writable.js"),r.Duplex=i("./lib/_stream_duplex.js"),r.Transform=i("./lib/_stream_transform.js"),r.PassThrough=i("./lib/_stream_passthrough.js"),r.finished=i("./lib/internal/streams/end-of-stream.js"),r.pipeline=i("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":56,"./lib/_stream_passthrough.js":57,"./lib/_stream_readable.js":58,"./lib/_stream_transform.js":59,"./lib/_stream_writable.js":60,"./lib/internal/streams/end-of-stream.js":64,"./lib/internal/streams/pipeline.js":66}],70:[function(i,n,r){n.exports=function(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var s;if(arguments.length>0){s=new Array(arguments.length-2);for(var a=0;a<s.length;a++)s[a]=arguments[a+2]}return new function(l,c,u){var h=this;this._callback=l,this._args=u,this._interval=setInterval(l,c,this._args),this.reschedule=function(d){d||(d=h._interval),h._interval&&clearInterval(h._interval),h._interval=setInterval(h._callback,d,h._args)},this.clear=function(){h._interval&&(clearInterval(h._interval),h._interval=void 0)},this.destroy=function(){h._interval&&clearInterval(h._interval),h._callback=void 0,h._interval=void 0,h._args=void 0}}(arguments[0],arguments[1],s)}},{}],71:[function(i,n,r){n.exports=i("./index.js")()},{"./index.js":72}],72:[function(i,n,r){(function(s){(function(){function a(l){return l instanceof s?s.from(l):new l.constructor(l.buffer.slice(),l.byteOffset,l.length)}n.exports=function(l){return(l=l||{}).circles?function(u){var h=[],d=[];return u.proto?function v(y){if(typeof y!="object"||y===null)return y;if(y instanceof Date)return new Date(y);if(Array.isArray(y))return g(y,v);if(y instanceof Map)return new Map(g(Array.from(y),v));if(y instanceof Set)return new Set(g(Array.from(y),v));var w={};for(var p in h.push(y),d.push(w),y){var _=y[p];if(typeof _!="object"||_===null)w[p]=_;else if(_ instanceof Date)w[p]=new Date(_);else if(_ instanceof Map)w[p]=new Map(g(Array.from(_),v));else if(_ instanceof Set)w[p]=new Set(g(Array.from(_),v));else if(ArrayBuffer.isView(_))w[p]=a(_);else{var A=h.indexOf(_);w[p]=A!==-1?d[A]:v(_)}}return h.pop(),d.pop(),w}:function v(y){if(typeof y!="object"||y===null)return y;if(y instanceof Date)return new Date(y);if(Array.isArray(y))return g(y,v);if(y instanceof Map)return new Map(g(Array.from(y),v));if(y instanceof Set)return new Set(g(Array.from(y),v));var w={};for(var p in h.push(y),d.push(w),y)if(Object.hasOwnProperty.call(y,p)!==!1){var _=y[p];if(typeof _!="object"||_===null)w[p]=_;else if(_ instanceof Date)w[p]=new Date(_);else if(_ instanceof Map)w[p]=new Map(g(Array.from(_),v));else if(_ instanceof Set)w[p]=new Set(g(Array.from(_),v));else if(ArrayBuffer.isView(_))w[p]=a(_);else{var A=h.indexOf(_);w[p]=A!==-1?d[A]:v(_)}}return h.pop(),d.pop(),w};function g(v,y){for(var w=Object.keys(v),p=new Array(w.length),_=0;_<w.length;_++){var A=w[_],x=v[A];if(typeof x!="object"||x===null)p[A]=x;else if(x instanceof Date)p[A]=new Date(x);else if(ArrayBuffer.isView(x))p[A]=a(x);else{var E=h.indexOf(x);p[A]=E!==-1?d[E]:y(x)}}return p}}(l):l.proto?function u(h){if(typeof h!="object"||h===null)return h;if(h instanceof Date)return new Date(h);if(Array.isArray(h))return c(h,u);if(h instanceof Map)return new Map(c(Array.from(h),u));if(h instanceof Set)return new Set(c(Array.from(h),u));var d={};for(var g in h){var v=h[g];typeof v!="object"||v===null?d[g]=v:v instanceof Date?d[g]=new Date(v):v instanceof Map?d[g]=new Map(c(Array.from(v),u)):v instanceof Set?d[g]=new Set(c(Array.from(v),u)):ArrayBuffer.isView(v)?d[g]=a(v):d[g]=u(v)}return d}:function u(h){if(typeof h!="object"||h===null)return h;if(h instanceof Date)return new Date(h);if(Array.isArray(h))return c(h,u);if(h instanceof Map)return new Map(c(Array.from(h),u));if(h instanceof Set)return new Set(c(Array.from(h),u));var d={};for(var g in h)if(Object.hasOwnProperty.call(h,g)!==!1){var v=h[g];typeof v!="object"||v===null?d[g]=v:v instanceof Date?d[g]=new Date(v):v instanceof Map?d[g]=new Map(c(Array.from(v),u)):v instanceof Set?d[g]=new Set(c(Array.from(v),u)):ArrayBuffer.isView(v)?d[g]=a(v):d[g]=u(v)}return d};function c(u,h){for(var d=Object.keys(u),g=new Array(d.length),v=0;v<d.length;v++){var y=d[v],w=u[y];typeof w!="object"||w===null?g[y]=w:w instanceof Date?g[y]=new Date(w):ArrayBuffer.isView(w)?g[y]=a(w):g[y]=h(w)}return g}}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],73:[function(i,n,r){var s=i("buffer"),a=s.Buffer;function l(u,h){for(var d in u)h[d]=u[d]}function c(u,h,d){return a(u,h,d)}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?n.exports=s:(l(s,r),r.Buffer=c),c.prototype=Object.create(a.prototype),l(a,c),c.from=function(u,h,d){if(typeof u=="number")throw new TypeError("Argument must not be a number");return a(u,h,d)},c.alloc=function(u,h,d){if(typeof u!="number")throw new TypeError("Argument must be a number");var g=a(u);return h!==void 0?typeof d=="string"?g.fill(h,d):g.fill(h):g.fill(0),g},c.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return a(u)},c.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(u)}},{buffer:17}],74:[function(i,n,r){n.exports=function(s){var a=s._readableState;return a?a.objectMode||typeof s._duplexState=="number"?s.read():s.read((l=a,l.buffer.length?l.buffer.head?l.buffer.head.data.length:l.buffer[0].length:l.length)):null;var l}},{}],75:[function(i,n,r){var s=i("safe-buffer").Buffer,a=s.isEncoding||function(p){switch((p=""+p)&&p.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function l(p){var _;switch(this.encoding=function(A){var x=function(E){if(!E)return"utf8";for(var I;;)switch(E){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return E;default:if(I)return;E=(""+E).toLowerCase(),I=!0}}(A);if(typeof x!="string"&&(s.isEncoding===a||!a(A)))throw new Error("Unknown encoding: "+A);return x||A}(p),this.encoding){case"utf16le":this.text=h,this.end=d,_=4;break;case"utf8":this.fillLast=u,_=4;break;case"base64":this.text=g,this.end=v,_=3;break;default:return this.write=y,void(this.end=w)}this.lastNeed=0,this.lastTotal=0,this.lastChar=s.allocUnsafe(_)}function c(p){return p<=127?0:p>>5==6?2:p>>4==14?3:p>>3==30?4:p>>6==2?-1:-2}function u(p){var _=this.lastTotal-this.lastNeed,A=function(x,E,I){if((192&E[0])!=128)return x.lastNeed=0,"\uFFFD";if(x.lastNeed>1&&E.length>1){if((192&E[1])!=128)return x.lastNeed=1,"\uFFFD";if(x.lastNeed>2&&E.length>2&&(192&E[2])!=128)return x.lastNeed=2,"\uFFFD"}}(this,p);return A!==void 0?A:this.lastNeed<=p.length?(p.copy(this.lastChar,_,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(p.copy(this.lastChar,_,0,p.length),void(this.lastNeed-=p.length))}function h(p,_){if((p.length-_)%2==0){var A=p.toString("utf16le",_);if(A){var x=A.charCodeAt(A.length-1);if(x>=55296&&x<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=p[p.length-2],this.lastChar[1]=p[p.length-1],A.slice(0,-1)}return A}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=p[p.length-1],p.toString("utf16le",_,p.length-1)}function d(p){var _=p&&p.length?this.write(p):"";if(this.lastNeed){var A=this.lastTotal-this.lastNeed;return _+this.lastChar.toString("utf16le",0,A)}return _}function g(p,_){var A=(p.length-_)%3;return A===0?p.toString("base64",_):(this.lastNeed=3-A,this.lastTotal=3,A===1?this.lastChar[0]=p[p.length-1]:(this.lastChar[0]=p[p.length-2],this.lastChar[1]=p[p.length-1]),p.toString("base64",_,p.length-A))}function v(p){var _=p&&p.length?this.write(p):"";return this.lastNeed?_+this.lastChar.toString("base64",0,3-this.lastNeed):_}function y(p){return p.toString(this.encoding)}function w(p){return p&&p.length?this.write(p):""}r.StringDecoder=l,l.prototype.write=function(p){if(p.length===0)return"";var _,A;if(this.lastNeed){if((_=this.fillLast(p))===void 0)return"";A=this.lastNeed,this.lastNeed=0}else A=0;return A<p.length?_?_+this.text(p,A):this.text(p,A):_||""},l.prototype.end=function(p){var _=p&&p.length?this.write(p):"";return this.lastNeed?_+"\uFFFD":_},l.prototype.text=function(p,_){var A=function(E,I,M){var B=I.length-1;if(B<M)return 0;var D=c(I[B]);return D>=0?(D>0&&(E.lastNeed=D-1),D):--B<M||D===-2?0:(D=c(I[B]))>=0?(D>0&&(E.lastNeed=D-2),D):--B<M||D===-2?0:(D=c(I[B]))>=0?(D>0&&(D===2?D=0:E.lastNeed=D-3),D):0}(this,p,_);if(!this.lastNeed)return p.toString("utf8",_);this.lastTotal=A;var x=p.length-(A-this.lastNeed);return p.copy(this.lastChar,0,x),p.toString("utf8",_,x)},l.prototype.fillLast=function(p){if(this.lastNeed<=p.length)return p.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);p.copy(this.lastChar,this.lastTotal-this.lastNeed,0,p.length),this.lastNeed-=p.length}},{"safe-buffer":73}],76:[function(i,n,r){var s=i("punycode"),a=i("./util");function l(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=I,r.resolve=function(M,B){return I(M,!1,!0).resolve(B)},r.resolveObject=function(M,B){return M?I(M,!1,!0).resolveObject(B):B},r.format=function(M){return a.isString(M)&&(M=I(M)),M instanceof l?M.format():l.prototype.format.call(M)},r.Url=l;var c=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,h=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,d=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",`
  57. `," "]),g=["'"].concat(d),v=["%","/","?",";","#"].concat(g),y=["/","?","#"],w=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_={javascript:!0,"javascript:":!0},A={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},E=i("querystring");function I(M,B,D){if(M&&a.isObject(M)&&M instanceof l)return M;var q=new l;return q.parse(M,B,D),q}l.prototype.parse=function(M,B,D){if(!a.isString(M))throw new TypeError("Parameter 'url' must be a string, not "+typeof M);var q=M.indexOf("?"),Q=q!==-1&&q<M.indexOf("#")?"?":"#",C=M.split(Q);C[0]=C[0].replace(/\\/g,"/");var T=M=C.join(Q);if(T=T.trim(),!D&&M.split("#").length===1){var S=h.exec(T);if(S)return this.path=T,this.href=T,this.pathname=S[1],S[2]?(this.search=S[2],this.query=B?E.parse(this.search.substr(1)):this.search.substr(1)):B&&(this.search="",this.query={}),this}var O=c.exec(T);if(O){var K=(O=O[0]).toLowerCase();this.protocol=K,T=T.substr(O.length)}if(D||O||T.match(/^\/\/[^@\/]+@[^@\/]+/)){var Z=T.substr(0,2)==="//";!Z||O&&A[O]||(T=T.substr(2),this.slashes=!0)}if(!A[O]&&(Z||O&&!x[O])){for(var st,$,z=-1,V=0;V<y.length;V++)(Y=T.indexOf(y[V]))!==-1&&(z===-1||Y<z)&&(z=Y);for(($=z===-1?T.lastIndexOf("@"):T.lastIndexOf("@",z))!==-1&&(st=T.slice(0,$),T=T.slice($+1),this.auth=decodeURIComponent(st)),z=-1,V=0;V<v.length;V++){var Y;(Y=T.indexOf(v[V]))!==-1&&(z===-1||Y<z)&&(z=Y)}z===-1&&(z=T.length),this.host=T.slice(0,z),T=T.slice(z),this.parseHost(),this.hostname=this.hostname||"";var U=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!U)for(var tt=this.hostname.split(/\./),rt=(V=0,tt.length);V<rt;V++){var nt=tt[V];if(nt&&!nt.match(w)){for(var ft="",lt=0,ut=nt.length;lt<ut;lt++)nt.charCodeAt(lt)>127?ft+="x":ft+=nt[lt];if(!ft.match(w)){var b=tt.slice(0,V),k=tt.slice(V+1),P=nt.match(p);P&&(b.push(P[1]),k.unshift(P[2])),k.length&&(T="/"+k.join(".")+T),this.hostname=b.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),U||(this.hostname=s.toASCII(this.hostname));var H=this.port?":"+this.port:"",X=this.hostname||"";this.host=X+H,this.href+=this.host,U&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),T[0]!=="/"&&(T="/"+T))}if(!_[K])for(V=0,rt=g.length;V<rt;V++){var J=g[V];if(T.indexOf(J)!==-1){var at=encodeURIComponent(J);at===J&&(at=escape(J)),T=T.split(J).join(at)}}var mt=T.indexOf("#");mt!==-1&&(this.hash=T.substr(mt),T=T.slice(0,mt));var yt=T.indexOf("?");if(yt!==-1?(this.search=T.substr(yt),this.query=T.substr(yt+1),B&&(this.query=E.parse(this.query)),T=T.slice(0,yt)):B&&(this.search="",this.query={}),T&&(this.pathname=T),x[K]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){H=this.pathname||"";var kt=this.search||"";this.path=H+kt}return this.href=this.format(),this},l.prototype.format=function(){var M=this.auth||"";M&&(M=(M=encodeURIComponent(M)).replace(/%3A/i,":"),M+="@");var B=this.protocol||"",D=this.pathname||"",q=this.hash||"",Q=!1,C="";this.host?Q=M+this.host:this.hostname&&(Q=M+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(Q+=":"+this.port)),this.query&&a.isObject(this.query)&&Object.keys(this.query).length&&(C=E.stringify(this.query));var T=this.search||C&&"?"+C||"";return B&&B.substr(-1)!==":"&&(B+=":"),this.slashes||(!B||x[B])&&Q!==!1?(Q="//"+(Q||""),D&&D.charAt(0)!=="/"&&(D="/"+D)):Q||(Q=""),q&&q.charAt(0)!=="#"&&(q="#"+q),T&&T.charAt(0)!=="?"&&(T="?"+T),B+Q+(D=D.replace(/[?#]/g,function(S){return encodeURIComponent(S)}))+(T=T.replace("#","%23"))+q},l.prototype.resolve=function(M){return this.resolveObject(I(M,!1,!0)).format()},l.prototype.resolveObject=function(M){if(a.isString(M)){var B=new l;B.parse(M,!1,!0),M=B}for(var D=new l,q=Object.keys(this),Q=0;Q<q.length;Q++){var C=q[Q];D[C]=this[C]}if(D.hash=M.hash,M.href==="")return D.href=D.format(),D;if(M.slashes&&!M.protocol){for(var T=Object.keys(M),S=0;S<T.length;S++){var O=T[S];O!=="protocol"&&(D[O]=M[O])}return x[D.protocol]&&D.hostname&&!D.pathname&&(D.path=D.pathname="/"),D.href=D.format(),D}if(M.protocol&&M.protocol!==D.protocol){if(!x[M.protocol]){for(var K=Object.keys(M),Z=0;Z<K.length;Z++){var st=K[Z];D[st]=M[st]}return D.href=D.format(),D}if(D.protocol=M.protocol,M.host||A[M.protocol])D.pathname=M.pathname;else{for(var $=(M.pathname||"").split("/");$.length&&!(M.host=$.shift()););M.host||(M.host=""),M.hostname||(M.hostname=""),$[0]!==""&&$.unshift(""),$.length<2&&$.unshift(""),D.pathname=$.join("/")}if(D.search=M.search,D.query=M.query,D.host=M.host||"",D.auth=M.auth,D.hostname=M.hostname||M.host,D.port=M.port,D.pathname||D.search){var z=D.pathname||"",V=D.search||"";D.path=z+V}return D.slashes=D.slashes||M.slashes,D.href=D.format(),D}var Y=D.pathname&&D.pathname.charAt(0)==="/",U=M.host||M.pathname&&M.pathname.charAt(0)==="/",tt=U||Y||D.host&&M.pathname,rt=tt,nt=D.pathname&&D.pathname.split("/")||[],ft=($=M.pathname&&M.pathname.split("/")||[],D.protocol&&!x[D.protocol]);if(ft&&(D.hostname="",D.port=null,D.host&&(nt[0]===""?nt[0]=D.host:nt.unshift(D.host)),D.host="",M.protocol&&(M.hostname=null,M.port=null,M.host&&($[0]===""?$[0]=M.host:$.unshift(M.host)),M.host=null),tt=tt&&($[0]===""||nt[0]==="")),U)D.host=M.host||M.host===""?M.host:D.host,D.hostname=M.hostname||M.hostname===""?M.hostname:D.hostname,D.search=M.search,D.query=M.query,nt=$;else if($.length)nt||(nt=[]),nt.pop(),nt=nt.concat($),D.search=M.search,D.query=M.query;else if(!a.isNullOrUndefined(M.search))return ft&&(D.hostname=D.host=nt.shift(),(P=!!(D.host&&D.host.indexOf("@")>0)&&D.host.split("@"))&&(D.auth=P.shift(),D.host=D.hostname=P.shift())),D.search=M.search,D.query=M.query,a.isNull(D.pathname)&&a.isNull(D.search)||(D.path=(D.pathname?D.pathname:"")+(D.search?D.search:"")),D.href=D.format(),D;if(!nt.length)return D.pathname=null,D.search?D.path="/"+D.search:D.path=null,D.href=D.format(),D;for(var lt=nt.slice(-1)[0],ut=(D.host||M.host||nt.length>1)&&(lt==="."||lt==="..")||lt==="",b=0,k=nt.length;k>=0;k--)(lt=nt[k])==="."?nt.splice(k,1):lt===".."?(nt.splice(k,1),b++):b&&(nt.splice(k,1),b--);if(!tt&&!rt)for(;b--;b)nt.unshift("..");!tt||nt[0]===""||nt[0]&&nt[0].charAt(0)==="/"||nt.unshift(""),ut&&nt.join("/").substr(-1)!=="/"&&nt.push("");var P,H=nt[0]===""||nt[0]&&nt[0].charAt(0)==="/";return ft&&(D.hostname=D.host=H?"":nt.length?nt.shift():"",(P=!!(D.host&&D.host.indexOf("@")>0)&&D.host.split("@"))&&(D.auth=P.shift(),D.host=D.hostname=P.shift())),(tt=tt||D.host&&nt.length)&&!H&&nt.unshift(""),nt.length?D.pathname=nt.join("/"):(D.pathname=null,D.path=null),a.isNull(D.pathname)&&a.isNull(D.search)||(D.path=(D.pathname?D.pathname:"")+(D.search?D.search:"")),D.auth=M.auth||D.auth,D.slashes=D.slashes||M.slashes,D.href=D.format(),D},l.prototype.parseHost=function(){var M=this.host,B=u.exec(M);B&&((B=B[0])!==":"&&(this.port=B.substr(1)),M=M.substr(0,M.length-B.length)),M&&(this.hostname=M)}},{"./util":77,punycode:51,querystring:54}],77:[function(i,n,r){n.exports={isString:function(s){return typeof s=="string"},isObject:function(s){return typeof s=="object"&&s!==null},isNull:function(s){return s===null},isNullOrUndefined:function(s){return s==null}}},{}],78:[function(i,n,r){(function(s){(function(){function a(l){try{if(!s.localStorage)return!1}catch{return!1}var c=s.localStorage[l];return c!=null&&String(c).toLowerCase()==="true"}n.exports=function(l,c){if(a("noDeprecation"))return l;var u=!1;return function(){if(!u){if(a("throwDeprecation"))throw new Error(c);a("traceDeprecation")?console.trace(c):console.warn(c),u=!0}return l.apply(this,arguments)}}}).call(this)}).call(this,typeof Le<"u"?Le:typeof self<"u"?self:typeof window<"u"?window:{})},{}],79:[function(i,n,r){n.exports=function s(a,l){if(a&&l)return s(a)(l);if(typeof a!="function")throw new TypeError("need wrapper function");return Object.keys(a).forEach(function(u){c[u]=a[u]}),c;function c(){for(var u=new Array(arguments.length),h=0;h<u.length;h++)u[h]=arguments[h];var d=a.apply(this,u),g=u[u.length-1];return typeof d=="function"&&d!==g&&Object.keys(g).forEach(function(v){d[v]=g[v]}),d}}},{}],80:[function(i,n,r){n.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(i,n,r){n.exports=function(){for(var a={},l=0;l<arguments.length;l++){var c=arguments[l];for(var u in c)s.call(c,u)&&(a[u]=c[u])}return a};var s=Object.prototype.hasOwnProperty},{}],82:[function(i,n,r){n.exports=function(s){s.prototype[Symbol.iterator]=function*(){for(let a=this.head;a;a=a.next)yield a.value}}},{}],83:[function(i,n,r){function s(h){var d=this;if(d instanceof s||(d=new s),d.tail=null,d.head=null,d.length=0,h&&typeof h.forEach=="function")h.forEach(function(y){d.push(y)});else if(arguments.length>0)for(var g=0,v=arguments.length;g<v;g++)d.push(arguments[g]);return d}function a(h,d,g){var v=d===h.head?new u(g,null,d,h):new u(g,d,d.next,h);return v.next===null&&(h.tail=v),v.prev===null&&(h.head=v),h.length++,v}function l(h,d){h.tail=new u(d,h.tail,null,h),h.head||(h.head=h.tail),h.length++}function c(h,d){h.head=new u(d,null,h.head,h),h.tail||(h.tail=h.head),h.length++}function u(h,d,g,v){if(!(this instanceof u))return new u(h,d,g,v);this.list=v,this.value=h,d?(d.next=this,this.prev=d):this.prev=null,g?(g.prev=this,this.next=g):this.next=null}n.exports=s,s.Node=u,s.create=s,s.prototype.removeNode=function(h){if(h.list!==this)throw new Error("removing node which does not belong to this list");var d=h.next,g=h.prev;return d&&(d.prev=g),g&&(g.next=d),h===this.head&&(this.head=d),h===this.tail&&(this.tail=g),h.list.length--,h.next=null,h.prev=null,h.list=null,d},s.prototype.unshiftNode=function(h){if(h!==this.head){h.list&&h.list.removeNode(h);var d=this.head;h.list=this,h.next=d,d&&(d.prev=h),this.head=h,this.tail||(this.tail=h),this.length++}},s.prototype.pushNode=function(h){if(h!==this.tail){h.list&&h.list.removeNode(h);var d=this.tail;h.list=this,h.prev=d,d&&(d.next=h),this.tail=h,this.head||(this.head=h),this.length++}},s.prototype.push=function(){for(var h=0,d=arguments.length;h<d;h++)l(this,arguments[h]);return this.length},s.prototype.unshift=function(){for(var h=0,d=arguments.length;h<d;h++)c(this,arguments[h]);return this.length},s.prototype.pop=function(){if(this.tail){var h=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,h}},s.prototype.shift=function(){if(this.head){var h=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,h}},s.prototype.forEach=function(h,d){d=d||this;for(var g=this.head,v=0;g!==null;v++)h.call(d,g.value,v,this),g=g.next},s.prototype.forEachReverse=function(h,d){d=d||this;for(var g=this.tail,v=this.length-1;g!==null;v--)h.call(d,g.value,v,this),g=g.prev},s.prototype.get=function(h){for(var d=0,g=this.head;g!==null&&d<h;d++)g=g.next;if(d===h&&g!==null)return g.value},s.prototype.getReverse=function(h){for(var d=0,g=this.tail;g!==null&&d<h;d++)g=g.prev;if(d===h&&g!==null)return g.value},s.prototype.map=function(h,d){d=d||this;for(var g=new s,v=this.head;v!==null;)g.push(h.call(d,v.value,this)),v=v.next;return g},s.prototype.mapReverse=function(h,d){d=d||this;for(var g=new s,v=this.tail;v!==null;)g.push(h.call(d,v.value,this)),v=v.prev;return g},s.prototype.reduce=function(h,d){var g,v=this.head;if(arguments.length>1)g=d;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");v=this.head.next,g=this.head.value}for(var y=0;v!==null;y++)g=h(g,v.value,y),v=v.next;return g},s.prototype.reduceReverse=function(h,d){var g,v=this.tail;if(arguments.length>1)g=d;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");v=this.tail.prev,g=this.tail.value}for(var y=this.length-1;v!==null;y--)g=h(g,v.value,y),v=v.prev;return g},s.prototype.toArray=function(){for(var h=new Array(this.length),d=0,g=this.head;g!==null;d++)h[d]=g.value,g=g.next;return h},s.prototype.toArrayReverse=function(){for(var h=new Array(this.length),d=0,g=this.tail;g!==null;d++)h[d]=g.value,g=g.prev;return h},s.prototype.slice=function(h,d){(d=d||this.length)<0&&(d+=this.length),(h=h||0)<0&&(h+=this.length);var g=new s;if(d<h||d<0)return g;h<0&&(h=0),d>this.length&&(d=this.length);for(var v=0,y=this.head;y!==null&&v<h;v++)y=y.next;for(;y!==null&&v<d;v++,y=y.next)g.push(y.value);return g},s.prototype.sliceReverse=function(h,d){(d=d||this.length)<0&&(d+=this.length),(h=h||0)<0&&(h+=this.length);var g=new s;if(d<h||d<0)return g;h<0&&(h=0),d>this.length&&(d=this.length);for(var v=this.length,y=this.tail;y!==null&&v>d;v--)y=y.prev;for(;y!==null&&v>h;v--,y=y.prev)g.push(y.value);return g},s.prototype.splice=function(h,d,...g){h>this.length&&(h=this.length-1),h<0&&(h=this.length+h);for(var v=0,y=this.head;y!==null&&v<h;v++)y=y.next;var w=[];for(v=0;y&&v<d;v++)w.push(y.value),y=this.removeNode(y);for(y===null&&(y=this.tail),y!==this.head&&y!==this.tail&&(y=y.prev),v=0;v<g.length;v++)y=a(this,y,g[v]);return w},s.prototype.reverse=function(){for(var h=this.head,d=this.tail,g=h;g!==null;g=g.prev){var v=g.prev;g.prev=g.next,g.next=v}return this.head=d,this.tail=h,this};try{i("./iterator.js")(s)}catch{}},{"./iterator.js":82}]},{},[12])(12)})})(ss);const ld={success:{color:"#2ba471",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 23a11 11 0 100-22 11 11 0 000 22zM7.5 10.59l3 3 6-6L17.91 9l-7.41 7.41L6.09 12l1.41-1.41z"></path></svg>'},info:{color:"#0052d9",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 23a11 11 0 100-22 11 11 0 000 22zM11 8.5v-2h2v2h-2zm2 1.5v7.5h-2V10h2z"></path></svg>'},warning:{color:"#e37318",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 1a11 11 0 110 22 11 11 0 010-22zm-1 13h2V6.5h-2V14zm2 1.5h-2v2h2v-2z"></path></svg>'},error:{color:"#d54941",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 1a11 11 0 110 22 11 11 0 010-22zm-1 13h2V6.5h-2V14zm2 1.5h-2v2h2v-2z"></path></svg>'},question:{color:"#0052d9",icon:'<svg fill="none" viewBox="0 0 24 24"><path d="M12 23a11 11 0 100-22 11 11 0 000 22zm-.17-11.11c.43-.53.97-.97 1.4-1.32A2 2 0 0012 7a2 2 0 00-1.89 1.33l-.33.95L7.9 8.6l.34-.94a4 4 0 116.24 4.47 7 7 0 00-1.1 1.01c-.27.34-.37.61-.37.85v1.25h-2V14c0-.87.39-1.57.83-2.11zM11 18.25v-2h2v2h-2z"></path></svg>'}},Ge={};class iE{constructor(t,i){W(this,"parentElement");W(this,"box");W(this,"icon");W(this,"text");W(this,"closeBtn");W(this,"duration");W(this,"content");W(this,"theme");W(this,"placement");W(this,"id");var r;this.parentElement=t,this.box=document.createElement("div"),this.icon=document.createElement("div"),this.text=document.createElement("div"),this.box.className="meta2d-message",this.icon.className="icon",this.text.className="text",this.icon.innerHTML=ld[i.theme||"info"].icon,this.text.innerHTML=i.content,this.box.appendChild(this.icon),this.box.appendChild(this.text),i.closeBtn&&(this.closeBtn=document.createElement("div"),this.closeBtn.className="close",this.closeBtn.innerHTML="x",this.closeBtn.onclick=()=>{this.close()},this.box.appendChild(this.closeBtn)),t.appendChild(this.box);let n;for(let s=0;s<document.styleSheets.length;s++)document.styleSheets[s].title==="le5le.com/message"&&(n=document.styleSheets[s]);if(!n){let s=document.createElement("style");s.type="text/css",s.title="le5le.com/message",document.head.appendChild(s),s=document.createElement("style"),s.type="text/css",document.head.appendChild(s),n=s.sheet,n.insertRule(`.meta2d-message{
  58. position:absolute;
  59. z-index:999;
  60. transform: translateX(-50%);
  61. padding:12px 16px;
  62. max-width:400px;
  63. background:#fff;
  64. border-radius:6px;
  65. box-shadow:0 3px 14px 2px rgba(0, 0, 0, .05),0 8px 10px 1px rgba(0, 0, 0, 6%),0 5px 5px -3px rgba(0, 0, 0, 10%);
  66. display:flex;
  67. animation: fadein .5s;}`),n.insertRule(`
  68. @keyframes fadein {
  69. 0% {
  70. transform: translate(-50%, -100%);
  71. }
  72. 100% {
  73. transform: translate(-50%,0);
  74. }
  75. }`),n.insertRule(".meta2d-message .icon{width:20px;height:20px;}"),n.insertRule(".meta2d-message .text{color:rgba(0, 0, 0, 0.9);font-size:12px;margin-left:8px;line-height:20px;}"),n.insertRule(".meta2d-message .close{width:20px;height:20px;padding-left: 16px; cursor: pointer;}")}this.id=i.id||It(),this.duration=(r=i.duration)!=null?r:3e3,this.placement=i.placement||"top",this.theme=i.theme||"info"}init(){Ge[this.id]=this,this.duration&&setTimeout(()=>{this.close()},this.duration);let t=-1;Object.keys(Ge).forEach(i=>{var n;((n=Ge[i])==null?void 0:n.placement)===this.placement&&t++}),this.setPosition(this.placement,t),this.icon.children[0].style.fill=ld[this.theme].color}setPosition(t,i=0){switch(t){case"top":this.box.style.top=`${30+i*60}px`,this.box.style.left="50%";break;case"bottom":this.box.style.bottom=`${30+i*60}px`,this.box.style.left="50%";break;case"left":this.box.style.top=`${30+i*60}px`,this.box.style.left="30px";break;case"right":this.box.style.top=`${30+i*60}px`,this.box.style.right="30px";break}}close(){Object.keys(Ge).forEach(t=>{var i;if(((i=Ge[t])==null?void 0:i.placement)===this.placement)switch(this.placement){case"top":case"left":case"right":Ge[t].box.style.top=parseInt(Ge[t].box.style.top)-60+"px";break;case"bottom":Ge[t].box.style.bottom=parseInt(Ge[t].box.style.bottom)-60+"px";break}}),Ge[this.id]=null,delete Ge[this.id],this.box.remove()}}class UC{constructor(t,i={}){W(this,"store");W(this,"canvas");W(this,"websocket");W(this,"mqttClient");W(this,"websockets");W(this,"mqttClients");W(this,"penPluginMap",new Map);W(this,"socketFn");W(this,"events",{});W(this,"map");W(this,"mapTimer");W(this,"facePen",Or);W(this,"getWords",Av);W(this,"calcTextLines",Es);W(this,"calcTextRect",Ti);W(this,"calcTextDrawRect",Ev);W(this,"jetLinksList",[]);W(this,"jetLinksClient");W(this,"register",A_);W(this,"registerCanvasDraw",R_);W(this,"registerAnchors",C_);W(this,"websocketTimes",0);W(this,"mqttTimes",0);W(this,"httpTimer");W(this,"httpTimerList",[]);W(this,"updateTimer");W(this,"updateTimerList",[]);W(this,"sqlTimerList",[]);W(this,"onEvent",(t,i)=>{switch(t){case"add":i.forEach(n=>{var r;(r=n.onAdd)==null||r.call(n,n)}),this.onSizeUpdate();break;case"enter":i&&i.onMouseEnter&&i.onMouseEnter(i,this.canvas.mousePos),this.store.data.locked&&this.doEvent(i,t);break;case"leave":i&&i.onMouseLeave&&i.onMouseLeave(i,this.canvas.mousePos),this.store.data.locked&&this.doEvent(i,t);break;case"active":case"inactive":this.store.data.locked&&i.forEach(n=>{this.doEvent(n,t)});break;case"click":this.store.data.locked&&i.pen&&!i.pen.disabled&&i.pen.switch&&(i.pen.checked=!i.pen.checked,i.pen.calculative.checked=i.pen.checked,i.pen.calculative.gradient=void 0,i.pen.calculative.radialGradient=void 0),i.pen&&i.pen.onClick&&!i.pen.disabled&&i.pen.onClick(i.pen,this.canvas.mousePos),this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"contextmenu":i.pen&&i.pen.onContextmenu&&!i.pen.disabled&&i.pen.onContextmenu(i.pen,this.canvas.mousePos),this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"mousedown":i.pen&&i.pen.onMouseDown&&!i.pen.disabled&&i.pen.onMouseDown(i.pen,this.canvas.mousePos),this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"mouseup":i.pen&&i.pen.onMouseUp&&!i.pen.disabled&&i.pen.onMouseUp(i.pen,this.canvas.mousePos),this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"dblclick":this.store.data.locked&&i.pen&&!i.pen.disabled&&this.doEvent(i.pen,t);break;case"valueUpdate":this.store.data.locked&&this.doEvent(i,t),this.canvas.tooltip.updateText(i);break;case"update":case"delete":case"translatePens":case"rotatePens":case"resizePens":this.onSizeUpdate();break;case"navigator":this.store.data.id||console.warn("\u8BF7\u5148\u4FDD\u5B58\u5F53\u524D\u56FE\u7EB8"),this.navigatorTo(i.params);break;case"input":this.store.data.locked&&i&&!i.disabled&&this.doEvent(i,t);break;case"change":this.store.data.locked&&i&&!i.disabled&&this.doEvent(i,t);break}this.doMessageEvent(t)});W(this,"doEvent",(t,i)=>{var s,a,l,c,u,h,d,g,v,y;if(!t)return;let n=!1,r=[];if((s=t.events)==null||s.forEach((w,p)=>{var _;if(w.actions&&w.actions.length){if(w.name===i){let A=!1;w.conditions&&w.conditions.length?w.conditionType==="and"?A=w.conditions.every(x=>this.judgeCondition(t,x.key,x)):w.conditionType==="or"&&(A=w.conditions.some(x=>this.judgeCondition(t,x.key,x))):A=!0,A&&r.push(p)}}else if(n=!0,this.events[w.action]&&w.name===i){let A=!((_=w.where)!=null&&_.type);if(w.where){const{fn:x,fnJs:E,comparison:I,key:M,value:B}=w.where;if(x)A=x(t,{meta2d:this});else if(E){try{w.where.fn=new Function("pen","context",E)}catch(D){console.error("Error: make function:",D)}w.where.fn&&(A=w.where.fn(t,{meta2d:this}))}else{let D=t[M];switch(["x","y","width","height"].includes(M)&&(D=this.getPenRect(t)[M]),I){case">":A=D>+B;break;case">=":A=D>=+B;break;case"<":A=D<+B;break;case"<=":A=D<=+B;break;case"=":case"==":A=D==B;break;case"!=":A=D!=B;break;case"[)":A=pr(+D,B);break;case"![)":A=!pr(+D,B);break;case"[]":A=wr(D,B);break;case"![]":A=!wr(D,B);break}}}A&&r.push(p)}}),n?(a=t.events)==null||a.forEach((w,p)=>{r.includes(p)&&this.events[w.action](t,w)}):(l=t.events)==null||l.forEach(async(w,p)=>{if(r.includes(p)){if(w.confirm&&!await this.canvas.popconfirm.showModal(t,this.canvas.mousePos,w.confirmTitle))return;w.actions.forEach(_=>{if(_.timeout){let A=setTimeout(()=>{this.events[_.action]&&(this.events[_.action](t,_),clearTimeout(A),A=null)},_.timeout)}else this.events[_.action]&&this.events[_.action](t,_)})}}),i==="valueUpdate"){(c=t.realTimes)==null||c.forEach(p=>{var A,x;let _=[];(A=p.triggers)==null||A.forEach((E,I)=>{var B;let M=!1;(B=E.conditions)!=null&&B.length?E.conditionType==="and"?M=E.conditions.every(D=>this.judgeCondition(t,p.key,D)):E.conditionType==="or"&&(M=E.conditions.some(D=>this.judgeCondition(t,p.key,D))):M=!0,M&&_.push(I)}),(x=p.triggers)==null||x.forEach((E,I)=>{var M;_.includes(I)&&((M=E.actions)==null||M.forEach(B=>{if(B.timeout){let D=setTimeout(()=>{this.events[B.action]&&(this.events[B.action](t,B),clearTimeout(D),D=null)},B.timeout)}else this.events[B.action](t,B)}))})});let w=[];if((u=this.store.globalTriggers[t.id])==null||u.forEach((p,_)=>{var x;let A=!1;(x=p.conditions)!=null&&x.length?p.conditionType==="and"?A=p.conditions.every(E=>this.judgeCondition(this.store.pens[E.source],E.key,E)):p.conditionType==="or"&&(A=p.conditions.some(E=>this.judgeCondition(this.store.pens[E.source],E.key,E))):A=!0,A&&w.push(_)}),(h=this.store.globalTriggers[t.id])==null||h.forEach((p,_)=>{var A;w.includes(_)&&((A=p.actions)==null||A.forEach(x=>{if(x.timeout){let E=setTimeout(()=>{this.events[x.action]&&(this.events[x.action](t,x),clearTimeout(E),E=null)},x.timeout)}else this.events[x.action](t,x)}))}),(d=t.triggers)!=null&&d.length){for(let p of t.triggers)if((g=p.status)!=null&&g.length)for(let _ of p.status){let A=!1;if((v=_.conditions)!=null&&v.length?_.conditionType==="and"?A=_.conditions.every(x=>this.judgeCondition(t,x.key,x)):_.conditionType==="or"&&(A=_.conditions.some(x=>this.judgeCondition(t,x.key,x))):A=!0,A){(y=_.actions)==null||y.forEach(x=>{if(x.timeout){let E=setTimeout(()=>{this.events[x.action]&&(this.events[x.action](t,x),clearTimeout(E),E=null)},x.timeout)}else this.events[x.action](t,x)});break}}}}this.doEvent(this.store.pens[t.parentId],i)});W(this,"doDataEvent",t=>{var r,s,a;if(!((r=this.store.data.dataEvents)!=null&&r.length))return;const i=t.reduce((l,{dataId:c,id:u,value:h})=>(l[u||c]=h,l),{});let n=[];(s=this.store.data.dataEvents)==null||s.forEach((l,c)=>{let u=!1;l.conditions&&l.conditions.length?l.conditionType==="and"?u=l.conditions.every(h=>this.dataJudegeCondition(i,h.key,h)):l.conditionType==="or"&&(u=l.conditions.some(h=>this.dataJudegeCondition(i,h.key,h))):u=!0,u&&n.push(c)}),(a=this.store.data.dataEvents)==null||a.forEach((l,c)=>{var u;n.includes(c)&&((u=l.actions)==null||u.forEach(h=>{this.events[h.action](i,h)}))})});W(this,"renderPenRaw",ja);W(this,"setElemPosition",ti);W(this,"setLifeCycleFunc",x2);this.store=L_(It()),this.setOptions(i),this.setDatabyOptions(i),this.init(t),this.register(Qk()),this.registerCanvasDraw({cube:tk}),this.registerAnchors(tE()),globalThis.meta2d=this,this.initEventFns(),this.store.emitter.on("*",this.onEvent)}get beforeAddPen(){return this.canvas.beforeAddPen}set beforeAddPen(t){this.canvas.beforeAddPen=t}get beforeAddPens(){return this.canvas.beforeAddPens}set beforeAddPens(t){this.canvas.beforeAddPens=t}get beforeAddAnchor(){return this.canvas.beforeAddAnchor}set beforeAddAnchor(t){this.canvas.beforeAddAnchor=t}get beforeRemovePens(){return this.canvas.beforeRemovePens}set beforeRemovePens(t){this.canvas.beforeRemovePens=t}get beforeRemoveAnchor(){return this.canvas.beforeRemoveAnchor}set beforeRemoveAnchor(t){this.canvas.beforeRemoveAnchor=t}setOptions(t={}){var i;(t.grid!==void 0||t.gridColor!==void 0||t.gridSize!==void 0)&&this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0),(t.rule!==void 0||t.ruleColor!==void 0||t.ruleOptions!==void 0)&&(this.store.patchFlagsTop=!0,t.ruleOptions&&(i=this.store.options)!=null&&i.ruleOptions&&(Object.assign(this.store.options.ruleOptions,t.ruleOptions),t.ruleOptions=this.store.options.ruleOptions)),t.background!==void 0&&this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0),t.resizeMode!==void 0&&(t.resizeMode||(this.canvas.hotkeyType=Kt.None)),(t.width!==void 0||t.height!==void 0)&&(this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0),this.canvas&&this.canvas.canvasTemplate.canvas.style.backgroundImage&&(this.canvas.canvasTemplate.canvas.style.backgroundImage="")),this.store.options=Object.assign(this.store.options,t),this.canvas&&t.scroll!==void 0&&(t.scroll?(!this.canvas.scroll&&(this.canvas.scroll=new ig(this.canvas)),this.canvas.scroll.show()):this.canvas.scroll&&this.canvas.scroll.hide())}getOptions(){return this.store.options}setTheme(t){this.store.data.theme=t,this.setBackgroundColor(this.store.theme[t].background),this.canvas.parentElement.style.background=this.store.theme[t].parentBackground,this.store.data.color=this.store.theme[t].color,this.setOptions({ruleColor:this.store.theme[t].ruleColor,ruleOptions:this.store.theme[t].ruleOptions}),this.render()}setDatabyOptions(t={}){const{color:i,activeColor:n,activeBackground:r,grid:s,gridColor:a,gridSize:l,fromArrow:c,toArrow:u,rule:h,ruleColor:d,textColor:g,x:v=0,y=0}=t;this.setRule({rule:h,ruleColor:d}),this.setGrid({grid:s,gridColor:a,gridSize:l}),this.store.data=Object.assign(this.store.data,{textColor:g,color:i,activeColor:n,activeBackground:r,fromArrow:c,toArrow:u,x:v,y})}init(t){typeof t=="string"?this.canvas=new sd(this,document.getElementById(t),this.store):this.canvas=new sd(this,t,this.store),this.resize(),this.canvas.listen()}initEventFns(){this.events[fe.Link]=(t,i)=>{var n;if(window&&i.value&&typeof i.value=="string"){window.open(i.value,(n=i.params)!=null?n:"_blank");return}console.warn("[meta2d] Link param is not a string")},this.events[fe.SetProps]=(t,i)=>{const n=i.value;if(n&&typeof n=="object"){(i.params?this.find(i.params):this.find(t.id)).forEach(s=>{n.hasOwnProperty("visible")&&s.visible!==n.visible&&this.setVisible(s,n.visible),this.setValue({id:s.id,...n},{render:!1,doEvent:!1})}),this.render();return}console.warn("[meta2d] SetProps value is not an object")},this.events[fe.StartAnimate]=(t,i)=>{let n=t;if(i.value&&(n=this.findOne(i.value)),!(this.store.animates.has(n)&&!n.calculative.pause&&n.animateName===i.params)){if(i.targetType&&i.params){this.startAnimate(i.value||[t],i.params);return}if(!i.value||typeof i.value=="string"){this.startAnimate(i.value||[t]);return}console.warn("[meta2d] StartAnimate value is not a string")}},this.events[fe.PauseAnimate]=(t,i)=>{if(!i.value||typeof i.value=="string"){this.pauseAnimate(i.value||[t]);return}console.warn("[meta2d] PauseAnimate value is not a string")},this.events[fe.StopAnimate]=(t,i)=>{if(!i.value||typeof i.value=="string"){if(i.value){let n=this.findOne(i.value);if(!this.store.animates.has(n))return}else if(!this.store.animates.has(t))return;this.stopAnimate(i.value||[t]);return}console.warn("[meta2d] StopAnimate event value is not a string")},this.events[fe.StartVideo]=(t,i)=>{if(!i.value||typeof i.value=="string"){this.startVideo(i.value||[t]);return}console.warn("[meta2d] StartVideo value is not a string")},this.events[fe.PauseVideo]=(t,i)=>{if(!i.value||typeof i.value=="string"){this.pauseVideo(i.value||[t]);return}console.warn("[meta2d] PauseVideo value is not a string")},this.events[fe.StopVideo]=(t,i)=>{if(!i.value||typeof i.value=="string"){this.stopVideo(i.value||[t]);return}console.warn("[meta2d] StopVideo event value is not a string")},this.events[fe.JS]=(t,i,n)=>{var r;if(i.value&&!i.fn)try{if(typeof i.value!="string")throw new Error("[meta2d] Function value must be string");const s=i.value;i.fn=new Function("pen","params","context",s)}catch(s){console.error("[meta2d]: Error on make a function:",s)}(r=i.fn)==null||r.call(i,t,n||i.params,{meta2d:this,eventName:i.name})},this.events[fe.GlobalFn]=(t,i)=>{if(typeof i.value!="string"){console.warn("[meta2d] GlobalFn value must be a string");return}globalThis[i.value]&&globalThis[i.value](t,i.params)},this.events[fe.Emit]=(t,i)=>{if(typeof i.value!="string"){console.warn("[meta2d] Emit value must be a string");return}this.store.emitter.emit(i.value,{pen:t,params:i.params,eventName:i.name})},this.events[fe.SendPropData]=(t,i)=>{const n=ct(i.value);if(n&&typeof n=="object"){const r=i.params?this.findOne(i.params):t;for(let s in n)(n[s]===void 0||n[s]==="")&&(n[s]=r[s]);n.id=r.id,this.doSendDataEvent(n,i.extend);return}console.warn("[meta2d] SendPropData value is not an object")},this.events[fe.SendVarData]=(t,i)=>{const n=ct(i.value);if(n&&typeof n=="object"){const r=i.params?this.findOne(i.params):t;let s=[];for(let a in n){let l={dataId:a,value:n[a]};if(!l.value){let c=r.form.find(u=>u.dataIds&&u.dataIds.dataId===l.dataId);c&&(l.value=r[c.key])}s.push(l)}this.doSendDataEvent(s,i.extend);return}console.warn("[meta2d] SendVarData value is not an object")},this.events[fe.Navigator]=(t,i)=>{i.value&&typeof i.value=="string"&&this.navigatorTo(i.value)},this.events[fe.Dialog]=(t,i)=>{if(i.params&&typeof i.params=="string"){let n=i.params;if(i.params.includes("${")){let r=i.params.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));r&&(r==null||r.forEach(s=>{n=n.replace(`\${${s}}`,t[s])}))}this.canvas.dialog.show(i.value,n,i.extend)}},this.events[fe.SendData]=(t,i)=>{var r,s;if((r=i.list)!=null&&r.length){if(i.network&&i.network.protocol==="jetLinks"){const l=[];i.list.forEach((c,u)=>{var d,g;const h=c.params?this.findOne(c.params):t;l[u]={deviceId:h.deviceId,productId:h.productId,properties:{}};for(let v in c.value)if(c.value[v]===void 0||c.value[v]===""){const y=(d=h.realTimes)==null?void 0:d.find(w=>w.propertyId===v);y&&(l[u].properties[v]=h[y.key])}else if(typeof c.value[v]=="string"&&((g=c.value[v])==null?void 0:g.indexOf("${"))>-1){let y=c.value[v].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));y!=null&&y.length&&(l[u].properties[v]=h[y[0]])}else l[u].properties[v]=c.value[v]}),this.jetLinksClient&&l.length&&l.forEach(c=>{this.jetLinksClient.send(JSON.stringify({type:"sub",topic:`/device-message-sender/${c.productId}/${c.deviceId}`,parameter:{messageType:"WRITE_PROPERTY",properties:c.properties,headers:{async:!1}},id:c.productId+"/"+c.deviceId+"-"+It()}))});return}const a={};i.list.forEach(l=>{var u;const c=l.params?this.findOne(l.params):t;for(let h in l.value)if(l.value[h]===void 0||l.value[h]==="")a[h]=c[h];else if(typeof l.value[h]=="string"&&((u=l.value[h])==null?void 0:u.indexOf("${"))>-1){let d=l.value[h].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));d!=null&&d.length&&(a[h]=c[d[0]])}else a[h]=l.value[h]}),t.deviceId&&(a.deviceId=t.deviceId),this.sendDataToNetWork(a,t,i);return}const n=ct(i.value);if(n&&typeof n=="object"&&i.targetType==="id"){const a=i.params?this.findOne(i.params):t;for(let l in n)if(n[l]===void 0||n[l]==="")n[l]=a[l];else if(typeof n[l]=="string"&&((s=n[l])==null?void 0:s.indexOf("${"))>-1){let c=n[l].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));c!=null&&c.length&&(n[l]=a[c[0]])}a.deviceId&&(n.deviceId=a.deviceId),this.sendDataToNetWork(n,t,i);return}},this.events[fe.PostMessage]=(t,i)=>{var a;if(typeof i.value!="string"){console.warn("[meta2d] Emit value must be a string");return}const n=i.params?this.findOne(i.params):t;if(n.name!=="iframe"||!n.iframe){console.warn("\u4E0D\u662F\u5D4C\u5165\u9875\u9762");return}let r=Il(n.iframe.split("?")[1]);const s={};(a=i.list)!=null&&a.length&&i.list.forEach(l=>{var u;const c=l.params?this.findOne(l.params):t;for(let h in l.value)if(l.value[h]===void 0||l.value[h]==="")s[h]=c[h];else if(typeof l.value[h]=="string"&&((u=l.value[h])==null?void 0:u.indexOf("${"))>-1){let d=l.value[h].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));d!=null&&d.length&&(s[h]=c[d[0]])}else s[h]=l.value[h]}),n.calculative.singleton.div.children[0].contentWindow.postMessage(JSON.stringify({name:i.value,id:r.id,value:s}),"*")},this.events[fe.PostMessageToParent]=(t,i)=>{var r;if(typeof i.value!="string"){console.warn("[meta2d] Emit value must be a string");return}const n={};(r=i.list)!=null&&r.length&&i.list.forEach(s=>{var l;const a=s.params?this.findOne(s.params):t;for(let c in s.value)if(s.value[c]===void 0||s.value[c]==="")n[c]=a[c];else if(typeof s.value[c]=="string"&&((l=s.value[c])==null?void 0:l.indexOf("${"))>-1){let u=s.value[c].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));u!=null&&u.length&&(n[c]=a[u[0]])}else n[c]=s.value[c]}),window.parent.postMessage(JSON.stringify({name:i.value,value:n}),"*")},this.events[fe.Message]=(t,i)=>{this.message({theme:i.params,content:i.value,...i.extend})}}message(t){new iE(this.canvas.parentElement,t).init()}closeAll(){for(let t in Ge)Ge[t].close()}async navigatorTo(t){if(!t)return;const i=new URL(window.location);i.searchParams.set("id",t),history.pushState({},"",i);const n=this.store.options.navigatorNetWork,r=location.href.includes("2d.")||location.href.includes("/2d")?"2d":"v",s=await fetch(((n==null?void 0:n.url)||`/api/data/${r}/get`)+((n==null?void 0:n.method)==="GET"?`?id=${t}`:""),{headers:{Authorization:`Bearer ${this.getCookie("token")||localStorage.getItem("token")||new URLSearchParams(location.search).get("token")||""}`},method:(n==null?void 0:n.method)||"POST",body:(n==null?void 0:n.method)==="GET"?void 0:JSON.stringify({id:t})});if(s.ok){let a=await s.text();a.constructor===Object||a.constructor===Array?a=JSON.parse(JSON.stringify(a)):typeof a=="string"&&(a=JSON.parse(a)),a.data&&(a=a.data),this.open(a)}else this.store.emitter.emit("error",{type:"http",error:s})}doSendDataEvent(t,i){let n=JSON.stringify(t);this.mqttClient&&this.mqttClient.connected&&(i?i.split(",").forEach(r=>{this.mqttClient.publish(r,n)}):this.store.data.mqttTopics&&this.store.data.mqttTopics.split(",").forEach(r=>{this.mqttClient.publish(r,n)})),this.websocket&&this.websocket.readyState===1&&this.websocket.send(n),(this.store.data.https||this.store.data.http)&&this.sendDatabyHttp(n),this.store.emitter.emit("sendData",n)}async sendDataToNetWork(t,i,n){var s;const r=ct(n.network);if(r.data&&(Object.assign(r,r.data),delete r.data),!!r.url){if(r.protocol==="http"){if(typeof r.headers=="object"){for(let u in r.headers)if(typeof r.headers[u]=="string"){let h=r.headers[u].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));h&&(r.headers[u]=r.headers[u].replace(`\${${h[0]}}`,this.getDynamicParam(h[0])))}}let a,l=r.url;if(r.method==="GET"&&(a="?"+Object.keys(t).map(u=>u+"="+t[u]).join("&")),r.method==="POST"&&l.indexOf("${")>-1){let u=l.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));u&&u.forEach(h=>{l=l.replace(`\${${h}}`,Nf(i,h)||this.getDynamicParam(h))})}const c=await fetch(l+(a||""),{headers:r.headers||{},method:r.method,body:r.method==="POST"?JSON.stringify(t):void 0});if(c.ok){if(n.callback){const u=await c.text();if(!n.fn)try{if(typeof n.callback!="string")throw new Error("[meta2d] Function callback must be string");const h=n.callback;n.fn=new Function("pen","data","context",h)}catch(h){console.error("[meta2d]: Error on make a function:",h)}(s=n.fn)==null||s.call(n,i,u,{meta2d:this,e:n})}console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F")}}else if(r.protocol==="mqtt"){const a=this.mqttClients.filter(l=>l.options.href===r.url);if(a&&a.length)a[0].connected&&r.topics.split(",").forEach(l=>{a[0].publish(l,t)});else{let l=ss.exports.connect(r.url,r.options);l.on("connect",()=>{console.info("mqtt\u8FDE\u63A5\u6210\u529F"),r.topics.split(",").forEach(c=>{l.publish(c,t),l==null||l.end()})})}}else if(r.protocol==="websocket"){const a=this.websockets.filter(l=>l.url===r.url);if(a&&a.length)a[0].readyState===1&&a[0].send(t);else{let l=new WebSocket(r.url,r.protocols||void 0);l.onopen=function(){console.info("websocket\u8FDE\u63A5\u6210\u529F"),l.send(t),setTimeout(()=>{l.close()},100)}}}}}resize(t,i){this.canvas.resize(t,i),this.render(),this.store.emitter.emit("resize",{width:t,height:i}),this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.init()}async addPen(t,i,n=!0,r=!1){return await this.canvas.addPen(t,i,n,r)}async addPens(t,i,n=!1){return await this.canvas.addPens(t,i,n)}render(t){var i;(i=this.canvas)==null||i.render(t)}async setBackgroundImage(t,i){var l,c,u,h;let n=this;async function r(d){return new Promise(g=>{const v=new Image;v.src=d,n.store.options.cdn&&!(d.startsWith("http")||d.startsWith("//")||d.startsWith("data:image"))&&(v.src=n.store.options.cdn+d),v.crossOrigin="anonymous",v.onload=()=>{g(v)}})}this.store.data.bkImage=t;const s=(i==null?void 0:i.width)||((l=this.store.data)==null?void 0:l.width)||((c=this.store.options)==null?void 0:c.width),a=(i==null?void 0:i.height)||((u=this.store.data)==null?void 0:u.height)||((h=this.store.options)==null?void 0:h.height);if(s&&a?(this.canvas.canvasTemplate.canvas.style.backgroundImage=null,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)):this.canvas.canvasTemplate.canvas.style.backgroundImage=t?`url('${t}')`:"",t){const d=await r(t);this.store.bkImg=d,s&&a&&this.canvas&&(this.canvas.canvasTemplate.init(),this.render())}else this.store.bkImg=null}setBackgroundColor(t=this.store.data.background){this.store.data.background=t,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)}setGrid({grid:t=this.store.data.grid,gridColor:i=this.store.data.gridColor,gridSize:n=this.store.data.gridSize,gridRotate:r=this.store.data.gridRotate}={}){this.store.data.grid=t,this.store.data.gridColor=i,this.store.data.gridSize=n<0?0:n,this.store.data.gridRotate=r,this.canvas&&(this.canvas.canvasTemplate.bgPatchFlags=!0)}setRule({rule:t=this.store.data.rule,ruleColor:i=this.store.data.ruleColor}={}){this.store.data.rule=t,this.store.data.ruleColor=i,this.store.patchFlagsTop=!0}open(t,i=!0){if(this.clear(!1,t==null?void 0:t.template),this.canvas.autoPolylineFlag=!0,t){this.setBackgroundImage(t.bkImage,t),Object.assign(this.store.data,t),this.store.data.pens=[];for(const n of t.pens)n.id||(n.id=It()),!n.calculative&&(n.calculative={canvas:this.canvas}),this.store.pens[n.id]=n;for(const n of t.pens)this.canvas.makePen(n)}if(this.canvas.patchFlagsLines.forEach(n=>{n.type&&this.canvas.initLineRect(n)}),this.store.data.template||(this.store.data.template=It()),i||(this.canvas.opening=!0),this.initBindDatas(),this.initBinds(),this.initMessageEvents(),this.initGlobalTriggers(),this.render(),this.listenSocket(),this.connectSocket(),this.connectNetwork(),this.startDataMock(),this.startAnimate(),this.startVideo(),this.doInitJS(),this.doInitFn(),setTimeout(()=>{const n=this.store.data.pens.find(r=>r.autofocus);n&&this.focus(n.id)},100),this.store.data.iconUrls)for(const n of this.store.data.iconUrls)F_(n,()=>{this.render()});this.canvas.autoPolylineFlag=!1,this.store.emitter.emit("opened"),this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.init()}cacheData(t){if(t&&this.store.options.cacheLength){let i=this.store.cacheDatas.findIndex(n=>n.data&&n.data._id===t);if(i===-1)this.store.cacheDatas.push({data:ct(this.store.data,!0)}),this.store.cacheDatas.length>this.store.options.cacheLength&&this.store.cacheDatas.shift();else{let n=this.store.cacheDatas.splice(i,1)[0];this.store.cacheDatas.push(n)}}}loadCacheData(t){let i=this.store.cacheDatas.findIndex(n=>n.data&&n.data._id===t);i!==-1&&(this.store.data=this.store.cacheDatas[i].data,this.setBackgroundImage(this.store.data.bkImage),this.store.pens={},this.store.data.pens.forEach(n=>{n.calculative.canvas=this.canvas,this.store.pens[n.id]=n,At.path2dDraws[n.name]&&this.store.path2dMap.set(n,At.path2dDraws[n.name](n)),n.type&&this.store.path2dMap.set(n,At.path2dDraws[n.name](n)),n.image&&(n.calculative.imageDrawed=!1,this.canvas.loadImage(n))}),this.render())}initBindDatas(){this.store.bindDatas={},this.store.data.pens.forEach(t=>{var i;(i=t.form)==null||i.forEach(n=>{let r;n.dataIds&&(Array.isArray(n.dataIds)?r=n.dataIds:r=[n.dataIds]),r==null||r.forEach(s=>{this.store.bindDatas[s.dataId]||(this.store.bindDatas[s.dataId]=[]),this.store.bindDatas[s.dataId].push({id:t.id,formItem:n})})})})}initBinds(){this.jetLinksList=[],this.store.bind={},this.store.data.pens.forEach(t=>{var i;(i=t.realTimes)==null||i.forEach(n=>{if(n.bind&&n.bind.id){this.store.bind[n.bind.id]||(this.store.bind[n.bind.id]=[]),this.store.bind[n.bind.id].push({id:t.id,key:n.key});const r=n.productId||t.productId,s=n.deviceId||t.deviceId,a=n.propertyId;if(r&&s&&a){const l=this.jetLinksList.findIndex(c=>c.topic.startsWith(`/${r}/${s}`));l>-1?this.jetLinksList[l].properties.includes(n.propertyId)||this.jetLinksList[l].properties.push(n.propertyId):this.jetLinksList.push({topic:`/${r}/${s}`,deviceId:s,properties:[n.propertyId]})}}})})}connectSocket(){this.connectWebsocket(),this.connectMqtt(),this.connectHttp()}doInitJS(){const t=this.store.data.initJs;if(t&&t.trim())try{new Function("context",t)({meta2d:this})}catch(i){console.warn("initJs error",i)}}doInitFn(){let t=Il(),i=[];for(let n in t)t.hasOwnProperty(n)&&n.startsWith("bind-")&&i.push({id:n.replace("bind-",""),dataId:n.replace("bind-",""),value:t[n]});i.length&&this.setDatas(i,{history:!1})}drawLine(t){t&&ng(this.store),this.canvas.drawingLineName=t}alignPenToGrid(t){this.canvas.alignPenToGrid(t)}drawingPencil(){this.canvas.drawingPencil()}stopPencil(){this.canvas.stopPencil()}lock(t){this.store.data.locked=t,this.finishDrawLine(!0),this.canvas.drawingLineName="",this.stopPencil(),this.store.data.pens.forEach(i=>{var n;i.externElement===!0&&(n=i.calculative.singleton)!=null&&n.div&&ti(i,i.calculative.singleton.div)}),t>0&&this.initMessageEvents()}async finishDrawLine(t){await this.canvas.finishDrawline(t)}async finishPencil(){await this.canvas.finishPencil()}updateLineType(t,i){if(!t||t.name!="line"||!i||!this.canvas[i])return;t.lineName=i;const n=le(t),r=qt(t);n.prev=void 0,n.next=void 0,r.prev=void 0,r.next=void 0,t.calculative.worldAnchors=[n,r],t.calculative.activeAnchor=n,this.canvas[i](this.store,t,r),t.lineName==="curve"&&(n.prev={penId:n.penId,x:n.x-50,y:n.y},n.next={penId:n.penId,x:n.x+50,y:n.y},r.prev={penId:r.penId,x:r.x-50,y:r.y},r.next={penId:r.penId,x:r.x+50,y:r.y}),t.calculative.activeAnchor=void 0,this.canvas.initLineRect(t),this.render()}addDrawLineFn(t,i){this.canvas[t]=i,this.canvas.drawLineFns.push(t)}removeDrawLineFn(t){const i=this.canvas.drawLineFns.indexOf(t);i>-1&&this.canvas.drawLineFns.splice(i,1)}showMagnifier(){this.canvas.showMagnifier()}hideMagnifier(){this.canvas.hideMagnifier()}toggleMagnifier(){this.canvas.toggleMagnifier()}clear(t=!0,i){var n;for(const r of this.store.data.pens)(n=r.onDestroy)==null||n.call(r,r);D_(this.store,i),this.hideInput(),this.canvas.tooltip.hide(),this.map&&this.map.isShow&&(this.map.show(),this.map.setView()),this.canvas.clearCanvas(),sessionStorage.removeItem("page"),this.store.clipboard=void 0,this.store.sameTemplate||(this.canvas.canvasTemplate.bgPatchFlags=!0),this.store.patchFlagsBackground=!0,this.store.patchFlagsTop=!0,this.setBackgroundImage(void 0),t&&this.render()}emit(t,i){this.store.emitter.emit(t,i)}on(t,i){return this.store.emitter.on(t,i),this}off(t,i){return this.store.emitter.off(t,i),this}registerMoveDock(t){this.canvas.customMoveDock=t}registerResizeDock(t){this.canvas.customResizeDock=t}find(t){return this.canvas.find(t)}findOne(t){return this.canvas.findOne(t)}getPenRect(t){return this.canvas.getPenRect(t)}setPenRect(t,i,n=!0){this.canvas.setPenRect(t,i,n)}startAnimate(t,i){this.stopAnimate(t);let n;t?typeof t=="string"?n=this.find(t):n=t:n=this.store.data.pens.filter(r=>(r.type||r.frames)&&r.autoPlay||r.animations&&r.animations.length&&r.animations.findIndex(s=>s.autoPlay)!==-1),n.length&&(n.forEach(r=>{var s,a;if(r.calculative.pause){const l=Date.now()-r.calculative.pause;r.calculative.pause=void 0,r.calculative.frameStart+=l,r.calculative.frameEnd+=l}else{let l=-1;if(i!==void 0&&r.animations){if(typeof i=="string"){if(l=r.animations.findIndex(c=>c.name===i),l===-1)return}else if(typeof i=="number")if(r.animations.length>i)l=i;else return}else i===void 0&&(l=(s=r.animations)==null?void 0:s.findIndex(c=>c.autoPlay),l===-1&&((a=r.animations)==null?void 0:a.length)&&(l=0));if(l!==-1&&l!==void 0){const c=ct(r.animations[l]);c.animateName=c.name,delete c.name,c.currentAnimation=l,!r.type&&c.frames&&(c.showDuration=this.calcAnimateDuration(c)),this.setValue({id:r.id,...c},{doEvent:!1,history:!1})}this.store.animates.add(r),r.type||this.store.animateMap.set(r,r.calculative.canvas.getFrameProps(r))}}),this.initImageCanvas(n),this.canvas.animate())}pauseAnimate(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:this.store.animates.forEach(n=>{i.push(n)}),i.forEach(n=>{n.calculative.pause||(n.calculative.pause=Date.now())})}stopAnimate(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:this.store.animates.forEach(n=>{i.push(n)}),i.forEach(n=>{n.currentAnimation=void 0,n.calculative.pause=void 0,n.calculative.start=void 0,n.calculative.duration=void 0,n.calculative.animatePos=0,this.store.animates.delete(n),this.canvas.restoreNodeAnimate(n),this.canvas.updateLines(n),this.store.animateMap.delete(n)}),this.initImageCanvas(i),setTimeout(()=>{var n;(n=this.canvas)==null||n.calcActiveRect(),this.render()},20)}startVideo(t){let i;t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(n=>(n.video||n.audio)&&n.autoPlay),i.forEach(n=>{var r,s;(r=n.calculative.media)==null||r.play(),(s=n.onStartVideo)==null||s.call(n,n)})}pauseVideo(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(n=>(n.video||n.audio)&&n.autoPlay),i.forEach(n=>{var r,s;(r=n.calculative.media)==null||r.pause(),(s=n.onPauseVideo)==null||s.call(n,n)})}stopVideo(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(n=>(n.video||n.audio)&&n.autoPlay),i.forEach(n=>{var r;n.calculative.media&&(n.calculative.media.currentTime=0,n.calculative.media.pause()),(r=n.onStopVideo)==null||r.call(n,n)})}calcAnimateDuration(t){return t.frames.reduce((i,n)=>i+n.duration,0)}combine(t=this.store.active,i){if(!t||!t.length)return;const n=ct(t);if(t.length===1&&t[0].type){t[0].type=jt.Node,this.canvas.active(t),this.pushHistory({type:bt.Update,initPens:n,pens:ct(t,!0)}),this.render();return}const r=pi(t);let s={id:It(),name:"combine",...r,children:[],showChild:i};this.canvas.makePen(s);const a=ct(s);let l=1/0;return t.forEach(c=>{var d;const u=this.store.data.pens.findIndex(g=>g.id===c.id);if(u<l&&(l=u),c===s||c.parentId===s.id||c.id===s.id)return;s.children.push(c.id),c.parentId=s.id;const h=mn(c.calculative.worldRect,r);Object.assign(c,h),c.locked=(d=c.lockedOnCombine)!=null?d:Ot.None,c.locked=c.interaction||Tl.includes(c.name)?0:c.locked}),this.store.data.pens.splice(l,0,s),this.store.data.pens.pop(),this.canvas.active([s]),this.pushHistory({type:bt.Add,pens:[a],step:3}),this.pushHistory({type:bt.Update,initPens:[a],pens:[s],step:3}),this.pushHistory({type:bt.Update,initPens:n,pens:t,step:3}),i!=null&&(t.forEach(c=>{Gi(c,!0)}),this.initImageCanvas([s])),this.store.emitter.emit("combine",[s]),this.render(),s}uncombine(t){if(!t&&this.store.active&&(t=this.store.active[0]),!t||!t.children)return;const i=t.children.map(s=>this.store.pens[s]);let n=ct(i);i.forEach(s=>{s.parentId=void 0,s.x=s.calculative.worldRect.x,s.y=s.calculative.worldRect.y,s.width=s.calculative.worldRect.width,s.height=s.calculative.worldRect.height,s.locked=Ot.None,s.calculative.active=void 0,s.calculative.hover=!1,this.setVisible(s,!0)});const r=this.isCombine(t)?3:2;this.pushHistory({type:bt.Update,initPens:n,pens:i,step:r}),n=[ct(t)],t.children=void 0,this.pushHistory({type:bt.Update,initPens:n,pens:[t],step:r}),this.isCombine(t)&&(this.delete([t]),this.store.histories[this.store.histories.length-1].step=r),this.inactive()}appendChild(t=this.store.active){if(!t||t.length<2)return;const i=t.findIndex(n=>n.name==="combine"&&n.showChild!==void 0);if(i!==-1){let n=t[i];const r=pi(t);Object.assign(n,r),Object.assign(n.calculative.worldRect,r),Ir(n),n.children.forEach(s=>{const a=this.store.pens[s],l=mn(a.calculative.worldRect,r);Object.assign(a,l)}),t.forEach(s=>{var a;if(s.id!==n.id){n.children.push(s.id),s.parentId=n.id;const l=mn(s.calculative.worldRect,r);Object.assign(s,l),s.locked=(a=s.lockedOnCombine)!=null?a:Ot.DisableMove,s.locked=s.interaction||Tl.includes(s.name)?0:s.locked,Gi(s,!0)}}),this.initImageCanvas(t),this.render()}else console.warn("Invalid operation!")}updateRectbyChild(t,i,n){if(ae(t),ee(t),i.calculative.worldRect=t,Ji(t,n.calculative.worldRect,!0)){const r=mn(t,n.calculative.worldRect);Object.assign(i,r)}else{let r=Math.min(t.x,n.calculative.worldRect.x),s=Math.min(t.y,n.calculative.worldRect.y),a=Math.max(t.ex,n.calculative.worldRect.ex),l=Math.max(t.ey,n.calculative.worldRect.ey);n.calculative.worldRect={x:r,y:s,width:a-r,height:l-s,ex:a,ey:l},n.parentId||Object.assign(n,n.calculative.worldRect),ee(n.calculative.worldRect),n.children.forEach(c=>{const u=this.store.pens[c],h=mn(u.calculative.worldRect,n.calculative.worldRect);Object.assign(u,h)}),n.parentId&&this.updateRectbyChild(n.calculative.worldRect,n,this.store.pens[n.parentId])}this.canvas.updatePenRect(n),this.render()}isCombine(t){return!!(t.name==="combine"||t.children&&t.children.length>0)}active(t,i=!0){this.canvas.active(t,i)}inactive(){this.canvas.inactive()}activeAll(){this.canvas.active(this.store.data.pens.filter(t=>!t.parentId&&t.locked!==Ot.Disable)),this.render()}focus(t){const i=this.findOne(t);i&&(this.store.hover=i,this.store.hover.calculative.hover=!0,this.showInput(i))}delete(t,i=!1,n=!0){this.canvas.delete(t,i,n)}scale(t,i={x:0,y:0}){this.canvas.scale(t,i)}translate(t,i){this.canvas.translate(t,i)}translatePens(t,i,n){this.canvas.translatePens(t,i,n)}getParent(t,i){return Ze(t,i)}getAllChildren(t){return Ci(t,this.store)}getAllFollowers(t){return Bc(t,this.store)}data(){const t=ct(this.store.data),{pens:i,paths:n}=this.store.data;t.version=kv.version,t.paths={};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&i.find(s=>s.pathId===r)&&(t.paths[r]=n[r]);return t.dataPoints=[...Object.keys(this.store.bind),...Object.keys(this.store.bindDatas)],t}copy(t){this.canvas.copy(t)}cut(t){this.canvas.cut(t)}paste(){this.canvas.paste()}undo(){this.canvas.undo()}redo(){this.canvas.redo()}listenSocket(){try{let t;const i=this.store.data.socketCbJs;if(i&&(t=new Function("e","context",i)),!t)return this.socketFn=null,!1;this.socketFn=t}catch(t){return console.error("Create the function for socket:",t),!1}return!0}connectWebsocket(t){this.closeWebsocket(),t&&(this.store.data.websocket=t),this.store.data.websocket&&(this.websocket=new WebSocket(this.store.data.websocket,this.store.data.websocketProtocols||void 0),this.websocket.onmessage=i=>{this.socketCallback(i.data,{type:"websocket",url:this.store.data.websocket})},this.websocket.onerror=i=>{this.store.emitter.emit("error",{type:"websocket",error:i})},this.websocket.onclose=()=>{if(this.store.options.reconnetTimes&&(this.websocketTimes++,this.websocketTimes>=this.store.options.reconnetTimes)){this.websocketTimes=0,this.closeWebsocket();return}console.info("Canvas websocket closed and reconneting..."),this.connectWebsocket()})}closeWebsocket(){this.websocket&&(this.websocket.onclose=void 0,this.websocket.close(),this.websocket=void 0)}connectMqtt(t){if(this.closeMqtt(),t&&(this.store.data.mqtt=t.mqtt,this.store.data.mqttTopics=t.mqttTopics,this.store.data.mqttOptions=t.mqttOptions),this.store.data.mqtt){this.store.data.mqttOptions.clientId&&!this.store.data.mqttOptions.customClientId&&(this.store.data.mqttOptions.clientId=It());const i={...this.store.data.mqttOptions};i.username||delete i.username,i.password||delete i.password;const{username:n,password:r}=i;n&&r||!n&&!r?(this.mqttClient=ss.exports.connect(this.store.data.mqtt,i),this.mqttClient.on("message",(s,a)=>{this.socketCallback(a.toString(),{topic:s,type:"mqtt",url:this.store.data.mqtt})}),this.mqttClient.on("error",s=>{this.store.emitter.emit("error",{type:"mqtt",error:s})}),this.mqttClient.on("close",()=>{this.store.options.reconnetTimes&&(this.mqttTimes++,this.mqttTimes>=this.store.options.reconnetTimes&&(this.mqttTimes=0,this.closeMqtt()))}),this.store.data.mqttTopics&&this.mqttClient.subscribe(this.store.data.mqttTopics.split(","))):console.warn("\u7F3A\u5C11\u7528\u6237\u540D\u6216\u5BC6\u7801")}}closeMqtt(){var t;(t=this.mqttClient)==null||t.end()}connectHttp(){this.closeHttp();const{https:t}=this.store.data;if(t)this.store.data.cancelFirstConnect||t.forEach(async i=>{this.oldRequestHttp(i)}),t.forEach((i,n)=>{i.http&&(i.times=0,this.httpTimerList[n]=setInterval(async()=>{this.oldRequestHttp(i),this.store.options.reconnetTimes&&(i.times++,i.times>=this.store.options.reconnetTimes&&(i.times=0,clearInterval(this.httpTimerList[n]),this.httpTimerList[n]=void 0))},i.httpTimeInterval||1e3))});else{const{http:i,httpTimeInterval:n,httpHeaders:r}=this.store.data;i&&(this.httpTimer=setInterval(async()=>{const s=await fetch(i,{headers:r});if(s.ok){const a=await s.text();this.socketCallback(a,{type:"http",url:i})}},n||1e3))}}async oldRequestHttp(t){let i=ct(t);if(i.http){const n=await fetch(i.http,{headers:i.httpHeaders,method:i.method||"GET",body:i.method==="POST"?JSON.stringify(i.body):void 0});if(n.ok){const r=await n.text();this.socketCallback(r,{type:"http",url:i.http})}else this.store.emitter.emit("error",{type:"http",error:n})}}async sendDatabyHttp(t){const{https:i}=this.store.data;if(i)i.forEach(async n=>{n.http&&(await fetch(n.http,{method:"post",body:t,headers:n.httpHeaders})).ok&&console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F")});else{const{http:n,httpHeaders:r}=this.store.data;n&&(await fetch(n,{method:"post",body:t,headers:r})).ok&&console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F")}}closeHttp(){clearInterval(this.httpTimer),this.httpTimer=void 0,this.httpTimerList&&this.httpTimerList.forEach(t=>{clearInterval(t),t=void 0})}connectNetwork(){this.closeNetwork();const{networks:t}=this.store.data,i=[];if(t){let n=0;this.mqttClients=[];let r=0,s=0;this.websockets=[],t.forEach(async a=>{if(a.protocol==="mqtt")a.index=n,a.options.clientId&&!a.options.customClientId&&(a.options.clientId=It()),a.times=0,this.mqttClients[n]=ss.exports.connect(a.url,a.options),this.mqttClients[n].on("message",(l,c)=>{this.socketCallback(c.toString(),{topic:l,type:"mqtt",url:a.url})}),this.mqttClients[n].on("error",l=>{this.store.emitter.emit("error",{type:"mqtt",error:l})}),this.mqttClients[n].on("close",()=>{var l;this.store.options.reconnetTimes&&(a.times++,a.times>=this.store.options.reconnetTimes&&(a.times=0,this.mqttClients&&((l=this.mqttClients[a.index])==null||l.end())))}),a.topics&&this.mqttClients[n].subscribe(a.topics.split(",")),n+=1;else if(a.protocol==="websocket")a.index=r,this.connectNetWebSocket(a),r+=1;else if(a.protocol==="http")i.push({url:a.url,interval:a.interval,headers:a.headers||void 0,method:a.method,body:a.body});else if(a.protocol==="iot"){const l=await this.getIotToken(a.devices);a.method==="mqtt"?(a.index=n,this.mqttClients[n]=ss.exports.connect(a.url),this.mqttClients[n].on("message",(c,u)=>{this.socketCallback(u.toString(),{topic:`le5le-iot/properties/${l}`,type:"iot",url:a.url,method:"mqtt"})}),this.mqttClients[n].on("error",c=>{this.store.emitter.emit("error",{type:"mqtt",error:c})}),this.mqttClients[n].subscribe(`le5le-iot/properties/${l}`),n+=1):a.method==="websocket"&&(a.index=r,this.websockets[r]=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/api/ws/iot/properties`,l),this.websockets[r].onmessage=c=>{this.socketCallback(c.data,{type:"iot",method:"websocket"})},this.websockets[r].onerror=c=>{this.store.emitter.emit("error",{type:"websocket",error:c})},r+=1)}else a.protocol==="sql"?(await this.doSqlCode("list",a.dbId,a.sql),a.interval&&(a.index=s,this.sqlTimerList[s]=setInterval(async()=>{await this.doSqlCode("list",a.dbId,a.sql)},a.interval),s+=1)):a.protocol==="jetLinks"&&this.jetLinksList.length&&(this.jetLinksClient=new WebSocket(`${a.url}/${localStorage.getItem("X-Access-Token")||this.getCookie("X-Access-Token")||new URLSearchParams(location.search).get("X-Access-Token")||""}`),this.jetLinksClient.onmessage=l=>{var u;const c=JSON.parse(l.data);if(c.payload&&c.payload.success&&((u=c.payload)==null?void 0:u.properties)){const h=[];for(let d in c.payload.properties)d.startsWith("_")||h.push({id:`${c.payload.headers.productId}#${c.payload.deviceId}#${d}`,value:c.payload.properties[d]});this.setDatas(h,{history:!1})}},this.jetLinksClient.onopen=()=>{this.jetLinksList.forEach(l=>{this.jetLinksClient.send(JSON.stringify({type:"sub",topic:`/device${l.topic}/message/property/report`,parameter:{deviceId:l.deviceId,properties:l.properties,history:1},id:l.topic+"-"+It()}))})})})}this.onNetworkConnect(i)}connectNetWebSocket(t){var i;this.websockets[t.index]&&(this.websockets[t.index].onclose=void 0,(i=this.websockets[t.index])==null||i.close(),this.websockets[t.index]=void 0),this.websockets[t.index]=new WebSocket(t.url,t.protocols||void 0),this.websockets[t.index].onmessage=n=>{this.socketCallback(n.data,{type:"websocket",url:t.url})},this.websockets[t.index].onerror=n=>{this.store.emitter.emit("error",{type:"websocket",error:n})},this.websockets[t.index].onclose=()=>{var n;if(this.store.options.reconnetTimes&&(t.times++,t.times>=this.store.options.reconnetTimes)){t.times=0,this.websockets[t.index].onclose=void 0,(n=this.websockets[t.index])==null||n.close(),this.websockets[t.index]=void 0;return}setTimeout(()=>{console.info("Canvas websocket closed and reconneting..."),this.connectNetWebSocket(t)},2e3)}}async getIotToken(t){const i=await fetch("/api/iot/subscribe/properties",{method:"POST",body:JSON.stringify({devices:t})});if(i.ok){const n=await i.text();return JSON.parse(n).token}}async doSqlCode(t,i,n){const r=await fetch(`/api/iot/data/sql/${t}`,{method:"POST",body:JSON.stringify({dbid:i,sql:n})});if(r.ok){const s=await r.text();s&&this.socketCallback(s,{type:"sql",url:`/api/iot/data/sql/${t}`})}}randomString(t){t=t||32;let i="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",n=i.length,r="";for(let s=0;s<t;s++)r+=i.charAt(Math.floor(Math.random()*n));return r}mockValue(t){let i;if(t.enableMock&&t.mock!==void 0)if(t.type==="float")if(t.mock&&t.mock.indexOf(",")!==-1){let n=t.mock.split(","),r=Math.floor(Math.random()*n.length);i=parseFloat(n[r])}else if(t.mock&&t.mock.indexOf("-")!==-1){let n,r,s,a=t.mock.split("-");if(t.mock.charAt(0)==="-"?a.length===4?(n=-parseFloat(a[3]),r=-parseFloat(a[1]),s=a[3]):(n=parseFloat(a[2]),r=-parseFloat(a[1]),s=a[2]):(n=parseFloat(a[1]),r=parseFloat(a[0]),s=a[1]),(s+"").indexOf(".")!==-1){let l=(s+"").split(".")[1].length;i=(Math.random()*(n-r)+r).toFixed(l)}else i=Math.random()*(n-r)+r}else i=parseFloat(t.mock);else if(t.type==="integer")if(t.mock&&t.mock.indexOf(",")!==-1){let n=t.mock.split(","),r=Math.floor(Math.random()*n.length);i=parseInt(n[r])}else if(t.mock&&t.mock.indexOf("-")!==-1){let n,r,s=t.mock.split("-");t.mock.charAt(0)==="-"?s.length===4?(n=-parseFloat(s[3]),r=-parseFloat(s[1])):(n=parseFloat(s[2]),r=-parseFloat(s[1])):(n=parseInt(s[1]),r=parseInt(s[0])),i=parseInt(Math.random()*(n-r)+r+"")}else i=parseInt(t.mock);else if(t.type==="bool")typeof t.mock=="boolean"?i=t.mock:t.mock==="true"?i=!0:t.mock==="false"?i=!1:i=Math.random()<.5;else if(t.type==="object"||t.type==="array")t.mock;else if(t.mock&&t.mock.indexOf(",")!==-1){let r=t.mock.substring(1,t.mock.length-1).split(","),s=Math.floor(Math.random()*r.length);i=r[s]}else if(t.mock&&t.mock.startsWith("[")&&t.mock.endsWith("]")){let n=parseInt(t.mock.substring(1,t.mock.length-1));i=this.randomString(n)}else i=t.mock;return i}dataMock(){var i,n;let t=[];(n=(i=this.store.data.dataset)==null?void 0:i.devices)==null||n.forEach(r=>{let s=this.mockValue(r);s!==void 0&&t.push({id:r.id,value:s})}),t.length&&this.setDatas(t,{render:!0,doEvent:!0,history:!1})}startDataMock(){this.store.data.enableMock&&(this.stopDataMock(),this.initBinds(),this.updateTimer=setInterval(()=>{this.store.data.pens.forEach(i=>{this.penMock(i)}),this.dataMock(),this.render()},this.store.data.networkInterval||1e3))}stopDataMock(){clearInterval(this.updateTimer),this.updateTimer=void 0}penMock(t){var i;if(t.realTimes){let n={};if(t.realTimes.forEach(r=>{let s=this.mockValue(r);s!==void 0&&(n[r.key]=s)}),Object.keys(n).length){let r=t.onBeforeValue?t.onBeforeValue(t,n):n;this.canvas.updateValue(t,r),(i=t.onValue)==null||i.call(t,t),this.store.emitter.emit("valueUpdate",t)}}}penNetwork(t){const i={url:t.apiUrl,method:t.apiMethod,headers:t.apiHeaders,body:t.apiBody};this.requestHttp(i),t.apiEnable?(this.store.pensNetwork||(this.store.pensNetwork={}),this.store.pensNetwork[t.id]=i):delete this.store.pensNetwork[t.id]}getCookie(t){let i;const n=new RegExp("(^| )"+t+"=([^;]*)(;|$)");return(i=document.cookie.match(n))?decodeURIComponent(i[2]):""}getDynamicParam(t){return Il()[t]||localStorage[t]||this.getCookie(t)||""}onNetworkConnect(t){if(!!(t&&t.length)){if(this.store.pensNetwork)for(let i in this.store.pensNetwork)t.push(this.store.pensNetwork[i]);this.store.data.cancelFirstConnect||t.forEach(async i=>{this.requestHttp(i)}),t.forEach((i,n)=>{i.times=0,this.updateTimerList[n]=setInterval(async()=>{this.requestHttp(i),this.store.options.reconnetTimes&&(i.times++,i.times>=this.store.options.reconnetTimes&&(i.times=0,clearInterval(this.updateTimerList[n]),this.updateTimerList[n]=void 0))},i.interval||1e3)})}}async requestHttp(t){let i=ct(t);if(i.url){if(typeof i.headers=="object"){for(let r in i.headers)if(typeof i.headers[r]=="string"){let s=i.headers[r].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));s&&(i.headers[r]=i.headers[r].replace(`\${${s[0]}}`,this.getDynamicParam(s[0])))}}if(typeof i.body=="object"){for(let r in i.body)if(typeof i.body[r]=="string"){let s=i.body[r].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));s&&(i.body[r]=i.body[r].replace(`\${${s[0]}}`,this.getDynamicParam(s[0])))}}const n=await fetch(i.url,{headers:i.headers,method:i.method,body:i.method==="GET"?void 0:JSON.stringify(i.body)});if(n.ok){const r=await n.text();this.socketCallback(r,{type:"http",url:i.url})}else this.store.emitter.emit("error",{type:"http",error:n})}}closeNetwork(){this.mqttClients&&this.mqttClients.forEach(t=>{t.end()}),this.websockets&&this.websockets.forEach(t=>{t&&(t.onclose=void 0,t.close(),t=void 0)}),this.mqttClients=void 0,this.websockets=void 0,this.updateTimerList&&this.updateTimerList.forEach(t=>{clearInterval(t),t=void 0}),this.sqlTimerList&&this.sqlTimerList.forEach(t=>{clearInterval(t),t=void 0})}socketCallback(t,i){this.store.emitter.emit("socket",{message:t,context:i});let n=t;if(this.socketFn&&(n=this.socketFn(t,{meta2d:this,type:i.type,topic:i.topic,url:i.url,method:i.method}),!n))return;n===!0&&(n=t);let r;if(n.constructor===Object||n.constructor===Array)r=n;else if(typeof n=="string")try{r=JSON.parse(n)}catch(s){console.warn("Invalid socket data:",r,s)}else return;!r||(Array.isArray(r)||(r=[r]),r.length&&(r[0].dataId?this.setDatas(r):r.forEach(s=>{this.setValue(s)})))}setDatas(t,{render:i=!0,doEvent:n=!0,history:r}={}){const s=new Map;t.forEach(c=>{var u,h;(u=this.store.bindDatas[c.dataId])==null||u.forEach(d=>{const g=this.store.pens[d.id];if(!g)return;let v=s.get(g);if(!g.noOnBinds&&typeof g.onBinds=="function"){if(v)return;s.set(g,g.onBinds(g,t,d.formItem));return}v?v[d.formItem.key]=c.value:(v={id:d.id,[d.formItem.key]:c.value},s.set(g,v))}),(h=this.store.bind[c.id||c.dataId])==null||h.forEach(d=>{const g=this.store.pens[d.id];if(!g)return;let v=s.get(g);v?v[d.key]=c.value:(v={id:d.id,[d.key]:c.value},s.set(g,v))})}),this.store.data.locked&&this.doDataEvent(t);let a,l;r&&(a=[]),s.forEach((c,u)=>{this.setValue(c,{render:!1,doEvent:n,history:!1}),r&&(a.push(ct(u,!0)),l.push(u))}),i&&this.render(),r&&this.pushHistory({type:bt.Update,initPens:a,pens:l})}setValue(t,{render:i=!0,doEvent:n=!0,history:r}={}){let s=[];if(!t)return;if(t.id){if(t.id===this.store.data.id){this.setDatabyOptions(t),t.bkImage&&this.setBackgroundImage(t.bkImage),t.background&&this.setBackgroundColor(t.background),this.render();return}const l=this.store.pens[t.id];if(l)s=[l];else{let c=this.store.bind[t.id];if(c&&c.length){s=[],this.setDatas([t],{render:i,doEvent:n,history:r});return}}}else if(t.dataId){s=[],this.setDatas([t],{render:i,doEvent:n,history:r});return}else if(t.tag)s=this.find(t.tag);else{let l=[];for(let c in t)l.push({dataId:c,id:c,value:t[c]});l.length&&this.setDatas(l,{render:i,doEvent:n,history:r});return}r=r&&!this.store.data.locked;let a;if(r&&(a=ct(s)),s.forEach(l=>{var u;const c=l.onBeforeValue?l.onBeforeValue(l,t):t;t.frames&&(this.stopAnimate([l]),t.showDuration||(t.showDuration=t.frames.reduce((h,d)=>h+d.duration,0))),Hc(l,c),this.canvas.updateValue(l,c),(u=l.onValue)==null||u.call(l,l)}),!this.store.data.locked&&this.store.active.length&&!this.canvas.movingPens&&this.canvas.calcActiveRect(),r){let l=ct(s);this.pushHistory({type:bt.Update,initPens:a,pens:l})}n&&s.forEach(l=>{this.store.emitter.emit("valueUpdate",l)}),i&&this.render()}_setValue(t,i=!1){this.setValue(t,{history:i,render:!1,doEvent:!1})}pushHistory(t){this.canvas.pushHistory(t)}showInput(t,i){this.canvas.showInput(t,i)}hideInput(){this.canvas.hideInput()}clearDropdownList(){this.canvas.clearDropdownList()}clearRuleLines(){this.canvas.clearRuleLines()}doMessageEvent(t,i){this.store.messageEvents[t]&&this.store.messageEvents[t].forEach(n=>{let r=!1;n.event.conditions&&n.event.conditions.length?n.event.conditionType==="and"?r=n.event.conditions.every(s=>this.judgeCondition(n.pen,s.key,s)):n.event.conditionType==="or"&&(r=n.event.conditions.some(s=>this.judgeCondition(n.pen,s.key,s))):r=!0,r&&n.event.actions.forEach(s=>{this.events[s.action](n.pen,s)})})}initGlobalTriggers(){var t;this.store.globalTriggers={},(t=this.store.data.triggers)==null||t.forEach(i=>{i.conditions.forEach(n=>{n.source&&(this.store.globalTriggers[n.source]||(this.store.globalTriggers[n.source]=[]),this.store.globalTriggers[n.source].includes(i)||this.store.globalTriggers[n.source].push(i))})})}initMessageEvents(){this.store.messageEvents={},this.store.data.pens.forEach(t=>{var i;(i=t.events)==null||i.forEach(n=>{n.name==="message"&&n.message&&(this.store.messageEvents[n.message]||(this.store.messageEvents[n.message]=[]),this.store.messageEvents[n.message].push({pen:t,event:n}))})})}dataJudegeCondition(t,i,n){const{type:r,target:s,fnJs:a,fn:l,operator:c,valueType:u}=n;let h=!1;if(r==="fn"){if(l)h=l(t,{meta2d:this});else if(a){try{n.fn=new Function("data","context",a)}catch(d){console.error("Error: make function:",d)}n.fn&&(h=n.fn(t,{meta2d:this}))}}else{let d=n.value;u==="prop"&&(d=t[n.value]);let g=t[i];switch(c){case">":h=g>+d;break;case">=":h=g>=+d;break;case"<":h=g<+d;break;case"<=":h=g<=+d;break;case"=":case"==":h=g==d;break;case"!=":h=g!=d;break;case"[)":h=pr(+g,d);break;case"![)":h=!pr(+g,d);break;case"[]":h=wr(g,d);break;case"![]":h=!wr(g,d);break}}return h}judgeCondition(t,i,n){const{type:r,target:s,fnJs:a,fn:l,operator:c,valueType:u}=n;let h=!1;if(r==="fn"){if(l)h=l(t,{meta2d:this});else if(a){try{n.fn=new Function("pen","context",a)}catch(d){console.error("Error: make function:",d)}n.fn&&(h=n.fn(t,{meta2d:this}))}}else{let d=n.value;u==="prop"&&(d=this.store.pens[s][n.value]);let g=Nf(t,i);switch(["x","y","width","height"].includes(i)&&(g=this.getPenRect(t)[i]),c){case">":h=g>+d;break;case">=":h=g>=+d;break;case"<":h=g<+d;break;case"<=":h=g<=+d;break;case"=":case"==":h=g==d;break;case"!=":h=g!=d;break;case"[)":h=pr(+g,d);break;case"![)":h=!pr(+g,d);break;case"[]":h=wr(g,d);break;case"![]":h=!wr(g,d);break}}return h}pushChildren(t,i){const n=[ct(t,!0)],r=[];t.children||(t.children=[]);const s=[];i.forEach(l=>{var h;let c=ct(l,!0);if((!l.id||!this.store.pens[l.id])&&(this.canvas.makePen(l),c=null),l.parentId){const d=this.store.pens[l.parentId],g=d.children.findIndex(v=>v===l.id);n.push(ct(d,!0)),d.children.splice(g,1),s.push(ct(d,!0))}t.children.push(l.id),l.parentId=t.id;const u=mn(l.calculative.worldRect,t.calculative.worldRect);Object.assign(l,u),l.locked=(h=l.lockedOnCombine)!=null?h:Ot.DisableMove,l.locked=l.interaction||Tl.includes(l.name)?0:l.locked,c?(n.push(c),s.push(ct(l,!0))):r.push(ct(l,!0))}),s.push(ct(t,!0));let a=1;r.length&&(a=2,this.pushHistory({type:bt.Add,pens:r,step:a})),this.pushHistory({type:bt.Update,initPens:n,pens:s,step:a})}toPng(t,i,n=!1,r){return this.canvas.toPng(t,i,n,r)}activeToPng(t,i){return this.canvas.activeToPng(t,i)}pensToPng(t=this.store.active,i,n){return this.canvas.pensToPng(t,i,n)}downloadPng(t,i,n){var r;for(const s of this.store.data.pens)(s.calculative.img||["iframe"].includes(s.name))&&((r=s.onRenderPenRaw)==null||r.call(s,s));setTimeout(()=>{const s=document.createElement("a");s.setAttribute("download",(t||this.store.data.name||"le5le.meta2d")+".png"),s.setAttribute("href",this.toPng(i,void 0,!0,n));const a=document.createEvent("MouseEvents");a.initEvent("click",!0,!0),s.dispatchEvent(a)},1e3)}downloadSvg(){if(!window.C2S)throw console.error("\u8BF7\u5148\u52A0\u8F7D\u4E50\u543E\u4E50\u5B98\u7F51\u4E0B\u7684canvas2svg.js","https://assets.le5lecdn.com/2d/canvas2svg.js"),new Error("\u8BF7\u5148\u52A0\u8F7D\u4E50\u543E\u4E50\u5B98\u7F51\u4E0B\u7684canvas2svg.js");const t=this.getRect();t.x-=10,t.y-=10;const i=new window.C2S(t.width+20,t.height+20);i.textBaseline="middle";for(const u of this.store.data.pens)u.visible==!1||!Va(u,this.store)||ja(i,u,t,!0);let n=i.getSerializedSvg();this.store.data.background?(n=n.replace("{{bk}}",""),n=n.replace("{{bkRect}}",`<rect x="0" y="0" width="100%" height="100%" fill="${this.store.data.background}"></rect>`)):(n=n.replace("{{bk}}",""),n=n.replace("{{bkRect}}","")),n=n.replace(/--le5le--/g,"&#x");const r=window.URL,s=new Blob([n]),a=r.createObjectURL(s),l=document.createElement("a");l.setAttribute("download",`${this.store.data.name||"le5le.meta2d"}.svg`),l.setAttribute("href",a);const c=document.createEvent("MouseEvents");c.initEvent("click",!0,!0),l.dispatchEvent(c)}getRect(t=this.store.data.pens){return pi(t)}hiddenTemplate(){this.canvas.canvasTemplate.hidden()}showTemplate(){this.canvas.canvasTemplate.show()}lockTemplate(t){this.store.data.pens.forEach(i=>{i.canvasLayer===zt.CanvasTemplate&&(i.locked=t)})}fitView(t=!0,i=10){var d,g;if(!this.hasView())return;const{canvas:n}=this.canvas,{offsetWidth:r,offsetHeight:s}=n;this.resize(r,s);const a=Xi(i),l=this.getRect(),c=(r-a[1]-a[3])/l.width,u=(s-a[0]-a[2])/l.height;let h=c;t?h=c>u?u:c:h=c>u?c:u,(d=this.store.data.fits)!=null&&d.length&&(this.canvas.opening=!0),this.scale(h*this.store.data.scale),this.centerView(),(g=this.store.data.fits)!=null&&g.length&&this.fillView()}fillView(){var r,s;const t=this.getRect(),i=this.canvas.width-t.width,n=this.canvas.height-t.height;if(Math.abs(i)>10){(r=this.store.data.fits)==null||r.forEach(l=>{let c=[];l.children.forEach(h=>{this.store.pens[h].locked=Ot.None,c.push(this.store.pens[h])});let u=i/2;if(l.left&&l.right){let h=l.leftValue,d=l.rightValue;h?h=Math.abs(h)<1?h*this.canvas.width:h:h=0,d?d=Math.abs(d)<1?d*this.canvas.width:d:d=0;let g=(this.canvas.width-h-d)/(t.width-h-d);c.forEach(v=>{var y;v.image&&v.imageRatio&&v.calculative.worldRect.width/this.canvas.width>.1&&(v.imageRatio=!1),v.calculative.worldRect.x=t.x-i/2+h+(v.calculative.worldRect.x-t.x)*g,v.calculative.worldRect.width*=g,v.calculative.worldRect.ex=v.calculative.worldRect.x+v.calculative.worldRect.width,v.calculative.width=v.calculative.worldRect.width,v.calculative.x=v.calculative.worldRect.x,v.width=v.calculative.worldRect.width,v.x=v.calculative.worldRect.x,this.canvas.updatePenRect(v,{worldRectIsReady:!1}),v.externElement&&((y=v.onResize)==null||y.call(v,v))})}else l.left?(u=-u,l.leftValue&&(u+=Math.abs(l.leftValue)<1?l.leftValue*this.canvas.width:l.leftValue),this.translatePens(c,u,0)):l.right&&(l.rightValue&&(u=u-(Math.abs(l.rightValue)<1?l.rightValue*this.canvas.width:l.rightValue)),this.translatePens(c,u,0))});const a=this.store.data.pens.filter(l=>l.name==="iframe");a==null||a.forEach(l=>{var u,h;const c=l.calculative.worldRect;if(c.width/this.store.data.scale>t.width*.8){let d=c.width;l.calculative.worldRect.x=c.x-i/2,l.calculative.worldRect.width=c.width+i,l.calculative.worldRect.ex=c.ex+i,l.operationalRect.x=l.operationalRect.x*d/l.calculative.worldRect.width,l.operationalRect.width=(l.calculative.worldRect.width-(1-l.operationalRect.width)*d)/l.calculative.worldRect.width,(u=l.onBeforeValue)==null||u.call(l,l,{operationalRect:l.operationalRect}),(h=l.onResize)==null||h.call(l,l)}})}if(Math.abs(n)>10){(s=this.store.data.fits)==null||s.forEach(l=>{let c=[];l.children.forEach(h=>{this.store.pens[h].locked=Ot.None,c.push(this.store.pens[h])});let u=n/2;if(l.top&&l.bottom){let h=l.topValue,d=l.bottomValue;h?h=Math.abs(h)<1?h*this.canvas.height:h:h=0,d?d=Math.abs(d)<1?d*this.canvas.height:d:d=0;let g=(this.canvas.height-h-d)/(t.height-h-d);c.forEach(v=>{var y;v.image&&v.imageRatio&&v.calculative.worldRect.height/this.canvas.height>.1&&(v.imageRatio=!1),v.calculative.worldRect.y=t.y-n/2+h+(v.calculative.worldRect.y-t.y)*g,v.calculative.worldRect.height*=g,v.calculative.worldRect.ey=v.calculative.worldRect.y+v.calculative.worldRect.height,v.calculative.height=v.calculative.worldRect.height,v.calculative.y=v.calculative.worldRect.y,v.height=v.calculative.worldRect.height,v.y=v.calculative.worldRect.y,this.canvas.updatePenRect(v,{worldRectIsReady:!1}),v.externElement&&((y=v.onResize)==null||y.call(v,v))})}else l.top?(u=-u,l.topValue&&(u+=Math.abs(l.topValue)<1?l.topValue*this.canvas.height:l.topValue),this.translatePens(c,0,u)):l.bottom&&(l.bottomValue&&(u=u-(Math.abs(l.bottomValue)<1?l.bottomValue*this.canvas.height:l.bottomValue)),this.translatePens(c,0,u))});const a=this.store.data.pens.filter(l=>l.name==="iframe");a==null||a.forEach(l=>{var u,h;const c=l.calculative.worldRect;if(c.height/this.store.data.scale>t.height*.8){let d=c.height;l.calculative.worldRect.y=c.y-n/2,l.calculative.worldRect.height=c.height+n,l.calculative.worldRect.ey=c.ey+n,l.operationalRect.y=l.operationalRect.y*d/l.calculative.worldRect.width,l.operationalRect.height=(l.calculative.worldRect.height-(1-l.operationalRect.height)*d)/l.calculative.worldRect.height,(u=l.onBeforeValue)==null||u.call(l,l,{operationalRect:l.operationalRect}),(h=l.onResize)==null||h.call(l,l)}})}this.canvas.canvasTemplate.init(),this.canvas.canvasImage.init(),this.canvas.canvasImageBottom.init(),this.render(!0)}trimPens(){let t=this.store.data.pens.filter(i=>i.name==="line"&&i.anchors.length<2);this.delete(t)}fitTemplateView(t=!0,i=10){if(!this.hasView())return;const{canvas:n}=this.canvas,{offsetWidth:r,offsetHeight:s}=n,a=Xi(i),l=this.getRect(),c=(r-a[1]-a[3])/l.width,u=(s-a[0]-a[2])/l.height;let h=c;t?h=c>u?u:c:h=c>u?c:u,this.canvas.templateScale(h*this.store.data.scale);let d=this.getRect(),g=this.store.data.pens.filter(v=>!v.parentId);this.canvas.templateTranslatePens(g,-d.x,-d.y),this.store.data.pens.forEach(v=>{v.type?this.canvas.initLineRect(v):this.canvas.updateLines(v)}),this.centerView()}fitSizeView(t=!0,i=10){var g,v;const{canvas:n}=this.canvas,{offsetWidth:r,offsetHeight:s}=n;this.resize(r,s);const a=Xi(i),l=(this.store.data.width||this.store.options.width)*this.store.data.scale,c=(this.store.data.height||this.store.options.height)*this.store.data.scale,u=(r-a[1]-a[3])/l,h=(s-a[0]-a[2])/c;let d=u;t==="width"?d=u:t==="height"?d=h:t?d=u>h?h:u:d=u>h?u:h,(g=this.store.data.fits)!=null&&g.length&&(this.canvas.opening=!0),this.scale(d*this.store.data.scale),this.centerSizeView(),(v=this.store.data.fits)!=null&&v.length&&this.fillView()}centerSizeView(){const t=this.getViewCenter(),i=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height,r={x:0,y:0,width:i,height:n};ee(r);const{center:s}=r,{scale:a,origin:l,x:c,y:u}=this.store.data;this.translate((t.x-l.x)/a-s.x-c/a,(t.y-l.y)/a-s.y-u/a);const{canvas:h}=this.canvas,d=(h.scrollWidth-h.offsetWidth)/2,g=(h.scrollHeight-h.offsetHeight)/2;h.scrollTo(d,g)}scrollView(t=10,i=!1){if(!this.hasView()||!this.canvas.scroll)return;const{canvas:n}=this.canvas,{offsetWidth:r,offsetHeight:s}=n;this.resize(r,s);const a=Xi(t),l=this.getRect(),c=(r-a[1]-a[3])/l.width;this.scale(c*this.store.data.scale),this.topView(a[0]),i&&this.canvas.scroll.changeMode()}screenView(t=10,i=!0){if(!this.hasView())return;const{canvas:n}=this.canvas,{offsetWidth:r,offsetHeight:s}=n;this.resize(r,s);const a=Xi(t),l=this.getRect();let c=(r-a[1]-a[3])/l.width;i||(c=(s-a[0]-a[2])/l.height),this.scale(c*this.store.data.scale),this.topView(a[0])}topView(t=10){if(!this.hasView())return;const i=this.getRect(),n=this.getViewCenter(),r=this.getPenRect(i);ee(r);const{center:s}=r,{scale:a,origin:l,x:c,y:u}=this.store.data;this.translate((n.x-l.x)/a-s.x-c/a,(t-l.y)/a-r.y-u/a);const{canvas:h}=this.canvas,d=(h.scrollWidth-h.offsetWidth)/2,g=(h.scrollHeight-h.offsetHeight)/2;h.scrollTo(d,g)}centerView(){if(!this.hasView())return;const t=this.getRect(),i=this.getViewCenter(),n=this.getPenRect(t);ee(n);const{center:r}=n,{scale:s,origin:a,x:l,y:c}=this.store.data;this.translate((i.x-a.x)/s-r.x-l/s,(i.y-a.y)/s-r.y-c/s);const{canvas:u}=this.canvas,h=(u.scrollWidth-u.offsetWidth)/2,d=(u.scrollHeight-u.offsetHeight)/2;u.scrollTo(h,d)}hasView(){return!!this.store.data.pens.filter(t=>!t.isRuleLine).length}getViewCenter(){const{width:t,height:i}=this.canvas;return{x:t/2,y:i/2}}beSameByFirst(t=this.store.data.pens,i){const n=ct(t),r=t[0],{width:s,height:a}=this.getPenRect(r);for(let l=1;l<t.length;l++){const c=t[l];i==="width"?this.setValue({id:c.id,width:s},{render:!1,doEvent:!1}):i==="height"?this.setValue({id:c.id,height:a},{render:!1,doEvent:!1}):this.setValue({id:c.id,width:s,height:a},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:n,pens:t})}beSameByLast(t=this.store.data.pens,i){const n=ct(t),r=t[t.length-1],{width:s,height:a}=this.getPenRect(r);for(let l=0;l<t.length-1;l++){const c=t[l];i==="width"?this.setValue({id:c.id,width:s},{render:!1,doEvent:!1}):i==="height"?this.setValue({id:c.id,height:a},{render:!1,doEvent:!1}):this.setValue({id:c.id,width:s,height:a},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:n,pens:t})}formatPainterByFirst(t=this.store.data.pens){const i=ct(t),n=t[0],r={};is.forEach(s=>{r[s]=n[s]});for(let s=1;s<t.length;s++){const a=t[s];this.setValue({id:a.id,...r},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:i,pens:t})}formatPainterByLast(t=this.store.data.pens){const i=ct(t),n=t[t.length-1],r={};is.forEach(s=>{r[s]=n[s]});for(let s=0;s<t.length-1;s++){const a=t[s];this.setValue({id:a.id,...r},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:i,pens:t})}setFormatPainter(){const t=this.store.active,i={};if(t.length>0){const n=t[0];is.forEach(r=>{i[r]=n[r]!==void 0?n[r]:this.store.options.defaultFormat[r]||this.store.data[r]||this.store.options[r]})}else is.forEach(n=>{this.store.options.defaultFormat[n]||this.store.data[n]||this.store.options[n]});localStorage.setItem("meta2d-formatPainter",JSON.stringify(i))}formatPainter(){const t=this.store.active,i=ct(t),n=JSON.parse(localStorage.getItem("meta2d-formatPainter"));for(let r=0;r<t.length;r++){const s=t[r];this.setValue({id:s.id,...n},{render:!1,doEvent:!1})}this.render(),this.pushHistory({type:bt.Update,initPens:i,pens:t})}clearFormatPainter(){const t=this.store.active,i=ct(t);is.forEach(n=>{for(let r=0;r<t.length;r++){const s=t[r],{fontSize:a,lineHeight:l}=this.store.options;n==="lineWidth"?(s.lineWidth=1,s.calculative.lineWidth=1):n==="fontSize"?(s.fontSize=a,s.calculative.fontSize=a):n==="lineHeight"?(s.lineHeight=l,s.calculative.lineHeight=l):(delete s[n],delete s.calculative[n])}}),this.render(),this.pushHistory({type:bt.Update,initPens:i,pens:t})}alignNodes(t,i=this.store.data.pens,n){!n&&(n=this.getPenRect(this.getRect(i)));const r=ct(i);for(const s of i)this.alignPen(t,s,n);this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:r,pens:i})}alignNodesV(t,i=this.store.data.pens,n=!1){const r=this.store.data.width||this.store.options.width,s=this.store.data.height||this.store.options.height;let a={x:0,y:0,width:r,height:s};const l=ct(i);if(n){const c=this.store.data.scale,u=this.getRect(i),h=(u.x-this.store.data.origin.x)/c,d=(u.y-this.store.data.origin.y)/c,g=u.width/c,v=u.height/c;let y=0,w=0;switch(t){case"left":y=-h;break;case"right":y=r-(h+g);break;case"top":w=-d;break;case"bottom":w=s-(d+v);break;case"center":y=r/2-(h+g/2);break;case"middle":w=s/2-(d+v/2);break}this.translatePens(i,y*c,w*c)}else for(const c of i)this.alignPen(t,c,a);this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:l,pens:i})}alignNodesByFirst(t,i=this.store.data.pens){const n=ct(i),r=i[0],s=this.getPenRect(r);for(let a=1;a<i.length;a++){const l=i[a];this.alignPen(t,l,s)}this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:n,pens:i})}alignNodesByLast(t,i=this.store.data.pens){const n=ct(i),r=i[i.length-1],s=this.getPenRect(r);for(let a=0;a<i.length-1;a++){const l=i[a];this.alignPen(t,l,s)}this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:n,pens:i})}alignPen(t,i,n){const r=this.getPenRect(i);switch(t){case"left":r.x=n.x;break;case"right":r.x=n.x+n.width-r.width;break;case"top":r.y=n.y;break;case"bottom":r.y=n.y+n.height-r.height;break;case"center":r.x=n.x+n.width/2-r.width/2;break;case"middle":r.y=n.y+n.height/2-r.height/2;break}this.setValue({id:i.id,...r},{render:!1,doEvent:!1})}spaceBetweenByDirection(t,i=this.store.data.pens,n){if(!n){let u=1/0,h=-1/0,d=t==="width"?"x":"y";i.forEach(g=>{u=Math.min(u,g.calculative.worldRect[d]),h=Math.max(h,g.calculative.worldRect["e"+d])}),n=(h-u)/this.store.data.scale}if(i=i.filter(u=>!u.parentId),i.length<=2)return;const r=ct(i),s=i.reduce((u,h)=>{const d=this.getPenRect(h);return u+d[t]},0),a=(n-s)/(i.length-1);i=i.sort((u,h)=>t==="width"?u.x-h.x:u.y-h.y);const l=this.getPenRect(i[0]);let c=t==="width"?l.x:l.y;for(const u of i){const h=this.getPenRect(u);t==="width"?h.x=c:h.y=c,c+=h[t]+a,this.setValue({id:u.id,...h},{render:!1,doEvent:!1})}this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:r,pens:i})}spaceBetween(t,i){this.spaceBetweenByDirection("width",t,i)}spaceBetweenColumn(t,i){this.spaceBetweenByDirection("height",t,i)}layout(t=this.store.data.pens,i,n=30){const r=this.getPenRect(pi(t));!i&&(i=r.width),t=t.filter(u=>!u.type&&!u.parentId);const s=ct(t);let a=0;t.forEach(u=>{const h=this.getPenRect(u);h.height>a&&(a=h.height)});let l=r.x,c=r.y;t.forEach((u,h)=>{const d=this.getPenRect(u);if(d.x=l,d.y=c+a/2-d.height/2,this.setValue({id:u.id,...d},{render:!1,doEvent:!1}),h===t.length-1)return;const g=l+d.width-r.x,v=this.getPenRect(t[h+1]);Math.round(i-g)>=Math.round(v.width+n)?l+=d.width+n:(l=r.x,c+=a+n)}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.render(),this.pushHistory({type:bt.Update,initPens:s,pens:t})}gotoView(t){const i=this.getViewCenter(),n=i.x-t.calculative.worldRect.x-t.calculative.worldRect.width/2,r=i.y-t.calculative.worldRect.y-t.calculative.worldRect.height/2;this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.translate(n-this.store.data.x,r-this.store.data.y),this.store.data.x=n,this.store.data.y=r;for(const s of this.store.data.pens)Gi(s);this.canvas.canvasImage.init(),this.canvas.canvasImageBottom.init(),this.render()}showMap(){this.map||(this.map=new eE(this.canvas)),this.map.show()}hideMap(){this.map.hide()}onSizeUpdate(){this.mapTimer&&(clearTimeout(this.mapTimer),this.mapTimer=void 0),this.mapTimer=setTimeout(()=>{this.map&&this.map.isShow&&this.map.show(),this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.resize()},500)}toggleAnchorMode(){this.canvas.toggleAnchorMode()}addAnchorHand(){this.canvas.addAnchorHand()}removeAnchorHand(){this.canvas.removeAnchorHand()}toggleAnchorHand(){this.canvas.toggleAnchorHand()}top(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const n=this.store.data.pens,r=[...Ci(i,this.store),i].map(a=>a.id);n.filter(a=>r.includes(a.id)).forEach(a=>{const l=n.findIndex(c=>c.id===a.id);l>-1&&(n.push(n[l]),n.splice(l,1),this.initTemplateCanvas([a]),this.initImageCanvas([a])),this.specificLayerMove(a,"top")})}this.store.emitter.emit("layer",{type:"top",pens:t})}initImageCanvas(t){this.canvas.initImageCanvas(t)}initTemplateCanvas(t){this.canvas.initTemplateCanvas(t)}bottom(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const n=this.store.data.pens,r=[...Ci(i,this.store),i].map(a=>a.id),s=n.filter(a=>r.includes(a.id));for(let a=s.length-1;a>=0;a--){const l=s[a],c=n.findIndex(u=>u.id===l.id);c>-1&&(n.unshift(n[c]),n.splice(c+1,1),this.initTemplateCanvas([l]),this.initImageCanvas([l])),this.specificLayerMove(l,"bottom")}}this.store.emitter.emit("layer",{type:"bottom",pens:t})}upByArea(t){if(this.store.data.pens.findIndex(c=>c.id===t.id)===-1){console.warn("upByArea: pen not in canvas");return}const n=[t,...Ci(t,this.store)];let r=n.map(c=>this.store.data.pens.findIndex(u=>u.id===c.id));r.includes(-1)&&(console.warn("upByArea: pen children not in canvas"),r=r.filter(c=>c!==-1));const s=Math.min(...r),a=t.calculative.worldRect,l=this.store.data.pens.findIndex((c,u)=>{if(u<=s||c.id===t.id||H_(c,t))return!1;const h=c.calculative.worldRect;return Ji(a,h)});if(l===-1){this.up(t);return}this.store.data.pens.splice(l+1,0,...n);for(const c of n){const u=this.store.data.pens.findIndex(h=>h.id===c.id);u>-1&&this.store.data.pens.splice(u,1)}this.initImageCanvas([t])}specificLayerMove(t,i){var n;if(t.image&&t.name!=="gif"){let r=zt.CanvasImageBottom;i==="top"?r=zt.CanvasImage:(i==="up"||i==="down")&&(r=zt.CanvasMain),this.setValue({id:t.id,canvasLayer:r},{render:!1,doEvent:!1,history:!1})}else if(t.externElement||t.name==="gif"){let r=0;i==="top"?(t.calculative.canvas.maxZindex+=1,r=t.calculative.canvas.maxZindex):i==="up"?r=t.calculative.zIndex===void 0?6:t.calculative.zIndex+1:i==="down"&&(r=t.calculative.zIndex===void 0?3:t.calculative.zIndex-1,r<0&&(r=0)),this.setValue({id:t.id,zIndex:r},{render:!1,doEvent:!1,history:!1}),(n=t.calculative.singleton)!=null&&n.div&&ti(t,t.calculative.singleton.div)}}up(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const n=this.store.data.pens;if(i.children&&i.children.length){const r=[...Ci(i,this.store),i],s=[];for(let c=0;c<n.length;c++){const u=n[c];r.findIndex(h=>h.id===u.id)!==-1&&(u.temIndex=c,s.push(u))}let a=-1,l=0;s.forEach(c=>{c.temIndex-=l,n.splice(c.temIndex,1),l+=1,a=c.temIndex,delete c.temIndex,this.specificLayerMove(c,"up")}),n.splice(a+1,0,...s),this.initTemplateCanvas(s),this.initImageCanvas(s)}else{const r=n.findIndex(s=>s.id===i.id);r>-1&&r!==n.length-1&&(n.splice(r+2,0,n[r]),n.splice(r,1),this.initTemplateCanvas([i]),this.initImageCanvas([i])),this.specificLayerMove(i,"up")}}this.store.emitter.emit("layer",{type:"up",pens:t})}down(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const n=this.store.data.pens;if(i.children&&i.children.length){const r=[...Ci(i,this.store),i],s=[];for(let c=0;c<n.length;c++){const u=n[c];r.findIndex(h=>h.id===u.id)!==-1&&(u.temIndex=c,s.push(u))}let a=-1,l=0;s.forEach((c,u)=>{c.temIndex-=l,n.splice(c.temIndex,1),l+=1,u===0&&(a=c.temIndex),delete c.temIndex,this.specificLayerMove(c,"down")}),n.splice(a-1,0,...s),this.initTemplateCanvas(s),this.initImageCanvas(s)}else{const r=n.findIndex(s=>s.id===i.id);r>-1&&r!==0&&(n.splice(r-1,0,n[r]),n.splice(r+1,1),this.initTemplateCanvas([i]),this.initImageCanvas([i])),this.specificLayerMove(i,"down")}}this.store.emitter.emit("layer",{type:"down",pens:t})}setLayer(t,i,n=this.store.data.pens){const r=n.findIndex(s=>s.id===t.id);r>-1&&(r>i?(n.splice(i,0,n[r]),n.splice(r+1,1)):r<i&&(n.splice(i,0,n[r]),n.splice(r,1)))}changePenId(t,i){this.canvas.changePenId(t,i)}getLines(t,i="all"){var r;if(t.type===jt.Line)return[];const n=[];return(r=t.connectedLines)==null||r.forEach(({lineId:s})=>{const a=this.store.pens[s];if(!a){console.warn(t,"node contain a error connectedLine");return}if(!n.find(l=>l.id===a.id))switch(i){case"all":n.push(a);break;case"in":qt(a).connectTo===t.id&&n.push(a);break;case"out":le(a).connectTo===t.id&&n.push(a);break}}),n}nextNode(t){if(t.type===jt.Line){const i=this.store.pens[qt(t).connectTo];return i?[i]:[]}else{const i=this.getLines(t,"out"),n=[];return i.forEach(r=>{const s=this.nextNode(r);for(const a of s)!n.find(c=>c.id===a.id)&&n.push(a)}),n}}previousNode(t){if(t.type===jt.Line){const i=this.store.pens[le(t).connectTo];return i?[i]:[]}else{const i=this.getLines(t,"in"),n=[];return i.forEach(r=>{const s=this.previousNode(r);for(const a of s)!n.find(c=>c.id===a.id)&&n.push(a)}),n}}getNext(t){var n;if(t.type===jt.Line){console.warn("\u975E\u8FDE\u7EBF\u8282\u70B9");return}const i=[];return(n=t.connectedLines)==null||n.forEach(({lineId:r,anchor:s})=>{var c,u;const a=(c=t.anchors)==null?void 0:c.filter(h=>h.id===s)[0],l=this.findOne(r);if(l.anchors[0].connectTo==t.id){const h=l.anchors[l.anchors.length-1].connectTo;if(h){const d=this.findOne(h),g=(u=d.connectedLines)==null?void 0:u.filter(y=>y.lineId===l.id)[0],v=d.anchors.filter(y=>y.id===g.anchor)[0];i.push({from:t,fromAnchor:a,line:l,to:d,toAnchor:v})}}}),i}addAnchor(t,i,n){if(!t)return;if(t.anchors||(t.anchors=[]),t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.type===jt.Line&&(n<0&&(n=t.anchors.length+1+n),n>t.anchors.length&&(n=t.anchors.length),n<0&&(n=0),n==0&&t.anchors[0].connectTo||n==t.anchors.length&&t.anchors[n-1].connectTo)){console.warn("\u7AEF\u70B9\u5B58\u5728\u8FDE\u63A5\u5173\u7CFB");return}let r=null,s=null;i.x<=1&&i.x>=0&&i.y<=1&&i.y>=0?(s={id:i.id||It(),penId:t.id,x:t.calculative.worldRect.x+t.calculative.worldRect.width*i.x,y:t.calculative.worldRect.y+t.calculative.worldRect.height*i.y},t.calculative.worldRect&&t.rotate%360&&Gt(s,t.rotate,t.calculative.worldRect.center),r={id:s.id,penId:t.id,x:i.x,y:i.y}):(s={id:i.id||It(),penId:t.id,x:i.x,y:i.y},t.calculative.worldRect&&(t.rotate%360&&Gt(i,-t.rotate,t.calculative.worldRect.center),r={id:s.id,penId:t.id,x:(i.x-t.calculative.worldRect.x)/t.calculative.worldRect.width,y:(i.y-t.calculative.worldRect.y)/t.calculative.worldRect.height})),t.type===jt.Line?(t.calculative.worldAnchors.splice(n,0,s),t.anchors.splice(n,0,r),this.canvas.updateLines(t),this.canvas.initLineRect(t),this.render()):(t.calculative.worldAnchors.push(s),t.anchors.push(r))}connectLine(t,i,n,r,s=!0){if(!n){const u=i.calculative.worldRect;n=Cr(t,{x:u.x+u.width/2,y:u.y+u.height/2})}if(!r){const u=t.calculative.worldRect;r=Cr(i,{x:u.x+u.width/2,y:u.y+u.height/2})}const a=Math.abs(n.x-r.x),c={height:Math.abs(n.y-r.y),lineName:"line",lineWidth:1,name:"line",type:1,width:a,x:Math.min(n.x,r.x),y:Math.min(n.y,r.y),anchors:[{x:n.x>r.x?1:0,y:n.y>r.y?1:0,id:It()},{x:n.x>r.x?0:1,y:n.x>r.x?0:1,id:It()}]};return this.addPens([c]),we(t,n,c,c.calculative.worldAnchors[0]),we(i,r,c,c.calculative.worldAnchors[1]),c.calculative.active=!1,this.canvas.updateLines(c),this.canvas.updateLines(t),this.canvas.updateLines(i),this.canvas.initLineRect(c),s&&this.render(),c}toComponent(t=this.store.data.pens,i,n){if(t.length===1){const h=ct(t[0]);return h.type=jt.Node,h.id=void 0,[h]}const r=ct(t,!0),s=pi(r);let a={id:It(),name:"combine",...s,children:[],showChild:i};n&&(a.anchors=[{id:"0",penId:a.id,x:.5,y:0},{id:"1",penId:a.id,x:1,y:.5},{id:"2",penId:a.id,x:.5,y:1},{id:"3",penId:a.id,x:0,y:.5}]);const l=r.filter(h=>!h.parentId),c=r.find(h=>h.width===s.width&&h.height===s.height),u=c&&i===void 0;return l.length===1?a=l[0]:u&&(c.children||(c.children=[]),a=c),r.forEach(h=>{var g;if(h===a||h.parentId===a.id||h.parentId)return;a.children.push(h.id),h.parentId=a.id;const d=mn(h.calculative.worldRect,s);Object.assign(h,d),h.locked=(g=h.lockedOnCombine)!=null?g:Ot.DisableMove}),u||l.length===1?ct(r):ct([a,...r])}installPenPlugins(t,i){if(!t.tag&&!t.name&&!t.id)return;let n;t.id?n="id":t.tag?n="tag":t.name&&(n="name"),i.forEach(r=>{let s=r.plugin,a=r.options;if(!!s&&_2(s)&&n)if(s.install(t,a),!this.penPluginMap.has(s))this.penPluginMap.set(s,[{[n]:t[n],option:a}]);else{let l=this.penPluginMap.get(s).find(c=>c[n]===t[n]);l?l.option=a:this.penPluginMap.get(s).push({[n]:t[n],option:a})}})}uninstallPenPlugins(t,i){let n;t.id?n="id":t.tag?n="tag":t.name&&(n="name"),n&&i.forEach(r=>{let s=r.plugin;s.uninstall(t,r.options);let a=this.penPluginMap.get(s),l=a.findIndex(c=>c[n]===t[n]);l!==-1&&(a.splice(l,1),a.length===0&&this.penPluginMap.delete(s))})}setVisible(t,i,n=!0){if(this.onSizeUpdate(),this.setValue({id:t.id,visible:i},{render:!1,doEvent:!1}),t.children)for(const s of t.children){const a=this.store.pens[s];a&&this.setVisible(a,i,!1)}let r=Ci(t,this.store);r.push(t),this.initImageCanvas(r),n&&this.render()}clearHover(){this.canvas.clearHover()}closeSocket(){this.closeWebsocket(),this.closeMqtt(),this.closeHttp()}destroy(t){if(this.clear(!1),this.stopDataMock(),this.closeSocket(),this.closeNetwork(),this.closeAll(),this.store.emitter.all.clear(),this.canvas.destroy(),this.canvas=void 0,At[this.store.id]=void 0,!t){for(const i in At)delete At[i];At.path2dDraws={},At.canvasDraws={},At.anchors={},At.htmlElements={}}}}function nE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,ey:a}=e.calculative.worldRect,l=s/4;if(i.moveTo(n+l,r),i.lineTo(n,r),i.lineTo(n,a),i.lineTo(n+l,a),i instanceof Path2D)return i}function rE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,ex:a,ey:l}=e.calculative.worldRect,c=e.offsetX;let u=s/7;if(c>1?u=c:c>0&&(u=s*c),i.moveTo(n+u,r),i.lineTo(a,r),i.lineTo(n+s-u,l),i.lineTo(n,l),i.closePath(),i instanceof Path2D)return i}function sE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a,ex:l,ey:c}=e.calculative.worldRect,u=s/8;if(i.moveTo(n+u,r),i.lineTo(l-u,r),i.bezierCurveTo(l+u/3,r,l+u/3,c,l-u,c),i.lineTo(n+u,c),i.lineTo(n,r+a/2),i.closePath(),i instanceof Path2D)return i}function aE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a,ex:l,center:c}=e.calculative.worldRect,u=c.x,h=r+a*6/7,d=a/6;if(i.moveTo(n,r),i.lineTo(l,r),i.lineTo(l,h),i.bezierCurveTo(l-20,h-d,u+s/5,h-d,u,h),i.bezierCurveTo(u-s/5,h+d,n,h+d,n,h),i.closePath(),i instanceof Path2D)return i}function oE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,ex:a,ey:l}=e.calculative.worldRect,c=s/10;if(i.moveTo(n+c*2,r),i.bezierCurveTo(n-c*2/3,r,n-c*2/3,l,n+c*2,l),i.lineTo(a,l),i.bezierCurveTo(a-c,l,a-c,r,a,r),i.closePath(),i instanceof Path2D)return i}function lE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,ex:a,ey:l}=e.calculative.worldRect;i.moveTo(n,r),i.lineTo(a,r),i.lineTo(a,l),i.lineTo(n,l),i.closePath();const c=s/7;if(i.moveTo(n,r+c),i.lineTo(a,r+c),i.moveTo(n+c,r),i.lineTo(n+c,l),i instanceof Path2D)return i}function cE(e,t){const i=t||new Path2D,{x:n,y:r,height:s,ex:a,ey:l}=e.calculative.worldRect,c=s/4;if(i.moveTo(n,r+c),i.lineTo(a,r),i.lineTo(a,l),i.lineTo(n,l),i.closePath(),i instanceof Path2D)return i}function hE(e,t){const i=t||new Path2D,{x:n,y:r,ex:s,ey:a}=e.calculative.worldRect;if(i.moveTo(n,r),i.lineTo(s,r),i.moveTo(n,a),i.lineTo(s,a),i instanceof Path2D)return i}function uE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a,ex:l,ey:c}=e.calculative.worldRect;if(i.ellipse(n+s/2,r+a/2,s/2,a/2,0,0,Math.PI*2),i.moveTo(n+s/2,c),i.lineTo(l,c),i.closePath(),i instanceof Path2D)return i}function fE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,ex:a,ey:l}=e.calculative.worldRect,c=s/7;if(i.moveTo(n,r),i.lineTo(a,r),i.lineTo(a,l),i.lineTo(n,l),i.closePath(),i.moveTo(n+c,r),i.lineTo(n+c,l),i.moveTo(a-c,r),i.lineTo(a-c,l),i instanceof Path2D)return i}function dE(e,t){const i=t||new Path2D,{x:n,y:r,height:s,ex:a,ey:l}=e.calculative.worldRect,c=s/7;if(i.moveTo(n,r+c),i.bezierCurveTo(n,r-c/2|0,a,r-c/2|0,a,r+c),i.lineTo(a,l-c),i.bezierCurveTo(a,l+c/2|0,n,l+c/2|0,n,l-c),i.closePath(),i.moveTo(n,l-c),i.bezierCurveTo(n,l-c*2|0,a,l-c*2|0,a,l-c),i instanceof Path2D)return i}function WC(){return{flowComment:nE,flowData:rE,flowDb:dE,flowDisplay:sE,flowDocument:aE,flowExternStorage:oE,flowInternalStorage:lE,flowManually:cE,flowParallel:hE,flowQueue:uE,flowSubprocess:fE}}var Ya;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(Ya||(Ya={}));function ag(e,t){const i=t.calculative.worldRect.height*14/16,r=(e.match(/[\u4e00-\u9fa5]/g)||"").length;return(e.length-r)*i*.6+r*i}function og(e){if(e.direction=="horizontal"){const t=[];let i=0;const n=e.height;e.checkboxHeight=n,e.options.forEach((s,a)=>{t.push(a*(40+n)+i),i+=ag(s.text,e)}),e.optionPos=t;const r=t.length*(40+n)+i;e.checkboxWidth=r,e.width=r,e.calculative.width=r,e.calculative.worldRect={x:e.x,y:e.y,height:e.height,width:e.width,center:{x:e.x+e.width/2,y:e.y+e.height/2}},ae(e.calculative.worldRect)}else if(e.direction=="vertical"){e.optionInterval==null&&(e.optionInterval=20),e.optionHeight||(e.optionHeight=20);const t=[];e.options.forEach((n,r)=>{t.push(r*(e.optionInterval+e.optionHeight))}),e.optionPos=t;const i=t[t.length-1]+e.optionHeight;e.checkboxHeight=i,e.width||(e.height=i,e.calculative.height=i,e.calculative.worldRect={x:e.x,y:e.y,height:e.height,width:e.width,center:{x:e.x+e.width/2,y:e.y+e.height/2}},ae(e.calculative.worldRect))}}function cd(e,t){t.onAdd||(t.onAdd=lg,(!t.rowPos||!t.colPos||!t.calculative.maxOffsetY)&&t.onAdd(t),t.onMouseMove=bE,t.onMouseLeave=xE,t.onMouseDown=_E,t.onShowInput=pE,t.onInput=wE,t.onValue=AE,t.onBeforeValue=RE,t.onMouseEnter=IE,t.onWheel=CE,t.onDestroy=SE),t.data.length!==t.rowPos.length&&(t.initWorldRect=null,t.calculative.isUpdateData=!0,t.onValue(t)),t.data[0].length!==t.colPos.length&&(t.initWorldRect=null,t.calculative.isUpdateData=!0,t.onValue(t));const i=t.calculative.canvas.store.data,n=t.calculative.canvas.store.options;if(t.color=t.color||i.color||n.color,t.textColor=t.textColor||t.color||i.textColor||n.textColor,t.activeColor=t.activeColor||n.activeColor,t.hoverColor=t.hoverColor||n.hoverColor,t.activeBackground=t.activeBackground||n.activeBackground,t.hoverBackground=t.hoverBackground||n.hoverBackground,!t.hasHeader){e.save(),e.beginPath();const{x:r,y:s,width:a,height:l}=t.calculative.worldRect;e.fillStyle="#fff0",e.rect(r-1,s-1,a+2,l+2),e.fill(),e.clip()}yE(e,t),mE(e,t),vE(e,t),e.restore(),t.isFirstTime=!1}function vE(e,t){if(!t.calculative.hover||!t.calculative.hoverCell||t.calculative.isInput||!t.calculative.isHover)return;let i=t.calculative.worldRect,n=t.calculative.canvas.mousePos;if(!(n.x>i.x&&n.x<i.x+i.width&&n.y>i.y&&n.y<i.y+i.height)){t.calculative.hover=!1,t.calculative.isHover=!1,t.calculative.hoverCell=void 0;return}const{row:r,col:s}=t.calculative.hoverCell,{x:a,y:l}=t.calculative.canvas.mousePos;if(!t.data[r])return;let c=t.data[r][s];if(typeof c=="object"||!c)return;e.save(),e.beginPath(),e.textAlign="start",e.textBaseline="middle",e.font=e.font=(t.calculative.fontStyle||"")+" normal "+(t.calculative.fontWeight||"")+" "+(t.calculative.fontSize||12)+"px "+t.calculative.fontFamily;const u=e.measureText(c).width;e.beginPath(),e.fillStyle="#fff",e.strokeStyle="#000",e.moveTo(a,l),e.rect(a-10,l,u+20,20),e.fill(),e.stroke(),e.beginPath(),e.fillStyle="#000",e.fillText(c,a,l+10),e.restore()}function gE(e){const t=[],i=[],n={};e.rowHeight||(e.rowHeight=40),e.colWidth||(e.colWidth=150);let r=0;const s=e.styles&&e.styles.filter(v=>v.col!==void 0&&v.row===void 0&&v.width);let a={};s&&s.forEach(v=>{a[v.col]=v.width});for(let v=0;v<e.data[0].length;v++){r+=(a[v]||e.colWidth)*e.calculative.canvas.store.data.scale,t.push(r);let y=e.styles&&e.styles.filter(w=>w.col===v&&w.row===void 0);y&&(n[v]=y[0])}let l=0;const c=e.styles&&e.styles.filter(v=>v.col===void 0&&v.row!==void 0&&v.height);let u={};c&&c.forEach(v=>{u[v.row]=v.height});let h=l;for(let v=0;v<e.data.length;v++)l+=(u[v]||e.rowHeight)*e.calculative.canvas.store.data.scale,i.push(l),v<e.maxNum&&(h=l);if(e.calculative.maxOffsetY=(l-h)/e.calculative.canvas.store.data.scale,e.initWorldRect)return;e.colPos=t,e.rowPos=i,e.colStyle=n,e.initScale=e.calculative.canvas.store.data.scale,e.tableWidth=r,e.tableHeight=h||l,e.calculative.width=r,e.calculative.height=h||l,e.calculative.width=r,e.calculative.height=h||l,e.height||(e.height=e.calculative.height),e.width||(e.width=e.calculative.width);let d=e.x,g=e.y;if(e.parentId){let v=e.calculative.canvas.store.pens[e.parentId];d=v.calculative.worldRect.x+v.calculative.worldRect.width*e.x,g=v.calculative.worldRect.y+v.calculative.worldRect.height*e.y}e.calculative.worldRect={x:d,y:g,height:e.calculative.height,width:e.calculative.width,center:{x:e.x+e.calculative.width/2,y:e.y+e.calculative.height/2}},e.width=e.calculative.width,e.height=e.calculative.height,e.initWorldRect||(e.initWorldRect={width:e.calculative.worldRect.width,height:e.calculative.worldRect.height}),ae(e.calculative.worldRect)}function yE(e,t){if(!t.colPos)return;const{x:i,y:n,width:r,height:s,ex:a,ey:l}=t.calculative.worldRect;e.save(),e.beginPath(),e.strokeStyle=t.color;let c=t.calculative.borderRadius||0,u=c;c<1&&(c=r*c,u=s*u);let h=c<u?c:u;if(r<2*h&&(h=r/2),s<2*h&&(h=s/2),e.moveTo(i+h,n),e.arcTo(a,n,a,l,h),e.arcTo(a,l,i,l,h),e.arcTo(i,l,i,n,h),e.arcTo(i,n,a,n,h),t.background&&(e.fillStyle=t.background,e.fill()),t.bordered!==!1&&(e.strokeStyle=t.borderColor||"#424B61",e.stroke()),t.hLine!==!1){let d=t.rowPos[t.rowPos.length-1];t.hasHeader&&(e.beginPath(),e.moveTo(t.calculative.worldRect.x,t.calculative.worldRect.y+t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight),e.lineTo(t.calculative.worldRect.ex,t.calculative.worldRect.y+t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight),e.strokeStyle=t.borderColor||"#424B61",e.stroke());for(const g of t.rowPos){if(g===d)continue;const v=g*t.calculative.worldRect.height/t.tableHeight-t.offsetY*t.calculative.canvas.store.data.scale;if(t.hasHeader){if(v<0+t.rowPos[0]||v>t.calculative.worldRect.height)continue}else if(v<0||v>t.calculative.worldRect.height)continue;e.beginPath(),e.moveTo(t.calculative.worldRect.x,t.calculative.worldRect.y+v),e.lineTo(t.calculative.worldRect.ex,t.calculative.worldRect.y+v),e.strokeStyle=t.borderColor||"#424B61",e.stroke()}}if(t.vLine!==!1){let d=t.colPos[t.colPos.length-1];t.colPos.forEach((g,v)=>{if(g===d)return;const y=g*t.calculative.worldRect.width/t.tableWidth;e.beginPath(),e.moveTo(t.calculative.worldRect.x+y,t.calculative.worldRect.y),e.lineTo(t.calculative.worldRect.x+y,t.calculative.worldRect.ey),e.strokeStyle=t.borderColor||"#424B61",e.stroke()})}e.restore()}function mE(e,t){var n,r,s,a,l;if(!t.colPos)return;t.calculative.texts||(t.calculative.texts=[]);const i=1;for(let c=0;c<t.rowPos.length;c++){if(t.hasHeader&&c===1){e.save(),e.beginPath();const{x:h,y:d,width:g,height:v}=t.calculative.worldRect;e.fillStyle="#fff0",e.rect(h-1,d+t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight-1,g+2,v-t.rowPos[0]*t.calculative.worldRect.height/t.tableHeight+2),e.fill(),e.clip()}let{style:u}=kE(t,c);for(let h=0;h<t.colPos.length;h++){let{value:d,style:g}=hg(t,c,h),v=!0;if(Array.isArray(g)&&g.length>0){let D=0;g.forEach((q,Q)=>{q.wheres&&q.wheres.every(T=>new Function("attr",`return attr ${T.comparison} ${T.value}`)(d))&&(D=Q)}),g=g[D]}else g.wheres&&Array.isArray(g.wheres)&&(v=!1,v=g.wheres.every(function(D){return new Function("attr",`return attr ${D.comparison} ${D.value}`)(d)}));let y=t.color,w=t.textColor||t.color,p=null,_=null,A=null,x=null;v&&(y=g.color||u.color||t.color,w=g.textColor||u.textColor||t.textColor,p=g.background||u.background,_=(g.fontSize||u.fontSize||0)*t.calculative.canvas.store.data.scale,A=g.fontWeight||u.fontWeight,x=g.fontStyle||u.fontStyle);let E;t.stripe&&(t.hasHeader!==!1?c%2===1&&(p=p||t.stripeColor||"#407FFF1F"):c%2===0&&(p=p||t.stripeColor||"#407FFF1F")),t.calculative.active&&((n=t.calculative.activeCell)==null?void 0:n.row)===c&&((r=t.calculative.activeCell)==null?void 0:r.col)===h&&(y=t.activeColor,p=t.activeBackground,E=y,w=t.activeTextColor||t.activeColor),t.calculative.hover&&((s=t.calculative.hoverCell)==null?void 0:s.row)===c&&((a=t.calculative.hoverCell)==null?void 0:a.col)===h&&(y=t.hoverColor,p=t.hoverBackground,w=t.hoverTextColor||t.hoverColor,E=y);const I=fg(t,c,h);if(I.y+I.height<t.calculative.worldRect.y||I.y>t.calculative.worldRect.height+t.calculative.worldRect.y)continue;p&&(e.save(),e.beginPath(),e.fillStyle=p,e.fillRect(I.x,I.y,I.width+.25*t.calculative.canvas.store.data.scale,I.height),e.restore()),E&&(e.save(),e.beginPath(),e.strokeStyle=E,e.strokeRect(I.x,I.y,I.width,I.height),e.restore()),t.calculative.worldTextRect=I;let M=t.calculative.texts[c];if(t.calculative.texts[c]||(M=[],t.calculative.texts.push(M)),M[h]==null){if(typeof d=="object"){const D=t.styles&&t.styles.filter(q=>q.col===h&&q.row===void 0&&q.pens);if(D.length>0){if(M[h]="",t.isFirstTime){t.maxNum&&t.hasHeader&&c>=t.maxNum&&(d.visible=!1);let q=JSON.parse(JSON.stringify(D[0].pens));q.forEach(Q=>{Object.assign(Q,{row:c,col:h},d),Q.activeBackground=Q.background,Q.hoverBackground=Q.background,Q.activeColor=Q.color,Q.hoverColor=Q.color,Q.activeTextColor=Q.textColor,Q.hoverTextColor=Q.textColor,Q.height*=t.calculative.canvas.store.data.scale,Q.width*=t.calculative.canvas.store.data.scale}),EE(t,I,q),t.calculative.canvas.parent.pushChildren(t,q)}continue}}else d===void 0?M[h]="":M[h]=d.text||d+"";if(!M[h])continue;M[h]=Es(t,M[h])}if(!M[h])continue;e.save(),e.beginPath(),e.fillStyle=w,e.textAlign="center",e.textBaseline="middle",e.font=(x||t.calculative.fontStyle||"")+" normal "+(A||t.calculative.fontWeight||"")+" "+(_||t.calculative.fontSize||12)*i+"px "+t.calculative.fontFamily;let B=t.colStyle&&((l=t.colStyle[h])==null?void 0:l.textAlign);if(B&&(e.textAlign=B),M[h].length===1)B==="left"?e.fillText(M[h][0],I.x,I.y+I.height/2):B==="right"?e.fillText(M[h][0],I.x+I.width,I.y+I.height/2):e.fillText(M[h][0],I.x+I.width/2,I.y+I.height/2);else{const q=(_||t.calculative.fontSize)*t.calculative.lineHeight*i,Q=M[h].length*q;let C=(I.height-Q)/2;B==="left"?M[h].forEach((T,S)=>{e.fillText(T,I.x,I.y+C+(S+.55)*q)}):B==="right"?M[h].forEach((T,S)=>{e.fillText(T,I.x+I.width,I.y+C+(S+.55)*q)}):M[h].forEach((T,S)=>{e.fillText(T,I.x+I.width/2,I.y+C+(S+.55)*q)})}e.restore()}}}function lg(e){var t;qc(e),(t=e.children)!=null&&t.length||(e.isFirstTime=!0),e.offsetY||(e.offsetY=0),gE(e)}function pE(e,t){if(!e.calculative.hoverCell)return;const{value:i}=hg(e,e.calculative.hoverCell.row,e.calculative.hoverCell.col);if(typeof i=="object")return;e.calculative.isHover=!1,e.calculative.isInput=!0,e.calculative.canvas.render(),e.calculative.inputCell=e.calculative.hoverCell;const n=fg(e,e.calculative.hoverCell.row,e.calculative.hoverCell.col);e.calculative.tempText=i.text||i+"",e.calculative.canvas.showInput(e,n,"#ffffff")}function wE(e,t){!e.calculative.inputCell||(ug(e,e.calculative.inputCell.row,e.calculative.inputCell.col,t),e.calculative.isInput=!1,e.calculative.isHover=!0,e.calculative.canvas.render())}function bE(e,t){e.timer&&(e.calculative.isHover=!1,clearTimeout(e.timer)),e.timer=setTimeout(()=>{e.calculative.isHover=!0,e.calculative.canvas.render()},500),e.calculative.hoverCell=cg(e,t),e.calculative.canvas.render()}function xE(e,t){qc(e),e.calculative.hoverCell=void 0,e.calculative.canvas.render()}function _E(e,t){e.calculative.activeCell=cg(e,t),e.calculative.canvas.render()}function cg(e,t){const i=e.calculative.worldRect.width/e.tableWidth,n=e.calculative.worldRect.height/e.tableHeight,r={row:0,col:0};for(let s=0;s<e.colPos.length;s++)t.x>e.calculative.worldRect.x+e.colPos[s]*i&&(r.col=s+1);for(let s=0;s<e.rowPos.length;s++)t.y>e.calculative.worldRect.y+e.rowPos[s]*n-e.offsetY*e.calculative.canvas.store.data.scale&&(r.row=s+1);return r}function hg(e,t,i){if(!e.data||!Array.isArray(e.data))return;const n=e.data[t],r=e.styles&&e.styles.filter(s=>s.row===t&&s.col===i);if(Array.isArray(n))return{value:n[i],style:(r==null?void 0:r.length)>0?r.length>1?r:r[0]:{}};if(!n.data||!Array.isArray(n.data))return}function kE(e,t){if(!e.data||!Array.isArray(e.data))return;const i=e.data[t],n=e.styles&&e.styles.filter(r=>r.row===t&&r.col===void 0);if(Array.isArray(i))return{value:i,style:(n==null?void 0:n.length)>0?n[0]:{}};if(!i.data||!Array.isArray(i.data))return}function ug(e,t,i,n){if(!e.data||!Array.isArray(e.data))return;e.isFirstTime=!1,e.calculative.texts=void 0;let r=e.data[t];!r||(r[i]instanceof Object||(r[i]=n),e.calculative.canvas.store.emitter.emit("valueUpdate",e))}function fg(e,t,i){const n=e.calculative.worldRect.width/e.tableWidth,r=e.calculative.worldRect.height/e.tableHeight;let s=0,a=e.colPos[i]*n;i>0&&(s=e.colPos[i-1]*n);let l=0,c=e.rowPos[t]*r;t>0&&(l=e.rowPos[t-1]*r);let u=e.offsetY*e.calculative.canvas.store.data.scale;return t===0&&e.hasHeader&&(u=0),{x:e.calculative.worldRect.x+s,y:e.calculative.worldRect.y+l-u,ex:e.calculative.worldRect.x+a,ey:e.calculative.worldRect.y+c-u,width:a-s,height:c-l}}function EE(e,t,i){if(!(i&&i.length))return;const n=e.calculative.worldRect.width/e.tableWidth,r=e.calculative.worldRect.height/e.tableHeight;let s=1,a=1;e.initWorldRect&&(e.calculative.worldRect.width!==e.initWorldRect.width&&(s=e.calculative.worldRect.width/e.initWorldRect.width),e.calculative.worldRect.height!==e.initWorldRect.height&&(a=e.calculative.worldRect.height/e.initWorldRect.height));let l=0,c=0,u=0;const h=e.calculative.canvas.store.data.scale;if(i.length>1){for(const d of i)c+d.width*n+20*h*n<t.width?(d.x=t.x+c+10*h*n,d.y=t.y+u+10*h*r,c+=(d.width+10*h)*n,l=Math.max(l,u+(d.height+10*h)*r)):(c=0,u=l,d.x=t.x+c+10*h*n,d.y=t.y+u+10*h*r,l+=(d.height+10*h)*r);if(l+20*h*r<t.height){const d=(t.height-l-10*h*r)/2;for(const g of i)g.y+=d}}else i[0].x=t.x+(t.width-i[0].width)/2,i[0].y=t.y+(t.height-i[0].height)/2;i.forEach(d=>{d.width=d.width*s,d.height=d.height*a})}function AE(e){if(e.calculative.isUpdateData){delete e.calculative.isUpdateData;let t=ct(e.children);e.children=[],lg(e),t&&t.forEach(i=>{e.calculative.canvas.delForce(e.calculative.canvas.findOne(i))}),e.calculative.texts=void 0}}function RE(e,t){if(e.calculative.isUpdateData=!1,e.swiper!==void 0&&(e.swiper?qc(e):Wc(e)),t.styles&&(e.initWorldRect=void 0),t.table||t.col==null&&t.row==null){if(t.dataY){const n=e.replaceMode;let r=[];return n?n===Ya.Replace?(r=e.data,t.dataX&&t.dataX.forEach((s,a)=>{r[s]=t.dataY[a]})):n===Ya.ReplaceAll&&(t.dataX?r[0]=t.dataX:r[0]=e.data[0],r=r.concat(t.dataY)):r=e.data.concat(t.dataY),delete t.dataX,delete t.dataY,e.calculative.isUpdateData=!0,Object.assign(t,{data:r})}(t.data||t.styles||t.maxNum||t.rowHeight||t.colWidth)&&(e.calculative.isUpdateData=!0,e.initWorldRect=null);for(let n of Object.keys(t))n.includes("data.")&&(e.calculative.isUpdateData=!0);return t}let i=e.data[t.row];return i&&(i[t.col]instanceof Object||(i[t.col]=t.value),ug(e,t.row,t.col,t.value),e.calculative.canvas.render(),delete t.col,delete t.row),t}function CE(e,t){if(!e.locked&&!e.calculative.canvas.store.data.locked||!e.maxNum)return;let i=0;t.deltaY>0?i=4:i=-4,kc(e,i)}function kc(e,t){var i;e.offsetY||(e.offsetY=0),e.offsetY+=t,e.offsetY>e.calculative.maxOffsetY&&(e.offsetY=e.calculative.maxOffsetY),e.offsetY<0&&(e.offsetY=0),(i=e.children)==null||i.forEach(n=>{const r=e.calculative.canvas.store.pens[n];TE(e,r)}),e.calculative.canvas.render()}function TE(e,t){if(!t)return;t.oldY||(t.oldY=t.y),t.calculative.worldRect,e.calculative.worldRect;const i=e.calculative.canvas.store.data.scale;e.calculative.worldRect.height/e.tableHeight;const n=e.rowHeight;t.y=t.oldY-e.offsetY*i/e.calculative.worldRect.height;const r=n*(e.initScale||1)/e.tableHeight*e.maxNum;if(e.calculative.canvas.updatePenRect(t),e.hasHeader)if(t.y<e.rowPos[0]/e.tableHeight){if(t.calculative.visible=!1,t.visible=!1,t.y<e.rowPos[0]/e.tableHeight/2){t.oldY+=r;let s=t.row+e.maxNum;if(!e.data[s])return;let a=ct(e.data[s][t.col]);a.background&&(a.activeBackground=a.background,a.hoverBackground=a.background),a.color&&(a.hoverColor=a.color,a.activeColor=a.color),a.textColor&&(a.activeTextColor=a.textColor,a.hoverTextColor=a.textColor),Object.assign(t,a,{row:s}),Object.assign(t.calculative,a,{row:s})}}else if(t.y+t.height>1){if(t.calculative.visible=!1,t.visible=!1,t.y+t.height/2>1){t.oldY-=r;let s=t.row-e.maxNum;if(!e.data[s])return;let a=ct(e.data[s][t.col]);a.background&&(a.activeBackground=a.background,a.hoverBackground=a.background),a.color&&(a.hoverColor=a.color,a.activeColor=a.color),a.textColor&&(a.activeTextColor=a.textColor,a.hoverTextColor=a.textColor),Object.assign(t,a,{row:s}),Object.assign(t.calculative,a,{row:s})}}else t.visible=!0,t.calculative.visible=!0;else if(t.y<0){if(t.calculative.visible=!1,t.visible=!1,t.y<-n/e.tableHeight/2){t.oldY+=r;let s=t.row+e.maxNum;if(!e.data[s])return;let a=ct(e.data[s][t.col]);a.background&&(a.activeBackground=a.background,a.hoverBackground=a.background),a.color&&(a.hoverColor=a.color,a.activeColor=a.color),a.textColor&&(a.activeTextColor=a.textColor,a.hoverTextColor=a.textColor),Object.assign(t,a,{row:s}),Object.assign(t.calculative,a,{row:s})}}else if(t.y+t.height>1){if(t.calculative.visible=!1,t.visible=!1,t.y+t.height/2>1){t.oldY-=r;let s=t.row-e.maxNum;if(!e.data[s])return;let a=ct(e.data[s][t.col]);a.background&&(a.activeBackground=a.background,a.hoverBackground=a.background),a.color&&(a.hoverColor=a.color,a.activeColor=a.color),a.textColor&&(a.activeTextColor=a.textColor,a.hoverTextColor=a.textColor),Object.assign(t,a,{row:s}),Object.assign(t.calculative,a,{row:s})}}else t.calculative.visible=!0,t.visible=!0}function SE(e){Wc(e)}function Wc(e){e.interval&&(globalThis.clearInterval(e.interval),e.interval=null)}function qc(e){if(e.maxNum&&e.swiper){if(e.interval)return;e.interval=globalThis.setInterval(()=>{e.offsetY>=e.calculative.maxOffsetY?(e.offsetY=0,PE(e)):e.offsetY%e.rowHeight?kc(e,1):(e.calculative.stap||(e.calculative.stap=0),e.calculative.stap+=1,e.calculative.stap==12&&(e.calculative.stap=0,kc(e,1)))},50)}}function PE(e){var t;(t=e.children)==null||t.forEach(i=>{const n=e.rowHeight,r=e.calculative.canvas.store.pens[i];if(!r)return;const s=n*(e.initScale||1)/e.tableHeight*e.maxNum;r.oldY-=s;const a=r.row-e.maxNum;if(!e.data[a])return;let l=ct(e.data[a][r.col]);l.background&&(l.activeBackground=l.background,l.hoverBackground=l.background),l.color&&(l.hoverColor=l.color,l.activeColor=l.color),l.textColor&&(l.activeTextColor=l.textColor,l.hoverTextColor=l.textColor),r.calculative.visible=!0,r.visible=!0,Object.assign(r,l,{row:a}),Object.assign(r.calculative,l,{row:a})}),e.calculative.canvas.render()}function IE(e){Wc(e)}function LE(e,t){t.onClick||(t.onClick=DE);let i=t.calculative.worldRect.x,n=t.calculative.worldRect.y,r=t.calculative.worldRect.width,s=t.calculative.worldRect.height;r<s*1.5&&(r=1.5*s),e.beginPath(),e.arc(i+s/2,n+s/2,s/2,Math.PI/2,Math.PI*3/2),e.lineTo(i+r-s/2,n),e.arc(i+r-s/2,n+s/2,s/2,-Math.PI/2,Math.PI/2),e.lineTo(i+s/2,n+s),t.checked?(e.fillStyle=t.onColor,(t.disabled||t.disable)&&(e.fillStyle=t.disableOnColor||Ae(.6,t.onColor)),t.lineWidth&&(e.strokeStyle=t.onStrokeColor,e.stroke()),e.fill(),e.closePath(),e.beginPath(),e.fillStyle="#ffffff",e.moveTo(i+s*2,n+s/2),e.arc(i+r-s/2,n+s/2,s/2>2?s/2-2:1,0,Math.PI*2),e.fill()):(e.fillStyle=t.offColor,(t.disabled||t.disable)&&(e.fillStyle=t.disableOffColor||Ae(.6,t.offColor)),t.lineWidth&&(e.strokeStyle=t.offStrokeColor,e.stroke()),e.fill(),e.closePath(),e.beginPath(),e.fillStyle="#ffffff",e.moveTo(i+s,n+s/2),e.arc(i+s/2,n+s/2,s/2>2?s/2-2:1,0,Math.PI*2),e.fill()),e.closePath()}function DE(e){e.disabled||e.disable||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function ME(e,t){t.onAdd||(t.onAdd=as,t.onResize=as,t.onMove=as,t.onMouseMove=BE,t.onMouseDown=dg,t.onValue=OE,t.onBeforeValue=NE),t.calculative.barRect||as(t),t.calculative.canvas.store.data;const i=t.calculative.canvas.store.options;let n=t.background;t.disabled&&(n=t.disabledBackground||Ae(.6,n)),e.fillStyle=n,e.beginPath();let r=t.calculative.worldRect.x+t.calculative.barRect.x,s=t.calculative.worldRect.y+t.calculative.barRect.y,a=t.calculative.barRect.width,l=t.calculative.barRect.height,c=l/2;e.moveTo(r+c,s),e.arcTo(r+a,s,r+a,s+l,c),e.arcTo(r+a,s+l,r,s+l,c),e.arcTo(r,s+l,t.x,t.y,c),e.arcTo(r,s,r+a,s,c),e.fill();let u=t.activeColor||i.activeColor;t.disabled&&(u=t.disabledColor||Ae(.6,u)),e.fillStyle=u,e.beginPath(),a=t.calculative.ballRect.x,e.moveTo(r+c,s),e.arcTo(r+a,s,r+a,s+l,c),e.arcTo(r+a,s+l,r,s+l,c),e.arcTo(r,s+l,t.x,t.y,c),e.arcTo(r,s,r+a,s,c),e.fill(),e.fillStyle=t.btnBackground||"#fff",e.strokeStyle=u,e.lineWidth=2,e.beginPath(),r=t.calculative.worldRect.x+t.calculative.ballRect.x,s=t.calculative.worldRect.y+t.calculative.ballRect.y+t.calculative.ballRect.height/2,e.lineWidth=t.calculative.ballRect.width/10,e.arc(r,s,t.calculative.ballRect.width/2,0,Math.PI*2),e.fill(),e.stroke()}function as(e){if(e._textWidth||(e._textWidth=e.textWidth||50,e._fontSize=e.fontSize||12),e.textWidth=e.calculative.worldRect.width,e.calculative.textWidth=e.textWidth,e.unit||(e.unit="%"),e.sliderWidth||(e.sliderWidth=e.width),e.sliderHeight||(e.sliderHeight=e.height),!e.calculative.worldRect)return;const t=e.calculative.worldRect.width/e.sliderWidth,i=e.calculative.worldRect.height/e.sliderHeight,n=Math.min(t,i);e.fontSize=e._fontSize*n;const r=e.calculative.worldRect.width-e._textWidth*n;e.textLeft=r+10*n,e.calculative.textLeft=e.textLeft,e.calculative.barRect={x:0,y:(e.calculative.worldRect.height-e.barHeight*i)/2,width:r,height:e.barHeight*i},ae(e.calculative.barRect),jc(e)}function jc(e){const t=e.calculative.barRect.height*3.5,i=e.calculative.barRect.width*e.value/100;e.calculative.ballRect={x:i,y:(e.calculative.worldRect.height-t)/2,width:t,height:t},ae(e.calculative.ballRect),e.calculative.text=e.value+e.unit,Ti(e)}function dg(e,t){if(e.disabled)return;const i=t.x-e.calculative.worldRect.x;if(i>e.calculative.barRect.width)return;let n=Math.round(i/e.calculative.barRect.width*100);n<e.min||n>e.max||n<0||n>100||(e.value=n,jc(e),e.calculative.text=e.value+e.unit,Ti(e),e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function BE(e,t){e.calculative.canvas.mouseDown&&dg(e,t)}function OE(e){e.calculative.isUpdateData&&(delete e.calculative.isUpdateData,as(e)),jc(e)}function NE(e,t){return e.calculative.isUpdateData=!1,(t.textWidth||t.barHeight)&&(t.textWidth&&(e._textWidth=0),e.calculative.isUpdateData=!0),t}function FE(e,t){t.onMouseDown||(t.onMouseDown=zE),t.options||(t.options=t.data);let i=t.calculative.worldRect.x,n=t.calculative.worldRect.y,r=t.calculative.worldRect.height;t.calculative.worldRect.width;const{fontStyle:s,fontWeight:a,fontSize:l,fontFamily:c,lineHeight:u}=t.calculative;let h=2;e.beginPath(),e.moveTo(i,n),e.arcTo(i+r,n,i+r,n+r,h),e.arcTo(i+r,n+r,i,n+r,h),e.arcTo(i,n+r,i,n,h),e.arcTo(i,n,i+r,n,h),e.strokeStyle="#d9d9d9",e.fillStyle="#ffffff00",t.checked&&(e.fillStyle=t.background||"#1890ff",e.strokeStyle=t.background||"#1890ff"),(t.isForbidden||t.disabled)&&(e.fillStyle=t.disabledBackground||Ae(.6,t.background)||"#ebebeb",e.strokeStyle=t.disabledColor||Ae(.6,t.color)||"#d9d9d9"),e.closePath(),e.fill(),e.stroke(),e.save(),t.checked&&(e.beginPath(),e.lineWidth=r/10,e.strokeStyle="#ffffff",e.moveTo(i+102/506*r,n+r/2),e.lineTo(i+220/506*r,n+346/460*r),e.lineTo(i+404/506*r,n+142/460*r),e.stroke()),e.restore(),e.save(),e.fillStyle=t.disabled||t.isForbidden?t.disabledTextColor||Ae(.6,t.textColor||t.color)||"#00000040":An(t,t.calculative.canvas.parent.store)||"#000000d9",e.textAlign="start",e.textBaseline="middle",e.font=Rn({fontStyle:s,fontWeight:a,fontFamily:c||t.calculative.canvas.parent.store.options.fontFamily,fontSize:l,lineHeight:u}),e.fillText(t.value+"",i+r+10,n+r/2),e.restore()}function zE(e,t){e.isForbidden||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function HE(e,t){t.options||(t.options=t.data),t.onAdd||(t.onAdd=UE,t.optionPos||(t.onAdd(t),t.calculative.canvas.parent.active([t])),t.onMouseDown=WE,t.onValue=qE);let i=t.calculative.worldRect.x,n=t.calculative.worldRect.y,r=t.calculative.worldRect.height,s=t.calculative.worldRect.width;if(!t.optionPos)return;const{fontStyle:a,fontWeight:l,fontSize:c,fontFamily:u,lineHeight:h}=t.calculative;if(t.direction=="horizontal")for(let d=0;d<t.optionPos.length;d++){const g=t.optionPos[d]*s/t.checkboxWidth,v=t.options[d].isForbidden||t.disabled;e.beginPath(),e.arc(i+g+r/2,n+r/2,r/2,0,Math.PI*2),e.strokeStyle="#d9d9d9",e.fillStyle="#ffffff00",t.options[d].text===t.checked&&(e.strokeStyle=t.options[d].background||t.background||"#1890ff"),v&&(e.fillStyle=t.disabledBackground||Ae(.6,t.background)||"#ebebeb",e.strokeStyle=t.disabledColor||Ae(.6,t.color)||"#d9d9d9",t.options[d].text===t.checked&&(e.fillStyle="#ffffff00")),e.closePath(),e.fill(),e.stroke(),e.save(),t.options[d].text===t.checked&&(e.beginPath(),e.strokeStyle=t.options[d].background?t.options[d].background+"20":t.background||"#1890ff20",v&&(e.strokeStyle=t.disabledBackground||Ae(.6,t.background)||"#ebebeb"),e.arc(i+r/2+g,n+r/2,r/2+1.5,0,Math.PI*2),e.stroke(),e.closePath(),e.beginPath(),e.fillStyle=t.options[d].background||t.background||"#1890ff",v&&(e.fillStyle=t.disabledBackground||Ae(.6,t.background)||"#ebebeb"),e.arc(i+r/2+g,n+r/2,r/4,0,Math.PI*2),e.fill(),e.closePath()),e.restore(),e.save(),e.fillStyle=v?t.disabledTextColor||"#00000040":An(t,t.calculative.canvas.parent.store)||"#000000d9";const y=t.calculative.worldRect.height*14/16;e.textAlign="start",e.textBaseline="middle",e.font=Rn({fontStyle:a,fontWeight:l,fontFamily:u||t.calculative.canvas.parent.store.options.fontFamily,fontSize:y,lineHeight:h}),e.fillText(t.options[d].text,i+r+g+10/t.checkboxWidth*s,n+r/2),e.restore()}else if(t.direction=="vertical"){const d=t.optionHeight*r/t.checkboxHeight;for(let g=0;g<t.optionPos.length;g++){const v=t.optionPos[g]*r/t.checkboxHeight,y=t.options[g].isForbidden;e.beginPath(),e.arc(i+d/2,n+d/2+v,d/2,0,Math.PI*2),e.strokeStyle="#d9d9d9",e.fillStyle="#ffffff00",t.options[g].text===t.checked&&(e.strokeStyle=t.options[g].background||"#1890ff"),y&&(e.fillStyle="#ebebeb",e.strokeStyle="#d9d9d9"),e.closePath(),e.fill(),e.stroke(),e.save(),!y&&t.options[g].text===t.checked&&(e.beginPath(),e.strokeStyle=t.options[g].background?t.options[g].background+"20":"#1890ff20",e.arc(i+d/2,n+d/2+v,d/2+1.5,0,Math.PI*2),e.stroke(),e.closePath(),e.beginPath(),e.fillStyle=t.options[g].background||"#1890ff",e.arc(i+d/2,n+d/2+v,d/4,0,Math.PI*2),e.fill(),e.closePath()),e.restore(),e.save(),e.fillStyle=y?"#00000040":An(t,t.calculative.canvas.parent.store)||"#000000d9";const w=14*t.calculative.worldRect.height/t.checkboxHeight;e.textAlign="start",e.textBaseline="middle",e.font=Rn({fontStyle:a,fontWeight:l,fontFamily:u||t.calculative.canvas.parent.store.options.fontFamily,fontSize:w,lineHeight:h}),e.fillText(t.options[g].text,i+d+10,n+d/2+v),e.restore()}}}function UE(e){og(e)}function WE(e,t){if(e.direction=="horizontal")for(let i=0;i<e.optionPos.length;i++)!e.options[i].isForbidden&&t.x>e.calculative.worldRect.x+e.optionPos[i]*e.calculative.worldRect.width/e.checkboxWidth&&t.x<e.calculative.worldRect.x+(e.optionPos[i]+e.height)/e.checkboxWidth*e.calculative.worldRect.width+ag(e.options[i].text,e)+10/e.checkboxWidth*e.calculative.worldRect.width&&(e.checked=e.options[i].text,e.calculative.canvas.store.emitter.emit("valueUpdate",e));else if(e.direction=="vertical"){const i=e.calculative.worldRect.height/e.checkboxHeight;for(let n=0;n<e.optionPos.length;n++)!e.options[n].isForbidden&&t.y>e.calculative.worldRect.y+e.optionPos[n]*i&&t.y<e.calculative.worldRect.y+(e.optionPos[n]+e.optionHeight)*i&&(e.checked=e.options[n].text,e.calculative.canvas.store.emitter.emit("valueUpdate",e))}e.calculative.canvas.render()}function qE(e){og(e)}function qC(){return{radio:HE,switch:LE,slider:ME,checkbox:FE,table:cd,table2:cd}}function jE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a,ey:l}=e.calculative.worldRect,c=e.calculative.lineLeft||.08;let u=e.calculative.borderRadius||0,h=u;u<1&&(u=s*u,h=a*u);let d=u<h?u:h;if(s<2*d&&(d=s/2),a<2*d&&(d=a/2),i.moveTo(n+d,r),i.arcTo(n+s,r,n+s,r+a,d),i.arcTo(n+s,r+a,n,r+a,d),i.arcTo(n,r+a,n,r,d),i.arcTo(n,r,n+s,r,d),i.closePath(),i.moveTo(n+c*s,r),i.lineTo(n+c*s,l),i instanceof Path2D)return i}function VE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a,ex:l}=e.calculative.worldRect,c=e.calculative.lineTop||.08;let u=e.calculative.borderRadius||0,h=u;u<1&&(u=s*u,h=a*h);let d=u<h?u:h;if(s<2*d&&(d=s/2),a<2*d&&(d=a/2),i.moveTo(n+d,r),i.arcTo(n+s,r,n+s,r+a,d),i.arcTo(n+s,r+a,n,r+a,d),i.arcTo(n,r+a,n,r,d),i.arcTo(n,r,n+s,r,d),i.closePath(),i.moveTo(n,r+c*a),i.lineTo(l,r+c*a),i instanceof Path2D)return i}function jC(){return{forkV:qn,forkH:qn,swimlaneH:jE,swimlaneV:VE}}function $E(e,t){e.onDestroy||(e.onDestroy=YE,e.onAdd=KE);const i=t||new Path2D,{x:n,y:r,width:s,height:a,ex:l}=e.calculative.worldRect;let c=e.calculative.borderRadius||0,u=c;c<1&&(c*=s,u*=a);let h=c<u?c:u;s<2*h&&(h=s/2),a<2*h&&(h=a/2),i.moveTo(n+h,r),i.arcTo(n+s,r,n+s,r+a,h),i.arcTo(n+s,r+a,n,r+a,h),i.arcTo(n,r+a,n,r,h),i.arcTo(n,r,n+s,r,h);const d=.2*a;i.moveTo(n,r+d),i.lineTo(l,r+d);const g=r+d+(a-d)/2;if(i.moveTo(n,g),i.lineTo(l,g),i.closePath(),i instanceof Path2D)return i}function KE(e){const{x:t,y:i,width:n,height:r}=e.calculative.worldRect,s=e.list,a={name:"text",x:t,y:i+.2*r,width:n,height:.4*r,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10},l={name:"text",x:t,y:i+.6*r,width:n,height:.4*r,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10};Object.assign(a,s[0]),Object.assign(l,s[1]),e.calculative.canvas.makePen(a),e.calculative.canvas.makePen(l),e.calculative.canvas.parent.pushChildren(e,[a]),e.calculative.canvas.parent.pushChildren(e,[l])}function YE(e){const t=e.calculative.canvas.store;e.children.forEach(i=>{const n=t.data.pens.findIndex(r=>r.id===i);n>-1&&(t.data.pens.splice(n,1),t.pens[i]=void 0)}),e.children=void 0}function XE(e,t){e.onDestroy||(e.onDestroy=ZE,e.onAdd=GE);const i=t||new Path2D,{x:n,y:r,width:s,height:a,ex:l}=e.calculative.worldRect;let c=e.calculative.borderRadius||0,u=c;c<1&&(c=s*c,u=a*u);let h=c<u?c:u;s<2*h&&(h=s/2),a<2*h&&(h=a/2),i.moveTo(n+h,r),i.arcTo(n+s,r,n+s,r+a,h),i.lineTo(n+s,r+a-h),i.arcTo(n+s,r+a,n,r+a,h),i.arcTo(n,r+a,n,r,h),i.arcTo(n,r,n+s,r,h);const d=.2*a;if(i.moveTo(n,r+d),i.lineTo(l,r+d),i.closePath(),i instanceof Path2D)return i}function GE(e){const{x:t,y:i,width:n,height:r}=e.calculative.worldRect,s=e.list;let a={name:"text",x:t,y:i+.2*r,width:n,height:.8*r,textAlign:"left",textBaseline:"top",textLeft:10,textTop:10};Object.assign(a,s[0]),e.calculative.canvas.makePen(a),e.calculative.canvas.parent.pushChildren(e,[a])}function ZE(e){const t=e.calculative.canvas.store;e.children.forEach(i=>{const n=t.data.pens.findIndex(r=>r.id===i);n>-1&&(t.data.pens.splice(n,1),t.pens[i]=void 0)}),e.children=[]}function VC(){return{interfaceClass:$E,simpleClass:XE}}function JE(e,t){const i=t||new Path2D,{x:n,y:r,width:s,height:a}=e.calculative.worldRect;if(i.rect(n,r,s,a),i.closePath(),i instanceof Path2D)return i}function QE(e,t){var g;const i=(g=t.headHeight)!=null?g:50,{x:n,y:r,width:s,height:a,ey:l}=t.calculative.worldRect;let c=t.calculative.borderRadius||0,u=c;t.calculative.borderRadius<1&&(c*=s,u*=a);let h=c<u?c:u;s<2*h&&(h=s/2),i<2*h&&(h=i/2),e.beginPath(),e.moveTo(n+h,r),e.arcTo(n+s,r,n+s,r+i,h),e.arcTo(n+s,r+i,n,r+i,h),e.arcTo(n,r+i,n,r,h),e.arcTo(n,r,n+s,r,h),e.closePath(),e.stroke(),e.save(),e.beginPath(),e.lineWidth=1,e.setLineDash([7,7]);const d=n+s/2;e.moveTo(d,r+i+1),e.lineTo(d,l),e.stroke(),e.restore()}function $C(){return{sequenceFocus:JE}}function KC(){return{lifeline:QE}}const YC={background:"#ECE5E5",color:"#fff",textColor:"#fff",anchorColor:"#f90",gridSize:30,grid:!1,gridColor:"rgba(255,255,255,0.1)",drawingLineName:"line"},XC=[{name:"line",label:"\u76F4\u7EBF",icon:"t-line"},{name:"polyline",label:"\u7EBF\u6BB5",icon:"t-polyline"},{name:"curve",label:"\u66F2\u7EBF",icon:"t-curve2"},{name:"mind",label:"\u8111\u56FE\u66F2\u7EBF",icon:"t-mind"}],GC=["triangle","diamond","circle","lineDown","lineUp","triangleSolid","diamondSolid","circleSolid","line"],ZC=["#000","#fff","#f00","#0f0","rgba(255,255,255,0.5)"],tA={name:"\u7BA1\u9053",show:!0,list:[{name:"\u77ED",data:{text:"",width:22,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u77ED.svg"}},{name:"\u6A2A\u5411",data:{text:"",width:68,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u6A2A\u5411.svg"}},{name:"45\u5EA6",data:{text:"",width:75,height:58,name:"svgPath",image:"/static/figures/pipe-new/45\u5EA6.svg"}},{name:"90\u5EA6",data:{text:"",width:84,height:84,name:"svgPath",image:"/static/figures/pipe-new/90\u5EA6.svg"}},{name:"\u56DB\u901A",data:{text:"",width:95,height:84,name:"svgPath",image:"/static/figures/pipe-new/\u56DB\u901A.svg"}},{name:"\u77ED-\u7070\u8272",data:{text:"",width:22,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u77ED-\u7070\u8272.svg"}},{name:"\u6A2A\u5411-\u7070\u8272",data:{text:"",width:68,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u6A2A\u5411-\u7070\u8272.svg"}},{name:"45\u5EA6-\u7070\u8272",data:{text:"",width:75,height:58,name:"svgPath",image:"/static/figures/pipe-new/45\u5EA6-\u7070\u8272.svg"}},{name:"90\u5EA6-\u7070\u8272",data:{text:"",width:84,height:84,name:"svgPath",image:"/static/figures/pipe-new/90\u5EA6-\u7070\u8272.svg"}},{name:"\u4E09\u901AL",data:{text:"",width:91,height:79,name:"svgPath",image:"/static/figures/pipe-new/\u4E09\u901AL.svg"}},{name:"\u77ED-\u84DD\u8272",data:{text:"",width:22,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u77ED-\u84DD\u8272.svg"}},{name:"\u6A2A\u5411-\u84DD\u8272",data:{text:"",width:68,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u6A2A\u5411-\u84DD\u8272.svg"}},{name:"45\u5EA6-\u84DD\u8272",data:{text:"",width:75,height:58,name:"svgPath",image:"/static/figures/pipe-new/45\u5EA6-\u84DD\u8272.svg"}},{name:"90\u5EA6-\u84DD\u8272",data:{text:"",width:84,height:84,name:"svgPath",image:"/static/figures/pipe-new/90\u5EA6-\u84DD\u8272.svg"}},{name:"\u4E09\u901AT",data:{text:"",width:85,height:66,name:"svgPath",image:"/static/figures/pipe-new/\u4E09\u901AT.svg"}},{name:"\u77ED-\u7D2B\u8272",data:{text:"",width:22,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u77ED-\u7D2B\u8272.svg"}},{name:"\u6A2A\u5411-\u7D2B\u8272",data:{text:"",width:68,height:30,name:"svgPath",image:"/static/figures/pipe-new/\u6A2A\u5411-\u7D2B\u8272.svg"}},{name:"45\u5EA6-\u7D2B\u8272",data:{text:"",width:75,height:58,name:"svgPath",image:"/static/figures/pipe-new/45\u5EA6-\u7D2B\u8272.svg"}},{name:"90\u5EA6-\u7D2B\u8272",data:{text:"",width:84,height:84,name:"svgPath",image:"/static/figures/pipe-new/90\u5EA6-\u7D2B\u8272.svg"}},{name:"\u4E09\u901AY",data:{text:"",width:85,height:85,name:"svgPath",image:"/static/figures/pipe-new/\u4E09\u901AY.svg"}},{name:"\u9600\u95E8-\u7EFF\u8272",data:{text:"",width:32,height:80,name:"svgPath",image:"/static/figures/pipe-new/\u9600\u95E8-green.svg"}},{name:"\u9600\u95E8-\u7EA2\u8272",data:{text:"",width:32,height:80,name:"svgPath",image:"/static/figures/pipe-new/\u9600\u95E8-red.svg"}},{name:"\u9600\u95E8-\u9EC4\u8272",data:{text:"",width:32,height:80,name:"svgPath",image:"/static/figures/pipe-new/\u9600\u95E8-yellow.svg"}},{name:"\u7BA1\u9053\u5E26\u9600\u95E8",data:{text:"",width:86,height:38,name:"svgPath",image:"/static/figures/pipe-new/\u7BA1\u9053\u5E26\u9600\u95E8.svg"}},{name:"\u5206\u6C14\u7F38",data:{text:"",width:229,height:108,name:"svgPath",image:"/static/figures/pipe-new/\u5206\u6C14\u7F38.svg"}}]},eA={name:"\u6309\u94AE",show:!0,list:[{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE0.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE1.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE2.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE3.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE4.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE5.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE6.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE7.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE8.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE9.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE10.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE11.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE12.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE13.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE14.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE15.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE16.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE17.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE18.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE19.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE20.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE21.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE22.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE23.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE24.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE25.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE26.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE27.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE28.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE29.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE30.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE31.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE32.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE33.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE34.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE35.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE36.svg"}},{data:{text:"",width:31,height:52,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE37.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE38.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE39.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE40.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE41.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE42.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE43.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE44.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE45.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE46.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE47.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE48.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/btn-1/\u6309\u94AE49.svg"}}]},iA={name:"\u7535\u529B",show:!0,list:[{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/1.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/2.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/3.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/4.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/5.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/6.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/7.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/8.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/9.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/10.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/11.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/12.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/13.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/14.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/15.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/16.svg"}},{data:{text:"",width:40,height:40,name:"svgPath",image:"/static/figures/ele-1/17.svg"}}]},JC=["time-comp"],QC=[{name:"\u57FA\u672C\u5F62\u72B6",show:!0,list:[{name:"square",icon:"t-icon t-rect",id:1,data:{text:"\u6B63\u65B9\u5F62",width:100,height:100,name:"square"}},{name:"rectangle",icon:"t-icon t-rectangle",id:2,data:{text:"\u5706\u89D2\u77E9\u5F62",width:200,height:50,borderRadius:.1,name:"rectangle"}},{name:"circle",icon:"t-icon t-circle",id:3,data:{text:"\u5706",width:100,height:100,name:"circle"}},{name:"text",icon:"t-icon t-text",id:16,data:{text:"\u6587\u5B57",width:100,height:40,name:"text",disableAnchor:!0}},{name:"triangle",icon:"t-icon t-triangle",id:4,data:{text:"\u4E09\u89D2\u5F62",width:100,height:100,name:"triangle"}},{name:"diamond",icon:"t-icon t-diamond",id:5,data:{text:"\u83F1\u5F62",width:100,height:100,name:"diamond"}},{name:"pentagon",icon:"t-icon t-pentagon",id:6,data:{text:"\u4E94\u8FB9\u5F62",width:100,height:100,name:"pentagon"}},{name:"hexagon",icon:"t-icon t-hexagon",id:7,data:{text:"\u516D\u8FB9\u5F62",width:100,height:100,name:"hexagon"}},{name:"pentagram",icon:"t-icon t-pentagram",id:8,data:{text:"\u4E94\u89D2\u661F",width:100,height:100,name:"pentagram"}},{name:"leftArrow",icon:"t-icon t-arrow-left",id:9,data:{text:"\u5DE6\u7BAD\u5934",width:120,height:60,name:"leftArrow"}},{name:"rightArrow",icon:"t-icon t-arrow-right",id:10,data:{text:"\u53F3\u7BAD\u5934",width:120,height:60,name:"rightArrow"}},{name:"twowayArrow",icon:"t-icon t-twoway-arrow",id:11,data:{text:"\u53CC\u5411\u7BAD\u5934",width:150,height:60,name:"twowayArrow"}},{name:"cloud",icon:"t-icon t-cloud",id:13,data:{text:"\u4E91",width:100,height:100,name:"cloud"}},{name:"message",icon:"t-icon t-msg",id:14,data:{textTop:-.1,text:"\u6D88\u606F\u6846",width:100,height:100,name:"message"}},{name:"file",icon:"t-icon t-file",id:15,data:{text:"\u6587\u6863",width:80,height:100,name:"file"}},{name:"image",icon:"t-icon t-image",id:17,data:{text:"",width:100,height:100,name:"image",image:"https://zhgy.sagoo.cn/base-api/upload_file/2023-11-24/cx73xp2ebryeijgtdt.jpeg"}},{name:"\u52A8\u56FE",icon:"t-icon t-image",data:{text:"",width:100,height:100,name:"gif",image:"/plugin/topo/static/gif.gif"}},{name:"people",icon:"t-icon t-people",id:19,data:{width:70,height:100,name:"people"}},{name:"switch",icon:"t-icon t-kaiguan",data:{name:"switch",checked:!0,onColor:"#1890ff",offColor:"#BFBFBF",width:60,height:30}}]},{name:"\u529F\u80FD\u7EC4\u4EF6",show:!0,list:[{name:"\u65F6\u95F4",icon:"topoicon topo-time",id:16,data:{text:"2022/12/12 12:12:12",width:200,height:40,name:"text",tags:["time-comp"],disableAnchor:!0}},{name:"\u6309\u94AE",icon:"t-icon t-anniu",data:{name:"rectangle",customType:"link-button",x:300,y:200,width:80,height:30,disableAnchor:!0,borderRadius:2,text:"\u6309\u94AE",activeBackground:"#40a9ff",activeColor:"#40a9ff",background:"#1890ff",color:"#1890ff",hoverBackground:"#40a9ff",hoverColor:"#40a9ff",textColor:"#ffffff",hoverTextColor:"#ffffff",activeTextColor:"#ffffff"}}]},{...tA},{...eA},{...iA},{name:"\u7535\u529B\u7CFB\u7EDF-1",show:!0,list:[{font_family:"sg-ele",my_class:"uniE00A",unicode:"e900"},{font_family:"sg-ele",my_class:"uniE04D",unicode:"e97e"},{font_family:"sg-ele",my_class:"uniE04E",unicode:"e97f"},{font_family:"sg-ele",my_class:"uniE005",unicode:"e981"},{font_family:"sg-ele",my_class:"uniE007",unicode:"e98f"},{font_family:"sg-ele",my_class:"uniE006",unicode:"e988"},{font_family:"sg-ele",my_class:"uniE008",unicode:"e996"},{font_family:"sg-ele",my_class:"uniE009",unicode:"e99d"},{font_family:"sg-ele",my_class:"uniE012",unicode:"e9b2"},{font_family:"sg-ele",my_class:"uniE082",unicode:"ea09"},{font_family:"sg-ele",my_class:"uniE088",unicode:"ea0f"},{font_family:"sg-ele",my_class:"uniE090",unicode:"ea11"},{font_family:"sg-ele",my_class:"uniE107",unicode:"ea22"},{font_family:"sg-ele",my_class:"uniE152",unicode:"ea4f"},{font_family:"sg-ele",my_class:"uniE080",unicode:"ea07"},{font_family:"sg-ele",my_class:"uniE084",unicode:"ea0b"},{font_family:"sg-ele",my_class:"uniE059",unicode:"e9f2"},{font_family:"sg-ele",my_class:"uniE10C",unicode:"e9a7"},{font_family:"sg-ele",my_class:"uniE0A0",unicode:"e901"}]},{name:"\u7535\u529B\u7CFB\u7EDF-2",show:!0,list:[{font_family:"sg-ele",my_class:"uniE09E",unicode:"e9a2"},{font_family:"sg-ele",my_class:"uniE010",unicode:"e9a4"},{font_family:"sg-ele",my_class:"uniE014",unicode:"e9bf"},{font_family:"sg-ele",my_class:"uniE040",unicode:"e9df"},{font_family:"sg-ele",my_class:"uniE041",unicode:"e9e0"},{font_family:"sg-ele",my_class:"uniE042",unicode:"e9e1"},{font_family:"sg-ele",my_class:"uniE043",unicode:"e9e2"},{font_family:"sg-ele",my_class:"uniE044",unicode:"e9e3"},{font_family:"sg-ele",my_class:"uniE062",unicode:"e9f5"},{font_family:"sg-ele",my_class:"uniE110",unicode:"ea25"},{font_family:"sg-ele",my_class:"uniE095",unicode:"ea16"},{font_family:"sg-ele",my_class:"uniE0FC",unicode:"e961"},{font_family:"sg-ele",my_class:"uniE02B",unicode:"e96e"},{font_family:"sg-ele",my_class:"uniE06C",unicode:"e98b"},{font_family:"sg-ele",my_class:"uniE0A1",unicode:"e902"},{font_family:"sg-ele",my_class:"uniE0ED",unicode:"e951"},{font_family:"sg-ele",my_class:"uniE00E",unicode:"e943"},{font_family:"sg-ele",my_class:"uniE0DB",unicode:"e93e"},{font_family:"sg-ele",my_class:"uniE0F0",unicode:"e955"},{font_family:"sg-ele",my_class:"uniE0EC",unicode:"e950"},{font_family:"sg-ele",my_class:"uniE0EE",unicode:"e952"},{font_family:"sg-ele",my_class:"uniE00B",unicode:"e911"},{font_family:"sg-ele",my_class:"uniE018",unicode:"e9c9"},{font_family:"sg-ele",my_class:"uniE103",unicode:"ea1e"},{font_family:"sg-ele",my_class:"uniE094",unicode:"ea15"},{font_family:"sg-ele",my_class:"uniE073",unicode:"ea00"}]},{name:"\u7535\u529B\u7CFB\u7EDF-3",show:!0,list:[{font_family:"sg-ele",my_class:"uniE0E4",unicode:"e948"},{font_family:"sg-ele",my_class:"uniE00F",unicode:"e954"},{font_family:"sg-ele",my_class:"uniE05A",unicode:"e982"},{font_family:"sg-ele",my_class:"uniE0AC",unicode:"e90d"},{font_family:"sg-ele",my_class:"uniE0AD",unicode:"e90e"},{font_family:"sg-ele",my_class:"uniE08F",unicode:"e99c"},{font_family:"sg-ele",my_class:"uniE02D",unicode:"e970"},{font_family:"sg-ele",my_class:"uniE09A",unicode:"e99e"},{font_family:"sg-ele",my_class:"uniE00D",unicode:"e932"},{font_family:"sg-ele",my_class:"uniE0C5",unicode:"e928"},{font_family:"sg-ele",my_class:"uniE10B",unicode:"e9a6"},{font_family:"sg-ele",my_class:"uniE00C",unicode:"e922"},{font_family:"sg-ele",my_class:"uniE0F5",unicode:"e95a"},{font_family:"sg-ele",my_class:"uniE01D",unicode:"e969"},{font_family:"sg-ele",my_class:"uniE02C",unicode:"e96f"},{font_family:"sg-ele",my_class:"uniE002",unicode:"e96c"},{font_family:"sg-ele",my_class:"uniE019",unicode:"e9ca"},{font_family:"sg-ele",my_class:"uniE020",unicode:"e9cb"},{font_family:"sg-ele",my_class:"uniE021",unicode:"e9cc"},{font_family:"sg-ele",my_class:"uniE022",unicode:"e9cd"},{font_family:"sg-ele",my_class:"uniE102",unicode:"ea1d"},{font_family:"sg-ele",my_class:"uniE023",unicode:"e9ce"},{font_family:"sg-ele",my_class:"uniE024",unicode:"e9cf"},{font_family:"sg-ele",my_class:"uniE025",unicode:"e9d0"},{font_family:"sg-ele",my_class:"uniE015",unicode:"e9c6"},{font_family:"sg-ele",my_class:"uniE0CB",unicode:"e92d"},{font_family:"sg-ele",my_class:"uniE0E2",unicode:"e946"},{font_family:"sg-ele",my_class:"uniE091",unicode:"ea12"},{font_family:"sg-ele",my_class:"uniE096",unicode:"ea17"}]},{name:"\u7535\u529B\u7CFB\u7EDF-4",show:!0,list:[{font_family:"sg-ele",my_class:"uniE0A2",unicode:"e903"},{font_family:"sg-ele",my_class:"uniE0A3",unicode:"e904"},{font_family:"sg-ele",my_class:"uniE0A6",unicode:"e907"},{font_family:"sg-ele",my_class:"uniE0A8",unicode:"e909"},{font_family:"sg-ele",my_class:"uniE0AE",unicode:"e90f"},{font_family:"sg-ele",my_class:"uniE0C7",unicode:"e929"},{font_family:"sg-ele",my_class:"uniE0C8",unicode:"e92a"},{font_family:"sg-ele",my_class:"uniE0EB",unicode:"e94f"},{font_family:"sg-ele",my_class:"uniE03E",unicode:"e978"},{font_family:"sg-ele",my_class:"uniE05F",unicode:"e987"},{font_family:"sg-ele",my_class:"uniE08A",unicode:"e997"},{font_family:"sg-ele",my_class:"uniE0BC",unicode:"e91e"},{font_family:"sg-ele",my_class:"uniE071",unicode:"e9fe"},{font_family:"sg-ele",my_class:"uniE111",unicode:"ea26"},{font_family:"sg-ele",my_class:"uniE112",unicode:"ea27"},{font_family:"sg-ele",my_class:"uniE100",unicode:"ea1b"},{font_family:"sg-ele",my_class:"uniE108",unicode:"ea23"},{font_family:"sg-ele",my_class:"uniE104",unicode:"ea1f"},{font_family:"sg-ele",my_class:"uniE105",unicode:"ea20"},{font_family:"sg-ele",my_class:"uniE079",unicode:"ea06"},{font_family:"sg-ele",my_class:"uniE072",unicode:"e9ff"},{font_family:"sg-ele",my_class:"uniE10D",unicode:"e9a8"},{font_family:"sg-ele",my_class:"uniE056",unicode:"e9ef"},{font_family:"sg-ele",my_class:"uniE047",unicode:"e9e6"},{font_family:"sg-ele",my_class:"uniE048",unicode:"e9e7"},{font_family:"sg-ele",my_class:"uniE049",unicode:"e9e8"},{font_family:"sg-ele",my_class:"uniE026",unicode:"e9d1"},{font_family:"sg-ele",my_class:"uniE028",unicode:"e9d3"},{font_family:"sg-ele",my_class:"uniE06F",unicode:"e98e"},{font_family:"sg-ele",my_class:"uniE11B",unicode:"e9ad"},{font_family:"sg-ele",my_class:"uniE04A",unicode:"e97b"},{font_family:"sg-ele",my_class:"uniE04B",unicode:"e97c"},{font_family:"sg-ele",my_class:"uniE04C",unicode:"e97d"},{font_family:"sg-ele",my_class:"uniE0EF",unicode:"e953"},{font_family:"sg-ele",my_class:"uniE0D8",unicode:"e93b"},{font_family:"sg-ele",my_class:"uniE0C9",unicode:"e92b"},{font_family:"sg-ele",my_class:"uniE0BE",unicode:"e920"}]},{name:"\u7535\u529B\u7CFB\u7EDF-5",show:!0,list:[{font_family:"sg-ele",my_class:"uniE140",unicode:"ea43"},{font_family:"sg-ele",my_class:"uniE0B5",unicode:"e917"},{font_family:"sg-ele",my_class:"uniE0E8",unicode:"e94c"},{font_family:"sg-ele",my_class:"uniE0B9",unicode:"e91b"},{font_family:"sg-ele",my_class:"uniE0AB",unicode:"e90c"},{font_family:"sg-ele",my_class:"uniE14F",unicode:"e9c5"},{font_family:"sg-ele",my_class:"uniE070",unicode:"e9fd"},{font_family:"sg-ele",my_class:"uniE0A7",unicode:"e908"},{font_family:"sg-ele",my_class:"uniE0A9",unicode:"e90a"},{font_family:"sg-ele",my_class:"uniE0AA",unicode:"e90b"},{font_family:"sg-ele",my_class:"uniE077",unicode:"ea04"},{font_family:"sg-ele",my_class:"uniE06E",unicode:"e98d"},{font_family:"sg-ele",my_class:"uniE10E",unicode:"e9a9"},{font_family:"sg-ele",my_class:"uniE10F",unicode:"e9aa"},{font_family:"sg-ele",my_class:"uniE0DC",unicode:"e93f"},{font_family:"sg-ele",my_class:"uniE0E7",unicode:"e94b"},{font_family:"sg-ele",my_class:"uniE113",unicode:"ea28"},{font_family:"sg-ele",my_class:"uniE127",unicode:"ea36"},{font_family:"sg-ele",my_class:"uniE097",unicode:"ea18"},{font_family:"sg-ele",my_class:"uniE136",unicode:"ea3f"},{font_family:"sg-ele",my_class:"uniE0A5",unicode:"e906"},{font_family:"sg-ele",my_class:"uniE0CE",unicode:"e930"},{font_family:"sg-ele",my_class:"uniE045",unicode:"e9e4"},{font_family:"sg-ele",my_class:"uniE046",unicode:"e9e5"},{font_family:"sg-ele",my_class:"uniE0E0",unicode:"e944"},{font_family:"sg-ele",my_class:"uniE063",unicode:"e9f6"},{font_family:"sg-ele",my_class:"uniE0F1",unicode:"e956"},{font_family:"sg-ele",my_class:"uniE07C",unicode:"e992"},{font_family:"sg-ele",my_class:"uniE07D",unicode:"e993"},{font_family:"sg-ele",my_class:"uniE08C",unicode:"e999"},{font_family:"sg-ele",my_class:"uniE0B3",unicode:"e915"},{font_family:"sg-ele",my_class:"uniE0AF",unicode:"e910"},{font_family:"sg-ele",my_class:"uniE0B2",unicode:"e914"},{font_family:"sg-ele",my_class:"uniE0B6",unicode:"e918"},{font_family:"sg-ele",my_class:"uniE0FB",unicode:"e960"},{font_family:"sg-ele",my_class:"uniE0B8",unicode:"e91a"},{font_family:"sg-ele",my_class:"uniE0CD",unicode:"e92f"},{font_family:"sg-ele",my_class:"uniE0D1",unicode:"e934"},{font_family:"sg-ele",my_class:"uniE0D3",unicode:"e936"},{font_family:"sg-ele",my_class:"uniE0D5",unicode:"e938"},{font_family:"sg-ele",my_class:"uniE087",unicode:"ea0e"},{font_family:"sg-ele",my_class:"uniE0D9",unicode:"e93c"},{font_family:"sg-ele",my_class:"uniE0DD",unicode:"e940"},{font_family:"sg-ele",my_class:"uniE0DE",unicode:"e941"},{font_family:"sg-ele",my_class:"uniE0DF",unicode:"e942"},{font_family:"sg-ele",my_class:"uniE0E3",unicode:"e947"},{font_family:"sg-ele",my_class:"uniE0E5",unicode:"e949"},{font_family:"sg-ele",my_class:"uniE0E6",unicode:"e94a"},{font_family:"sg-ele",my_class:"uniE0E9",unicode:"e94d"},{font_family:"sg-ele",my_class:"uniE0F2",unicode:"e957"},{font_family:"sg-ele",my_class:"uniE0FA",unicode:"e95f"},{font_family:"sg-ele",my_class:"uniE0FF",unicode:"e964"},{font_family:"sg-ele",my_class:"uniE001",unicode:"e965"},{font_family:"sg-ele",my_class:"uniE01A",unicode:"e966"},{font_family:"sg-ele",my_class:"uniE01E",unicode:"e96a"},{font_family:"sg-ele",my_class:"uniE003",unicode:"e973"},{font_family:"sg-ele",my_class:"uniE0E1",unicode:"e945"},{font_family:"sg-ele",my_class:"uniE035",unicode:"e9da"},{font_family:"sg-ele",my_class:"uniE0C0",unicode:"e923"},{font_family:"sg-ele",my_class:"uniE03F",unicode:"e979"},{font_family:"sg-ele",my_class:"uniE05E",unicode:"e986"},{font_family:"sg-ele",my_class:"uniE07F",unicode:"e995"},{font_family:"sg-ele",my_class:"uniE08B",unicode:"e998"},{font_family:"sg-ele",my_class:"uniE08D",unicode:"e99a"},{font_family:"sg-ele",my_class:"uniE09B",unicode:"e99f"},{font_family:"sg-ele",my_class:"uniE09C",unicode:"e9a0"},{font_family:"sg-ele",my_class:"uniE029",unicode:"e9d4"},{font_family:"sg-ele",my_class:"uniE036",unicode:"e9db"},{font_family:"sg-ele",my_class:"uniE037",unicode:"e9dc"},{font_family:"sg-ele",my_class:"uniE038",unicode:"e9dd"},{font_family:"sg-ele",my_class:"uniE053",unicode:"e9ec"},{font_family:"sg-ele",my_class:"uniE054",unicode:"e9ed"},{font_family:"sg-ele",my_class:"uniE076",unicode:"ea03"},{font_family:"sg-ele",my_class:"uniE081",unicode:"ea08"},{font_family:"sg-ele",my_class:"uniE085",unicode:"ea0c"},{font_family:"sg-ele",my_class:"uniE089",unicode:"ea10"},{font_family:"sg-ele",my_class:"uniE098",unicode:"ea19"},{font_family:"sg-ele",my_class:"uniE093",unicode:"ea14"}]},{name:"\u7535\u529B\u7CFB\u7EDF-6",show:!0,list:[{font_family:"sg-ele",my_class:"uniE147",unicode:"ea4a"},{font_family:"sg-ele",my_class:"uniE145",unicode:"ea48"},{font_family:"sg-ele",my_class:"uniE148",unicode:"ea4b"},{font_family:"sg-ele",my_class:"uniE139",unicode:"ea42"},{font_family:"sg-ele",my_class:"uniE133",unicode:"ea3c"},{font_family:"sg-ele",my_class:"uniE135",unicode:"ea3e"},{font_family:"sg-ele",my_class:"uniE064",unicode:"e9f7"},{font_family:"sg-ele",my_class:"uniE065",unicode:"e9f8"},{font_family:"sg-ele",my_class:"uniE066",unicode:"e9f9"},{font_family:"sg-ele",my_class:"uniE067",unicode:"e9fa"},{font_family:"sg-ele",my_class:"uniE068",unicode:"e9fb"},{font_family:"sg-ele",my_class:"uniE14B",unicode:"e9c1"},{font_family:"sg-ele",my_class:"uniE14D",unicode:"e9c3"},{font_family:"sg-ele",my_class:"uniE13A",unicode:"e9b9"},{font_family:"sg-ele",my_class:"uniE13B",unicode:"e9ba"},{font_family:"sg-ele",my_class:"uniE12C",unicode:"e9b4"},{font_family:"sg-ele",my_class:"uniE06D",unicode:"e98c"},{font_family:"sg-ele",my_class:"uniE05C",unicode:"e984"},{font_family:"sg-ele",my_class:"uniE03A",unicode:"e974"},{font_family:"sg-ele",my_class:"uniE03B",unicode:"e975"},{font_family:"sg-ele",my_class:"uniE03C",unicode:"e976"},{font_family:"sg-ele",my_class:"uniE004",unicode:"e97a"},{font_family:"sg-ele",my_class:"uniE134",unicode:"ea3d"},{font_family:"sg-ele",my_class:"uniE128",unicode:"ea37"},{font_family:"sg-ele",my_class:"uniE122",unicode:"ea31"},{font_family:"sg-ele",my_class:"uniE123",unicode:"ea32"},{font_family:"sg-ele",my_class:"uniE120",unicode:"ea2f"},{font_family:"sg-ele",my_class:"uniE039",unicode:"e9de"},{font_family:"sg-ele",my_class:"uniE03D",unicode:"e977"},{font_family:"sg-ele",my_class:"uniE05D",unicode:"e985"},{font_family:"sg-ele",my_class:"uniE0EA",unicode:"e94e"},{font_family:"sg-ele",my_class:"uniE08E",unicode:"e99b"},{font_family:"sg-ele",my_class:"uniE07A",unicode:"e990"},{font_family:"sg-ele",my_class:"uniE07B",unicode:"e991"},{font_family:"sg-ele",my_class:"uniE074",unicode:"ea01"},{font_family:"sg-ele",my_class:"uniE078",unicode:"ea05"}]},{name:"\u7535\u529B\u7CFB\u7EDF-7",show:!0,list:[{font_family:"sg-ele",my_class:"uniE02A",unicode:"e96d"},{font_family:"sg-ele",my_class:"uniE02E",unicode:"e971"},{font_family:"sg-ele",my_class:"uniE02F",unicode:"e972"},{font_family:"sg-ele",my_class:"uniE131",unicode:"ea3a"},{font_family:"sg-ele",my_class:"uniE132",unicode:"ea3b"},{font_family:"sg-ele",my_class:"uniE143",unicode:"ea46"},{font_family:"sg-ele",my_class:"uniE0A4",unicode:"e905"},{font_family:"sg-ele",my_class:"uniE144",unicode:"ea47"},{font_family:"sg-ele",my_class:"uniE146",unicode:"ea49"},{font_family:"sg-ele",my_class:"uniE149",unicode:"ea4c"},{font_family:"sg-ele",my_class:"uniE150",unicode:"ea4d"},{font_family:"sg-ele",my_class:"uniE154",unicode:"ea50"},{font_family:"sg-ele",my_class:"uniE151",unicode:"ea4e"},{font_family:"sg-ele",my_class:"uniE138",unicode:"ea41"},{font_family:"sg-ele",my_class:"uniE0C2",unicode:"e925"},{font_family:"sg-ele",my_class:"uniE027",unicode:"e9d2"},{font_family:"sg-ele",my_class:"uniE141",unicode:"ea44"},{font_family:"sg-ele",my_class:"uniE126",unicode:"ea35"},{font_family:"sg-ele",my_class:"uniE129",unicode:"ea38"},{font_family:"sg-ele",my_class:"uniE130",unicode:"ea39"},{font_family:"sg-ele",my_class:"uniE069",unicode:"e9fc"},{font_family:"sg-ele",my_class:"uniE057",unicode:"e9f0"},{font_family:"sg-ele",my_class:"uniE058",unicode:"e9f1"},{font_family:"sg-ele",my_class:"uniE030",unicode:"e9d5"},{font_family:"sg-ele",my_class:"uniE031",unicode:"e9d6"},{font_family:"sg-ele",my_class:"uniE032",unicode:"e9d7"},{font_family:"sg-ele",my_class:"uniE033",unicode:"e9d8"},{font_family:"sg-ele",my_class:"uniE034",unicode:"e9d9"},{font_family:"sg-ele",my_class:"uniE12B",unicode:"e9b3"},{font_family:"sg-ele",my_class:"uniE12D",unicode:"e9b5"},{font_family:"sg-ele",my_class:"uniE12E",unicode:"e9b6"},{font_family:"sg-ele",my_class:"uniE12F",unicode:"e9b7"},{font_family:"sg-ele",my_class:"uniE14A",unicode:"e9c0"},{font_family:"sg-ele",my_class:"uniE14C",unicode:"e9c2"},{font_family:"sg-ele",my_class:"uniE14E",unicode:"e9c4"},{font_family:"sg-ele",my_class:"uniE06A",unicode:"e989"},{font_family:"sg-ele",my_class:"uniE011",unicode:"e9ab"},{font_family:"sg-ele",my_class:"uniE075",unicode:"ea02"},{font_family:"sg-ele",my_class:"uniE083",unicode:"ea0a"},{font_family:"sg-ele",my_class:"uniE0C4",unicode:"e927"},{font_family:"sg-ele",my_class:"uniE0B1",unicode:"e913"},{font_family:"sg-ele",my_class:"uniE0FE",unicode:"e963"}]},{name:"\u7535\u529B\u7CFB\u7EDF-8",show:!0,list:[{font_family:"sg-ele",my_class:"uniE114",unicode:"ea29"},{font_family:"sg-ele",my_class:"uniE115",unicode:"ea2a"},{font_family:"sg-ele",my_class:"uniE116",unicode:"ea2b"},{font_family:"sg-ele",my_class:"uniE117",unicode:"ea2c"},{font_family:"sg-ele",my_class:"uniE118",unicode:"ea2d"},{font_family:"sg-ele",my_class:"uniE119",unicode:"ea2e"},{font_family:"sg-ele",my_class:"uniE121",unicode:"ea30"},{font_family:"sg-ele",my_class:"uniE124",unicode:"ea33"},{font_family:"sg-ele",my_class:"uniE0B0",unicode:"e912"},{font_family:"sg-ele",my_class:"uniE0B7",unicode:"e919"},{font_family:"sg-ele",my_class:"uniE0BA",unicode:"e91c"},{font_family:"sg-ele",my_class:"uniE0BB",unicode:"e91d"},{font_family:"sg-ele",my_class:"uniE0BD",unicode:"e91f"},{font_family:"sg-ele",my_class:"uniE0C1",unicode:"e924"},{font_family:"sg-ele",my_class:"uniE0CC",unicode:"e92e"},{font_family:"sg-ele",my_class:"uniE0DA",unicode:"e93d"},{font_family:"sg-ele",my_class:"uniE0F3",unicode:"e958"},{font_family:"sg-ele",my_class:"uniE0F4",unicode:"e959"},{font_family:"sg-ele",my_class:"uniE0F6",unicode:"e95b"},{font_family:"sg-ele",my_class:"uniE0F7",unicode:"e95c"},{font_family:"sg-ele",my_class:"uniE0F8",unicode:"e95d"},{font_family:"sg-ele",my_class:"uniE0F9",unicode:"e95e"},{font_family:"sg-ele",my_class:"uniE0FD",unicode:"e962"},{font_family:"sg-ele",my_class:"uniE04F",unicode:"e980"},{font_family:"sg-ele",my_class:"uniE05B",unicode:"e983"},{font_family:"sg-ele",my_class:"uniE11A",unicode:"e9ac"},{font_family:"sg-ele",my_class:"uniE11C",unicode:"e9ae"},{font_family:"sg-ele",my_class:"uniE11D",unicode:"e9af"},{font_family:"sg-ele",my_class:"uniE11E",unicode:"e9b0"},{font_family:"sg-ele",my_class:"uniE13C",unicode:"e9bb"},{font_family:"sg-ele",my_class:"uniE13D",unicode:"e9bc"},{font_family:"sg-ele",my_class:"uniE13E",unicode:"e9bd"},{font_family:"sg-ele",my_class:"uniE052",unicode:"e9eb"},{font_family:"sg-ele",my_class:"uniE055",unicode:"e9ee"},{font_family:"sg-ele",my_class:"uniE060",unicode:"e9f3"},{font_family:"sg-ele",my_class:"uniE0B4",unicode:"e916"},{font_family:"sg-ele",my_class:"uniE0BF",unicode:"e921"},{font_family:"sg-ele",my_class:"uniE0CA",unicode:"e92c"},{font_family:"sg-ele",my_class:"uniE0D7",unicode:"e93a"},{font_family:"sg-ele",my_class:"uniE06B",unicode:"e98a"},{font_family:"sg-ele",my_class:"uniE10A",unicode:"e9a5"},{font_family:"sg-ele",my_class:"uniE017",unicode:"e9c8"},{font_family:"sg-ele",my_class:"uniE050",unicode:"e9e9"},{font_family:"sg-ele",my_class:"uniE086",unicode:"ea0d"},{font_family:"sg-ele",my_class:"uniE099",unicode:"ea1a"},{font_family:"sg-ele",my_class:"uniE101",unicode:"ea1c"}]},{name:"\u7535\u529B\u7CFB\u7EDF-9",show:!0,list:[{font_family:"sg-ele",my_class:"uniE106",unicode:"ea21"},{font_family:"sg-ele",my_class:"uniE109",unicode:"ea24"},{font_family:"sg-ele",my_class:"uniE061",unicode:"e9f4"},{font_family:"sg-ele",my_class:"uniE092",unicode:"ea13"},{font_family:"sg-ele",my_class:"uniE01B",unicode:"e967"},{font_family:"sg-ele",my_class:"uniE01C",unicode:"e968"},{font_family:"sg-ele",my_class:"uniE09D",unicode:"e9a1"},{font_family:"sg-ele",my_class:"uniE09F",unicode:"e9a3"},{font_family:"sg-ele",my_class:"uniE11F",unicode:"e9b1"},{font_family:"sg-ele",my_class:"uniE13F",unicode:"e9be"},{font_family:"sg-ele",my_class:"uniE016",unicode:"e9c7"},{font_family:"sg-ele",my_class:"uniE125",unicode:"ea34"},{font_family:"sg-ele",my_class:"uniE137",unicode:"ea40"},{font_family:"sg-ele",my_class:"uniE142",unicode:"ea45"},{font_family:"sg-ele",my_class:"uniE0C3",unicode:"e926"},{font_family:"sg-ele",my_class:"uniE0CF",unicode:"e931"},{font_family:"sg-ele",my_class:"uniE0D0",unicode:"e933"},{font_family:"sg-ele",my_class:"uniE0D2",unicode:"e935"},{font_family:"sg-ele",my_class:"uniE0D4",unicode:"e937"},{font_family:"sg-ele",my_class:"uniE0D6",unicode:"e939"},{font_family:"sg-ele",my_class:"uniE051",unicode:"e9ea"}]},{name:"\u8111\u56FE",show:!1,list:[{name:"mindNode",icon:"t-icon t-zhuti",data:{text:"\u4E3B\u9898",width:200,height:50,name:"mindNode",borderRadius:.5}},{name:"mindLine",icon:"t-icon t-zizhuti",data:{text:"\u5B50\u4E3B\u9898",width:160,height:40,name:"mindLine"}}]},{name:"\u6D41\u7A0B\u56FE",show:!1,list:[{name:"\u5F00\u59CB/\u7ED3\u675F",icon:"t-icon t-flow-start",id:21,data:{text:"\u5F00\u59CB/\u7ED3\u675F",width:120,height:40,borderRadius:.5,name:"rectangle"}},{name:"\u6D41\u7A0B",icon:"t-icon t-rectangle",id:22,data:{text:"\u6D41\u7A0B",width:120,height:40,name:"rectangle"}},{name:"\u5224\u5B9A",icon:"t-icon t-diamond",id:23,data:{text:"\u5224\u5B9A",width:120,height:60,name:"diamond"}},{name:"\u6570\u636E",icon:"t-icon t-flow-data",id:24,data:{text:"\u6570\u636E",width:120,height:50,name:"flowData"}},{name:"\u51C6\u5907",icon:"t-icon t-flow-ready",id:25,data:{text:"\u51C6\u5907",width:120,height:50,name:"hexagon"}},{name:"\u5B50\u6D41\u7A0B",icon:"t-icon t-flow-subprocess",id:26,data:{text:"\u5B50\u6D41\u7A0B",width:120,height:50,name:"flowSubprocess"}},{name:"\u6570\u636E\u5E93",icon:"t-icon t-db",id:27,data:{text:"\u6570\u636E\u5E93",width:80,height:120,name:"flowDb"}},{name:"\u6587\u6863",icon:"t-icon t-flow-document",id:28,data:{text:"\u6587\u6863",width:120,height:100,name:"flowDocument"}},{name:"\u5185\u90E8\u5B58\u50A8",icon:"t-icon t-internal-storage",id:29,data:{text:"\u5185\u90E8\u5B58\u50A8",width:120,height:80,name:"flowInternalStorage"}},{name:"\u5916\u90E8\u5B58\u50A8",icon:"t-icon t-extern-storage",id:30,data:{text:"\u5916\u90E8\u5B58\u50A8",width:120,height:80,name:"flowExternStorage"}},{name:"\u961F\u5217",icon:"t-icon t-flow-queue",id:31,data:{text:"\u961F\u5217",width:100,height:100,name:"flowQueue"}},{name:"\u624B\u52A8\u8F93\u5165",icon:"t-icon t-flow-manually",id:32,data:{text:"\u624B\u52A8\u8F93\u5165",width:120,height:80,name:"flowManually"}},{name:"\u5C55\u793A",icon:"t-icon t-flow-display",id:33,data:{text:"\u5C55\u793A",width:120,height:80,name:"flowDisplay"}},{name:"\u5E76\u884C\u6A21\u5F0F",icon:"t-icon t-flow-parallel",id:34,data:{text:"\u5E76\u884C\u6A21\u5F0F",width:120,height:50,name:"flowParallel"}},{name:"\u6CE8\u91CA",icon:"t-icon t-flow-comment",id:35,data:{text:"\u6CE8\u91CA",width:100,height:100,name:"flowComment"}}]},{name:"\u6D3B\u52A8\u56FE",show:!1,list:[{name:"\u5F00\u59CB",icon:"t-icon t-inital",id:36,data:{text:"",width:30,height:30,name:"circle",background:"#555",color:"transparent"}},{name:"\u7ED3\u675F",icon:"t-icon t-final",id:37,data:{width:30,height:30,name:"activityFinal"}},{name:"\u6D3B\u52A8",icon:"t-icon t-action",id:38,data:{text:"\u6D3B\u52A8",width:120,height:50,borderRadius:.25,name:"rectangle"}},{name:"\u51B3\u7B56/\u5408\u5E76",icon:"t-icon t-diamond",id:39,data:{text:"\u51B3\u7B56/\u5408\u5E76",width:120,height:50,name:"diamond"}},{name:"\u5782\u76F4\u6CF3\u9053",icon:"t-icon t-swimlane-v",id:40,data:{text:"\u5782\u76F4\u6CF3\u9053",width:200,height:500,name:"swimlaneV",textHeight:.1}},{name:"\u6C34\u5E73\u6CF3\u9053",icon:"t-icon t-swimlane-h",id:41,data:{text:"\u6C34\u5E73\u6CF3\u9053",width:500,height:200,name:"swimlaneH",textWidth:.01,textLeft:.04,textAlign:"start"}},{name:"\u5782\u76F4\u5206\u5C94/\u6C47\u5408",icon:"t-icon t-fork-v",id:42,data:{text:"\u5782\u76F4\u5206\u5C94/\u6C47\u5408",width:10,height:150,name:"forkV",fillStyle:"#555",strokeStyle:"transparent"}},{name:"\u6C34\u5E73\u5206\u5C94/\u6C47\u5408",icon:"t-icon t-fork",id:43,data:{text:"\u6C34\u5E73\u5206\u5C94/\u6C47\u5408",width:150,height:10,name:"forkH",fillStyle:"#555",strokeStyle:"transparent"}}]},{name:"\u65F6\u5E8F\u56FE\u548C\u7C7B\u56FE",show:!1,list:[{name:"\u751F\u547D\u7EBF",icon:"t-icon t-lifeline",id:44,data:{text:"\u751F\u547D\u7EBF",width:150,height:400,textHeight:50,name:"lifeline"}},{name:"\u6FC0\u6D3B",icon:"t-icon t-focus",id:45,data:{text:"\u6FC0\u6D3B",width:12,height:200,name:"sequenceFocus"}},{name:"\u7B80\u5355\u7C7B",icon:"t-icon t-simple-class",id:46,data:{text:"Topolgoy",width:270,height:200,textHeight:.2,name:"simpleClass",textAlign:"center",textBaseline:"top",textTop:10,list:[{text:`- name: string
  76. + setName(name: string): void`}]}},{name:"\u7C7B",icon:"t-icon t-class",id:47,data:{text:"Topolgoy",width:270,height:200,textHeight:.2,name:"interfaceClass",textAlign:"center",textBaseline:"top",textTop:10,list:[{text:"- name: string"},{text:"+ setName(name: string): void"}]}}]}];var vg={exports:{}},Vc={exports:{}},gg=function(t,i){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(i,r)}},nA=gg,Cn=Object.prototype.toString;function $c(e){return Array.isArray(e)}function Ec(e){return typeof e>"u"}function rA(e){return e!==null&&!Ec(e)&&e.constructor!==null&&!Ec(e.constructor)&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function yg(e){return Cn.call(e)==="[object ArrayBuffer]"}function sA(e){return Cn.call(e)==="[object FormData]"}function aA(e){var t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&yg(e.buffer),t}function oA(e){return typeof e=="string"}function lA(e){return typeof e=="number"}function mg(e){return e!==null&&typeof e=="object"}function Ba(e){if(Cn.call(e)!=="[object Object]")return!1;var t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function cA(e){return Cn.call(e)==="[object Date]"}function hA(e){return Cn.call(e)==="[object File]"}function uA(e){return Cn.call(e)==="[object Blob]"}function pg(e){return Cn.call(e)==="[object Function]"}function fA(e){return mg(e)&&pg(e.pipe)}function dA(e){return Cn.call(e)==="[object URLSearchParams]"}function vA(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function gA(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function Kc(e,t){if(!(e===null||typeof e>"u"))if(typeof e!="object"&&(e=[e]),$c(e))for(var i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(null,e[r],r,e)}function Ac(){var e={};function t(r,s){Ba(e[s])&&Ba(r)?e[s]=Ac(e[s],r):Ba(r)?e[s]=Ac({},r):$c(r)?e[s]=r.slice():e[s]=r}for(var i=0,n=arguments.length;i<n;i++)Kc(arguments[i],t);return e}function yA(e,t,i){return Kc(t,function(r,s){i&&typeof r=="function"?e[s]=nA(r,i):e[s]=r}),e}function mA(e){return e.charCodeAt(0)===65279&&(e=e.slice(1)),e}var We={isArray:$c,isArrayBuffer:yg,isBuffer:rA,isFormData:sA,isArrayBufferView:aA,isString:oA,isNumber:lA,isObject:mg,isPlainObject:Ba,isUndefined:Ec,isDate:cA,isFile:hA,isBlob:uA,isFunction:pg,isStream:fA,isURLSearchParams:dA,isStandardBrowserEnv:gA,forEach:Kc,merge:Ac,extend:yA,trim:vA,stripBOM:mA},xr=We;function hd(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var wg=function(t,i,n){if(!i)return t;var r;if(n)r=n(i);else if(xr.isURLSearchParams(i))r=i.toString();else{var s=[];xr.forEach(i,function(c,u){c===null||typeof c>"u"||(xr.isArray(c)?u=u+"[]":c=[c],xr.forEach(c,function(d){xr.isDate(d)?d=d.toISOString():xr.isObject(d)&&(d=JSON.stringify(d)),s.push(hd(u)+"="+hd(d))}))}),r=s.join("&")}if(r){var a=t.indexOf("#");a!==-1&&(t=t.slice(0,a)),t+=(t.indexOf("?")===-1?"?":"&")+r}return t},pA=We;function Qa(){this.handlers=[]}Qa.prototype.use=function(t,i,n){return this.handlers.push({fulfilled:t,rejected:i,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};Qa.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)};Qa.prototype.forEach=function(t){pA.forEach(this.handlers,function(n){n!==null&&t(n)})};var wA=Qa,bA=We,xA=function(t,i){bA.forEach(t,function(r,s){s!==i&&s.toUpperCase()===i.toUpperCase()&&(t[i]=r,delete t[s])})},bg=function(t,i,n,r,s){return t.config=i,n&&(t.code=n),t.request=r,t.response=s,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t},Nl,ud;function xg(){if(ud)return Nl;ud=1;var e=bg;return Nl=function(i,n,r,s,a){var l=new Error(i);return e(l,n,r,s,a)},Nl}var Fl,fd;function _A(){if(fd)return Fl;fd=1;var e=xg();return Fl=function(i,n,r){var s=r.config.validateStatus;!r.status||!s||s(r.status)?i(r):n(e("Request failed with status code "+r.status,r.config,null,r.request,r))},Fl}var zl,dd;function kA(){if(dd)return zl;dd=1;var e=We;return zl=e.isStandardBrowserEnv()?function(){return{write:function(n,r,s,a,l,c){var u=[];u.push(n+"="+encodeURIComponent(r)),e.isNumber(s)&&u.push("expires="+new Date(s).toGMTString()),e.isString(a)&&u.push("path="+a),e.isString(l)&&u.push("domain="+l),c===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(n){var r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),zl}var Hl,vd;function EA(){return vd||(vd=1,Hl=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}),Hl}var Ul,gd;function AA(){return gd||(gd=1,Ul=function(t,i){return i?t.replace(/\/+$/,"")+"/"+i.replace(/^\/+/,""):t}),Ul}var Wl,yd;function RA(){if(yd)return Wl;yd=1;var e=EA(),t=AA();return Wl=function(n,r){return n&&!e(r)?t(n,r):r},Wl}var ql,md;function CA(){if(md)return ql;md=1;var e=We,t=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return ql=function(n){var r={},s,a,l;return n&&e.forEach(n.split(`
  77. `),function(u){if(l=u.indexOf(":"),s=e.trim(u.substr(0,l)).toLowerCase(),a=e.trim(u.substr(l+1)),s){if(r[s]&&t.indexOf(s)>=0)return;s==="set-cookie"?r[s]=(r[s]?r[s]:[]).concat([a]):r[s]=r[s]?r[s]+", "+a:a}}),r},ql}var jl,pd;function TA(){if(pd)return jl;pd=1;var e=We;return jl=e.isStandardBrowserEnv()?function(){var i=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),r;function s(a){var l=a;return i&&(n.setAttribute("href",l),l=n.href),n.setAttribute("href",l),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(l){var c=e.isString(l)?s(l):l;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}(),jl}var Vl,wd;function to(){if(wd)return Vl;wd=1;function e(t){this.message=t}return e.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},e.prototype.__CANCEL__=!0,Vl=e,Vl}var $l,bd;function xd(){if(bd)return $l;bd=1;var e=We,t=_A(),i=kA(),n=wg,r=RA(),s=CA(),a=TA(),l=xg(),c=eo(),u=to();return $l=function(d){return new Promise(function(v,y){var w=d.data,p=d.headers,_=d.responseType,A;function x(){d.cancelToken&&d.cancelToken.unsubscribe(A),d.signal&&d.signal.removeEventListener("abort",A)}e.isFormData(w)&&delete p["Content-Type"];var E=new XMLHttpRequest;if(d.auth){var I=d.auth.username||"",M=d.auth.password?unescape(encodeURIComponent(d.auth.password)):"";p.Authorization="Basic "+btoa(I+":"+M)}var B=r(d.baseURL,d.url);E.open(d.method.toUpperCase(),n(B,d.params,d.paramsSerializer),!0),E.timeout=d.timeout;function D(){if(!!E){var Q="getAllResponseHeaders"in E?s(E.getAllResponseHeaders()):null,C=!_||_==="text"||_==="json"?E.responseText:E.response,T={data:C,status:E.status,statusText:E.statusText,headers:Q,config:d,request:E};t(function(O){v(O),x()},function(O){y(O),x()},T),E=null}}if("onloadend"in E?E.onloadend=D:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(D)},E.onabort=function(){!E||(y(l("Request aborted",d,"ECONNABORTED",E)),E=null)},E.onerror=function(){y(l("Network Error",d,null,E)),E=null},E.ontimeout=function(){var C=d.timeout?"timeout of "+d.timeout+"ms exceeded":"timeout exceeded",T=d.transitional||c.transitional;d.timeoutErrorMessage&&(C=d.timeoutErrorMessage),y(l(C,d,T.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",E)),E=null},e.isStandardBrowserEnv()){var q=(d.withCredentials||a(B))&&d.xsrfCookieName?i.read(d.xsrfCookieName):void 0;q&&(p[d.xsrfHeaderName]=q)}"setRequestHeader"in E&&e.forEach(p,function(C,T){typeof w>"u"&&T.toLowerCase()==="content-type"?delete p[T]:E.setRequestHeader(T,C)}),e.isUndefined(d.withCredentials)||(E.withCredentials=!!d.withCredentials),_&&_!=="json"&&(E.responseType=d.responseType),typeof d.onDownloadProgress=="function"&&E.addEventListener("progress",d.onDownloadProgress),typeof d.onUploadProgress=="function"&&E.upload&&E.upload.addEventListener("progress",d.onUploadProgress),(d.cancelToken||d.signal)&&(A=function(Q){!E||(y(!Q||Q&&Q.type?new u("canceled"):Q),E.abort(),E=null)},d.cancelToken&&d.cancelToken.subscribe(A),d.signal&&(d.signal.aborted?A():d.signal.addEventListener("abort",A))),w||(w=null),E.send(w)})},$l}var Kl,_d;function eo(){if(_d)return Kl;_d=1;var e=We,t=xA,i=bg,n={"Content-Type":"application/x-www-form-urlencoded"};function r(c,u){!e.isUndefined(c)&&e.isUndefined(c["Content-Type"])&&(c["Content-Type"]=u)}function s(){var c;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(c=xd()),c}function a(c,u,h){if(e.isString(c))try{return(u||JSON.parse)(c),e.trim(c)}catch(d){if(d.name!=="SyntaxError")throw d}return(h||JSON.stringify)(c)}var l={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:s(),transformRequest:[function(u,h){return t(h,"Accept"),t(h,"Content-Type"),e.isFormData(u)||e.isArrayBuffer(u)||e.isBuffer(u)||e.isStream(u)||e.isFile(u)||e.isBlob(u)?u:e.isArrayBufferView(u)?u.buffer:e.isURLSearchParams(u)?(r(h,"application/x-www-form-urlencoded;charset=utf-8"),u.toString()):e.isObject(u)||h&&h["Content-Type"]==="application/json"?(r(h,"application/json"),a(u)):u}],transformResponse:[function(u){var h=this.transitional||l.transitional,d=h&&h.silentJSONParsing,g=h&&h.forcedJSONParsing,v=!d&&this.responseType==="json";if(v||g&&e.isString(u)&&u.length)try{return JSON.parse(u)}catch(y){if(v)throw y.name==="SyntaxError"?i(y,this,"E_JSON_PARSE"):y}return u}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(u){return u>=200&&u<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};return e.forEach(["delete","get","head"],function(u){l.headers[u]={}}),e.forEach(["post","put","patch"],function(u){l.headers[u]=e.merge(n)}),Kl=l,Kl}var SA=We,PA=eo(),IA=function(t,i,n){var r=this||PA;return SA.forEach(n,function(a){t=a.call(r,t,i)}),t},Yl,kd;function _g(){return kd||(kd=1,Yl=function(t){return!!(t&&t.__CANCEL__)}),Yl}var Ed=We,Xl=IA,LA=_g(),DA=eo(),MA=to();function Gl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new MA("canceled")}var BA=function(t){Gl(t),t.headers=t.headers||{},t.data=Xl.call(t,t.data,t.headers,t.transformRequest),t.headers=Ed.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),Ed.forEach(["delete","get","head","post","put","patch","common"],function(r){delete t.headers[r]});var i=t.adapter||DA.adapter;return i(t).then(function(r){return Gl(t),r.data=Xl.call(t,r.data,r.headers,t.transformResponse),r},function(r){return LA(r)||(Gl(t),r&&r.response&&(r.response.data=Xl.call(t,r.response.data,r.response.headers,t.transformResponse))),Promise.reject(r)})},Xe=We,kg=function(t,i){i=i||{};var n={};function r(h,d){return Xe.isPlainObject(h)&&Xe.isPlainObject(d)?Xe.merge(h,d):Xe.isPlainObject(d)?Xe.merge({},d):Xe.isArray(d)?d.slice():d}function s(h){if(Xe.isUndefined(i[h])){if(!Xe.isUndefined(t[h]))return r(void 0,t[h])}else return r(t[h],i[h])}function a(h){if(!Xe.isUndefined(i[h]))return r(void 0,i[h])}function l(h){if(Xe.isUndefined(i[h])){if(!Xe.isUndefined(t[h]))return r(void 0,t[h])}else return r(void 0,i[h])}function c(h){if(h in i)return r(t[h],i[h]);if(h in t)return r(void 0,t[h])}var u={url:a,method:a,data:a,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:c};return Xe.forEach(Object.keys(t).concat(Object.keys(i)),function(d){var g=u[d]||s,v=g(d);Xe.isUndefined(v)&&g!==c||(n[d]=v)}),n},Zl,Ad;function Eg(){return Ad||(Ad=1,Zl={version:"0.25.0"}),Zl}var OA=Eg().version,Yc={};["object","boolean","number","function","string","symbol"].forEach(function(e,t){Yc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var Rd={};Yc.transitional=function(t,i,n){function r(s,a){return"[Axios v"+OA+"] Transitional option '"+s+"'"+a+(n?". "+n:"")}return function(s,a,l){if(t===!1)throw new Error(r(a," has been removed"+(i?" in "+i:"")));return i&&!Rd[a]&&(Rd[a]=!0,console.warn(r(a," has been deprecated since v"+i+" and will be removed in the near future"))),t?t(s,a,l):!0}};function NA(e,t,i){if(typeof e!="object")throw new TypeError("options must be an object");for(var n=Object.keys(e),r=n.length;r-- >0;){var s=n[r],a=t[s];if(a){var l=e[s],c=l===void 0||a(l,s,e);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(i!==!0)throw Error("Unknown option "+s)}}var FA={assertOptions:NA,validators:Yc},Ag=We,zA=wg,Cd=wA,Td=BA,io=kg,Rg=FA,_r=Rg.validators;function Rs(e){this.defaults=e,this.interceptors={request:new Cd,response:new Cd}}Rs.prototype.request=function(t,i){if(typeof t=="string"?(i=i||{},i.url=t):i=t||{},!i.url)throw new Error("Provided config url is not valid");i=io(this.defaults,i),i.method?i.method=i.method.toLowerCase():this.defaults.method?i.method=this.defaults.method.toLowerCase():i.method="get";var n=i.transitional;n!==void 0&&Rg.assertOptions(n,{silentJSONParsing:_r.transitional(_r.boolean),forcedJSONParsing:_r.transitional(_r.boolean),clarifyTimeoutError:_r.transitional(_r.boolean)},!1);var r=[],s=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(i)===!1||(s=s&&v.synchronous,r.unshift(v.fulfilled,v.rejected))});var a=[];this.interceptors.response.forEach(function(v){a.push(v.fulfilled,v.rejected)});var l;if(!s){var c=[Td,void 0];for(Array.prototype.unshift.apply(c,r),c=c.concat(a),l=Promise.resolve(i);c.length;)l=l.then(c.shift(),c.shift());return l}for(var u=i;r.length;){var h=r.shift(),d=r.shift();try{u=h(u)}catch(g){d(g);break}}try{l=Td(u)}catch(g){return Promise.reject(g)}for(;a.length;)l=l.then(a.shift(),a.shift());return l};Rs.prototype.getUri=function(t){if(!t.url)throw new Error("Provided config url is not valid");return t=io(this.defaults,t),zA(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")};Ag.forEach(["delete","get","head","options"],function(t){Rs.prototype[t]=function(i,n){return this.request(io(n||{},{method:t,url:i,data:(n||{}).data}))}});Ag.forEach(["post","put","patch"],function(t){Rs.prototype[t]=function(i,n,r){return this.request(io(r||{},{method:t,url:i,data:n}))}});var HA=Rs,Jl,Sd;function UA(){if(Sd)return Jl;Sd=1;var e=to();function t(i){if(typeof i!="function")throw new TypeError("executor must be a function.");var n;this.promise=new Promise(function(a){n=a});var r=this;this.promise.then(function(s){if(!!r._listeners){var a,l=r._listeners.length;for(a=0;a<l;a++)r._listeners[a](s);r._listeners=null}}),this.promise.then=function(s){var a,l=new Promise(function(c){r.subscribe(c),a=c}).then(s);return l.cancel=function(){r.unsubscribe(a)},l},i(function(a){r.reason||(r.reason=new e(a),n(r.reason))})}return t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},t.prototype.subscribe=function(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]},t.prototype.unsubscribe=function(n){if(!!this._listeners){var r=this._listeners.indexOf(n);r!==-1&&this._listeners.splice(r,1)}},t.source=function(){var n,r=new t(function(a){n=a});return{token:r,cancel:n}},Jl=t,Jl}var Ql,Pd;function WA(){return Pd||(Pd=1,Ql=function(t){return function(n){return t.apply(null,n)}}),Ql}var tc,Id;function qA(){if(Id)return tc;Id=1;var e=We;return tc=function(i){return e.isObject(i)&&i.isAxiosError===!0},tc}var Ld=We,jA=gg,Oa=HA,VA=kg,$A=eo();function Cg(e){var t=new Oa(e),i=jA(Oa.prototype.request,t);return Ld.extend(i,Oa.prototype,t),Ld.extend(i,t),i.create=function(r){return Cg(VA(e,r))},i}var Li=Cg($A);Li.Axios=Oa;Li.Cancel=to();Li.CancelToken=UA();Li.isCancel=_g();Li.VERSION=Eg().version;Li.all=function(t){return Promise.all(t)};Li.spread=WA();Li.isAxiosError=qA();Vc.exports=Li;Vc.exports.default=Li;(function(e){e.exports=Vc.exports})(vg);const en=Jx(vg.exports);en.defaults.baseURL=window.allEnv.topo.server;en.defaults.timeout=Number("50000");en.defaults.headers.post["Content-Type"]="application/json;charset=utf-8";let Dd=!1;en.interceptors.request.use(e=>{const t=localStorage.getItem("token");return t&&(e.headers.Authorization="Bearer "+t),e});en.interceptors.response.use(e=>{var t,i,n;return e.data&&e.data.code===0?Promise.resolve((t=e.data)==null?void 0:t.data):e.data&&e.data.code===401?(setTimeout(()=>{window.location.href="/"},1e3),mr.error((i=e.data)==null?void 0:i.message)):(mr.error((n=e.data)==null?void 0:n.message),Promise.reject(e.data))},e=>{var t,i;return Dd?!1:e.response?(mr.closeAll(),mr.error(((t=e.response.data)==null?void 0:t.msg)||"\u767B\u5F55\u5931\u6548\uFF0C\u7A0D\u540E\u91CD\u65B0\u767B\u5F55"),((i=e.response.data)==null?void 0:i.code)===401&&(localStorage.removeItem("token"),setTimeout(()=>{window.location.href="/"},1e3)),Promise.reject(e)):(Dd=!0,mr.closeAll(),mr.error("\u8BF7\u6C42\u51FA\u9519\uFF01\uFF01\uFF01"),Promise.reject(e))});function qi(e,t){return en.post(e,t)}function ec(e,t){return en({url:e,method:"delete",data:t})}function ji(e,t){return en.get(e,{params:t})}function KA(e,t){return en.put(e,t)}const tT={tokenRefresh:()=>qi("/tokenRefresh",{appId:0}),login:()=>qi("/jwt/login",{username:"hxy",password:"hxy123"}),folder:()=>ji("/configure/folder/list"),folderData:e=>ji("/configure/diagram/getInfoByFolderId",{folderId:e}),folderAdd:(e,t)=>qi("/configure/folder/add",{name:e,types:t}),folderEdit:(e,t,i)=>qi("/configure/folder/edit",{name:e,types:t,id:i}),folderDel:e=>ec("/configure/folder/del",{id:e}),topologyAdd:e=>qi("/configure/diagram/add",e),topologyEdit:e=>qi("/configure/diagram/edit",e),topologyDel:e=>ec("/configure/diagram/del",{id:e}),topology:e=>ji("/configure/diagram/getInfoById",{id:e}),topologyName:e=>ji("/configure/diagram/getInfoByName",{name:e}),deviceList:()=>ji("/product/device/list"),functionList:e=>ji("/product/tsl/function/all",e),devicePoint:e=>ji(`/configure/devicePoint/${e}`),do:e=>qi("/product/function/do",e),uploadImg:e=>qi("/common/singleImg",e),drawer:{pointAdd:e=>qi("/configure/point/add",e),pointDel:e=>ec("/configure/point/del",{id:e}),pointEdit:e=>KA("/configure/point/edit",e),getEchartInfo:e=>ji("/configure/point/getEchartInfo",e),getInfoByDiagramIdAndPointId:e=>ji("/configure/point/getInfoByDiagramIdAndPointId",e)}};var nn={};(function(e){var t=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function i(s,a){return Object.prototype.hasOwnProperty.call(s,a)}e.assign=function(s){for(var a=Array.prototype.slice.call(arguments,1);a.length;){var l=a.shift();if(!!l){if(typeof l!="object")throw new TypeError(l+"must be non-object");for(var c in l)i(l,c)&&(s[c]=l[c])}}return s},e.shrinkBuf=function(s,a){return s.length===a?s:s.subarray?s.subarray(0,a):(s.length=a,s)};var n={arraySet:function(s,a,l,c,u){if(a.subarray&&s.subarray){s.set(a.subarray(l,l+c),u);return}for(var h=0;h<c;h++)s[u+h]=a[l+h]},flattenChunks:function(s){var a,l,c,u,h,d;for(c=0,a=0,l=s.length;a<l;a++)c+=s[a].length;for(d=new Uint8Array(c),u=0,a=0,l=s.length;a<l;a++)h=s[a],d.set(h,u),u+=h.length;return d}},r={arraySet:function(s,a,l,c,u){for(var h=0;h<c;h++)s[u+h]=a[l+h]},flattenChunks:function(s){return[].concat.apply([],s)}};e.setTyped=function(s){s?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,r))},e.setTyped(t)})(nn);var Cs={},Di={},Nr={},YA=nn,XA=4,Md=0,Bd=1,GA=2;function Fr(e){for(var t=e.length;--t>=0;)e[t]=0}var ZA=0,Tg=1,JA=2,QA=3,tR=258,Xc=29,Ts=256,ws=Ts+1+Xc,Lr=30,Gc=19,Sg=2*ws+1,Un=15,ic=16,eR=7,Zc=256,Pg=16,Ig=17,Lg=18,Rc=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Na=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],iR=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Dg=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],nR=512,Yi=new Array((ws+2)*2);Fr(Yi);var fs=new Array(Lr*2);Fr(fs);var bs=new Array(nR);Fr(bs);var xs=new Array(tR-QA+1);Fr(xs);var Jc=new Array(Xc);Fr(Jc);var Xa=new Array(Lr);Fr(Xa);function nc(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}var Mg,Bg,Og;function rc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Ng(e){return e<256?bs[e]:bs[256+(e>>>7)]}function _s(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Ue(e,t,i){e.bi_valid>ic-i?(e.bi_buf|=t<<e.bi_valid&65535,_s(e,e.bi_buf),e.bi_buf=t>>ic-e.bi_valid,e.bi_valid+=i-ic):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function Si(e,t,i){Ue(e,i[t*2],i[t*2+1])}function Fg(e,t){var i=0;do i|=e&1,e>>>=1,i<<=1;while(--t>0);return i>>>1}function rR(e){e.bi_valid===16?(_s(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function sR(e,t){var i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,l=t.stat_desc.extra_base,c=t.stat_desc.max_length,u,h,d,g,v,y,w=0;for(g=0;g<=Un;g++)e.bl_count[g]=0;for(i[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;u<Sg;u++)h=e.heap[u],g=i[i[h*2+1]*2+1]+1,g>c&&(g=c,w++),i[h*2+1]=g,!(h>n)&&(e.bl_count[g]++,v=0,h>=l&&(v=a[h-l]),y=i[h*2],e.opt_len+=y*(g+v),s&&(e.static_len+=y*(r[h*2+1]+v)));if(w!==0){do{for(g=c-1;e.bl_count[g]===0;)g--;e.bl_count[g]--,e.bl_count[g+1]+=2,e.bl_count[c]--,w-=2}while(w>0);for(g=c;g!==0;g--)for(h=e.bl_count[g];h!==0;)d=e.heap[--u],!(d>n)&&(i[d*2+1]!==g&&(e.opt_len+=(g-i[d*2+1])*i[d*2],i[d*2+1]=g),h--)}}function zg(e,t,i){var n=new Array(Un+1),r=0,s,a;for(s=1;s<=Un;s++)n[s]=r=r+i[s-1]<<1;for(a=0;a<=t;a++){var l=e[a*2+1];l!==0&&(e[a*2]=Fg(n[l]++,l))}}function aR(){var e,t,i,n,r,s=new Array(Un+1);for(i=0,n=0;n<Xc-1;n++)for(Jc[n]=i,e=0;e<1<<Rc[n];e++)xs[i++]=n;for(xs[i-1]=n,r=0,n=0;n<16;n++)for(Xa[n]=r,e=0;e<1<<Na[n];e++)bs[r++]=n;for(r>>=7;n<Lr;n++)for(Xa[n]=r<<7,e=0;e<1<<Na[n]-7;e++)bs[256+r++]=n;for(t=0;t<=Un;t++)s[t]=0;for(e=0;e<=143;)Yi[e*2+1]=8,e++,s[8]++;for(;e<=255;)Yi[e*2+1]=9,e++,s[9]++;for(;e<=279;)Yi[e*2+1]=7,e++,s[7]++;for(;e<=287;)Yi[e*2+1]=8,e++,s[8]++;for(zg(Yi,ws+1,s),e=0;e<Lr;e++)fs[e*2+1]=5,fs[e*2]=Fg(e,5);Mg=new nc(Yi,Rc,Ts+1,ws,Un),Bg=new nc(fs,Na,0,Lr,Un),Og=new nc(new Array(0),iR,0,Gc,eR)}function Hg(e){var t;for(t=0;t<ws;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Lr;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Gc;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Zc*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Ug(e){e.bi_valid>8?_s(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function oR(e,t,i,n){Ug(e),n&&(_s(e,i),_s(e,~i)),YA.arraySet(e.pending_buf,e.window,t,i,e.pending),e.pending+=i}function Od(e,t,i,n){var r=t*2,s=i*2;return e[r]<e[s]||e[r]===e[s]&&n[t]<=n[i]}function sc(e,t,i){for(var n=e.heap[i],r=i<<1;r<=e.heap_len&&(r<e.heap_len&&Od(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!Od(t,n,e.heap[r],e.depth));)e.heap[i]=e.heap[r],i=r,r<<=1;e.heap[i]=n}function Nd(e,t,i){var n,r,s=0,a,l;if(e.last_lit!==0)do n=e.pending_buf[e.d_buf+s*2]<<8|e.pending_buf[e.d_buf+s*2+1],r=e.pending_buf[e.l_buf+s],s++,n===0?Si(e,r,t):(a=xs[r],Si(e,a+Ts+1,t),l=Rc[a],l!==0&&(r-=Jc[a],Ue(e,r,l)),n--,a=Ng(n),Si(e,a,i),l=Na[a],l!==0&&(n-=Xa[a],Ue(e,n,l)));while(s<e.last_lit);Si(e,Zc,t)}function Cc(e,t){var i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems,a,l,c=-1,u;for(e.heap_len=0,e.heap_max=Sg,a=0;a<s;a++)i[a*2]!==0?(e.heap[++e.heap_len]=c=a,e.depth[a]=0):i[a*2+1]=0;for(;e.heap_len<2;)u=e.heap[++e.heap_len]=c<2?++c:0,i[u*2]=1,e.depth[u]=0,e.opt_len--,r&&(e.static_len-=n[u*2+1]);for(t.max_code=c,a=e.heap_len>>1;a>=1;a--)sc(e,i,a);u=s;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],sc(e,i,1),l=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=l,i[u*2]=i[a*2]+i[l*2],e.depth[u]=(e.depth[a]>=e.depth[l]?e.depth[a]:e.depth[l])+1,i[a*2+1]=i[l*2+1]=u,e.heap[1]=u++,sc(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],sR(e,t),zg(i,c,e.bl_count)}function Fd(e,t,i){var n,r=-1,s,a=t[0*2+1],l=0,c=7,u=4;for(a===0&&(c=138,u=3),t[(i+1)*2+1]=65535,n=0;n<=i;n++)s=a,a=t[(n+1)*2+1],!(++l<c&&s===a)&&(l<u?e.bl_tree[s*2]+=l:s!==0?(s!==r&&e.bl_tree[s*2]++,e.bl_tree[Pg*2]++):l<=10?e.bl_tree[Ig*2]++:e.bl_tree[Lg*2]++,l=0,r=s,a===0?(c=138,u=3):s===a?(c=6,u=3):(c=7,u=4))}function zd(e,t,i){var n,r=-1,s,a=t[0*2+1],l=0,c=7,u=4;for(a===0&&(c=138,u=3),n=0;n<=i;n++)if(s=a,a=t[(n+1)*2+1],!(++l<c&&s===a)){if(l<u)do Si(e,s,e.bl_tree);while(--l!==0);else s!==0?(s!==r&&(Si(e,s,e.bl_tree),l--),Si(e,Pg,e.bl_tree),Ue(e,l-3,2)):l<=10?(Si(e,Ig,e.bl_tree),Ue(e,l-3,3)):(Si(e,Lg,e.bl_tree),Ue(e,l-11,7));l=0,r=s,a===0?(c=138,u=3):s===a?(c=6,u=3):(c=7,u=4)}}function lR(e){var t;for(Fd(e,e.dyn_ltree,e.l_desc.max_code),Fd(e,e.dyn_dtree,e.d_desc.max_code),Cc(e,e.bl_desc),t=Gc-1;t>=3&&e.bl_tree[Dg[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function cR(e,t,i,n){var r;for(Ue(e,t-257,5),Ue(e,i-1,5),Ue(e,n-4,4),r=0;r<n;r++)Ue(e,e.bl_tree[Dg[r]*2+1],3);zd(e,e.dyn_ltree,t-1),zd(e,e.dyn_dtree,i-1)}function hR(e){var t=4093624447,i;for(i=0;i<=31;i++,t>>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return Md;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Bd;for(i=32;i<Ts;i++)if(e.dyn_ltree[i*2]!==0)return Bd;return Md}var Hd=!1;function uR(e){Hd||(aR(),Hd=!0),e.l_desc=new rc(e.dyn_ltree,Mg),e.d_desc=new rc(e.dyn_dtree,Bg),e.bl_desc=new rc(e.bl_tree,Og),e.bi_buf=0,e.bi_valid=0,Hg(e)}function Wg(e,t,i,n){Ue(e,(ZA<<1)+(n?1:0),3),oR(e,t,i,!0)}function fR(e){Ue(e,Tg<<1,3),Si(e,Zc,Yi),rR(e)}function dR(e,t,i,n){var r,s,a=0;e.level>0?(e.strm.data_type===GA&&(e.strm.data_type=hR(e)),Cc(e,e.l_desc),Cc(e,e.d_desc),a=lR(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&t!==-1?Wg(e,t,i,n):e.strategy===XA||s===r?(Ue(e,(Tg<<1)+(n?1:0),3),Nd(e,Yi,fs)):(Ue(e,(JA<<1)+(n?1:0),3),cR(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),Nd(e,e.dyn_ltree,e.dyn_dtree)),Hg(e),n&&Ug(e)}function vR(e,t,i){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=i&255,e.last_lit++,t===0?e.dyn_ltree[i*2]++:(e.matches++,t--,e.dyn_ltree[(xs[i]+Ts+1)*2]++,e.dyn_dtree[Ng(t)*2]++),e.last_lit===e.lit_bufsize-1}Nr._tr_init=uR;Nr._tr_stored_block=Wg;Nr._tr_flush_block=dR;Nr._tr_tally=vR;Nr._tr_align=fR;function gR(e,t,i,n){for(var r=e&65535|0,s=e>>>16&65535|0,a=0;i!==0;){a=i>2e3?2e3:i,i-=a;do r=r+t[n++]|0,s=s+r|0;while(--a);r%=65521,s%=65521}return r|s<<16|0}var qg=gR;function yR(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[i]=e}return t}var mR=yR();function pR(e,t,i,n){var r=mR,s=n+i;e^=-1;for(var a=n;a<s;a++)e=e>>>8^r[(e^t[a])&255];return e^-1}var jg=pR,Qc={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},De=nn,ui=Nr,Vg=qg,pn=jg,wR=Qc,tr=0,bR=1,xR=3,En=4,Ud=5,Pi=0,Wd=1,fi=-2,_R=-3,ac=-5,kR=-1,ER=1,Ta=2,AR=3,RR=4,CR=0,TR=2,no=8,SR=9,PR=15,IR=8,LR=29,DR=256,Tc=DR+1+LR,MR=30,BR=19,OR=2*Tc+1,NR=15,Ut=3,_n=258,wi=_n+Ut+1,FR=32,ro=42,Sc=69,Fa=73,za=91,Ha=103,Wn=113,os=666,me=1,Ss=2,Yn=3,zr=4,zR=3;function kn(e,t){return e.msg=wR[t],t}function qd(e){return(e<<1)-(e>4?9:0)}function xn(e){for(var t=e.length;--t>=0;)e[t]=0}function wn(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),i!==0&&(De.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,t.pending===0&&(t.pending_out=0))}function Re(e,t){ui._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,wn(e.strm)}function Wt(e,t){e.pending_buf[e.pending++]=t}function ns(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function HR(e,t,i,n){var r=e.avail_in;return r>n&&(r=n),r===0?0:(e.avail_in-=r,De.arraySet(t,e.input,e.next_in,r,i),e.state.wrap===1?e.adler=Vg(e.adler,t,r,i):e.state.wrap===2&&(e.adler=pn(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)}function $g(e,t){var i=e.max_chain_length,n=e.strstart,r,s,a=e.prev_length,l=e.nice_match,c=e.strstart>e.w_size-wi?e.strstart-(e.w_size-wi):0,u=e.window,h=e.w_mask,d=e.prev,g=e.strstart+_n,v=u[n+a-1],y=u[n+a];e.prev_length>=e.good_match&&(i>>=2),l>e.lookahead&&(l=e.lookahead);do if(r=t,!(u[r+a]!==y||u[r+a-1]!==v||u[r]!==u[n]||u[++r]!==u[n+1])){n+=2,r++;do;while(u[++n]===u[++r]&&u[++n]===u[++r]&&u[++n]===u[++r]&&u[++n]===u[++r]&&u[++n]===u[++r]&&u[++n]===u[++r]&&u[++n]===u[++r]&&u[++n]===u[++r]&&n<g);if(s=_n-(g-n),n=g-_n,s>a){if(e.match_start=t,a=s,s>=l)break;v=u[n+a-1],y=u[n+a]}}while((t=d[t&h])>c&&--i!==0);return a<=e.lookahead?a:e.lookahead}function Xn(e){var t=e.w_size,i,n,r,s,a;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-wi)){De.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,n=e.hash_size,i=n;do r=e.head[--i],e.head[i]=r>=t?r-t:0;while(--n);n=t,i=n;do r=e.prev[--i],e.prev[i]=r>=t?r-t:0;while(--n);s+=t}if(e.strm.avail_in===0)break;if(n=HR(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=n,e.lookahead+e.insert>=Ut)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+Ut-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<Ut)););}while(e.lookahead<wi&&e.strm.avail_in!==0)}function UR(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Xn(e),e.lookahead===0&&t===tr)return me;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+i;if((e.strstart===0||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,Re(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-wi&&(Re(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===En?(Re(e,!0),e.strm.avail_out===0?Yn:zr):(e.strstart>e.block_start&&(Re(e,!1),e.strm.avail_out===0),me)}function oc(e,t){for(var i,n;;){if(e.lookahead<wi){if(Xn(e),e.lookahead<wi&&t===tr)return me;if(e.lookahead===0)break}if(i=0,e.lookahead>=Ut&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ut-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),i!==0&&e.strstart-i<=e.w_size-wi&&(e.match_length=$g(e,i)),e.match_length>=Ut)if(n=ui._tr_tally(e,e.strstart-e.match_start,e.match_length-Ut),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Ut){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ut-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=ui._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Re(e,!1),e.strm.avail_out===0))return me}return e.insert=e.strstart<Ut-1?e.strstart:Ut-1,t===En?(Re(e,!0),e.strm.avail_out===0?Yn:zr):e.last_lit&&(Re(e,!1),e.strm.avail_out===0)?me:Ss}function kr(e,t){for(var i,n,r;;){if(e.lookahead<wi){if(Xn(e),e.lookahead<wi&&t===tr)return me;if(e.lookahead===0)break}if(i=0,e.lookahead>=Ut&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ut-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Ut-1,i!==0&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-wi&&(e.match_length=$g(e,i),e.match_length<=5&&(e.strategy===ER||e.match_length===Ut&&e.strstart-e.match_start>4096)&&(e.match_length=Ut-1)),e.prev_length>=Ut&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-Ut,n=ui._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Ut),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Ut-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Ut-1,e.strstart++,n&&(Re(e,!1),e.strm.avail_out===0))return me}else if(e.match_available){if(n=ui._tr_tally(e,0,e.window[e.strstart-1]),n&&Re(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return me}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=ui._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Ut-1?e.strstart:Ut-1,t===En?(Re(e,!0),e.strm.avail_out===0?Yn:zr):e.last_lit&&(Re(e,!1),e.strm.avail_out===0)?me:Ss}function WR(e,t){for(var i,n,r,s,a=e.window;;){if(e.lookahead<=_n){if(Xn(e),e.lookahead<=_n&&t===tr)return me;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Ut&&e.strstart>0&&(r=e.strstart-1,n=a[r],n===a[++r]&&n===a[++r]&&n===a[++r])){s=e.strstart+_n;do;while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&r<s);e.match_length=_n-(s-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Ut?(i=ui._tr_tally(e,1,e.match_length-Ut),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=ui._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(Re(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===En?(Re(e,!0),e.strm.avail_out===0?Yn:zr):e.last_lit&&(Re(e,!1),e.strm.avail_out===0)?me:Ss}function qR(e,t){for(var i;;){if(e.lookahead===0&&(Xn(e),e.lookahead===0)){if(t===tr)return me;break}if(e.match_length=0,i=ui._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(Re(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===En?(Re(e,!0),e.strm.avail_out===0?Yn:zr):e.last_lit&&(Re(e,!1),e.strm.avail_out===0)?me:Ss}function Ai(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}var Sr;Sr=[new Ai(0,0,0,0,UR),new Ai(4,4,8,4,oc),new Ai(4,5,16,8,oc),new Ai(4,6,32,32,oc),new Ai(4,4,16,16,kr),new Ai(8,16,32,32,kr),new Ai(8,16,128,128,kr),new Ai(8,32,128,256,kr),new Ai(32,128,258,1024,kr),new Ai(32,258,258,4096,kr)];function jR(e){e.window_size=2*e.w_size,xn(e.head),e.max_lazy_match=Sr[e.level].max_lazy,e.good_match=Sr[e.level].good_length,e.nice_match=Sr[e.level].nice_length,e.max_chain_length=Sr[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Ut-1,e.match_available=0,e.ins_h=0}function VR(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=no,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new De.Buf16(OR*2),this.dyn_dtree=new De.Buf16((2*MR+1)*2),this.bl_tree=new De.Buf16((2*BR+1)*2),xn(this.dyn_ltree),xn(this.dyn_dtree),xn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new De.Buf16(NR+1),this.heap=new De.Buf16(2*Tc+1),xn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new De.Buf16(2*Tc+1),xn(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Kg(e){var t;return!e||!e.state?kn(e,fi):(e.total_in=e.total_out=0,e.data_type=TR,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?ro:Wn,e.adler=t.wrap===2?0:1,t.last_flush=tr,ui._tr_init(t),Pi)}function Yg(e){var t=Kg(e);return t===Pi&&jR(e.state),t}function $R(e,t){return!e||!e.state||e.state.wrap!==2?fi:(e.state.gzhead=t,Pi)}function Xg(e,t,i,n,r,s){if(!e)return fi;var a=1;if(t===kR&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),r<1||r>SR||i!==no||n<8||n>15||t<0||t>9||s<0||s>RR)return kn(e,fi);n===8&&(n=9);var l=new VR;return e.state=l,l.strm=e,l.wrap=a,l.gzhead=null,l.w_bits=n,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=r+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+Ut-1)/Ut),l.window=new De.Buf8(l.w_size*2),l.head=new De.Buf16(l.hash_size),l.prev=new De.Buf16(l.w_size),l.lit_bufsize=1<<r+6,l.pending_buf_size=l.lit_bufsize*4,l.pending_buf=new De.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=(1+2)*l.lit_bufsize,l.level=t,l.strategy=s,l.method=i,Yg(e)}function KR(e,t){return Xg(e,t,no,PR,IR,CR)}function YR(e,t){var i,n,r,s;if(!e||!e.state||t>Ud||t<0)return e?kn(e,fi):fi;if(n=e.state,!e.output||!e.input&&e.avail_in!==0||n.status===os&&t!==En)return kn(e,e.avail_out===0?ac:fi);if(n.strm=e,i=n.last_flush,n.last_flush=t,n.status===ro)if(n.wrap===2)e.adler=0,Wt(n,31),Wt(n,139),Wt(n,8),n.gzhead?(Wt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Wt(n,n.gzhead.time&255),Wt(n,n.gzhead.time>>8&255),Wt(n,n.gzhead.time>>16&255),Wt(n,n.gzhead.time>>24&255),Wt(n,n.level===9?2:n.strategy>=Ta||n.level<2?4:0),Wt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(Wt(n,n.gzhead.extra.length&255),Wt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=pn(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=Sc):(Wt(n,0),Wt(n,0),Wt(n,0),Wt(n,0),Wt(n,0),Wt(n,n.level===9?2:n.strategy>=Ta||n.level<2?4:0),Wt(n,zR),n.status=Wn);else{var a=no+(n.w_bits-8<<4)<<8,l=-1;n.strategy>=Ta||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,a|=l<<6,n.strstart!==0&&(a|=FR),a+=31-a%31,n.status=Wn,ns(n,a),n.strstart!==0&&(ns(n,e.adler>>>16),ns(n,e.adler&65535)),e.adler=1}if(n.status===Sc)if(n.gzhead.extra){for(r=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>r&&(e.adler=pn(e.adler,n.pending_buf,n.pending-r,r)),wn(e),r=n.pending,n.pending===n.pending_buf_size));)Wt(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>r&&(e.adler=pn(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=Fa)}else n.status=Fa;if(n.status===Fa)if(n.gzhead.name){r=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>r&&(e.adler=pn(e.adler,n.pending_buf,n.pending-r,r)),wn(e),r=n.pending,n.pending===n.pending_buf_size)){s=1;break}n.gzindex<n.gzhead.name.length?s=n.gzhead.name.charCodeAt(n.gzindex++)&255:s=0,Wt(n,s)}while(s!==0);n.gzhead.hcrc&&n.pending>r&&(e.adler=pn(e.adler,n.pending_buf,n.pending-r,r)),s===0&&(n.gzindex=0,n.status=za)}else n.status=za;if(n.status===za)if(n.gzhead.comment){r=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>r&&(e.adler=pn(e.adler,n.pending_buf,n.pending-r,r)),wn(e),r=n.pending,n.pending===n.pending_buf_size)){s=1;break}n.gzindex<n.gzhead.comment.length?s=n.gzhead.comment.charCodeAt(n.gzindex++)&255:s=0,Wt(n,s)}while(s!==0);n.gzhead.hcrc&&n.pending>r&&(e.adler=pn(e.adler,n.pending_buf,n.pending-r,r)),s===0&&(n.status=Ha)}else n.status=Ha;if(n.status===Ha&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&wn(e),n.pending+2<=n.pending_buf_size&&(Wt(n,e.adler&255),Wt(n,e.adler>>8&255),e.adler=0,n.status=Wn)):n.status=Wn),n.pending!==0){if(wn(e),e.avail_out===0)return n.last_flush=-1,Pi}else if(e.avail_in===0&&qd(t)<=qd(i)&&t!==En)return kn(e,ac);if(n.status===os&&e.avail_in!==0)return kn(e,ac);if(e.avail_in!==0||n.lookahead!==0||t!==tr&&n.status!==os){var c=n.strategy===Ta?qR(n,t):n.strategy===AR?WR(n,t):Sr[n.level].func(n,t);if((c===Yn||c===zr)&&(n.status=os),c===me||c===Yn)return e.avail_out===0&&(n.last_flush=-1),Pi;if(c===Ss&&(t===bR?ui._tr_align(n):t!==Ud&&(ui._tr_stored_block(n,0,0,!1),t===xR&&(xn(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),wn(e),e.avail_out===0))return n.last_flush=-1,Pi}return t!==En?Pi:n.wrap<=0?Wd:(n.wrap===2?(Wt(n,e.adler&255),Wt(n,e.adler>>8&255),Wt(n,e.adler>>16&255),Wt(n,e.adler>>24&255),Wt(n,e.total_in&255),Wt(n,e.total_in>>8&255),Wt(n,e.total_in>>16&255),Wt(n,e.total_in>>24&255)):(ns(n,e.adler>>>16),ns(n,e.adler&65535)),wn(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Pi:Wd)}function XR(e){var t;return!e||!e.state?fi:(t=e.state.status,t!==ro&&t!==Sc&&t!==Fa&&t!==za&&t!==Ha&&t!==Wn&&t!==os?kn(e,fi):(e.state=null,t===Wn?kn(e,_R):Pi))}function GR(e,t){var i=t.length,n,r,s,a,l,c,u,h;if(!e||!e.state||(n=e.state,a=n.wrap,a===2||a===1&&n.status!==ro||n.lookahead))return fi;for(a===1&&(e.adler=Vg(e.adler,t,i,0)),n.wrap=0,i>=n.w_size&&(a===0&&(xn(n.head),n.strstart=0,n.block_start=0,n.insert=0),h=new De.Buf8(n.w_size),De.arraySet(h,t,i-n.w_size,n.w_size,0),t=h,i=n.w_size),l=e.avail_in,c=e.next_in,u=e.input,e.avail_in=i,e.next_in=0,e.input=t,Xn(n);n.lookahead>=Ut;){r=n.strstart,s=n.lookahead-(Ut-1);do n.ins_h=(n.ins_h<<n.hash_shift^n.window[r+Ut-1])&n.hash_mask,n.prev[r&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=r,r++;while(--s);n.strstart=r,n.lookahead=Ut-1,Xn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=Ut-1,n.match_available=0,e.next_in=c,e.input=u,e.avail_in=l,n.wrap=a,Pi}Di.deflateInit=KR;Di.deflateInit2=Xg;Di.deflateReset=Yg;Di.deflateResetKeep=Kg;Di.deflateSetHeader=$R;Di.deflate=YR;Di.deflateEnd=XR;Di.deflateSetDictionary=GR;Di.deflateInfo="pako deflate (from Nodeca project)";var er={},so=nn,Gg=!0,Zg=!0;try{String.fromCharCode.apply(null,[0])}catch{Gg=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Zg=!1}var ks=new so.Buf8(256);for(var vn=0;vn<256;vn++)ks[vn]=vn>=252?6:vn>=248?5:vn>=240?4:vn>=224?3:vn>=192?2:1;ks[254]=ks[254]=1;er.string2buf=function(e){var t,i,n,r,s,a=e.length,l=0;for(r=0;r<a;r++)i=e.charCodeAt(r),(i&64512)===55296&&r+1<a&&(n=e.charCodeAt(r+1),(n&64512)===56320&&(i=65536+(i-55296<<10)+(n-56320),r++)),l+=i<128?1:i<2048?2:i<65536?3:4;for(t=new so.Buf8(l),s=0,r=0;s<l;r++)i=e.charCodeAt(r),(i&64512)===55296&&r+1<a&&(n=e.charCodeAt(r+1),(n&64512)===56320&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?t[s++]=i:i<2048?(t[s++]=192|i>>>6,t[s++]=128|i&63):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|i&63):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|i&63);return t};function Jg(e,t){if(t<65534&&(e.subarray&&Zg||!e.subarray&&Gg))return String.fromCharCode.apply(null,so.shrinkBuf(e,t));for(var i="",n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i}er.buf2binstring=function(e){return Jg(e,e.length)};er.binstring2buf=function(e){for(var t=new so.Buf8(e.length),i=0,n=t.length;i<n;i++)t[i]=e.charCodeAt(i);return t};er.buf2string=function(e,t){var i,n,r,s,a=t||e.length,l=new Array(a*2);for(n=0,i=0;i<a;){if(r=e[i++],r<128){l[n++]=r;continue}if(s=ks[r],s>4){l[n++]=65533,i+=s-1;continue}for(r&=s===2?31:s===3?15:7;s>1&&i<a;)r=r<<6|e[i++]&63,s--;if(s>1){l[n++]=65533;continue}r<65536?l[n++]=r:(r-=65536,l[n++]=55296|r>>10&1023,l[n++]=56320|r&1023)}return Jg(l,n)};er.utf8border=function(e,t){var i;for(t=t||e.length,t>e.length&&(t=e.length),i=t-1;i>=0&&(e[i]&192)===128;)i--;return i<0||i===0?t:i+ks[e[i]]>t?i:t};function ZR(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Qg=ZR,ds=Di,vs=nn,Pc=er,Ic=Qc,JR=Qg,ty=Object.prototype.toString,QR=0,lc=4,Dr=0,jd=1,Vd=2,tC=-1,eC=0,iC=8;function Gn(e){if(!(this instanceof Gn))return new Gn(e);this.options=vs.assign({level:tC,method:iC,chunkSize:16384,windowBits:15,memLevel:8,strategy:eC,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new JR,this.strm.avail_out=0;var i=ds.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Dr)throw new Error(Ic[i]);if(t.header&&ds.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(typeof t.dictionary=="string"?n=Pc.string2buf(t.dictionary):ty.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,i=ds.deflateSetDictionary(this.strm,n),i!==Dr)throw new Error(Ic[i]);this._dict_set=!0}}Gn.prototype.push=function(e,t){var i=this.strm,n=this.options.chunkSize,r,s;if(this.ended)return!1;s=t===~~t?t:t===!0?lc:QR,typeof e=="string"?i.input=Pc.string2buf(e):ty.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(i.avail_out===0&&(i.output=new vs.Buf8(n),i.next_out=0,i.avail_out=n),r=ds.deflate(i,s),r!==jd&&r!==Dr)return this.onEnd(r),this.ended=!0,!1;(i.avail_out===0||i.avail_in===0&&(s===lc||s===Vd))&&(this.options.to==="string"?this.onData(Pc.buf2binstring(vs.shrinkBuf(i.output,i.next_out))):this.onData(vs.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||i.avail_out===0)&&r!==jd);return s===lc?(r=ds.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Dr):(s===Vd&&(this.onEnd(Dr),i.avail_out=0),!0)};Gn.prototype.onData=function(e){this.chunks.push(e)};Gn.prototype.onEnd=function(e){e===Dr&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=vs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function th(e,t){var i=new Gn(t);if(i.push(e,!0),i.err)throw i.msg||Ic[i.err];return i.result}function nC(e,t){return t=t||{},t.raw=!0,th(e,t)}function rC(e,t){return t=t||{},t.gzip=!0,th(e,t)}Cs.Deflate=Gn;Cs.deflate=th;Cs.deflateRaw=nC;Cs.gzip=rC;var Ps={},bi={},Sa=30,sC=12,aC=function(t,i){var n,r,s,a,l,c,u,h,d,g,v,y,w,p,_,A,x,E,I,M,B,D,q,Q,C;n=t.state,r=t.next_in,Q=t.input,s=r+(t.avail_in-5),a=t.next_out,C=t.output,l=a-(i-t.avail_out),c=a+(t.avail_out-257),u=n.dmax,h=n.wsize,d=n.whave,g=n.wnext,v=n.window,y=n.hold,w=n.bits,p=n.lencode,_=n.distcode,A=(1<<n.lenbits)-1,x=(1<<n.distbits)-1;t:do{w<15&&(y+=Q[r++]<<w,w+=8,y+=Q[r++]<<w,w+=8),E=p[y&A];e:for(;;){if(I=E>>>24,y>>>=I,w-=I,I=E>>>16&255,I===0)C[a++]=E&65535;else if(I&16){M=E&65535,I&=15,I&&(w<I&&(y+=Q[r++]<<w,w+=8),M+=y&(1<<I)-1,y>>>=I,w-=I),w<15&&(y+=Q[r++]<<w,w+=8,y+=Q[r++]<<w,w+=8),E=_[y&x];i:for(;;){if(I=E>>>24,y>>>=I,w-=I,I=E>>>16&255,I&16){if(B=E&65535,I&=15,w<I&&(y+=Q[r++]<<w,w+=8,w<I&&(y+=Q[r++]<<w,w+=8)),B+=y&(1<<I)-1,B>u){t.msg="invalid distance too far back",n.mode=Sa;break t}if(y>>>=I,w-=I,I=a-l,B>I){if(I=B-I,I>d&&n.sane){t.msg="invalid distance too far back",n.mode=Sa;break t}if(D=0,q=v,g===0){if(D+=h-I,I<M){M-=I;do C[a++]=v[D++];while(--I);D=a-B,q=C}}else if(g<I){if(D+=h+g-I,I-=g,I<M){M-=I;do C[a++]=v[D++];while(--I);if(D=0,g<M){I=g,M-=I;do C[a++]=v[D++];while(--I);D=a-B,q=C}}}else if(D+=g-I,I<M){M-=I;do C[a++]=v[D++];while(--I);D=a-B,q=C}for(;M>2;)C[a++]=q[D++],C[a++]=q[D++],C[a++]=q[D++],M-=3;M&&(C[a++]=q[D++],M>1&&(C[a++]=q[D++]))}else{D=a-B;do C[a++]=C[D++],C[a++]=C[D++],C[a++]=C[D++],M-=3;while(M>2);M&&(C[a++]=C[D++],M>1&&(C[a++]=C[D++]))}}else if((I&64)===0){E=_[(E&65535)+(y&(1<<I)-1)];continue i}else{t.msg="invalid distance code",n.mode=Sa;break t}break}}else if((I&64)===0){E=p[(E&65535)+(y&(1<<I)-1)];continue e}else if(I&32){n.mode=sC;break t}else{t.msg="invalid literal/length code",n.mode=Sa;break t}break}}while(r<s&&a<c);M=w>>3,r-=M,w-=M<<3,y&=(1<<w)-1,t.next_in=r,t.next_out=a,t.avail_in=r<s?5+(s-r):5-(r-s),t.avail_out=a<c?257+(c-a):257-(a-c),n.hold=y,n.bits=w},$d=nn,Er=15,Kd=852,Yd=592,Xd=0,cc=1,Gd=2,oC=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],lC=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],cC=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],hC=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],uC=function(t,i,n,r,s,a,l,c){var u=c.bits,h=0,d=0,g=0,v=0,y=0,w=0,p=0,_=0,A=0,x=0,E,I,M,B,D,q=null,Q=0,C,T=new $d.Buf16(Er+1),S=new $d.Buf16(Er+1),O=null,K=0,Z,st,$;for(h=0;h<=Er;h++)T[h]=0;for(d=0;d<r;d++)T[i[n+d]]++;for(y=u,v=Er;v>=1&&T[v]===0;v--);if(y>v&&(y=v),v===0)return s[a++]=1<<24|64<<16|0,s[a++]=1<<24|64<<16|0,c.bits=1,0;for(g=1;g<v&&T[g]===0;g++);for(y<g&&(y=g),_=1,h=1;h<=Er;h++)if(_<<=1,_-=T[h],_<0)return-1;if(_>0&&(t===Xd||v!==1))return-1;for(S[1]=0,h=1;h<Er;h++)S[h+1]=S[h]+T[h];for(d=0;d<r;d++)i[n+d]!==0&&(l[S[i[n+d]]++]=d);if(t===Xd?(q=O=l,C=19):t===cc?(q=oC,Q-=257,O=lC,K-=257,C=256):(q=cC,O=hC,C=-1),x=0,d=0,h=g,D=a,w=y,p=0,M=-1,A=1<<y,B=A-1,t===cc&&A>Kd||t===Gd&&A>Yd)return 1;for(;;){Z=h-p,l[d]<C?(st=0,$=l[d]):l[d]>C?(st=O[K+l[d]],$=q[Q+l[d]]):(st=32+64,$=0),E=1<<h-p,I=1<<w,g=I;do I-=E,s[D+(x>>p)+I]=Z<<24|st<<16|$|0;while(I!==0);for(E=1<<h-1;x&E;)E>>=1;if(E!==0?(x&=E-1,x+=E):x=0,d++,--T[h]===0){if(h===v)break;h=i[n+l[d]]}if(h>y&&(x&B)!==M){for(p===0&&(p=y),D+=g,w=h-p,_=1<<w;w+p<v&&(_-=T[w+p],!(_<=0));)w++,_<<=1;if(A+=1<<w,t===cc&&A>Kd||t===Gd&&A>Yd)return 1;M=x&B,s[M]=y<<24|w<<16|D-a|0}}return x!==0&&(s[D+x]=h-p<<24|64<<16|0),c.bits=y,0},Qe=nn,Lc=qg,Ri=jg,fC=aC,gs=uC,dC=0,ey=1,iy=2,Zd=4,vC=5,Pa=6,Zn=0,gC=1,yC=2,di=-2,ny=-3,ry=-4,mC=-5,Jd=8,sy=1,Qd=2,tv=3,ev=4,iv=5,nv=6,rv=7,sv=8,av=9,ov=10,Ga=11,Vi=12,hc=13,lv=14,uc=15,cv=16,hv=17,uv=18,fv=19,Ia=20,La=21,dv=22,vv=23,gv=24,yv=25,mv=26,fc=27,pv=28,wv=29,se=30,ay=31,pC=32,wC=852,bC=592,xC=15,_C=xC;function bv(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function kC(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Qe.Buf16(320),this.work=new Qe.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function oy(e){var t;return!e||!e.state?di:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=sy,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Qe.Buf32(wC),t.distcode=t.distdyn=new Qe.Buf32(bC),t.sane=1,t.back=-1,Zn)}function ly(e){var t;return!e||!e.state?di:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,oy(e))}function cy(e,t){var i,n;return!e||!e.state||(n=e.state,t<0?(i=0,t=-t):(i=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?di:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,ly(e))}function hy(e,t){var i,n;return e?(n=new kC,e.state=n,n.window=null,i=cy(e,t),i!==Zn&&(e.state=null),i):di}function EC(e){return hy(e,_C)}var xv=!0,dc,vc;function AC(e){if(xv){var t;for(dc=new Qe.Buf32(512),vc=new Qe.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(gs(ey,e.lens,0,288,dc,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;gs(iy,e.lens,0,32,vc,0,e.work,{bits:5}),xv=!1}e.lencode=dc,e.lenbits=9,e.distcode=vc,e.distbits=5}function uy(e,t,i,n){var r,s=e.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Qe.Buf8(s.wsize)),n>=s.wsize?(Qe.arraySet(s.window,t,i-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),Qe.arraySet(s.window,t,i-n,r,s.wnext),n-=r,n?(Qe.arraySet(s.window,t,i-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0}function RC(e,t){var i,n,r,s,a,l,c,u,h,d,g,v,y,w,p=0,_,A,x,E,I,M,B,D,q=new Qe.Buf8(4),Q,C,T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return di;i=e.state,i.mode===Vi&&(i.mode=hc),a=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,l=e.avail_in,u=i.hold,h=i.bits,d=l,g=c,D=Zn;t:for(;;)switch(i.mode){case sy:if(i.wrap===0){i.mode=hc;break}for(;h<16;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if(i.wrap&2&&u===35615){i.check=0,q[0]=u&255,q[1]=u>>>8&255,i.check=Ri(i.check,q,2,0),u=0,h=0,i.mode=Qd;break}if(i.flags=0,i.head&&(i.head.done=!1),!(i.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",i.mode=se;break}if((u&15)!==Jd){e.msg="unknown compression method",i.mode=se;break}if(u>>>=4,h-=4,B=(u&15)+8,i.wbits===0)i.wbits=B;else if(B>i.wbits){e.msg="invalid window size",i.mode=se;break}i.dmax=1<<B,e.adler=i.check=1,i.mode=u&512?ov:Vi,u=0,h=0;break;case Qd:for(;h<16;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if(i.flags=u,(i.flags&255)!==Jd){e.msg="unknown compression method",i.mode=se;break}if(i.flags&57344){e.msg="unknown header flags set",i.mode=se;break}i.head&&(i.head.text=u>>8&1),i.flags&512&&(q[0]=u&255,q[1]=u>>>8&255,i.check=Ri(i.check,q,2,0)),u=0,h=0,i.mode=tv;case tv:for(;h<32;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}i.head&&(i.head.time=u),i.flags&512&&(q[0]=u&255,q[1]=u>>>8&255,q[2]=u>>>16&255,q[3]=u>>>24&255,i.check=Ri(i.check,q,4,0)),u=0,h=0,i.mode=ev;case ev:for(;h<16;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}i.head&&(i.head.xflags=u&255,i.head.os=u>>8),i.flags&512&&(q[0]=u&255,q[1]=u>>>8&255,i.check=Ri(i.check,q,2,0)),u=0,h=0,i.mode=iv;case iv:if(i.flags&1024){for(;h<16;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}i.length=u,i.head&&(i.head.extra_len=u),i.flags&512&&(q[0]=u&255,q[1]=u>>>8&255,i.check=Ri(i.check,q,2,0)),u=0,h=0}else i.head&&(i.head.extra=null);i.mode=nv;case nv:if(i.flags&1024&&(v=i.length,v>l&&(v=l),v&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Qe.arraySet(i.head.extra,n,s,v,B)),i.flags&512&&(i.check=Ri(i.check,n,v,s)),l-=v,s+=v,i.length-=v),i.length))break t;i.length=0,i.mode=rv;case rv:if(i.flags&2048){if(l===0)break t;v=0;do B=n[s+v++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B));while(B&&v<l);if(i.flags&512&&(i.check=Ri(i.check,n,v,s)),l-=v,s+=v,B)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=sv;case sv:if(i.flags&4096){if(l===0)break t;v=0;do B=n[s+v++],i.head&&B&&i.length<65536&&(i.head.comment+=String.fromCharCode(B));while(B&&v<l);if(i.flags&512&&(i.check=Ri(i.check,n,v,s)),l-=v,s+=v,B)break t}else i.head&&(i.head.comment=null);i.mode=av;case av:if(i.flags&512){for(;h<16;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if(u!==(i.check&65535)){e.msg="header crc mismatch",i.mode=se;break}u=0,h=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Vi;break;case ov:for(;h<32;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}e.adler=i.check=bv(u),u=0,h=0,i.mode=Ga;case Ga:if(i.havedict===0)return e.next_out=a,e.avail_out=c,e.next_in=s,e.avail_in=l,i.hold=u,i.bits=h,yC;e.adler=i.check=1,i.mode=Vi;case Vi:if(t===vC||t===Pa)break t;case hc:if(i.last){u>>>=h&7,h-=h&7,i.mode=fc;break}for(;h<3;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}switch(i.last=u&1,u>>>=1,h-=1,u&3){case 0:i.mode=lv;break;case 1:if(AC(i),i.mode=Ia,t===Pa){u>>>=2,h-=2;break t}break;case 2:i.mode=hv;break;case 3:e.msg="invalid block type",i.mode=se}u>>>=2,h-=2;break;case lv:for(u>>>=h&7,h-=h&7;h<32;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if((u&65535)!==(u>>>16^65535)){e.msg="invalid stored block lengths",i.mode=se;break}if(i.length=u&65535,u=0,h=0,i.mode=uc,t===Pa)break t;case uc:i.mode=cv;case cv:if(v=i.length,v){if(v>l&&(v=l),v>c&&(v=c),v===0)break t;Qe.arraySet(r,n,s,v,a),l-=v,s+=v,c-=v,a+=v,i.length-=v;break}i.mode=Vi;break;case hv:for(;h<14;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if(i.nlen=(u&31)+257,u>>>=5,h-=5,i.ndist=(u&31)+1,u>>>=5,h-=5,i.ncode=(u&15)+4,u>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=se;break}i.have=0,i.mode=uv;case uv:for(;i.have<i.ncode;){for(;h<3;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}i.lens[T[i.have++]]=u&7,u>>>=3,h-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,Q={bits:i.lenbits},D=gs(dC,i.lens,0,19,i.lencode,0,i.work,Q),i.lenbits=Q.bits,D){e.msg="invalid code lengths set",i.mode=se;break}i.have=0,i.mode=fv;case fv:for(;i.have<i.nlen+i.ndist;){for(;p=i.lencode[u&(1<<i.lenbits)-1],_=p>>>24,A=p>>>16&255,x=p&65535,!(_<=h);){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if(x<16)u>>>=_,h-=_,i.lens[i.have++]=x;else{if(x===16){for(C=_+2;h<C;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if(u>>>=_,h-=_,i.have===0){e.msg="invalid bit length repeat",i.mode=se;break}B=i.lens[i.have-1],v=3+(u&3),u>>>=2,h-=2}else if(x===17){for(C=_+3;h<C;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}u>>>=_,h-=_,B=0,v=3+(u&7),u>>>=3,h-=3}else{for(C=_+7;h<C;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}u>>>=_,h-=_,B=0,v=11+(u&127),u>>>=7,h-=7}if(i.have+v>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=se;break}for(;v--;)i.lens[i.have++]=B}}if(i.mode===se)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=se;break}if(i.lenbits=9,Q={bits:i.lenbits},D=gs(ey,i.lens,0,i.nlen,i.lencode,0,i.work,Q),i.lenbits=Q.bits,D){e.msg="invalid literal/lengths set",i.mode=se;break}if(i.distbits=6,i.distcode=i.distdyn,Q={bits:i.distbits},D=gs(iy,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,Q),i.distbits=Q.bits,D){e.msg="invalid distances set",i.mode=se;break}if(i.mode=Ia,t===Pa)break t;case Ia:i.mode=La;case La:if(l>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=s,e.avail_in=l,i.hold=u,i.bits=h,fC(e,g),a=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,l=e.avail_in,u=i.hold,h=i.bits,i.mode===Vi&&(i.back=-1);break}for(i.back=0;p=i.lencode[u&(1<<i.lenbits)-1],_=p>>>24,A=p>>>16&255,x=p&65535,!(_<=h);){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if(A&&(A&240)===0){for(E=_,I=A,M=x;p=i.lencode[M+((u&(1<<E+I)-1)>>E)],_=p>>>24,A=p>>>16&255,x=p&65535,!(E+_<=h);){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}u>>>=E,h-=E,i.back+=E}if(u>>>=_,h-=_,i.back+=_,i.length=x,A===0){i.mode=mv;break}if(A&32){i.back=-1,i.mode=Vi;break}if(A&64){e.msg="invalid literal/length code",i.mode=se;break}i.extra=A&15,i.mode=dv;case dv:if(i.extra){for(C=i.extra;h<C;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}i.length+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=vv;case vv:for(;p=i.distcode[u&(1<<i.distbits)-1],_=p>>>24,A=p>>>16&255,x=p&65535,!(_<=h);){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if((A&240)===0){for(E=_,I=A,M=x;p=i.distcode[M+((u&(1<<E+I)-1)>>E)],_=p>>>24,A=p>>>16&255,x=p&65535,!(E+_<=h);){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}u>>>=E,h-=E,i.back+=E}if(u>>>=_,h-=_,i.back+=_,A&64){e.msg="invalid distance code",i.mode=se;break}i.offset=x,i.extra=A&15,i.mode=gv;case gv:if(i.extra){for(C=i.extra;h<C;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}i.offset+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=se;break}i.mode=yv;case yv:if(c===0)break t;if(v=g-c,i.offset>v){if(v=i.offset-v,v>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=se;break}v>i.wnext?(v-=i.wnext,y=i.wsize-v):y=i.wnext-v,v>i.length&&(v=i.length),w=i.window}else w=r,y=a-i.offset,v=i.length;v>c&&(v=c),c-=v,i.length-=v;do r[a++]=w[y++];while(--v);i.length===0&&(i.mode=La);break;case mv:if(c===0)break t;r[a++]=i.length,c--,i.mode=La;break;case fc:if(i.wrap){for(;h<32;){if(l===0)break t;l--,u|=n[s++]<<h,h+=8}if(g-=c,e.total_out+=g,i.total+=g,g&&(e.adler=i.check=i.flags?Ri(i.check,r,g,a-g):Lc(i.check,r,g,a-g)),g=c,(i.flags?u:bv(u))!==i.check){e.msg="incorrect data check",i.mode=se;break}u=0,h=0}i.mode=pv;case pv:if(i.wrap&&i.flags){for(;h<32;){if(l===0)break t;l--,u+=n[s++]<<h,h+=8}if(u!==(i.total&4294967295)){e.msg="incorrect length check",i.mode=se;break}u=0,h=0}i.mode=wv;case wv:D=gC;break t;case se:D=ny;break t;case ay:return ry;case pC:default:return di}return e.next_out=a,e.avail_out=c,e.next_in=s,e.avail_in=l,i.hold=u,i.bits=h,(i.wsize||g!==e.avail_out&&i.mode<se&&(i.mode<fc||t!==Zd))&&uy(e,e.output,e.next_out,g-e.avail_out),d-=e.avail_in,g-=e.avail_out,e.total_in+=d,e.total_out+=g,i.total+=g,i.wrap&&g&&(e.adler=i.check=i.flags?Ri(i.check,r,g,e.next_out-g):Lc(i.check,r,g,e.next_out-g)),e.data_type=i.bits+(i.last?64:0)+(i.mode===Vi?128:0)+(i.mode===Ia||i.mode===uc?256:0),(d===0&&g===0||t===Zd)&&D===Zn&&(D=mC),D}function CC(e){if(!e||!e.state)return di;var t=e.state;return t.window&&(t.window=null),e.state=null,Zn}function TC(e,t){var i;return!e||!e.state||(i=e.state,(i.wrap&2)===0)?di:(i.head=t,t.done=!1,Zn)}function SC(e,t){var i=t.length,n,r,s;return!e||!e.state||(n=e.state,n.wrap!==0&&n.mode!==Ga)?di:n.mode===Ga&&(r=1,r=Lc(r,t,i,0),r!==n.check)?ny:(s=uy(e,t,i,i),s?(n.mode=ay,ry):(n.havedict=1,Zn))}bi.inflateReset=ly;bi.inflateReset2=cy;bi.inflateResetKeep=oy;bi.inflateInit=EC;bi.inflateInit2=hy;bi.inflate=RC;bi.inflateEnd=CC;bi.inflateGetHeader=TC;bi.inflateSetDictionary=SC;bi.inflateInfo="pako inflate (from Nodeca project)";var fy={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function PC(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var IC=PC,Mr=bi,ys=nn,Ua=er,de=fy,Dc=Qc,LC=Qg,DC=IC,dy=Object.prototype.toString;function Jn(e){if(!(this instanceof Jn))return new Jn(e);this.options=ys.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new LC,this.strm.avail_out=0;var i=Mr.inflateInit2(this.strm,t.windowBits);if(i!==de.Z_OK)throw new Error(Dc[i]);if(this.header=new DC,Mr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Ua.string2buf(t.dictionary):dy.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Mr.inflateSetDictionary(this.strm,t.dictionary),i!==de.Z_OK)))throw new Error(Dc[i])}Jn.prototype.push=function(e,t){var i=this.strm,n=this.options.chunkSize,r=this.options.dictionary,s,a,l,c,u,h=!1;if(this.ended)return!1;a=t===~~t?t:t===!0?de.Z_FINISH:de.Z_NO_FLUSH,typeof e=="string"?i.input=Ua.binstring2buf(e):dy.call(e)==="[object ArrayBuffer]"?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(i.avail_out===0&&(i.output=new ys.Buf8(n),i.next_out=0,i.avail_out=n),s=Mr.inflate(i,de.Z_NO_FLUSH),s===de.Z_NEED_DICT&&r&&(s=Mr.inflateSetDictionary(this.strm,r)),s===de.Z_BUF_ERROR&&h===!0&&(s=de.Z_OK,h=!1),s!==de.Z_STREAM_END&&s!==de.Z_OK)return this.onEnd(s),this.ended=!0,!1;i.next_out&&(i.avail_out===0||s===de.Z_STREAM_END||i.avail_in===0&&(a===de.Z_FINISH||a===de.Z_SYNC_FLUSH))&&(this.options.to==="string"?(l=Ua.utf8border(i.output,i.next_out),c=i.next_out-l,u=Ua.buf2string(i.output,l),i.next_out=c,i.avail_out=n-c,c&&ys.arraySet(i.output,i.output,l,c,0),this.onData(u)):this.onData(ys.shrinkBuf(i.output,i.next_out))),i.avail_in===0&&i.avail_out===0&&(h=!0)}while((i.avail_in>0||i.avail_out===0)&&s!==de.Z_STREAM_END);return s===de.Z_STREAM_END&&(a=de.Z_FINISH),a===de.Z_FINISH?(s=Mr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===de.Z_OK):(a===de.Z_SYNC_FLUSH&&(this.onEnd(de.Z_OK),i.avail_out=0),!0)};Jn.prototype.onData=function(e){this.chunks.push(e)};Jn.prototype.onEnd=function(e){e===de.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ys.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function eh(e,t){var i=new Jn(t);if(i.push(e,!0),i.err)throw i.msg||Dc[i.err];return i.result}function MC(e,t){return t=t||{},t.raw=!0,eh(e,t)}Ps.Inflate=Jn;Ps.inflate=eh;Ps.inflateRaw=MC;Ps.ungzip=eh;var BC=nn.assign,OC=Cs,NC=Ps,FC=fy,vy={};BC(vy,OC,NC,FC);var eT=vy,Mc={exports:{}};/**
  78. * @license
  79. * Lodash <https://lodash.com/>
  80. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  81. * Released under MIT license <https://lodash.com/license>
  82. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  83. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  84. */(function(e,t){(function(){var i,n="4.17.21",r=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",u=500,h="__lodash_placeholder__",d=1,g=2,v=4,y=1,w=2,p=1,_=2,A=4,x=8,E=16,I=32,M=64,B=128,D=256,q=512,Q=30,C="...",T=800,S=16,O=1,K=2,Z=3,st=1/0,$=9007199254740991,z=17976931348623157e292,V=0/0,Y=4294967295,U=Y-1,tt=Y>>>1,rt=[["ary",B],["bind",p],["bindKey",_],["curry",x],["curryRight",E],["flip",q],["partial",I],["partialRight",M],["rearg",D]],nt="[object Arguments]",ft="[object Array]",lt="[object AsyncFunction]",ut="[object Boolean]",b="[object Date]",k="[object DOMException]",P="[object Error]",H="[object Function]",X="[object GeneratorFunction]",J="[object Map]",at="[object Number]",mt="[object Null]",yt="[object Object]",kt="[object Promise]",Tt="[object Proxy]",be="[object RegExp]",ne="[object Set]",xe="[object String]",Vt="[object Symbol]",Qt="[object Undefined]",xi="[object WeakMap]",gy="[object WeakSet]",Hr="[object ArrayBuffer]",ir="[object DataView]",ao="[object Float32Array]",oo="[object Float64Array]",lo="[object Int8Array]",co="[object Int16Array]",ho="[object Int32Array]",uo="[object Uint8Array]",fo="[object Uint8ClampedArray]",vo="[object Uint16Array]",go="[object Uint32Array]",yy=/\b__p \+= '';/g,my=/\b(__p \+=) '' \+/g,py=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ih=/&(?:amp|lt|gt|quot|#39);/g,nh=/[&<>"']/g,wy=RegExp(ih.source),by=RegExp(nh.source),xy=/<%-([\s\S]+?)%>/g,_y=/<%([\s\S]+?)%>/g,rh=/<%=([\s\S]+?)%>/g,ky=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ey=/^\w*$/,Ay=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,yo=/[\\^$.*+?()[\]{}|]/g,Ry=RegExp(yo.source),mo=/^\s+/,Cy=/\s/,Ty=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Sy=/\{\n\/\* \[wrapped with (.+)\] \*/,Py=/,? & /,Iy=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ly=/[()=,{}\[\]\/\s]/,Dy=/\\(\\)?/g,My=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,sh=/\w*$/,By=/^[-+]0x[0-9a-f]+$/i,Oy=/^0b[01]+$/i,Ny=/^\[object .+?Constructor\]$/,Fy=/^0o[0-7]+$/i,zy=/^(?:0|[1-9]\d*)$/,Hy=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Is=/($^)/,Uy=/['\n\r\u2028\u2029\\]/g,Ls="\\ud800-\\udfff",Wy="\\u0300-\\u036f",qy="\\ufe20-\\ufe2f",jy="\\u20d0-\\u20ff",ah=Wy+qy+jy,oh="\\u2700-\\u27bf",lh="a-z\\xdf-\\xf6\\xf8-\\xff",Vy="\\xac\\xb1\\xd7\\xf7",$y="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ky="\\u2000-\\u206f",Yy=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ch="A-Z\\xc0-\\xd6\\xd8-\\xde",hh="\\ufe0e\\ufe0f",uh=Vy+$y+Ky+Yy,po="['\u2019]",Xy="["+Ls+"]",fh="["+uh+"]",Ds="["+ah+"]",dh="\\d+",Gy="["+oh+"]",vh="["+lh+"]",gh="[^"+Ls+uh+dh+oh+lh+ch+"]",wo="\\ud83c[\\udffb-\\udfff]",Zy="(?:"+Ds+"|"+wo+")",yh="[^"+Ls+"]",bo="(?:\\ud83c[\\udde6-\\uddff]){2}",xo="[\\ud800-\\udbff][\\udc00-\\udfff]",nr="["+ch+"]",mh="\\u200d",ph="(?:"+vh+"|"+gh+")",Jy="(?:"+nr+"|"+gh+")",wh="(?:"+po+"(?:d|ll|m|re|s|t|ve))?",bh="(?:"+po+"(?:D|LL|M|RE|S|T|VE))?",xh=Zy+"?",_h="["+hh+"]?",Qy="(?:"+mh+"(?:"+[yh,bo,xo].join("|")+")"+_h+xh+")*",tm="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",em="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",kh=_h+xh+Qy,im="(?:"+[Gy,bo,xo].join("|")+")"+kh,nm="(?:"+[yh+Ds+"?",Ds,bo,xo,Xy].join("|")+")",rm=RegExp(po,"g"),sm=RegExp(Ds,"g"),_o=RegExp(wo+"(?="+wo+")|"+nm+kh,"g"),am=RegExp([nr+"?"+vh+"+"+wh+"(?="+[fh,nr,"$"].join("|")+")",Jy+"+"+bh+"(?="+[fh,nr+ph,"$"].join("|")+")",nr+"?"+ph+"+"+wh,nr+"+"+bh,em,tm,dh,im].join("|"),"g"),om=RegExp("["+mh+Ls+ah+hh+"]"),lm=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,cm=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],hm=-1,ie={};ie[ao]=ie[oo]=ie[lo]=ie[co]=ie[ho]=ie[uo]=ie[fo]=ie[vo]=ie[go]=!0,ie[nt]=ie[ft]=ie[Hr]=ie[ut]=ie[ir]=ie[b]=ie[P]=ie[H]=ie[J]=ie[at]=ie[yt]=ie[be]=ie[ne]=ie[xe]=ie[xi]=!1;var te={};te[nt]=te[ft]=te[Hr]=te[ir]=te[ut]=te[b]=te[ao]=te[oo]=te[lo]=te[co]=te[ho]=te[J]=te[at]=te[yt]=te[be]=te[ne]=te[xe]=te[Vt]=te[uo]=te[fo]=te[vo]=te[go]=!0,te[P]=te[H]=te[xi]=!1;var um={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},fm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},dm={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},vm={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},gm=parseFloat,ym=parseInt,Eh=typeof Le=="object"&&Le&&Le.Object===Object&&Le,mm=typeof self=="object"&&self&&self.Object===Object&&self,_e=Eh||mm||Function("return this")(),ko=t&&!t.nodeType&&t,Tn=ko&&!0&&e&&!e.nodeType&&e,Ah=Tn&&Tn.exports===ko,Eo=Ah&&Eh.process,ii=function(){try{var et=Tn&&Tn.require&&Tn.require("util").types;return et||Eo&&Eo.binding&&Eo.binding("util")}catch{}}(),Rh=ii&&ii.isArrayBuffer,Ch=ii&&ii.isDate,Th=ii&&ii.isMap,Sh=ii&&ii.isRegExp,Ph=ii&&ii.isSet,Ih=ii&&ii.isTypedArray;function qe(et,ht,ot){switch(ot.length){case 0:return et.call(ht);case 1:return et.call(ht,ot[0]);case 2:return et.call(ht,ot[0],ot[1]);case 3:return et.call(ht,ot[0],ot[1],ot[2])}return et.apply(ht,ot)}function pm(et,ht,ot,wt){for(var St=-1,$t=et==null?0:et.length;++St<$t;){var ge=et[St];ht(wt,ge,ot(ge),et)}return wt}function ni(et,ht){for(var ot=-1,wt=et==null?0:et.length;++ot<wt&&ht(et[ot],ot,et)!==!1;);return et}function wm(et,ht){for(var ot=et==null?0:et.length;ot--&&ht(et[ot],ot,et)!==!1;);return et}function Lh(et,ht){for(var ot=-1,wt=et==null?0:et.length;++ot<wt;)if(!ht(et[ot],ot,et))return!1;return!0}function rn(et,ht){for(var ot=-1,wt=et==null?0:et.length,St=0,$t=[];++ot<wt;){var ge=et[ot];ht(ge,ot,et)&&($t[St++]=ge)}return $t}function Ms(et,ht){var ot=et==null?0:et.length;return!!ot&&rr(et,ht,0)>-1}function Ao(et,ht,ot){for(var wt=-1,St=et==null?0:et.length;++wt<St;)if(ot(ht,et[wt]))return!0;return!1}function re(et,ht){for(var ot=-1,wt=et==null?0:et.length,St=Array(wt);++ot<wt;)St[ot]=ht(et[ot],ot,et);return St}function sn(et,ht){for(var ot=-1,wt=ht.length,St=et.length;++ot<wt;)et[St+ot]=ht[ot];return et}function Ro(et,ht,ot,wt){var St=-1,$t=et==null?0:et.length;for(wt&&$t&&(ot=et[++St]);++St<$t;)ot=ht(ot,et[St],St,et);return ot}function bm(et,ht,ot,wt){var St=et==null?0:et.length;for(wt&&St&&(ot=et[--St]);St--;)ot=ht(ot,et[St],St,et);return ot}function Co(et,ht){for(var ot=-1,wt=et==null?0:et.length;++ot<wt;)if(ht(et[ot],ot,et))return!0;return!1}var xm=To("length");function _m(et){return et.split("")}function km(et){return et.match(Iy)||[]}function Dh(et,ht,ot){var wt;return ot(et,function(St,$t,ge){if(ht(St,$t,ge))return wt=$t,!1}),wt}function Bs(et,ht,ot,wt){for(var St=et.length,$t=ot+(wt?1:-1);wt?$t--:++$t<St;)if(ht(et[$t],$t,et))return $t;return-1}function rr(et,ht,ot){return ht===ht?Bm(et,ht,ot):Bs(et,Mh,ot)}function Em(et,ht,ot,wt){for(var St=ot-1,$t=et.length;++St<$t;)if(wt(et[St],ht))return St;return-1}function Mh(et){return et!==et}function Bh(et,ht){var ot=et==null?0:et.length;return ot?Po(et,ht)/ot:V}function To(et){return function(ht){return ht==null?i:ht[et]}}function So(et){return function(ht){return et==null?i:et[ht]}}function Oh(et,ht,ot,wt,St){return St(et,function($t,ge,Zt){ot=wt?(wt=!1,$t):ht(ot,$t,ge,Zt)}),ot}function Am(et,ht){var ot=et.length;for(et.sort(ht);ot--;)et[ot]=et[ot].value;return et}function Po(et,ht){for(var ot,wt=-1,St=et.length;++wt<St;){var $t=ht(et[wt]);$t!==i&&(ot=ot===i?$t:ot+$t)}return ot}function Io(et,ht){for(var ot=-1,wt=Array(et);++ot<et;)wt[ot]=ht(ot);return wt}function Rm(et,ht){return re(ht,function(ot){return[ot,et[ot]]})}function Nh(et){return et&&et.slice(0,Uh(et)+1).replace(mo,"")}function je(et){return function(ht){return et(ht)}}function Lo(et,ht){return re(ht,function(ot){return et[ot]})}function Ur(et,ht){return et.has(ht)}function Fh(et,ht){for(var ot=-1,wt=et.length;++ot<wt&&rr(ht,et[ot],0)>-1;);return ot}function zh(et,ht){for(var ot=et.length;ot--&&rr(ht,et[ot],0)>-1;);return ot}function Cm(et,ht){for(var ot=et.length,wt=0;ot--;)et[ot]===ht&&++wt;return wt}var Tm=So(um),Sm=So(fm);function Pm(et){return"\\"+vm[et]}function Im(et,ht){return et==null?i:et[ht]}function sr(et){return om.test(et)}function Lm(et){return lm.test(et)}function Dm(et){for(var ht,ot=[];!(ht=et.next()).done;)ot.push(ht.value);return ot}function Do(et){var ht=-1,ot=Array(et.size);return et.forEach(function(wt,St){ot[++ht]=[St,wt]}),ot}function Hh(et,ht){return function(ot){return et(ht(ot))}}function an(et,ht){for(var ot=-1,wt=et.length,St=0,$t=[];++ot<wt;){var ge=et[ot];(ge===ht||ge===h)&&(et[ot]=h,$t[St++]=ot)}return $t}function Os(et){var ht=-1,ot=Array(et.size);return et.forEach(function(wt){ot[++ht]=wt}),ot}function Mm(et){var ht=-1,ot=Array(et.size);return et.forEach(function(wt){ot[++ht]=[wt,wt]}),ot}function Bm(et,ht,ot){for(var wt=ot-1,St=et.length;++wt<St;)if(et[wt]===ht)return wt;return-1}function Om(et,ht,ot){for(var wt=ot+1;wt--;)if(et[wt]===ht)return wt;return wt}function ar(et){return sr(et)?Fm(et):xm(et)}function vi(et){return sr(et)?zm(et):_m(et)}function Uh(et){for(var ht=et.length;ht--&&Cy.test(et.charAt(ht)););return ht}var Nm=So(dm);function Fm(et){for(var ht=_o.lastIndex=0;_o.test(et);)++ht;return ht}function zm(et){return et.match(_o)||[]}function Hm(et){return et.match(am)||[]}var Um=function et(ht){ht=ht==null?_e:or.defaults(_e.Object(),ht,or.pick(_e,cm));var ot=ht.Array,wt=ht.Date,St=ht.Error,$t=ht.Function,ge=ht.Math,Zt=ht.Object,Mo=ht.RegExp,Wm=ht.String,ri=ht.TypeError,Ns=ot.prototype,qm=$t.prototype,lr=Zt.prototype,Fs=ht["__core-js_shared__"],zs=qm.toString,Xt=lr.hasOwnProperty,jm=0,Wh=function(){var o=/[^.]+$/.exec(Fs&&Fs.keys&&Fs.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),Hs=lr.toString,Vm=zs.call(Zt),$m=_e._,Km=Mo("^"+zs.call(Xt).replace(yo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Us=Ah?ht.Buffer:i,on=ht.Symbol,Ws=ht.Uint8Array,qh=Us?Us.allocUnsafe:i,qs=Hh(Zt.getPrototypeOf,Zt),jh=Zt.create,Vh=lr.propertyIsEnumerable,js=Ns.splice,$h=on?on.isConcatSpreadable:i,Wr=on?on.iterator:i,Sn=on?on.toStringTag:i,Vs=function(){try{var o=Mn(Zt,"defineProperty");return o({},"",{}),o}catch{}}(),Ym=ht.clearTimeout!==_e.clearTimeout&&ht.clearTimeout,Xm=wt&&wt.now!==_e.Date.now&&wt.now,Gm=ht.setTimeout!==_e.setTimeout&&ht.setTimeout,$s=ge.ceil,Ks=ge.floor,Bo=Zt.getOwnPropertySymbols,Zm=Us?Us.isBuffer:i,Kh=ht.isFinite,Jm=Ns.join,Qm=Hh(Zt.keys,Zt),ye=ge.max,Ce=ge.min,t0=wt.now,e0=ht.parseInt,Yh=ge.random,i0=Ns.reverse,Oo=Mn(ht,"DataView"),qr=Mn(ht,"Map"),No=Mn(ht,"Promise"),cr=Mn(ht,"Set"),jr=Mn(ht,"WeakMap"),Vr=Mn(Zt,"create"),Ys=jr&&new jr,hr={},n0=Bn(Oo),r0=Bn(qr),s0=Bn(No),a0=Bn(cr),o0=Bn(jr),Xs=on?on.prototype:i,$r=Xs?Xs.valueOf:i,Xh=Xs?Xs.toString:i;function N(o){if(ce(o)&&!Pt(o)&&!(o instanceof Ft)){if(o instanceof si)return o;if(Xt.call(o,"__wrapped__"))return Gu(o)}return new si(o)}var ur=function(){function o(){}return function(f){if(!oe(f))return{};if(jh)return jh(f);o.prototype=f;var m=new o;return o.prototype=i,m}}();function Gs(){}function si(o,f){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!f,this.__index__=0,this.__values__=i}N.templateSettings={escape:xy,evaluate:_y,interpolate:rh,variable:"",imports:{_:N}},N.prototype=Gs.prototype,N.prototype.constructor=N,si.prototype=ur(Gs.prototype),si.prototype.constructor=si;function Ft(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Y,this.__views__=[]}function l0(){var o=new Ft(this.__wrapped__);return o.__actions__=Me(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=Me(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=Me(this.__views__),o}function c0(){if(this.__filtered__){var o=new Ft(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function h0(){var o=this.__wrapped__.value(),f=this.__dir__,m=Pt(o),R=f<0,L=m?o.length:0,F=_p(0,L,this.__views__),j=F.start,G=F.end,it=G-j,dt=R?G:j-1,vt=this.__iteratees__,gt=vt.length,pt=0,_t=Ce(it,this.__takeCount__);if(!m||!R&&L==it&&_t==it)return wu(o,this.__actions__);var Rt=[];t:for(;it--&&pt<_t;){dt+=f;for(var Mt=-1,Ct=o[dt];++Mt<gt;){var Nt=vt[Mt],Ht=Nt.iteratee,Ke=Nt.type,Ie=Ht(Ct);if(Ke==K)Ct=Ie;else if(!Ie){if(Ke==O)continue t;break t}}Rt[pt++]=Ct}return Rt}Ft.prototype=ur(Gs.prototype),Ft.prototype.constructor=Ft;function Pn(o){var f=-1,m=o==null?0:o.length;for(this.clear();++f<m;){var R=o[f];this.set(R[0],R[1])}}function u0(){this.__data__=Vr?Vr(null):{},this.size=0}function f0(o){var f=this.has(o)&&delete this.__data__[o];return this.size-=f?1:0,f}function d0(o){var f=this.__data__;if(Vr){var m=f[o];return m===c?i:m}return Xt.call(f,o)?f[o]:i}function v0(o){var f=this.__data__;return Vr?f[o]!==i:Xt.call(f,o)}function g0(o,f){var m=this.__data__;return this.size+=this.has(o)?0:1,m[o]=Vr&&f===i?c:f,this}Pn.prototype.clear=u0,Pn.prototype.delete=f0,Pn.prototype.get=d0,Pn.prototype.has=v0,Pn.prototype.set=g0;function Mi(o){var f=-1,m=o==null?0:o.length;for(this.clear();++f<m;){var R=o[f];this.set(R[0],R[1])}}function y0(){this.__data__=[],this.size=0}function m0(o){var f=this.__data__,m=Zs(f,o);if(m<0)return!1;var R=f.length-1;return m==R?f.pop():js.call(f,m,1),--this.size,!0}function p0(o){var f=this.__data__,m=Zs(f,o);return m<0?i:f[m][1]}function w0(o){return Zs(this.__data__,o)>-1}function b0(o,f){var m=this.__data__,R=Zs(m,o);return R<0?(++this.size,m.push([o,f])):m[R][1]=f,this}Mi.prototype.clear=y0,Mi.prototype.delete=m0,Mi.prototype.get=p0,Mi.prototype.has=w0,Mi.prototype.set=b0;function Bi(o){var f=-1,m=o==null?0:o.length;for(this.clear();++f<m;){var R=o[f];this.set(R[0],R[1])}}function x0(){this.size=0,this.__data__={hash:new Pn,map:new(qr||Mi),string:new Pn}}function _0(o){var f=ca(this,o).delete(o);return this.size-=f?1:0,f}function k0(o){return ca(this,o).get(o)}function E0(o){return ca(this,o).has(o)}function A0(o,f){var m=ca(this,o),R=m.size;return m.set(o,f),this.size+=m.size==R?0:1,this}Bi.prototype.clear=x0,Bi.prototype.delete=_0,Bi.prototype.get=k0,Bi.prototype.has=E0,Bi.prototype.set=A0;function In(o){var f=-1,m=o==null?0:o.length;for(this.__data__=new Bi;++f<m;)this.add(o[f])}function R0(o){return this.__data__.set(o,c),this}function C0(o){return this.__data__.has(o)}In.prototype.add=In.prototype.push=R0,In.prototype.has=C0;function gi(o){var f=this.__data__=new Mi(o);this.size=f.size}function T0(){this.__data__=new Mi,this.size=0}function S0(o){var f=this.__data__,m=f.delete(o);return this.size=f.size,m}function P0(o){return this.__data__.get(o)}function I0(o){return this.__data__.has(o)}function L0(o,f){var m=this.__data__;if(m instanceof Mi){var R=m.__data__;if(!qr||R.length<r-1)return R.push([o,f]),this.size=++m.size,this;m=this.__data__=new Bi(R)}return m.set(o,f),this.size=m.size,this}gi.prototype.clear=T0,gi.prototype.delete=S0,gi.prototype.get=P0,gi.prototype.has=I0,gi.prototype.set=L0;function Gh(o,f){var m=Pt(o),R=!m&&On(o),L=!m&&!R&&fn(o),F=!m&&!R&&!L&&gr(o),j=m||R||L||F,G=j?Io(o.length,Wm):[],it=G.length;for(var dt in o)(f||Xt.call(o,dt))&&!(j&&(dt=="length"||L&&(dt=="offset"||dt=="parent")||F&&(dt=="buffer"||dt=="byteLength"||dt=="byteOffset")||zi(dt,it)))&&G.push(dt);return G}function Zh(o){var f=o.length;return f?o[Yo(0,f-1)]:i}function D0(o,f){return ha(Me(o),Ln(f,0,o.length))}function M0(o){return ha(Me(o))}function Fo(o,f,m){(m!==i&&!yi(o[f],m)||m===i&&!(f in o))&&Oi(o,f,m)}function Kr(o,f,m){var R=o[f];(!(Xt.call(o,f)&&yi(R,m))||m===i&&!(f in o))&&Oi(o,f,m)}function Zs(o,f){for(var m=o.length;m--;)if(yi(o[m][0],f))return m;return-1}function B0(o,f,m,R){return ln(o,function(L,F,j){f(R,L,m(L),j)}),R}function Jh(o,f){return o&&ki(f,pe(f),o)}function O0(o,f){return o&&ki(f,Oe(f),o)}function Oi(o,f,m){f=="__proto__"&&Vs?Vs(o,f,{configurable:!0,enumerable:!0,value:m,writable:!0}):o[f]=m}function zo(o,f){for(var m=-1,R=f.length,L=ot(R),F=o==null;++m<R;)L[m]=F?i:wl(o,f[m]);return L}function Ln(o,f,m){return o===o&&(m!==i&&(o=o<=m?o:m),f!==i&&(o=o>=f?o:f)),o}function ai(o,f,m,R,L,F){var j,G=f&d,it=f&g,dt=f&v;if(m&&(j=L?m(o,R,L,F):m(o)),j!==i)return j;if(!oe(o))return o;var vt=Pt(o);if(vt){if(j=Ep(o),!G)return Me(o,j)}else{var gt=Te(o),pt=gt==H||gt==X;if(fn(o))return _u(o,G);if(gt==yt||gt==nt||pt&&!L){if(j=it||pt?{}:Uu(o),!G)return it?dp(o,O0(j,o)):fp(o,Jh(j,o))}else{if(!te[gt])return L?o:{};j=Ap(o,gt,G)}}F||(F=new gi);var _t=F.get(o);if(_t)return _t;F.set(o,j),mf(o)?o.forEach(function(Ct){j.add(ai(Ct,f,m,Ct,o,F))}):gf(o)&&o.forEach(function(Ct,Nt){j.set(Nt,ai(Ct,f,m,Nt,o,F))});var Rt=dt?it?sl:rl:it?Oe:pe,Mt=vt?i:Rt(o);return ni(Mt||o,function(Ct,Nt){Mt&&(Nt=Ct,Ct=o[Nt]),Kr(j,Nt,ai(Ct,f,m,Nt,o,F))}),j}function N0(o){var f=pe(o);return function(m){return Qh(m,o,f)}}function Qh(o,f,m){var R=m.length;if(o==null)return!R;for(o=Zt(o);R--;){var L=m[R],F=f[L],j=o[L];if(j===i&&!(L in o)||!F(j))return!1}return!0}function tu(o,f,m){if(typeof o!="function")throw new ri(a);return ts(function(){o.apply(i,m)},f)}function Yr(o,f,m,R){var L=-1,F=Ms,j=!0,G=o.length,it=[],dt=f.length;if(!G)return it;m&&(f=re(f,je(m))),R?(F=Ao,j=!1):f.length>=r&&(F=Ur,j=!1,f=new In(f));t:for(;++L<G;){var vt=o[L],gt=m==null?vt:m(vt);if(vt=R||vt!==0?vt:0,j&&gt===gt){for(var pt=dt;pt--;)if(f[pt]===gt)continue t;it.push(vt)}else F(f,gt,R)||it.push(vt)}return it}var ln=Cu(_i),eu=Cu(Uo,!0);function F0(o,f){var m=!0;return ln(o,function(R,L,F){return m=!!f(R,L,F),m}),m}function Js(o,f,m){for(var R=-1,L=o.length;++R<L;){var F=o[R],j=f(F);if(j!=null&&(G===i?j===j&&!$e(j):m(j,G)))var G=j,it=F}return it}function z0(o,f,m,R){var L=o.length;for(m=Dt(m),m<0&&(m=-m>L?0:L+m),R=R===i||R>L?L:Dt(R),R<0&&(R+=L),R=m>R?0:wf(R);m<R;)o[m++]=f;return o}function iu(o,f){var m=[];return ln(o,function(R,L,F){f(R,L,F)&&m.push(R)}),m}function ke(o,f,m,R,L){var F=-1,j=o.length;for(m||(m=Cp),L||(L=[]);++F<j;){var G=o[F];f>0&&m(G)?f>1?ke(G,f-1,m,R,L):sn(L,G):R||(L[L.length]=G)}return L}var Ho=Tu(),nu=Tu(!0);function _i(o,f){return o&&Ho(o,f,pe)}function Uo(o,f){return o&&nu(o,f,pe)}function Qs(o,f){return rn(f,function(m){return Hi(o[m])})}function Dn(o,f){f=hn(f,o);for(var m=0,R=f.length;o!=null&&m<R;)o=o[Ei(f[m++])];return m&&m==R?o:i}function ru(o,f,m){var R=f(o);return Pt(o)?R:sn(R,m(o))}function Se(o){return o==null?o===i?Qt:mt:Sn&&Sn in Zt(o)?xp(o):Mp(o)}function Wo(o,f){return o>f}function H0(o,f){return o!=null&&Xt.call(o,f)}function U0(o,f){return o!=null&&f in Zt(o)}function W0(o,f,m){return o>=Ce(f,m)&&o<ye(f,m)}function qo(o,f,m){for(var R=m?Ao:Ms,L=o[0].length,F=o.length,j=F,G=ot(F),it=1/0,dt=[];j--;){var vt=o[j];j&&f&&(vt=re(vt,je(f))),it=Ce(vt.length,it),G[j]=!m&&(f||L>=120&&vt.length>=120)?new In(j&&vt):i}vt=o[0];var gt=-1,pt=G[0];t:for(;++gt<L&&dt.length<it;){var _t=vt[gt],Rt=f?f(_t):_t;if(_t=m||_t!==0?_t:0,!(pt?Ur(pt,Rt):R(dt,Rt,m))){for(j=F;--j;){var Mt=G[j];if(!(Mt?Ur(Mt,Rt):R(o[j],Rt,m)))continue t}pt&&pt.push(Rt),dt.push(_t)}}return dt}function q0(o,f,m,R){return _i(o,function(L,F,j){f(R,m(L),F,j)}),R}function Xr(o,f,m){f=hn(f,o),o=Vu(o,f);var R=o==null?o:o[Ei(li(f))];return R==null?i:qe(R,o,m)}function su(o){return ce(o)&&Se(o)==nt}function j0(o){return ce(o)&&Se(o)==Hr}function V0(o){return ce(o)&&Se(o)==b}function Gr(o,f,m,R,L){return o===f?!0:o==null||f==null||!ce(o)&&!ce(f)?o!==o&&f!==f:$0(o,f,m,R,Gr,L)}function $0(o,f,m,R,L,F){var j=Pt(o),G=Pt(f),it=j?ft:Te(o),dt=G?ft:Te(f);it=it==nt?yt:it,dt=dt==nt?yt:dt;var vt=it==yt,gt=dt==yt,pt=it==dt;if(pt&&fn(o)){if(!fn(f))return!1;j=!0,vt=!1}if(pt&&!vt)return F||(F=new gi),j||gr(o)?Fu(o,f,m,R,L,F):wp(o,f,it,m,R,L,F);if(!(m&y)){var _t=vt&&Xt.call(o,"__wrapped__"),Rt=gt&&Xt.call(f,"__wrapped__");if(_t||Rt){var Mt=_t?o.value():o,Ct=Rt?f.value():f;return F||(F=new gi),L(Mt,Ct,m,R,F)}}return pt?(F||(F=new gi),bp(o,f,m,R,L,F)):!1}function K0(o){return ce(o)&&Te(o)==J}function jo(o,f,m,R){var L=m.length,F=L,j=!R;if(o==null)return!F;for(o=Zt(o);L--;){var G=m[L];if(j&&G[2]?G[1]!==o[G[0]]:!(G[0]in o))return!1}for(;++L<F;){G=m[L];var it=G[0],dt=o[it],vt=G[1];if(j&&G[2]){if(dt===i&&!(it in o))return!1}else{var gt=new gi;if(R)var pt=R(dt,vt,it,o,f,gt);if(!(pt===i?Gr(vt,dt,y|w,R,gt):pt))return!1}}return!0}function au(o){if(!oe(o)||Sp(o))return!1;var f=Hi(o)?Km:Ny;return f.test(Bn(o))}function Y0(o){return ce(o)&&Se(o)==be}function X0(o){return ce(o)&&Te(o)==ne}function G0(o){return ce(o)&&ya(o.length)&&!!ie[Se(o)]}function ou(o){return typeof o=="function"?o:o==null?Ne:typeof o=="object"?Pt(o)?hu(o[0],o[1]):cu(o):Pf(o)}function Vo(o){if(!Qr(o))return Qm(o);var f=[];for(var m in Zt(o))Xt.call(o,m)&&m!="constructor"&&f.push(m);return f}function Z0(o){if(!oe(o))return Dp(o);var f=Qr(o),m=[];for(var R in o)R=="constructor"&&(f||!Xt.call(o,R))||m.push(R);return m}function $o(o,f){return o<f}function lu(o,f){var m=-1,R=Be(o)?ot(o.length):[];return ln(o,function(L,F,j){R[++m]=f(L,F,j)}),R}function cu(o){var f=ol(o);return f.length==1&&f[0][2]?qu(f[0][0],f[0][1]):function(m){return m===o||jo(m,o,f)}}function hu(o,f){return cl(o)&&Wu(f)?qu(Ei(o),f):function(m){var R=wl(m,o);return R===i&&R===f?bl(m,o):Gr(f,R,y|w)}}function ta(o,f,m,R,L){o!==f&&Ho(f,function(F,j){if(L||(L=new gi),oe(F))J0(o,f,j,m,ta,R,L);else{var G=R?R(ul(o,j),F,j+"",o,f,L):i;G===i&&(G=F),Fo(o,j,G)}},Oe)}function J0(o,f,m,R,L,F,j){var G=ul(o,m),it=ul(f,m),dt=j.get(it);if(dt){Fo(o,m,dt);return}var vt=F?F(G,it,m+"",o,f,j):i,gt=vt===i;if(gt){var pt=Pt(it),_t=!pt&&fn(it),Rt=!pt&&!_t&&gr(it);vt=it,pt||_t||Rt?Pt(G)?vt=G:he(G)?vt=Me(G):_t?(gt=!1,vt=_u(it,!0)):Rt?(gt=!1,vt=ku(it,!0)):vt=[]:es(it)||On(it)?(vt=G,On(G)?vt=bf(G):(!oe(G)||Hi(G))&&(vt=Uu(it))):gt=!1}gt&&(j.set(it,vt),L(vt,it,R,F,j),j.delete(it)),Fo(o,m,vt)}function uu(o,f){var m=o.length;if(!!m)return f+=f<0?m:0,zi(f,m)?o[f]:i}function fu(o,f,m){f.length?f=re(f,function(F){return Pt(F)?function(j){return Dn(j,F.length===1?F[0]:F)}:F}):f=[Ne];var R=-1;f=re(f,je(Et()));var L=lu(o,function(F,j,G){var it=re(f,function(dt){return dt(F)});return{criteria:it,index:++R,value:F}});return Am(L,function(F,j){return up(F,j,m)})}function Q0(o,f){return du(o,f,function(m,R){return bl(o,R)})}function du(o,f,m){for(var R=-1,L=f.length,F={};++R<L;){var j=f[R],G=Dn(o,j);m(G,j)&&Zr(F,hn(j,o),G)}return F}function tp(o){return function(f){return Dn(f,o)}}function Ko(o,f,m,R){var L=R?Em:rr,F=-1,j=f.length,G=o;for(o===f&&(f=Me(f)),m&&(G=re(o,je(m)));++F<j;)for(var it=0,dt=f[F],vt=m?m(dt):dt;(it=L(G,vt,it,R))>-1;)G!==o&&js.call(G,it,1),js.call(o,it,1);return o}function vu(o,f){for(var m=o?f.length:0,R=m-1;m--;){var L=f[m];if(m==R||L!==F){var F=L;zi(L)?js.call(o,L,1):Zo(o,L)}}return o}function Yo(o,f){return o+Ks(Yh()*(f-o+1))}function ep(o,f,m,R){for(var L=-1,F=ye($s((f-o)/(m||1)),0),j=ot(F);F--;)j[R?F:++L]=o,o+=m;return j}function Xo(o,f){var m="";if(!o||f<1||f>$)return m;do f%2&&(m+=o),f=Ks(f/2),f&&(o+=o);while(f);return m}function Bt(o,f){return fl(ju(o,f,Ne),o+"")}function ip(o){return Zh(yr(o))}function np(o,f){var m=yr(o);return ha(m,Ln(f,0,m.length))}function Zr(o,f,m,R){if(!oe(o))return o;f=hn(f,o);for(var L=-1,F=f.length,j=F-1,G=o;G!=null&&++L<F;){var it=Ei(f[L]),dt=m;if(it==="__proto__"||it==="constructor"||it==="prototype")return o;if(L!=j){var vt=G[it];dt=R?R(vt,it,G):i,dt===i&&(dt=oe(vt)?vt:zi(f[L+1])?[]:{})}Kr(G,it,dt),G=G[it]}return o}var gu=Ys?function(o,f){return Ys.set(o,f),o}:Ne,rp=Vs?function(o,f){return Vs(o,"toString",{configurable:!0,enumerable:!1,value:_l(f),writable:!0})}:Ne;function sp(o){return ha(yr(o))}function oi(o,f,m){var R=-1,L=o.length;f<0&&(f=-f>L?0:L+f),m=m>L?L:m,m<0&&(m+=L),L=f>m?0:m-f>>>0,f>>>=0;for(var F=ot(L);++R<L;)F[R]=o[R+f];return F}function ap(o,f){var m;return ln(o,function(R,L,F){return m=f(R,L,F),!m}),!!m}function ea(o,f,m){var R=0,L=o==null?R:o.length;if(typeof f=="number"&&f===f&&L<=tt){for(;R<L;){var F=R+L>>>1,j=o[F];j!==null&&!$e(j)&&(m?j<=f:j<f)?R=F+1:L=F}return L}return Go(o,f,Ne,m)}function Go(o,f,m,R){var L=0,F=o==null?0:o.length;if(F===0)return 0;f=m(f);for(var j=f!==f,G=f===null,it=$e(f),dt=f===i;L<F;){var vt=Ks((L+F)/2),gt=m(o[vt]),pt=gt!==i,_t=gt===null,Rt=gt===gt,Mt=$e(gt);if(j)var Ct=R||Rt;else dt?Ct=Rt&&(R||pt):G?Ct=Rt&&pt&&(R||!_t):it?Ct=Rt&&pt&&!_t&&(R||!Mt):_t||Mt?Ct=!1:Ct=R?gt<=f:gt<f;Ct?L=vt+1:F=vt}return Ce(F,U)}function yu(o,f){for(var m=-1,R=o.length,L=0,F=[];++m<R;){var j=o[m],G=f?f(j):j;if(!m||!yi(G,it)){var it=G;F[L++]=j===0?0:j}}return F}function mu(o){return typeof o=="number"?o:$e(o)?V:+o}function Ve(o){if(typeof o=="string")return o;if(Pt(o))return re(o,Ve)+"";if($e(o))return Xh?Xh.call(o):"";var f=o+"";return f=="0"&&1/o==-st?"-0":f}function cn(o,f,m){var R=-1,L=Ms,F=o.length,j=!0,G=[],it=G;if(m)j=!1,L=Ao;else if(F>=r){var dt=f?null:mp(o);if(dt)return Os(dt);j=!1,L=Ur,it=new In}else it=f?[]:G;t:for(;++R<F;){var vt=o[R],gt=f?f(vt):vt;if(vt=m||vt!==0?vt:0,j&&gt===gt){for(var pt=it.length;pt--;)if(it[pt]===gt)continue t;f&&it.push(gt),G.push(vt)}else L(it,gt,m)||(it!==G&&it.push(gt),G.push(vt))}return G}function Zo(o,f){return f=hn(f,o),o=Vu(o,f),o==null||delete o[Ei(li(f))]}function pu(o,f,m,R){return Zr(o,f,m(Dn(o,f)),R)}function ia(o,f,m,R){for(var L=o.length,F=R?L:-1;(R?F--:++F<L)&&f(o[F],F,o););return m?oi(o,R?0:F,R?F+1:L):oi(o,R?F+1:0,R?L:F)}function wu(o,f){var m=o;return m instanceof Ft&&(m=m.value()),Ro(f,function(R,L){return L.func.apply(L.thisArg,sn([R],L.args))},m)}function Jo(o,f,m){var R=o.length;if(R<2)return R?cn(o[0]):[];for(var L=-1,F=ot(R);++L<R;)for(var j=o[L],G=-1;++G<R;)G!=L&&(F[L]=Yr(F[L]||j,o[G],f,m));return cn(ke(F,1),f,m)}function bu(o,f,m){for(var R=-1,L=o.length,F=f.length,j={};++R<L;){var G=R<F?f[R]:i;m(j,o[R],G)}return j}function Qo(o){return he(o)?o:[]}function tl(o){return typeof o=="function"?o:Ne}function hn(o,f){return Pt(o)?o:cl(o,f)?[o]:Xu(Yt(o))}var op=Bt;function un(o,f,m){var R=o.length;return m=m===i?R:m,!f&&m>=R?o:oi(o,f,m)}var xu=Ym||function(o){return _e.clearTimeout(o)};function _u(o,f){if(f)return o.slice();var m=o.length,R=qh?qh(m):new o.constructor(m);return o.copy(R),R}function el(o){var f=new o.constructor(o.byteLength);return new Ws(f).set(new Ws(o)),f}function lp(o,f){var m=f?el(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.byteLength)}function cp(o){var f=new o.constructor(o.source,sh.exec(o));return f.lastIndex=o.lastIndex,f}function hp(o){return $r?Zt($r.call(o)):{}}function ku(o,f){var m=f?el(o.buffer):o.buffer;return new o.constructor(m,o.byteOffset,o.length)}function Eu(o,f){if(o!==f){var m=o!==i,R=o===null,L=o===o,F=$e(o),j=f!==i,G=f===null,it=f===f,dt=$e(f);if(!G&&!dt&&!F&&o>f||F&&j&&it&&!G&&!dt||R&&j&&it||!m&&it||!L)return 1;if(!R&&!F&&!dt&&o<f||dt&&m&&L&&!R&&!F||G&&m&&L||!j&&L||!it)return-1}return 0}function up(o,f,m){for(var R=-1,L=o.criteria,F=f.criteria,j=L.length,G=m.length;++R<j;){var it=Eu(L[R],F[R]);if(it){if(R>=G)return it;var dt=m[R];return it*(dt=="desc"?-1:1)}}return o.index-f.index}function Au(o,f,m,R){for(var L=-1,F=o.length,j=m.length,G=-1,it=f.length,dt=ye(F-j,0),vt=ot(it+dt),gt=!R;++G<it;)vt[G]=f[G];for(;++L<j;)(gt||L<F)&&(vt[m[L]]=o[L]);for(;dt--;)vt[G++]=o[L++];return vt}function Ru(o,f,m,R){for(var L=-1,F=o.length,j=-1,G=m.length,it=-1,dt=f.length,vt=ye(F-G,0),gt=ot(vt+dt),pt=!R;++L<vt;)gt[L]=o[L];for(var _t=L;++it<dt;)gt[_t+it]=f[it];for(;++j<G;)(pt||L<F)&&(gt[_t+m[j]]=o[L++]);return gt}function Me(o,f){var m=-1,R=o.length;for(f||(f=ot(R));++m<R;)f[m]=o[m];return f}function ki(o,f,m,R){var L=!m;m||(m={});for(var F=-1,j=f.length;++F<j;){var G=f[F],it=R?R(m[G],o[G],G,m,o):i;it===i&&(it=o[G]),L?Oi(m,G,it):Kr(m,G,it)}return m}function fp(o,f){return ki(o,ll(o),f)}function dp(o,f){return ki(o,zu(o),f)}function na(o,f){return function(m,R){var L=Pt(m)?pm:B0,F=f?f():{};return L(m,o,Et(R,2),F)}}function fr(o){return Bt(function(f,m){var R=-1,L=m.length,F=L>1?m[L-1]:i,j=L>2?m[2]:i;for(F=o.length>3&&typeof F=="function"?(L--,F):i,j&&Pe(m[0],m[1],j)&&(F=L<3?i:F,L=1),f=Zt(f);++R<L;){var G=m[R];G&&o(f,G,R,F)}return f})}function Cu(o,f){return function(m,R){if(m==null)return m;if(!Be(m))return o(m,R);for(var L=m.length,F=f?L:-1,j=Zt(m);(f?F--:++F<L)&&R(j[F],F,j)!==!1;);return m}}function Tu(o){return function(f,m,R){for(var L=-1,F=Zt(f),j=R(f),G=j.length;G--;){var it=j[o?G:++L];if(m(F[it],it,F)===!1)break}return f}}function vp(o,f,m){var R=f&p,L=Jr(o);function F(){var j=this&&this!==_e&&this instanceof F?L:o;return j.apply(R?m:this,arguments)}return F}function Su(o){return function(f){f=Yt(f);var m=sr(f)?vi(f):i,R=m?m[0]:f.charAt(0),L=m?un(m,1).join(""):f.slice(1);return R[o]()+L}}function dr(o){return function(f){return Ro(Tf(Cf(f).replace(rm,"")),o,"")}}function Jr(o){return function(){var f=arguments;switch(f.length){case 0:return new o;case 1:return new o(f[0]);case 2:return new o(f[0],f[1]);case 3:return new o(f[0],f[1],f[2]);case 4:return new o(f[0],f[1],f[2],f[3]);case 5:return new o(f[0],f[1],f[2],f[3],f[4]);case 6:return new o(f[0],f[1],f[2],f[3],f[4],f[5]);case 7:return new o(f[0],f[1],f[2],f[3],f[4],f[5],f[6])}var m=ur(o.prototype),R=o.apply(m,f);return oe(R)?R:m}}function gp(o,f,m){var R=Jr(o);function L(){for(var F=arguments.length,j=ot(F),G=F,it=vr(L);G--;)j[G]=arguments[G];var dt=F<3&&j[0]!==it&&j[F-1]!==it?[]:an(j,it);if(F-=dt.length,F<m)return Mu(o,f,ra,L.placeholder,i,j,dt,i,i,m-F);var vt=this&&this!==_e&&this instanceof L?R:o;return qe(vt,this,j)}return L}function Pu(o){return function(f,m,R){var L=Zt(f);if(!Be(f)){var F=Et(m,3);f=pe(f),m=function(G){return F(L[G],G,L)}}var j=o(f,m,R);return j>-1?L[F?f[j]:j]:i}}function Iu(o){return Fi(function(f){var m=f.length,R=m,L=si.prototype.thru;for(o&&f.reverse();R--;){var F=f[R];if(typeof F!="function")throw new ri(a);if(L&&!j&&la(F)=="wrapper")var j=new si([],!0)}for(R=j?R:m;++R<m;){F=f[R];var G=la(F),it=G=="wrapper"?al(F):i;it&&hl(it[0])&&it[1]==(B|x|I|D)&&!it[4].length&&it[9]==1?j=j[la(it[0])].apply(j,it[3]):j=F.length==1&&hl(F)?j[G]():j.thru(F)}return function(){var dt=arguments,vt=dt[0];if(j&&dt.length==1&&Pt(vt))return j.plant(vt).value();for(var gt=0,pt=m?f[gt].apply(this,dt):vt;++gt<m;)pt=f[gt].call(this,pt);return pt}})}function ra(o,f,m,R,L,F,j,G,it,dt){var vt=f&B,gt=f&p,pt=f&_,_t=f&(x|E),Rt=f&q,Mt=pt?i:Jr(o);function Ct(){for(var Nt=arguments.length,Ht=ot(Nt),Ke=Nt;Ke--;)Ht[Ke]=arguments[Ke];if(_t)var Ie=vr(Ct),Ye=Cm(Ht,Ie);if(R&&(Ht=Au(Ht,R,L,_t)),F&&(Ht=Ru(Ht,F,j,_t)),Nt-=Ye,_t&&Nt<dt){var ue=an(Ht,Ie);return Mu(o,f,ra,Ct.placeholder,m,Ht,ue,G,it,dt-Nt)}var mi=gt?m:this,Wi=pt?mi[o]:o;return Nt=Ht.length,G?Ht=Bp(Ht,G):Rt&&Nt>1&&Ht.reverse(),vt&&it<Nt&&(Ht.length=it),this&&this!==_e&&this instanceof Ct&&(Wi=Mt||Jr(Wi)),Wi.apply(mi,Ht)}return Ct}function Lu(o,f){return function(m,R){return q0(m,o,f(R),{})}}function sa(o,f){return function(m,R){var L;if(m===i&&R===i)return f;if(m!==i&&(L=m),R!==i){if(L===i)return R;typeof m=="string"||typeof R=="string"?(m=Ve(m),R=Ve(R)):(m=mu(m),R=mu(R)),L=o(m,R)}return L}}function il(o){return Fi(function(f){return f=re(f,je(Et())),Bt(function(m){var R=this;return o(f,function(L){return qe(L,R,m)})})})}function aa(o,f){f=f===i?" ":Ve(f);var m=f.length;if(m<2)return m?Xo(f,o):f;var R=Xo(f,$s(o/ar(f)));return sr(f)?un(vi(R),0,o).join(""):R.slice(0,o)}function yp(o,f,m,R){var L=f&p,F=Jr(o);function j(){for(var G=-1,it=arguments.length,dt=-1,vt=R.length,gt=ot(vt+it),pt=this&&this!==_e&&this instanceof j?F:o;++dt<vt;)gt[dt]=R[dt];for(;it--;)gt[dt++]=arguments[++G];return qe(pt,L?m:this,gt)}return j}function Du(o){return function(f,m,R){return R&&typeof R!="number"&&Pe(f,m,R)&&(m=R=i),f=Ui(f),m===i?(m=f,f=0):m=Ui(m),R=R===i?f<m?1:-1:Ui(R),ep(f,m,R,o)}}function oa(o){return function(f,m){return typeof f=="string"&&typeof m=="string"||(f=ci(f),m=ci(m)),o(f,m)}}function Mu(o,f,m,R,L,F,j,G,it,dt){var vt=f&x,gt=vt?j:i,pt=vt?i:j,_t=vt?F:i,Rt=vt?i:F;f|=vt?I:M,f&=~(vt?M:I),f&A||(f&=~(p|_));var Mt=[o,f,L,_t,gt,Rt,pt,G,it,dt],Ct=m.apply(i,Mt);return hl(o)&&$u(Ct,Mt),Ct.placeholder=R,Ku(Ct,o,f)}function nl(o){var f=ge[o];return function(m,R){if(m=ci(m),R=R==null?0:Ce(Dt(R),292),R&&Kh(m)){var L=(Yt(m)+"e").split("e"),F=f(L[0]+"e"+(+L[1]+R));return L=(Yt(F)+"e").split("e"),+(L[0]+"e"+(+L[1]-R))}return f(m)}}var mp=cr&&1/Os(new cr([,-0]))[1]==st?function(o){return new cr(o)}:Al;function Bu(o){return function(f){var m=Te(f);return m==J?Do(f):m==ne?Mm(f):Rm(f,o(f))}}function Ni(o,f,m,R,L,F,j,G){var it=f&_;if(!it&&typeof o!="function")throw new ri(a);var dt=R?R.length:0;if(dt||(f&=~(I|M),R=L=i),j=j===i?j:ye(Dt(j),0),G=G===i?G:Dt(G),dt-=L?L.length:0,f&M){var vt=R,gt=L;R=L=i}var pt=it?i:al(o),_t=[o,f,m,R,L,vt,gt,F,j,G];if(pt&&Lp(_t,pt),o=_t[0],f=_t[1],m=_t[2],R=_t[3],L=_t[4],G=_t[9]=_t[9]===i?it?0:o.length:ye(_t[9]-dt,0),!G&&f&(x|E)&&(f&=~(x|E)),!f||f==p)var Rt=vp(o,f,m);else f==x||f==E?Rt=gp(o,f,G):(f==I||f==(p|I))&&!L.length?Rt=yp(o,f,m,R):Rt=ra.apply(i,_t);var Mt=pt?gu:$u;return Ku(Mt(Rt,_t),o,f)}function Ou(o,f,m,R){return o===i||yi(o,lr[m])&&!Xt.call(R,m)?f:o}function Nu(o,f,m,R,L,F){return oe(o)&&oe(f)&&(F.set(f,o),ta(o,f,i,Nu,F),F.delete(f)),o}function pp(o){return es(o)?i:o}function Fu(o,f,m,R,L,F){var j=m&y,G=o.length,it=f.length;if(G!=it&&!(j&&it>G))return!1;var dt=F.get(o),vt=F.get(f);if(dt&&vt)return dt==f&&vt==o;var gt=-1,pt=!0,_t=m&w?new In:i;for(F.set(o,f),F.set(f,o);++gt<G;){var Rt=o[gt],Mt=f[gt];if(R)var Ct=j?R(Mt,Rt,gt,f,o,F):R(Rt,Mt,gt,o,f,F);if(Ct!==i){if(Ct)continue;pt=!1;break}if(_t){if(!Co(f,function(Nt,Ht){if(!Ur(_t,Ht)&&(Rt===Nt||L(Rt,Nt,m,R,F)))return _t.push(Ht)})){pt=!1;break}}else if(!(Rt===Mt||L(Rt,Mt,m,R,F))){pt=!1;break}}return F.delete(o),F.delete(f),pt}function wp(o,f,m,R,L,F,j){switch(m){case ir:if(o.byteLength!=f.byteLength||o.byteOffset!=f.byteOffset)return!1;o=o.buffer,f=f.buffer;case Hr:return!(o.byteLength!=f.byteLength||!F(new Ws(o),new Ws(f)));case ut:case b:case at:return yi(+o,+f);case P:return o.name==f.name&&o.message==f.message;case be:case xe:return o==f+"";case J:var G=Do;case ne:var it=R&y;if(G||(G=Os),o.size!=f.size&&!it)return!1;var dt=j.get(o);if(dt)return dt==f;R|=w,j.set(o,f);var vt=Fu(G(o),G(f),R,L,F,j);return j.delete(o),vt;case Vt:if($r)return $r.call(o)==$r.call(f)}return!1}function bp(o,f,m,R,L,F){var j=m&y,G=rl(o),it=G.length,dt=rl(f),vt=dt.length;if(it!=vt&&!j)return!1;for(var gt=it;gt--;){var pt=G[gt];if(!(j?pt in f:Xt.call(f,pt)))return!1}var _t=F.get(o),Rt=F.get(f);if(_t&&Rt)return _t==f&&Rt==o;var Mt=!0;F.set(o,f),F.set(f,o);for(var Ct=j;++gt<it;){pt=G[gt];var Nt=o[pt],Ht=f[pt];if(R)var Ke=j?R(Ht,Nt,pt,f,o,F):R(Nt,Ht,pt,o,f,F);if(!(Ke===i?Nt===Ht||L(Nt,Ht,m,R,F):Ke)){Mt=!1;break}Ct||(Ct=pt=="constructor")}if(Mt&&!Ct){var Ie=o.constructor,Ye=f.constructor;Ie!=Ye&&"constructor"in o&&"constructor"in f&&!(typeof Ie=="function"&&Ie instanceof Ie&&typeof Ye=="function"&&Ye instanceof Ye)&&(Mt=!1)}return F.delete(o),F.delete(f),Mt}function Fi(o){return fl(ju(o,i,Qu),o+"")}function rl(o){return ru(o,pe,ll)}function sl(o){return ru(o,Oe,zu)}var al=Ys?function(o){return Ys.get(o)}:Al;function la(o){for(var f=o.name+"",m=hr[f],R=Xt.call(hr,f)?m.length:0;R--;){var L=m[R],F=L.func;if(F==null||F==o)return L.name}return f}function vr(o){var f=Xt.call(N,"placeholder")?N:o;return f.placeholder}function Et(){var o=N.iteratee||kl;return o=o===kl?ou:o,arguments.length?o(arguments[0],arguments[1]):o}function ca(o,f){var m=o.__data__;return Tp(f)?m[typeof f=="string"?"string":"hash"]:m.map}function ol(o){for(var f=pe(o),m=f.length;m--;){var R=f[m],L=o[R];f[m]=[R,L,Wu(L)]}return f}function Mn(o,f){var m=Im(o,f);return au(m)?m:i}function xp(o){var f=Xt.call(o,Sn),m=o[Sn];try{o[Sn]=i;var R=!0}catch{}var L=Hs.call(o);return R&&(f?o[Sn]=m:delete o[Sn]),L}var ll=Bo?function(o){return o==null?[]:(o=Zt(o),rn(Bo(o),function(f){return Vh.call(o,f)}))}:Rl,zu=Bo?function(o){for(var f=[];o;)sn(f,ll(o)),o=qs(o);return f}:Rl,Te=Se;(Oo&&Te(new Oo(new ArrayBuffer(1)))!=ir||qr&&Te(new qr)!=J||No&&Te(No.resolve())!=kt||cr&&Te(new cr)!=ne||jr&&Te(new jr)!=xi)&&(Te=function(o){var f=Se(o),m=f==yt?o.constructor:i,R=m?Bn(m):"";if(R)switch(R){case n0:return ir;case r0:return J;case s0:return kt;case a0:return ne;case o0:return xi}return f});function _p(o,f,m){for(var R=-1,L=m.length;++R<L;){var F=m[R],j=F.size;switch(F.type){case"drop":o+=j;break;case"dropRight":f-=j;break;case"take":f=Ce(f,o+j);break;case"takeRight":o=ye(o,f-j);break}}return{start:o,end:f}}function kp(o){var f=o.match(Sy);return f?f[1].split(Py):[]}function Hu(o,f,m){f=hn(f,o);for(var R=-1,L=f.length,F=!1;++R<L;){var j=Ei(f[R]);if(!(F=o!=null&&m(o,j)))break;o=o[j]}return F||++R!=L?F:(L=o==null?0:o.length,!!L&&ya(L)&&zi(j,L)&&(Pt(o)||On(o)))}function Ep(o){var f=o.length,m=new o.constructor(f);return f&&typeof o[0]=="string"&&Xt.call(o,"index")&&(m.index=o.index,m.input=o.input),m}function Uu(o){return typeof o.constructor=="function"&&!Qr(o)?ur(qs(o)):{}}function Ap(o,f,m){var R=o.constructor;switch(f){case Hr:return el(o);case ut:case b:return new R(+o);case ir:return lp(o,m);case ao:case oo:case lo:case co:case ho:case uo:case fo:case vo:case go:return ku(o,m);case J:return new R;case at:case xe:return new R(o);case be:return cp(o);case ne:return new R;case Vt:return hp(o)}}function Rp(o,f){var m=f.length;if(!m)return o;var R=m-1;return f[R]=(m>1?"& ":"")+f[R],f=f.join(m>2?", ":" "),o.replace(Ty,`{
  85. /* [wrapped with `+f+`] */
  86. `)}function Cp(o){return Pt(o)||On(o)||!!($h&&o&&o[$h])}function zi(o,f){var m=typeof o;return f=f==null?$:f,!!f&&(m=="number"||m!="symbol"&&zy.test(o))&&o>-1&&o%1==0&&o<f}function Pe(o,f,m){if(!oe(m))return!1;var R=typeof f;return(R=="number"?Be(m)&&zi(f,m.length):R=="string"&&f in m)?yi(m[f],o):!1}function cl(o,f){if(Pt(o))return!1;var m=typeof o;return m=="number"||m=="symbol"||m=="boolean"||o==null||$e(o)?!0:Ey.test(o)||!ky.test(o)||f!=null&&o in Zt(f)}function Tp(o){var f=typeof o;return f=="string"||f=="number"||f=="symbol"||f=="boolean"?o!=="__proto__":o===null}function hl(o){var f=la(o),m=N[f];if(typeof m!="function"||!(f in Ft.prototype))return!1;if(o===m)return!0;var R=al(m);return!!R&&o===R[0]}function Sp(o){return!!Wh&&Wh in o}var Pp=Fs?Hi:Cl;function Qr(o){var f=o&&o.constructor,m=typeof f=="function"&&f.prototype||lr;return o===m}function Wu(o){return o===o&&!oe(o)}function qu(o,f){return function(m){return m==null?!1:m[o]===f&&(f!==i||o in Zt(m))}}function Ip(o){var f=va(o,function(R){return m.size===u&&m.clear(),R}),m=f.cache;return f}function Lp(o,f){var m=o[1],R=f[1],L=m|R,F=L<(p|_|B),j=R==B&&m==x||R==B&&m==D&&o[7].length<=f[8]||R==(B|D)&&f[7].length<=f[8]&&m==x;if(!(F||j))return o;R&p&&(o[2]=f[2],L|=m&p?0:A);var G=f[3];if(G){var it=o[3];o[3]=it?Au(it,G,f[4]):G,o[4]=it?an(o[3],h):f[4]}return G=f[5],G&&(it=o[5],o[5]=it?Ru(it,G,f[6]):G,o[6]=it?an(o[5],h):f[6]),G=f[7],G&&(o[7]=G),R&B&&(o[8]=o[8]==null?f[8]:Ce(o[8],f[8])),o[9]==null&&(o[9]=f[9]),o[0]=f[0],o[1]=L,o}function Dp(o){var f=[];if(o!=null)for(var m in Zt(o))f.push(m);return f}function Mp(o){return Hs.call(o)}function ju(o,f,m){return f=ye(f===i?o.length-1:f,0),function(){for(var R=arguments,L=-1,F=ye(R.length-f,0),j=ot(F);++L<F;)j[L]=R[f+L];L=-1;for(var G=ot(f+1);++L<f;)G[L]=R[L];return G[f]=m(j),qe(o,this,G)}}function Vu(o,f){return f.length<2?o:Dn(o,oi(f,0,-1))}function Bp(o,f){for(var m=o.length,R=Ce(f.length,m),L=Me(o);R--;){var F=f[R];o[R]=zi(F,m)?L[F]:i}return o}function ul(o,f){if(!(f==="constructor"&&typeof o[f]=="function")&&f!="__proto__")return o[f]}var $u=Yu(gu),ts=Gm||function(o,f){return _e.setTimeout(o,f)},fl=Yu(rp);function Ku(o,f,m){var R=f+"";return fl(o,Rp(R,Op(kp(R),m)))}function Yu(o){var f=0,m=0;return function(){var R=t0(),L=S-(R-m);if(m=R,L>0){if(++f>=T)return arguments[0]}else f=0;return o.apply(i,arguments)}}function ha(o,f){var m=-1,R=o.length,L=R-1;for(f=f===i?R:f;++m<f;){var F=Yo(m,L),j=o[F];o[F]=o[m],o[m]=j}return o.length=f,o}var Xu=Ip(function(o){var f=[];return o.charCodeAt(0)===46&&f.push(""),o.replace(Ay,function(m,R,L,F){f.push(L?F.replace(Dy,"$1"):R||m)}),f});function Ei(o){if(typeof o=="string"||$e(o))return o;var f=o+"";return f=="0"&&1/o==-st?"-0":f}function Bn(o){if(o!=null){try{return zs.call(o)}catch{}try{return o+""}catch{}}return""}function Op(o,f){return ni(rt,function(m){var R="_."+m[0];f&m[1]&&!Ms(o,R)&&o.push(R)}),o.sort()}function Gu(o){if(o instanceof Ft)return o.clone();var f=new si(o.__wrapped__,o.__chain__);return f.__actions__=Me(o.__actions__),f.__index__=o.__index__,f.__values__=o.__values__,f}function Np(o,f,m){(m?Pe(o,f,m):f===i)?f=1:f=ye(Dt(f),0);var R=o==null?0:o.length;if(!R||f<1)return[];for(var L=0,F=0,j=ot($s(R/f));L<R;)j[F++]=oi(o,L,L+=f);return j}function Fp(o){for(var f=-1,m=o==null?0:o.length,R=0,L=[];++f<m;){var F=o[f];F&&(L[R++]=F)}return L}function zp(){var o=arguments.length;if(!o)return[];for(var f=ot(o-1),m=arguments[0],R=o;R--;)f[R-1]=arguments[R];return sn(Pt(m)?Me(m):[m],ke(f,1))}var Hp=Bt(function(o,f){return he(o)?Yr(o,ke(f,1,he,!0)):[]}),Up=Bt(function(o,f){var m=li(f);return he(m)&&(m=i),he(o)?Yr(o,ke(f,1,he,!0),Et(m,2)):[]}),Wp=Bt(function(o,f){var m=li(f);return he(m)&&(m=i),he(o)?Yr(o,ke(f,1,he,!0),i,m):[]});function qp(o,f,m){var R=o==null?0:o.length;return R?(f=m||f===i?1:Dt(f),oi(o,f<0?0:f,R)):[]}function jp(o,f,m){var R=o==null?0:o.length;return R?(f=m||f===i?1:Dt(f),f=R-f,oi(o,0,f<0?0:f)):[]}function Vp(o,f){return o&&o.length?ia(o,Et(f,3),!0,!0):[]}function $p(o,f){return o&&o.length?ia(o,Et(f,3),!0):[]}function Kp(o,f,m,R){var L=o==null?0:o.length;return L?(m&&typeof m!="number"&&Pe(o,f,m)&&(m=0,R=L),z0(o,f,m,R)):[]}function Zu(o,f,m){var R=o==null?0:o.length;if(!R)return-1;var L=m==null?0:Dt(m);return L<0&&(L=ye(R+L,0)),Bs(o,Et(f,3),L)}function Ju(o,f,m){var R=o==null?0:o.length;if(!R)return-1;var L=R-1;return m!==i&&(L=Dt(m),L=m<0?ye(R+L,0):Ce(L,R-1)),Bs(o,Et(f,3),L,!0)}function Qu(o){var f=o==null?0:o.length;return f?ke(o,1):[]}function Yp(o){var f=o==null?0:o.length;return f?ke(o,st):[]}function Xp(o,f){var m=o==null?0:o.length;return m?(f=f===i?1:Dt(f),ke(o,f)):[]}function Gp(o){for(var f=-1,m=o==null?0:o.length,R={};++f<m;){var L=o[f];R[L[0]]=L[1]}return R}function tf(o){return o&&o.length?o[0]:i}function Zp(o,f,m){var R=o==null?0:o.length;if(!R)return-1;var L=m==null?0:Dt(m);return L<0&&(L=ye(R+L,0)),rr(o,f,L)}function Jp(o){var f=o==null?0:o.length;return f?oi(o,0,-1):[]}var Qp=Bt(function(o){var f=re(o,Qo);return f.length&&f[0]===o[0]?qo(f):[]}),tw=Bt(function(o){var f=li(o),m=re(o,Qo);return f===li(m)?f=i:m.pop(),m.length&&m[0]===o[0]?qo(m,Et(f,2)):[]}),ew=Bt(function(o){var f=li(o),m=re(o,Qo);return f=typeof f=="function"?f:i,f&&m.pop(),m.length&&m[0]===o[0]?qo(m,i,f):[]});function iw(o,f){return o==null?"":Jm.call(o,f)}function li(o){var f=o==null?0:o.length;return f?o[f-1]:i}function nw(o,f,m){var R=o==null?0:o.length;if(!R)return-1;var L=R;return m!==i&&(L=Dt(m),L=L<0?ye(R+L,0):Ce(L,R-1)),f===f?Om(o,f,L):Bs(o,Mh,L,!0)}function rw(o,f){return o&&o.length?uu(o,Dt(f)):i}var sw=Bt(ef);function ef(o,f){return o&&o.length&&f&&f.length?Ko(o,f):o}function aw(o,f,m){return o&&o.length&&f&&f.length?Ko(o,f,Et(m,2)):o}function ow(o,f,m){return o&&o.length&&f&&f.length?Ko(o,f,i,m):o}var lw=Fi(function(o,f){var m=o==null?0:o.length,R=zo(o,f);return vu(o,re(f,function(L){return zi(L,m)?+L:L}).sort(Eu)),R});function cw(o,f){var m=[];if(!(o&&o.length))return m;var R=-1,L=[],F=o.length;for(f=Et(f,3);++R<F;){var j=o[R];f(j,R,o)&&(m.push(j),L.push(R))}return vu(o,L),m}function dl(o){return o==null?o:i0.call(o)}function hw(o,f,m){var R=o==null?0:o.length;return R?(m&&typeof m!="number"&&Pe(o,f,m)?(f=0,m=R):(f=f==null?0:Dt(f),m=m===i?R:Dt(m)),oi(o,f,m)):[]}function uw(o,f){return ea(o,f)}function fw(o,f,m){return Go(o,f,Et(m,2))}function dw(o,f){var m=o==null?0:o.length;if(m){var R=ea(o,f);if(R<m&&yi(o[R],f))return R}return-1}function vw(o,f){return ea(o,f,!0)}function gw(o,f,m){return Go(o,f,Et(m,2),!0)}function yw(o,f){var m=o==null?0:o.length;if(m){var R=ea(o,f,!0)-1;if(yi(o[R],f))return R}return-1}function mw(o){return o&&o.length?yu(o):[]}function pw(o,f){return o&&o.length?yu(o,Et(f,2)):[]}function ww(o){var f=o==null?0:o.length;return f?oi(o,1,f):[]}function bw(o,f,m){return o&&o.length?(f=m||f===i?1:Dt(f),oi(o,0,f<0?0:f)):[]}function xw(o,f,m){var R=o==null?0:o.length;return R?(f=m||f===i?1:Dt(f),f=R-f,oi(o,f<0?0:f,R)):[]}function _w(o,f){return o&&o.length?ia(o,Et(f,3),!1,!0):[]}function kw(o,f){return o&&o.length?ia(o,Et(f,3)):[]}var Ew=Bt(function(o){return cn(ke(o,1,he,!0))}),Aw=Bt(function(o){var f=li(o);return he(f)&&(f=i),cn(ke(o,1,he,!0),Et(f,2))}),Rw=Bt(function(o){var f=li(o);return f=typeof f=="function"?f:i,cn(ke(o,1,he,!0),i,f)});function Cw(o){return o&&o.length?cn(o):[]}function Tw(o,f){return o&&o.length?cn(o,Et(f,2)):[]}function Sw(o,f){return f=typeof f=="function"?f:i,o&&o.length?cn(o,i,f):[]}function vl(o){if(!(o&&o.length))return[];var f=0;return o=rn(o,function(m){if(he(m))return f=ye(m.length,f),!0}),Io(f,function(m){return re(o,To(m))})}function nf(o,f){if(!(o&&o.length))return[];var m=vl(o);return f==null?m:re(m,function(R){return qe(f,i,R)})}var Pw=Bt(function(o,f){return he(o)?Yr(o,f):[]}),Iw=Bt(function(o){return Jo(rn(o,he))}),Lw=Bt(function(o){var f=li(o);return he(f)&&(f=i),Jo(rn(o,he),Et(f,2))}),Dw=Bt(function(o){var f=li(o);return f=typeof f=="function"?f:i,Jo(rn(o,he),i,f)}),Mw=Bt(vl);function Bw(o,f){return bu(o||[],f||[],Kr)}function Ow(o,f){return bu(o||[],f||[],Zr)}var Nw=Bt(function(o){var f=o.length,m=f>1?o[f-1]:i;return m=typeof m=="function"?(o.pop(),m):i,nf(o,m)});function rf(o){var f=N(o);return f.__chain__=!0,f}function Fw(o,f){return f(o),o}function ua(o,f){return f(o)}var zw=Fi(function(o){var f=o.length,m=f?o[0]:0,R=this.__wrapped__,L=function(F){return zo(F,o)};return f>1||this.__actions__.length||!(R instanceof Ft)||!zi(m)?this.thru(L):(R=R.slice(m,+m+(f?1:0)),R.__actions__.push({func:ua,args:[L],thisArg:i}),new si(R,this.__chain__).thru(function(F){return f&&!F.length&&F.push(i),F}))});function Hw(){return rf(this)}function Uw(){return new si(this.value(),this.__chain__)}function Ww(){this.__values__===i&&(this.__values__=pf(this.value()));var o=this.__index__>=this.__values__.length,f=o?i:this.__values__[this.__index__++];return{done:o,value:f}}function qw(){return this}function jw(o){for(var f,m=this;m instanceof Gs;){var R=Gu(m);R.__index__=0,R.__values__=i,f?L.__wrapped__=R:f=R;var L=R;m=m.__wrapped__}return L.__wrapped__=o,f}function Vw(){var o=this.__wrapped__;if(o instanceof Ft){var f=o;return this.__actions__.length&&(f=new Ft(this)),f=f.reverse(),f.__actions__.push({func:ua,args:[dl],thisArg:i}),new si(f,this.__chain__)}return this.thru(dl)}function $w(){return wu(this.__wrapped__,this.__actions__)}var Kw=na(function(o,f,m){Xt.call(o,m)?++o[m]:Oi(o,m,1)});function Yw(o,f,m){var R=Pt(o)?Lh:F0;return m&&Pe(o,f,m)&&(f=i),R(o,Et(f,3))}function Xw(o,f){var m=Pt(o)?rn:iu;return m(o,Et(f,3))}var Gw=Pu(Zu),Zw=Pu(Ju);function Jw(o,f){return ke(fa(o,f),1)}function Qw(o,f){return ke(fa(o,f),st)}function tb(o,f,m){return m=m===i?1:Dt(m),ke(fa(o,f),m)}function sf(o,f){var m=Pt(o)?ni:ln;return m(o,Et(f,3))}function af(o,f){var m=Pt(o)?wm:eu;return m(o,Et(f,3))}var eb=na(function(o,f,m){Xt.call(o,m)?o[m].push(f):Oi(o,m,[f])});function ib(o,f,m,R){o=Be(o)?o:yr(o),m=m&&!R?Dt(m):0;var L=o.length;return m<0&&(m=ye(L+m,0)),ma(o)?m<=L&&o.indexOf(f,m)>-1:!!L&&rr(o,f,m)>-1}var nb=Bt(function(o,f,m){var R=-1,L=typeof f=="function",F=Be(o)?ot(o.length):[];return ln(o,function(j){F[++R]=L?qe(f,j,m):Xr(j,f,m)}),F}),rb=na(function(o,f,m){Oi(o,m,f)});function fa(o,f){var m=Pt(o)?re:lu;return m(o,Et(f,3))}function sb(o,f,m,R){return o==null?[]:(Pt(f)||(f=f==null?[]:[f]),m=R?i:m,Pt(m)||(m=m==null?[]:[m]),fu(o,f,m))}var ab=na(function(o,f,m){o[m?0:1].push(f)},function(){return[[],[]]});function ob(o,f,m){var R=Pt(o)?Ro:Oh,L=arguments.length<3;return R(o,Et(f,4),m,L,ln)}function lb(o,f,m){var R=Pt(o)?bm:Oh,L=arguments.length<3;return R(o,Et(f,4),m,L,eu)}function cb(o,f){var m=Pt(o)?rn:iu;return m(o,ga(Et(f,3)))}function hb(o){var f=Pt(o)?Zh:ip;return f(o)}function ub(o,f,m){(m?Pe(o,f,m):f===i)?f=1:f=Dt(f);var R=Pt(o)?D0:np;return R(o,f)}function fb(o){var f=Pt(o)?M0:sp;return f(o)}function db(o){if(o==null)return 0;if(Be(o))return ma(o)?ar(o):o.length;var f=Te(o);return f==J||f==ne?o.size:Vo(o).length}function vb(o,f,m){var R=Pt(o)?Co:ap;return m&&Pe(o,f,m)&&(f=i),R(o,Et(f,3))}var gb=Bt(function(o,f){if(o==null)return[];var m=f.length;return m>1&&Pe(o,f[0],f[1])?f=[]:m>2&&Pe(f[0],f[1],f[2])&&(f=[f[0]]),fu(o,ke(f,1),[])}),da=Xm||function(){return _e.Date.now()};function yb(o,f){if(typeof f!="function")throw new ri(a);return o=Dt(o),function(){if(--o<1)return f.apply(this,arguments)}}function of(o,f,m){return f=m?i:f,f=o&&f==null?o.length:f,Ni(o,B,i,i,i,i,f)}function lf(o,f){var m;if(typeof f!="function")throw new ri(a);return o=Dt(o),function(){return--o>0&&(m=f.apply(this,arguments)),o<=1&&(f=i),m}}var gl=Bt(function(o,f,m){var R=p;if(m.length){var L=an(m,vr(gl));R|=I}return Ni(o,R,f,m,L)}),cf=Bt(function(o,f,m){var R=p|_;if(m.length){var L=an(m,vr(cf));R|=I}return Ni(f,R,o,m,L)});function hf(o,f,m){f=m?i:f;var R=Ni(o,x,i,i,i,i,i,f);return R.placeholder=hf.placeholder,R}function uf(o,f,m){f=m?i:f;var R=Ni(o,E,i,i,i,i,i,f);return R.placeholder=uf.placeholder,R}function ff(o,f,m){var R,L,F,j,G,it,dt=0,vt=!1,gt=!1,pt=!0;if(typeof o!="function")throw new ri(a);f=ci(f)||0,oe(m)&&(vt=!!m.leading,gt="maxWait"in m,F=gt?ye(ci(m.maxWait)||0,f):F,pt="trailing"in m?!!m.trailing:pt);function _t(ue){var mi=R,Wi=L;return R=L=i,dt=ue,j=o.apply(Wi,mi),j}function Rt(ue){return dt=ue,G=ts(Nt,f),vt?_t(ue):j}function Mt(ue){var mi=ue-it,Wi=ue-dt,If=f-mi;return gt?Ce(If,F-Wi):If}function Ct(ue){var mi=ue-it,Wi=ue-dt;return it===i||mi>=f||mi<0||gt&&Wi>=F}function Nt(){var ue=da();if(Ct(ue))return Ht(ue);G=ts(Nt,Mt(ue))}function Ht(ue){return G=i,pt&&R?_t(ue):(R=L=i,j)}function Ke(){G!==i&&xu(G),dt=0,R=it=L=G=i}function Ie(){return G===i?j:Ht(da())}function Ye(){var ue=da(),mi=Ct(ue);if(R=arguments,L=this,it=ue,mi){if(G===i)return Rt(it);if(gt)return xu(G),G=ts(Nt,f),_t(it)}return G===i&&(G=ts(Nt,f)),j}return Ye.cancel=Ke,Ye.flush=Ie,Ye}var mb=Bt(function(o,f){return tu(o,1,f)}),pb=Bt(function(o,f,m){return tu(o,ci(f)||0,m)});function wb(o){return Ni(o,q)}function va(o,f){if(typeof o!="function"||f!=null&&typeof f!="function")throw new ri(a);var m=function(){var R=arguments,L=f?f.apply(this,R):R[0],F=m.cache;if(F.has(L))return F.get(L);var j=o.apply(this,R);return m.cache=F.set(L,j)||F,j};return m.cache=new(va.Cache||Bi),m}va.Cache=Bi;function ga(o){if(typeof o!="function")throw new ri(a);return function(){var f=arguments;switch(f.length){case 0:return!o.call(this);case 1:return!o.call(this,f[0]);case 2:return!o.call(this,f[0],f[1]);case 3:return!o.call(this,f[0],f[1],f[2])}return!o.apply(this,f)}}function bb(o){return lf(2,o)}var xb=op(function(o,f){f=f.length==1&&Pt(f[0])?re(f[0],je(Et())):re(ke(f,1),je(Et()));var m=f.length;return Bt(function(R){for(var L=-1,F=Ce(R.length,m);++L<F;)R[L]=f[L].call(this,R[L]);return qe(o,this,R)})}),yl=Bt(function(o,f){var m=an(f,vr(yl));return Ni(o,I,i,f,m)}),df=Bt(function(o,f){var m=an(f,vr(df));return Ni(o,M,i,f,m)}),_b=Fi(function(o,f){return Ni(o,D,i,i,i,f)});function kb(o,f){if(typeof o!="function")throw new ri(a);return f=f===i?f:Dt(f),Bt(o,f)}function Eb(o,f){if(typeof o!="function")throw new ri(a);return f=f==null?0:ye(Dt(f),0),Bt(function(m){var R=m[f],L=un(m,0,f);return R&&sn(L,R),qe(o,this,L)})}function Ab(o,f,m){var R=!0,L=!0;if(typeof o!="function")throw new ri(a);return oe(m)&&(R="leading"in m?!!m.leading:R,L="trailing"in m?!!m.trailing:L),ff(o,f,{leading:R,maxWait:f,trailing:L})}function Rb(o){return of(o,1)}function Cb(o,f){return yl(tl(f),o)}function Tb(){if(!arguments.length)return[];var o=arguments[0];return Pt(o)?o:[o]}function Sb(o){return ai(o,v)}function Pb(o,f){return f=typeof f=="function"?f:i,ai(o,v,f)}function Ib(o){return ai(o,d|v)}function Lb(o,f){return f=typeof f=="function"?f:i,ai(o,d|v,f)}function Db(o,f){return f==null||Qh(o,f,pe(f))}function yi(o,f){return o===f||o!==o&&f!==f}var Mb=oa(Wo),Bb=oa(function(o,f){return o>=f}),On=su(function(){return arguments}())?su:function(o){return ce(o)&&Xt.call(o,"callee")&&!Vh.call(o,"callee")},Pt=ot.isArray,Ob=Rh?je(Rh):j0;function Be(o){return o!=null&&ya(o.length)&&!Hi(o)}function he(o){return ce(o)&&Be(o)}function Nb(o){return o===!0||o===!1||ce(o)&&Se(o)==ut}var fn=Zm||Cl,Fb=Ch?je(Ch):V0;function zb(o){return ce(o)&&o.nodeType===1&&!es(o)}function Hb(o){if(o==null)return!0;if(Be(o)&&(Pt(o)||typeof o=="string"||typeof o.splice=="function"||fn(o)||gr(o)||On(o)))return!o.length;var f=Te(o);if(f==J||f==ne)return!o.size;if(Qr(o))return!Vo(o).length;for(var m in o)if(Xt.call(o,m))return!1;return!0}function Ub(o,f){return Gr(o,f)}function Wb(o,f,m){m=typeof m=="function"?m:i;var R=m?m(o,f):i;return R===i?Gr(o,f,i,m):!!R}function ml(o){if(!ce(o))return!1;var f=Se(o);return f==P||f==k||typeof o.message=="string"&&typeof o.name=="string"&&!es(o)}function qb(o){return typeof o=="number"&&Kh(o)}function Hi(o){if(!oe(o))return!1;var f=Se(o);return f==H||f==X||f==lt||f==Tt}function vf(o){return typeof o=="number"&&o==Dt(o)}function ya(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=$}function oe(o){var f=typeof o;return o!=null&&(f=="object"||f=="function")}function ce(o){return o!=null&&typeof o=="object"}var gf=Th?je(Th):K0;function jb(o,f){return o===f||jo(o,f,ol(f))}function Vb(o,f,m){return m=typeof m=="function"?m:i,jo(o,f,ol(f),m)}function $b(o){return yf(o)&&o!=+o}function Kb(o){if(Pp(o))throw new St(s);return au(o)}function Yb(o){return o===null}function Xb(o){return o==null}function yf(o){return typeof o=="number"||ce(o)&&Se(o)==at}function es(o){if(!ce(o)||Se(o)!=yt)return!1;var f=qs(o);if(f===null)return!0;var m=Xt.call(f,"constructor")&&f.constructor;return typeof m=="function"&&m instanceof m&&zs.call(m)==Vm}var pl=Sh?je(Sh):Y0;function Gb(o){return vf(o)&&o>=-$&&o<=$}var mf=Ph?je(Ph):X0;function ma(o){return typeof o=="string"||!Pt(o)&&ce(o)&&Se(o)==xe}function $e(o){return typeof o=="symbol"||ce(o)&&Se(o)==Vt}var gr=Ih?je(Ih):G0;function Zb(o){return o===i}function Jb(o){return ce(o)&&Te(o)==xi}function Qb(o){return ce(o)&&Se(o)==gy}var t1=oa($o),e1=oa(function(o,f){return o<=f});function pf(o){if(!o)return[];if(Be(o))return ma(o)?vi(o):Me(o);if(Wr&&o[Wr])return Dm(o[Wr]());var f=Te(o),m=f==J?Do:f==ne?Os:yr;return m(o)}function Ui(o){if(!o)return o===0?o:0;if(o=ci(o),o===st||o===-st){var f=o<0?-1:1;return f*z}return o===o?o:0}function Dt(o){var f=Ui(o),m=f%1;return f===f?m?f-m:f:0}function wf(o){return o?Ln(Dt(o),0,Y):0}function ci(o){if(typeof o=="number")return o;if($e(o))return V;if(oe(o)){var f=typeof o.valueOf=="function"?o.valueOf():o;o=oe(f)?f+"":f}if(typeof o!="string")return o===0?o:+o;o=Nh(o);var m=Oy.test(o);return m||Fy.test(o)?ym(o.slice(2),m?2:8):By.test(o)?V:+o}function bf(o){return ki(o,Oe(o))}function i1(o){return o?Ln(Dt(o),-$,$):o===0?o:0}function Yt(o){return o==null?"":Ve(o)}var n1=fr(function(o,f){if(Qr(f)||Be(f)){ki(f,pe(f),o);return}for(var m in f)Xt.call(f,m)&&Kr(o,m,f[m])}),xf=fr(function(o,f){ki(f,Oe(f),o)}),pa=fr(function(o,f,m,R){ki(f,Oe(f),o,R)}),r1=fr(function(o,f,m,R){ki(f,pe(f),o,R)}),s1=Fi(zo);function a1(o,f){var m=ur(o);return f==null?m:Jh(m,f)}var o1=Bt(function(o,f){o=Zt(o);var m=-1,R=f.length,L=R>2?f[2]:i;for(L&&Pe(f[0],f[1],L)&&(R=1);++m<R;)for(var F=f[m],j=Oe(F),G=-1,it=j.length;++G<it;){var dt=j[G],vt=o[dt];(vt===i||yi(vt,lr[dt])&&!Xt.call(o,dt))&&(o[dt]=F[dt])}return o}),l1=Bt(function(o){return o.push(i,Nu),qe(_f,i,o)});function c1(o,f){return Dh(o,Et(f,3),_i)}function h1(o,f){return Dh(o,Et(f,3),Uo)}function u1(o,f){return o==null?o:Ho(o,Et(f,3),Oe)}function f1(o,f){return o==null?o:nu(o,Et(f,3),Oe)}function d1(o,f){return o&&_i(o,Et(f,3))}function v1(o,f){return o&&Uo(o,Et(f,3))}function g1(o){return o==null?[]:Qs(o,pe(o))}function y1(o){return o==null?[]:Qs(o,Oe(o))}function wl(o,f,m){var R=o==null?i:Dn(o,f);return R===i?m:R}function m1(o,f){return o!=null&&Hu(o,f,H0)}function bl(o,f){return o!=null&&Hu(o,f,U0)}var p1=Lu(function(o,f,m){f!=null&&typeof f.toString!="function"&&(f=Hs.call(f)),o[f]=m},_l(Ne)),w1=Lu(function(o,f,m){f!=null&&typeof f.toString!="function"&&(f=Hs.call(f)),Xt.call(o,f)?o[f].push(m):o[f]=[m]},Et),b1=Bt(Xr);function pe(o){return Be(o)?Gh(o):Vo(o)}function Oe(o){return Be(o)?Gh(o,!0):Z0(o)}function x1(o,f){var m={};return f=Et(f,3),_i(o,function(R,L,F){Oi(m,f(R,L,F),R)}),m}function _1(o,f){var m={};return f=Et(f,3),_i(o,function(R,L,F){Oi(m,L,f(R,L,F))}),m}var k1=fr(function(o,f,m){ta(o,f,m)}),_f=fr(function(o,f,m,R){ta(o,f,m,R)}),E1=Fi(function(o,f){var m={};if(o==null)return m;var R=!1;f=re(f,function(F){return F=hn(F,o),R||(R=F.length>1),F}),ki(o,sl(o),m),R&&(m=ai(m,d|g|v,pp));for(var L=f.length;L--;)Zo(m,f[L]);return m});function A1(o,f){return kf(o,ga(Et(f)))}var R1=Fi(function(o,f){return o==null?{}:Q0(o,f)});function kf(o,f){if(o==null)return{};var m=re(sl(o),function(R){return[R]});return f=Et(f),du(o,m,function(R,L){return f(R,L[0])})}function C1(o,f,m){f=hn(f,o);var R=-1,L=f.length;for(L||(L=1,o=i);++R<L;){var F=o==null?i:o[Ei(f[R])];F===i&&(R=L,F=m),o=Hi(F)?F.call(o):F}return o}function T1(o,f,m){return o==null?o:Zr(o,f,m)}function S1(o,f,m,R){return R=typeof R=="function"?R:i,o==null?o:Zr(o,f,m,R)}var Ef=Bu(pe),Af=Bu(Oe);function P1(o,f,m){var R=Pt(o),L=R||fn(o)||gr(o);if(f=Et(f,4),m==null){var F=o&&o.constructor;L?m=R?new F:[]:oe(o)?m=Hi(F)?ur(qs(o)):{}:m={}}return(L?ni:_i)(o,function(j,G,it){return f(m,j,G,it)}),m}function I1(o,f){return o==null?!0:Zo(o,f)}function L1(o,f,m){return o==null?o:pu(o,f,tl(m))}function D1(o,f,m,R){return R=typeof R=="function"?R:i,o==null?o:pu(o,f,tl(m),R)}function yr(o){return o==null?[]:Lo(o,pe(o))}function M1(o){return o==null?[]:Lo(o,Oe(o))}function B1(o,f,m){return m===i&&(m=f,f=i),m!==i&&(m=ci(m),m=m===m?m:0),f!==i&&(f=ci(f),f=f===f?f:0),Ln(ci(o),f,m)}function O1(o,f,m){return f=Ui(f),m===i?(m=f,f=0):m=Ui(m),o=ci(o),W0(o,f,m)}function N1(o,f,m){if(m&&typeof m!="boolean"&&Pe(o,f,m)&&(f=m=i),m===i&&(typeof f=="boolean"?(m=f,f=i):typeof o=="boolean"&&(m=o,o=i)),o===i&&f===i?(o=0,f=1):(o=Ui(o),f===i?(f=o,o=0):f=Ui(f)),o>f){var R=o;o=f,f=R}if(m||o%1||f%1){var L=Yh();return Ce(o+L*(f-o+gm("1e-"+((L+"").length-1))),f)}return Yo(o,f)}var F1=dr(function(o,f,m){return f=f.toLowerCase(),o+(m?Rf(f):f)});function Rf(o){return xl(Yt(o).toLowerCase())}function Cf(o){return o=Yt(o),o&&o.replace(Hy,Tm).replace(sm,"")}function z1(o,f,m){o=Yt(o),f=Ve(f);var R=o.length;m=m===i?R:Ln(Dt(m),0,R);var L=m;return m-=f.length,m>=0&&o.slice(m,L)==f}function H1(o){return o=Yt(o),o&&by.test(o)?o.replace(nh,Sm):o}function U1(o){return o=Yt(o),o&&Ry.test(o)?o.replace(yo,"\\$&"):o}var W1=dr(function(o,f,m){return o+(m?"-":"")+f.toLowerCase()}),q1=dr(function(o,f,m){return o+(m?" ":"")+f.toLowerCase()}),j1=Su("toLowerCase");function V1(o,f,m){o=Yt(o),f=Dt(f);var R=f?ar(o):0;if(!f||R>=f)return o;var L=(f-R)/2;return aa(Ks(L),m)+o+aa($s(L),m)}function $1(o,f,m){o=Yt(o),f=Dt(f);var R=f?ar(o):0;return f&&R<f?o+aa(f-R,m):o}function K1(o,f,m){o=Yt(o),f=Dt(f);var R=f?ar(o):0;return f&&R<f?aa(f-R,m)+o:o}function Y1(o,f,m){return m||f==null?f=0:f&&(f=+f),e0(Yt(o).replace(mo,""),f||0)}function X1(o,f,m){return(m?Pe(o,f,m):f===i)?f=1:f=Dt(f),Xo(Yt(o),f)}function G1(){var o=arguments,f=Yt(o[0]);return o.length<3?f:f.replace(o[1],o[2])}var Z1=dr(function(o,f,m){return o+(m?"_":"")+f.toLowerCase()});function J1(o,f,m){return m&&typeof m!="number"&&Pe(o,f,m)&&(f=m=i),m=m===i?Y:m>>>0,m?(o=Yt(o),o&&(typeof f=="string"||f!=null&&!pl(f))&&(f=Ve(f),!f&&sr(o))?un(vi(o),0,m):o.split(f,m)):[]}var Q1=dr(function(o,f,m){return o+(m?" ":"")+xl(f)});function tx(o,f,m){return o=Yt(o),m=m==null?0:Ln(Dt(m),0,o.length),f=Ve(f),o.slice(m,m+f.length)==f}function ex(o,f,m){var R=N.templateSettings;m&&Pe(o,f,m)&&(f=i),o=Yt(o),f=pa({},f,R,Ou);var L=pa({},f.imports,R.imports,Ou),F=pe(L),j=Lo(L,F),G,it,dt=0,vt=f.interpolate||Is,gt="__p += '",pt=Mo((f.escape||Is).source+"|"+vt.source+"|"+(vt===rh?My:Is).source+"|"+(f.evaluate||Is).source+"|$","g"),_t="//# sourceURL="+(Xt.call(f,"sourceURL")?(f.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++hm+"]")+`
  87. `;o.replace(pt,function(Ct,Nt,Ht,Ke,Ie,Ye){return Ht||(Ht=Ke),gt+=o.slice(dt,Ye).replace(Uy,Pm),Nt&&(G=!0,gt+=`' +
  88. __e(`+Nt+`) +
  89. '`),Ie&&(it=!0,gt+=`';
  90. `+Ie+`;
  91. __p += '`),Ht&&(gt+=`' +
  92. ((__t = (`+Ht+`)) == null ? '' : __t) +
  93. '`),dt=Ye+Ct.length,Ct}),gt+=`';
  94. `;var Rt=Xt.call(f,"variable")&&f.variable;if(!Rt)gt=`with (obj) {
  95. `+gt+`
  96. }
  97. `;else if(Ly.test(Rt))throw new St(l);gt=(it?gt.replace(yy,""):gt).replace(my,"$1").replace(py,"$1;"),gt="function("+(Rt||"obj")+`) {
  98. `+(Rt?"":`obj || (obj = {});
  99. `)+"var __t, __p = ''"+(G?", __e = _.escape":"")+(it?`, __j = Array.prototype.join;
  100. function print() { __p += __j.call(arguments, '') }
  101. `:`;
  102. `)+gt+`return __p
  103. }`;var Mt=Sf(function(){return $t(F,_t+"return "+gt).apply(i,j)});if(Mt.source=gt,ml(Mt))throw Mt;return Mt}function ix(o){return Yt(o).toLowerCase()}function nx(o){return Yt(o).toUpperCase()}function rx(o,f,m){if(o=Yt(o),o&&(m||f===i))return Nh(o);if(!o||!(f=Ve(f)))return o;var R=vi(o),L=vi(f),F=Fh(R,L),j=zh(R,L)+1;return un(R,F,j).join("")}function sx(o,f,m){if(o=Yt(o),o&&(m||f===i))return o.slice(0,Uh(o)+1);if(!o||!(f=Ve(f)))return o;var R=vi(o),L=zh(R,vi(f))+1;return un(R,0,L).join("")}function ax(o,f,m){if(o=Yt(o),o&&(m||f===i))return o.replace(mo,"");if(!o||!(f=Ve(f)))return o;var R=vi(o),L=Fh(R,vi(f));return un(R,L).join("")}function ox(o,f){var m=Q,R=C;if(oe(f)){var L="separator"in f?f.separator:L;m="length"in f?Dt(f.length):m,R="omission"in f?Ve(f.omission):R}o=Yt(o);var F=o.length;if(sr(o)){var j=vi(o);F=j.length}if(m>=F)return o;var G=m-ar(R);if(G<1)return R;var it=j?un(j,0,G).join(""):o.slice(0,G);if(L===i)return it+R;if(j&&(G+=it.length-G),pl(L)){if(o.slice(G).search(L)){var dt,vt=it;for(L.global||(L=Mo(L.source,Yt(sh.exec(L))+"g")),L.lastIndex=0;dt=L.exec(vt);)var gt=dt.index;it=it.slice(0,gt===i?G:gt)}}else if(o.indexOf(Ve(L),G)!=G){var pt=it.lastIndexOf(L);pt>-1&&(it=it.slice(0,pt))}return it+R}function lx(o){return o=Yt(o),o&&wy.test(o)?o.replace(ih,Nm):o}var cx=dr(function(o,f,m){return o+(m?" ":"")+f.toUpperCase()}),xl=Su("toUpperCase");function Tf(o,f,m){return o=Yt(o),f=m?i:f,f===i?Lm(o)?Hm(o):km(o):o.match(f)||[]}var Sf=Bt(function(o,f){try{return qe(o,i,f)}catch(m){return ml(m)?m:new St(m)}}),hx=Fi(function(o,f){return ni(f,function(m){m=Ei(m),Oi(o,m,gl(o[m],o))}),o});function ux(o){var f=o==null?0:o.length,m=Et();return o=f?re(o,function(R){if(typeof R[1]!="function")throw new ri(a);return[m(R[0]),R[1]]}):[],Bt(function(R){for(var L=-1;++L<f;){var F=o[L];if(qe(F[0],this,R))return qe(F[1],this,R)}})}function fx(o){return N0(ai(o,d))}function _l(o){return function(){return o}}function dx(o,f){return o==null||o!==o?f:o}var vx=Iu(),gx=Iu(!0);function Ne(o){return o}function kl(o){return ou(typeof o=="function"?o:ai(o,d))}function yx(o){return cu(ai(o,d))}function mx(o,f){return hu(o,ai(f,d))}var px=Bt(function(o,f){return function(m){return Xr(m,o,f)}}),bx=Bt(function(o,f){return function(m){return Xr(o,m,f)}});function El(o,f,m){var R=pe(f),L=Qs(f,R);m==null&&!(oe(f)&&(L.length||!R.length))&&(m=f,f=o,o=this,L=Qs(f,pe(f)));var F=!(oe(m)&&"chain"in m)||!!m.chain,j=Hi(o);return ni(L,function(G){var it=f[G];o[G]=it,j&&(o.prototype[G]=function(){var dt=this.__chain__;if(F||dt){var vt=o(this.__wrapped__),gt=vt.__actions__=Me(this.__actions__);return gt.push({func:it,args:arguments,thisArg:o}),vt.__chain__=dt,vt}return it.apply(o,sn([this.value()],arguments))})}),o}function xx(){return _e._===this&&(_e._=$m),this}function Al(){}function _x(o){return o=Dt(o),Bt(function(f){return uu(f,o)})}var kx=il(re),Ex=il(Lh),Ax=il(Co);function Pf(o){return cl(o)?To(Ei(o)):tp(o)}function Rx(o){return function(f){return o==null?i:Dn(o,f)}}var Cx=Du(),Tx=Du(!0);function Rl(){return[]}function Cl(){return!1}function Sx(){return{}}function Px(){return""}function Ix(){return!0}function Lx(o,f){if(o=Dt(o),o<1||o>$)return[];var m=Y,R=Ce(o,Y);f=Et(f),o-=Y;for(var L=Io(R,f);++m<o;)f(m);return L}function Dx(o){return Pt(o)?re(o,Ei):$e(o)?[o]:Me(Xu(Yt(o)))}function Mx(o){var f=++jm;return Yt(o)+f}var Bx=sa(function(o,f){return o+f},0),Ox=nl("ceil"),Nx=sa(function(o,f){return o/f},1),Fx=nl("floor");function zx(o){return o&&o.length?Js(o,Ne,Wo):i}function Hx(o,f){return o&&o.length?Js(o,Et(f,2),Wo):i}function Ux(o){return Bh(o,Ne)}function Wx(o,f){return Bh(o,Et(f,2))}function qx(o){return o&&o.length?Js(o,Ne,$o):i}function jx(o,f){return o&&o.length?Js(o,Et(f,2),$o):i}var Vx=sa(function(o,f){return o*f},1),$x=nl("round"),Kx=sa(function(o,f){return o-f},0);function Yx(o){return o&&o.length?Po(o,Ne):0}function Xx(o,f){return o&&o.length?Po(o,Et(f,2)):0}return N.after=yb,N.ary=of,N.assign=n1,N.assignIn=xf,N.assignInWith=pa,N.assignWith=r1,N.at=s1,N.before=lf,N.bind=gl,N.bindAll=hx,N.bindKey=cf,N.castArray=Tb,N.chain=rf,N.chunk=Np,N.compact=Fp,N.concat=zp,N.cond=ux,N.conforms=fx,N.constant=_l,N.countBy=Kw,N.create=a1,N.curry=hf,N.curryRight=uf,N.debounce=ff,N.defaults=o1,N.defaultsDeep=l1,N.defer=mb,N.delay=pb,N.difference=Hp,N.differenceBy=Up,N.differenceWith=Wp,N.drop=qp,N.dropRight=jp,N.dropRightWhile=Vp,N.dropWhile=$p,N.fill=Kp,N.filter=Xw,N.flatMap=Jw,N.flatMapDeep=Qw,N.flatMapDepth=tb,N.flatten=Qu,N.flattenDeep=Yp,N.flattenDepth=Xp,N.flip=wb,N.flow=vx,N.flowRight=gx,N.fromPairs=Gp,N.functions=g1,N.functionsIn=y1,N.groupBy=eb,N.initial=Jp,N.intersection=Qp,N.intersectionBy=tw,N.intersectionWith=ew,N.invert=p1,N.invertBy=w1,N.invokeMap=nb,N.iteratee=kl,N.keyBy=rb,N.keys=pe,N.keysIn=Oe,N.map=fa,N.mapKeys=x1,N.mapValues=_1,N.matches=yx,N.matchesProperty=mx,N.memoize=va,N.merge=k1,N.mergeWith=_f,N.method=px,N.methodOf=bx,N.mixin=El,N.negate=ga,N.nthArg=_x,N.omit=E1,N.omitBy=A1,N.once=bb,N.orderBy=sb,N.over=kx,N.overArgs=xb,N.overEvery=Ex,N.overSome=Ax,N.partial=yl,N.partialRight=df,N.partition=ab,N.pick=R1,N.pickBy=kf,N.property=Pf,N.propertyOf=Rx,N.pull=sw,N.pullAll=ef,N.pullAllBy=aw,N.pullAllWith=ow,N.pullAt=lw,N.range=Cx,N.rangeRight=Tx,N.rearg=_b,N.reject=cb,N.remove=cw,N.rest=kb,N.reverse=dl,N.sampleSize=ub,N.set=T1,N.setWith=S1,N.shuffle=fb,N.slice=hw,N.sortBy=gb,N.sortedUniq=mw,N.sortedUniqBy=pw,N.split=J1,N.spread=Eb,N.tail=ww,N.take=bw,N.takeRight=xw,N.takeRightWhile=_w,N.takeWhile=kw,N.tap=Fw,N.throttle=Ab,N.thru=ua,N.toArray=pf,N.toPairs=Ef,N.toPairsIn=Af,N.toPath=Dx,N.toPlainObject=bf,N.transform=P1,N.unary=Rb,N.union=Ew,N.unionBy=Aw,N.unionWith=Rw,N.uniq=Cw,N.uniqBy=Tw,N.uniqWith=Sw,N.unset=I1,N.unzip=vl,N.unzipWith=nf,N.update=L1,N.updateWith=D1,N.values=yr,N.valuesIn=M1,N.without=Pw,N.words=Tf,N.wrap=Cb,N.xor=Iw,N.xorBy=Lw,N.xorWith=Dw,N.zip=Mw,N.zipObject=Bw,N.zipObjectDeep=Ow,N.zipWith=Nw,N.entries=Ef,N.entriesIn=Af,N.extend=xf,N.extendWith=pa,El(N,N),N.add=Bx,N.attempt=Sf,N.camelCase=F1,N.capitalize=Rf,N.ceil=Ox,N.clamp=B1,N.clone=Sb,N.cloneDeep=Ib,N.cloneDeepWith=Lb,N.cloneWith=Pb,N.conformsTo=Db,N.deburr=Cf,N.defaultTo=dx,N.divide=Nx,N.endsWith=z1,N.eq=yi,N.escape=H1,N.escapeRegExp=U1,N.every=Yw,N.find=Gw,N.findIndex=Zu,N.findKey=c1,N.findLast=Zw,N.findLastIndex=Ju,N.findLastKey=h1,N.floor=Fx,N.forEach=sf,N.forEachRight=af,N.forIn=u1,N.forInRight=f1,N.forOwn=d1,N.forOwnRight=v1,N.get=wl,N.gt=Mb,N.gte=Bb,N.has=m1,N.hasIn=bl,N.head=tf,N.identity=Ne,N.includes=ib,N.indexOf=Zp,N.inRange=O1,N.invoke=b1,N.isArguments=On,N.isArray=Pt,N.isArrayBuffer=Ob,N.isArrayLike=Be,N.isArrayLikeObject=he,N.isBoolean=Nb,N.isBuffer=fn,N.isDate=Fb,N.isElement=zb,N.isEmpty=Hb,N.isEqual=Ub,N.isEqualWith=Wb,N.isError=ml,N.isFinite=qb,N.isFunction=Hi,N.isInteger=vf,N.isLength=ya,N.isMap=gf,N.isMatch=jb,N.isMatchWith=Vb,N.isNaN=$b,N.isNative=Kb,N.isNil=Xb,N.isNull=Yb,N.isNumber=yf,N.isObject=oe,N.isObjectLike=ce,N.isPlainObject=es,N.isRegExp=pl,N.isSafeInteger=Gb,N.isSet=mf,N.isString=ma,N.isSymbol=$e,N.isTypedArray=gr,N.isUndefined=Zb,N.isWeakMap=Jb,N.isWeakSet=Qb,N.join=iw,N.kebabCase=W1,N.last=li,N.lastIndexOf=nw,N.lowerCase=q1,N.lowerFirst=j1,N.lt=t1,N.lte=e1,N.max=zx,N.maxBy=Hx,N.mean=Ux,N.meanBy=Wx,N.min=qx,N.minBy=jx,N.stubArray=Rl,N.stubFalse=Cl,N.stubObject=Sx,N.stubString=Px,N.stubTrue=Ix,N.multiply=Vx,N.nth=rw,N.noConflict=xx,N.noop=Al,N.now=da,N.pad=V1,N.padEnd=$1,N.padStart=K1,N.parseInt=Y1,N.random=N1,N.reduce=ob,N.reduceRight=lb,N.repeat=X1,N.replace=G1,N.result=C1,N.round=$x,N.runInContext=et,N.sample=hb,N.size=db,N.snakeCase=Z1,N.some=vb,N.sortedIndex=uw,N.sortedIndexBy=fw,N.sortedIndexOf=dw,N.sortedLastIndex=vw,N.sortedLastIndexBy=gw,N.sortedLastIndexOf=yw,N.startCase=Q1,N.startsWith=tx,N.subtract=Kx,N.sum=Yx,N.sumBy=Xx,N.template=ex,N.times=Lx,N.toFinite=Ui,N.toInteger=Dt,N.toLength=wf,N.toLower=ix,N.toNumber=ci,N.toSafeInteger=i1,N.toString=Yt,N.toUpper=nx,N.trim=rx,N.trimEnd=sx,N.trimStart=ax,N.truncate=ox,N.unescape=lx,N.uniqueId=Mx,N.upperCase=cx,N.upperFirst=xl,N.each=sf,N.eachRight=af,N.first=tf,El(N,function(){var o={};return _i(N,function(f,m){Xt.call(N.prototype,m)||(o[m]=f)}),o}(),{chain:!1}),N.VERSION=n,ni(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){N[o].placeholder=N}),ni(["drop","take"],function(o,f){Ft.prototype[o]=function(m){m=m===i?1:ye(Dt(m),0);var R=this.__filtered__&&!f?new Ft(this):this.clone();return R.__filtered__?R.__takeCount__=Ce(m,R.__takeCount__):R.__views__.push({size:Ce(m,Y),type:o+(R.__dir__<0?"Right":"")}),R},Ft.prototype[o+"Right"]=function(m){return this.reverse()[o](m).reverse()}}),ni(["filter","map","takeWhile"],function(o,f){var m=f+1,R=m==O||m==Z;Ft.prototype[o]=function(L){var F=this.clone();return F.__iteratees__.push({iteratee:Et(L,3),type:m}),F.__filtered__=F.__filtered__||R,F}}),ni(["head","last"],function(o,f){var m="take"+(f?"Right":"");Ft.prototype[o]=function(){return this[m](1).value()[0]}}),ni(["initial","tail"],function(o,f){var m="drop"+(f?"":"Right");Ft.prototype[o]=function(){return this.__filtered__?new Ft(this):this[m](1)}}),Ft.prototype.compact=function(){return this.filter(Ne)},Ft.prototype.find=function(o){return this.filter(o).head()},Ft.prototype.findLast=function(o){return this.reverse().find(o)},Ft.prototype.invokeMap=Bt(function(o,f){return typeof o=="function"?new Ft(this):this.map(function(m){return Xr(m,o,f)})}),Ft.prototype.reject=function(o){return this.filter(ga(Et(o)))},Ft.prototype.slice=function(o,f){o=Dt(o);var m=this;return m.__filtered__&&(o>0||f<0)?new Ft(m):(o<0?m=m.takeRight(-o):o&&(m=m.drop(o)),f!==i&&(f=Dt(f),m=f<0?m.dropRight(-f):m.take(f-o)),m)},Ft.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},Ft.prototype.toArray=function(){return this.take(Y)},_i(Ft.prototype,function(o,f){var m=/^(?:filter|find|map|reject)|While$/.test(f),R=/^(?:head|last)$/.test(f),L=N[R?"take"+(f=="last"?"Right":""):f],F=R||/^find/.test(f);!L||(N.prototype[f]=function(){var j=this.__wrapped__,G=R?[1]:arguments,it=j instanceof Ft,dt=G[0],vt=it||Pt(j),gt=function(Nt){var Ht=L.apply(N,sn([Nt],G));return R&&pt?Ht[0]:Ht};vt&&m&&typeof dt=="function"&&dt.length!=1&&(it=vt=!1);var pt=this.__chain__,_t=!!this.__actions__.length,Rt=F&&!pt,Mt=it&&!_t;if(!F&&vt){j=Mt?j:new Ft(this);var Ct=o.apply(j,G);return Ct.__actions__.push({func:ua,args:[gt],thisArg:i}),new si(Ct,pt)}return Rt&&Mt?o.apply(this,G):(Ct=this.thru(gt),Rt?R?Ct.value()[0]:Ct.value():Ct)})}),ni(["pop","push","shift","sort","splice","unshift"],function(o){var f=Ns[o],m=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",R=/^(?:pop|shift)$/.test(o);N.prototype[o]=function(){var L=arguments;if(R&&!this.__chain__){var F=this.value();return f.apply(Pt(F)?F:[],L)}return this[m](function(j){return f.apply(Pt(j)?j:[],L)})}}),_i(Ft.prototype,function(o,f){var m=N[f];if(m){var R=m.name+"";Xt.call(hr,R)||(hr[R]=[]),hr[R].push({name:f,func:m})}}),hr[ra(i,_).name]=[{name:"wrapper",func:i}],Ft.prototype.clone=l0,Ft.prototype.reverse=c0,Ft.prototype.value=h0,N.prototype.at=zw,N.prototype.chain=Hw,N.prototype.commit=Uw,N.prototype.next=Ww,N.prototype.plant=jw,N.prototype.reverse=Vw,N.prototype.toJSON=N.prototype.valueOf=N.prototype.value=$w,N.prototype.first=N.prototype.head,Wr&&(N.prototype[Wr]=qw),N},or=Um();Tn?((Tn.exports=or)._=or,ko._=or):_e._=or}).call(Le)})(Mc,Mc.exports);const iT=Mc.exports;export{UC as M,iT as _,jC as a,KC as b,VC as c,qC as d,tT as e,WC as f,QC as g,ZC as h,XC as i,GC as j,JC as k,eT as p,$C as s,YC as t};