var ex=Object.defineProperty;var ix=(e,t,i)=>t in e?ex(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var W=(e,t,i)=>(ix(e,typeof t!="symbol"?t+"":t,i),i);import{P as De}from"./index.51881bf4.js";function Fs(e,t){const i=t||new Path2D;if(e.name==="combine"&&!e.draw)return i instanceof Path2D?i:void 0;e.setTheme||(e.setTheme=sx);let s=e.calculative.borderRadius||0,n=s;const{x:a,y:r,width:l,height:o,ex:u,ey:c}=e.calculative.worldRect;s<1&&(s=l*s,n=o*n);let f=st.x-i&&e.xt.y-i&&e.y0&&s>0?n=180-n:i<0&&s>0?n+=180:i<0&&s<0&&(n=360-n),n}function Qr(e,t){const i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)}function fx(e,t){let i=Lt.None;if(!t)return i;const s=e.x-t.x,n=e.y-t.y;return Math.abs(s)>Math.abs(n)?s>0?i=Lt.Right:i=Lt.Left:n>0?i=Lt.Bottom:i=Lt.Up,i}function aa(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 ff(e,t){return e.anchorId===t.anchorId&&e.connectTo===t.connectTo}function yr(e,t,i){let s=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>>0,1)},emit:function(t,i){(e.get(t)||[]).slice().map(function(s){s(i)}),(e.get("*")||[]).slice().map(function(s){s(t,i)})}}}var Ds;(function(e){e[e.None=-1]="None",e[e.Document=0]="Document",e[e.Canvas=1]="Canvas"})(Ds||(Ds={}));const Dx={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:Ds.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,reconnetTimes:10},Mx=["color","hoverColor","activeColor","disabledColor","background","activeBackground","hoverBackground","disabledBackground","anchorColor","hoverAnchorColor","anchorBackground","animateColor","textColor","ruleColor","ruleLineColor","gridColor","lineColor","penBackground","dockPenColor"],Bx={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"}}},ta={cssRuleSelector:":root",style_prefix:"le5le_",vendor_css_prefix:"--le-",dark:["textColor-9: rgba(255,255,255,0.90)","textColor-6: rgba(255,255,255,0.60)","textColor-1: rgba(255,255,255,1)","textColor-4: rgba(255,255,255,0.40)","textPrimaryColor: #7f838c","textSecondColor: rgba(255,255,255,0.90)","textDisabledColor: rgba(255,255,255,0.40)","textActiveColor: #0052d9","buttonBg: #4583ff","buttonDisabledBg: #0057CC","buttonDisabledColor: #FFFFFF26","buttonGradient: linear-gradient(360deg,#4583ff, #33ccff)","containerBg: rgba(21,24,28,0.95)","tabBg: #303746","tabActiveBg: #4583ff","tabDisabledBg: #282e3b","tabDisabledColor: rgba(255,255,255,0.26)","tabActiveColor: rgba(255,255,255,0.90)","formBg: #2a2f36","datePickerCellActiveRangeBg: #2c4475","componentDisabledBg: #282e3b","dataPickerCellActiveBg: #001b52","activeBg: #25375b","popContentBg: #252b37","disabledBg: #7f838c","disabledBg-2: #282E3B","tableStripeColor: rgba(150,192,255,0.10)","tableMenuBg: #303746","tableMenuDividerBg: rgb(76 81 94)","tableMenuHandleBg: #454f64","tableMenuColor: #bdc7db","tableMenuBorderColor: transparent","tableColRowBg: #303746","tableColRowActiveBg: #4A5263","tableColRowColor: rgba(255,255,255,0.6)","paginationColor: rgba(255,255,255,0.6)","paginationActiveColor: #4583ff","paginationActiveBg: rgba(69,131,255,0.20)","sliderBg: #303746","sliderBtnBg: #000000","notificationBorderColor: transparent","notificationBg: #282e3b","borderColor: #424b61","borderOutsideColor: #4583ff","formBorderColor: #424b61","borderInsideColor: rgba(255,255,255,0.40)","shadow: 0px 1px 10px 0px rgba(0,0,0,0.05), 0px 4px 5px 0px rgba(0,0,0,0.08), 0px 2px 4px -1px rgba(0,0,0,0.12)","radius: 4px"],light:["textColor-9: rgba(0,0,0,0.90)","textColor-6: rgba(0,0,0,0.60)","textColor-1: rgba(0,0,0,1)","textColor-4: rgba(0,0,0,0.40)","textPrimaryColor: #7f838c","textSecondColor: #171B27","textDisabledColor: rgba(0, 0, 0, 0.6)","textActiveColor: #0052d9","buttonBg: #4583ff","buttonDisabledBg: #b5c7ff","buttonDisabledColor: #FFFFFF","buttonGradient: linear-gradient(360deg,#4583ff, #33ccff)","containerBg: #ffffff","tabBg: #f1f2f5","tabActiveBg: #4583ff","tabDisabledBg: #e2e6ea","tabDisabledColor: rgba(0,0,0,0.26)","tabActiveColor: #ffffff","formBg: #EFF1F4","datePickerCellActiveRangeBg: #f2f3ff","componentDisabledBg: #eee","dataPickerCellActiveBg: #edefff","activeBg: #f2f3ff","popContentBg: #ffffff","disabledBg: #7f838c","disabledBg-2: #E2E6EA","tableStripeColor: #f1f2f5","tableMenuBg: #ffffff","tableMenuDividerBg: #e2e6ea","tableMenuHandleBg: #ebedf1","tableMenuColor: rgba(0,0,0,0.60)","tableMenuBorderColor: #e2e6ea","tableColRowBg: #ebedf1","tableColRowActiveBg: #bcc4d0","tableColRowColor: rgba(0,0,0,0.4)","paginationColor: rgba(0,0,0,0.6)","paginationActiveColor: #ffffff","paginationActiveBg: #4583ff","sliderBg: #e2e6ea","sliderBtnBg: #ffffff","notificationBorderColor: transparent","notificationBg: #ffffff","borderColor: #d6dbe3","borderOutsideColor: #d6dbe3","formBorderColor: #d4d6d9","borderInsideColor: #e7e7e7","shadow: 0px 2px 4px 0px rgba(107,113,121,0.25)","radius: 4px"],camelCaseToHyphenated(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())},_addVendorCssPrefix(e){return e.map(t=>{const[i,s]=t.split(":");return`${this.vendor_css_prefix}${this.camelCaseToHyphenated(i.trim())}:${s.trim()}`})},createThemeSheet(e,t){const i=document.createElement("style");i.type="text/css",i.id=this.style_prefix+t,document.head.appendChild(i);const s=e||"dark",n=this.getTheme(s),a=`${this.cssRuleSelector} { ${n.join(";")} }`;i.innerHTML=a},destroyThemeSheet(e){const t=this.findStyleSheet(this.style_prefix+e);t&&document.head.removeChild(t.ownerNode)},addTheme(e,t){Object.assign(this,{[e]:t})},getTheme(e){return this._addVendorCssPrefix(this[e]||this.light)},getThemeObj(e="dark"){const t=":";return this[e].reduce((s,n)=>{const[a,r]=n.split(t);return s[a]=r,s},{})},findStyleSheet(e){const t=document.styleSheets;for(let i=0;il.selectorText===this.cssRuleSelector);if(r){const l=s.join(";");r.style.cssText+=`; ${l}`}else n.addRule(this.cssRuleSelector,s.join(";"))}}};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 Ox=()=>({data:{x:0,y:0,scale:1,pens:[],origin:{x:0,y:0},center:{x:0,y:0},paths:{}},histories:[],pens:{},path2dMap:new WeakMap,animateMap:new WeakMap,active:[],animates:new Set,options:{...Dx},theme:{...Bx},emitter:Lx(),bindDatas:{},bind:{},pensNetwork:{},cacheDatas:[],messageEvents:{},templatePens:{},globalTriggers:{}}),Fx=(e="default")=>(kt[e]||(kt[e]=Ox(),kt[e].id=e),kt[e]),Nx=(e,t)=>{const i=e.data.template===t;if(i)for(const s of e.data.pens)s.canvasLayer===zt.CanvasTemplate&&(e.templatePens[s.id]=s);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,lineAnimateDraws:{}},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 Ri(e){const{paddingTop:t,paddingBottom:i,paddingLeft:s,paddingRight:n,worldRect:a,canvas:r}=e.calculative;let{textLeft:l,textTop:o,textWidth:u,textHeight:c}=e.calculative,f=s,g=t;const v=a.width-s-n,y=a.height-t-i;u&&u<1&&(u*=a.width),c&&c<1&&(c*=a.height),u1?r:1;switch(e.whiteSpace){case"nowrap":if(e.ellipsis!==!1){const c=df(t.split(""),e);c[0]&&(s.push(c[0]),c.length>1&&Tl(s))}else s.push(t);break;case"pre-line":s=t.split(/[\n]/g),e.ellipsis!==!1&&s.length>l&&(s=s.slice(0,l),Tl(s));break;case"break-all":default:const o=t.split(/[\n]/g);let u=0;t:for(const c of o){const f=e.whiteSpace==="break-all"?c.split(""):Hd(c);let g=df(f,e);if(g.length===0&&(g=[""]),e.ellipsis!=!1)for(const v of g)if(u++,u>l){Tl(s);break t}else s.push(v);else s.push(...g)}break}return e.calculative.textLines=s,s}function Hd(e=""){const t=[];let i="";for(let s=0;s126?(i&&(t.push(i),i=""),t.push(e[s])):i+=e[s]}return i&&t.push(i),t}function df(e,t){const i=t.calculative.canvas,s=i.offscreen.getContext("2d"),{fontStyle:n,fontWeight:a,fontSize:r,fontFamily:l,lineHeight:o}=t.calculative;s.save();const u=[];let c=e[0]||"";for(let f=1;f{const n=e.measureText(s).width;t.calculative.textLineWidths.push(n),iu&&(u=c)}s.restore();let f=t.length*r*o;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-(f-e.height):e.y=e.y-(f-e.height)/2),e.height=f+5,e.width=u+5,e.calculative.canvas.updatePenRect(e),e.calculative.canvas.calcActiveRect()}function ht(e,t=!1){if(Array.isArray(e)){const i=[];return e.forEach(s=>{i.push(ht(s,t))}),i}else if(typeof e=="object"){if(e===null)return null;if(e.constructor===RegExp)return e;const i={};for(const s in e)if(!(["canvas","lastFrame","socketFn"].includes(s)||e[s]instanceof HTMLImageElement||e[s]instanceof HTMLMediaElement)){{if(s==="calculative"&&!t)continue;if(s==="singleton"){t?i[s]={}:i[s]=e[s];continue}}i[s]=ht(e[s],t)}return i}return e}function Xl(e,t,i){if(Array.isArray(e)){const s=[];return e.forEach(n=>{s.push(Xl(n,t,i))}),s}else if(typeof e=="object"){if(e===null)return null;for(const s in e)if(t.includes(s))if(Array.isArray(e[s]))e[s].forEach((n,a)=>{Number.isNaN(Number(n))||(e[s][a]=Number(n*i))});else{if(Number.isNaN(Number(e[s])))continue;e[s]=Number(e[s])*i}else e[s]=Xl(e[s],t,i);return e}return e}const Ve={};function Wd(e,t,i){if(!Ve[t.fromArrow])return;const s=le(t),{x:n,y:a}=s,r={x:n,y:a};if(r.step=(t.fromArrowSize||10)*i.data.scale,s.next)r.rotate=ui(s.next,s)+90;else{const o=t.calculative.worldAnchors[1];if(!o)return;o.prev?r.rotate=ui(o.prev,s)+90:r.rotate=ui(o,s)+90}e.save(),e.beginPath(),e.setLineDash([]);const l=t.fromArrowColor||t.calculative.color;l&&(e.strokeStyle=l),Ve[t.fromArrow](e,t,i,r),e.restore()}function Ud(e,t,i){if(!Ve[t.toArrow]||t.calculative.worldAnchors.length<2)return;e.save();const s=$t(t),{x:n,y:a}=s,r={x:n,y:a};if(r.step=(t.toArrowSize||10)*i.data.scale,s.prev)r.rotate=ui(s.prev,s)+90;else{const o=t.calculative.worldAnchors[t.calculative.worldAnchors.length-2];o.next?r.rotate=ui(o.next,s)+90:r.rotate=ui(o,s)+90}e.beginPath(),e.setLineDash([]);const l=t.toArrowColor||t.calculative.color;l&&(e.strokeStyle=l),Ve[t.toArrow](e,t,i,r),e.restore()}Ve.triangleSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y-s.step/4),e.lineTo(s.x,s.y),e.lineTo(n,s.y+s.step/4),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Ve.reTriangleSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step/2;e.moveTo(s.x,s.y-s.step/2),e.lineTo(n,s.y),e.lineTo(s.x,s.y+s.step/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Ve.triangle=(e,t,i,s)=>{e.save(),e.lineWidth<2&&(e.lineWidth=2),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y-s.step/4),e.lineTo(s.x,s.y),e.lineTo(n,s.y+s.step/4),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Ve.circleSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.step/2;e.arc(s.x-n,s.y,n,0,2*Math.PI),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Ve.circle=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.step/2;e.arc(s.x-n,s.y,n,0,2*Math.PI),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Ve.diamondSolid=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step,a=s.step/2;e.moveTo(n,s.y),e.lineTo(n+a,s.y-a/2),e.lineTo(s.x,s.y),e.lineTo(n+a,s.y+a/2),e.closePath(),e.stroke(),e.fillStyle=e.strokeStyle,e.fill(),e.restore()};Ve.diamond=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step,a=s.step/2;e.moveTo(n,s.y),e.lineTo(n+a,s.y-a/2),e.lineTo(s.x,s.y),e.lineTo(n+a,s.y+a/2),e.closePath(),e.stroke(),e.fillStyle=i.data.background||"#ffffff",e.fill(),e.restore()};Ve.line=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y-s.step/3),e.lineTo(s.x,s.y),e.lineTo(n,s.y+s.step/3),e.stroke(),e.restore()};Ve.lineUp=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y-s.step/3),e.lineTo(s.x,s.y),e.stroke(),e.restore()};Ve.lineDown=(e,t,i,s)=>{e.save(),e.translate(s.x,s.y),e.rotate(s.rotate*Math.PI/180),e.translate(-s.x,-s.y);const n=s.x-s.step;e.moveTo(n,s.y+s.step/3),e.lineTo(s.x,s.y),e.stroke(),e.restore()};function Gl(e){const t=parseInt,i=Math.round;let s=e.length,n={};if(s>9){const[a,r,l,o]=e=e.split(",");if(s=e.length,s<3||s>4)return null;n.r=t(a[3]=="a"?a.slice(5):a.slice(4)),n.g=t(r),n.b=t(l),n.a=o?parseFloat(o):-1}else{if(s==8||s==6||s<4)return null;s<6&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(s>4?e[4]+e[4]:"")),e=t(e.slice(1),16),s==9||s==5?(n.r=e>>24&255,n.g=e>>16&255,n.b=e>>8&255,n.a=i((e&255)/.255)/1e3):(n.r=e>>16,n.g=e>>8&255,n.b=e&255,n.a=-1)}return n}function Ae(e,t,i,s){let n,a,r,l,o,u,c,f=Math.round,g=typeof i=="string";return typeof e!="number"||e<-1||e>1||typeof t!="string"||t[0]!="r"&&t[0]!="#"||i&&!g||(c=t.length>9,c=g?i.length>9?!0:i=="c"?!c:!1:c,o=Gl(t),l=e<0,u=i&&i!="c"?Gl(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,!o||!u)?null:(s?(n=f(l*o.r+e*u.r),a=f(l*o.g+e*u.g),r=f(l*o.b+e*u.b)):(n=f((l*o.r**2+e*u.r**2)**.5),a=f((l*o.g**2+e*u.g**2)**.5),r=f((l*o.b**2+e*u.b**2)**.5)),g=o.a,u=u.a,o=g>=0||u>=0,g=o?g<0?u:u<0?g:g*l+u*e:0,c?"rgb"+(o?"a(":"(")+n+","+a+","+r+(o?","+f(g*1e3)/1e3:"")+")":"#"+(4294967296+n*16777216+a*65536+r*256+(o?f(g*255):0)).toString(16).slice(1,o?void 0:-2))}globalThis.pSBC=Ae;function Wr(e,t){const i=Gl(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 fn(e,t){if(isNaN(e)){console.warn("realValue not number");return}if(typeof t!="string"){console.warn("collection must be string");return}const[i,s]=[t[0],t[t.length-1]];if(!["[","("].includes(i)){console.warn('collection must start with "[" or "("');return}if(!["]",")"].includes(s)){console.warn('collection must end with "]" or ")"');return}const n=t.substring(1,t.length-1).split(",");if(n.length!==2){console.warn("collection must have 2 numbers");return}const[a,r]=[+n[0],+n[1]];if(a>=r){console.warn("startNum must less than endNum");return}return e>a||i==="["&&e===a?e=u){console.warn("startNum must less than endNum");return}if(e>=o&&e<=u)return!0}else if(e==a)return!0;return!1}function Wx(e,t,i){const s=1-e;return 3*s*s*e*t+3*s*e*e*i+e*e*e}function It(){return((1+Math.random())*4294967296|0).toString(16).substring(1)}const qi=e=>{let t=0,i=0,s=0,n=0;return typeof e=="number"?t=i=s=n=e:typeof e=="string"?t=i=s=n=parseInt(e,10):Array.isArray(e)&&(t=e[0],s=Sl(e[1])?e[0]:e[1],n=Sl(e[2])?e[0]:e[2],i=Sl(e[3])?s:e[3]),[t,s,n,i]};function Sl(e){return e==null}async function Ux(e){return new Promise((t,i)=>{const s=new FileReader;s.onload=n=>{t(n.target.result)},s.onerror=n=>{i(n)},s.readAsDataURL(e)})}async function $x(e,t,i,s){const n=new FormData;if(n.append("file",e),i)for(const r in i)i.hasOwnProperty(r)&&n.append(r,i[r]);return(await(await fetch(t,{method:"POST",headers:s,body:n})).json()).url}function jx(e,t,i){var s=document.createElement("link");s.href=e,s.rel="stylesheet",t&&(s.onload=t),i&&(s.onerror=i),document.head.appendChild(s)}function bn(e){let t=e||window.location.search.split("?")[1];const i=new URLSearchParams(t);return Object.fromEntries(i.entries())}function ga(e){let t;const i=new RegExp("(^| )"+e+"=([^;]*)(;|$)");return(t=document.cookie.match(i))?decodeURIComponent(t[2]):""}var Ur;(function(e){e[e.None=0]="None",e[e.LocalStorage=1]="LocalStorage",e[e.Cookie=2]="Cookie"})(Ur||(Ur={}));const Vx=location.host.indexOf("le5le.com")!==-1;function Ir(){var t;const e=(t=globalThis.le5leTokenName)!=null?t:"token";switch(globalThis.le5leTokenType){case Ur.LocalStorage:return localStorage.getItem(e);case Ur.Cookie:return ga(e);default:return Vx?ga(e):localStorage.getItem(e)}}async function $d(e,t){var o,u;if(globalThis.getMeta2dData)return await globalThis.getMeta2dData(t);const i=e.options.navigatorNetWork;let n=`/api/data/${location.href.includes("2d.")||location.href.includes("/2d")?"2d":"v"}/get`,a=((o=bn())==null?void 0:o.id)||n.includes("${id}");if(!a&&((u=bn())==null?void 0:u.data)){n=`./projects/${t}`;const f=new URL(window.location);f.searchParams.set("data",t),history.pushState({},"",f)}i!=null&&i.url&&(i.url.includes("${id}")?n=i.url.replace("${id}",t):n=i.url+((i==null?void 0:i.method)==="GET"?`?id=${t}`:""));let r=(i==null?void 0:i.method)||"POST";a||(r="GET");const l=await fetch(n,{headers:{Authorization:`Bearer ${Ir()}`},method:r,body:r==="GET"?void 0:JSON.stringify({id:t})});if(l.ok){let c=await l.text();return c.constructor===Object||c.constructor===Array?c=JSON.parse(JSON.stringify(c)):typeof c=="string"&&(c=JSON.parse(c)),c.data&&(c=c.data),c}else e.emitter.emit("error",{type:"http",error:l})}function ms(e,t){if(t==null)return e;const i=t.split(".");for(;i.length&&(e=e[i.shift()]););return e}function $r(e,t,i){t!=null&&t.split(".").reduce((s,n,a)=>s[n]=t.split(".").length===++a?i:s[n]||{},e)}function Zl(e,t){const i=["\u5929","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"];let s=new Date;t&&(s=new Date(t));const n=s.getFullYear(),a=s.getMonth()+1,r=s.getDate(),l=s.getDay(),o=s.getHours(),u=s.getMinutes(),c=s.getSeconds();return new Function("year","month","day","week","hours","minutes","seconds",e?`return ${e}`:"return `${year}:${month}:${day} ${hours}:${minutes}:${seconds} \u661F\u671F${week}`")(n,a,r,i[l],o,u,c)}function qx(e,t){if(!e||!t)return!1;let i=ti(e);for(;i;){if(i.id===t.id)return!0;i=ti(i)}return!1}function ti(e,t){if(!e||!e.parentId||!e.calculative)return;const s=e.calculative.canvas.store.pens[e.parentId];return t&&ti(s,t)||s}function Qe(e,t){if(!e||!e.children)return[];const i=[];return e.children.forEach(s=>{const n=t.pens[s];n&&(i.push(n),i.push(...Qe(n,t)))}),i}function yc(e,t){if(!e||!e.followers)return[];const i=[];return e.followers.forEach(s=>{const n=t.pens[s];n&&!n.parentId&&(i.push(n),i.push(...yc(n,t)))}),i}function Yx(e,t){const{worldRect:i,gradientFromColor:s,gradientToColor:n,gradientAngle:a}=t.calculative;return Vd(e,i,s,n,a)}function Kx(e,t){const{worldRect:i,gradientFromColor:s,gradientToColor:n,gradientRadius:a}=t.calculative;if(!s||!n)return;const{width:r,height:l,center:o}=i,{x:u,y:c}=o;let f=r;f{v.addColorStop(y.i,y.color)}),v}function Zx(e,t){const{x:i,y:s,ex:n,width:a,height:r,center:l}=t.calculative.worldRect;let o=[{x:n,y:s+r/2},{x:i,y:s+r/2}],u=t.calculative.gradientColors;t.calculative.checked&&(u=t.calculative.onGradientColors);const{angle:c,colors:f}=Ys(u);let g=mc(c,a,r);return o.forEach(v=>{Gt(v,c,l)}),to(e,o,f,g)}function Jx(e,t){const{worldRect:i,textGradientColors:s}=t.calculative;if(!s)return;const{width:n,height:a,center:r}=i,{x:l,y:o}=r;let u=n;u{f.addColorStop(g.i,g.color)}),f}function Qx(e,t){!t.calculative.textDrawRect&&vc(e,t),Qt(t.calculative.textDrawRect);const{x:i,y:s,ex:n,width:a,height:r,center:l}=t.calculative.textDrawRect;let o=[{x:n,y:s+r/2},{x:i,y:s+r/2}];const{angle:u,colors:c}=Ys(t.calculative.textGradientColors);let f=mc(u,a,r);return o.forEach(g=>{Gt(g,u,l)}),to(e,o,c,f)}function mc(e,t,i){const s=Math.atan(i/t)/Math.PI*180;let n=(e-90)%360,a=0;return n>s&&n<180-s||n>180+s&&n<360-s||n<0?(n>270?n=360-n:n>180?n=n-180:n>90&&(n=180-n),a=Math.abs(i/Math.sin(n/180*Math.PI)/2)):(n>270?n=360-n:n>180?n=n-180:n>90&&(n=180-n),a=Math.abs(t/Math.cos(n/180*Math.PI)/2)),a}function Ys(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 s=[];return i.forEach(n=>{if(/rgba?/.test(n)){let a=n.split(") ");s.push({color:t_(a[0]+")"),i:parseFloat(a[1])/100})}else{let a=n.split(" ");a.length>2?s.push({color:a[1],i:parseFloat(a[2])/100}):s.push({color:a[0],i:parseFloat(a[1])/100})}}),{angle:parseFloat(t[0]),colors:s}}else return{angle:parseFloat(t[0]),colors:[]}}else return{angle:0,colors:[]}}function t_(e){if(/rgba?/.test(e)){let t=e.split(",");if(t.length<3)return"";e="#";for(let i=0,s;s=t[i++];)if(i<4)s=parseInt(s.replace(/[^\d]/gi,""),10).toString(16),e+=s.length==1?"0"+s:s;else{s=s.replace(")","");let a=parseInt(s*255+"").toString(16);a=a.length===2?a:"0"+a,e+=a}e=e.toUpperCase()}return e}function e_(e,t){const{x:i,y:s,ex:n,width:a,height:r,center:l}=t.calculative.worldRect;let o=[{x:n,y:s+r/2},{x:i,y:s+r/2}];const{angle:u,colors:c}=Ys(t.calculative.lineGradientColors);let f=mc(u,a,r);return o.forEach(g=>{Gt(g,u,l)}),to(e,o,c,f)}function to(e,t,i,s){let n=Xx(t[0].x,t[0].y,t[1].x,t[1].y,s),a=e.createLinearGradient(n[0],n[1],n[2],n[3]);return i.forEach(r=>{a.addColorStop(r.i,r.color)}),a}function us(e,t,i){let s=[];t.calculative.gradientColorStop?s=t.calculative.gradientColorStop:(s=Ys(t.calculative.lineGradientColors).colors,t.calculative.gradientColorStop=s),e.strokeStyle=to(e,i,s,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 jd(e,t){const i=t.calculative.worldAnchors;let s=t.calculative.lineWidth*(t.calculative.gradientSmooth||t.calculative.lineSmooth||0);for(let n=0;n0){let l=i[n-1].curvePoints;l?mr(e,t,s,l[l.length-1],i[n],i[n].curvePoints[0]):mr(e,t,s,i[n-1],i[n],i[n].curvePoints[0]);let o=Ki(s,i[n],i[n].curvePoints[0]);us(e,t,[o,i[n].curvePoints[1]])}else us(e,t,[i[n],i[n].curvePoints[0]]),us(e,t,[i[n].curvePoints[0],i[n].curvePoints[1]]);let a=i[n].curvePoints.length-1;for(let l=1;l0&&n0&&n0&&n0&&n{const $=t.calculative.textLineWidths[D];let Q=0;S==="center"?Q=(E-$)/2:S==="right"&&(Q=E-$),e.fillText(M,m+Q,_+(D+C)*L);const{textDecorationColor:R,textDecorationDash:T,textDecoration:P}=t;P&&l_(e,{x:m+Q,y:_+(D+C)*L,width:$},{textDecorationColor:R,textDecorationDash:T,fontSize:n});const{textStrickoutColor:O,textStrickoutDash:Y,textStrickout:Z}=t;Z&&c_(e,{x:m+Q,y:_+(D+C)*L,width:$},{textStrickoutColor:O,textStrickoutDash:Y,fontSize:n})}),e.restore()}function l_(e,t,i){const{textDecorationColor:s,textDecorationDash:n,fontSize:a}=i;let{x:r,y:l,width:o}=t;switch(e.textBaseline){case"top":l+=a;break;case"middle":l+=a/2;break}e.save(),e.beginPath(),e.strokeStyle=s||e.fillStyle,e.lineWidth=1,e.moveTo(r,l),e.setLineDash(n||[]),e.lineTo(r+o,l),e.stroke(),e.restore()}function c_(e,t,i){const{textStrickoutColor:s,textStrickoutDash:n,fontSize:a}=i;let{x:r,y:l,width:o}=t;switch(e.textBaseline){case"top":l+=a/2;break;case"bottom":l-=a/2;break}e.save(),e.beginPath(),e.strokeStyle=s||e.fillStyle,e.lineWidth=1,e.moveTo(r,l),e.setLineDash(n||[]),e.lineTo(r+o,l),e.stroke(),e.restore()}function Yd(e,t,i){if(i==null)return;const{fontStyle:s,fontWeight:n,fontSize:a,fontFamily:r,lineHeight:l,canvas:o}=t.calculative,u=o.store;e.save();let c;t.calculative.hover?c=t.hoverTextColor||t.hoverColor||u.styles.hoverColor:t.calculative.active&&(c=t.activeTextColor||t.activeColor||u.styles.activeColor),e.fillStyle=c||Ji(t,u),e.font=Be({fontStyle:s,fontWeight:n,fontFamily:r||u.options.fontFamily,fontSize:a,lineHeight:l});const f=e.measureText(i).width;let g,v;for(const y of t.calculative.worldAnchors){if(!v){v=y;continue}const w=Qr(v,y),m=Math.floor(w/f);g="";for(let E=0;E0?l=t.calculative.iconSize:s.width>s.height?l=s.height:l=s.width,e.font=Be({fontSize:l,fontWeight:r,fontFamily:o}),e.fillStyle=t.calculative.iconColor||Ji(t,i),t.calculative.iconRotate&&(e.translate(s.center.x,s.center.y),e.rotate(t.calculative.iconRotate*Math.PI/180),e.translate(-s.center.x,-s.center.y)),e.beginPath(),e.fillText(t.calculative.icon,n,a),e.restore()}function Xd(e,t){if(!t.input)return;const i=t.calculative.canvas.store.data.scale,s=t.calculative.canvas.inputDiv.dataset.penId,{x:n,y:a,width:r,height:l}=t.calculative.worldRect;e.save(),e.beginPath(),t.id===s?(e.moveTo(n+r-20*i,a+l/2+2*i),e.lineTo(n+r-14*i,a+l/2-4*i),e.lineTo(n+r-8*i,a+l/2+2*i)):(e.moveTo(n+r-20*i,a+l/2-4*i),e.lineTo(n+r-14*i,a+l/2+2*i),e.lineTo(n+r-8*i,a+l/2-4*i)),e.stroke(),e.restore()}function Be({fontStyle:e="normal",textDecoration:t="normal",fontWeight:i="normal",fontSize:s=12,fontFamily:n="Arial",lineHeight:a=1}={}){return`${e} ${t} ${i} ${s}px/${a} ${n}`}function zs(e,t){const{x:i,ex:s,y:n,ey:a}=t.calculative.worldRect||{};t.calculative.flipX&&(e.translate(i+s,0),e.scale(-1,1)),t.calculative.flipY&&(e.translate(0,n+a),e.scale(1,-1))}function Gi(e,t,i=!1){const{x:s,y:n}=t.calculative.worldRect.pivot||t.calculative.worldRect.center;e.translate(s,n);let a=t.calculative.rotate*Math.PI/180;i||(t.calculative.flipX&&(a*=-1),t.calculative.flipY&&(a*=-1)),e.rotate(a),e.translate(-s,-n)}function Is(e,t,i){e.save(),e.translate(.5,.5),e.beginPath(),I_(e,t);const s=t.calculative.canvas.store,n=t.textFlip||s.options.textFlip,a=t.textRotate||s.options.textRotate;(!n||!a)&&e.save(),zs(e,t),t.calculative.rotate&&t.name!=="line"&&Gi(e,t),(t.calculative.lineWidth>1||i)&&(e.lineWidth=t.calculative.lineWidth),A_(e,s,t);let r,l=!1,o;t.calculative.disabled?(o=t.disabledColor||s.styles.disabledColor||Ae(.4,t.calculative.color||s.styles.color),r=t.disabledBackground||s.styles.disabledBackground||Ae(.4,t.calculative.background||s.styles.penBackground)):t.mouseDownValid&&t.calculative.mouseDown?(o=t.mouseDownColor||Ae(-.4,t.calculative.color||s.styles.color),r=t.mouseDownBackground||Ae(-.4,t.calculative.background||s.styles.penBackground)):t.switch&&t.calculative.checked?t.calculative.bkType||(r=t.onBackground):t.calculative.hover?(o=t.hoverColor||s.styles.hoverColor,r=t.hoverBackground||s.styles.hoverBackground):t.calculative.active?(o=t.activeColor||s.styles.activeColor,r=t.activeBackground||s.styles.activeBackground):t.calculative.isDock&&(t.type===jt.Line?o=s.styles.dockPenColor:r=Wr(s.styles.dockPenColor,.2));const u=t.calculative.strokeImg;if(t.calculative.strokeImage&&u)e.strokeStyle=o||e.createPattern(u,"repeat");else{let f;t.calculative.strokeType?t.calculative.lineGradientColors?t.name==="line"?l=!0:t.calculative.lineGradient?f=t.calculative.lineGradient:(f=e_(e,t),t.calculative.lineGradient=f):f=r_(e,t):f=t.calculative.color||(t.type?s.data.lineColor:"")||s.styles.color,e.strokeStyle=o||f}const c=t.calculative.backgroundImg;if(t.calculative.backgroundImage&&c)e.fillStyle=r||e.createPattern(c,"repeat"),r=!0;else{let f;t.calculative.bkType===Sn.Linear?t.calculative.gradientColors?t.calculative.gradient?f=t.calculative.gradient:(f=Zx(e,t),t.calculative.gradient=f):f=Yx(e,t):t.calculative.bkType===Sn.Radial?t.calculative.gradientColors?t.calculative.radialGradient?f=t.calculative.radialGradient:(f=Gx(e,t),t.calculative.radialGradient=f):f=Kx(e,t):f=t.calculative.background||s.styles.penBackground,e.fillStyle=r||f,r=!!f}if(Gd(e,t),Zd(e,t),Hs(e,t),t.calculative.lineDash&&e.setLineDash(t.calculative.lineDash.map(f=>f*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?(jd(e,t),Qd(!0,e,t,s)):(Jd(!0,e,t,s,r),rg(e,t)),!(t.image&&t.calculative.img)&&t.calculative.icon&&Kd(e,t),t.dropdownList&&Xd(e,t),(!n||!a)&&e.restore(),n&&!a&&zs(e,t),!n&&a&&t.calculative.rotate&&t.name!=="line"&&Gi(e,t,!0),qd(e,t),t.type===jt.Line&&t.fillTexts)for(const f of t.fillTexts)Yd(e,t,f);e.restore()}function Gd(e,t){const i=t.lineCap||(t.type?"round":"square");i?e.lineCap=i:t.type&&(e.lineCap="round")}function Zd(e,t){const i=t.lineJoin;i?e.lineJoin=i:t.type&&(e.lineJoin="round")}function jr(e,t,i,s){var u;e.save(),i&&e.translate(-i.x,-i.y),(u=e.setAttrs)==null||u.call(e,t);let n=!1;const a=t.calculative.canvas.store,r=t.textFlip||a.options.textFlip,l=t.textRotate||a.options.textRotate;e.beginPath(),(!r||!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"&&Gi(e,t),(t.calculative.lineWidth>1||s)&&(e.lineWidth=t.calculative.lineWidth);let o;if(t.calculative.hover)e.strokeStyle=t.hoverColor||a.styles.hoverColor,e.fillStyle=t.hoverBackground||a.styles.hoverBackground,o=t.hoverBackground||a.styles.hoverBackground;else if(t.calculative.active)e.strokeStyle=t.activeColor||a.styles.activeColor,e.fillStyle=t.activeBackground||a.styles.activeBackground,o=t.activeBackground||a.styles.activeBackground;else{if(t.strokeImage)t.calculative.strokeImg&&(e.strokeStyle=e.createPattern(t.calculative.strokeImg,"repeat"),o=!0);else{let c;t.calculative.strokeType&&t.calculative.lineGradientColors&&t.name==="line"?n=!0:c=t.calculative.color||a.styles.color,e.strokeStyle=c}t.backgroundImage?t.calculative.backgroundImg&&(e.fillStyle=e.createPattern(t.calculative.backgroundImg,"repeat"),o=!0):(e.fillStyle=t.background,o=!!t.background)}if(Gd(e,t),Zd(e,t),Hs(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),n?(jd(e,t),Qd(!0,e,t,a)):(Jd(!1,e,t,a,o),rg(e,t)),t.calculative.img?(e.save(),e.shadowColor="",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,En(e,t),e.restore()):t.calculative.icon&&Kd(e,t),t.dropdownList&&Xd(e,t),(!r||!l)&&e.restore(),r&&!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))),!r&&l&&t.calculative.rotate&&t.name!=="line"&&Gi(e,t,!0),qd(e,t),t.type===jt.Line&&t.fillTexts)for(const c of t.fillTexts)Yd(e,t,c);e.restore()}function Jd(e=!0,t,i,s,n){if(i.name==="drawCommand")return;const a=e?s.path2dMap.get(i):kt.path2dDraws[i.name];let r=null,l=null;if(i.type===jt.Line&&(i.fromLineCap&&i.fromLineCap!=="butt"&&(t.lineCap="butt",r=new Path2D,r.moveTo(i.calculative.worldAnchors[0].x,i.calculative.worldAnchors[0].y),r.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))),a){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,r&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(r),t.restore()),a instanceof Path2D?(n&&t.fill(a),u&&t.stroke(a)):(a(i,t),n&&t.fill(),u&&t.stroke()),l&&(t.save(),t.lineCap=i.toLineCap,t.stroke(l),t.restore()),t.restore()}a instanceof Path2D?i.type?i.close&&n&&t.fill(a):n&&t.fill(a):(t.save(),a(i,t),n&&t.fill(),t.restore());const o=i.calculative.progress;if(o!=null){t.save();const{ex:u,x:c,y:f,width:g,height:v,ey:y}=i.calculative.worldRect;let w=null;if(i.calculative.verticalProgress?w=i.reverseProgress?t.createLinearGradient(c,f,c,f+v*o):t.createLinearGradient(c,y,c,f+v*(1-o)):w=i.reverseProgress?t.createLinearGradient(u,f,c+g*(1-o),f):t.createLinearGradient(c,f,c+g*o,f),i.calculative.progressGradientColors){const{colors:m}=Ys(i.calculative.progressGradientColors);m.forEach(_=>{w.addColorStop(_.i,_.color)})}else{const m=i.calculative.progressColor||i.calculative.color||s.options.activeColor||s.data.color;w.addColorStop(0,m),w.addColorStop(1,m)}w.addColorStop(1,"transparent"),t.fillStyle=w,a instanceof Path2D?t.fill(a):(a(i,t),t.fill()),t.restore()}if(i.calculative.lineWidth&&(a instanceof Path2D?(s.options.svgPathStroke||i.name!=="svgPath")&&(r&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(r),t.restore()),t.stroke(a),l&&(t.save(),t.lineCap=i.toLineCap,t.stroke(l),t.restore())):(a(i,t),t.stroke())),i.type){if(i.calculative.animatePos){if(t.save(),tg(t,i,s),i.lineAnimateType===We.Arrow||i.lineAnimateType===We.WaterDrop){let u=dg(i,t);u instanceof Path2D?(t.stroke(u),t.fill(u)):(t.stroke(),t.fill())}else a instanceof Path2D?(r&&!i.lineAnimateType&&(t.save(),t.lineCap=i.fromLineCap,t.stroke(r),t.restore()),t.lineCap=i.lineCap,t.stroke(a)):(a(i,t),t.stroke());t.restore()}i.fromArrow&&Wd(t,i,s),i.toArrow&&Ud(t,i,s),i.calculative.active&&!i.calculative.pencil&&!s.options.disableAnchor&&!s.data.locked&&eg(t,i)}}}function Qd(e=!0,t,i,s){const n=e?s.path2dMap.get(i):kt.path2dDraws[i.name];if(n&&i.type){if(i.calculative.animatePos){if(t.save(),tg(t,i,s),t.beginPath(),n instanceof Path2D)if(i.lineName==="polyline"||i.lineName==="line")if(i.lineAnimateType===We.Arrow||i.lineAnimateType===We.WaterDrop){const a=dg(i);t.stroke(a),t.fill(a)}else i.calculative.gradientSmooth||i.calculative.lineSmooth?(i.calculative.gradientAnimatePath||(i.calculative.gradientAnimatePath=pc(i)),i.calculative.gradientAnimatePath instanceof Path2D&&t.stroke(i.calculative.gradientAnimatePath)):t.stroke(n);else t.stroke(n);else n(i,t),t.stroke();t.restore()}i.fromArrow&&Wd(t,i,s),i.toArrow&&Ud(t,i,s),i.calculative.active&&!i.calculative.pencil&&!s.options.disableAnchor&&!s.data.locked&&eg(t,i)}}function tg(e,t,i){var n;e.strokeStyle=t.animateColor||i.styles.animateColor,t.animateShadow&&(e.shadowBlur=t.animateShadowBlur||t.animateLineWidth||6,e.shadowColor=t.animateShadowColor||t.animateColor||i.styles.animateColor),t.calculative.animateLineWidth&&(e.lineWidth=t.calculative.animateLineWidth*i.data.scale);let s=0;switch(t.lineAnimateType){case We.Beads:t.animateReverse?e.lineDashOffset=t.calculative.animatePos:e.lineDashOffset=t.length-t.calculative.animatePos,s=t.calculative.lineWidth||5,s<5&&(s=5);const a=t.animateLineDash&&t.animateLineDash.map(r=>r*s/5);e.setLineDash(a||[s,s*2]);break;case We.Dot:t.animateReverse?e.lineDashOffset=t.calculative.animatePos:e.lineDashOffset=t.length-t.calculative.animatePos,s=t.calculative.animateDotSize||t.calculative.lineWidth*2||6,s<6&&(s=6),s>40&&(s=40),e.lineWidth=(t.calculative.animateLineWidth||s)*i.data.scale,e.setLineDash([.1,t.length]);break;case We.Arrow:e.fillStyle=t.animateColor||i.styles.animateColor,e.lineWidth=1;break;case We.WaterDrop:e.fillStyle=t.animateColor||i.styles.animateColor,e.lineWidth=1;break;case We.Custom:switch(t.lineAnimateTargetType){case wn.Image:if((n=t.lineAnimateImages)!=null||(t.lineAnimateImages=[]),t.lineAnimateImages.length>0){const o=t.lineAnimateImages.map((u,c)=>{const f=kt.htmlElements[u];if(!f)t.calculative.canvas.__loadImage(u);else return f});pr(e,t,"image",o)}break;case wn.Icon:const r=t.lineAnimateIcon;pr(e,t,"icon",r);break;case wn.Pen:t.lineAnimatePens&&pr(e,t,"pen",t.lineAnimatePens);break;case wn.Element:const l=t.lineAnimateElement;pr(e,t,"element",l)}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 pr(e,t,i,s){let n=null;switch(i){case"image":n=h_(s);break;case"icon":n=f_(s);break;case"pen":let a=t.calculative.canvas.find(s);t.lineAnimateElementCount=a.length,n=u_(a);break;case"element":if(n=kt.lineAnimateDraws[s],!n)return;break}d_(e,t,n)}function h_(e){return function(t,i,s,n){const a=i.calculative.canvas.store.data.scale,r=i.lineAnimateElementWidth||10,l=i.lineAnimateElementHeight||10,o=e[n%e.length];!o||(t.beginPath(),t.translate(s.x+r/2*a,s.y+l/2*a),t.rotate(s.rotate*Math.PI/180),t.scale(a,a),t.translate(-(r/2*a),-(l/2*a)),t.drawImage(o,0,0,r,l))}}function u_(e){return function(t,i,s,n){const a=e[n%e.length];if(!a)return;const r=i.calculative.canvas.store.data.scale,l=i.calculative.canvas.store.data.origin,o=i.calculative.canvas.parent,u=a.width,c=a.height,f=s.x-u/2,g=s.y-c/2,v=(f-l.x)/r,y=(g-l.y)/r,w=u/r,m=c/r,_={x:v,y,width:w,height:m,rotate:s.rotate};o.setValue({id:a.id,..._})}}function f_(e){return function(t,i,s,n){const a=i.calculative.canvas.store.data.scale,r=i.lineAnimateElementWidth||10,l=i.lineAnimateElementHeight||10;t.beginPath(),t.translate(s.x+r/2*a,s.y+l/2*a),t.rotate(s.rotate*Math.PI/180),t.scale(a,a),t.translate(-(r/2*a),-(l/2*a));const o=i.calculative.iconWeight;let u;const c=i.calculative.iconFamily;u=i.calculative.iconSize||Math.max(i.lineAnimateElementWidth||0,i.lineAnimateElementHeight||0)||10,t.font=Be({fontSize:u,fontWeight:o,fontFamily:c}),t.fillStyle=i.calculative.iconColor||Ji(i,i.calculative.canvas.parent.store),i.calculative.iconRotate&&t.rotate(i.calculative.iconRotate*Math.PI/180),t.beginPath(),t.fillText(e,0,0)}}function d_(e,t,i){var l;const s=Array.isArray(t.lineAnimateDash)?t.lineAnimateDash:((l=t.lineAnimateDash)==null?void 0:l.split(",").map(o=>Number(o)))||[10,20],n=t.calculative.canvas.store.data.scale,a=Yr(t)/n;g_(a,s,t.lineAnimateDashOffset,t.lineAnimateElementCount).forEach((o,u)=>{const c=v_(t,o.start);if(!!c)try{e.save(),i(e,t,c,u),e.restore()}catch(f){e.restore(),console.warn(f)}})}function g_(e,t,i=0,s,n=0){const a=[];if(!t||t.length===0)return a.push({start:0,end:e,isDash:!0}),a;const r=t.reduce((c,f)=>c+f,0);let l=(-i+n)%r;l<0&&(l+=r);let o=0,u=0;for(s||(s=1/0);ue&&(y=e),g&&y>v){const w=(v+n)%e,m=(y+n)%e;a.push({start:w,end:m,isDash:!0}),o+=1}if(u=y,l=0,u>=e||o>=s)break}return a}function v_(e,t=0){let i,s=null;if(e.calculative.worldAnchors.forEach(r=>{s&&(i=Lf(i,s,s.next,r.prev,r)),s=r}),e.close){let r=e.calculative.worldAnchors[0];i=Lf(i,s,s.next,r.prev,r)}let n=0;return e.animateReverse?n=e.length-e.calculative.animatePos-t*e.calculative.canvas.store.data.scale:n=e.calculative.animatePos-t*e.calculative.canvas.store.data.scale,A2(i,n)}function eg(e,t){const i=t.calculative.canvas.store;e.save(),e.lineWidth=1,e.fillStyle=t.activeColor||i.styles.activeColor,t.calculative.worldAnchors.forEach(s=>{!s.hidden&&!s.isTemp&&y_(e,s,t)}),e.restore()}function y_(e,t,i){if(!t)return;const s=i.calculative.canvas.store.activeAnchor===i.calculative.activeAnchor&&i.calculative.activeAnchor===t;let n=3;i.calculative.lineWidth>3&&(n=i.calculative.lineWidth),i.anchorRadius&&(n=i.anchorRadius),t.radius&&(n=t.radius),s?(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,n,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,n,0,Math.PI*2),e.fill(),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,n,0,Math.PI*2),e.fill(),e.stroke()),e.beginPath(),e.arc(t.x,t.y,n,0,Math.PI*2),e.fill(),e.stroke()):(e.save(),e.fillStyle="#ffffff",e.beginPath(),e.arc(t.x,t.y,n,0,Math.PI*2),e.fill(),e.stroke(),e.restore())}function ig(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,re(i),Qt(i),e.pivot&&Ql(i,e.pivot);else{const s=t.pens[e.parentId];let n=s.calculative.worldRect;n||(n=ig(s)),i.x=n.x+n.width*e.x,i.y=n.y+n.height*e.y,i.width=n.width*e.width,i.height=n.height*e.height,s.flipX&&(i.x=n.width-(i.x-n.x+i.width)+n.x),s.flipY&&(i.y=n.height-(i.y-n.y+i.height)+n.y),re(i),i.rotate=n.rotate+e.rotate,Qt(i),e.pivot&&Ql(i,e.pivot)}return e.calculative.worldRect=i,wc(e,i),i}function wc(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 Lr(e){const t=ht(e.calculative.worldRect);if(delete t.pivot,!e.parentId){Object.assign(e,t);return}const s=e.calculative.canvas.store.pens[e.parentId].calculative.worldRect;Object.assign(e,fs(t,s))}function An(e){const t=e.calculative.canvas.store;let i=[];if(e.anchors){let s=ht(e.anchors);e.flipX&&s.forEach(n=>{n.x=.5-(n.x-.5)}),e.flipY&&s.forEach(n=>{n.y=.5-(n.y-.5)}),s.forEach(n=>{i.push(m_(e,n))})}if(!i.length&&!e.type&&!e.calculative.canvas.parent.isCombine(e)){const{x:s,y:n,width:a,height:r}=e.calculative.worldRect;i=t.options.defaultAnchors.map((l,o)=>({id:`${o}`,penId:e.id,x:s+a*l.x,y:n+r*l.y}))}e.calculative.rotate&&e.name!=="line"&&i.forEach(s=>{Gt(s,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(s=>{s.id,e.calculative.activeAnchor.id})),e.calculative.gradientAnimatePath=void 0}function sg(e){var t;if((t=e.children)!=null&&t.length){let i=e.calculative.worldRect;e.children.forEach(s=>{const n=e.calculative.canvas.store.pens[s];n.calculative.initRect&&n.calculative.initRelativeRect&&(n.calculative.initRect.x=i.x+i.width*n.calculative.initRelativeRect.x,n.calculative.initRect.y=i.y+i.height*n.calculative.initRelativeRect.y,n.calculative.initRect.ex=n.calculative.initRect.x+i.width*n.calculative.initRelativeRect.width,n.calculative.initRect.ey=n.calculative.initRect.y+i.height+n.calculative.initRelativeRect.height,Qt(n.calculative.initRect)),sg(n)})}}function m_(e,t){const i={...t},{x:s,y:n,width:a,height:r}=e.calculative.worldRect;return i.x=s+a*t.x,i.y=n+r*t.y,t.prev&&(i.prev={penId:e.id,connectTo:t.prev.connectTo,x:s+a*t.prev.x,y:n+r*t.prev.y}),t.next&&(i.next={penId:e.id,connectTo:t.next.connectTo,x:s+a*t.next.x,y:n+r*t.next.y}),i}function vf(e,t){const{paddingTop:i,paddingBottom:s,paddingLeft:n,paddingRight:a}=t.calculative;let r=n,l=i,o=t.calculative.worldRect.width-n-a,u=t.calculative.worldRect.height-i-s,c=t.calculative.iconLeft,f=t.calculative.iconTop;c&&Math.abs(c)<1&&(c=t.calculative.worldRect.width*c),f&&Math.abs(f)<1&&(f=t.calculative.worldRect.height*f),r+=c||0,l+=f||0,o-=c||0,u-=f||0;let g=t.calculative.iconRotate||0;if(t.parentId){const v=e[t.parentId].calculative;v&&(g+=v.rotate,g%=360)}r=t.calculative.worldRect.x+r,l=t.calculative.worldRect.y+l,t.calculative.worldIconRect={x:r,y:l,width:o,height:u,rotate:g},re(t.calculative.worldIconRect),Qt(t.calculative.worldIconRect)}function gn(e,t,i){va(e.calculative.worldRect,t,i,e.pivot),e.calculative.initRect&&va(e.calculative.initRect,t,i,e.pivot),ng(e,t,i),e.calculative.x&&Hr(e.calculative,t,i),e.type&&An(e)}function ng(e,t,i){var s;!e||(s=e.children)!=null&&s.length&&e.children.forEach(n=>{const a=e.calculative.canvas.store.pens[n];a&&(a.calculative.initRect&&va(a.calculative.initRect,t,i),ng(a,t,i))})}function p_(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 s={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(s)}return i}function w_(e,t,i){e.anchors||(e.anchors=[]),e.calculative.worldAnchors||(e.calculative.worldAnchors=[]);const s=p2(e,t,i);return e.calculative.worldAnchors.splice(i+1,0,s),e.anchors.splice(i+1,0,ra(s,e.calculative.worldRect)),e.calculative.activeAnchor=s,s}function b_(e,t){if(!e||!e.calculative.worldAnchors)return;let i=e.calculative.worldAnchors.findIndex(s=>s.id===t.id);i>-1&&e.calculative.worldAnchors.splice(i,1),i=e.anchors.findIndex(s=>s.id===t.id),i>-1&&e.anchors.splice(i,1)}function Pn(e,t){if(!t||!t.calculative||!t.calculative.worldRect.center)return Lt.None;if(e.anchorId){let i=t.anchors.filter(s=>s.id===e.anchorId);if(i.length&&i[0].direction>-1)return i[0].direction}return fx(e,t.calculative.worldRect.center)}function xn(e,t){let i=1/0,s;return e.calculative.worldAnchors.forEach(n=>{const a=Qr(t,n);i>a&&(i=a,s=n)}),s}function yf(e,t,i){e.x+=t,e.y+=i,e.anchors&&e.anchors.forEach(s=>{aa(s,t,i)}),e.calculative.worldAnchors&&e.calculative.worldAnchors.forEach(s=>{aa(s,t,i)})}function bc(e){if(e&&e.calculative&&e.calculative.worldAnchors.length){let t=$t(e);if(!e.anchors||!e.anchors.length)for(;e.calculative.worldAnchors.length&&t!==e.calculative.activeAnchor;)e.calculative.worldAnchors.pop(),t=$t(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,s){var l,o,u,c,f,g;if(!e||!t||!i||!s||t.twoWay===Ee.DisableConnected||t.twoWay===Ee.Disable||s.twoWay===Ee.DisableConnectTo||s.twoWay===Ee.Disable)return;if(t.twoWay===Ee.In){if(i.calculative.worldAnchors.length===1)return;const v=$t(i);if(s.id!==v.id)return}if(t.twoWay===Ee.Out){const v=le(i);if(s.id!==v.id)return}if(s.connectTo===e.id&&s.anchorId===t.id)return;if(s.connectTo){const v=e.calculative.canvas.store.pens[s.connectTo];_n(v,Ls(v,s.anchorId),i,s)}e.connectedLines||(e.connectedLines=[]),e.connectedLines.findIndex(v=>v.lineId===i.id&&v.lineAnchor===s.id&&v.anchor===t.id)<0&&e.connectedLines.push({lineId:i.id,lineAnchor:s.id,anchor:t.id}),s.connectTo=e.id,s.anchorId=t.id,e.type&&we(i,s,e,t),e.calculative.canvas.store.emitter.emit("connectLine",{line:i,lineAnchor:s,pen:e,anchor:t});let a=((l=i.calculative.worldAnchors)==null?void 0:l.length)>=2?(o=i.calculative.worldAnchors)==null?void 0:o[0].connectTo:void 0,r=((u=i.calculative.worldAnchors)==null?void 0:u.length)>=2?(f=i.calculative.canvas.store.pens[(c=i.calculative.worldAnchors)==null?void 0:c[0].connectTo])==null?void 0:f.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:s,pen:e,anchor:t,fromPen:a,fromAnchor:r}),!0}function _n(e,t,i,s){if(!(!e||!t||!i||!s)&&!(!e.connectedLines||!e.connectedLines.length))return i.lastConnected||(i.lastConnected={}),i.lastConnected[e.id]||(i.lastConnected[e.id]=ht(e.connectedLines)),e.connectedLines.forEach((n,a,r)=>{(n.lineId===i.id||n.lineId===i.id)&&n.lineAnchor===s.id&&n.anchor===t.id&&r.splice(a,1)}),s.connectTo=void 0,s.anchorId=void 0,e.type&&t.connectTo===i.id&&t.anchorId===s.id&&_n(i,s,e,t),e.calculative.canvas.store.emitter.emit("disconnectLine",{line:i,lineAnchor:s,pen:e,anchor:t}),!0}function Ls(e,t){var i;if(!(!e||!t))return(i=e.calculative.worldAnchors)==null?void 0:i.find(s=>s.id===t)}function le(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[0]}function $t(e){if(!(!e||!e.calculative.worldAnchors))return e.calculative.worldAnchors[e.calculative.worldAnchors.length-1]}function x_(e,t){var s,n;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 a of e.frames){e.calculative.duration+=a.duration;for(const r in a)r!=="duration"&&!e[r]&&r==="scale"&&(e[r]=1)}}if(e.animateCycle||(e.animateCycle=1/0),e.calculative.start){let a=0;const r=Math.ceil((t-e.calculative.start)/e.calculative.duration);if(r>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,pf(e,1),0;const l=(t-e.calculative.start)%e.calculative.duration||e.calculative.duration;let o=0;for(const f of e.frames)if(o+=f.duration,l>o)++a;else break;if(!e.frames[a])return!0;let u=!1;a!==e.calculative.frameIndex&&(u=!0,e.calculative.frameIndex=a,e.calculative.frameDuration=e.frames[a].duration,a>0&&(e.calculative.frameStart+=e.frames[a-1].duration),e.calculative.frameEnd=e.calculative.frameStart+e.calculative.frameDuration);let c=!1;if(r>e.calculative.cycleIndex&&(e.calculative.cycleIndex=r,e.calculative.frameStart=e.calculative.start+e.calculative.duration*(r-1),c=!0),u||c)if(e.calculative.x=e.calculative.initRect.x,e.calculative.y=e.calculative.initRect.y,((n=e.children)==null?void 0:n.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,a>0){e.prevFrame={};const f=e.frames[a-1];for(const g in f)e.prevFrame[g]=f[g];Object.assign(e.prevFrame,{rotate:f.rotate||0,x:f.x||0,y:f.y||0,scale:f.scale||1})}else mf(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=ht(e.calculative.worldRect),e.parentId&&(e.calculative.initRelativeRect={x:e.x,y:e.y,width:e.width,height:e.height}),(s=e.children)!=null&&s.length){const a=e.calculative.canvas.store;e.calculative.childrenVisible={},e.children.forEach(r=>{e.calculative.childrenVisible[r]=a.pens[r].visible})}e.calculative.initRect.rotate=e.calculative.rotate||0,mf(e)}const i=(t-e.calculative.frameStart)/e.calculative.frameDuration%1;return i>0&&pf(e,i),!0}function mf(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 pf(e,t){var n,a,r,l,o,u;if(t<0)return;t>1&&(t=1);const i=e.frames[e.calculative.frameIndex],s=e.calculative.canvas.store.data.scale;for(const c in i)if(c!=="duration"){if(c==="scale"){e.calculative.worldRect=ht(e.calculative.initRect),va(e.calculative.worldRect,e.prevFrame.scale,e.calculative.worldRect.center);const f=e.prevFrame.scale+(i[c]-e.prevFrame.scale)*t;va(e.calculative.worldRect,f/e.prevFrame.scale,e.calculative.worldRect.center),e.calculative.patchFlags=!0}else if(c==="x"){const f=Jn(e,c,e.calculative.frameIndex)*s;e.calculative.worldRect.x=e.calculative.initRect.x+f,e.calculative.worldRect.ex=e.calculative.initRect.ex+f,e.calculative.worldRect.center.x=e.calculative.initRect.center.x+f,(n=e.calculative.worldRect.pivot)!=null&&n.x&&(e.calculative.worldRect.pivot.x=((a=e.calculative.initRect.pivot)==null?void 0:a.x)+f),Ms(e.calculative.worldRect,i[c]*t*s,0),e.calculative.patchFlags=!0}else if(c==="y"){const f=Jn(e,c,e.calculative.frameIndex)*s;e.calculative.worldRect.y=e.calculative.initRect.y+f,e.calculative.worldRect.ey=e.calculative.initRect.ey+f,e.calculative.worldRect.center.y=e.calculative.initRect.center.y+f,(r=e.calculative.worldRect.pivot)!=null&&r.x&&(e.calculative.worldRect.pivot.y=((l=e.calculative.initRect.pivot)==null?void 0:l.y)+f),Ms(e.calculative.worldRect,0,i[c]*t*s),e.calculative.patchFlags=!0}else if(c==="width"){const f=Jn(e,c,e.calculative.frameIndex)*s;e.calculative.worldRect.width=e.calculative.initRect.width+f,e.calculative.worldRect.ex=e.calculative.initRect.ex+f,e.calculative.worldRect.center.x=e.calculative.initRect.center.x+f;let g=i[c]*t*s;e.calculative.worldRect.width+=g,e.calculative.worldRect.ex+=g,e.calculative.worldRect.center.x+=g,e.calculative.patchFlags=!0}else if(c==="height"){const f=Jn(e,c,e.calculative.frameIndex)*s;e.calculative.worldRect.height=e.calculative.initRect.height+f,e.calculative.worldRect.ey=e.calculative.initRect.ey+f,e.calculative.worldRect.center.y=e.calculative.initRect.center.y+f;let g=i[c]*t*s;e.calculative.worldRect.height+=g,e.calculative.worldRect.ey+=g,e.calculative.worldRect.center.y+=g,e.calculative.patchFlags=!0}else if(c==="rotate"){e.prevFrame[c]>=360&&(e.prevFrame[c]%=360);const f=Jn(e,c,e.calculative.frameIndex),g=(e.calculative.initRect.rotate+f+i[c]*t)%360-(e.calculative.rotate||0);(o=e.children)!=null&&o.length?e.calculative.canvas.rotatePen(e,g,e.calculative.initRect):e.calculative.rotate=(e.calculative.initRect.rotate+f+i[c]*t)%360,e.calculative.patchFlags=!0}else if(c==="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(__(i[c],c,e)){e.prevFrame[c]==null&&(c==="globalAlpha"?e.prevFrame[c]=1:e.prevFrame[c]=0);const f=e.prevFrame[c]+(i[c]-e.prevFrame[c])*t;e.calculative[c]=Math.round(f*100)/100}else{if(c==="visible"&&!e.calculative.image){if((u=e.children)!=null&&u.length){const g=Qe(e,e.calculative.canvas.store);e.calculative.canvas.initImageCanvas(g)}}e.calculative[c]=i[c];const f={};f[c]=i[c],xc(e,f)}c==="text"&&_a(e)}}function __(e,t,i){const s=["strokeType","bkType","showChild"];return typeof e=="number"&&i.linear!==!1&&!s.includes(t)}function k_(e,t){if(e.calculative.start===0)return e.calculative.start=void 0,e.calculative.cycleStart=void 0,0;e.animateCycle||(e.animateCycle=1/0),e.animateSpan||(e.animateSpan=1);const i=(t-e.calculative.cycleStart)/1e3;if(e.curveAnimate){let s=[];e.animateTimingFunction?s=Array.isArray(e.animateTimingFunction)?e.animateTimingFunction:e.animateTimingFunction.split(","):s=[.25,.25,.75,.75];const n=e.duration||5,a=i/n,r=Wx(a,s[1],s[3]);e.calculative.animatePos=r*e.length}else e.calculative.animatePos+=e.animateSpan*(e.calculative.canvas.store.data.scale||1);if(e.calculative.cycleStart||(e.calculative.cycleStart=t),!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||e.curveAnimate&&i>e.duration){if(++e.calculative.cycleIndex,e.calculative.cycleIndex>e.animateCycle)return e.currentAnimation=void 0,e.calculative.start=void 0,e.calculative.cycleStart=void 0,0;e.calculative.cycleStart=void 0,e.calculative.animatePos=e.animateSpan}return!0}function pn(e,t=!0){if(!e.children||e.childActive===!1)return;const i=e.calculative.canvas.store;e.children.forEach(s=>{const n=i.pens[s];n&&(n.calculative.active=t,pn(n,t))})}function ea(e,t=!0){if(!e)return;const i=e.calculative.canvas.store;e.calculative.hover=t,e.childHover!==!1&&e.children&&e.children.forEach(s=>{var n,a;((n=i.pens[s])==null?void 0:n.hoverColor)==null&&((a=i.pens[s])==null?void 0:a.hoverBackground)==null&&ea(i.pens[s],t)})}function Re(e,t){if(!t)return;const i=e.calculative.canvas.store,s=e.calculative.worldRect;if(t.style.opacity=e.globalAlpha+"",t.style.position="absolute",t.style.outline="none",t.style.left=s.x+i.data.x+"px",t.style.top=s.y+i.data.y+"px",t.style.width=s.width+"px",t.style.height=s.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"),e.className&&(t.className=e.className),e.styles)for(let n in e.styles)t.style[n]=e.styles[n]}function Pl(e){return e.every(t=>t.locked)}function wf(e){return e.every(t=>t.disableRotate)}function ag(e,t,i){var s;e.type?(e.calculative.worldAnchors.forEach(n=>{Gt(n,t,i.center)}),E_(e),Lr(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)),(s=e.children)==null||s.forEach(n=>{const a=e.calculative.canvas.store.pens[n];ag(a,t,i)})}function E_(e){var n;if(!((n=e.calculative.worldAnchors)!=null&&n.length)||!isFinite(e.x)||!isFinite(e.x)||e.x==null||e.y==null)return;const t=ic(e);e.parentId||Object.assign(e,t);const{fontSize:i,lineHeight:s}=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=s,e.calculative.lineHeight=e.lineHeight),Qt(t),e.calculative.worldRect=t,wc(e,t),Ri(e),e.calculative.worldAnchors&&(e.anchors=e.calculative.worldAnchors.map(a=>ra(a,e.calculative.worldRect)))}function bf(e){return e.every(t=>t.disableSize||t.pivot)}function Jn(e,t,i){if(!e.frames||!t)return 0;let s=0;for(let n=0;n{const o=i.pens[l];o&&Yi(o,!0)})),e.calculative.inView=!0,Vr(e,i)?(e.visible==!1||e.calculative.visible==!1)&&(e.calculative.inView=!1,(e.canvasLayer===zt.CanvasImageBottom||e.canvasLayer===zt.CanvasImage)&&((a=e.frames)==null?void 0:a.length)&&(e.calculative.inView=e.frames.some(l=>l.hasOwnProperty("visible")))):e.calculative.inView=!1,e.calculative.inView){const{x:l,y:o,width:u,height:c,rotate:f}=e.calculative.worldRect,g={x:l+i.data.x,y:o+i.data.y,width:u,height:c,rotate:f};re(g),Xi(g,s)||(e.calculative.inView=!1)}(r=e.calculative.singleton)!=null&&r.div&&Re(e,e.calculative.singleton.div)}function A_(e,t,i){if(t.fillWorldTextRect){e.save(),e.fillStyle="#c3deb7";const{x:s,y:n,width:a,height:r}=i.calculative.worldTextRect;e.fillRect(s,n,a,r),e.restore()}}function Hs(e,t){const i=t.calculative.globalAlpha;typeof i=="number"&&i<1&&!isNaN(i)&&(e.globalAlpha=i)}function rg(e,t){const i=C_(e,t)||kt.canvasDraws[t.name];i&&(e.save(),i(e,t),e.restore())}function C_(e,t){const i=t.drawCommand;if(!(!i||t.name==="line"))return(s,n)=>{i.forEach(a=>{try{a.steps=a.steps.flat(1/0),a.steps.reduce((r,l)=>{const o=R_(l,n,r.x,r.y);try{if(o.c){if(o.c.startsWith("_")){const c=o.c.split("_")[1];return typeof o.v.value=="number"&&(o.v.value*=n.calculative.canvas.store.data.scale),(o.p||s)[c]=o.v.value,{x:r.x,y:r.y}}let u=[];for(const c in o.v)u.push(o.v[c]);return(o.p||s)[o.c](...u),{x:o.startX||o.v.x,y:o.startY||o.v.y}}return{x:r.x,y:r.y}}catch{}},{})}catch{}}),s.stroke()}}function R_(e,t,i,s){var a;const n={visio:P_,dxf:T_,canvas:S_};return((a=n[t.parseType])==null?void 0:a.call(n,e,t,i,s))||e}function T_(e,t,i,s){var c,f;const{x:n,y:a,width:r,height:l}=t.calculative.worldRect,{originWidth:o,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*(r/o)+n,y:e.v.y*(l/u)+a}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a}};case"arc":return{c:"ellipse",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a,rx:e.v.xr*(r/o),ry:e.v.yr*(l/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(c=e.v.aclockwise)!=null?c:!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a,rx:e.v.xr*(r/o),ry:e.v.yr*(l/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(f=e.v.aclockwise)!=null?f:!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*(r/o)+n),g.v.y!==void 0&&(g.v.y=e.v.y*(l/u)+a),g}}function S_(e,t,i,s){var c,f;const{x:n,y:a,width:r,height:l}=t.calculative.worldRect,{originWidth:o,originHeight:u}=t.origin;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*(r/o)+n,y:e.v.y*(l/u)+a}};case"lineTo":return{c:"lineTo",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a}};case"arc":return{c:"ellipse",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a,rx:e.v.xr*(r/o),ry:e.v.yr*(l/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(c=e.v.aclockwise)!=null?c:!0}};case"ellipse":return{c:"ellipse",v:{x:e.v.x*(r/o)+n,y:e.v.y*(l/u)+a,rx:e.v.xr*(r/o),ry:e.v.yr*(l/u),rotation:e.v.rotation||0,startAngle:e.v.startAngle,endAngle:e.v.endAngle,a:(f=e.v.aclockwise)!=null?f:!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)}};default:const g={c:e.c,v:{...e.v}};return g.v.x!==void 0&&(g.v.x=e.v.x*(r/o)+n),g.v.y!==void 0&&(g.v.y=e.v.y*(l/u)+a),g}}function P_(e,t,i,s){const{x:n,y:a,width:r,height:l}=t.calculative.worldRect,{width:o,height:u}=t.origin;switch(e.c){case"MoveTo":return{c:"moveTo",v:{x:+e.v.X*100*(r/o)+n,y:+e.v.Y*100*(l/u)+a}};case"RelMoveTo":return{c:"moveTo",v:{x:+e.v.X*o*(r/o)+n,y:+e.v.Y*u*(l/u)+a}};case"LineTo":return{c:"lineTo",v:{x:+e.v.X*100*(r/o)+n,y:+e.v.Y*100*(l/u)+a}};case"RelLineTo":return{c:"lineTo",v:{x:+e.v.X*o*(r/o)+n,y:+e.v.Y*u*(l/u)+a}};case"Ellipse":let c=e.v.X,f=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:c*100*(r/o)+n,y:f*100*(l/u)+a,radiuX:g*100*(r/o),radiuY:v*100*(l/u),rotation:0,startAngle:0,endAngle:Math.PI*2,anticlockwise:!0}};case"EllipticalArcTo":const y=e.v.X*100*(r/o)+n,w=e.v.Y*100*(l/u)+a,m=e.v.A*100*(r/o)+n,_=e.v.B*100*(l/u)+a;e.v.C;const E=e.v.D*(r/l)*(u/o),x=(y-i)*(_-s)-(w-s)*(m-i)>0,C=xf(i,s,y,w,m,_,E);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=wr(C.x0,C.y0,i,s)),!e.orign.endA&&(e.orign.endA=wr(C.x0,C.y0,y,w)),{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:x},startX:y,startY:w};case"RelEllipticalArcTo":const S=e.v.X*o*(r/o)+n,L=e.v.Y*u*(l/u)+a,M=e.v.A*o*(r/o)+n,D=e.v.B*u*(l/u)+a;e.v.C;const $=e.v.D*(r/l)*(u/o),Q=(S-i)*(D-s)-(L-s)*(M-i)>0,R=xf(i,s,S,L,M,D,$);return!e.orign&&(e.orign={}),!e.orign.startA&&(e.orign.startA=wr(R.x0,R.y0,i,s)),!e.orign.endA&&(e.orign.endA=wr(R.x0,R.y0,S,L)),{c:"ellipse",v:{centerX:R.x0,centerY:R.y0,radiuX:R.a,radiuY:R.b,rotation:0,startAngle:e.orign.startA,endAngle:e.orign.endA,anticlockwise:Q},startX:S,startY:L};case"ArcTo":let T=e.v.X*100*r/o+n,P=e.v.Y*100*l/u+a,O=e.v.A*100*(r/l)*(u/o),Y=(i+T)/2,Z=(s+P)/2,at=Math.sqrt((T-i)**2+(P-s)**2),V=at**2/(8*O)+O/2,H=-(P-s)/at,j=(T-i)/at,K=Y+H*V,U=Z+j*V,tt=K,st=U,et=Math.atan2(s-st,i-tt),ut=Math.atan2(P-st,T-tt);return{c:"arc",v:{x:tt,y:st,radius:V,startAngle:et,endAngle:ut,aclockwise:!0}};default:const ct=ht(e);return Object.entries(ct.v).forEach(([ot,b])=>{var k,I;(k=ot.endsWith)!=null&&k.call(ot,"_x")?typeof b=="number"&&(ct.v[ot]=b*(r/o)+n):(I=ot.endsWith)!=null&&I.call(ot,"_y")?typeof b=="number"&&(ct.v[ot]=b*(l/u)+a):typeof b=="number"&&(ct.v[ot]=b)}),ct}}function I_(e,t){e.filter=t.filter}function xc(e,t){for(const i in t)Fd.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,Ri(e)):e.calculative[i]=t[i]),e.image&&e.name!=="gif"&&Bd.includes(i)&&(e.calculative.canvas.store.patchFlagsTop=!0,e.calculative.canvas.store.patchFlagsBackground=!0,e.calculative.imageDrawed=!1);if(e.calculative.canvas.parent.isCombine(e)){const i=e.children;i==null||i.forEach(s=>{let n=ht(t);e.calculative.childrenVisible&&e.calculative.childrenVisible[s]===!1&&delete n.visible;const a=e.calculative.canvas.store.pens[s];a&&xc(a,n)})}}function xf(e,t,i,s,n,a,r){let l=(e-i)*(e+i)*(s-a)-(i-n)*(i+n)*(t-s)+r*r*(t-s)*(s-a)*(t-a),o=2*((e-i)*(s-a)-(i-n)*(t-s)),u=l/o,c=(e-i)*(i-n)*(e-n)+r*r*((i-n)*(t-s)*(t+s)-(e-i)*(s-a)*(s+a)),f=2*r*r*((i-n)*(t-s)-(e-i)*(s-a)),g=c/f,v=Math.sqrt(Math.pow(e-u,2)+Math.pow(r*(t-g),2)),y=v/r;return{x0:u,y0:g,a:v,b:y}}function wr(e,t,i,s){let n=i-e,a=s-t,r=Math.atan2(a,n);return r<0&&(r+=2*Math.PI),r}function _f(e,t,i){let s,n,a=1/0,r=1/0;const l=8;for(const o of e.data.pens){if(o.calculative.inView===!1)continue;_c(o).forEach(c=>{if(c===t||c===i)return;let f=(o.calculative.worldRect.center.x-t.x)*(o.calculative.worldRect.center.x-t.x)+(o.calculative.worldRect.center.y-t.y)*(o.calculative.worldRect.center.y-t.y);const g=Math.abs(c.x-t.x);g>0&&g0&&v{a.x+=s.x,a.y+=s.y})):(Qt(t),n=[t.center,...Zi(t)]),og(e,n,t,!0)}function _c(e){if(e.type){if(e.type===jt.Line)return e.calculative.worldAnchors}else{const t=Zi(e.calculative.worldRect);return Qt(e.calculative.worldRect),[...e.calculative.worldAnchors,...t,e.calculative.worldRect.center]}}function D_(e,t,i,s){const n=Zi(t);return og(e,n,t)}function og(e,t,i,s=!1){let n,a,r=1/0,l=1/0;const o=10,u=H_(i,o);return e.data.pens.forEach(c=>{const{inView:f,worldRect:g,active:v}=c.calculative;if(f===!1||!s&&v||z_(u,g)||c.type&&e.active.some(w=>lg(e,w,c)))return;const y=_c(c);if(!!y)for(const w of y)for(const m of t){const _=w.x-m.x,E=w.y-m.y,x=Math.abs(_),C=Math.abs(E);i.center||(i.center={x:i.x+i.width/2,y:i.y+i.height/2}),xu.calculative.worldRect);const s=i.map(u=>u.x),n=i.map(u=>u.y),a=s.reduce((u,c)=>u+c,0)/s.length,r=n.reduce((u,c)=>u+c,0)/n.length,l=Math.sqrt(s.map(u=>Math.pow(u-a,2)).reduce((u,c)=>u+c,0)/s.length),o=Math.sqrt(n.map(u=>Math.pow(u-r,2)).reduce((u,c)=>u+c,0)/n.length);return e.filter(u=>{let c=u.calculative.worldRect;const f=(c.x-a)/l,g=(c.y-r)/o;return Math.sqrt(f*f+g*g)>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 B_(){let e=null,t=new Map;return(i,s,n,a=!1)=>{if(t.has(i)&&t.get(i)?e=t.get(i):t.set(i,e=new Map),typeof n!="function")return()=>{console.warn("[rewritePenLifeCycle] warn: not a function ")};let r=new Set,l=new Map;e.has(s)&&e.get(s)?r=e.get(s):(l.set(s,i[s]),e.set(s,r)),a?r.delete(n):r.add(n);let o=l.get(s),u=(...c)=>{o==null||o(...c),r.forEach(f=>{f(...c)})};i[s]=u}}let O_=B_();function F_(e){return!e.name&&!e.install?(console.error("installPenPlugin Error: Validation Failed"),!1):!0}function Ui(e,t){if(!t)return;if(t.ex==null&&re(t),!t.rotate||t.rotate%360===0)return e.x>t.x&&e.xt.y&&e.y{Gt(s,t.rotate,t.pivot||t.center)}),N_(e,i)}function Ws(e,t,i=0){const{x:s,y:n,ex:a,ey:r}=t;return e.x>=s-i&&e.x<=a+i&&e.y>=n-i&&e.y<=r+i}function Qt(e){e.center||(e.center={}),e.center.x=e.x+e.width/2,e.center.y=e.y+e.height/2}function re(e){e.ex=e.x+e.width,e.ey=e.y+e.height}function Ql(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 N_(e,t){if(t.length<3)return!1;let i=!1,s=t[t.length-1];for(const n of t)s.y>e.y!=n.y>e.y&&n.x+(e.y-n.y)*(s.x-n.x)/(s.y-n.y)>e.x&&(i=!i),s=n;return i}function hi(e){const t=[];e.forEach(s=>{if(s.isRuleLine)return;const n=s.calculative.worldRect;if(n){const a=Zi(n);t.push(...a)}});const i=ka(t);return Qt(i),i}function Zi(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||Qt(e),t.forEach(i=>{Gt(i,e.rotate,e.pivot||e.center)})),t}function ka(e){let t=1/0,i=1/0,s=-1/0,n=-1/0;return e==null||e.forEach(a=>{!isFinite(a.x)||!isFinite(a.y)||(t=Math.min(t,a.x),i=Math.min(i,a.y),s=Math.max(s,a.x),n=Math.max(n,a.y))}),{x:t,y:i,ex:s,ey:n,width:s-t,height:n-i}}function Xi(e,t,i){return e.rotate&&(e=ka(Zi(e))),i?e.x>t.x&&e.ext.y&&e.eyt.ex||e.ext.ey)}function z_(e,t){return(t.x>e.ex||t.exe.ey||t.eye.y!=o>e.y&&e.x<(l-a)*(e.y-r)/(o-r)+a&&(i=!i)}return i}const j_=/^[\t\n\f\r ]*([MLHVZCSQTAmlhvzcsqta])[\t\n\f\r ]*/,Af=/^[01]/,Jt=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,V_=/^(([\t\n\f\r ]+,?[\t\n\f\r ]*)|(,[\t\n\f\r ]*))/,q_={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,Af,Af,Jt,Jt]};function Y_(e){let t=0;const i=[];for(;t{a.worldPoints.forEach((r,l)=>{l%2===0?(rs&&(s=r)):(rn&&(n=r))})}),{x:t,y:i,ex:s,ey:n,width:s-t+1,height:n-i+1}}function K_(e,t,i){i==null&&(i=t),e.commands.forEach((s,n)=>{if(!(s.relative&&n))switch(s.key){case"A":case"a":s.values[5]+=t,s.values[6]+=i;break;case"V":case"v":s.values[0]+=i;break;default:s.values.forEach((a,r)=>{s.values[r]=a+(r%2===0?t:i)});break}})}function X_(e,t,i){i==null&&(i=t),e.commands.forEach(s=>{switch(s.key){case"A":case"a":const n=s.values[0],a=s.values[1],r=Math.PI*s.values[2]/180,l=Math.cos(r),o=Math.sin(r),u=a*a*i*i*l*l+n*n*i*i*o*o,c=2*t*i*l*o*(a*a-n*n),f=n*n*t*t*l*l+a*a*t*t*o*o,g=-(n*n*a*a*t*t*i*i),v=c*c-4*u*f,y=Math.sqrt((u-f)*(u-f)+c*c);s.values[2]=c!==0?Math.atan((f-u-y)/c)*180/Math.PI:u=0?s.values[4]:1-s.values[4];break;case"V":case"v":s.values[0]*=i;break;default:s.values.forEach((w,m)=>{s.values[m]=w*(m%2===0?t:i)});break}})}function G_(e){let t="";return e.commands.forEach(i=>{t+=i.key+" ",i.values.forEach(s=>{t+=s+" "})}),t}function Z_(e,t,i){const s=q_[e.toUpperCase()],n=[];for(;i<=t.length;){const a={key:e,values:[]};for(const r of s){const l=t.slice(i).match(r);if(l!==null){a.values.push(+l[0]),i+=l[0].length;const o=t.slice(i).match(V_);o!==null&&(i+=o[0].length)}else{if(a.values.length===0)return{cursor:i,commands:n};throw new Error("malformed path (first error at "+i+")")}}if(a.relative=a.key.toUpperCase()!==a.key,n.push(a),s.length===0)return{cursor:i,commands:n};e==="m"&&(e="l"),e==="M"&&(e="L")}throw new Error("malformed path (first error at "+i+")")}function J_(e,t){const i=[];let s=e.relative&&t?{x:t.worldPoints[t.worldPoints.length-2],y:t.worldPoints[t.worldPoints.length-1]}:{x:0,y:0};for(let n=0;n{switch(n.key){case"Z":case"z":n.worldPoints=[i,s];break;case"H":n.worldPoints=[n.values[0],t.worldPoints[t.worldPoints.length-1]];break;case"h":n.worldPoints=[n.values[0]+t.worldPoints[t.worldPoints.length-2],t.worldPoints[t.worldPoints.length-1]];break;case"V":n.worldPoints=[t.worldPoints[t.worldPoints.length-2],n.values[0]];break;case"v":n.worldPoints=[t.worldPoints[t.worldPoints.length-2],n.values[0]+t.worldPoints[t.worldPoints.length-1]];break;case"A":n.worldPoints=[t.worldPoints[t.worldPoints.length-2],n.values[0]+t.worldPoints[t.worldPoints.length-1]];break;default:J_(n,t);break}(n.key==="M"||n.key==="m"||n.key==="Z"||n.key==="z")&&(i=n.worldPoints[n.worldPoints.length-2],s=n.worldPoints[n.worldPoints.length-1]),t=n})}function t2(e,t){var o;const s=e.calculative.canvas.store.data.paths[e.pathId];if(!s)return new Path2D;const n=Y_(s);e.calculative.svgRect=Cf(n),Qt(e.calculative.svgRect),(e.calculative.svgRect.width!==e.calculative.worldRect.width||e.calculative.svgRect.height!==e.calculative.worldRect.height)&&X_(n,e.calculative.worldRect.width/e.calculative.svgRect.width,e.calculative.worldRect.height/e.calculative.svgRect.height);const a=Cf(n);Qt(a),K_(n,e.calculative.worldRect.x-a.x,e.calculative.worldRect.y-a.y);const r=G_(n);if(t){(o=t.svgPath)==null||o.call(t,r);return}return new Path2D(r)}function e2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/2,n),i.lineTo(s+a,n+r/2),i.lineTo(s+a/2,n+r),i.lineTo(s,n+r/2),i.lineTo(s+a/2,n),i.closePath(),i instanceof Path2D)return i}function i2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/2,n),i.lineTo(s+a,n+r),i.lineTo(s,n+r),i.lineTo(s+a/2,n),i.closePath(),i instanceof Path2D)return i}function s2(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:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function n2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/2,n),i.lineTo(s+a,n+r*2/5),i.lineTo(s+a*4/5,n+r),i.lineTo(s+a/5,n+r),i.lineTo(s,n+r*2/5),i.closePath(),i instanceof Path2D)return i}function a2(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:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function r2(e,t){e.onResize||(e.onResize=o2);const i=t||new Path2D,{width:s,height:n,center:a}=e.calculative.worldRect,r=s>n?n:s,l=a.x,o=a.y,u=o-r/2,c=o-r/4,f=-(c-o)*Math.sin(Math.PI/180*324)+l,g=(c-o)*Math.cos(Math.PI/180*324)+o;i.moveTo(f,g);for(let v=0;v<5;++v)i.lineTo(-(u-o)*Math.sin(Math.PI/180*72*v)+l,(u-o)*Math.cos(Math.PI/180*72*v)+o),i.lineTo((f-l)*Math.cos(Math.PI/180*72*(v+1))-(g-o)*Math.sin(Math.PI/180*72*(v+1))+l,(f-l)*Math.sin(Math.PI/180*72*(v+1))+(g-o)*Math.cos(Math.PI/180*72*(v+1))+o);if(i.closePath(),i instanceof Path2D)return i}function cg(e){const{width:t,height:i}=e,s=t>i?i:t,n=[];for(let a=0;a<5;++a)n.push({flag:1,id:String(a),penId:e.id,x:.5+s/2*Math.sin(Math.PI/180*72*a)/t,y:-s/2*Math.cos(Math.PI/180*72*a)/i+.5});e.anchors=n}function o2(e){const t=e.anchors.filter(i=>i.flag!==1);cg(e),e.anchors=e.anchors.concat(...t)}function l2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/4,n),i.lineTo(s+a*3/4,n),i.lineTo(s+a,n+r/2),i.lineTo(s+a*3/4,n+r),i.lineTo(s+a*1/4,n+r),i.lineTo(s,n+r/2),i.lineTo(s+a/4,n),i.closePath(),i instanceof Path2D)return i}function c2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s,n+r/2),i.lineTo(s+r/2,n),i.lineTo(s+r/2,n+r/3),i.lineTo(s+a,n+r/3),i.lineTo(s+a,n+r*2/3),i.lineTo(s+r/2,n+r*2/3),i.lineTo(s+r/2,n+r*2/3),i.lineTo(s+r/2,n+r),i.closePath(),i instanceof Path2D)return i}function h2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s,n+r/3),i.lineTo(s+(a-r/2),n+r/3),i.lineTo(s+(a-r/2),n),i.lineTo(s+a,n+r/2),i.lineTo(s+(a-r/2),n+r),i.lineTo(s+(a-r/2),n+r*2/3),i.lineTo(s,n+r*2/3),i.closePath(),i instanceof Path2D)return i}function u2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s,n+r/2),i.lineTo(s+r/2,n),i.lineTo(s+r/2,n+r/3),i.lineTo(s+(a-r/2),n+r/3),i.lineTo(s+(a-r/2),n),i.lineTo(s+a,n+r/2),i.lineTo(s+(a-r/2),n+r),i.lineTo(s+(a-r/2),n+r*2/3),i.lineTo(s+r/2,n+r*2/3),i.lineTo(s+r/2,n+r),i.closePath(),i instanceof Path2D)return i}function f2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ey:l}=e.calculative.worldRect;if(i.moveTo(s,n),i.lineTo(s+a,n),i.lineTo(s+a,n+r*3/4),i.lineTo(s+a*8/16,n+r*3/4),i.lineTo(s+a/4,l),i.lineTo(s+a*5/16,n+r*3/4),i.lineTo(s,n+r*3/4),i.closePath(),i instanceof Path2D)return i}function d2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.moveTo(s+a/5,n+r*13/16),i.bezierCurveTo(s-a/15,n+r*13/16,s-a/15,n+r*7/16,s+a/5,n+r*7/16),i.bezierCurveTo(s+a/5,n,s+a*4/5,n,s+a*4/5,n+r*7/16),i.bezierCurveTo(s+a*16/15,n+r*7/16,s+a*16/15,n+r*13/16,s+a*4/5,n+r*13/16),i.closePath(),i instanceof Path2D)return i}function g2(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=a/6;if(i.moveTo(s,n),i.lineTo(r-o,n),i.lineTo(r,n+o),i.lineTo(r,l),i.lineTo(s,l),i.closePath(),i.moveTo(r-o,n),i.lineTo(r-o,n+o),i.lineTo(r,n+o),i.closePath(),i instanceof Path2D)return i}function v2(e,t){const{x:i,y:s,width:n,ex:a,ey:r}=t.calculative.worldRect;let l=n*.25;const o=t.z;o>1?l=o*t.calculative.canvas.store.data.scale:o>0&&(l=n*o);const u={x:i,y:s+l},c={x:a-l,y:s+l},f={x:a-l,y:r};Il(e,[u,c,f,{x:i,y:r}],t.backgroundFront||t.background,t.color),Il(e,[u,{x:i+l,y:s},{x:a,y:s},c],t.backgroundUp||t.background,t.color),Il(e,[c,{x:a,y:s},{x:a,y:r-l},f],t.backgroundRight||t.background,t.color)}function Il(e,t,i="",s=""){e.save(),i&&(e.fillStyle=i),s&&(e.strokeStyle=s),e.beginPath();for(let n=0;ns.x?l=Lt.Right:l=Lt.Left),s.next={id:It(),penId:t.id,x:s.x,y:s.y,prevNextType:2},n.prev={id:It(),penId:t.id,x:n.x,y:n.y,prevNextType:2},l){case Lt.Up:s.next.y-=a,n.prev.y=s.y;break;case Lt.Bottom:s.next.y+=a,n.prev.y=s.y;break;case Lt.Left:s.next.x-=a,n.prev.x=s.x;break;default:s.next.x+=a,n.prev.x=s.x;break}}function b2(e,t){const i=t||new Path2D;if((e.lineName==="line"||e.lineName==="polyline")&&e.calculative.lineSmooth){let n=pc(e);if(i instanceof Path2D&&i.addPath(n),i instanceof Path2D)return i}const s=e.calculative.worldAnchors;if(s.length>1){let n;s.forEach(a=>{n?Tf(i,n,a):a.start=!0,n=a}),e.close&&(e.lineName==="curve"?Tf(i,n,s[0]):i.closePath())}if(i instanceof Path2D)return i}function x2(e,t,i){var a;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.calculative.worldAnchors.length<2||((a=t.anchors)==null?void 0:a.length)>1)return;const s=le(t),n=$t(t);!s||!n||!n.id||s===n||(s.next=void 0,bc(t),n.prev=void 0,t.calculative.worldAnchors.push(n))}function Tf(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 ic(e){return Yr(e),ka(ug(e))}function ug(e){const t=[];let i;return e.calculative.worldAnchors.forEach(s=>{t.push(s),i&&t.push(...Sf(i,s,e)),i=s}),e.close&&e.calculative.worldAnchors.length>1&&t.push(...Sf(i,e.calculative.worldAnchors[0],e)),t}function qr(e){return e!=null&&e.lineWidth?e.lineWidth/2+4:4}function Sf(e,t,i){const s=[];if(!t)return s;let n=.02;if(e.lineLength&&!i.parentId&&(n=qr(i)/e.lineLength),e.next)if(t.prev)for(let a=n;a<1;a+=n)s.push(hg(a,e,e.next,t.prev,t));else for(let a=n;a<1;a+=n)s.push(ec(a,e,e.next,t));else if(t.prev)for(let a=n;a<1;a+=n)s.push(ec(a,e,t.prev,t));else s.push({x:t.x,y:t.y});return s.length>1&&(e.curvePoints=s),s}function _2(e,t){const i=qr(t);let s=0,n,a;for(const r of t.calculative.worldAnchors){if(n){if(a=Pf(e,n,r,i),a)return{i:s,point:a};++s}n=r}if(t.close&&t.calculative.worldAnchors.length>1&&(a=Pf(e,n,t.calculative.worldAnchors[0],i)))return{i:s,point:a}}function Pf(e,t,i,s=4){if(!t.next&&!i.prev){const{x:n,y:a}=t,{x:r,y:l}=i,o=Math.min(n,r),u=Math.max(n,r),c=Math.min(a,l),f=Math.max(a,l);return e.x>=o-s&&e.x<=u+s&&e.y>=c-s&&e.y<=f+s?k2(e,t,i,s):void 0}else if(t.curvePoints){for(const n of t.curvePoints)if(mn(e,n,s))return n}}function k2(e,t,i,s=4){if(t.x===i.x){if(Math.abs(e.x-t.x)<=s)return{x:t.x,y:e.y}}else{const n=(t.y-i.y)/(t.x-i.x),a=t.y-n*t.x;if(Math.abs((n*e.x+a-e.y)/Math.sqrt(n*n+1))<=s){const o=(e.x+n*e.y-n*a)/(n*n+1);return{x:o,y:n*o+a}}}}function If(e,t,i,s){if(!t&&!i)return Math.sqrt(Math.pow(Math.abs(e.x-s.x),2)+Math.pow(Math.abs(e.y-s.y),2))||0;const n=document.createElementNS("http://www.w3.org/2000/svg","path");return t&&i?n.setAttribute("d",`M${e.x} ${e.y} C${t.x} ${t.y} ${i.x} ${i.y} ${s.x} ${s.y}`):t?n.setAttribute("d",`M${e.x} ${e.y} Q${t.x} ${t.y} ${s.x} ${s.y}`):n.setAttribute("d",`M${e.x} ${e.y} Q${i.x} ${i.y} ${s.x} ${s.y}`),n.getTotalLength()||0}function Yr(e){if(e.calculative.worldAnchors.length<2)return 0;let t=0,i;if(e.calculative.worldAnchors.forEach(s=>{i&&(i.lineLength=If(i,i.next,s.prev,s),t+=i.lineLength),i=s}),e.close){const s=le(e);i.lineLength=If(i,i.next,s.prev,s),t+=i.lineLength}return e.calculative.animatePos&&(e.calculative.animatePos=t/e.length*e.calculative.animatePos),e.length=t,t}function Ll(e,t){const i=e.calculative.worldAnchors;for(let s=0;s=0&&f*u+g*c+v<=0||f*l+g*o+v<=0&&f*u+g*c+v>=0||f*l+g*c+v>=0&&f*u+g*o+v<=0||f*l+g*c+v<=0&&f*u+g*o+v>=0){if(l>u){const y=l;l=u,u=y}if(ou&&a>u||n>o&&r>o||ni)return null;const s=.01,n=e.getPointAtLength(t),a=e.getPointAtLength(t-s),r=Math.atan2(n.y-a.y,n.x-a.x);return{x:n.x,y:n.y,rotate:r/Math.PI*180,progress:t/i}}let Ue=10;function C2(e,t,i){var w;if(t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),Ue=e.options.polylineSpace||10,t.calculative.worldAnchors.length<2)return;let s=le(t),n=$t(t);if(!s||!n)return;let a;if(((w=t.anchors)==null?void 0:w.length)&&s===t.calculative.activeAnchor?(a=!0,s=n,n=le(t)):(!t.anchors||!t.anchors.length)&&s!==t.calculative.activeAnchor&&(s=t.calculative.activeAnchor),!s||!n)return;s.next=void 0,n.prev=void 0;const r=n.connectTo;bc(t);const l=[],o=e.pens[s.connectTo],u=e.pens[n.connectTo],c=Pn(s,o),f=Pn(n,u);let g=Df(s,c,Ue);g&&(s=g,l.push(g)),g=Df(n,f,Ue);const v=n;let y;if(g&&(n=g,v.connectTo&&(g.y>v.y&&s.yv.y))){y=g;let m=Ue;s.x{m.id=It(),m.penId=t.id,t.calculative.worldAnchors.push(m)}),t.calculative.worldAnchors.push(n),y&&t.calculative.worldAnchors.push(y),g&&t.calculative.worldAnchors.push(v),a&&t.calculative.worldAnchors.reverse(),r){const m=t.calculative.worldAnchors.length-2;t.calculative.worldAnchors[m].isTemp=!1,t.calculative.worldAnchors[1].isTemp=!1}}function Df(e,t,i){const s={x:e.x,y:e.y,id:It()};switch(t){case Lt.Up:s.y-=i;break;case Lt.Right:s.x+=i;break;case Lt.Bottom:s.y+=i;break;case Lt.Left:s.x-=i;break;default:return}return s}function R2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,a;switch(i){case Lt.Up:e.ye.y)n=e.x+(t.x-e.x)/2,s.push({x:n,y:e.y},{x:n,y:t.y});else{const r=(e.y+t.y)/2;s.push({x:e.x,y:r},{x:t.x,y:r})}break;case Lt.Right:n=t.x,a=e.y,t.xe.x&&t.ye.y-Ue)n=e.x+(t.x-e.x)/2,s.push({x:n,y:e.y},{x:n,y:t.y});else{const r=(e.y+t.y+Ue)/2;s.push({x:e.x,y:r},{x:t.x,y:r})}break}return s}function T2(e,t,i){if(e.x===t.x||e.y===t.y)return[];const s=[];let n,a;switch(i){case Lt.Up:n=e.x,a=t.y,t.x>e.x&&t.y>e.y&&(n=t.x,a=e.y),s.push({x:n,y:a});break;case Lt.Bottom:n=e.x,a=t.y,t.x>e.x&&t.ye.y&&(n=e.x,a=t.y),s.push({x:n,y:a});break;case Lt.Bottom:e.y>t.y?(n=t.x,a=e.y):(n=e.x,a=t.y),s.push({x:n,y:a});break;case Lt.Left:n=t.x,a=e.y,t.x>e.x&&t.y>e.y&&(n=e.x,a=t.y),s.push({x:n,y:a});break;default:if(n=e.x,t.ye.y&&(n=t.x,a=e.y),s.push({x:n,y:a});break;case Lt.Bottom:n=e.x,a=t.y,t.xe.x)n=t.x,a=e.y+(t.y-e.y)/2,s.push({x:e.x,y:a},{x:t.x,y:a});else{const r=(e.x+t.x)/2;s.push({x:r,y:e.y},{x:r,y:t.y})}break;case Lt.Left:t.x>e.x?s.push({x:e.x,y:t.y}):s.push({x:t.x,y:e.y});break;default:if(n=e.x,a=t.y,t.xMath.abs(i.y-t.y));let n=e.calculative.worldAnchors.findIndex(a=>a.id==t.id);if(n>1){let a=e.calculative.worldAnchors[n-1];if(a.x===t.x&&a.y!==t.y)return s.push({x:i.x,y:t.y}),s;if(a.y===t.y&&a.x!==t.x)return s.push({x:t.x,y:i.y}),s}return e.calculative.worldAnchors.length&&(i.isTemp=void 0,e.calculative.drawlineH?(s.push({x:i.x,y:t.y}),Math.abs(i.y-t.y){s.unshift(r)}));for(let r=0;r{s.unshift(r)}));for(let r=0;ro.id===t.id),n=le(e),a=$t(e);let r=e.calculative.worldAnchors[s-1],l=e.calculative.worldAnchors[s+1];if(e.calculative.h==null&&(n.connectTo&&(br(e,t,!0)?e.calculative.h=!0:xr(e,t,!0)&&(e.calculative.h=!1)),e.calculative.h==null&&a.connectTo&&(br(e,t,!1)?e.calculative.h=!0:xr(e,t,!1)&&(e.calculative.h=!1)),e.calculative.h==null&&(r?e.calculative.h=r.y===t.y:l&&(e.calculative.h=l.y===t.y))),e.calculative.h){if(t.x=i.x,n.connectTo&&br(e,t,!0)){l&&l.y!==t.y&&(l.x=t.x);return}if(a.connectTo&&br(e,t,!1)){r&&r.y!==t.y&&(r.x=t.x);return}const o=e.anchors[s];let u;for(let c=s-1;c>-1;c--)if(r=e.anchors[c],u==null&&(u=r.y===o.y),u===!0)if(r.y===o.y)e.calculative.worldAnchors[c].y=i.y;else break;else if(r.x===o.x)e.calculative.worldAnchors[c].x=i.x;else break;u=void 0;for(let c=s+1;c-1;c--)if(r=e.anchors[c],u==null&&(u=r.x===o.x),u===!0)if(r.x===o.x)e.calculative.worldAnchors[c].x=i.x;else break;else if(r.y===o.y)e.calculative.worldAnchors[c].y=i.y;else break;u=void 0;for(let c=s+1;c1?(u=w.x-y.x,c=w.y-y.y):m>0?(u=w.x-(l+f*m),c=w.y-(o+g*m)):(u=w.x-l,c=w.y-o)):(u=w.x-l,c=w.y-o),_=u*u+c*c,_>a&&(r=x,a=_);return a>t&&(r-i>1&&n.push(...sc(e,t,i,r)),n.push({id:e[r].id,penId:e[r].penId,x:e[r].x,y:e[r].y}),s-r>1&&n.push(...sc(e,t,r,s))),n}function D2(e,t=.8,i=!1){if(e.length<3)return e;let s,n,a,r,l,o,u,c,f,g,v,y,w,m,_;const E=(x,C,S,L)=>(r=Math.sqrt(x*x+C*C),r>0?(y=x/r,m=C/r):(y=1,m=0),l=Math.sqrt(S*S+L*L),l>0?(w=S/l,_=L/l):(w=1,_=0),Math.acos(y*w+m*_));g=[],v=e.length,s=e[0],e[v-1],g.push({...e[0]});for(let x=0;x1){let c,f=0;for(let g=0;gr)&&m>o+r&&_-m>o&&(e.lineAnimateType===We.Arrow?B2(i,w,a,y,u,r):e.lineAnimateType===We.WaterDrop&&O2(i,w,e.animateReverse,y,u,r)),w.x+=l*Math.cos(y*Math.PI/180),w.y-=l*Math.sin(y*Math.PI/180),m=Math.sqrt((w.x-c.x)**2+(w.y-c.y)**2)}c=v}}if(i instanceof Path2D)return i}function M2(e,t){let i=t.x-e.x,s=t.y-e.y,n=Math.atan(s/i)*180/Math.PI;return t.x>=e.x?n=-n:n=180-n,n}function vs(e,t,i){let s=(180-i)*Math.PI/180;return{x:(e.x-t.x)*Math.cos(s)-(e.y-t.y)*Math.sin(s)+t.x,y:(e.x-t.x)*Math.sin(s)+(e.y-t.y)*Math.cos(s)+t.y}}function B2(e,t,i,s,n,a){let r=vs({x:t.x+i,y:t.y+.57*i},{x:t.x,y:t.y},s),l=vs({x:t.x+i,y:t.y-.57*i},{x:t.x,y:t.y},s),o=vs({x:t.x+i,y:t.y+n/2},{x:t.x,y:t.y},s),u=vs({x:t.x+a,y:t.y+n/2},{x:t.x,y:t.y},s),c=vs({x:t.x+i,y:t.y-n/2},{x:t.x,y:t.y},s),f=vs({x:t.x+a,y:t.y-n/2},{x:t.x,y:t.y},s);e.moveTo(r.x,r.y),e.lineTo(t.x,t.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.lineTo(f.x,f.y),e.lineTo(u.x,u.y),e.lineTo(o.x,o.y),e.lineTo(r.x,r.y)}function O2(e,t,i,s,n,a){let r=n/2;i&&(r=-n/2);let l=vs({x:t.x,y:t.y+r},{x:t.x,y:t.y},s),o=vs({x:t.x+a,y:t.y},{x:t.x,y:t.y},s),u=Math.PI/2;i&&(u=-Math.PI/2),e.moveTo(t.x,t.y),e.arc(t.x,t.y,n/2,-u-s/180*Math.PI,u-s/180*Math.PI,!1),e.lineTo(o.x,o.y),e.lineTo(l.x,l.y)}function F2(e){var i;e.onDestroy||(e.onDestroy=N2,e.onMove=_r,e.onResize=_r,e.onRotate=_r,e.onValue=_r,e.onMouseMove=H2,e.onBeforeValue=z2,e.onRenderPenRaw=W2),e.calculative.singleton||(e.calculative.singleton={});const t=e.calculative.worldRect;if(!e.calculative.singleton.div){const s=document.createElement("div");s.style.position="absolute",s.style.outline="none",s.style.left="-9999px",s.style.top="-9999px",s.style.width=t.width+"px",s.style.height=t.height+"px",document.body.appendChild(s),(i=e.calculative.canvas.externalElements)==null||i.parentElement.appendChild(s),Re(e,s),e.calculative.singleton.div=s;const n=document.createElement("iframe");n.style.width="100%",n.style.height="100%",n.scrolling=e.scrolling||"no",n.frameBorder="0",n.style.border="none",n.src=e.iframe,e.calculative.iframe=e.iframe,s.appendChild(n),vg(e),n.onload=()=>{n.setAttribute("document.domain","")}}return e.calculative.patchFlags&&Re(e,e.calculative.singleton.div),e.onRenderPenRaw(e),new Path2D}function N2(e){yg(e),e.calculative.singleton&&e.calculative.singleton.div&&(e.calculative.singleton.div.remove(),delete e.calculative.singleton.div)}function _r(e){e.calculative.singleton.div&&Re(e,e.calculative.singleton.div)}function z2(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=ht(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?vg(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 H2(e,t){if(!(!e.calculative.canvas.store.data.locked&&!e.locked)&&gg(e.operationalRect)&&e.calculative.zIndex<5&&t.x>e.x+e.width*e.operationalRect.x&&t.xe.y+e.height*e.operationalRect.y&&t.y{yg(e)};i.onmouseenter=r,n.onmouseenter=r,s.onmouseenter=r,a.onmouseenter=r,t.onmouseleave=r}function yg(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 W2(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 $e={},Dr=['',''];function U2(e){var t;if(e.onDestroy||(e.onDestroy=$2,e.onMove=Dl,e.onResize=Dl,e.onRotate=Dl,e.onClick=Mf,e.onValue=V2,e.onChangeId=j2),$e[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"),s=document.createElement("div");s.style.position="absolute",s.style.outline="none",s.style.left="0",s.style.bottom="0",s.style.width="0",s.style.height="2px",s.style.background="#52c41a",s.style.zIndex="1",e.hideProgress&&(s.style.display="none");const n=document.createElement("div");n.innerHTML=Dr[1],n.style.position="absolute",n.style.right="0",n.style.bottom="0",n.style.width="20px",n.style.height="20px",n.style.fill="hsla(0, 0%, 100%, .8)",n.style.zIndex="1",n.style.display="none",i.appendChild(s),i.appendChild(n),n.onclick=r=>{r.stopPropagation(),e.calculative.media.muted?(n.innerHTML=Dr[0],e.calculative.media.muted=!1):(n.innerHTML=Dr[1],e.calculative.media.muted=!0)},e.calculative.singleton||(e.calculative.singleton={}),e.calculative.singleton.muted=n,i.onmouseenter=r=>{e.hideMuted||(n.style.display="block")},i.onmouseleave=r=>{n.style.display="none"},i.onclick=r=>{r.stopPropagation(),Mf(e)};let a;e.audio?(a=document.createElement("audio"),a.controls=e.controls,a.src=e.audio):(a=document.createElement("video"),a.src=e.video),a.loop=e.playLoop,a.ontimeupdate=()=>{mg(s,a,e.calculative.worldRect.width)},a.onended=()=>{e.calculative.onended&&e.calculative.onended(e)},e.calculative.media=a,a.style.position="absolute",a.style.outline="none",a.style.left="0",a.style.top="0",a.style.width="100%",a.style.height="100%",a.style.objectFit=e.objectFit||"contain",i.appendChild(a),$e[e.id]=i,(t=e.calculative.canvas.externalElements)==null||t.parentElement.appendChild(i),Re(e,i),e.autoPlay&&(a.autoplay=!0,a.muted=!0)}return e.calculative.patchFlags&&Re(e,$e[e.id]),new Path2D}function $2(e){$e[e.id].onclick=null,$e[e.id].remove(),$e[e.id]=void 0}function Dl(e){Re(e,$e[e.id]);const t=$e[e.id].children[0],i=$e[e.id].children[1];mg(t,i,e.calculative.worldRect.width)}function Mf(e){e.calculative.media&&(e.calculative.media.muted=!1,e.calculative.singleton.muted.innerHTML=Dr[0],e.calculative.media.paused?e.calculative.media.play():e.calculative.media.pause())}function mg(e,t,i){e.style.width=t.currentTime/t.duration*i+"px"}function j2(e,t,i){!$e[t]||($e[i]=$e[t],delete $e[t])}function V2(e){const t=$e[e.id];if(!t)return;Re(e,t),e.calculative.media||(e.calculative.media=t.querySelector("video"));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 Pi(){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 oa{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 s;for(let n=0;n0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#777777"):(r+=s.height+n.height+5,this.arrowUp.style.borderBottomColor="#777777",this.arrowDown.style.borderTopColor="transparent"),this.x=a,this.y=r,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 pg{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 s=0;s=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().height0?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 Bf{constructor(t,i,s){W(this,"parentElement");W(this,"store");W(this,"isBottom");W(this,"canvas",document.createElement("canvas"));W(this,"otherOffsreen",Pi());W(this,"offscreen",Pi());W(this,"animateOffsScreen",Pi());W(this,"fitOffscreen",Pi());W(this,"fitFlag",!1);W(this,"currentFit");W(this,"activeFit");this.parentElement=t,this.store=i,this.isBottom=s,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 r;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(ti(l,!0))&&(i=!0));const s=this.store.patchFlagsBackground,n=this.store.patchFlagsTop;if(n&&!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 o of this.store.data.pens)!o.calculative.hasImage||this.store.animates.has(o)||this.store.animates.has(ti(o,!0))||o.canvasLayer!==zt.CanvasTemplate&&(o.calculative.imageDrawed=!0,l.save(),zs(l,o),o.calculative.rotate&&Gi(l,o),Hs(l,o),En(l,o),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 o of this.store.animates)!o.calculative.hasImage||o.canvasLayer!==zt.CanvasTemplate&&(o.visible===!1||o.calculative.visible===!1||(o.calculative.imageDrawed=!0,l.save(),zs(l,o),o.calculative.rotate&&Gi(l,o),Hs(l,o),En(l,o),l.restore()));for(const o of this.store.data.pens)!o.calculative.hasImage||!o.parentId||o.canvasLayer!==zt.CanvasTemplate&&(o.visible===!1||o.calculative.visible===!1||this.store.animates.has(ti(o,!0))&&(o.calculative.imageDrawed=!0,l.save(),zs(l,o),o.calculative.rotate&&Gi(l,o),Hs(l,o),En(l,o),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,o=(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,c=this.store.data.origin.y+this.store.data.y||this.store.options.y||0,f=this.fitOffscreen.getContext("2d");f.save(),f.clearRect(0,0,this.canvas.width,this.canvas.height),f.fillStyle="#ffffff66",f.strokeStyle=this.store.styles.activeColor,(r=this.store.data.fits)==null||r.forEach((g,v)=>{f.fillRect(u+l*g.x,c+o*g.y,l*g.width,o*g.height),g.active&&f.strokeRect(u+l*g.x,c+o*g.y,l*g.width,o*g.height)}),f.restore()}if(t||i||s&&this.isBottom||n&&!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,C,S,L,M,D,$,Q;const{data:i,options:s}=this.store,{rule:n,ruleColor:a,scale:r,origin:l}=i;if(!(n!=null?n:s.rule))return;const o=r*10;t.save();const u=a||s.ruleColor||"#ccc";t.strokeStyle=Wr(u,.7);const c=l.x+i.x,f=l.y+i.y,{width:g,height:v}=this.canvas;let y=((x=s.ruleOptions)==null?void 0:x.height)||20;(C=s.ruleOptions)!=null&&C.background&&(t.beginPath(),t.fillStyle=(S=s.ruleOptions)==null?void 0:S.background,t.rect(0,0,g,y),t.fill(),t.rect(0,0,y,v),t.fill()),(L=s.ruleOptions)!=null&&L.underline&&(t.beginPath(),t.fillStyle=Wr(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;((M=s.ruleOptions)==null?void 0:M.baseline)==="bottom"&&(w=y*3/4),t.beginPath(),t.lineWidth=y/2,t.lineDashOffset=-c%o,t.setLineDash([1,o-1]),t.moveTo(0,w),t.lineTo(g,w),t.stroke(),t.beginPath(),t.lineDashOffset=-f%o,t.moveTo(w,0),t.lineTo(w,v),t.stroke(),t.strokeStyle=u,t.beginPath(),t.lineWidth=y,t.lineDashOffset=-c%(o*10),t.setLineDash([1,o*10-1]),t.moveTo(0,y/2),t.lineTo(g,y/2),t.stroke(),t.beginPath(),t.lineDashOffset=-f%(o*10),t.moveTo(y/2,0),t.lineTo(y/2,v),t.stroke(),t.beginPath(),t.fillStyle=((D=s.ruleOptions)==null?void 0:D.textColor)||t.strokeStyle;let m=0-Math.floor(c/o/10)*100,_=(($=s.ruleOptions)==null?void 0:$.textTop)||16,E=((Q=s.ruleOptions)==null?void 0:Q.textLeft)||4;c<0&&(m-=100);for(let R=c%(o*10);R{s.drawImage(o,n.x-t,n.y-t,this.magnifierSize,this.magnifierSize,0,0,this.magnifierSize,this.magnifierSize)}),s.restore(),s.beginPath();const r=s.createRadialGradient(t,t,t-5,t,t,t);r.addColorStop(0,"rgba(0,0,0,0.2)"),r.addColorStop(.8,"rgb(200,200,200)"),r.addColorStop(.9,"rgb(200,200,200)"),r.addColorStop(1,"rgba(200,200,200,0.9)"),s.strokeStyle=r,s.arc(t,t,t,0,Math.PI*2,!1),s.stroke(),s.restore(),this.offscreen.getContext("2d").drawImage(this.magnifierScreen,0,0,this.magnifierSize+5,this.magnifierSize+5,(n.x-t-2.5)/this.store.dpiRatio,(n.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:s,y:n,width:a,height:r}=i.calculative.worldRect;t.drawImage(i.calculative.img,s,n,a,r),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 wg(e){if(e.data.locked)throw new Error("canvas is locked")}class Y2{constructor(t,i){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");W(this,"meta2dDiv");W(this,"dialogMeta2d");W(this,"store");this.parentElement=t,this.store=i,this.box=document.createElement("div"),this.dialog=document.createElement("div");let s=document.createElement("div");this.title=document.createElement("div"),this.close=document.createElement("span"),this.close.innerHTML=` `,this.body=document.createElement("div"),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.meta2dDiv=document.createElement("div"),this.box.className="meta2d-dialog_mask",this.dialog.className="meta2d-dialog",this.body.className="meta2d-dialog_body",s.className="meta2d-dialog_header",this.title.className="meta2d-dialog-content",this.close.className="meta2d-dialog-close",this.meta2dDiv.className="meta2d-dialog-meta2d",s.appendChild(this.title),s.appendChild(this.close),this.body.appendChild(this.iframe),this.body.appendChild(this.meta2dDiv),this.dialog.appendChild(s),this.dialog.appendChild(this.body),this.box.appendChild(this.dialog),t.appendChild(this.box),this.dialog.onclick=a=>{a.stopPropagation()},this.box.onclick=()=>{this.hide()},this.close.onclick=()=>{this.hide()};let n;for(let a=0;a{this.iframe.contentWindow.meta2d&&(clearInterval(l),setTimeout(()=>{this.iframe.contentWindow.postMessage(JSON.stringify({name:"dialog",data:n}),"*")},100)),r++,r>50&&clearInterval(l)},300)}if((!this.dialogMeta2d||a)&&(this.box.style.display="block"),!a){this.meta2dDiv.style.display="block",this.dialogMeta2d||(globalThis.mainMeta2d=globalThis.meta2d,this.dialogMeta2d=new Ak(this.meta2dDiv),globalThis.meta2d=globalThis.mainMeta2d);const r=await $d(this.store,i);r&&(this.box.style.display="block",this.dialogMeta2d.clear(!0),this.dialogMeta2d.open(r,!1),this.dialogMeta2d.lock(1),this.dialogMeta2d.resize(),this.dialogMeta2d.fitView(!0,0),this.dialogMeta2d.render(!0))}}hide(){this.box.style.display="none"}isUrl(t){return!!(t.startsWith("http")||t.includes("?")||t.includes("/"))}destroy(){var t;this.dialog.onclick=void 0,this.box.onclick=void 0,this.close.onclick=void 0,(t=this.dialogMeta2d)==null||t.destroy(!0)}}class Kr{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 s=0;s{const f=c.x*n.x+c.y*n.y;l=Math.min(l,f),o=Math.max(o,f)});const u=Math.ceil((o-l)/s);e.beginPath();for(let c=0;c<=u;c++){const f=l+c*s;let g=[];for(let v=0;v1e-6){const _=(f-y.x*n.x-y.y*n.y)/(n.x*(w.x-y.x)+n.y*(w.y-y.y));if(_>=0&&_<=1){const E=y.x+_*(w.x-y.x),x=y.y+_*(w.y-y.y);g.push({x:E,y:x})}}}g.length>=2&&(e.moveTo(g[0].x,g[0].y),e.lineTo(g[1].x,g[1].y))}e.stroke()}function Ff(e,t,i,s,n,a,r,l){const o=[{x:t,y:i},{x:t+s,y:i},{x:t+s,y:i+n},{x:t,y:i+n}];let u=1/0,c=-1/0;o.forEach(y=>{const w=y.x*r.x+y.y*r.y;u=Math.min(u,w),c=Math.max(c,w)});const f=c-u,g=Math.ceil(f/a),v=u;e.beginPath();for(let y=0;y<=g;y++){const w=v+y*a,m=[];for(let _=0;_1e-6){const M=(w-E.x*r.x-E.y*r.y)/(r.x*C+r.y*S);M>=0&&M<=1&&m.push({x:E.x+M*C,y:E.y+M*S})}}m.length>=2&&(e.moveTo(m[0].x,m[0].y),e.lineTo(m[1].x,m[1].y))}e.stroke()}const X2={success:{},info:{icon:''},warning:{},error:{}};class G2{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=X2.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 s;for(let n=0;n0?(this.arrowUp.style.borderBottomColor="transparent",this.arrowDown.style.borderTopColor="#fff",r-=10):(r+=s.height+n.height+5,r+=10,this.arrowUp.style.borderBottomColor="#fff",this.arrowDown.style.borderTopColor="transparent"),this.x=a,this.y=r,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,s){return new Promise(n=>{this.text.innerHTML=s||"\u786E\u8BA4\u6267\u884C\u64CD\u4F5C\u5417\uFF1F",this.show(t,i),this.confirm.onclick=()=>{n(!0),this.hide()},this.cancel.onclick=()=>{n(!1),this.hide()}})}destroy(){this.box=null}}const He="-moving";class Nf{constructor(t,i,s){W(this,"parent");W(this,"parentElement");W(this,"store");W(this,"canvas",document.createElement("canvas"));W(this,"offscreen",Pi());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",[...ux]);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",m2);W(this,"polyline",C2);W(this,"mind",w2);W(this,"line",x2);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",async 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 s=t.clipboardData.items;if(s){for(let n=0;n{if(typeof t.data!="string"||!t.data||t.data.startsWith("setImmediate")||t.data.startsWith("webpackHotUpdate"))return;let i=JSON.parse(t.data);typeof i=="object"?this.parent.doMessageEvent(i.name,JSON.stringify(i.data)):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 a=this.store.data.scale||1;this.translate(-t.deltaX/a,-t.deltaY/a);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 r=.2;t.deltaY.toString().indexOf(".")!==-1&&(r=.01),t.deltaY>0?i=-r:i=r}let{offsetX:s,offsetY:n}=t;this.scale(this.store.data.scale+i,{x:s,y:n}),this.externalElements.focus()});W(this,"onkeydown",t=>{var a,r,l;if(this.store.data.locked>=Ot.DisableEdit&&t.target.tagName!=="INPUT"&&t.target.tagName!=="TEXTAREA"&&!t.target.dataset.meta2dIgnore&&this.store.active.forEach(o=>{var u;(u=o.onKeyDown)==null||u.call(o,o,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,this.keyOptions.F=!1,(t.key==="F"||t.key==="f")&&(this.keyOptions.F=!0);let i=10,s=10,n=null;if(this.store.options.strictScope){const o=this.store.data.width||this.store.options.width,u=this.store.data.height||this.store.options.height;o&&u&&(n={x:this.store.data.origin.x,y:this.store.data.origin.y,width:o*this.store.data.scale,height:u*this.store.data.scale})}switch(t.key){case" ":this.hotkeyType=Yt.Translate;break;case"Control":this.drawingLine?this.drawingLine.calculative.drawlineH=!this.drawingLine.calculative.drawlineH:this.hotkeyType||(this.patchFlags=!0,this.hotkeyType=Yt.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=Yt.Resize));break;case"Alt":if(!t.ctrlKey&&!t.shiftKey&&this.drawingLine){const o=$t(this.drawingLine);o!==this.drawingLine.calculative.activeAnchor?(bc(this.drawingLine),this.drawingLine.calculative.worldAnchors.push(o)):this.drawingLine.calculative.worldAnchors.push({x:o.x,y:o.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(o=>!o.parentId&&o.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}n&&this.activeRect.x+in.x+n.width&&(i=n.x+n.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(s=1,t.shiftKey&&(s=5),(t.ctrlKey||t.metaKey)&&(s=10),s=s*this.store.data.scale,n&&this.activeRect.y+this.activeRect.height+s>n.y+n.height&&(s=n.y+n.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+s},{});break}this.translatePens(this.store.active,0,s);break;case"d":case"D":(a=this.store.active[0])!=null&&a.locked||this.removeAnchorHand();break;case"h":case"H":(r=this.store.active[0])!=null&&r.locked||this.addAnchorHand();break;case"m":case"M":this.toggleMagnifier();break;case"g":case"G":if(t.ctrlKey||t.metaKey){t.shiftKey?this.parent.uncombine():this.store.active.length>1&&this.parent.combine(this.store.active),t.preventDefault();break}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(o=>{o.type?(o.close=!o.close,o.close&&ug(o),this.store.path2dMap.set(o,kt.path2dDraws.line(o)),Yr(o)):o.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(o=>{o.type||(o.calculative.focus=!1)}),this.movingPens&&(this.getAllByPens(this.movingPens).forEach(o=>{this.store.pens[o.id]=void 0}),this.movingPens=void 0,this.mouseDown=void 0,this.clearDock(),(l=this.store.active)==null||l.forEach(o=>{this.updateLines(o)}),this.calcActiveRect(),this.patchFlags=!0),this.hotkeyType=Yt.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.store.data.locked&&(t.ctrlKey||t.metaKey)&&!this.store.options.disableClipboard&&this.paste(),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{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 s=null;try{i&&(s=JSON.parse(i))}catch{}if(!s){const{files:n}=t.dataTransfer;if(n.length&&n[0].type.match("image.*")&&!(this.addCaches&&this.addCaches.length)){const a=n[0].type==="image/gif";s=await this.fileToPen(n[0],a)}else if(this.addCaches&&this.addCaches.length)s=this.addCaches,this.addCaches=[];else{this.store.emitter.emit("drop",void 0);return}}if(s=Array.isArray(s)?s:[s],s[0]&&s[0].draggable!==!1){const n={x:t.offsetX,y:t.offsetY};this.calibrateMouse(n),this.dropPens(s,n),this.addCaches=[],this.getContainerHover(n),this.mousePos.x=n.x,this.mousePos.y=n.y,this.store.emitter.emit("mouseup",{x:n.x,y:n.y,pen:this.store.hoverContainer})}this.store.emitter.emit("drop",s||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,s=t.touches[0].pageY-this.clientRect.y,n={x:i,y:s};if(this.calibrateMouse(n),this.getHover(n),this.onMouseDown({x:i,y:s,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:s,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 s=t.touches,n=s.length,a=t.touches[0].pageX-this.clientRect.x,r=t.touches[0].pageY-this.clientRect.y;if(n===1)this.onMouseMove({x:a,y:r,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(n===2&&((l=this.startTouches)==null?void 0:l.length)===2){if(!this.touchMoving&&!this.touchScaling){const o=this.startTouches[0].pageX-s[0].pageX,u=this.startTouches[1].pageX-s[1].pageX,c=this.startTouches[0].pageY-s[0].pageY,f=this.startTouches[1].pageY-s[1].pageY;(o>=0&&u<0||o<=0&&u>0)&&(c>=0&&f<0||c<=0&&f>0)?this.touchScaling=!0:this.touchMoving=!0}if(this.touchScaling){if(this.store.data.disableScale||this.store.options.disableScale)return;const o=Math.hypot(s[0].pageX-s[1].pageX,s[0].pageY-s[1].pageY)/this.initTouchDis;this.scale(this.initScale*o,ht(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:o}=this.store.data;this.translate((a-this.lastOffsetX)/o,(r-this.lastOffsetY)/o)}this.lastOffsetX=a,this.lastOffsetY=r}}});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,s=t.changedTouches[0].pageY-this.clientRect.y;this.onMouseUp({x:i,y:s,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,s,n,a,r;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===Yt.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 o={id:It(),x:l.x,y:l.y};this.drawingLine=this.createDrawingLine(o);let u=le(this.drawingLine);this.drawingLine.calculative.activeAnchor=u,we(this.store.hover,l,this.drawingLine,o),this.drawline();return}if(!(this.hotkeyType===Yt.Translate||this.mouseRight===$i.Down&&!this.store.options.mouseRightActive)){if(this.drawingLine){if(this.store.hoverAnchor){const o=$t(this.drawingLine);this.store.hoverAnchor.type===ji.Line?yr(o,this.store.hoverAnchor,this.store):(o.x=this.store.hoverAnchor.x,o.y=this.store.hoverAnchor.y),we(this.store.hover,this.store.hoverAnchor,this.drawingLine,o),this.drawline(),this.finishDrawline(!0);return}if(!this.store.options.autoAnchor&&t.shiftKey&&t.altKey&&t.ctrlKey){this.setAnchor(this.store.pointAt);const o=$t(this.drawingLine),u=this.store.activeAnchor;if(!u)return;o.x=u.x,o.y=u.y,we(this.store.hover,u,this.drawingLine,o),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&&((s=this.drawingLine)==null?void 0:s.calculative.worldAnchors.length)>this.store.options.drawingLineLength){this.finishDrawline(!0),((n=this.store.active[0])==null?void 0:n.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 o=$t(this.drawingLine),u=xn(this.store.hover,t);o.x=u.x,o.y=u.y,this.drawingLine.autoTo=!0,we(this.store.hover,u,this.drawingLine,o),this.drawline(),this.finishDrawline(!0);return}const l=$t(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=xn(this.store.hover,t);this.store.hoverAnchor=l;const o={id:It(),x:l.x,y:l.y};this.drawingLine=this.createDrawingLine(o),this.drawingLine.autoFrom=!0,we(this.store.hover,l,this.drawingLine,o)}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(),o={x:t.x,y:t.y,id:It(),penId:l};this.pencilLine=this.getInitPencilLine(o)}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=Yt.None),this.inactive();break;case xt.Node:case xt.Line:if(this.store.hover){if(((a=this.store.active)==null?void 0:a.length)&&this.store.active.length===1&&this.store.hover.id===this.store.active[0].id){this.calcActiveRect();break}const l=ti(this.store.hover,!0);let o=l||this.store.hover;l&&(l.container||((r=this.store.options.containerShapes)==null?void 0:r.includes(l.name)))&&(o=this.store.hover),t.ctrlKey&&!t.shiftKey?(o.calculative.active?this.willInactivePen=o:this.store.active.length>0&&(o.calculative.active=!0,pn(o),this.store.active.push(o),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&&Ui({x:t.x,y:t.y},this.activeRect))||this.store.active.length==1)&&(o.calculative.active||(this.active([o]),this.store.options.resizeMode&&(this.hotkeyType=Yt.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 s,n,a,r,l,o,u,c;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 f=performance.now();f-this.fitTimer>100&&(this.mouseDown?this.updateFit(t):this.inFitBorder(this.mousePos),this.fitTimer=f);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===Yt.Translate||this.mouseRight===$i.Translate){const{scale:f}=this.store.data;let g=(t.x-this.mouseDown.x)/f,v=(t.y-this.mouseDown.y)/f;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 f={id:It(),x:this.store.hoverAnchor.x,y:this.store.hoverAnchor.y};this.drawingLine=this.createDrawingLine(f),this.drawingLine.calculative.activeAnchor=f,we(this.store.hover,this.store.hoverAnchor,this.drawingLine,f),this.drawline();return}}else if(this.drawingLineName&&this.hoverType===xt.None){const f={id:It(),x:t.x,y:t.y};this.drawingLine=this.createDrawingLine(f),this.drawingLine.calculative.activeAnchor=f,this.drawline();return}if(t.buttons===1&&(t.ctrlKey||!this.hoverType&&!this.hotkeyType)&&!(t.ctrlKey&&(this.store.activeAnchor||((s=this.store.active)==null?void 0:s.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 f=t.x-this.movingAnchor.x,g=t.y-this.movingAnchor.y;this.translateAnchor(f,g),this.render();return}else if(!((n=this.store.active[0])!=null&&n.locked)){const f={x:t.x,y:t.y};if(this.hoverType===xt.LineAnchor){(this.dockInAnchor(t)||((a=this.store.active[0])==null?void 0:a.lineName)==="line")&&!this.store.options.disableDock&&!this.store.options.disableLineDock&&(this.clearDock(),this.dock=_f(this.store,f,this.store.activeAnchor),(r=this.dock)!=null&&r.xDock&&(f.x+=this.dock.xDock.step),(l=this.dock)!=null&&l.yDock&&(f.y+=this.dock.yDock.step)),this.moveLineAnchor(f,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 f=t.x-this.mouseDown.x,g=t.y-this.mouseDown.y,v=20;if(t.ctrlKey&&!t.shiftKey&&(Math.abs(f)>=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.locked1&&(y=$t(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!==ji.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===Yt.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=$t(this.drawingLine);this.store.hoverAnchor.type===ji.Line?yr(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=$t(this.drawingLine),s=xn(this.store.hover,t);i.x=s.x,i.y=s.y,this.drawingLine.autoTo=!0,we(this.store.hover,s,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],s=le(i),n=$t(i);if(this.store.hoverAnchor){const a=this.store.hover,r=le(a)===this.store.hoverAnchor,l=$t(a)===this.store.hoverAnchor,o=s===this.store.activeAnchor,u=n===this.store.activeAnchor;if((t.ctrlKey||t.altKey)&&a.type===jt.Line&&(r||l)&&(o||u)){const c=a.calculative.worldAnchors.map(f=>({...f,penId:i.id}));r?c.shift():l&&c.pop(),(r&&o||l&&u)&&c.reverse(),o?(i.calculative.worldAnchors[0].connectTo=void 0,i.calculative.worldAnchors.unshift(...c)):u&&(i.calculative.worldAnchors[i.calculative.worldAnchors.length-1].connectTo=void 0,i.calculative.worldAnchors.push(...c)),this.delete([a]),this.render()}else this.store.activeAnchor&&(this.store.hoverAnchor.type===ji.Line?yr(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,kt.path2dDraws.line(i)),this.initLineRect(i)}else s===this.store.activeAnchor&&i.autoFrom?this.calcAutoAnchor(i,s,this.store.hover):n===this.store.activeAnchor&&i.autoTo&&this.calcAutoAnchor(i,n,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(s=>{if(s.visible===!1||s.locked>=Ot.DisableMove||s.parentId||s.isRuleLine)return!1;if(Xi(s.calculative.worldRect,this.dragRect,t.ctrlKey||this.store.options.dragAllIn))return s.type===jt.Line&&!this.store.options.dragAllIn?Ll(s,this.dragRect):!0});this.active(i)}if(t.button!==2&&(Qr(this.mouseDown,t)<2&&(this.store.hover&&this.store.hover.input&&(this.store.hover.onShowInput?this.store.hover.onShowInput(this.store.hover,t):(this.store.hover.parentId&&this.active([this.store.hover]),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,pn(this.willInactivePen,!1);const i=this.store.active.findIndex(s=>s===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 a,r,l,o;const t=(r=(a=this.dock)==null?void 0:a.xDock)==null?void 0:r.penId,i=(o=(l=this.dock)==null?void 0:l.yDock)==null?void 0:o.penId,s=this.store.pens[t];s&&(s.calculative.isDock=!1);const n=this.store.pens[i];n&&(n.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 s;if(this.dragRect)return;this.store.hoverContainer=void 0;const i=this.store.data.pens.filter(n=>{var a;return n.container||((a=this.store.options.containerShapes)==null?void 0:a.includes(n.name))});if(i.length)for(let n=i.length-1;n>=0;--n){const a=i[n];if(!(a.visible==!1||a.calculative.inView==!1||a.locked===Ot.Disable)){if(Ui(t,a.calculative.worldRect))this.store.hoverContainer=a,(s=a==null?void 0:a.onMouseMove)==null||s.call(a,a,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(a===this.store.hoverContainer&&(this.store.hoverContainer=void 0,this.store.lastHoverContainer!==this.store.hoverContainer)){this.patchFlags=!0;const r=this.store.lastHoverContainer.calculative.canvas.store.pens[this.store.lastHoverContainer.id+He];this.store.lastHoverContainer&&!r&&(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 n,a;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 s=this.store.active.length===1&&this.store.active[0].type;if(!this.drawingLineName&&this.hotkeyType!==Yt.AddAnchor&&this.activeRect&&!s&&!this.store.data.locked){const r=Pl(this.store.active),l=wf(this.store.active)||this.store.options.disableRotate,o=bf(this.store.active)||this.store.options.disableSize;if(!r&&!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&&mn(t,u,this.pointSize)&&(i=xt.Rotate,this.externalElements.style.cursor=`url("${this.store.options.rotateCursor}"), auto`)}if(!r&&!o)for(let u=0;u<8;u++){const c=u<4;if((this.hotkeyType===Yt.Resize||c&&!this.hotkeyType)&&mn(t,this.sizeCPs[u],this.pointSize)){let g=c?hf:uf,v=0;Math.abs(this.activeRect.rotate%90-45)<25?(g=c?uf:hf,v=Math.round((this.activeRect.rotate-45)/90)+(c?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&&!s&&Ui(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,ea(ti(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,ea(ti(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),(a=(n=this.store.hover)==null?void 0:n.onMouseMove)==null||a.call(n,this.store.hover,this.mousePos)});W(this,"inPens",(t,i)=>{var n;let s=xt.None;t:for(let a=i.length-1;a>=0;--a){const r=i[a];if(r.visible==!1||r.calculative.inView==!1||r.locked===Ot.Disable)continue;const l=qr(r);if(!(!r.calculative.active&&!Ws(t,r.calculative.worldRect,l)&&!Ui(t,r.calculative.worldRect))){if(!this.store.data.locked&&this.hotkeyType!==Yt.Resize&&r.calculative.worldAnchors){for(const o of r.calculative.worldAnchors)if(s=this.inAnchor(t,r,o),s){let u=ht(o);Object.assign(u,t),this.title.show(u,r);break t}}if(r.type){if(r.isRuleLine){let u=((n=this.store.options.ruleOptions)==null?void 0:n.height)||20;if(t.x+this.store.data.x>u&&t.y+this.store.data.y>u)break}const o=_2(t,r);if(o){!this.store.data.locked&&!r.locked?this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="pointer":this.externalElements.style.cursor="move":this.externalElements.style.cursor=this.store.options.hoverCursor,r.calculative.disabled&&(this.externalElements.style.cursor="not-allowed"),this.store.hover=r,this.store.pointAt=o.point,this.store.pointAtIndex=o.i,this.initTemplateCanvas([this.store.hover]),s=xt.Line;break}}else{if(r.children){const u=[];if(r.children.forEach(c=>{this.store.pens[c]&&u.push(this.store.pens[c])}),s=this.inPens(t,u),s)break}let o=!1;if(r.name==="line"?o=Ws(t,r.calculative.worldRect,r.lineWidth):o=Ui(t,r.calculative.worldRect),o){if(r.type===jt.Node&&r.name==="line"&&!$_(t,r.calculative.worldAnchors))continue;if(!this.store.data.locked&&!r.locked?this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="pointer":this.externalElements.style.cursor="move":this.externalElements.style.cursor=this.store.options.hoverCursor,r.calculative.disabled&&(this.externalElements.style.cursor="not-allowed"),this.store.hover=r,this.initTemplateCanvas([this.store.hover]),s=xt.Node,this.store.pointAt=t,!t.ctrlKey){let{x:u,y:c,ex:f,ey:g,rotate:v,center:y}=this.store.hover.calculative.worldRect;if(v){const w=[{x:u,y:c},{x:f,y:c},{x:f,y:g},{x:u,y:g}];w.forEach(_=>{Gt(_,v,y)});let m=w[w.length-1];for(const _ of w){if(m.y>t.y!=_.y>t.y){const E=_.x+(t.y-_.y)*(m.x-_.x)/(m.y-_.y);Math.abs(E-this.store.pointAt.x)<10&&(this.store.pointAt.x=E)}m=_}}else this.store.pointAt.x-10f&&(this.store.pointAt.x=f),this.store.pointAt.y-10g&&(this.store.pointAt.y=g)}break}}}}return s});W(this,"dockInAnchor",t=>{var i,s;this.store.hover=void 0;for(let n=this.store.data.pens.length-1;n>=0;--n){const a=this.store.data.pens[n];if(a.visible==!1||a.locked===Ot.Disable||a===this.store.active[0])continue;let r=qr(a);if(r+=2*this.store.options.anchorRadius,!!Ws(t,a.calculative.worldRect,r)&&(this.store.hover=a,this.hotkeyType!==Yt.Resize&&a.calculative.worldAnchors))for(const l of a.calculative.worldAnchors){if(l.twoWay===Ee.In){const o=$t(this.store.active[0]);if(this.store.activeAnchor.id!==o.id)continue}if(l.twoWay===Ee.Out){const o=le(this.store.active[0]);if(this.store.activeAnchor.id!==o.id)continue}if(!(l.twoWay===Ee.DisableConnected||l.twoWay===Ee.Disable||((i=this.store.activeAnchor)==null?void 0:i.twoWay)===Ee.DisableConnectTo||((s=this.store.activeAnchor)==null?void 0:s.twoWay)===Ee.Disable)&&(this.title.hide(),this.inAnchor(t,a,l))){let o=ht(l);return Object.assign(o,t),this.title.show(o,a),!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{const t=this.offscreen.getContext("2d");t.strokeStyle=this.store.styles.color;for(const i of this.store.data.pens)!isFinite(i.x)||i.canvasLayer!==zt.CanvasTemplate&&i.calculative.inView&&(i.canvasLayer===zt.CanvasMain&&i.name!=="gif"&&i.image&&i.calculative.img&&(t.save(),zs(t,i),i.calculative.rotate&&Gi(t,i),Hs(t,i),En(t,i),t.restore()),Is(t,i));this.drawingLine&&Is(t,this.drawingLine),this.pencilLine&&Is(t,this.pencilLine),this.movingPens&&this.movingPens.forEach(i=>{this.renderPenContainChild(t,i)})});W(this,"renderPenContainChild",(t,i)=>{var s;i.calculative.inView&&Is(t,i),(s=i.children)==null||s.forEach(n=>{const a=this.store.pens[n];a&&this.renderPenContainChild(t,a)})});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.styles.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,Pl(this.store.active)||wf(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.styles.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!==Yt.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===Yt.AddAnchor&&i.push(this.store.pointAt),i&&(t.strokeStyle=this.store.hover.anchorColor||this.store.styles.anchorColor,t.fillStyle=this.store.hover.anchorBackground||this.store.options.anchorBackground,i.forEach(s=>{if(s.hidden&&s.locked>Ot.DisableEdit)return;if(s===this.store.hoverAnchor){t.save();const a=this.store.hover.hoverAnchorColor||this.store.options.hoverAnchorColor;t.strokeStyle=a,t.fillStyle=a}t.beginPath();let n=s.radius||this.store.hover.anchorRadius||this.store.options.anchorRadius;if(this.store.hover.type&&!s.radius&&!this.store.hover.anchorRadius&&(n=3,this.store.hover.calculative.lineWidth>3&&(n=this.store.hover.calculative.lineWidth)),s.type===ji.Line){let a=this.store.pens[s.penId].rotate||0;this.store.pens[s.penId].calculative.flipX&&(a*=-1),this.store.pens[s.penId].calculative.flipY&&(a*=-1);let r=s.rotate+a;this.store.pens[s.penId].calculative.flipX&&(r*=-1),this.store.pens[s.penId].calculative.flipY&&(r*=-1),t.save(),t.translate(s.x,s.y),t.rotate(r*Math.PI/180),t.translate(-s.x,-s.y),t.rect(s.x-s.length*this.store.data.scale/2,s.y-n,s.length*this.store.data.scale,n*2),t.restore()}else t.arc(s.x,s.y,n,0,Math.PI*2);if(this.store.hover.type&&this.store.hoverAnchor===s?(t.save(),t.strokeStyle=this.store.hover.activeColor||this.store.styles.activeColor,t.fillStyle=t.strokeStyle):(s.color||s.background)&&(t.save(),t.strokeStyle=s.color,t.fillStyle=s.background),t.fill(),t.stroke(),s===this.store.hoverAnchor&&t.restore(),(this.store.hover.type&&this.store.hoverAnchor===s||s.color||s.background)&&t.restore(),!this.store.hover.parentId&&this.store.hover.children&&this.store.hover.children.length>0&&s===this.store.hoverAnchor){t.save(),t.beginPath(),t.lineWidth=3;const a=this.store.hover.hoverAnchorColor||this.store.options.hoverAnchorColor;globalThis.pSBC&&(t.strokeStyle=globalThis.pSBC(.5,a)),t.arc(s.x,s.y,n+1.5,0,Math.PI*2),t.stroke(),t.restore()}}))}this.hotkeyType!==Yt.AddAnchor&&!this.movingPens&&this.activeRect&&!(this.store.active.length===1&&this.store.active[0].type)&&!Pl(this.store.active)&&!bf(this.store.active)&&!this.store.options.disableSize&&(t.strokeStyle=this.store.styles.activeColor,t.fillStyle="#ffffff",this.sizeCPs.forEach((i,s)=>{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)),(s<4||this.hotkeyType===Yt.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=Wr(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,"transTimeout");W(this,"pastePen",(t,i)=>{const s=t.id;if(kf(t),t.parentId=i,t.type===jt.Line?this.changeNodeConnectedLine(s,t,this.store.clipboard.pens):this.changeLineAnchors(s,t,this.store.clipboard.pens),!t.parentId){const a=this.getPenRect(t,this.store.clipboard.origin,this.store.clipboard.scale),r=this.getPenRect(this.store.clipboard.initRect,this.store.clipboard.origin,this.store.clipboard.scale),{origin:l,scale:o}=this.store.data;t.x=l.x+a.x*o,t.y=l.y+a.y*o,t.width=a.width*o,t.height=a.height*o,r.x=l.x+r.x*o,r.y=l.y+r.y*o,Qt(r),this.store.clipboard.pos&&(t.x-=r.center.x-this.store.clipboard.pos.x,t.y-=r.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||this.keyOptions.F)||(t.x+=this.store.clipboard.offset*this.store.data.scale,t.y+=this.store.clipboard.offset*this.store.data.scale)}this.makePen(t);const n=[];if(Array.isArray(t.children))for(const a of t.children){const r=this.store.clipboard.pens.find(l=>l.id===a);r&&n.push(this.pastePen(r,t.id).id)}return t.children=n,Yi(t,!0),t});W(this,"ondblclick",t=>{var i,s,n;if(this.store.hover&&(!this.store.data.locked||this.store.hover.dbInput)&&!this.store.options.disableInput)if(this.store.hover.onShowInput)this.store.hover.onShowInput(this.store.hover,t);else if(this.store.hover&&this.store.hover.parentId)if(((i=this.store.active)==null?void 0:i.length)===1&&this.store.active[0].id===this.store.hover.id)this.showInput(this.store.hover);else{if(this.store.pens[this.store.hover.parentId].children.forEach(a=>{this.store.pens[a].calculative.active=!1,this.store.pens[a].calculative.hover=!1}),this.store.hover.parentId){let a=this.store.hover.id;const r=this.calibrateMouse({x:t.offsetX,y:t.offsetY});let l=1/0;(n=(s=this.store.pens[this.store.hover.parentId])==null?void 0:s.children)==null||n.forEach(o=>{const u=this.store.pens[o];if(Ui(r,u.calculative.worldRect)){const c=Math.sqrt((r.x-u.calculative.worldRect.center.x)**2+(r.y-u.calculative.worldRect.center.y)**2);c{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 c=window.getSelection();c.selectAllChildren(this.inputDiv),c.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 n=i||t.calculative.worldTextRect,l=`${(t.calculative.tempText===void 0?t.text+""||"":t.calculative.tempText).replace(/\x20/g," ").split(/[\s\n]/).join("
")}
`.replace("","").replace(/\\<\/div\>/g,"

");this.inputDiv.innerHTML=l,this.inputParent.style.left=n.x+this.store.data.x-(t.calculative.textLeft||0)+"px",this.inputParent.style.top=n.y+this.store.data.y-(t.calculative.textTop||0)+"px";let o=n.width;this.inputParent.style.width=(o<0?12:o)+"px",this.inputParent.style.height=n.height+(t.textTop||0)+"px",this.inputParent.style.zIndex="9999",this.inputParent.style.background=s,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||this.store.styles.popContentBg||"#fff",this.dropdown.style.color=t.dropdownColor||"#bdc7db",this.dropdown.style.width=this.inputParent.style.width,this.dropdown.style.fontSize=(t.fontSize||12)+"px",this.setDropdownList(),this.externalElements.style.zIndex="9999"),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 o=0;o1?t.textLeft*a:t.textLeft*a/r}px;`),t.textTop&&(s+=`margin-top:${r>1?t.textTop*a:t.textTop*a/r}px;`),t.lineHeight&&(s+=`line-height:${r>1?t.fontSize*t.lineHeight*r:t.fontSize*t.lineHeight*a}px;`),t.textHeight)s+=`height:${r>1?t.textHeight*a*r:t.textHeight*a}px;`;else{let o=t.calculative.worldRect.height/r;o<0&&(o=0);let u=t.fontSize*r<12?o*a:o*r*a;u-1?t.textWidth*t.calculative.worldRect.width:t.textWidth,t.whiteSpace!=="pre-line"&&(l1?l*a*r:l*a}px;`);else if(t.whiteSpace===void 0||t.whiteSpace==="break-all"){let o=(t.calculative.worldTextRect.width||12)/r;o<0&&(o=0),s+=`width:${t.fontSize*r<12?o*a:o*r}px;`}if(t.whiteSpace&&(t.whiteSpace==="pre-line"?s+="white-space:pre;":(s+=`white-space:${t.whiteSpace};`,t.whiteSpace==="nowrap"&&(n+="display:contents;"))),t.whiteSpace!=="nowrap"){let o=t.fontSize*1.2*t.text.length,u=(l||t.calculative.worldRect.width/r)*Math.floor(t.calculative.worldRect.height/r/(t.lineHeight*t.fontSize));o>u&&(s+="justify-content: start;")}i.deleteRule(0),i.deleteRule(0),i.insertRule(`.meta2d-input .input-div{ 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;${s}}`),i.insertRule(`.input-div div{${n}}`)});W(this,"hideInput",()=>{if(this.externalElements.style.zIndex="5",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(/\/g,` `).replace(/\<\/div\>/g,"").replace(/\/g,"").replace(/ /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=[ht(t,!0)];t.text=this.inputDiv.dataset.value,t.calculative.text=t.text,this.inputDiv.dataset.penId=void 0,t.text&&t.textAutoAdjust&&!t.parentId&&Hx(t),Ri(t),this.patchFlags=!0,this.pushHistory({type:bt.Update,pens:[ht(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&&Ri(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 a=document.createElement("div");a.innerText="None",a.style.padding="5px 12px",a.style.color="#ddd",this.dropdown.appendChild(a);return}const s=this.inputDiv.innerHTML.replace(/\/g,` `).replace(/\<\/div\>/g,"").replace(/\/g,"");let n=0;for(const a of i.dropdownList){const r=typeof a=="string"?a:a.text;t&&s?r.includes(s)&&this.dropdownAppendOption(r,n):this.dropdownAppendOption(r,n),++n}if(!this.dropdown.hasChildNodes()){const a=document.createElement("div");a.innerText="None",a.style.padding="5px 12px",a.style.color="#ddd",this.dropdown.appendChild(a)}});W(this,"selectDropdown",t=>{const i=t.target,s=this.store.pens[this.inputDiv.dataset.penId];if(!i||!s||!s.dropdownList)return;const n=+i.dataset.i,a=s.dropdownList[n];if(!a)return;const r=[ht(s,!0)];typeof a=="object"?(this.updateValue(s,{...a}),s.calculative.text=void 0,this.calcActiveRect()):s.text=a+"",this.inputDiv.innerText=s.text,this.hideInput(),this.pushHistory({type:bt.Update,pens:[ht(s,!0)],initPens:r}),this.render(),this.store.emitter.emit("change",s),this.store.emitter.emit("valueUpdate",s)});W(this,"inFitBorder",t=>{let i;const s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height;let a={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 r=this.canvasImage.activeFit;this.externalElements.style.cursor="default",a.y>n*r.y-10&&a.yn*(r.y+r.height)-10&&a.ys*r.x-10&&a.xs*(r.x+r.width)-10&&a.x{this.patchFlags=!0,this.store.lastHover&&(this.store.lastHover.calculative.hover=!1);let a=this.store.data.pens.find(r=>r.calculative.hover===!0);ea(a,!1)},this.popconfirm=new G2(i,s),this.dialog=new Y2(i,s),this.title=new Kr(i),this.store.options.scroll&&(this.scroll=new pg(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 Ds.Document:document.addEventListener("keydown",this.onkeydown),document.addEventListener("keyup",this.onkeyup);break;case Ds.Canvas:this.externalElements.addEventListener("keydown",this.onkeydown),this.externalElements.addEventListener("keyup",this.onkeyup);break}}splitLine(t,i){const s=t.calculative.worldAnchors,n=s.findIndex(c=>c===i);if([-1,0,s.length-1].includes(n))return;const a=ht(t,!0),r=ht(t,!0),l=It();r.id=l,r.calculative.canvas=this,r.calculative.active=!1,r.calculative.hover=!1;const o=ht(s.slice(0,n+1)),u=ht(s.slice(n)).map(c=>(c.penId=l,c));t.calculative.worldAnchors=o,r.calculative.worldAnchors=u,this.initLineRect(t),this.initLineRect(r),this.store.data.pens.push(r),this.store.pens[l]=r,this.pushHistory({type:bt.Add,pens:[ht(r,!0)],step:2}),this.pushHistory({type:bt.Update,initPens:[a],pens:[ht(t,!0)],step:2})}translateAnchor(t,i){this.movingAnchor.x+=t,this.movingAnchor.y+=i;const s=this.movingAnchor.penId;if(s){const n=this.store.pens[s],a=n.calculative.worldRect;this.movingAnchor.xa.ex&&(this.movingAnchor.x=a.ex),this.movingAnchor.ya.ey&&(this.movingAnchor.y=a.ey);const r=ra(this.movingAnchor,a),l=n.anchors.findIndex(o=>o.id===this.movingAnchor.id);n.anchors[l]=r,this.patchFlags=!0}}async fileToPen(t,i){let s="";return this.store.options.uploadFn?s=await this.store.options.uploadFn(t):this.store.options.uploadUrl?s=await $x(t,this.store.options.uploadUrl,this.store.options.uploadParams,this.store.options.uploadHeaders):s=await Ux(t),new Promise((n,a)=>{const r=new Image;r.onload=()=>{kt.htmlElements[s]=r,n({width:r.width,height:r.height,name:i?"gif":"image",image:s})},r.onerror=l=>{a(l)},r.crossOrigin="anonymous",r.src=s})}async dropPens(t,i){var o,u,c,f;this.randomIdObj={};for(const g of t)!g.parentId&&this.randomCombineId(g,t);if(Object.keys(this.randomIdObj).length!==0){const g=Object.keys(this.randomIdObj).join("|"),v=new RegExp(`(${g})`,"g");for(const y of t){if(y.type?(y.anchors[0].connectTo=this.randomIdObj[y.anchors[0].connectTo],y.anchors[y.anchors.length-1].connectTo=this.randomIdObj[y.anchors[y.anchors.length-1].connectTo]):(o=y.connectedLines)==null||o.forEach(w=>{w.lineAnchor=this.randomIdObj[w.lineAnchor],w.lineId=this.randomIdObj[w.lineId]}),(u=y.animations)!=null&&u.length){const w=JSON.stringify(y.animations).replace(v,m=>this.randomIdObj[m]);y.animations=JSON.parse(w)}if((c=y.triggers)!=null&&c.length){const w=JSON.stringify(y.triggers).replace(v,m=>this.randomIdObj[m]);y.triggers=JSON.parse(w)}if((f=y.events)!=null&&f.length){const w=JSON.stringify(y.events).replace(v,m=>this.randomIdObj[m]);y.events=JSON.parse(w)}}}for(const g of t)g.id||(g.id=It()),!g.calculative&&(g.calculative={canvas:this}),this.store.pens[g.id]=g;let s=0,n=0,a=0;for(const g of t)g.parentId||(g.width*=this.store.data.scale,g.height*=this.store.data.scale,g.x=i.x-g.width/2+a,g.y=i.y-g.height/2+n,g.tags&&g.tags.includes("meta3d")&&(g.x=this.store.data.origin.x,g.y=this.store.data.origin.y),g.dataset&&(s%2===0?a=g.width-40*this.store.data.scale:a=0,s++,s%2===0&&(n+=g.height+10*this.store.data.scale)));const r=this.store.data.width||this.store.options.width,l=this.store.data.height||this.store.options.height;if(r&&l){let g={x:this.store.data.origin.x,y:this.store.data.origin.y,width:r*this.store.data.scale,height:l*this.store.data.scale},v=!0;for(const y of t)if(!y.parentId){let w=[{x:y.x,y:y.y},{x:y.x+y.width,y:y.y},{x:y.x,y:y.y+y.height},{x:y.x+y.width,y:y.y+y.height},{x:y.x+y.width/2,y:y.y+y.height/2}];if(y.x===g.x&&y.y===g.y&&y.width===g.width&&y.height===g.height||w.some(m=>Ui(m,g))){v=!1,this.store.options.strictScope&&(y.xg.x+g.width&&(y.x=g.x+g.width-y.width),y.y+y.height>g.y+g.height&&(y.y=g.y+g.height-y.height));break}}if(v){console.info("\u753B\u7B14\u5728\u5927\u5C4F\u8303\u56F4\u5916");return}}await this.addPens(t,!0),this.active(t.filter(g=>!g.parentId)),this.render(),this.externalElements.focus()}randomCombineId(t,i,s){let n=null;t.type?t.anchors[0].connectTo||t.anchors[t.anchors.length-1].connectTo?n=[t.id,t.anchors[0].id,t.anchors[t.anchors.length-1].id]:n=[t.id]:i.length>1&&(n=[t.id]),kf(t),i.length>1&&(n.length===1?this.randomIdObj[n[0]]=t.id:(this.randomIdObj[n[0]]=t.id,this.randomIdObj[n[1]]=t.anchors[0].id,this.randomIdObj[n[2]]=t.anchors[t.anchors.length-1].id)),t.parentId=s;const a=[];if(Array.isArray(t.children))for(const r of t.children){const l=i.find(o=>o.id===r);l&&a.push(this.randomCombineId(l,i,t.id).id)}return t.children=a,t}async addPens(t,i,s){if(this.beforeAddPens&&await this.beforeAddPens(t)!=!0)return[];const n=[];for(const a of t)this.beforeAddPen&&this.beforeAddPen(a)!=!0||(s&&!a.parentId&&(a.x=a.x*this.store.data.scale+this.store.data.origin.x,a.y=a.y*this.store.data.scale+this.store.data.origin.y,a.width=a.width*this.store.data.scale,a.height=a.height*this.store.data.scale),this.makePen(a),n.push(a));return this.render(),this.store.emitter.emit("add",n),i&&this.pushHistory({type:bt.Add,pens:ht(n,!0)}),n}getInitPencilLine(t){const{data:i,options:s}=this.store,n=i.scale,a=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:a*n},fromArrow:i.fromArrow||s.fromArrow,toArrow:i.toArrow||s.toArrow,lineWidth:a}}createDrawingLine(t){this.inactive();const{data:i,options:s}=this.store,n=i.scale,a=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:a*n,...s.linePresetStyle},fromArrow:i.fromArrow||s.fromArrow,toArrow:i.toArrow||s.toArrow,lineWidth:a,...s.linePresetStyle}}addRuleLine(t){const{x:i,y:s,scale:n,origin:a}=this.store.data,r=t.x+i,l=t.y+s;let o=t.x,u=t.y,c=0,f=0,g=0,v=0;if(r<=l&&r<20)o=-i,c=this.width,g=1,t.ctrlKey||(u=Math.round((u-a.y)/(n*10))*(n*10)+a.y);else if(lt.isRuleLine)}alignPenToGrid(t){var s;if(this.store.options.autoAlignGrid&&this.store.data.grid&&!t.type){const n=this.store.data.gridSize||this.store.options.gridSize,{origin:a,scale:r}=this.store.data,{x:l,y:o}=t,u={x:l,y:o},c=this.getPenRect(t),f=parseInt((c.x/n).toFixed()),g=parseInt((c.y/n).toFixed()),v=f*n,y=g*n;u.x=a.x+v*r,u.y=a.y+y*r,Object.assign(t,u),(s=t.onMove)==null||s.call(t,t),this.updatePenRect(t),this.calcActiveRect(),this.getSizeCPs()}}movedActivePens(t){let i=this.getAllFollowersByPens(this.store.active,!1);const s=ht(i,!0),n=this.store.data.gridSize||this.store.options.gridSize,{origin:a,scale:r}=this.store.data,l=this.store.options.autoAlignGrid&&(this.store.data.grid||this.store.options.grid);if(i.forEach(g=>{var _;const v=this.movingPens.findIndex(E=>E.id===g.id+He);if(v<0)return;const{x:y,y:w}=this.movingPens[v],m={x:y,y:w};if(l&&!this.movingPens[v].type){const E=this.getPenRect(this.movingPens[v]),x=parseInt((E.x/n).toFixed()),C=parseInt((E.y/n).toFixed()),S=x*n,L=C*n;m.x=a.x+S*r,m.y=a.y+L*r}Object.assign(g,m),(_=g.onMove)==null||_.call(g,g),this.updatePenRect(g),this.updateLines(g),this.store.emitter.emit("updateLines",g),this.patchFlagsLines.forEach(E=>{E.type&&this.initLineRect(E)}),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),sg(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:o,yDock:u}=this.dock;let c;o&&(c=this.store.pens[o.penId]),!c&&u&&(c=this.store.pens[u.penId]);const f=ht(this.store.active,!0);if(t&&this.store.active.length===1&&(c==null?void 0:c.type)===1&&((o==null?void 0:o.anchorId)||(u==null?void 0:u.anchorId))){const g=le(c),v=$t(c);if(o!=null&&o.anchorId){const y=this.store.pens[this.store.active[0].id+He].calculative.worldAnchors.find(w=>w.id===o.anchorId);y.x===g.x&&y.y===g.y?(s.push(ht(c,!0)),we(this.store.active[0],y,c,g),f.push(ht(c,!0))):y.x===v.x&&y.y===v.y&&(s.push(ht(c,!0)),we(this.store.active[0],y,c,v),f.push(ht(c,!0)))}else if(u!=null&&u.anchorId){const y=this.store.pens[this.store.active[0].id+He].calculative.worldAnchors.find(w=>w.id===u.anchorId);y.x===g.x&&y.y===g.y?(s.push(ht(c,!0)),we(this.store.active[0],y,c,g),f.push(ht(c,!0))):y.x===v.x&&y.y===v.y&&(s.push(ht(c,!0)),we(this.store.active[0],y,c,v),f.push(ht(c,!0)))}}l&&(this.calcActiveRect(),this.getSizeCPs()),this.pushHistory({type:bt.Update,pens:f,initPens:s}),this.store.emitter.emit("translatePens",f)}copyMovedPens(){this.copy(this.store.active.map((t,i)=>{const{x:s,y:n}=this.movingPens[i];return this.updateLines(t),{...t,x:s,y:n}})),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 s;return t.image&&t.name!=="gif"?i?t.canvasLayer===zt.CanvasImageBottom:t.canvasLayer===zt.CanvasImage:(s=t.children)==null?void 0:s.some(n=>{const a=this.store.pens[n];return a&&this.hasImage(a,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,pn(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 s of this.store.active)s.calculative.active=void 0,s.calculative.hover=!1,pn(s,!1)}this.store.active=[],t.forEach(s=>{s.calculative.active=!0,pn(s)}),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=Zi(this.activeRect);const t=[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}],{x:i,y:s,width:n,height:a,rotate:r,center:l}=this.activeRect;t.forEach(o=>{const u={x:o.x*n+i,y:o.y*a+s};Gt(u,r,l),this.sizeCPs.push(u)})}getSpecialAngle(t,i){let s=0;t.x-i.x!==0?(s=Math.atan((i.y-t.y)/(t.x-i.x))*180/Math.PI,t.x0?s-=180:s+=180)):i.y>t.y?s=90:i.yOt.DisableEdit||!(i.type&&i.calculative.active)&&this.store.options.disableAnchor||i.disableAnchor)return xt.None;if((this.mouseDown||this.drawingLine)&&i.name==="line"&&s.connectTo){const a=this.findOne(s.connectTo);if((a==null?void 0:a.calculative)&&!(a!=null&&a.calculative.active)){i=a;const r=a.calculative.worldAnchors.find(l=>l.id===s.anchorId);r&&(s=r)}}if(s.twoWay===Ee.Disable&&i.name!=="line")return xt.None;if(i.name==="line"&&s.connectTo){let a=(n=this.findOne(s.connectTo))==null?void 0:n.anchors.find(r=>r.id===s.anchorId);if(a&&a.twoWay)return xt.None}if(this.drawingLine){if(s.twoWay===Ee.Out)return xt.None}else if(!(this.mouseDown&&this.hoverType===xt.LineAnchor)){if(s.twoWay===Ee.In)return xt.None}if(mn(t,s,this.pointSize,s.penId?this.store.pens[s.penId]:void 0))return s!==this.store.hoverAnchor&&(this.patchFlags=!0),this.store.hoverAnchor=s,this.store.hover=i,i.type?s.connectTo&&!i.calculative.active&&(this.store.hover=this.store.pens[s.connectTo],this.store.hover)?(this.store.hoverAnchor=this.store.hover.calculative.worldAnchors.find(a=>a.id===s.anchorId),this.store.hoverAnchor?(this.externalElements.style.cursor="crosshair",xt.NodeAnchor):xt.None):(this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="vertical-text":this.externalElements.style.cursor="pointer",xt.LineAnchor):(this.hotkeyType===Yt.AddAnchor?this.externalElements.style.cursor="vertical-text":this.externalElements.style.cursor="crosshair",xt.NodeAnchor);if(!this.mouseDown&&i.type){if(i.calculative.active&&s.prev&&mn(t,s.prev,this.pointSize))return this.store.hoverAnchor=s,this.store.hover=i,this.externalElements.style.cursor="pointer",xt.LineAnchorPrev;if(i.calculative.active&&s.next&&mn(t,s.next,this.pointSize))return this.store.hoverAnchor=s,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},re(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 s of this.store.data.pens)s.isRuleLine&&(s.width?s.height||(s.width=this.width):s.height=this.height,this.updatePenRect(s)),Yi(s);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,s,n){if(!(this.beforeAddPens&&await this.beforeAddPens([t])!=!0)&&!(this.beforeAddPen&&this.beforeAddPen(t)!=!0))return n&&(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(),s&&this.store.emitter.emit("add",[t]),i&&this.pushHistory({type:bt.Add,pens:[t]}),t}pushHistory(t){var n;if(this.store.data.locked)return;const{origin:i,scale:s}=this.store.data;t.origin=ht(i),t.scale=s,t.type!==bt.Update&&t.pens&&t.pens.forEach(a=>{a.calculative&&(a.calculative.layer=this.store.data.pens.findIndex(r=>r.id===a.id))}),this.store.historyIndex{let r;if(t.initPens)for(const l of t.initPens)l.id===a.id&&(r=l);if(r)for(const l in a)r[l]==null&&(r[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 s=this.store.histories[this.store.historyIndex--];this.doEditAction(s,!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 s=this.store.histories[++this.store.historyIndex];this.doEditAction(s,!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(n=>{i.push(this.store.pens[n.id])}),this.active(i);return}let s=this.store.histories[this.store.historyIndex];s&&(s.type===bt.Add||s.type===bt.Delete)&&(s.pens.forEach(n=>{i.push(this.store.pens[n.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(a=>{var o;const r=ht(a,!0),l=this.store.data.pens.findIndex(u=>u.id===r.id);l>-1&&((o=r.onDestroy)==null||o.call(r,this.store.pens[r.id]),this.store.data.pens.splice(l,1),this.store.pens[r.id]=void 0,r.calculative||(r.calculative={}),r.calculative.canvas=this,this.store.animates.delete(r),this.store.animateMap.delete(r))}),t.type=bt.Delete;break;case bt.Update:const s=i?t.initPens:t.pens,n=i?t.pens:t.initPens;s.forEach(a=>{const r=ht(a,!0),l=this.store.data.pens.findIndex(o=>o.id===r.id);if(l>-1){if(r.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 c=ht(this.store.data.pens[l].lastConnected[u]);this.store.pens[u].connectedLines=c,r.anchors.forEach(f=>{c.forEach(g=>{f.id===g.lineAnchor&&(f.connectTo=u)})})}}this.store.data.pens[l]=r,this.store.pens[r.id]=r;for(const u in r)(typeof r[u]!="object"||u==="lineDash")&&(r.calculative[u]=r[u]);r.calculative.image=void 0;const o=this.getPenRect(r,t.origin,t.scale);if(this.setPenRect(r,o,!1),this.updateLines(r,!0),r.calculative.canvas.parent.isCombine(r)){let u=n.find(c=>c.id===r.id);Fd.forEach(c=>{r[c]!==u[c]&&this.parent.setValue({id:r.id,[c]:r[c]},{render:!0,doEvent:!1})})}}});break;case bt.Delete:t.pens.reverse().forEach(a=>{var l,o;const r=ht(a,!0);if(r.calculative||(r.calculative={}),this.store.data.pens.splice(((l=r.calculative)==null?void 0:l.layer)!==-1?(o=r.calculative)==null?void 0:o.layer:this.store.data.pens.length,0,r),this.store.pens[r.id]=r,r.type&&r.lastConnected)for(let u in r.lastConnected)this.store.pens[u]&&(this.store.pens[u].connectedLines=r.lastConnected[u]);r.calculative.canvas=this}),t.pens.reverse().forEach(a=>{const r=this.store.pens[a.id],l=this.getPenRect(r,t.origin,t.scale);this.setPenRect(r,l,!1),r.calculative.image=void 0,r.calculative.backgroundImage=void 0,r.calculative.strokeImage=void 0,this.loadImage(r)}),t.type=bt.Add;break;case bt.Replace:{const a=i?t.initPens:t.pens;(i?t.pens:t.initPens).forEach(l=>{var c;const o=ht(l,!0);if(this.store.data.pens.findIndex(f=>f.id===o.id)>-1){(c=o.onDestroy)==null||c.call(o,this.store.data.pens.find(g=>g.id===o.id));const f=this.store.data.pens.findIndex(g=>g.id===o.id);this.store.data.pens.splice(f,1),this.store.pens[o.id]=void 0,o.calculative||(o.calculative={}),o.calculative.canvas=this,this.store.animates.delete(o),this.store.animateMap.delete(o)}}),a.reverse().forEach(l=>{var u,c;const o=ht(l,!0);if(o.calculative||(o.calculative={}),this.store.data.pens.splice(((u=o.calculative)==null?void 0:u.layer)!==-1?(c=o.calculative)==null?void 0:c.layer:this.store.data.pens.length,0,o),this.store.pens[o.id]=o,o.type&&o.lastConnected)for(let f in o.lastConnected)this.store.pens[f]&&(this.store.pens[f].connectedLines=o.lastConnected[f]);o.calculative.canvas=this}),a.reverse().forEach(l=>{const o=this.store.data.pens.find(c=>c.id===l.id),u=this.getPenRect(o,t.origin,t.scale);this.setPenRect(o,u,!1),o.calculative.image=void 0,o.calculative.backgroundImage=void 0,o.calculative.strokeImage=void 0,this.loadImage(o)}),t.type=bt.Replace;break}}if(t.type===bt.Update){let s=[...t.pens,...t.initPens];this.initImageCanvas(s),this.initTemplateCanvas(s)}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 n,a;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(t.copyIndex?(this.store.data.pens.splice(t.copyIndex+1,0,t),delete t.copyIndex):this.store.data.pens.push(t),this.store.pens[t.id]=t,t.path){!t.pathId&&(t.pathId=It());const r=this.store.data.paths;!r[t.pathId]&&(r[t.pathId]=t.path),t.path=void 0}t.lineWidth==null&&(t.lineWidth=1);const{fontSize:i,lineHeight:s}=this.store.options;t.fontSize?t.fontSize<0&&(t.fontSize=0):t.fontSize=i>=0?i:12,t.lineHeight||(t.lineHeight=s),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:(n=t.calculative)==null?void 0:n.singleton},(t.video||t.audio)&&(t.calculative.onended=r=>{this.nextAnimate(r)});for(const r in t)(typeof t[r]!="object"||r==="lineDash")&&(t.calculative[r]=t[r]);if(t.calculative.image=void 0,t.calculative.backgroundImage=void 0,t.calculative.strokeImage=void 0,!t.anchors&&kt.anchors[t.name]&&(t.anchors||(t.anchors=[]),kt.anchors[t.name](t)),!t.anchors){const r=ht(this.store.options.defaultAnchors);r.forEach((l,o)=>{l.id=`${o}`,l.penId=t.id}),t.anchors=r}this.updatePenRect(t),!t.anchors&&t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(r=>ra(r,t.calculative.worldRect))),!t.rotate&&(t.rotate=0),(a=t.lineAnimateImages)!=null||(t.lineAnimateImages=[]),t.lineAnimateImages&&t.lineAnimateImages.forEach(r=>{this.__loadImage(r)}),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,kt.path2dDraws.line(this.drawingLine)),this.patchFlags=!0)}initLineRect(t){var a;if(!t)return;if(!((a=t.calculative.worldAnchors)!=null&&a.length)){this._del([t]);return}if(!isFinite(t.x)||!isFinite(t.x)||t.x==null||t.y==null)return;const i=ic(t);t.parentId||Object.assign(t,i);const{fontSize:s,lineHeight:n}=this.store.options;t.fontSize||(t.fontSize=s>=0?s:12,t.calculative.fontSize=t.fontSize*this.store.data.scale),t.lineHeight||(t.lineHeight=n,t.calculative.lineHeight=t.lineHeight),Qt(i),t.calculative.worldRect=i,wc(t,i),Ri(t),Yi(t),t.calculative&&(t.calculative.gradientAnimatePath=void 0),this.store.path2dMap.set(t,kt.path2dDraws[t.name](t)),t.calculative.worldAnchors&&(t.anchors=t.calculative.worldAnchors.map(r=>ra(r,t.calculative.worldRect)))}drawingPencil(){wg(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 s=$t(this.drawingLine);if(s.isTemp&&(this.drawingLine.calculative.worldAnchors.pop(),s=$t(this.drawingLine)),!t&&(!s.connectTo&&this.drawingLine.calculative.worldAnchors.pop(),le(this.drawingLine)===this.drawingLine.calculative.activeAnchor)){this.drawingLine=void 0,this.render();return}if(!i.connectTo||!s.connectTo){if(this.store.options.disableEmptyLine){i.connectTo&&(this.store.pens[i.connectTo].connectedLines=this.store.pens[i.connectTo].connectedLines.filter(r=>r.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 o=le(l),u=$t(l);return ff(o,i)&&ff(u,s)}})){this.drawingLine=void 0,this.render();return}const n=ic(this.drawingLine);Object.assign(this.drawingLine,n),this.drawingLine.calculative.worldRect=n,this.drawingLine.calculative.activeAnchor=$t(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:ht([this.drawingLine],!0)})),this.store.path2dMap.set(this.drawingLine,kt.path2dDraws[this.drawingLine.name](this.drawingLine)),this.drawingLine=void 0,this.drawingLineName=void 0,this.render()}async finishPencil(){if(this.pencilLine){const t=sc(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=$t(this.pencilLine),t.push({id:i.id,penId:i.penId,x:i.x,y:i.y}),this.pencilLine.calculative.worldAnchors=D2(t),this.pencilLine.calculative.worldAnchors.length>1&&(this.pencilLine.calculative.pencil=!1,this.store.path2dMap.set(this.pencilLine,kt.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:ht([this.pencilLine],!0)}))),this.pencilLine=void 0,this.render()}}firefoxLoadSvg(t){const i=new Image,s=new XMLHttpRequest;s.open("GET",t.image,!0),s.onload=()=>{const r=new DOMParser().parseFromString(s.responseText,"text/xml").getElementsByTagName("svg")[0],{width:l,height:o}=t.calculative.worldRect;r.setAttribute("width",`${l}px`),r.setAttribute("height",`${o}px`);const c="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(new XMLSerializer().serializeToString(r))));i.src=c,i.onload=()=>{t.calculative.img=i,t.calculative.imgNaturalWidth=i.naturalWidth||t.iconWidth,t.calculative.imgNaturalHeight=i.naturalHeight||t.iconHeight,kt.htmlElements[t.image]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&this.templateImageLoaded()}},s.send()}loadImage(t){if(t.image!==t.calculative.image||!t.calculative.img){if(t.calculative.img=void 0,t.image)if(kt.htmlElements[t.image]){const i=kt.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,kt.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(kt.htmlElements[t.backgroundImage]){const i=kt.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,kt.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(kt.htmlElements[t.strokeImage]){const i=kt.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,kt.htmlElements[t.strokeImage]=i,this.imageLoaded(),t.canvasLayer===zt.CanvasTemplate&&t.name!=="gif"&&this.templateImageLoaded()}}t.calculative.strokeImage=t.strokeImage}}__loadImage(t){return new Promise(i=>{if(kt.htmlElements[t])i(kt.htmlElements[t]);else{const s=new Image;s.crossOrigin="anonymous",s.src=t,this.store.options.cdn&&!(t.startsWith("http")||t.startsWith("//")||t.startsWith("data:image"))&&(s.src=this.store.options.cdn+t),s.onload=()=>{kt.htmlElements[t]=s,i(s)}}})}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:s}={}){i?Lr(t):ig(t),s||this.setCalculativeByScale(t),An(t),vf(this.store.pens,t),Ri(t),Yi(t),kt.path2dDraws[t.name]&&this.store.path2dMap.set(t,kt.path2dDraws[t.name](t)),t.calculative.patchFlags=!0,this.patchFlags=!0,t.children&&t.children.forEach(n=>{const a=this.store.pens[n];a&&this.updatePenRect(a,{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)}initGlobalStyle(){if(this.store.options.themeOnlyCanvas||this.store.data.themeOnlyCanvas)return;const t={},i={},s={};Mx.forEach(a=>{var r;if(this.store.options[a]!==void 0&&(t[a]=this.store.options[a]),this.store.data[a]!==void 0&&(i[a]=this.store.data[a]),this.store.data.theme){const l=(r=this.store.theme[this.store.data.theme])==null?void 0:r[a];l!==void 0&&(s[a]=l)}}),this.store.styles={};const n=ta.getThemeObj(this.store.data.theme);Object.assign(this.store.styles,t,i,s,n)}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 s=qi(this.store.options.padding);const n=this.store.data.width||this.store.options.width,a=this.store.data.height||this.store.options.height;this.width<(n+s[1]+s[3])*this.store.data.scale&&(this.store.data.x+this.store.data.origin.x>s[3]*this.store.data.scale&&(this.store.data.x=s[3]*this.store.data.scale-this.store.data.origin.x),this.store.data.x+this.store.data.origin.x+n*this.store.data.scales[0]*this.store.data.scale&&(this.store.data.y=s[0]*this.store.data.scale-this.store.data.origin.y),this.store.data.y+this.store.data.origin.y+a*this.store.data.scale{this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init(),this.render()},300)):(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 s of this.store.data.pens)Yi(s),(i=s.onMove)==null||i.call(s,s),s.isRuleLine&&(s.width?s.height||(s.x=-this.store.data.x):s.y=-this.store.data.y,this.updatePenRect(s))}scale(t,i={x:0,y:0}){var l;const s=this.store.data.minScale||this.store.options.minScale,n=this.store.data.maxScale||this.store.options.maxScale;if(!(t>=s&&t<=n))return;this.calibrateMouse(i);const a=t/this.store.data.scale;this.store.data.scale=t,this.store.data.center=i,(l=this.store.clipboard)!=null&&l.pos&&Hr(this.store.clipboard.pos,a,i),Hr(this.store.data.origin,a,i),this.store.data.pens.forEach(o=>{if(o.onScale&&o.onScale(o),!o.parentId){if(gn(o,a,i),o.isRuleLine){const u=1/a,c=o.calculative.worldRect.center;o.width&&o.height||gn(o,u,c)}this.updatePenRect(o,{worldRectIsReady:!0}),this.execPenResize(o)}}),this.onMovePens(),this.calcActiveRect(),this.canvasTemplate.init(),this.canvasImage.init(),this.canvasImageBottom.init();const r=this.parent.map;r&&r.isShow&&r.setView(),this.render(),this.store.emitter.emit("scale",this.store.data.scale)}templateScale(t,i={x:0,y:0}){const{minScale:s,maxScale:n}=this.store.options;if(!(t>=s&&t<=n))return;const a=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(r=>{if(!r.parentId){if(gn(r,a,i),r.onScale&&r.onScale(r),r.isRuleLine){const l=a>1?1:1/a/a,o=r.calculative.worldRect.center;r.width&&r.height||gn(r,l,o)}this.execPenResize(r)}}),this.calcActiveRect()}rotatePens(t){this.initPens||(this.initPens=ht(this.getAllByPens(this.store.active))),this.activeRect.rotate=ui(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 s of this.store.active){if(s.parentId)return;this.rotatePen(s,i,this.activeRect),s.onRotate&&s.onRotate(s),this.updateLines(s)}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:ht(this.getAllByPens(this.store.active)),initPens:this.initPens}),this.initPens=void 0},200)}resizePens(t){if(this.initPens||(this.initPens=ht(this.store.active,!0)),!this.initActiveRect){this.initActiveRect=ht(this.activeRect);return}const i={x:this.mouseDown.x,y:this.mouseDown.y},s={x:t.x,y:t.y};let n=s.x-i.x,a=s.y-i.y;const r=ht(this.initActiveRect);if(Ef(r,n,a,this.resizeIndex),Qt(r),!this.store.options.disableDock){this.clearDock();const v=this.customResizeDock||D_;this.dock=v(this.store,r,this.store.active,this.resizeIndex);const{xDock:y,yDock:w}=this.dock;if(y){n+=y.step;const m=this.store.pens[y.penId];m.calculative.isDock=!0}if(w){a+=w.step;const m=this.store.pens[w.penId];m.calculative.isDock=!0}}const l=this.activeRect.width,o=this.activeRect.height;let u=n-this.lastOffsetX,c=a-this.lastOffsetY;if(this.lastOffsetX=n,this.lastOffsetY=a,(t.ctrlKey||this.initPens.length===1&&this.initPens[0].ratio)&&(c=([1,3].includes(this.resizeIndex)?-1:1)*(u*o)/l),this.activeRect.ratio=this.initPens[0].ratio,Ef(this.activeRect,u,c,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.xw.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)}}Qt(this.activeRect);const f=this.activeRect.width/l,g=this.activeRect.height/o;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*=f,v.calculative.iconWidth&&(v.calculative.iconWidth*=f),v.calculative.worldRect.height*=g,v.calculative.iconHeight&&(v.calculative.iconHeight*=g),re(v.calculative.worldRect),Qt(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:ht(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},200)}movePens(t){var l,o;if(!this.activeRect||this.store.data.locked)return;if(!this.initActiveRect){this.initActiveRect=ht(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)||((o=this.store.active[0].anchors[this.store.active[0].anchors.length-1])==null?void 0:o.connectTo))||(this.movingPens||(this.initMovingPens(),this.store.active.forEach(u=>{ea(u,!1)}),this.store.hover=void 0),!this.mouseDown))return;let i=t.x-this.mouseDown.x,s=t.y-this.mouseDown.y;t.shiftKey&&!t.ctrlKey&&(s=0),t.ctrlKey&&(i=0);const n=ht(this.initActiveRect);Ms(n,i,s);let a=!1;if(this.store.options.strictScope){const u=this.store.data.width||this.store.options.width,c=this.store.data.height||this.store.options.height;if(u&&c){let f={x:this.store.data.origin.x,y:this.store.data.origin.y,width:u*this.store.data.scale,height:c*this.store.data.scale};n.xf.x+f.width&&(n.x=f.x+f.width-n.width,a=!0),n.y+n.height>f.y+f.height&&(n.y=f.y+f.height-n.height,a=!0)}}const r={x:n.x-this.activeRect.x,y:n.y-this.activeRect.y};if(!this.store.options.disableDock&&!a){this.clearDock();const u=this.customMoveDock||L_;this.dock=u(this.store,n,this.movingPens,r);const{xDock:c,yDock:f}=this.dock;let g;c&&(r.x+=c.step,g=this.store.pens[c.penId],g.calculative.isDock=!0),f&&(r.y+=f.step,g=this.store.pens[f.penId],g.calculative.isDock=!0)}this.translatePens(this.movingPens,r.x,r.y,!0)}changeIdsByMoving(t,i){t.id+=He,t.parentId&&i.find(s=>s.id===t.parentId)&&(t.parentId+=He),t.children&&(t.children=t.children.map(s=>s+He)),t.connectedLines&&(t.connectedLines=t.connectedLines.map(s=>(i.find(n=>n.id===s.lineId)&&(s.lineId+=He),s))),t.type&&t.calculative.worldAnchors&&(t.calculative.worldAnchors=t.calculative.worldAnchors.map(s=>(s.connectTo&&i.find(n=>n.id===s.connectTo)&&(s.connectTo+=He),s)))}initMovingPens(){var s,n;if(!this.store.options.moveConnectedLine&&!this.canMoveLine)for(let a=0;a{this.changeIdsByMoving(a,i),this.store.pens[a.id]=a,a.calculative.canvas=this;const r={globalAlpha:.5};a.lineWidth===0&&(r.lineWidth=1),(a.name.endsWith("Dom")||Od.includes(a.name)||this.store.options.domShapes.includes(a.name)||a.image)&&(r.name="rectangle",r.onDestroy=void 0),this.updateValue(a,r),a.calculative.image=void 0})}moveLineAnchor(t,i){var l,o,u,c,f;if(!this.activeRect||this.store.data.locked)return;if(this.initPens||(this.initPens=ht(this.store.active,!0)),(l=this.store.activeAnchor)!=null&&l.connectTo){const g=this.store.pens[this.store.activeAnchor.connectTo];_n(g,Ls(g,this.store.activeAnchor.anchorId),this.store.pens[this.store.activeAnchor.penId],this.store.activeAnchor)}let s=(o=this.store.activeAnchor)==null?void 0:o.id,n=(c=(u=this.store.pens[this.store.activeAnchor.penId])==null?void 0:u.connectedLines)==null?void 0:c.filter(g=>g.anchor===s);n&&n.length>0&&n.forEach(g=>{const v=this.store.pens[g.lineId];_n(this.store.pens[this.store.activeAnchor.penId],this.store.activeAnchor,v,Ls(v,g.lineAnchor))});const a=this.store.active[0];le(a);const r=$t(a);if(a.lineName==="polyline"&&!i.shiftKey)L2(a,this.store.activeAnchor,t);else{let g=0,v=0;if(a.lineName==="line"){let y=a.calculative.worldAnchors.findIndex(m=>m.id===this.store.activeAnchor.id);y===0&&(y=2);let w=a.calculative.worldAnchors[y-1];if(i.ctrlKey&&i.shiftKey){let m=ht(t);this.getSpecialAngle(m,w),g=m.x-this.store.activeAnchor.x,v=m.y-this.store.activeAnchor.y}else if(!i.ctrlKey&&i.shiftKey){let m={x:t.x,y:w.y};g=m.x-this.store.activeAnchor.x,v=m.y-this.store.activeAnchor.y}else if(i.ctrlKey&&!i.shiftKey){let m={x:w.x,y:t.y};g=m.x-this.store.activeAnchor.x,v=m.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);aa(this.store.activeAnchor,g,v),this.store.hover&&this.store.hoverAnchor&&this.store.hoverAnchor.penId!==this.store.activeAnchor.penId&&(this.store.hoverAnchor.type===ji.Line?(g=t.x-this.store.activeAnchor.x,v=t.y-this.store.activeAnchor.y,yr(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),aa(this.store.activeAnchor,g,v),r.prev=void 0,a.lineName!=="polyline"&&((f=this[a.lineName])==null||f.call(this,this.store,a)))}this.patchFlagsLines.add(a),this.store.path2dMap.set(a,kt.path2dDraws[a.name](a)),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:ht(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=ht(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===Ns.Bilateral&&this.prevAnchor){const s=ui(t,this.store.activeAnchor),n=ui(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,s-n,this.store.activeAnchor)}}const i=this.store.active[0];this.patchFlagsLines.add(i),this.store.path2dMap.set(i,kt.path2dDraws[i.name](i)),this.render(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ht(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=ht(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===Ns.Bilateral&&this.nextAnchor){const s=ui(t,this.store.activeAnchor),n=ui(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,s-n,this.store.activeAnchor)}}const i=this.store.active[0];this.patchFlagsLines.add(i),this.store.path2dMap.set(i,kt.path2dDraws[i.name](i)),this.render(),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.pushHistory({type:bt.Update,pens:ht(this.store.active,!0),initPens:this.initPens}),this.initPens=void 0},200)}async setAnchor(t){var n;const i=[ht(this.store.hover,!0)],s=this.store.hover;if(this.store.hoverAnchor){if(this.beforeRemoveAnchor&&!await this.beforeRemoveAnchor(s,this.store.hoverAnchor))return;s.type===jt.Line&&((n=s.calculative.worldAnchors)==null?void 0:n.length)<=2?this.delete([s]):(b_(s,this.store.hoverAnchor),s.type===jt.Line&&this.initLineRect(s)),this.store.hoverAnchor=void 0,this.store.activeAnchor=void 0,this.externalElements.style.cursor="default"}else if(s){if(this.beforeAddAnchor&&!await this.beforeAddAnchor(s,this.store.pointAt))return;if(s.type===jt.Line){this.store.activeAnchor=w_(s,this.store.pointAt,this.store.pointAtIndex),this.initLineRect(s);const a={x:t.x,y:t.y};this.getHover(a)}else{const a={id:It(),x:t.x,y:t.y};this.store.activeAnchor=p_(s,a)}}this.hotkeyType=Yt.None,this.render(),s&&this.pushHistory({type:bt.Update,pens:[ht(s,!0)],initPens:i})}checkDisconnect(t,i){if(t.id.indexOf(He)>0){const s=t.id;t=this.store.pens[s.replace(He,"")]}t.anchors.forEach(s=>{if(s.connectTo&&!i.find(n=>n.id===s.connectTo||n.id===s.connectTo+He)){const n=this.store.pens[s.connectTo];if(!n||n.type)return;_n(n,Ls(n,s.anchorId),t,s)}})}translatePens(t=this.store.active,i,s,n){if(!t||!t.length||t.some(o=>{if(o.locked>=Ot.DisableMove)return!0}))return;const r=!n&&ht(t,!0);this.activeRect&&Ms(this.activeRect,i,s);const l=this.getAllByPens(t);t.forEach(o=>{var u,c;if(!(o.locked>=Ot.DisableMove)){if(o.type===jt.Line){if(!this.store.options.moveConnectedLine&&!this.canMoveLine||o.isRuleLine)return;yf(o,i,s),this.checkDisconnect(o,l),this.store.path2dMap.set(o,kt.path2dDraws[o.name](o)),n||(this.initLineRect(o),(u=o.connectedLines)==null||u.forEach(f=>{const g=this.store.pens[f.lineId];this.initLineRect(g)}))}else Ms(o.calculative.worldRect,i,s),this.updatePenRect(o,{worldRectIsReady:!0}),o.calculative.x=o.x,o.calculative.y=o.y,o.calculative.initRect&&(o.calculative.initRect.x=o.calculative.x,o.calculative.initRect.y=o.calculative.y,o.calculative.initRect.ex=o.calculative.x+o.calculative.width,o.calculative.initRect.ey=o.calculative.y+o.calculative.height);this.updateLines(o),(c=o.onMove)==null||c.call(o,o)}}),this.activeRect&&this.getSizeCPs(),this.render(),this.tooltip.translate(i,s),n||(this.pushHistory({type:bt.Update,pens:ht(t,!0),initPens:r}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.store.emitter.emit("translatePens",t)),this.store.emitter.emit("translatingPens",t)}templateTranslatePens(t=this.store.active,i,s){if(!t||!t.length)return;const n=this.getAllByPens(t);t.forEach(a=>{var r;if(a.type===jt.Line){if(!this.store.options.moveConnectedLine&&!this.canMoveLine)return;yf(a,i,s),this.checkDisconnect(a,n),this.store.path2dMap.set(a,kt.path2dDraws[a.name](a))}else Ms(a.calculative.worldRect,i,s),this.updatePenRect(a,{worldRectIsReady:!0}),a.calculative.x=a.x,a.calculative.y=a.y,a.calculative.initRect&&(a.calculative.initRect.x=a.calculative.x,a.calculative.initRect.y=a.calculative.y,a.calculative.initRect.ex=a.calculative.x+a.calculative.width,a.calculative.initRect.ey=a.calculative.y+a.calculative.height);(r=a.onMove)==null||r.call(a,a)})}calcAutoAnchor(t,i,s,n){const a=le(t),r=$t(t),l=xn(s,i===a?r:a);!l||(i.x=l.x,i.y=l.y,i.prev=void 0,i.next=void 0,n?n.anchor=l.id:we(s,l,t,i),this[t.lineName]&&this[t.lineName](this.store,t),this.store.path2dMap.set(t,kt.path2dDraws.line(t)),this.initLineRect(t))}restoreNodeAnimate(t){var i,s;if(t.calculative.initRect){if(t.keepAnimateState)for(const n in t)t.calculative[n]!==void 0&&n!=="x"&&n!=="y"&&n!=="width"&&n!=="height"&&n!=="initRect"&&(typeof t[n]!="object"||n==="lineDash")&&(n==="fontSize"||n==="lineWidth"?t[n]=t.calculative[n]/t.calculative.canvas.store.data.scale:t[n]=t.calculative[n]);else{const n=t.calculative.initRect.rotate-t.calculative.rotate;for(const r in t)r!=="x"&&r!=="y"&&r!=="width"&&r!=="height"&&r!=="initRect"&&r!=="rotate"&&(typeof t[r]!="object"||r==="lineDash")&&(t.calculative[r]=t[r]);(i=t.children)!=null&&i.length?n&&ag(t,n,t.calculative.worldRect):t.calculative.rotate=t.rotate;const a=ht(this.store.animateMap.get(t));a&&(a.id=t.id,this.parent.setValue(a,{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,_a(t)),(s=this.store.active)!=null&&s.length&&this.calcActiveRect(),t.calculative.initRect=void 0}}updateLines(t,i){var s;(s=t.children)==null||s.forEach(n=>{const a=this.store.pens[n];a&&this.updateLines(a,i)}),t.connectedLines&&t.connectedLines.forEach((n,a)=>{const r=this.store.pens[n.lineId];if(!r||r.calculative.active)return;const l=Ls(r,n.lineAnchor);if(!l)return;if(!l.connectTo){t.connectedLines.splice(a,1);return}if(r.autoFrom){const g=le(r);g.id===l.id&&this.calcAutoAnchor(r,g,t,n)}if(r.autoTo){const g=$t(r);g.id===l.id&&this.calcAutoAnchor(r,g,t,n)}const o=Ls(t,n.anchor);if(!o)return;let u=t.rotate;t.flipX&&(u*=-1),t.flipY&&(u*=-1);let c=l.distance*this.store.data.scale*Math.cos((u+o.rotate)/180*Math.PI)||0,f=l.distance*this.store.data.scale*Math.sin((u+o.rotate)/180*Math.PI)||0;if(t.flipX&&(c=-c),t.flipY&&(f=-f),aa(l,o.x-l.x+c,o.y-l.y+f),this.store.options.autoPolyline&&!this.autoPolylineFlag&&r.autoPolyline!==!1&&r.lineName==="polyline"){let g=le(r),v=$t(r),y=!1;g.id===l.id?(g=l,y=!0):v.id===l.id&&(v=l,y=!0),y&&(r.calculative.worldAnchors=[g,v],r.calculative.activeAnchor=g,this.polyline(this.store,r,v),this.initLineRect(r))}this.store.path2dMap.set(r,kt.path2dDraws[r.name](r)),this.patchFlagsLines.add(r),r.calculative.gradientSmooth&&(r.calculative.gradientAnimatePath=pc(r)),i&&Yr(r)})}calcActiveRect(){const t=this.store.active.filter(i=>(!i.locked||i.locked{Gt(n,i,s.center)}),this.initLineRect(t),Lr(t)):(t.calculative.rotate?t.calculative.rotate+=i:t.calculative.rotate=i,Gt(t.calculative.worldRect.center,i,s.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-s.x)/s.width,t.y=(t.calculative.worldRect.y-s.y)/s.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(n=>{const a=this.store.pens[n];this.rotatePen(a,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(s=>s.id===t.nextAnimate||s.tags&&s.tags.indexOf(t.nextAnimate)>-1)),i&&(i.forEach(s=>{var n,a,r,l,o;if(s.calculative.pause){const u=Date.now()-s.calculative.pause;s.calculative.pause=void 0,s.calculative.frameStart+=u,s.calculative.frameEnd+=u}else if(s.name==="video")s.calculative.media.currentTime=0,(n=s.calculative.media)==null||n.play(),(a=s.onStartVideo)==null||a.call(s,s);else if(s.type||((r=s.frames)==null?void 0:r.length)||s.animations&&s.animations.length){if(s.type){if((o=s.animations)!=null&&o.length){const u=ht(s.animations[0]);delete u.name,u.currentAnimation=0,this.parent.setValue({id:s.id,...u},{doEvent:!1,history:!1})}}else{if(!s.frames&&s.animations&&s.animations.length){let u=(l=s.animations)==null?void 0:l.findIndex(g=>g.autoPlay),c=u===-1?0:u;const f=ht(s.animations[c]);delete f.name,f.currentAnimation=c,!s.type&&f.frames&&(f.showDuration=this.parent.calcAnimateDuration(f)),this.parent.setValue({id:s.id,...f},{doEvent:!1,history:!1})}this.store.animateMap.set(s,this.getFrameProps(s))}this.store.animates.add(s)}}),this.animate())}getFrameProps(t){let i={};return t.frames&&t.frames.forEach(s=>{for(let n in s)!["duration","x","y","width","height","rotate"].includes(n)&&!i[n]&&(i[n]=t[n])}),i}animate(){this.animateRendering||requestAnimationFrame(()=>{const t=Date.now();if(t-this.lastAnimateRender0&&this.animate();return}this.lastAnimateRender=t,this.animateRendering=!0;const i=[];let s=!1;for(const n of this.store.animates)if(!n.calculative.pause){if(n.calculative.active&&!n.type&&!this.movingPens&&(s=!0),!n.type)x_(n,t)?n.calculative.patchFlags&&(Qt(n.calculative.worldRect),this.updatePenRect(n,{worldRectIsReady:!0,playingAnimate:!0})):(requestAnimationFrame(()=>{this.restoreNodeAnimate(n)}),i.push(n),this.nextAnimate(n)),this.updateLines(n,!0);else if(!k_(n,t)){if(n.keepAnimateState){for(const a in n)n.calculative[a]!==void 0&&a!=="length"&&(typeof n[a]!="object"||a==="lineDash")&&(a==="lineWidth"?n[a]=n.calculative[a]/n.calculative.canvas.store.data.scale:n[a]=n.calculative[a]);Lr(n)}else for(const a in n)(typeof n[a]!="object"||a==="lineDash")&&(a==="lineWidth"?n.calculative[a]=n[a]*n.calculative.canvas.store.data.scale:n.calculative[a]=n[a]);i.push(n),this.nextAnimate(n)}this.patchFlags=!0}s&&this.calcActiveRect(),i.forEach(n=>{this.store.animates.delete(n)}),this.render(!1),this.animateRendering=!1,this.animate()})}get clipboardName(){return"meta2d-clipboard"}async copy(t,i=!0){const s=It(),{origin:n,scale:a}=this.store.data;this.store.clipboard=void 0,localStorage.removeItem(this.clipboardName),sessionStorage.setItem("page",s);let r=this.getAllByPens(ht(t||this.store.active,!0));r.forEach(o=>{o.copyIndex=this.store.data.pens.findIndex(u=>u.id===o.id),o.pathId&&(o.path=this.store.data.paths[o.pathId])}),r.sort((o,u)=>o.copyIndex-u.copyIndex);const l={meta2d:!0,pens:r,origin:ht(n),scale:a,page:s,initRect:ht(this.activeRect),offset:10,mousePos:ht(this.mousePos)};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 o,u;let t,i;if(navigator.clipboard&&!this.store.options.disableClipboard&&!navigator.userAgent.includes("Firefox"))try{t=await((o=navigator.clipboard)==null?void 0:o.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 s,n;this.store.clipboard&&(s=this.store.clipboard.offset+10,n=this.store.clipboard.pos),this.store.clipboard=ht(i);const a=sessionStorage.getItem("page"),r=this.store.data.scale;if(this.store.clipboard.mousePos&&(Math.abs(this.store.clipboard.mousePos.x-this.mousePos.x)>100*r||Math.abs(this.store.clipboard.mousePos.y-this.mousePos.y)>100*r)){let c=-this.store.clipboard.initRect.width/this.store.clipboard.scale/10/r,f=-this.store.clipboard.initRect.height/this.store.clipboard.scale/10/r,g=(r-this.store.clipboard.scale)*this.store.clipboard.initRect.width/2+c,v=(r-this.store.clipboard.scale)*this.store.clipboard.initRect.height/2+f;r1&&(g=(r-1)*this.store.clipboard.initRect.width/this.store.clipboard.scale/2,v=(r-1)*this.store.clipboard.initRect.height/this.store.clipboard.scale/2),this.store.clipboard.pos={x:this.mousePos.x-g,y:this.mousePos.y-v},this.store.clipboard.offset=0}else a!==i.page?(this.store.clipboard.pos={x:this.mousePos.x,y:this.mousePos.y},this.store.clipboard.offset=0):this.pasteOffset?(s&&(this.store.clipboard.offset=s),n&&(this.store.clipboard.pos=n)):(this.store.clipboard.offset=0,this.pasteOffset=!0);(u=this.keyOptions)!=null&&u.F||this.store.clipboard.pens.forEach(c=>{delete c.copyIndex});const l=this.store.clipboard.pens.filter(c=>!c.parentId);for(const c of l)this.pastePen(c,void 0);sessionStorage.setItem("page",i.page),this.active(l),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 s of t)i.push(...ht(Qe(s,this.store),!0));return i.concat(t)}getAllFollowersByPens(t,i=!0){const s=t;for(const n of t){let a=yc(n,this.store);i&&(a=ht(a,!0));for(const r of a)s.find(l=>l.id===r.id)||s.push(r)}return s}setFollowers(t=this.store.active){if(!!t)if(t.length<2)t[0].followers=[];else{let i=t.map(n=>n.id);i.pop();const s=t[t.length-1];s.followers?i.forEach(n=>{s.followers.includes(n)||s.followers.push(n)}):s.followers=i}}changeLineAnchors(t,i,s){if(!!Array.isArray(i.connectedLines))for(let n=0;nl.id===a);if(r){const l=r.anchors[0],o=r.anchors[r.anchors.length-1];l.connectTo===t&&(l.connectTo=i.id),o.connectTo===t&&(o.connectTo=i.id)}else i.connectedLines.splice(n,1),n--}}changeNodeConnectedLine(t,i,s){var l;const n=i.anchors[0],a=i.anchors[i.anchors.length-1],r=[n,a];for(const o of r){const u=o.connectTo;if(u){const c=s.find(f=>f.id===u);c?(l=c.connectedLines)==null||l.forEach(f=>{f.lineId===t&&(f.lineId=i.id,f.lineAnchor=o.id)}):(o.connectTo=void 0,o.prev&&(o.prev.connectTo=void 0),o.next&&(o.next.connectTo=void 0))}}}async delete(t=this.store.active,i=!1,s=!0){if(!t||!t.length||this.beforeRemovePens&&await this.beforeRemovePens(t)!=!0||(i||(t=t.filter(a=>!a.locked)),!t||!t.length))return;const n=[];if(this._del(t,n,i),this.initImageCanvas(n),this.initTemplateCanvas(n),this.inactive(),this.clearHover(),this.render(),s){if(n.length===0)return;this.pushHistory({type:bt.Delete,pens:n})}this.store.emitter.emit("delete",t)}_del(t,i,s){!t||t.forEach(n=>{if(n.type&&(n.lastConnected={}),n.parentId)if(this.getLockedParent(n)){console.warn("\u7236\u8282\u70B9\u9501\u5B9A");return}else{const r=ti(n),l=r.children.indexOf(n.id);r.children.splice(l,1),i&&this.getDelPens(n,i),this.delForce(n)}else{if(!s&&n.locked)return;i&&this.getDelPens(n,i),this.delForce(n)}})}getDelPens(t,i){if(!t)return;if(this.store.data.pens.findIndex(n=>n.id===t.id)>-1){const n=this.store.pens[t.id];n&&n.calculative&&(n.calculative.active=void 0),i.push(n)}t.children&&t.children.forEach(n=>{this.getDelPens(this.store.pens[n],i)})}getLockedParent(t){if(!t.parentId)return!1;const i=ti(t);if(i.locked)return i;this.getLockedParent(i)}delForce(t){var s;if(!t)return;const i=this.store.data.pens.findIndex(n=>n.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(n=>{this.delForce(this.store.pens[n])}),(s=t.onDestroy)==null||s.call(t,t)}delConnectedLines(t){var i;if(t.connectedLines)for(let s=0;so.id===a);(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=Ls(r,a),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((s,n)=>{var r;if(!s.connectTo)return;const a=this.store.pens[s.connectTo];a&&((r=a.calculative.worldAnchors)==null||r.forEach(l=>{_n(a,l,t,s)}))})}convertSpecialCharacter(t){var i={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"'};return t.replace(/&(lt|gt|nbsp|amp|quot);/gi,function(s,n){return i[n]})}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{if(navigator.userAgent.includes("Firefox")){if(!i.target.innerText){let s=this.inputDiv.offsetWidth/2;window.getComputedStyle(this.inputDiv,null).textAlign!=="center"&&(s=0),this.inputDiv.innerHTML=`
`}}else if(i.target.innerText)this.inputDiv.style.paddingTop="";else{let s=window.getComputedStyle(this.inputDiv,null);s.justifyContent==="center"&&(this.inputDiv.style.paddingTop=` ${this.inputDiv.offsetHeight/2-parseFloat(s.lineHeight)/2}px`)}},this.inputDiv.onblur=()=>{setTimeout(()=>{this.hideInput()},300)},this.inputDiv.oninput=i=>{const s=this.store.pens[this.inputDiv.dataset.penId];if(s&&s.inputType==="number"){const n=i.target.innerText,a=n.replace(/[^0-9]/g,"");n!==a&&(i.preventDefault(),i.target.innerText=a)}if(navigator.userAgent.includes("Firefox")){if(!i.target.innerText.trim()){let n=this.inputDiv.offsetWidth/2;window.getComputedStyle(this.inputDiv,null).textAlign!=="center"&&(n=0),this.inputDiv.innerHTML=`
`}}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.store.emitter.emit("input",s)},this.inputDiv.onclick=i=>{i.stopPropagation();const s=this.store.pens[this.inputDiv.dataset.penId];this.dropdown.style.display==="block"?this.dropdown.style.display="none":(s==null?void 0:s.dropdownList)&&this.store.data.locked&&(this.dropdown.style.display="block"),this.store.emitter.emit("clickInput",s)},this.inputDiv.onkeyup=i=>{this.setDropdownList(!0);const s=this.store.pens[this.inputDiv.dataset.penId];this.store.emitter.emit("input",{pen:s,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 s="";i.clipboardData&&i.clipboardData.getData&&(s=i.clipboardData.getData("text/plain")),document.execCommand("insertHTML",!1,s)}}clearDropdownList(){if(this.dropdown.hasChildNodes())for(let t=0;t{s.style.background=n.dropdownHoverBackground||this.store.styles.activeBg||"#eee",s.style.color=n.dropdownHoverColor||"#bdc7db"},s.onmouseleave=()=>{s.style.background=n.dropdownBackground||this.store.styles.popContentBg||"#fff",s.style.color=n.dropdownColor||"#bdc7db"},this.dropdown.appendChild(s)}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 n,a,r,l,o,u,c;if(t===i)return;const s=this.store.pens[t];if(!!s&&!this.store.pens[i]){if(s.id=i,this.store.pens[i]=this.store.pens[t],(n=s.onChangeId)==null||n.call(s,s,t,i),delete this.store.pens[t],s.parentId){const f=this.store.pens[s.parentId],g=(a=f.children)==null?void 0:a.findIndex(v=>v===t);g!==-1&&((r=f.children)==null||r.splice(g,1,i))}(l=s.children)==null||l.forEach(f=>{const g=this.store.pens[f];g.parentId=i}),s.formId&&s.followers.forEach(f=>{const g=this.store.pens[f];g.formId=i}),s.type===jt.Line?this.changeNodeConnectedLine(t,s,this.store.data.pens):(this.changeLineAnchors(t,s,this.store.data.pens),(o=s.connectedLines)==null||o.forEach(({lineId:f})=>{const g=this.store.pens[f];An(g)})),(u=s.anchors)==null||u.forEach(f=>f.penId=i),(c=s.calculative.worldAnchors)==null||c.forEach(f=>f.penId=i)}}updateValue(t,i){var y,w,m,_,E,x;const s=this.getPenRect(t),n=t.name;Object.assign(t,i);const a=n!==t.name;i.newId&&this.changePenId(t.id,i.newId);let r=!1,l=!1,o=!1,u=!1,c=!1,f=!1,g,v=!1;for(const C in i)C.indexOf(".")===-1?(C==="rotate"?t.disableRotate?t.rotate=t.calculative.rotate||0:g=t.calculative.rotate||0:C==="canvasLayer"||C==="isBottom"||C==="showChild"?f=!0:C==="image"&&(v=!0),(typeof t[C]!="object"||C==="lineDash")&&(!t.disableRotate||C!=="rotate")&&(t.calculative[C]=i[C]),rx.includes(C)&&(l=!0),["name","borderRadius","lineSmooth","close"].includes(C)&&(r=!0),ox.includes(C)&&(c=!0),lx.includes(C)&&(o=!0),cx.includes(C)&&(u=!0),t.image&&t.name!=="gif"&&Bd.includes(C)&&(v=!0)):(delete t[C],$r(t,C,i[C])),C.split(".")[0]==="anchors"&&An(t);if(this.setCalculativeByScale(t),a&&((y=t.onDestroy)==null||y.call(t,t),hx(t)),c){const C={x:(w=i.x)!=null?w:s.x,y:(m=i.y)!=null?m:s.y,width:(_=i.width)!=null?_:s.width,height:(E=i.height)!=null?E:s.height};this.setPenRect(t,C,!1),this.updateLines(t,!0),this.store.active&&this.store.active.length&&t.id===this.store.active[0].id&&this.calcActiveRect()}else o?this.updatePenRect(t):(l&&Ri(t),u&&vf(this.store.pens,t),r&&kt.path2dDraws[t.name]&&this.store.path2dMap.set(t,kt.path2dDraws[t.name](t)));if(g!==void 0){const C=t.calculative.rotate;t.calculative.rotate=g,this.rotatePen(t,C-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),f?(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&&Re(t,t.calculative.singleton.div)}execPenResize(t){var i,s;(i=t.onResize)==null||i.call(t,t),(s=t.children)==null||s.forEach(n=>{const a=this.store.pens[n];a&&this.execPenResize(a)})}setPenRect(t,i,s=!0){if(t.parentId)Object.assign(t,i);else{const{origin:n,scale:a}=this.store.data;t.x=n.x+i.x*a,t.y=n.y+i.y*a,t.width=i.width*a,t.height=i.height*a}this.updatePenRect(t),this.execPenResize(t),s&&this.render()}getPenRect(t,i=this.store.data.origin,s=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)/s,y:(t.y-i.y)/s,width:t.width/s,height:t.height/s}}toPng(t=2,i,s=!1,n){const a=hi(this.store.data.pens),r=this.store.data.scale;if(!isFinite(a.width))throw new Error("can not to png, because width is not finite");const l=ht(a),o=this.store.data,u=s&&this.store.bkImg;let c=!1,f=!1;if(u){if(a.x+=o.x,a.y+=o.y,re(a),Xi(a,this.canvasRect,!0))Object.assign(a,this.canvasRect);else{const S=ka([...Zi(a),...Zi(this.canvasRect)]);Object.assign(a,S)}c=a.x===0,f=a.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&&(a.x=this.store.data.origin.x,a.y=this.store.data.origin.y,a.width=g*this.store.data.scale,a.height=v*this.store.data.scale);const w=ht(a),m=qi(t);a.x-=m[3]*r,a.y-=m[0]*r,a.width+=(m[3]+m[1])*r,a.height+=(m[0]+m[2])*r;const _=(n||1920)/a.width;a.width*=_,a.height*=_,re(a);const E=document.createElement("canvas");if(E.width=a.width,E.height=a.height,E.width>32767||E.height>32767||!navigator.userAgent.includes("Firefox")&&E.height*E.width>268435456||navigator.userAgent.includes("Firefox")&&E.height*E.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");const x=E.getContext("2d");x.textBaseline="middle",x.scale(_,_);const C=this.store.options.downloadBgTransparent?void 0:this.store.data.background||this.store.styles.background;if(C&&y&&(x.save(),x.fillStyle=C,x.fillRect(0,0,w.width+(m[1]+m[3])*r,w.height+(m[0]+m[2])*r),x.restore()),u)if(y)x.drawImage(this.store.bkImg,m[3]*r||0,m[0]*r||0,w.width,w.height);else{const S=a.x<0?-a.x:0,L=a.y<0?-a.y:0;x.drawImage(this.store.bkImg,S,L,this.canvasRect.width,this.canvasRect.height)}if(C&&!y)if(u){const S=a.x<0?-a.x:0,L=a.y<0?-a.y:0;x.save(),x.fillStyle=C,x.fillRect(S,L,this.canvasRect.width,this.canvasRect.height),x.restore()}else x.save(),x.fillStyle=C,x.fillRect(0,0,l.width+(m[3]+m[1])*r,l.height+(m[0]+m[2])*r),x.restore();u?y?x.translate(-a.x,-a.y):x.translate((c?o.x:-l.x)+m[3]*r||0,(f?o.y:-l.y)+m[0]*r||0):x.translate(-a.x,-a.y);for(const S of this.store.data.pens){if(!Vr(S,this.store)||S.visible==!1)continue;const{active:L}=S.calculative;S.calculative.active=!1,S.calculative.img?jr(x,S):Is(x,S,!0),S.calculative.active=L}if(i){E.toBlob(i);return}return E.toDataURL()}activeToPng(t=2,i){return this.pensToPng(this.store.active,t,i)}pensToPng(t=this.store.active,i=2,s){if(t.length===0)return;const n=this.getAllByPens(t);let a=n.map(v=>v.id);const r=hi(n);if(!isFinite(r.width))throw new Error("can not to png, because width is not finite");const l=ht(r),o=qi(i);r.x-=o[3],r.y-=o[0],r.width+=o[3]+o[1],r.height+=o[0]+o[2],re(r);const u=(s||r.width)/r.width;r.width*=u,r.height*=u;const c=document.createElement("canvas");if(c.width=r.width,c.height=r.height,c.width>32767||c.height>32767||!navigator.userAgent.includes("Firefox")&&c.height*c.width>268435456||navigator.userAgent.includes("Firefox")&&c.height*c.width>472907776)throw new Error("can not to png, because the size exceeds the browser limit");const f=c.getContext("2d");f.textBaseline="middle",f.scale(u,u);const g=this.store.options.downloadBgTransparent?void 0:this.store.data.background||this.store.styles.background;g&&(f.save(),f.fillStyle=g,f.fillRect(0,0,l.width+(o[3]+o[1]),l.height+(o[0]+o[2])),f.restore()),f.translate(-l.x+o[3],-l.y+o[0]);for(const v of this.store.data.pens)if(a.includes(v.id)){if(!Vr(v,this.store)||v.visible==!1)continue;const{active:y}=v.calculative;v.calculative.active=!1,v.calculative.img?jr(f,v):Is(f,v),v.calculative.active=y}return c.toDataURL()}toggleAnchorMode(){var t;if(this.hotkeyType)this.hotkeyType===Yt.AddAnchor&&(this.hotkeyType=Yt.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=Yt.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=[ht(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:[ht(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=[ht(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:[ht(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=Ns.Mirror),this.store.activeAnchor.prevNextType=(this.store.activeAnchor.prevNextType+1)%3)}gotoView(t,i){let s=hi(this.store.data.pens);if(!isFinite(s.width))throw new Error("can not move view, because width is not finite");const n=this.store.data.width||this.store.options.width,a=this.store.data.height||this.store.options.height;n&&a&&(s={x:this.store.data.origin.x,y:this.store.data.origin.y,width:n*this.store.data.scale,height:a*this.store.data.scale}),this.store.data.x=this.canvas.clientWidth/2-t*s.width-s.x,this.store.data.y=this.canvas.clientHeight/2-i*s.height-s.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.magnifierCanvas.render(),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(Xi(u.calculative.worldRect,this.dragRect,!0))return u.type===jt.Line&&!this.store.options.dragAllIn?Ll(u,this.dragRect):!0});if(!t.length)return;const i=this.parent.getRect(t),s=this.store.data.scale,n=this.store.data.width||this.store.options.width,a=this.store.data.height||this.store.options.height;let r=(Math.floor(i.x)-this.store.data.origin.x)/s/n,l=(Math.floor(i.y)-this.store.data.origin.y)/s/a,o={x:r,y:l,width:(Math.ceil(i.width)+1)/s/n,height:(Math.ceil(i.height)+1)/s/a,children:t.map(u=>u.id),id:It(),active:!0};o.x<-.1&&(o.x=-.1),o.y<-.1&&(o.y=-.1),o.width>.5?(o.left=!0,o.right=!0,o.leftValue=(o.x-0)*s*n,o.rightValue=(1-(o.x+o.width))*s*n):o.x<.5?(o.left=!0,o.leftValue=(o.x-0)*s*n):(o.right=!0,o.rightValue=(1-(o.x+o.width))*s*n),o.leftValue<1&&(o.leftValue=0),o.rightValue<1&&(o.rightValue=0),o.height>.5?(o.top=!0,o.bottom=!0,o.topValue=(o.y-0)*s*a,o.bottomValue=(1-(o.y+o.height))*s*a):o.y<.5?(o.top=!0,o.topValue=(o.y-0)*s*a):(o.bottom=!0,o.bottomValue=(1-(o.y+o.height))*s*a),o.topValue<1&&(o.topValue=0),o.bottomValue<1&&(o.bottomValue=0),this.store.data.fits||(this.store.data.fits=[]),this.store.data.fits.forEach(u=>{u.active=!1}),this.store.data.fits.push(o),this.canvasImage.activeFit=o,this.store.emitter.emit("fit",o),this.canvasImage.init(),this.canvasImage.render()}updateFit(t){const i=this.store.data.scale,s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height;let a=(t.x-this.store.data.origin.x)/i/s,r=(t.y-this.store.data.origin.y)/i/n;if(this.canvasImage.currentFit){const l=this.canvasImage.activeFit;if(this.canvasImage.currentFit==="top"){r<-.1&&(r=-.1);let c=r-l.y;if(l.height-=c,l.height<.01){l.height=.01;return}l.y=r}if(this.canvasImage.currentFit==="bottom"&&(r>1.1&&(r=1.1),l.height=r-l.y,l.height<=.01&&(l.height=.01)),this.canvasImage.currentFit==="left"){a<-.1&&(a=-.1);let c=a-l.x;if(l.width-=c,l.width<.01){l.width=.01;return}l.x=a}this.canvasImage.currentFit==="right"&&(a>1.1&&(a=1.1),l.width=a-l.x,l.width<=.01&&(l.width=.01));let o={x:l.x*s*i+this.store.data.origin.x,y:l.y*n*i+this.store.data.origin.y,width:l.width*s*i,height:l.height*n*i};re(o);const u=this.store.data.pens.filter(c=>{if(c.parentId||c.isRuleLine)return!1;if(Xi(c.calculative.worldRect,o,!0))return c.type===jt.Line&&!this.store.options.dragAllIn?Ll(c,o):!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*s,l.rightValue=(1-(l.x+l.width))*i*s):l.x<.5?(l.left=!0,l.leftValue=(l.x-0)*i*s):(l.right=!0,l.rightValue=(1-(l.x+l.width))*i*s),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*n,l.bottomValue=(1-(l.y+l.height))*i*n):l.y<.5?(l.top=!0,l.topValue=(l.y-0)*i*n):(l.bottom=!0,l.bottomValue=(1-(l.y+l.height))*i*n),Math.abs(l.topValue)<1&&(l.topValue=0),Math.abs(l.bottomValue)<1&&(l.bottomValue=0),l.children=u.map(c=>c.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,s=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/s:t.y=0),t.bottom&&(t.bottomValue?t.height=1-(Math.abs(t.bottomValue)<1?t.bottomValue:t.bottomValue/s)-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(s=>s.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 s=(this.mouseDown.x-this.store.data.origin.x)/this.store.data.scale/t,n=(this.mouseDown.y-this.store.data.origin.y)/this.store.data.scale/i,a=-1,r=-1;(l=this.store.data.fits)==null||l.forEach((o,u)=>{o.ex=null,o.ey=null,Ui({x:s,y:n},o)&&(a=u),o.active&&(r=u)}),a!==-1&&a!==r?(this.canvasImage.activeFit=this.store.data.fits[a],this.store.data.fits[a].active=!0,r!==-1&&(this.store.data.fits[r].active=!1),this.store.emitter.emit("fit",this.store.data.fits[a])):a===-1&&r!==-1&&(this.store.data.fits[r].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,s,n;switch(this.scroll&&this.scroll.destroy(),(t=this.tooltip)==null||t.destroy(),(i=this.dialog)==null||i.destroy(),(s=this.title)==null||s.destroy(),(n=this.popconfirm)==null||n.destroy(),this.externalElements.removeEventListener("gesturestart",this.onGesturestart),this.externalElements.ondragover=a=>a.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 Ds.Document:document.removeEventListener("keydown",this.onkeydown),document.removeEventListener("keyup",this.onkeyup);break;case Ds.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 Z2(e,t){const i=t||new Path2D;e.onDestroy||(e.onDestroy=Q2,e.onMove=zf,e.onRotate=zf,e.onMouseEnter=tk,e.onMouseLeave=ek,e.onMouseMove=sk,e.onMouseUp=ik,e.onInput=J2),e.formId=e.id;let s=e.calculative.borderRadius||0,n=s;const{x:a,y:r,width:l,height:o,ex:u,ey:c}=e.calculative.worldRect;e.calculative.worldTextRect,s<1&&(s=l*s,n=o*n);let f=s{if(e.followers){let s=e.followers.findIndex(n=>n===i.id);if(s!==-1){const n=e.calculative.canvas.store.pens[i.id+He];n&&n.calculative&&(Xi(n.calculative.worldRect,e.calculative.worldRect,!0)||(e.followers.splice(s,1),delete i.formId))}}})}function ik(e){const t=e.calculative.canvas.store.active;t&&t.length&&t.forEach(i=>{const s=e.calculative.canvas.store.pens[i.id+He];if(s&&s.calculative){let n=ht(e.calculative.worldRect);n.x-=1,n.y-=1,n.width+=2,n.height+=2,Xi(s.calculative.worldRect,n,!0)&&(e.followers||(e.followers=[]),e.followers.includes(i.id)||e.followers.push(i.id),i.formId=e.id)}})}function sk(e,t){}function Hf(e,t){if(e.formId&&e.formKey&&e.formValue){const i=e.calculative.canvas.store.pens[e.formId];i&&(i.formData||(i.formData={}),i.formData[e.formKey]=e[e.formValue])}}function nk(e){const t=e.calculative.canvas.store.pens[e.formId];t.followers.forEach(i=>{const s=e.calculative.canvas.store.pens[i];if(s.formId&&s.formKey&&t.formData[s.formKey]){const n=s[s.formValue];let a="";Array.isArray(n)&&(a=[]),e.calculative.canvas.parent.setValue({id:s.id,[s.formValue]:a},{render:!1,doEvent:!1,history:!1})}}),t.formData={},e.calculative.canvas.parent.render()}const ge={};function ak(e){e.onDestroy||(e.onDestroy=rk,e.onMove=Wf,e.onResize=ok,e.onRotate=Wf,e.onValue=lk,e.onChangeId=ck);const t=new Path2D;if(!e.image)return;const s=e.calculative.canvas.store.id+"-"+e.id;if(!ge[s]){const n=new Image;n.crossOrigin="anonymous",n.src=e.image,e.calculative.canvas.parent.store.options.cdn&&!(e.image.startsWith("http")||e.image.startsWith("//")||e.image.startsWith("data:image"))&&(n.src=e.calculative.canvas.parent.store.options.cdn+e.image),ge[s]=n,n.onload=()=>{var a;ge[s]===n&&(e.calculative.img=n,e.calculative.imgNaturalWidth=n.naturalWidth||e.iconWidth,e.calculative.imgNaturalHeight=n.naturalHeight||e.iconHeight,(a=e.calculative.canvas.externalElements)==null||a.parentElement.appendChild(n),ya(e,n))}}return e.calculative.patchFlags&&ge[s]&&ya(e,ge[s]),t}function rk(e){const i=e.calculative.canvas.store.id+"-"+e.id;ge[i]&&(ge[i].remove(),ge[i]=void 0)}function Wf(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||ya(e,ge[i])}function ok(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||ya(e,ge[i])}function lk(e){const i=e.calculative.canvas.store.id+"-"+e.id;!ge[i]||(ya(e,ge[i]),ge[i].getAttribute("src")!==e.image&&(ge[i].src=e.image))}function ck(e,t,i){const s=e.calculative.canvas.store.id;!ge[s+"-"+t]||(ge[s+"-"+i]=ge[s+"-"+t],delete ge[s+"-"+t])}function ya(e,t){t.style.objectFit=e.imageRatio?"contain":"fill",Re(e,t)}function hk(e,t){return e.onResize||(e.onResize=bg,e.onValue=uk),Fs(e,t)}function bg(e){const t=e.anchors.filter(i=>i.flag!==1);xg(e),e.anchors=e.anchors.concat(...t)}function uk(e){bg(e),An(e)}function xg(e){const t=[],{x:i,y:s,width:n,height:a}=e,r=fk(e),l=5;for(let f=0;fi+n-r&&(v=Er(i+n-r,v+r,g,r,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(g-i)/n,y:(v-s)/a})}const o=3;for(let f=0;fs+a-r&&(v=kr(v-r,s+a-r,g,r)),t.push({id:String(t.length),flag:1,penId:e.id,x:(v-i)/n,y:(g-s)/a})}const u=5;for(let f=0;fi+n-r&&(v=Er(i+n-r,v-r,g,r)),t.push({id:String(t.length),flag:1,penId:e.id,x:(g-i)/n,y:(v-s)/a})}const c=3;for(let f=0;fs+a-r&&(v=kr(v+r,s+a-r,g,r,-1)),t.push({id:String(t.length),flag:1,penId:e.id,x:(v-i)/n,y:(g-s)/a})}e.anchors=t}function fk(e){let t=e.calculative.borderRadius||0,i=e.calculative.borderRadius||0;const{width:s,height:n}=e;e.calculative.borderRadius<1&&(t=s*e.calculative.borderRadius,i=n*e.calculative.borderRadius);let a=t({id:n+"",x:i,y:s,penId:e.id}))}function vk(){return{rectangle:Fs,square:nx,circle:ax,svgPath:t2,diamond:e2,triangle:i2,pentagon:n2,pentagram:r2,hexagon:l2,leftArrow:c2,rightArrow:h2,twowayArrow:u2,message:f2,cloud:d2,file:g2,people:y2,line:b2,iframe:F2,video:U2,gif:ak,mindNode:hk,mindLine:dk,mindNode2:Fs,form:Z2,combine:Fs}}function yk(){return{triangle:s2,pentagon:a2,pentagram:cg,mindNode:xg,mindLine:gk}}var he;(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"})(he||(he={}));class mk{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,"timer");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 o=.2;t.deltaY.toString().indexOf(".")!==-1&&(o=.01),t.deltaY>0?i=-o:i=o}let{offsetX:s,offsetY:n}=t;const a=this.parent.store.data.width||this.parent.store.options.width,r=this.parent.store.data.height||this.parent.store.options.height;if(a&&r)s=s/this.boxWidth*a*this.parent.store.data.scale+this.parent.store.data.origin.x+this.parent.store.data.x,n=n/this.boxHeight*r*this.parent.store.data.scale+this.parent.store.data.origin.y+this.parent.store.data.y;else{const l=this.parent.parent.getRect();s=s/this.boxWidth*l.width+l.x+this.parent.store.data.x,n=n/this.boxHeight*l.height+l.y+this.parent.store.data.y}this.parent.scale(this.parent.store.data.scale+i,{x:s,y:n})});var s;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),(s=this.parent.externalElements)==null||s.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 n=0;n{this.parent.store.bkImg&&(this.img.src=this.parent.toPng(0,void 0,!0))},300)),Ms(i,t.x,t.y),i.width/i.height>this.ratio){const f=i.width/this.ratio;i.y-=(f-i.height)/2,i.height=f,re(i)}else{const f=i.height*this.ratio;i.x-=(f-i.width)/2,i.width=f,re(i)}const r=this.parent.canvasRect;let l=0,o=0;if(i.x<0)l=-i.x/i.width;else if(i.x+i.width>r.width){let f=0;r.width>i.width&&(f=r.width-i.width),l=(-i.x+f)/i.width}if(i.y<0)o=-i.y/i.height;else if(i.y+i.height>r.height){let f=0;r.height>i.height&&(f=r.height-i.height),o=(-i.y+f)/i.height}const u=r.width>i.width?1:r.width/i.width,c=r.height>i.height?1:r.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+o*this.boxHeight+"px",this.view.style.height=c*this.boxHeight+"px"}}}function Ar(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 ia={exports:{}};(function(e,t){(function(i){e.exports=i()})(function(){return function(){return function i(s,n,a){function r(u,c){if(!n[u]){if(!s[u]){var f=typeof Ar=="function"&&Ar;if(!c&&f)return f(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=n[u]={exports:{}};s[u][0].call(v.exports,function(y){return r(s[u][1][y]||y)},v,v.exports,i,s,n,a)}return n[u].exports}for(var l=typeof Ar=="function"&&Ar,o=0;o0&&(O.topicAliasMaximum>65535?x("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new u(O.topicAliasMaximum)),this.on("connect",function(){const at=this.queue;x("connect :: sending queued packets"),function V(){const H=at.shift();x("deliver :: entry %o",H);let j=null;if(!H)return void Z._resubscribe();j=H.packet,x("deliver :: call _sendPacket for %o",j);let K=!0;j.messageId&&j.messageId!==0&&(Z.messageIdProvider.register(j.messageId)||(K=!1)),K?Z._sendPacket(j,function(U){H.cb&&H.cb(U),V()}):(x("messageId: %d has already used. The message is skipped and removed.",j.messageId),V())}()}),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 P=this,O=new v,Y=f.parser(this.options);let Z=null;const at=[];function V(){if(at.length)C(H);else{const K=Z;Z=null,K()}}function H(){x("work :: getting next packet in queue");const K=at.shift();if(K)x("work :: packet pulled from queue"),P._handlePacket(K,V);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),Y.on("packet",function(K){x("parser :: on packet push to packets array."),at.push(K)}),O._write=function(K,U,tt){Z=tt,x("writable stream :: parsing buffer"),Y.parse(K),H()},x("_setupStream :: pipe stream to writable stream"),this.stream.pipe(O),this.stream.on("error",function(K){x("streamErrorHandler :: error",K.message),K.code?(x("streamErrorHandler :: emitting error"),P.emit("error",K)):R(K)}),this.stream.on("close",function(){var K;x("(%s)stream :: on close",P.options.clientId),(K=P.outgoing)&&(x("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(K).forEach(function(U){K[U].volatile&&typeof K[U].cb=="function"&&(K[U].cb(new Error("Connection closed")),delete K[U])})),x("stream: emit close to MqttClient"),P.emit("close")}),x("_setupStream: sending packet `connect`");const j=Object.create(this.options);if(j.cmd="connect",this.topicAliasRecv&&(j.properties||(j.properties={}),this.topicAliasRecv&&(j.properties.topicAliasMaximum=this.topicAliasRecv.max)),$(this,j),Y.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return P.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"&&$(this,E({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`"),P._cleanUp(!0)},this.options.connectTimeout)},T.prototype._handlePacket=function(P,O){const Y=this.options;if(Y.protocolVersion===5&&Y.properties&&Y.properties.maximumPacketSize&&Y.properties.maximumPacketSize0||!H())&&this._storeProcessingQueue.push({invoke:H,cbStorePut:Y.cbStorePut,callback:Z}),this},T.prototype.subscribe=function(){const P=this,O=new Array(arguments.length);for(let st=0;st0){const ot={qos:ct.qos};j===5&&(ot.nl=ct.nl||!1,ot.rap=ct.rap||!1,ot.rh=ct.rh||0,ot.properties=ct.properties),P._resubscribeTopics[ct.topic]=ot,ut.push(ct.topic)}}),P.messageIdToTopic[et.messageId]=ut}return P.outgoing[et.messageId]={volatile:!0,cb:function(ut,ct){if(!ut){const ot=ct.granted;for(let b=0;b0||!tt())&&this._storeProcessingQueue.push({invoke:tt,callback:V}),this},T.prototype.unsubscribe=function(){const P=this,O=new Array(arguments.length);for(let j=0;j0||!H())&&this._storeProcessingQueue.push({invoke:H,callback:Z}),this},T.prototype.end=function(P,O,Y){const Z=this;function at(){x("end :: (%s) :: finish :: calling _cleanUp with force %s",Z.options.clientId,P),Z._cleanUp(P,()=>{x("end :: finish :: calling process.nextTick on closeStores"),C(function(){x("end :: closeStores: closing incoming and outgoing stores"),Z.disconnected=!0,Z.incomingStore.close(function(V){Z.outgoingStore.close(function(H){if(x("end :: closeStores: emitting end"),Z.emit("end"),Y){const j=V||H;x("end :: closeStores: invoking callback with args"),Y(j)}})}),Z._deferredReconnect&&Z._deferredReconnect()}.bind(Z))},O)}return x("end :: (%s)",this.options.clientId),P!=null&&typeof P=="boolean"||(Y=O||R,O=P,P=!1,typeof O!="object"&&(Y=O,O=null,typeof Y!="function"&&(Y=R))),typeof O!="object"&&(Y=O,O=null),x("end :: cb? %s",!!Y),Y=Y||R,this.disconnecting?(Y(),this):(this._clearReconnect(),this.disconnecting=!0,!P&&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,at,10))):(x("end :: (%s) :: immediately calling finish",Z.options.clientId),at()),this)},T.prototype.removeOutgoingMessage=function(P){const O=this.outgoing[P]?this.outgoing[P].cb:null;return delete this.outgoing[P],this.outgoingStore.del({messageId:P},function(){O(new Error("Message removed"))}),this},T.prototype.reconnect=function(P){x("client reconnect");const O=this,Y=function(){P?(O.options.incomingStore=P.incomingStore,O.options.outgoingStore=P.outgoingStore):(O.options.incomingStore=null,O.options.outgoingStore=null),O.incomingStore=O.options.incomingStore||new o,O.outgoingStore=O.options.outgoingStore||new o,O.disconnecting=!1,O.disconnected=!1,O._deferredReconnect=null,O._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=Y:Y(),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 P=this;!P.disconnecting&&!P.reconnectTimer&&P.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",P.options.reconnectPeriod),P.reconnectTimer=setInterval(function(){x("reconnectTimer :: reconnect triggered!"),P._reconnect()},P.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(P,O){const Y=arguments[2];if(O&&(x("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",O)),x("_cleanUp :: forced? %s",P),P)this.options.reconnectPeriod===0&&this.options.clean&&(Z=this.outgoing)&&(x("flush: queue exists? %b",!!Z),Object.keys(Z).forEach(function(at){typeof Z[at].cb=="function"&&(Z[at].cb(new Error("Connection closed")),delete Z[at])})),x("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const at=E({cmd:"disconnect"},Y);x("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(at,S.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(P,O,Y){x("_sendPacket :: (%s) :: start",this.options.clientId),Y=Y||R,O=O||R;const Z=function(at,V){if(at.options.protocolVersion===5&&V.cmd==="publish"){let H;V.properties&&(H=V.properties.topicAlias);const j=V.topic.toString();if(at.topicAliasSend)if(H){if(j.length!==0&&(x("applyTopicAlias :: register topic: %s - alias: %d",j,H),!at.topicAliasSend.put(j,H)))return x("applyTopicAlias :: error out of range. topic: %s - alias: %d",j,H),new Error("Sending Topic Alias out of range")}else j.length!==0&&(at.options.autoAssignTopicAlias?(H=at.topicAliasSend.getAliasByTopic(j))?(V.topic="",V.properties={...V.properties,topicAlias:H},x("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",j,H)):(H=at.topicAliasSend.getLruAlias(),at.topicAliasSend.put(j,H),V.properties={...V.properties,topicAlias:H},x("applyTopicAlias :: auto assign topic: %s - alias: %d",j,H)):at.options.autoUseTopicAlias&&(H=at.topicAliasSend.getAliasByTopic(j))&&(V.topic="",V.properties={...V.properties,topicAlias:H},x("applyTopicAlias :: auto use topic: %s - alias: %d",j,H)));else if(H)return x("applyTopicAlias :: error out of range. topic: %s - alias: %d",j,H),new Error("Sending Topic Alias out of range")}}(this,P);if(Z)O(Z);else{if(!this.connected)return P.cmd==="auth"?(this._shiftPingInterval(),void $(this,P,O)):(x("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(P,O,Y));switch(this._shiftPingInterval(),P.cmd){case"publish":break;case"pubrel":return void Q(this,P,O,Y);default:return void $(this,P,O)}switch(P.qos){case 2:case 1:Q(this,P,O,Y);break;case 0:default:$(this,P,O)}x("_sendPacket :: (%s) :: end",this.options.clientId)}},T.prototype._storePacket=function(P,O,Y){x("_storePacket :: packet: %o",P),x("_storePacket :: cb? %s",!!O),Y=Y||R;let Z=P;if(Z.cmd==="publish"){const at=D(this,Z=m(P));if(at)return O&&O(at)}(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(at){if(at)return O&&O(at);Y()})):O&&O(new Error("No connection to broker"))},T.prototype._setupPingTimer=function(){x("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const P=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=w(function(){P._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(P){x("_handleConnack");const O=this.options,Y=O.protocolVersion===5?P.reasonCode:P.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,P.properties){if(P.properties.topicAliasMaximum){if(P.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));P.properties.topicAliasMaximum>0&&(this.topicAliasSend=new c(P.properties.topicAliasMaximum))}P.properties.serverKeepAlive&&O.keepalive&&(O.keepalive=P.properties.serverKeepAlive,this._shiftPingInterval()),P.properties.maximumPacketSize&&(O.properties||(O.properties={}),O.properties.maximumPacketSize=P.properties.maximumPacketSize)}if(Y===0)this.reconnecting=!1,this._onConnect(P);else if(Y>0){const Z=new Error("Connection refused: "+M[Y]);Z.code=Y,this.emit("error",Z)}},T.prototype._handleAuth=function(P){const O=this.options.protocolVersion,Y=O===5?P.reasonCode:P.returnCode;if(O!==5){const at=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+O);return at.code=Y,void this.emit("error",at)}const Z=this;this.handleAuth(P,function(at,V){if(at)Z.emit("error",at);else if(Y===24)Z.reconnecting=!1,Z._sendPacket(V);else{const H=new Error("Connection refused: "+M[Y]);at.code=Y,Z.emit("error",H)}})},T.prototype.handleAuth=function(P,O){O()},T.prototype._handlePublish=function(P,O){x("_handlePublish: packet %o",P),O=O!==void 0?O:R;let Y=P.topic.toString();const Z=P.payload,at=P.qos,V=P.messageId,H=this,j=this.options,K=[0,16,128,131,135,144,145,151,153];if(this.options.protocolVersion===5){let U;if(P.properties&&(U=P.properties.topicAlias),U!==void 0)if(Y.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",Y=tt,U)}}else{if(!this.topicAliasRecv.put(Y,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",Y,U)}}switch(x("_handlePublish: qos %d",at),at){case 2:j.customHandleAcks(Y,Z,P,function(U,tt){return U instanceof Error||(tt=U,U=null),U?H.emit("error",U):K.indexOf(tt)===-1?H.emit("error",new Error("Wrong reason code for pubrec")):void(tt?H._sendPacket({cmd:"pubrec",messageId:V,reasonCode:tt},O):H.incomingStore.put(P,function(){H._sendPacket({cmd:"pubrec",messageId:V},O)}))});break;case 1:j.customHandleAcks(Y,Z,P,function(U,tt){return U instanceof Error||(tt=U,U=null),U?H.emit("error",U):K.indexOf(tt)===-1?H.emit("error",new Error("Wrong reason code for puback")):(tt||H.emit("message",Y,Z,P),void H.handleMessage(P,function(st){if(st)return O&&O(st);H._sendPacket({cmd:"puback",messageId:V,reasonCode:tt},O)}))});break;case 0:this.emit("message",Y,Z,P),this.handleMessage(P,O);break;default:x("_handlePublish: unknown QoS. Doing nothing.")}},T.prototype.handleMessage=function(P,O){O()},T.prototype._handleAck=function(P){const O=P.messageId,Y=P.cmd;let Z=null;const at=this.outgoing[O]?this.outgoing[O].cb:null,V=this;let H;if(at){switch(x("_handleAck :: packet type",Y),Y){case"pubcomp":case"puback":{const j=P.reasonCode;j&&j>0&&j!==16&&((H=new Error("Publish error: "+M[j])).code=j,at(H,P)),delete this.outgoing[O],this.outgoingStore.del(P,at),this.messageIdProvider.deallocate(O),this._invokeStoreProcessingQueue();break}case"pubrec":{Z={cmd:"pubrel",qos:2,messageId:O};const j=P.reasonCode;j&&j>0&&j!==16?((H=new Error("Publish error: "+M[j])).code=j,at(H,P)):this._sendPacket(Z);break}case"suback":delete this.outgoing[O],this.messageIdProvider.deallocate(O);for(let j=0;j0)if(this.options.resubscribe)if(this.options.protocolVersion===5){x("_resubscribe: protocolVersion 5");for(let O=0;O0){const P=this._storeProcessingQueue[0];if(P&&P.invoke())return this._storeProcessingQueue.shift(),!0}return!1},T.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},T.prototype._flushStoreProcessingQueue=function(){for(const P of this._storeProcessingQueue)P.cbStorePut&&P.cbStorePut(new Error("Connection closed")),P.callback&&P.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},s.exports=T}).call(this)}).call(this,i("_process"),typeof De<"u"?De: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,s,n){const{Buffer:a}=i("buffer"),r=i("readable-stream").Transform,l=i("duplexify");let o,u,c,f=!1;s.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(m){m.hostname||(m.hostname="localhost"),m.path||(m.path="/"),m.wsOptions||(m.wsOptions={})})(v);const w=function(m,_){const E=m.protocol==="alis"?"wss":"ws";let x=E+"://"+m.hostname+m.path;return m.port&&m.port!==80&&m.port!==443&&(x=E+"://"+m.hostname+":"+m.port+m.path),typeof m.transformWsUrl=="function"&&(x=m.transformWsUrl(x,m,_)),x}(v,g);return(o=v.my).connectSocket({url:w,protocols:y}),u=function(){const m=new r;return m._write=function(_,E,x){o.sendSocketMessage({data:_.buffer,success:function(){x()},fail:function(){x(new Error)}})},m._flush=function(_){o.closeSocket({success:function(){_()}})},m}(),c=l.obj(),f||(f=!0,o.onSocketOpen(function(){c.setReadable(u),c.setWritable(u),c.emit("connect")}),o.onSocketMessage(function(m){if(typeof m.data=="string"){const _=a.from(m.data,"base64");u.push(_)}else{const _=new FileReader;_.addEventListener("load",function(){let E=_.result;E=E instanceof ArrayBuffer?a.from(E):a.from(E,"utf8"),u.push(E)}),_.readAsArrayBuffer(m.data)}}),o.onSocketClose(function(){c.end(),c.destroy()}),o.onSocketError(function(m){c.destroy(m)})),c}},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(i,s,n){const a=i("net"),r=i("debug")("mqttjs:tcp");s.exports=function(l,o){o.port=o.port||1883,o.hostname=o.hostname||o.host||"localhost";const u=o.port,c=o.hostname;return r("port %d and host %s",u,c),a.createConnection(u,c)}},{debug:18,net:16}],4:[function(i,s,n){const a=i("tls"),r=i("net"),l=i("debug")("mqttjs:tls");s.exports=function(o,u){u.port=u.port||8883,u.host=u.hostname||u.host||"localhost",r.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 c=a.connect(u);function f(g){u.rejectUnauthorized&&o.emit("error",g),c.end()}return c.on("secureConnect",function(){u.rejectUnauthorized&&!c.authorized?c.emit("error",new Error("TLS not authorized")):c.removeListener("error",f)}),c.on("error",f),c}},{debug:18,net:16,tls:16}],5:[function(i,s,n){(function(a){(function(){const{Buffer:r}=i("buffer"),l=i("ws"),o=i("debug")("mqttjs:ws"),u=i("duplexify"),c=i("readable-stream").Transform,f=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],g=a!==void 0&&a.title==="browser"||typeof __webpack_require__=="function";function v(w,m){let _=w.protocol+"://"+w.hostname+":"+w.port+w.path;return typeof w.transformWsUrl=="function"&&(_=w.transformWsUrl(_,w,m)),_}function y(w){const m=w;return w.hostname||(m.hostname="localhost"),w.port||(w.protocol==="wss"?m.port=443:m.port=80),w.path||(m.path="/"),w.wsOptions||(m.wsOptions={}),g||w.protocol!=="wss"||f.forEach(function(_){Object.prototype.hasOwnProperty.call(w,_)&&!Object.prototype.hasOwnProperty.call(w.wsOptions,_)&&(m.wsOptions[_]=w[_])}),m}s.exports=g?function(w,m){let _;o("browserStreamBuilder");const E=function(P){const O=y(P);if(O.hostname||(O.hostname=O.host),!O.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");const Y=new URL(document.URL);O.hostname=Y.hostname,O.port||(O.port=Y.port)}return O.objectMode===void 0&&(O.objectMode=!(O.binary===!0||O.binary===void 0)),O}(m).browserBufferSize||524288,x=m.browserBufferTimeout||1e3,C=!m.objectMode,S=function(P,O){const Y=O.protocolId==="MQIsdp"&&O.protocolVersion===3?"mqttv3.1":"mqtt",Z=v(O,P),at=new WebSocket(Z,[Y]);return at.binaryType="arraybuffer",at}(w,m),L=function(P,O,Y){const Z=new c({objectModeMode:P.objectMode});return Z._write=O,Z._flush=Y,Z}(m,function P(O,Y,Z){S.bufferedAmount>E&&setTimeout(P,x,O,Y,Z),C&&typeof O=="string"&&(O=r.from(O,"utf8"));try{S.send(O)}catch(at){return Z(at)}Z()},function(P){S.close(),P()});m.objectMode||(L._writev=T),L.on("close",()=>{S.close()});const M=S.addEventListener!==void 0;function D(){_.setReadable(L),_.setWritable(L),_.emit("connect")}function $(){_.end(),_.destroy()}function Q(P){_.destroy(P)}function R(P){let O=P.data;O=O instanceof ArrayBuffer?r.from(O):r.from(O,"utf8"),L.push(O)}function T(P,O){const Y=new Array(P.length);for(let Z=0;Z{C.destroy()}),C}}).call(this)}).call(this,i("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(i,s,n){const{Buffer:a}=i("buffer"),r=i("readable-stream").Transform,l=i("duplexify");let o,u,c;s.exports=function(f,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(m){m.hostname||(m.hostname="localhost"),m.path||(m.path="/"),m.wsOptions||(m.wsOptions={})})(g);const y=function(m,_){const E=m.protocol==="wxs"?"wss":"ws";let x=E+"://"+m.hostname+m.path;return m.port&&m.port!==80&&m.port!==443&&(x=E+"://"+m.hostname+":"+m.port+m.path),typeof m.transformWsUrl=="function"&&(x=m.transformWsUrl(x,m,_)),x}(g,f);o=wx.connectSocket({url:y,protocols:[v]}),u=function(){const m=new r;return m._write=function(_,E,x){o.send({data:_.buffer,success:function(){x()},fail:function(C){x(new Error(C))}})},m._flush=function(_){o.close({success:function(){_()}})},m}(),(c=l.obj())._destroy=function(m,_){o.close({success:function(){_&&_(m)}})};const w=c.destroy;return c.destroy=function(){c.destroy=w;const m=this;setTimeout(function(){o.close({fail:function(){m._destroy(new Error)}})},0)}.bind(c),o.onOpen(function(){c.setReadable(u),c.setWritable(u),c.emit("connect")}),o.onMessage(function(m){let _=m.data;_=_ instanceof ArrayBuffer?a.from(_):a.from(_,"utf8"),u.push(_)}),o.onClose(function(){c.end(),c.destroy()}),o.onError(function(m){c.destroy(new Error(m.errMsg))}),c}},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(i,s,n){function a(){if(!(this instanceof a))return new a;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}a.prototype.allocate=function(){const r=this.nextId++;return this.nextId===65536&&(this.nextId=1),r},a.prototype.getLastAllocated=function(){return this.nextId===1?65535:this.nextId-1},a.prototype.register=function(r){return!0},a.prototype.deallocate=function(r){},a.prototype.clear=function(){},s.exports=a},{}],8:[function(i,s,n){const a=i("xtend"),r=i("readable-stream").Readable,l={objectMode:!0},o={clean:!0};function u(c){if(!(this instanceof u))return new u(c);this.options=c||{},this.options=a(o,c),this._inflights=new Map}u.prototype.put=function(c,f){return this._inflights.set(c.messageId,c),f&&f(),this},u.prototype.createStream=function(){const c=new r(l),f=[];let g=!1,v=0;return this._inflights.forEach(function(y,w){f.push(y)}),c._read=function(){!g&&vthis.max)&&(this.aliasToTopic[l]=r,this.length=Object.keys(this.aliasToTopic).length,!0)},a.prototype.getTopicByAlias=function(r){return this.aliasToTopic[r]},a.prototype.clear=function(){this.aliasToTopic={}},s.exports=a},{}],10:[function(i,s,n){const a=i("lru-cache"),r=i("number-allocator").NumberAllocator;function l(o){if(!(this instanceof l))return new l(o);o>0&&(this.aliasToTopic=new a({max:o}),this.topicToAlias={},this.numberAllocator=new r(1,o),this.max=o,this.length=0)}l.prototype.put=function(o,u){if(u===0||u>this.max)return!1;const c=this.aliasToTopic.get(u);return c&&delete this.topicToAlias[c],this.aliasToTopic.set(u,o),this.topicToAlias[o]=u,this.numberAllocator.use(u),this.length=this.aliasToTopic.length,!0},l.prototype.getTopicByAlias=function(o){return this.aliasToTopic.get(o)},l.prototype.getAliasByTopic=function(o){const u=this.topicToAlias[o];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]},s.exports=l},{"lru-cache":37,"number-allocator":46}],11:[function(i,s,n){function a(r){const l=r.split("/");for(let o=0;o0?_-4:_;for(w=0;w>16&255,x[C++]=y>>8&255,x[C++]=255&y;return E===2&&(y=r[v.charCodeAt(w)]<<2|r[v.charCodeAt(w+1)]>>4,x[C++]=255&y),E===1&&(y=r[v.charCodeAt(w)]<<10|r[v.charCodeAt(w+1)]<<4|r[v.charCodeAt(w+2)]>>2,x[C++]=y>>8&255,x[C++]=255&y),x},n.fromByteArray=function(v){for(var y,w=v.length,m=w%3,_=[],E=0,x=w-m;Ex?x:E+16383));return m===1?(y=v[w-1],_.push(a[y>>2]+a[y<<4&63]+"==")):m===2&&(y=(v[w-2]<<8)+v[w-1],_.push(a[y>>10]+a[y>>4&63]+a[y<<2&63]+"=")),_.join("")};for(var a=[],r=[],l=typeof Uint8Array<"u"?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,c=o.length;u0)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 m,_,E=[],x=y;x>18&63]+a[_>>12&63]+a[_>>6&63]+a[63&_]);return E.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},{}],14:[function(i,s,n){const{Buffer:a}=i("buffer"),r=Symbol.for("BufferList");function l(o){if(!(this instanceof l))return new l(o);l._init.call(this,o)}l._init=function(o){Object.defineProperty(this,r,{value:!0}),this._bufs=[],this.length=0,o&&this.append(o)},l.prototype._new=function(o){return new l(o)},l.prototype._offset=function(o){if(o===0)return[0,0];let u=0;for(let c=0;cthis.length||o<0)return;const u=this._offset(o);return this._bufs[u[0]][u[1]]},l.prototype.slice=function(o,u){return typeof o=="number"&&o<0&&(o+=this.length),typeof u=="number"&&u<0&&(u+=this.length),this.copy(null,0,o,u)},l.prototype.copy=function(o,u,c,f){if((typeof c!="number"||c<0)&&(c=0),(typeof f!="number"||f>this.length)&&(f=this.length),c>=this.length||f<=0)return o||a.alloc(0);const g=!!o,v=this._offset(c),y=f-c;let w=y,m=g&&u||0,_=v[1];if(c===0&&f===this.length){if(!g)return this._bufs.length===1?this._bufs[0]:a.concat(this._bufs,this.length);for(let E=0;Ex)){this._bufs[E].copy(o,m,_,_+w),m+=x;break}this._bufs[E].copy(o,m,_),m+=x,w-=x,_&&(_=0)}return o.length>m?o.slice(0,m):o},l.prototype.shallowSlice=function(o,u){if(o=o||0,u=typeof u!="number"?this.length:u,o<0&&(o+=this.length),u<0&&(u+=this.length),o===u)return this._new();const c=this._offset(o),f=this._offset(u),g=this._bufs.slice(c[0],f[0]+1);return f[1]===0?g.pop():g[g.length-1]=g[g.length-1].slice(0,f[1]),c[1]!==0&&(g[0]=g[0].slice(c[1])),this._new(g)},l.prototype.toString=function(o,u,c){return this.slice(u,c).toString(o)},l.prototype.consume=function(o){if(o=Math.trunc(o),Number.isNaN(o)||o<=0)return this;for(;this._bufs.length;){if(!(o>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(o),this.length-=o;break}o-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},l.prototype.duplicate=function(){const o=this._new();for(let u=0;uthis.length?this.length:u;const f=this._offset(u);let g=f[0],v=f[1];for(;g=o.length){const w=y.indexOf(o,v);if(w!==-1)return this._reverseOffset([g,w]);v=y.length-o.length+1}else{const w=this._reverseOffset([g,v]);if(this._match(w,o))return w;v++}v=0}return-1},l.prototype._match=function(o,u){if(this.length-oo)throw new RangeError('The value "'+b+'" is invalid for option "size"');var k=new Uint8Array(b);return k.__proto__=c.prototype,k}function c(b,k,I){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 f(b,k,I)}function f(b,k,I){if(typeof b=="string")return function(G,rt){if(typeof rt=="string"&&rt!==""||(rt="utf8"),!c.isEncoding(rt))throw new TypeError("Unknown encoding: "+rt);var mt=0|m(G,rt),yt=u(mt),Et=yt.write(G,rt);return Et!==mt&&(yt=yt.slice(0,Et)),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(ct(b,ArrayBuffer)||b&&ct(b.buffer,ArrayBuffer))return function(G,rt,mt){if(rt<0||G.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|b}function m(b,k){if(c.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||ct(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 I=b.length,N=arguments.length>2&&arguments[2]===!0;if(!N&&I===0)return 0;for(var X=!1;;)switch(k){case"ascii":case"latin1":case"binary":return I;case"utf8":case"utf-8":return st(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*I;case"hex":return I>>>1;case"base64":return et(b).length;default:if(X)return N?-1:st(b).length;k=(""+k).toLowerCase(),X=!0}}function _(b,k,I){var N=b[k];b[k]=b[I],b[I]=N}function E(b,k,I,N,X){if(b.length===0)return-1;if(typeof I=="string"?(N=I,I=0):I>2147483647?I=2147483647:I<-2147483648&&(I=-2147483648),ot(I=+I)&&(I=X?0:b.length-1),I<0&&(I=b.length+I),I>=b.length){if(X)return-1;I=b.length-1}else if(I<0){if(!X)return-1;I=0}if(typeof k=="string"&&(k=c.from(k,N)),c.isBuffer(k))return k.length===0?-1:x(b,k,I,N,X);if(typeof k=="number")return k&=255,typeof Uint8Array.prototype.indexOf=="function"?X?Uint8Array.prototype.indexOf.call(b,k,I):Uint8Array.prototype.lastIndexOf.call(b,k,I):x(b,[k],I,N,X);throw new TypeError("val must be string, number or Buffer")}function x(b,k,I,N,X){var G,rt=1,mt=b.length,yt=k.length;if(N!==void 0&&((N=String(N).toLowerCase())==="ucs2"||N==="ucs-2"||N==="utf16le"||N==="utf-16le")){if(b.length<2||k.length<2)return-1;rt=2,mt/=2,yt/=2,I/=2}function Et(xe,Vt){return rt===1?xe[Vt]:xe.readUInt16BE(Vt*rt)}if(X){var Tt=-1;for(G=I;Gmt&&(I=mt-yt),G=I;G>=0;G--){for(var be=!0,se=0;seX&&(N=X):N=X;var G=k.length;N>G/2&&(N=G/2);for(var rt=0;rt>8,yt=rt%256,Et.push(yt),Et.push(mt);return Et}(k,b.length-I),b,I,N)}function Q(b,k,I){return k===0&&I===b.length?r.fromByteArray(b):r.fromByteArray(b.slice(k,I))}function R(b,k,I){I=Math.min(b.length,I);for(var N=[],X=k;X239?4:Et>223?3:Et>191?2:1;if(X+be<=I)switch(be){case 1:Et<128&&(Tt=Et);break;case 2:(192&(G=b[X+1]))==128&&(yt=(31&Et)<<6|63&G)>127&&(Tt=yt);break;case 3:G=b[X+1],rt=b[X+2],(192&G)==128&&(192&rt)==128&&(yt=(15&Et)<<12|(63&G)<<6|63&rt)>2047&&(yt<55296||yt>57343)&&(Tt=yt);break;case 4:G=b[X+1],rt=b[X+2],mt=b[X+3],(192&G)==128&&(192&rt)==128&&(192&mt)==128&&(yt=(15&Et)<<18|(63&G)<<12|(63&rt)<<6|63&mt)>65535&&yt<1114112&&(Tt=yt)}Tt===null?(Tt=65533,be=1):Tt>65535&&(Tt-=65536,N.push(Tt>>>10&1023|55296),Tt=56320|1023&Tt),N.push(Tt),X+=be}return function(se){var xe=se.length;if(xe<=T)return String.fromCharCode.apply(String,se);for(var Vt="",te=0;te"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(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),typeof Symbol<"u"&&Symbol.species!=null&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),c.poolSize=8192,c.from=function(b,k,I){return f(b,k,I)},c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,c.alloc=function(b,k,I){return function(N,X,G){return g(N),N<=0?u(N):X!==void 0?typeof G=="string"?u(N).fill(X,G):u(N).fill(X):u(N)}(b,k,I)},c.allocUnsafe=function(b){return v(b)},c.allocUnsafeSlow=function(b){return v(b)},c.isBuffer=function(b){return b!=null&&b._isBuffer===!0&&b!==c.prototype},c.compare=function(b,k){if(ct(b,Uint8Array)&&(b=c.from(b,b.offset,b.byteLength)),ct(k,Uint8Array)&&(k=c.from(k,k.offset,k.byteLength)),!c.isBuffer(b)||!c.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(b===k)return 0;for(var I=b.length,N=k.length,X=0,G=Math.min(I,N);Xthis.length||((N===void 0||N>this.length)&&(N=this.length),N<=0)||(N>>>=0)<=(I>>>=0))return"";for(k||(k="utf8");;)switch(k){case"hex":return Y(this,I,N);case"utf8":case"utf-8":return R(this,I,N);case"ascii":return P(this,I,N);case"latin1":case"binary":return O(this,I,N);case"base64":return Q(this,I,N);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Z(this,I,N);default:if(X)throw new TypeError("Unknown encoding: "+k);k=(k+"").toLowerCase(),X=!0}}.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(b){if(!c.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||c.compare(this,b)===0},c.prototype.inspect=function(){var b="",k=n.INSPECT_MAX_BYTES;return b=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(b+=" ... "),""},c.prototype.compare=function(b,k,I,N,X){if(ct(b,Uint8Array)&&(b=c.from(b,b.offset,b.byteLength)),!c.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),I===void 0&&(I=b?b.length:0),N===void 0&&(N=0),X===void 0&&(X=this.length),k<0||I>b.length||N<0||X>this.length)throw new RangeError("out of range index");if(N>=X&&k>=I)return 0;if(N>=X)return-1;if(k>=I)return 1;if(k>>>=0,I>>>=0,N>>>=0,X>>>=0,this===b)return 0;for(var G=X-N,rt=I-k,mt=Math.min(G,rt),yt=this.slice(N,X),Et=b.slice(k,I),Tt=0;Tt>>=0,isFinite(I)?(I>>>=0,N===void 0&&(N="utf8")):(N=I,I=void 0)}var X=this.length-k;if((I===void 0||I>X)&&(I=X),b.length>0&&(I<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");N||(N="utf8");for(var G=!1;;)switch(N){case"hex":return C(this,b,k,I);case"utf8":case"utf-8":return S(this,b,k,I);case"ascii":return L(this,b,k,I);case"latin1":case"binary":return M(this,b,k,I);case"base64":return D(this,b,k,I);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,b,k,I);default:if(G)throw new TypeError("Unknown encoding: "+N);N=(""+N).toLowerCase(),G=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function P(b,k,I){var N="";I=Math.min(b.length,I);for(var X=k;XN)&&(I=N);for(var X="",G=k;GI)throw new RangeError("Trying to access beyond buffer length")}function V(b,k,I,N,X,G){if(!c.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(k>X||kb.length)throw new RangeError("Index out of range")}function H(b,k,I,N,X,G){if(I+N>b.length)throw new RangeError("Index out of range");if(I<0)throw new RangeError("Index out of range")}function j(b,k,I,N,X){return k=+k,I>>>=0,X||H(b,0,I,4),l.write(b,k,I,N,23,4),I+4}function K(b,k,I,N,X){return k=+k,I>>>=0,X||H(b,0,I,8),l.write(b,k,I,N,52,8),I+8}c.prototype.slice=function(b,k){var I=this.length;b=~~b,k=k===void 0?I:~~k,b<0?(b+=I)<0&&(b=0):b>I&&(b=I),k<0?(k+=I)<0&&(k=0):k>I&&(k=I),k>>=0,k>>>=0,I||at(b,k,this.length);for(var N=this[b],X=1,G=0;++G>>=0,k>>>=0,I||at(b,k,this.length);for(var N=this[b+--k],X=1;k>0&&(X*=256);)N+=this[b+--k]*X;return N},c.prototype.readUInt8=function(b,k){return b>>>=0,k||at(b,1,this.length),this[b]},c.prototype.readUInt16LE=function(b,k){return b>>>=0,k||at(b,2,this.length),this[b]|this[b+1]<<8},c.prototype.readUInt16BE=function(b,k){return b>>>=0,k||at(b,2,this.length),this[b]<<8|this[b+1]},c.prototype.readUInt32LE=function(b,k){return b>>>=0,k||at(b,4,this.length),(this[b]|this[b+1]<<8|this[b+2]<<16)+16777216*this[b+3]},c.prototype.readUInt32BE=function(b,k){return b>>>=0,k||at(b,4,this.length),16777216*this[b]+(this[b+1]<<16|this[b+2]<<8|this[b+3])},c.prototype.readIntLE=function(b,k,I){b>>>=0,k>>>=0,I||at(b,k,this.length);for(var N=this[b],X=1,G=0;++G=(X*=128)&&(N-=Math.pow(2,8*k)),N},c.prototype.readIntBE=function(b,k,I){b>>>=0,k>>>=0,I||at(b,k,this.length);for(var N=k,X=1,G=this[b+--N];N>0&&(X*=256);)G+=this[b+--N]*X;return G>=(X*=128)&&(G-=Math.pow(2,8*k)),G},c.prototype.readInt8=function(b,k){return b>>>=0,k||at(b,1,this.length),128&this[b]?-1*(255-this[b]+1):this[b]},c.prototype.readInt16LE=function(b,k){b>>>=0,k||at(b,2,this.length);var I=this[b]|this[b+1]<<8;return 32768&I?4294901760|I:I},c.prototype.readInt16BE=function(b,k){b>>>=0,k||at(b,2,this.length);var I=this[b+1]|this[b]<<8;return 32768&I?4294901760|I:I},c.prototype.readInt32LE=function(b,k){return b>>>=0,k||at(b,4,this.length),this[b]|this[b+1]<<8|this[b+2]<<16|this[b+3]<<24},c.prototype.readInt32BE=function(b,k){return b>>>=0,k||at(b,4,this.length),this[b]<<24|this[b+1]<<16|this[b+2]<<8|this[b+3]},c.prototype.readFloatLE=function(b,k){return b>>>=0,k||at(b,4,this.length),l.read(this,b,!0,23,4)},c.prototype.readFloatBE=function(b,k){return b>>>=0,k||at(b,4,this.length),l.read(this,b,!1,23,4)},c.prototype.readDoubleLE=function(b,k){return b>>>=0,k||at(b,8,this.length),l.read(this,b,!0,52,8)},c.prototype.readDoubleBE=function(b,k){return b>>>=0,k||at(b,8,this.length),l.read(this,b,!1,52,8)},c.prototype.writeUIntLE=function(b,k,I,N){b=+b,k>>>=0,I>>>=0,N||V(this,b,k,I,Math.pow(2,8*I)-1,0);var X=1,G=0;for(this[k]=255&b;++G>>=0,I>>>=0,N||V(this,b,k,I,Math.pow(2,8*I)-1,0);var X=I-1,G=1;for(this[k+X]=255&b;--X>=0&&(G*=256);)this[k+X]=b/G&255;return k+I},c.prototype.writeUInt8=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,1,255,0),this[k]=255&b,k+1},c.prototype.writeUInt16LE=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,2,65535,0),this[k]=255&b,this[k+1]=b>>>8,k+2},c.prototype.writeUInt16BE=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,2,65535,0),this[k]=b>>>8,this[k+1]=255&b,k+2},c.prototype.writeUInt32LE=function(b,k,I){return b=+b,k>>>=0,I||V(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},c.prototype.writeUInt32BE=function(b,k,I){return b=+b,k>>>=0,I||V(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},c.prototype.writeIntLE=function(b,k,I,N){if(b=+b,k>>>=0,!N){var X=Math.pow(2,8*I-1);V(this,b,k,I,X-1,-X)}var G=0,rt=1,mt=0;for(this[k]=255&b;++G>0)-mt&255;return k+I},c.prototype.writeIntBE=function(b,k,I,N){if(b=+b,k>>>=0,!N){var X=Math.pow(2,8*I-1);V(this,b,k,I,X-1,-X)}var G=I-1,rt=1,mt=0;for(this[k+G]=255&b;--G>=0&&(rt*=256);)b<0&&mt===0&&this[k+G+1]!==0&&(mt=1),this[k+G]=(b/rt>>0)-mt&255;return k+I},c.prototype.writeInt8=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,1,127,-128),b<0&&(b=255+b+1),this[k]=255&b,k+1},c.prototype.writeInt16LE=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,2,32767,-32768),this[k]=255&b,this[k+1]=b>>>8,k+2},c.prototype.writeInt16BE=function(b,k,I){return b=+b,k>>>=0,I||V(this,b,k,2,32767,-32768),this[k]=b>>>8,this[k+1]=255&b,k+2},c.prototype.writeInt32LE=function(b,k,I){return b=+b,k>>>=0,I||V(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},c.prototype.writeInt32BE=function(b,k,I){return b=+b,k>>>=0,I||V(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},c.prototype.writeFloatLE=function(b,k,I){return j(this,b,k,!0,I)},c.prototype.writeFloatBE=function(b,k,I){return j(this,b,k,!1,I)},c.prototype.writeDoubleLE=function(b,k,I){return K(this,b,k,!0,I)},c.prototype.writeDoubleBE=function(b,k,I){return K(this,b,k,!1,I)},c.prototype.copy=function(b,k,I,N){if(!c.isBuffer(b))throw new TypeError("argument should be a Buffer");if(I||(I=0),N||N===0||(N=this.length),k>=b.length&&(k=b.length),k||(k=0),N>0&&N=this.length)throw new RangeError("Index out of range");if(N<0)throw new RangeError("sourceEnd out of bounds");N>this.length&&(N=this.length),b.length-k=0;--G)b[G+k]=this[G+I];else Uint8Array.prototype.set.call(b,this.subarray(I,N),k);return X},c.prototype.fill=function(b,k,I,N){if(typeof b=="string"){if(typeof k=="string"?(N=k,k=0,I=this.length):typeof I=="string"&&(N=I,I=this.length),N!==void 0&&typeof N!="string")throw new TypeError("encoding must be a string");if(typeof N=="string"&&!c.isEncoding(N))throw new TypeError("Unknown encoding: "+N);if(b.length===1){var X=b.charCodeAt(0);(N==="utf8"&&X<128||N==="latin1")&&(b=X)}}else typeof b=="number"&&(b&=255);if(k<0||this.length>>=0,I=I===void 0?this.length:I>>>0,b||(b=0),typeof b=="number")for(G=k;G55295&&I<57344){if(!X){if(I>56319){(k-=3)>-1&&G.push(239,191,189);continue}if(rt+1===N){(k-=3)>-1&&G.push(239,191,189);continue}X=I;continue}if(I<56320){(k-=3)>-1&&G.push(239,191,189),X=I;continue}I=65536+(X-55296<<10|I-56320)}else X&&(k-=3)>-1&&G.push(239,191,189);if(X=null,I<128){if((k-=1)<0)break;G.push(I)}else if(I<2048){if((k-=2)<0)break;G.push(I>>6|192,63&I|128)}else if(I<65536){if((k-=3)<0)break;G.push(I>>12|224,I>>6&63|128,63&I|128)}else{if(!(I<1114112))throw new Error("Invalid code point");if((k-=4)<0)break;G.push(I>>18|240,I>>12&63|128,I>>6&63|128,63&I|128)}}return G}function et(b){return r.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 ut(b,k,I,N){for(var X=0;X=k.length||X>=b.length);++X)k[X+I]=b[X];return X}function ct(b,k){return b instanceof k||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===k.name}function ot(b){return b!=b}}).call(this)}).call(this,i("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(i,s,n){(function(a){(function(){n.formatArgs=function(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+s.exports.humanize(this.diff),!this.useColors)return;const o="color: "+this.color;l.splice(1,0,o,"color: inherit");let u=0,c=0;l[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&f==="%c"&&(c=++u)}),l.splice(c,0,o)},n.save=function(l){try{l?n.storage.setItem("debug",l):n.storage.removeItem("debug")}catch{}},n.load=function(){let l;try{l=n.storage.getItem("debug")}catch{}return!l&&a!==void 0&&"env"in a&&(l=a.env.DEBUG),l},n.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+)/)},n.storage=function(){try{return localStorage}catch{}}(),n.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`."))}})(),n.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"],n.log=console.debug||console.log||(()=>{}),s.exports=i("./common")(n);const{formatters:r}=s.exports;r.j=function(l){try{return JSON.stringify(l)}catch(o){return"[UnexpectedJSONParseError]: "+o.message}}}).call(this)}).call(this,i("_process"))},{"./common":19,_process:50}],19:[function(i,s,n){s.exports=function(a){function r(u){let c,f,g,v=null;function y(...w){if(!y.enabled)return;const m=y,_=Number(new Date),E=_-(c||_);m.diff=E,m.prev=c,m.curr=_,c=_,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let x=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(C,S)=>{if(C==="%%")return"%";x++;const L=r.formatters[S];if(typeof L=="function"){const M=w[x];C=L.call(m,M),w.splice(x,1),x--}return C}),r.formatArgs.call(m,w),(m.log||r.log).apply(m,w)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=l,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(f!==r.namespaces&&(f=r.namespaces,g=r.enabled(u)),g),set:w=>{v=w}}),typeof r.init=="function"&&r.init(y),y}function l(u,c){const f=r(this.namespace+(c===void 0?":":c)+u);return f.log=this.log,f}function o(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(u){return u instanceof Error?u.stack||u.message:u},r.disable=function(){const u=[...r.names.map(o),...r.skips.map(o).map(c=>"-"+c)].join(",");return r.enable(""),u},r.enable=function(u){let c;r.save(u),r.namespaces=u,r.names=[],r.skips=[];const f=(typeof u=="string"?u:"").split(/[\s,]+/),g=f.length;for(c=0;c{r[u]=a[u]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(u){let c=0;for(let f=0;f0&&$.length>M){$.warned=!0;var Q=new Error("Possible EventEmitter memory leak detected. "+$.length+' "'+String(C)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');Q.name="MaxListenersExceededWarning",Q.emitter=x,Q.type=C,Q.count=$.length,typeof console=="object"&&console.warn&&console.warn("%s: %s",Q.name,Q.message)}}else $=D[C]=S,++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),C=0;C1&&(C=arguments[1]),C instanceof Error)throw C;var R=new Error('Unhandled "error" event. ('+C+")");throw R.context=C,R}if(!(S=$[x]))return!1;var T=typeof S=="function";switch(L=arguments.length){case 1:(function(P,O,Y){if(O)P.call(Y);else for(var Z=P.length,at=E(P,Z),V=0;V=0;D--)if(S[D]===C||S[D].listener===C){$=S[D].listener,M=D;break}if(M<0)return this;M===0?S.shift():function(Q,R){for(var T=R,P=T+1,O=Q.length;P=0;L--)this.removeListener(x,C[L]);return this},o.prototype.listeners=function(x){return m(this,x,!0)},o.prototype.rawListeners=function(x){return m(this,x,!1)},o.listenerCount=function(x,C){return typeof x.listenerCount=="function"?x.listenerCount(C):_.call(x,C)},o.prototype.listenerCount=_,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(i,s,n){n.read=function(a,r,l,o,u){var c,f,g=8*u-o-1,v=(1<>1,w=-7,m=l?u-1:0,_=l?-1:1,E=a[r+m];for(m+=_,c=E&(1<<-w)-1,E>>=-w,w+=g;w>0;c=256*c+a[r+m],m+=_,w-=8);for(f=c&(1<<-w)-1,c>>=-w,w+=o;w>0;f=256*f+a[r+m],m+=_,w-=8);if(c===0)c=1-y;else{if(c===v)return f?NaN:1/0*(E?-1:1);f+=Math.pow(2,o),c-=y}return(E?-1:1)*f*Math.pow(2,c-o)},n.write=function(a,r,l,o,u,c){var f,g,v,y=8*c-u-1,w=(1<>1,_=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=o?0:c-1,x=o?1:-1,C=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(g=isNaN(r)?1:0,f=w):(f=Math.floor(Math.log(r)/Math.LN2),r*(v=Math.pow(2,-f))<1&&(f--,v*=2),(r+=f+m>=1?_/v:_*Math.pow(2,1-m))*v>=2&&(f++,v/=2),f+m>=w?(g=0,f=w):f+m>=1?(g=(r*v-1)*Math.pow(2,u),f+=m):(g=r*Math.pow(2,m-1)*Math.pow(2,u),f=0));u>=8;a[l+E]=255&g,E+=x,g/=256,u-=8);for(f=f<0;a[l+E]=255&f,E+=x,f/=256,y-=8);a[l+E-x]|=128*C}},{}],24:[function(i,s,n){typeof Object.create=="function"?s.exports=function(a,r){r&&(a.super_=r,a.prototype=Object.create(r.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:s.exports=function(a,r){if(r){a.super_=r;var l=function(){};l.prototype=r.prototype,a.prototype=new l,a.prototype.constructor=a}}},{}],25:[function(i,s,n){Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function r(l,o){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=o}return r.prototype.rotateLeft=function(){var l=this.parent,o=this.brother,u=this.leftChild,c=this.rightChild;if(!c)throw new Error("unknown error");var f=c.leftChild,g=c.rightChild;return l&&(l.leftChild===this?l.leftChild=c:l.rightChild===this&&(l.rightChild=c)),c.parent=l,c.brother=o,c.leftChild=this,c.rightChild=g,o&&(o.brother=c),this.parent=c,this.brother=g,this.leftChild=u,this.rightChild=f,g&&(g.parent=c,g.brother=this),u&&(u.parent=this,u.brother=f),f&&(f.parent=this,f.brother=u),c},r.prototype.rotateRight=function(){var l=this.parent,o=this.brother,u=this.leftChild;if(!u)throw new Error("unknown error");var c=this.rightChild,f=u.leftChild,g=u.rightChild;return l&&(l.leftChild===this?l.leftChild=u:l.rightChild===this&&(l.rightChild=u)),u.parent=l,u.brother=o,u.leftChild=f,u.rightChild=this,o&&(o.brother=u),f&&(f.parent=u,f.brother=this),this.parent=u,this.brother=f,this.leftChild=g,this.rightChild=c,g&&(g.parent=this,g.brother=c),c&&(c.parent=this,c.brother=g),u},r.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},r.TreeNodeColorType={red:!0,black:!1},r}();Object.freeze(a),n.default=a},{}],26:[function(i,s,n){var a=this&&this.__generator||function(l,o){var u,c,f,g,v={label:0,sent:function(){if(1&f[0])throw f[1];return f[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(m){return function(_){if(u)throw new TypeError("Generator is already executing.");for(;v;)try{if(u=1,c&&(f=2&_[0]?c.return:_[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,_[1])).done)return f;switch(c=0,f&&(_=[2&_[0],f.value]),_[0]){case 0:case 1:f=_;break;case 4:return v.label++,{value:_[1],done:!1};case 5:v.label++,c=_[1],_=[0];continue;case 7:_=v.ops.pop(),v.trys.pop();continue;default:if(!(f=(f=v.trys).length>0&&f[f.length-1])&&(_[0]===6||_[0]===2)){v=0;continue}if(_[0]===3&&(!f||_[1]>f[0]&&_[1]S)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(C/r.bucketSize),curNodePointerIndex:C%r.bucketSize}};this.getElementByPos=function(E){var x=m(E),C=x.curNodeBucketIndex,S=x.curNodePointerIndex;return u[C][S]},this.eraseElementByPos=function(E){var x=this;if(E<0||E>w)throw new Error("pos should more than 0 and less than queue's size");if(E===0)this.popFront();else if(E===this.size())this.popBack();else{for(var C=[],S=E+1;S0?--v:c0&&--w)},this.setElementByPos=function(E,x){var C=m(E),S=C.curNodeBucketIndex,L=C.curNodePointerIndex;u[S][L]=x},this.insert=function(E,x,C){var S=this;if(C===void 0&&(C=1),E===0)for(;C--;)this.pushFront(x);else if(E===this.size())for(;C--;)this.pushBack(x);else{for(var L=[],M=E;M0?--f:c>0&&(--c,f=r.bucketSize-1)),++w,u[c][f]=E},this.popFront=function(){this.empty()||(this.size()!==1&&(f0&&--w)},this.shrinkToFit=function(){var E=this,x=[];this.forEach(function(M){x.push(M)});var C=x.length;u=[];for(var S=Math.ceil(C/r.bucketSize),L=0;L0&&y[y.length-1])&&(C[0]===6||C[0]===2)){m=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]=c.length&&(c=void 0),{value:c&&c[v++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i("../LinkList/LinkList"),o=i("../Map/Map");function u(c,f,g){var v=this;if(c===void 0&&(c=[]),f===void 0&&(f=u.initSize),g=g||function(_){var E,x,C=0,S="";if(typeof _=="number")C=((C=Math.floor(_))<<5)-C,C&=C;else{S=typeof _!="string"?JSON.stringify(_):_;try{for(var L=r(S),M=L.next();!M.done;M=L.next())C=(C<<5)-C+M.value.charCodeAt(0),C&=C}catch(D){E={error:D}}finally{try{M&&!M.done&&(x=L.return)&&x.call(L)}finally{if(E)throw E.error}}}return C^=C>>>16},(f&f-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var y=0,w=[],m=Math.max(u.initSize,Math.min(u.maxSize,f));this.size=function(){return y},this.empty=function(){return y===0},this.clear=function(){y=0,m=f,w=[]},this.forEach=function(_){var E=0;w.forEach(function(x){x.forEach(function(C){_(C,E++)})})},this.setElement=function(_,E){var x,C;if(_==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(E!=null){var S=g(_)&m-1;if(w[S]){var L=w[S].size();if(w[S]instanceof l.default){try{for(var M=r(w[S]),D=M.next();!D.done;D=M.next()){var $=D.value;if($.key===_)return void($.value=E)}}catch(R){x={error:R}}finally{try{D&&!D.done&&(C=M.return)&&C.call(M)}finally{if(x)throw x.error}}w[S].pushBack({key:_,value:E}),w[S].size()>=u.treeifyThreshold&&(w[S]=new o.default(w[S]))}else w[S].setElement(_,E);var Q=w[S].size();y+=Q-L}else++y,w[S]=new l.default([{key:_,value:E}]);y>m*u.sigma&&function(R){if(!(R>=u.maxSize)){m=2*R;var T=[];w.forEach(function(P,O){if(!P.empty()){if(P instanceof l.default&&P.size()===1){var Y=P.front(),Z=Y.key,at=Y.value;T[g(Z)&m-1]=new l.default([{key:Z,value:at}])}else if(P instanceof o.default){var V=new l.default,H=new l.default;P.forEach(function(U){(g(U.key)&R)==0?V.pushBack(U):H.pushBack(U)}),V.size()>u.untreeifyThreshold?T[O]=new o.default(V):V.size()&&(T[O]=V),H.size()>u.untreeifyThreshold?T[O+R]=new o.default(H):H.size()&&(T[O+R]=H)}else{var j=new l.default,K=new l.default;P.forEach(function(U){(g(U.key)&R)==0?j.pushBack(U):K.pushBack(U)}),j.size()&&(T[O]=j),K.size()&&(T[O+R]=K)}w[O].clear()}}),w=T}}.call(this,m)}else this.eraseElementByKey(_)},this.getElementByKey=function(_){var E,x,C=g(_)&m-1;if(w[C]){if(w[C]instanceof o.default)return w[C].getElementByKey(_);try{for(var S=r(w[C]),L=S.next();!L.done;L=S.next()){var M=L.value;if(M.key===_)return M.value}}catch(D){E={error:D}}finally{try{L&&!L.done&&(x=S.return)&&x.call(S)}finally{if(E)throw E.error}}}},this.eraseElementByKey=function(_){var E,x,C=g(_)&m-1;if(w[C]){var S=w[C].size();if(w[C]instanceof o.default)w[C].eraseElementByKey(_),w[C].size()<=u.untreeifyThreshold&&(w[C]=new l.default(w[C]));else{var L=-1;try{for(var M=r(w[C]),D=M.next();!D.done;D=M.next())if(++L,D.value.key===_){w[C].eraseElementByPos(L);break}}catch(Q){E={error:Q}}finally{try{D&&!D.done&&(x=M.return)&&x.call(M)}finally{if(E)throw E.error}}}var $=w[C].size();y+=$-S}},this.find=function(_){var E,x,C=g(_)&m-1;if(!w[C])return!1;if(w[C]instanceof o.default)return w[C].find(_);try{for(var S=r(w[C]),L=S.next();!L.done;L=S.next())if(L.value.key===_)return!0}catch(M){E={error:M}}finally{try{L&&!L.done&&(x=S.return)&&x.call(S)}finally{if(E)throw E.error}}return!1},this[Symbol.iterator]=function(){return function(){var _,E,x,C,S,L;return a(this,function(M){switch(M.label){case 0:_=0,M.label=1;case 1:if(!(_=m)return[3,10];M.label=2;case 2:M.trys.push([2,7,8,9]),S=void 0,E=r(w[_]),x=E.next(),M.label=3;case 3:return x.done?[3,6]:[4,x.value];case 4:M.sent(),M.label=5;case 5:return x=E.next(),[3,3];case 6:return[3,9];case 7:return C=M.sent(),S={error:C},[3,9];case 8:try{x&&!x.done&&(L=E.return)&&L.call(E)}finally{if(S)throw S.error}return[7];case 9:return++_,[3,1];case 10:return[2]}})}()},c.forEach(function(_){var E=_.key,x=_.value;return v.setElement(E,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),n.default=u},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(i,s,n){var a=this&&this.__generator||function(c,f){var g,v,y,w,m={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 _(E){return function(x){return function(C){if(g)throw new TypeError("Generator is already executing.");for(;m;)try{if(g=1,v&&(y=2&C[0]?v.return:C[0]?v.throw||((y=v.return)&&y.call(v),0):v.next)&&!(y=y.call(v,C[1])).done)return y;switch(v=0,y&&(C=[2&C[0],y.value]),C[0]){case 0:case 1:y=C;break;case 4:return m.label++,{value:C[1],done:!1};case 5:m.label++,v=C[1],C=[0];continue;case 7:C=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(C[0]===6||C[0]===2)){m=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]=c.length&&(c=void 0),{value:c&&c[v++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i("../Set/Set"),o=i("../LinkList/LinkList");function u(c,f,g){var v=this;if(c===void 0&&(c=[]),f===void 0&&(f=u.initSize),g=g||function(_){var E=0,x="";if(typeof _=="number")E=((E=Math.floor(_))<<5)-E,E&=E;else{x=typeof _!="string"?JSON.stringify(_):_;for(var C=0;C>>16},(f&f-1)!=0)throw new Error("initBucketNum must be 2 to the power of n");var y=0,w=[],m=Math.max(u.initSize,Math.min(u.maxSize,f));this.size=function(){return y},this.empty=function(){return y===0},this.clear=function(){y=0,m=f,w=[]},this.forEach=function(_){var E=0;w.forEach(function(x){x.forEach(function(C){_(C,E++)})})},this.insert=function(_){if(_==null)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var E=g(_)&m-1;if(w[E]){var x=w[E].size();if(w[E]instanceof o.default){if(w[E].find(_))return;w[E].pushBack(_),w[E].size()>=u.treeifyThreshold&&(w[E]=new l.default(w[E]))}else w[E].insert(_);var C=w[E].size();y+=C-x}else w[E]=new o.default([_]),++y;y>m*u.sigma&&function(S){if(!(S>=u.maxSize)){m=2*S;var L=[];w.forEach(function(M,D){if(!M.empty()){if(M instanceof o.default&&M.size()===1){var $=M.front();if($===void 0)throw new Error("unknown error");L[g($)&m-1]=new o.default([$])}else if(M instanceof l.default){var Q=new o.default,R=new o.default;M.forEach(function(O){(g(O)&S)==0?Q.pushBack(O):R.pushBack(O)}),Q.size()>u.untreeifyThreshold?L[D]=new l.default(Q):Q.size()&&(L[D]=Q),R.size()>u.untreeifyThreshold?L[D+S]=new l.default(R):R.size()&&(L[D+S]=R)}else{var T=new o.default,P=new o.default;M.forEach(function(O){(g(O)&S)==0?T.pushBack(O):P.pushBack(O)}),T.size()&&(L[D]=T),P.size()&&(L[D+S]=P)}w[D].clear()}}),w=L}}.call(this,m)},this.eraseElementByValue=function(_){var E=g(_)&m-1;if(w[E]){var x=w[E].size();w[E].eraseElementByValue(_),w[E]instanceof l.default&&w[E].size()<=u.untreeifyThreshold&&(w[E]=new o.default(w[E]));var C=w[E].size();y+=C-x}},this.find=function(_){var E=g(_)&m-1;return!!w[E]&&w[E].find(_)},this[Symbol.iterator]=function(){return function(){var _,E,x,C,S,L;return a(this,function(M){switch(M.label){case 0:_=0,M.label=1;case 1:if(!(_=m)return[3,10];M.label=2;case 2:M.trys.push([2,7,8,9]),S=void 0,E=r(w[_]),x=E.next(),M.label=3;case 3:return x.done?[3,6]:[4,x.value];case 4:M.sent(),M.label=5;case 5:return x=E.next(),[3,3];case 6:return[3,9];case 7:return C=M.sent(),S={error:C},[3,9];case 8:try{x&&!x.done&&(L=E.return)&&L.call(E)}finally{if(S)throw S.error}return[7];case 9:return++_,[3,1];case 10:return[2]}})}()},c.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),n.default=u},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(i,s,n){var a=this&&this.__generator||function(o,u){var c,f,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(m){return function(_){return function(E){if(c)throw new TypeError("Generator is already executing.");for(;y;)try{if(c=1,f&&(g=2&E[0]?f.return:E[0]?f.throw||((g=f.return)&&g.call(f),0):f.next)&&!(g=g.call(f,E[1])).done)return g;switch(f=0,g&&(E=[2&E[0],g.value]),E[0]){case 0:case 1:g=E;break;case 4:return y.label++,{value:E[1],done:!1};case 5:y.label++,f=E[1],E=[0];continue;case 7:E=y.ops.pop(),y.trys.pop();continue;default:if(!(g=(g=y.trys).length>0&&g[g.length-1])&&(E[0]===6||E[0]===2)){y=0;continue}if(E[0]===3&&(!g||E[1]>g[0]&&E[1]=c)throw new Error("pos must more then 0 and less then the list length");for(var y=f;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>=c)throw new Error("erase pos must more then 0 and less then the list length");if(v===0)this.popFront();else if(v===c-1)this.popBack();else{for(var y=f;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,m=y.next;m.pre=w,w.next=m,c>0&&--c}},this.eraseElementByValue=function(v){for(;f&&f.value===v;)this.popFront();for(;g&&g.value===v;)this.popBack();if(f)for(var y=f;y;){if(y.value===v){var w=y.pre,m=y.next;m&&(m.pre=w),w&&(w.next=m),c>0&&--c}y=y.next}},this.pushBack=function(v){if(v==null)throw new Error("you can't push null or undefined here");++c;var y=new r(v);g?(g.next=y,y.pre=g,g=y):f=g=y},this.popBack=function(){g&&(c>0&&--c,g&&(f===g?f=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>=c)throw new Error("pos must more then 0 and less then the list length");for(var w=f;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>c)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===c)for(;w--;)this.pushBack(y);else{for(var m=f,_=1;_0&&--c;v.next=y.next,v.next&&(v.next.pre=v),v=v.next}},this.sort=function(v){var y=[];this.forEach(function(m){y.push(m)}),y.sort(v);var w=f;y.forEach(function(m){w&&(w.value=m,w=w.next)})},this.pushFront=function(v){if(v==null)throw new Error("you can't push null or undefined here");++c;var y=new r(v);f?(y.next=f,f.pre=y,f=y):f=g=y},this.popFront=function(){f&&(c>0&&--c,f&&(f===g?f=g=void 0:(f=f.next)&&(f.pre=void 0)))},this.merge=function(v){var y=this,w=f;v.forEach(function(m){for(;w&&w.value!==void 0&&w.value<=m;)w=w.next;if(w===void 0)y.pushBack(m),w=g;else if(w===f)y.pushFront(m),w=f;else{++c;var _=w.pre;_&&(_.next=new r(m),_.next.pre=_,_.next.next=w,w&&(w.pre=_.next))}})},this[Symbol.iterator]=function(){return function(){var v;return a(this,function(y){switch(y.label){case 0:v=f,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]}})}()},o.forEach(function(v){return u.pushBack(v)}),Object.freeze(this)}Object.freeze(l),n.default=l},{}],30:[function(i,s,n){var a=this&&this.__generator||function(u,c){var f,g,v,y,w={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return y={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function m(_){return function(E){return function(x){if(f)throw new TypeError("Generator is already executing.");for(;w;)try{if(f=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]=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(c?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i("../Base/TreeNode");function o(u,c){var f=this;u===void 0&&(u=[]),c=c||function(R,T){return RT?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(R){if(!R||R.key===void 0)throw new Error("unknown error");return R.leftChild?y(R.leftChild):R},w=function(R){if(!R||R.key===void 0)throw new Error("unknown error");return R.rightChild?w(R.rightChild):R};this.front=function(){if(!this.empty()){var R=y(v);if(R.key===void 0||R.value===void 0)throw new Error("unknown error");return{key:R.key,value:R.value}}},this.back=function(){if(!this.empty()){var R=w(v);if(R.key===void 0||R.value===void 0)throw new Error("unknown error");return{key:R.key,value:R.value}}},this.forEach=function(R){var T,P,O=0;try{for(var Y=r(this),Z=Y.next();!Z.done;Z=Y.next())R(Z.value,O++)}catch(at){T={error:at}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(T)throw T.error}}},this.getElementByPos=function(R){var T,P;if(R<0||R>=this.size())throw new Error("pos must more than 0 and less than set's size");var O=0;try{for(var Y=r(this),Z=Y.next();!Z.done;Z=Y.next()){var at=Z.value;if(O===R)return at;++O}}catch(V){T={error:V}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(T)throw T.error}}throw new Error("unknown Error")};var m=function(R,T){if(R&&R.key!==void 0&&R.value!==void 0){var P=c(R.key,T);return P===0?{key:R.key,value:R.value}:P<0?m(R.rightChild,T):m(R.leftChild,T)||{key:R.key,value:R.value}}};this.lowerBound=function(R){return m(v,R)};var _=function(R,T){if(R&&R.key!==void 0&&R.value!==void 0)return c(R.key,T)<=0?_(R.rightChild,T):_(R.leftChild,T)||{key:R.key,value:R.value}};this.upperBound=function(R){return _(v,R)};var E=function(R,T){if(R&&R.key!==void 0&&R.value!==void 0){var P=c(R.key,T);return P===0?{key:R.key,value:R.value}:P>0?E(R.leftChild,T):E(R.rightChild,T)||{key:R.key,value:R.value}}};this.reverseLowerBound=function(R){return E(v,R)};var x=function(R,T){if(R&&R.key!==void 0&&R.value!==void 0)return c(R.key,T)>=0?x(R.leftChild,T):x(R.rightChild,T)||{key:R.key,value:R.value}};this.reverseUpperBound=function(R){return x(v,R)};var C=function(R){var T=R.parent;if(!T){if(R===v)return;throw new Error("unknown error")}if(R.color!==l.default.TreeNodeColorType.red){var P=R.brother;if(!P)throw new Error("unknown error");if(R===T.leftChild)if(P.color===l.default.TreeNodeColorType.red){P.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red;var O=T.rotateLeft();v===T&&(v=O),C(R)}else P.color===l.default.TreeNodeColorType.black&&(P.rightChild&&P.rightChild.color===l.default.TreeNodeColorType.red?(P.color=T.color,T.color=l.default.TreeNodeColorType.black,P.rightChild&&(P.rightChild.color=l.default.TreeNodeColorType.black),O=T.rotateLeft(),v===T&&(v=O),R.color=l.default.TreeNodeColorType.black):P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||!P.leftChild||P.leftChild.color!==l.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||(P.color=l.default.TreeNodeColorType.red,C(T)):(P.color=l.default.TreeNodeColorType.red,P.leftChild&&(P.leftChild.color=l.default.TreeNodeColorType.black),O=P.rotateRight(),v===P&&(v=O),C(R)));else R===T.rightChild&&(P.color===l.default.TreeNodeColorType.red?(P.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red,O=T.rotateRight(),v===T&&(v=O),C(R)):P.color===l.default.TreeNodeColorType.black&&(P.leftChild&&P.leftChild.color===l.default.TreeNodeColorType.red?(P.color=T.color,T.color=l.default.TreeNodeColorType.black,P.leftChild&&(P.leftChild.color=l.default.TreeNodeColorType.black),O=T.rotateRight(),v===T&&(v=O),R.color=l.default.TreeNodeColorType.black):P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||!P.rightChild||P.rightChild.color!==l.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||(P.color=l.default.TreeNodeColorType.red,C(T)):(P.color=l.default.TreeNodeColorType.red,P.rightChild&&(P.rightChild.color=l.default.TreeNodeColorType.black),O=P.rotateLeft(),v===P&&(v=O),C(R))))}else R.color=l.default.TreeNodeColorType.black},S=function(R){for(var T=R;T.leftChild||T.rightChild;){if(T.rightChild){T=y(T.rightChild);var P=R.key;R.key=T.key,T.key=P;var O=R.value;R.value=T.value,T.value=O,R=T}T.leftChild&&(T=w(T.leftChild),P=R.key,R.key=T.key,T.key=P,O=R.value,R.value=T.value,T.value=O,R=T)}C(T),T&&T.remove(),--g,v.color=l.default.TreeNodeColorType.black},L=function(R,T){return!(!R||R.key===void 0)&&(!!L(R.leftChild,T)||!!T(R)||L(R.rightChild,T))};this.eraseElementByPos=function(R){if(R<0||R>=g)throw new Error("pos must more than 0 and less than set's size");var T=0;L(v,function(P){return R===T?(S(P),!0):(++T,!1)})},this.eraseElementByKey=function(R){if(!this.empty()){var T=$(v,R);T!==void 0&&T.key!==void 0&&c(T.key,R)===0&&S(T)}};var M=function(R,T){if(!R||R.key===void 0)throw new Error("unknown error");var P=c(T,R.key);return P<0?R.leftChild?M(R.leftChild,T):(R.leftChild=new l.default,R.leftChild.parent=R,R.leftChild.brother=R.rightChild,R.rightChild&&(R.rightChild.brother=R.leftChild),R.leftChild):P>0?R.rightChild?M(R.rightChild,T):(R.rightChild=new l.default,R.rightChild.parent=R,R.rightChild.brother=R.leftChild,R.leftChild&&(R.leftChild.brother=R.rightChild),R.rightChild):R},D=function(R){var T=R.parent;if(!T){if(R===v)return;throw new Error("unknown error")}if(T.color!==l.default.TreeNodeColorType.black&&T.color===l.default.TreeNodeColorType.red){var P=T.brother,O=T.parent;if(!O)throw new Error("unknown error");if(P&&P.color===l.default.TreeNodeColorType.red)P.color=T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,D(O);else if(!P||P.color===l.default.TreeNodeColorType.black)if(T===O.leftChild)if(R===T.leftChild){T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red;var Y=O.rotateRight();O===v&&(v=Y)}else R===T.rightChild&&(Y=T.rotateLeft(),O===v&&(v=Y),D(T));else T===O.rightChild&&(R===T.leftChild?(Y=T.rotateRight(),O===v&&(v=Y),D(T)):R===T.rightChild&&(T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,Y=O.rotateLeft(),O===v&&(v=Y)))}};this.setElement=function(R,T){if(R==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=R,v.value=T,void(v.color=l.default.TreeNodeColorType.black);var P=M(v,R);P.key===void 0||c(P.key,R)!==0?(++g,P.key=R,P.value=T,D(P),v.color=l.default.TreeNodeColorType.black):P.value=T}else this.eraseElementByKey(R)};var $=function(R,T){if(R&&R.key!==void 0){var P=c(T,R.key);return P<0?$(R.leftChild,T):P>0?$(R.rightChild,T):R}};this.find=function(R){return!!$(v,R)},this.getElementByKey=function(R){var T=$(v,R);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(R){var T=this;R.forEach(function(P){var O=P.key,Y=P.value;return T.setElement(O,Y)})},this.getHeight=function(){if(this.empty())return 0;var R=function(T){return T?Math.max(R(T.leftChild),R(T.rightChild))+1:1};return R(v)};var Q=function(R){return a(this,function(T){switch(T.label){case 0:return R&&R.key!==void 0&&R.value!==void 0?[5,r(Q(R.leftChild))]:[2];case 1:return T.sent(),[4,{key:R.key,value:R.value}];case 2:return T.sent(),[5,r(Q(R.rightChild))];case 3:return T.sent(),[2]}})};this[Symbol.iterator]=function(){return Q(v)},u.forEach(function(R){var T=R.key,P=R.value;return f.setElement(T,P)}),Object.freeze(this)}Object.freeze(o),n.default=o},{"../Base/TreeNode":25}],31:[function(i,s,n){function a(r,l){r===void 0&&(r=[]),l=l||function(g,v){return g>v?-1:g=u)throw new Error("unknown error");if(v<0||v>=u)throw new Error("unknown error");var y=o[g];o[g]=o[v],o[v]=y},f=function(g){if(g<0||g>=u)throw new Error("unknown error");var v=2*g+1,y=2*g+2;v0&&c(g,v),y0&&c(g,y)};(function(){for(var g=Math.floor((u-1)/2);g>=0;--g)for(var v=g,y=2*v+1;y0&&(m=w),l(o[v],o[m])<=0)break;c(v,m),y=2*(v=m)+1}})(),this.size=function(){return u},this.empty=function(){return u===0},this.clear=function(){u=0,o.length=0},this.push=function(g){if(o.push(g),++u!==1)for(var v=u-1;v>0;){var y=Math.floor((v-1)/2);if(l(o[y],g)<=0)break;f(y),v=y}},this.pop=function(){if(!this.empty())if(this.size()!==1){var g=o[u-1];--u;for(var v=0;v=this.size())break;var m=y;if(w0&&(m=w),l(o[m],g)>=0)break;o[v]=o[m],v=m}o[v]=g}else--u},this.top=function(){return o[0]},Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(a),n.default=a},{}],32:[function(i,s,n){Object.defineProperty(n,"__esModule",{value:!0});var a=i("../LinkList/LinkList");function r(l){l===void 0&&(l=[]);var o=new a.default(l);this.size=function(){return o.size()},this.empty=function(){return o.empty()},this.clear=function(){o.clear()},this.push=function(u){o.pushBack(u)},this.pop=function(){o.popFront()},this.front=function(){return o.front()},Object.freeze(this)}Object.freeze(r),n.default=r},{"../LinkList/LinkList":29}],33:[function(i,s,n){var a=this&&this.__generator||function(u,c){var f,g,v,y,w={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return y={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function m(_){return function(E){return function(x){if(f)throw new TypeError("Generator is already executing.");for(;w;)try{if(f=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]=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(c?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i("../Base/TreeNode");function o(u,c){var f=this;u===void 0&&(u=[]),c=c||function(R,T){return RT?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(R){if(!R||R.key===void 0)throw new Error("unknown error");return R.leftChild?y(R.leftChild):R},w=function(R){if(!R||R.key===void 0)throw new Error("unknown error");return R.rightChild?w(R.rightChild):R};this.front=function(){if(!this.empty())return y(v).key},this.back=function(){if(!this.empty())return w(v).key},this.forEach=function(R){var T,P,O=0;try{for(var Y=r(this),Z=Y.next();!Z.done;Z=Y.next())R(Z.value,O++)}catch(at){T={error:at}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(T)throw T.error}}},this.getElementByPos=function(R){var T,P;if(R<0||R>=this.size())throw new Error("pos must more than 0 and less than set's size");var O=0;try{for(var Y=r(this),Z=Y.next();!Z.done;Z=Y.next()){var at=Z.value;if(O===R)return at;++O}}catch(V){T={error:V}}finally{try{Z&&!Z.done&&(P=Y.return)&&P.call(Y)}finally{if(T)throw T.error}}throw new Error("unknown error")};var m=function(R){var T=R.parent;if(!T){if(R===v)return;throw new Error("unknown error")}if(R.color!==l.default.TreeNodeColorType.red){var P=R.brother;if(!P)throw new Error("unknown error");if(R===T.leftChild)if(P.color===l.default.TreeNodeColorType.red){P.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red;var O=T.rotateLeft();v===T&&(v=O),m(R)}else P.color===l.default.TreeNodeColorType.black&&(P.rightChild&&P.rightChild.color===l.default.TreeNodeColorType.red?(P.color=T.color,T.color=l.default.TreeNodeColorType.black,P.rightChild&&(P.rightChild.color=l.default.TreeNodeColorType.black),O=T.rotateLeft(),v===T&&(v=O),R.color=l.default.TreeNodeColorType.black):P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||!P.leftChild||P.leftChild.color!==l.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||(P.color=l.default.TreeNodeColorType.red,m(T)):(P.color=l.default.TreeNodeColorType.red,P.leftChild&&(P.leftChild.color=l.default.TreeNodeColorType.black),O=P.rotateRight(),v===P&&(v=O),m(R)));else R===T.rightChild&&(P.color===l.default.TreeNodeColorType.red?(P.color=l.default.TreeNodeColorType.black,T.color=l.default.TreeNodeColorType.red,O=T.rotateRight(),v===T&&(v=O),m(R)):P.color===l.default.TreeNodeColorType.black&&(P.leftChild&&P.leftChild.color===l.default.TreeNodeColorType.red?(P.color=T.color,T.color=l.default.TreeNodeColorType.black,P.leftChild&&(P.leftChild.color=l.default.TreeNodeColorType.black),O=T.rotateRight(),v===T&&(v=O),R.color=l.default.TreeNodeColorType.black):P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||!P.rightChild||P.rightChild.color!==l.default.TreeNodeColorType.red?P.leftChild&&P.leftChild.color!==l.default.TreeNodeColorType.black||P.rightChild&&P.rightChild.color!==l.default.TreeNodeColorType.black||(P.color=l.default.TreeNodeColorType.red,m(T)):(P.color=l.default.TreeNodeColorType.red,P.rightChild&&(P.rightChild.color=l.default.TreeNodeColorType.black),O=P.rotateLeft(),v===P&&(v=O),m(R))))}else R.color=l.default.TreeNodeColorType.black},_=function(R){for(var T=R;T.leftChild||T.rightChild;){if(T.rightChild){T=y(T.rightChild);var P=R.key;R.key=T.key,T.key=P,R=T}T.leftChild&&(T=w(T.leftChild),P=R.key,R.key=T.key,T.key=P,R=T)}m(T),T&&T.remove(),--g,v.color=l.default.TreeNodeColorType.black},E=function(R,T){return!(!R||R.key===void 0)&&(!!E(R.leftChild,T)||!!T(R)||E(R.rightChild,T))};this.eraseElementByPos=function(R){if(R<0||R>=g)throw new Error("pos must more than 0 and less than set's size");var T=0;E(v,function(P){return R===T?(_(P),!0):(++T,!1)})},this.eraseElementByValue=function(R){if(!this.empty()){var T=S(v,R);T!==void 0&&T.key!==void 0&&c(T.key,R)===0&&_(T)}};var x=function(R,T){if(!R||R.key===void 0)throw new Error("unknown error");var P=c(T,R.key);return P<0?R.leftChild?x(R.leftChild,T):(R.leftChild=new l.default,R.leftChild.parent=R,R.leftChild.brother=R.rightChild,R.rightChild&&(R.rightChild.brother=R.leftChild),R.leftChild):P>0?R.rightChild?x(R.rightChild,T):(R.rightChild=new l.default,R.rightChild.parent=R,R.rightChild.brother=R.leftChild,R.leftChild&&(R.leftChild.brother=R.rightChild),R.rightChild):R},C=function(R){var T=R.parent;if(!T){if(R===v)return;throw new Error("unknown error")}if(T.color!==l.default.TreeNodeColorType.black&&T.color===l.default.TreeNodeColorType.red){var P=T.brother,O=T.parent;if(!O)throw new Error("unknown error");if(P&&P.color===l.default.TreeNodeColorType.red)P.color=T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,C(O);else if(!P||P.color===l.default.TreeNodeColorType.black)if(T===O.leftChild)if(R===T.leftChild){T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red;var Y=O.rotateRight();O===v&&(v=Y)}else R===T.rightChild&&(Y=T.rotateLeft(),O===v&&(v=Y),C(T));else T===O.rightChild&&(R===T.leftChild?(Y=T.rotateRight(),O===v&&(v=Y),C(T)):R===T.rightChild&&(T.color=l.default.TreeNodeColorType.black,O.color=l.default.TreeNodeColorType.red,Y=O.rotateLeft(),O===v&&(v=Y)))}};this.insert=function(R){if(R==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=R,void(v.color=l.default.TreeNodeColorType.black);var T=x(v,R);T.key!==void 0&&c(T.key,R)===0||(++g,T.key=R,C(T),v.color=l.default.TreeNodeColorType.black)};var S=function(R,T){if(R&&R.key!==void 0){var P=c(T,R.key);return P<0?S(R.leftChild,T):P>0?S(R.rightChild,T):R}};this.find=function(R){var T=S(v,R);return T!==void 0&&T.key!==void 0&&c(T.key,R)===0};var L=function(R,T){if(R&&R.key!==void 0){var P=c(R.key,T);if(P===0)return R.key;if(P<0)return L(R.rightChild,T);var O=L(R.leftChild,T);return O!==void 0?O:R.key}};this.lowerBound=function(R){return L(v,R)};var M=function(R,T){if(R&&R.key!==void 0){if(c(R.key,T)<=0)return M(R.rightChild,T);var P=M(R.leftChild,T);return P!==void 0?P:R.key}};this.upperBound=function(R){return M(v,R)};var D=function(R,T){if(R&&R.key!==void 0){var P=c(R.key,T);if(P===0)return R.key;if(P>0)return D(R.leftChild,T);var O=D(R.rightChild,T);return O!==void 0?O:R.key}};this.reverseLowerBound=function(R){return D(v,R)};var $=function(R,T){if(R&&R.key!==void 0){if(c(R.key,T)>=0)return $(R.leftChild,T);var P=$(R.rightChild,T);return P!==void 0?P:R.key}};this.reverseUpperBound=function(R){return $(v,R)},this.union=function(R){var T=this;R.forEach(function(P){return T.insert(P)})},this.getHeight=function(){if(this.empty())return 0;var R=function(T){return T?Math.max(R(T.leftChild),R(T.rightChild))+1:1};return R(v)};var Q=function(R){return a(this,function(T){switch(T.label){case 0:return R&&R.key!==void 0?[5,r(Q(R.leftChild))]:[2];case 1:return T.sent(),[4,R.key];case 2:return T.sent(),[5,r(Q(R.rightChild))];case 3:return T.sent(),[2]}})};this[Symbol.iterator]=function(){return Q(v)},u.forEach(function(R){return f.insert(R)}),Object.freeze(this)}Object.freeze(o),n.default=o},{"../Base/TreeNode":25}],34:[function(i,s,n){function a(r){var l=this;r===void 0&&(r=[]);var o=0,u=[];this.size=function(){return o},this.empty=function(){return o===0},this.clear=function(){o=0,u.length=0},this.push=function(c){u.push(c),++o},this.pop=function(){u.pop(),o>0&&--o},this.top=function(){return u[o-1]},r.forEach(function(c){return l.push(c)}),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(a),n.default=a},{}],35:[function(i,s,n){var a=this&&this.__generator||function(c,f){var g,v,y,w,m={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 _(E){return function(x){return function(C){if(g)throw new TypeError("Generator is already executing.");for(;m;)try{if(g=1,v&&(y=2&C[0]?v.return:C[0]?v.throw||((y=v.return)&&y.call(v),0):v.next)&&!(y=y.call(v,C[1])).done)return y;switch(v=0,y&&(C=[2&C[0],y.value]),C[0]){case 0:case 1:y=C;break;case 4:return m.label++,{value:C[1],done:!1};case 5:m.label++,v=C[1],C=[0];continue;case 7:C=m.ops.pop(),m.trys.pop();continue;default:if(!(y=(y=m.trys).length>0&&y[y.length-1])&&(C[0]===6||C[0]===2)){m=0;continue}if(C[0]===3&&(!y||C[1]>y[0]&&C[1]0)&&!(v=w.next()).done;)m.push(v.value)}catch(_){y={error:_}}finally{try{v&&!v.done&&(g=w.return)&&g.call(w)}finally{if(y)throw y.error}}return m},l=this&&this.__spreadArray||function(c,f,g){if(g||arguments.length===2)for(var v,y=0,w=f.length;y=c.length&&(c=void 0),{value:c&&c[v++],done:!c}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};function u(c){var f=this;c===void 0&&(c=[]);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;wm;)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,m){if(m===void 0&&(m=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],r(new Array(m).fill(w)),!1)),g+=m},this.find=function(y){return v.includes(y)},this.reverse=function(){v.reverse()},this.unique=function(){var y,w=[];this.forEach(function(_,E){E!==0&&_===y||(w.push(_),y=_)}),w.forEach(function(_,E){v[E]=_});for(var m=w.length;g>m;)this.popBack()},this.sort=function(y){v.sort(y)},this[Symbol.iterator]=function(){return function(){return a(this,function(y){switch(y.label){case 0:return[5,o(v)];case 1:return[2,y.sent()]}})}()},c.forEach(function(y){return f.pushBack(y)}),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(u),n.default=u},{}],36:[function(i,s,n){Object.defineProperty(n,"__esModule",{value:!0}),n.HashMap=n.HashSet=n.Map=n.Set=n.PriorityQueue=n.Deque=n.LinkList=n.Queue=n.Stack=n.Vector=void 0;var a=i("./Vector/Vector");n.Vector=a.default;var r=i("./Stack/Stack");n.Stack=r.default;var l=i("./Queue/Queue");n.Queue=l.default;var o=i("./LinkList/LinkList");n.LinkList=o.default;var u=i("./Deque/Deque");n.Deque=u.default;var c=i("./PriorityQueue/PriorityQueue");n.PriorityQueue=c.default;var f=i("./Set/Set");n.Set=f.default;var g=i("./Map/Map");n.Map=g.default;var v=i("./HashSet/HashSet");n.HashSet=v.default;var y=i("./HashMap/HashMap");n.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,s,n){const a=i("yallist"),r=Symbol("max"),l=Symbol("length"),o=Symbol("lengthCalculator"),u=Symbol("allowStale"),c=Symbol("maxAge"),f=Symbol("dispose"),g=Symbol("noDisposeOnSet"),v=Symbol("lruList"),y=Symbol("cache"),w=Symbol("updateAgeOnGet"),m=()=>1,_=(M,D,$)=>{const Q=M[y].get(D);if(Q){const R=Q.value;if(E(M,R)){if(C(M,Q),!M[u])return}else $&&(M[w]&&(Q.value.now=Date.now()),M[v].unshiftNode(Q));return R.value}},E=(M,D)=>{if(!D||!D.maxAge&&!M[c])return!1;const $=Date.now()-D.now;return D.maxAge?$>D.maxAge:M[c]&&$>M[c]},x=M=>{if(M[l]>M[r])for(let D=M[v].tail;M[l]>M[r]&&D!==null;){const $=D.prev;C(M,D),D=$}},C=(M,D)=>{if(D){const $=D.value;M[f]&&M[f]($.key,$.value),M[l]-=$.length,M[y].delete($.key),M[v].removeNode(D)}};class S{constructor(D,$,Q,R,T){this.key=D,this.value=$,this.length=Q,this.now=R,this.maxAge=T||0}}const L=(M,D,$,Q)=>{let R=$.value;E(M,R)&&(C(M,$),M[u]||(R=void 0)),R&&D.call(Q,R.value,R.key,M)};s.exports=class{constructor(M){if(typeof M=="number"&&(M={max:M}),M||(M={}),M.max&&(typeof M.max!="number"||M.max<0))throw new TypeError("max must be a non-negative number");this[r]=M.max||1/0;const D=M.length||m;if(this[o]=typeof D!="function"?m:D,this[u]=M.stale||!1,M.maxAge&&typeof M.maxAge!="number")throw new TypeError("maxAge must be a number");this[c]=M.maxAge||0,this[f]=M.dispose,this[g]=M.noDisposeOnSet||!1,this[w]=M.updateAgeOnGet||!1,this.reset()}set max(M){if(typeof M!="number"||M<0)throw new TypeError("max must be a non-negative number");this[r]=M||1/0,x(this)}get max(){return this[r]}set allowStale(M){this[u]=!!M}get allowStale(){return this[u]}set maxAge(M){if(typeof M!="number")throw new TypeError("maxAge must be a non-negative number");this[c]=M,x(this)}get maxAge(){return this[c]}set lengthCalculator(M){typeof M!="function"&&(M=m),M!==this[o]&&(this[o]=M,this[l]=0,this[v].forEach(D=>{D.length=this[o](D.value,D.key),this[l]+=D.length})),x(this)}get lengthCalculator(){return this[o]}get length(){return this[l]}get itemCount(){return this[v].length}rforEach(M,D){D=D||this;for(let $=this[v].tail;$!==null;){const Q=$.prev;L(this,M,$,D),$=Q}}forEach(M,D){D=D||this;for(let $=this[v].head;$!==null;){const Q=$.next;L(this,M,$,D),$=Q}}keys(){return this[v].toArray().map(M=>M.key)}values(){return this[v].toArray().map(M=>M.value)}reset(){this[f]&&this[v]&&this[v].length&&this[v].forEach(M=>this[f](M.key,M.value)),this[y]=new Map,this[v]=new a,this[l]=0}dump(){return this[v].map(M=>!E(this,M)&&{k:M.key,v:M.value,e:M.now+(M.maxAge||0)}).toArray().filter(M=>M)}dumpLru(){return this[v]}set(M,D,$){if(($=$||this[c])&&typeof $!="number")throw new TypeError("maxAge must be a number");const Q=$?Date.now():0,R=this[o](D,M);if(this[y].has(M)){if(R>this[r])return C(this,this[y].get(M)),!1;const P=this[y].get(M).value;return this[f]&&(this[g]||this[f](M,P.value)),P.now=Q,P.maxAge=$,P.value=D,this[l]+=R-P.length,P.length=R,this.get(M),x(this),!0}const T=new S(M,D,R,Q,$);return T.length>this[r]?(this[f]&&this[f](M,D),!1):(this[l]+=T.length,this[v].unshift(T),this[y].set(M,this[v].head),x(this),!0)}has(M){if(!this[y].has(M))return!1;const D=this[y].get(M).value;return!E(this,D)}get(M){return _(this,M,!0)}peek(M){return _(this,M,!1)}pop(){const M=this[v].tail;return M?(C(this,M),M.value):null}del(M){C(this,this[y].get(M))}load(M){this.reset();const D=Date.now();for(let $=M.length-1;$>=0;$--){const Q=M[$],R=Q.e||0;if(R===0)this.set(Q.k,Q.v);else{const T=R-D;T>0&&this.set(Q.k,Q.v,T)}}}prune(){this[y].forEach((M,D)=>_(this,D,!1))}}},{yallist:83}],38:[function(i,s,n){(function(a){(function(){const r=s.exports;r.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"},r.codes={};for(const o in r.types){const u=r.types[o];r.codes[u]=o}r.CMD_SHIFT=4,r.CMD_MASK=240,r.DUP_MASK=8,r.QOS_MASK=3,r.QOS_SHIFT=1,r.RETAIN_MASK=1,r.VARBYTEINT_MASK=127,r.VARBYTEINT_FIN_MASK=128,r.VARBYTEINT_MAX=268435455,r.SESSIONPRESENT_MASK=1,r.SESSIONPRESENT_HEADER=a.from([r.SESSIONPRESENT_MASK]),r.CONNACK_HEADER=a.from([r.codes.connack<[0,1].map(c=>[0,1].map(f=>{const g=a.alloc(1);return g.writeUInt8(r.codes[o]<a.from([o])),r.EMPTY={pingreq:a.from([r.codes.pingreq<<4,0]),pingresp:a.from([r.codes.pingresp<<4,0]),disconnect:a.from([r.codes.disconnect<<4,0])}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],39:[function(i,s,n){(function(a){(function(){const r=i("./writeToStream"),l=i("events");class o extends l{constructor(){super(),this._array=new Array(20),this._i=0}write(c){return this._array[this._i++]=c,!0}concat(){let c=0;const f=new Array(this._array.length),g=this._array;let v,y=0;for(v=0;v>8,0),f.writeUInt8(255&c,1),f}s.exports={cache:l,generateCache:function(){for(let c=0;c<65536;c++)l[c]=u(c)},generateNumber:u,genBufVariableByteInt:function(c){let f=0,g=0;const v=a.allocUnsafe(4);do f=c%128|0,(c=c/128|0)>0&&(f|=128),v.writeUInt8(f,g++);while(c>0&&g<4);return c>0&&(g=0),o?v.subarray(0,g):v.slice(0,g)},generate4ByteBuffer:function(c){const f=a.allocUnsafe(4);return f.writeUInt32BE(c,0),f}}}).call(this)}).call(this,i("buffer").Buffer)},{buffer:17}],42:[function(i,s,n){s.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,s,n){const a=i("bl"),r=i("events"),l=i("./packet"),o=i("./constants"),u=i("debug")("mqtt-packet:parser");class c extends r{constructor(){super(),this.parser=this.constructor.parser}static parser(g){return this instanceof c?(this.settings=g||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new c().parser(g)}_resetState(){u("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new l,this.error=null,this._list=a(),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=o.types[g>>o.CMD_SHIFT],this.packet.retain=(g&o.RETAIN_MASK)!=0,this.packet.qos=g>>o.QOS_SHIFT&o.QOS_MASK,this.packet.dup=(g&o.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 m={},_=this.packet,E=this._parseString();if(E===null)return this._emitError(new Error("Cannot parse protocolId"));if(E!=="MQTT"&&E!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(_.protocolId=E,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(m.username=this._list.readUInt8(this._pos)&o.USERNAME_MASK,m.password=this._list.readUInt8(this._pos)&o.PASSWORD_MASK,m.will=this._list.readUInt8(this._pos)&o.WILL_FLAG_MASK,m.will&&(_.will={},_.will.retain=(this._list.readUInt8(this._pos)&o.WILL_RETAIN_MASK)!=0,_.will.qos=(this._list.readUInt8(this._pos)&o.WILL_QOS_MASK)>>o.WILL_QOS_SHIFT),_.clean=(this._list.readUInt8(this._pos)&o.CLEAN_SESSION_MASK)!=0,this._pos++,_.keepalive=this._parseNum(),_.keepalive===-1)return this._emitError(new Error("Packet too short"));if(_.protocolVersion===5){const C=this._parseProperties();Object.getOwnPropertyNames(C).length&&(_.properties=C)}const x=this._parseString();if(x===null)return this._emitError(new Error("Packet too short"));if(_.clientId=x,u("_parseConnect: packet.clientId: %s",_.clientId),m.will){if(_.protocolVersion===5){const C=this._parseProperties();Object.getOwnPropertyNames(C).length&&(_.will.properties=C)}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(m.username){if((w=this._parseString())===null)return this._emitError(new Error("Cannot parse username"));_.username=w,u("_parseConnect: packet.username: %s",_.username)}if(m.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++)&o.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,m,_,E,x;if(g.qos!==1)return this._emitError(new Error("Wrong subscribe header"));if(g.subscriptions=[],this._parseMessageId()){if(this.settings.protocolVersion===5){const C=this._parseProperties();Object.getOwnPropertyNames(C).length&&(g.properties=C)}for(;this._pos=g.length)return this._emitError(new Error("Malformed Subscribe Payload"));w=(y=this._parseByte())&o.SUBSCRIBE_OPTIONS_QOS_MASK,E=(y>>o.SUBSCRIBE_OPTIONS_NL_SHIFT&o.SUBSCRIBE_OPTIONS_NL_MASK)!=0,_=(y>>o.SUBSCRIBE_OPTIONS_RAP_SHIFT&o.SUBSCRIBE_OPTIONS_RAP_MASK)!=0,m=y>>o.SUBSCRIBE_OPTIONS_RH_SHIFT&o.SUBSCRIBE_OPTIONS_RH_MASK,x={topic:v,qos:w},this.settings.protocolVersion===5?(x.nl=E,x.rap=_,x.rh=m):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._pos2?(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,m=0,_=!1;const E=this._pos?this._pos:0;for(;y<4&&E+y=y&&this._emitError(new Error("Invalid variable byte integer")),E&&(this._pos+=y),u("_parseVarByteNum: result: %o",_=!!_&&(g?{bytes:y,value:m}:m)),_}_parseByte(){let g;return this._pos=4)&&(k||ot))G+=a.byteLength(k)+2;else{if(ut<4)return U.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*ot==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(G+=2,G+=1,ut===5){var rt=T(U,X);if(!rt)return!1;G+=rt.length}if(ct){if(typeof ct!="object")return U.emit("error",new Error("Invalid will")),!1;if(!ct.topic||typeof ct.topic!="string")return U.emit("error",new Error("Invalid will topic")),!1;if(G+=a.byteLength(ct.topic)+2,G+=2,ct.payload){if(!(ct.payload.length>=0))return U.emit("error",new Error("Invalid will payload")),!1;typeof ct.payload=="string"?G+=a.byteLength(ct.payload):G+=ct.payload.length}var mt={};if(ut===5){if(!(mt=T(U,ct.properties)))return!1;G+=mt.length}}let yt=!1;if(I!=null){if(!at(I))return U.emit("error",new Error("Invalid username")),!1;yt=!0,G+=a.byteLength(I)+2}if(N!=null){if(!yt)return U.emit("error",new Error("Username is required to use password")),!1;if(!at(N))return U.emit("error",new Error("Invalid password")),!1;G+=Z(N)+2}U.write(r.CONNECT_HEADER),L(U,G),R(U,et),st.bridgeMode&&(ut+=128),U.write(ut===131?r.VERSION131:ut===132?r.VERSION132:ut===4?r.VERSION4:ut===5?r.VERSION5:r.VERSION3);let Et=0;return Et|=I!=null?r.USERNAME_MASK:0,Et|=N!=null?r.PASSWORD_MASK:0,Et|=ct&&ct.retain?r.WILL_RETAIN_MASK:0,Et|=ct&&ct.qos?ct.qos<0&&_(U,k),X!=null&&X.write(),f("publish: payload: %o",b),U.write(b)}(V,H,j);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=et.cmd||"puback",ct=et.messageId,ot=et.dup&&ut==="pubrel"?r.DUP_MASK:0;let b=0;const k=et.reasonCode,I=et.properties;let N=st===5?3:2;if(ut==="pubrel"&&(b=1),typeof ct!="number")return U.emit("error",new Error("Invalid messageId")),!1;let X=null;if(st===5&&typeof I=="object"){if(!(X=P(U,I,tt,N)))return!1;N+=X.length}return U.write(r.ACKS[ut][b][ot][0]),L(U,N),_(U,ct),st===5&&U.write(a.from([k])),X!==null&&X.write(),!0}(V,H,j);case"subscribe":return function(K,U,tt){f("subscribe: packet: ");const st=tt?tt.protocolVersion:4,et=K||{},ut=et.dup?r.DUP_MASK:0,ct=et.messageId,ot=et.subscriptions,b=et.properties;let k=0;if(typeof ct!="number")return U.emit("error",new Error("Invalid messageId")),!1;k+=2;let I=null;if(st===5){if(!(I=T(U,b)))return!1;k+=I.length}if(typeof ot!="object"||!ot.length)return U.emit("error",new Error("Invalid subscriptions")),!1;for(let X=0;X2)return U.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}k+=a.byteLength(G)+2+1}f("subscribe: writing to stream: %o",r.SUBSCRIBE_HEADER),U.write(r.SUBSCRIBE_HEADER[1][ut?1:0][0]),L(U,k),_(U,ct),I!==null&&I.write();let N=!0;for(const X of ot){const G=X.topic,rt=X.qos,mt=+X.nl,yt=+X.rap,Et=X.rh;let Tt;M(U,G),Tt=r.SUBSCRIBE_OPTIONS_QOS[rt],st===5&&(Tt|=mt?r.SUBSCRIBE_OPTIONS_NL:0,Tt|=yt?r.SUBSCRIBE_OPTIONS_RAP:0,Tt|=Et?r.SUBSCRIBE_OPTIONS_RH[Et]:0),N=U.write(a.from([Tt]))}return N}(V,H,j);case"suback":return function(K,U,tt){const st=tt?tt.protocolVersion:4,et=K||{},ut=et.messageId,ct=et.granted,ot=et.properties;let b=0;if(typeof ut!="number")return U.emit("error",new Error("Invalid messageId")),!1;if(b+=2,typeof ct!="object"||!ct.length)return U.emit("error",new Error("Invalid qos vector")),!1;for(let I=0;I_===$,set(V){V?(g&&Object.keys(g).length!==0||(E=!0),_=$):(E=!1,_=Q)}});const S={};function L(V,H){if(H>r.VARBYTEINT_MAX)return V.emit("error",new Error(`Invalid variable byte integer: ${H}`)),!1;let j=S[H];return j||(j=w(H),H<16384&&(S[H]=j)),f("writeVarByteInt: writing to stream: %o",j),V.write(j)}function M(V,H){const j=a.byteLength(H);return _(V,j),f("writeString: %s",H),V.write(H,"utf8")}function D(V,H,j){M(V,H),M(V,j)}function $(V,H){return f("writeNumberCached: number: %d",H),f("writeNumberCached: %o",g[H]),V.write(g[H])}function Q(V,H){const j=v(H);return f("writeNumberGenerated: %o",j),V.write(j)}function R(V,H){typeof H=="string"?M(V,H):H?(_(V,H.length),V.write(H)):_(V,0)}function T(V,H){if(typeof H!="object"||H.length!=null)return{length:1,write(){Y(V,{},0)}};let j=0;function K(U,tt){let st=0;switch(r.propertiesTypes[U]){case"byte":if(typeof tt!="boolean")return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=2;break;case"int8":if(typeof tt!="number"||tt<0||tt>255)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=2;break;case"binary":if(tt&&tt===null)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=1+a.byteLength(tt)+2;break;case"int16":if(typeof tt!="number"||tt<0||tt>65535)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=3;break;case"int32":if(typeof tt!="number"||tt<0||tt>4294967295)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=5;break;case"var":if(typeof tt!="number"||tt<0||tt>268435455)return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=1+a.byteLength(w(tt));break;case"string":if(typeof tt!="string")return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=3+a.byteLength(tt.toString());break;case"pair":if(typeof tt!="object")return V.emit("error",new Error(`Invalid ${U}: ${tt}`)),!1;st+=Object.getOwnPropertyNames(tt).reduce((et,ut)=>{const ct=tt[ut];return Array.isArray(ct)?et+=ct.reduce((ot,b)=>ot+=3+a.byteLength(ut.toString())+2+a.byteLength(b.toString()),0):et+=3+a.byteLength(ut.toString())+2+a.byteLength(tt[ut].toString()),et},0);break;default:return V.emit("error",new Error(`Invalid property ${U}: ${tt}`)),!1}return st}if(H)for(const U in H){let tt=0,st=0;const et=H[U];if(Array.isArray(et))for(let ut=0;uttt;){const et=U.shift();if(!et||!H[et])return!1;delete H[et],st=T(V,H)}return st}function O(V,H,j){switch(r.propertiesTypes[H]){case"byte":V.write(a.from([r.properties[H]])),V.write(a.from([+j]));break;case"int8":V.write(a.from([r.properties[H]])),V.write(a.from([j]));break;case"binary":V.write(a.from([r.properties[H]])),R(V,j);break;case"int16":V.write(a.from([r.properties[H]])),_(V,j);break;case"int32":V.write(a.from([r.properties[H]])),function(K,U){const tt=m(U);f("write4ByteNumber: %o",tt),K.write(tt)}(V,j);break;case"var":V.write(a.from([r.properties[H]])),L(V,j);break;case"string":V.write(a.from([r.properties[H]])),M(V,j);break;case"pair":Object.getOwnPropertyNames(j).forEach(K=>{const U=j[K];Array.isArray(U)?U.forEach(tt=>{V.write(a.from([r.properties[H]])),D(V,K.toString(),tt.toString())}):(V.write(a.from([r.properties[H]])),D(V,K.toString(),U.toString()))});break;default:return V.emit("error",new Error(`Invalid property ${H} value: ${j}`)),!1}}function Y(V,H,j){L(V,j);for(const K in H)if(Object.prototype.hasOwnProperty.call(H,K)&&H[K]!==null){const U=H[K];if(Array.isArray(U))for(let tt=0;tt=1.5*y;return Math.round(g/y)+" "+w+(m?"s":"")}s.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 m=/^(-?(?:\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(!!m){var _=parseFloat(m[1]);switch((m[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return _*c;case"weeks":case"week":case"w":return _*u;case"days":case"day":case"d":return _*o;case"hours":case"hour":case"hrs":case"hr":case"h":return _*l;case"minutes":case"minute":case"mins":case"min":case"m":return _*r;case"seconds":case"second":case"secs":case"sec":case"s":return _*a;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 m=Math.abs(w);return m>=o?f(w,m,o,"day"):m>=l?f(w,m,l,"hour"):m>=r?f(w,m,r,"minute"):m>=a?f(w,m,a,"second"):w+" ms"}(g):function(w){var m=Math.abs(w);return m>=o?Math.round(w/o)+"d":m>=l?Math.round(w/l)+"h":m>=r?Math.round(w/r)+"m":m>=a?Math.round(w/a)+"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,s,n){const a=i("./lib/number-allocator.js");s.exports.NumberAllocator=a},{"./lib/number-allocator.js":47}],47:[function(i,s,n){const a=i("js-sdsl").Set,r=i("debug")("number-allocator:trace"),l=i("debug")("number-allocator:error");function o(c,f){this.low=c,this.high=f}function u(c,f){if(!(this instanceof u))return new u(c,f);this.min=c,this.max=f,this.ss=new a([],(g,v)=>g.compare(v)),r("Create"),this.clear()}o.prototype.equals=function(c){return this.low===c.low&&this.high===c.high},o.prototype.compare=function(c){return this.lowc)return!1;if(g.low===c)return++g.low,r("use():"+c),!0;if(g.high===c)return--g.high,r("use():"+c),!0;const v=g.low;return g.low=c+1,this.ss.insert(new o(v,c-1)),r("use():"+c),!0}return r("use():failed"),!1},u.prototype.free=function(c){if(cthis.max)return void l("free():"+c+" is out of range");const f=new o(c,c),g=this.ss.lowerBound(f);if(g){if(g.low<=c&&c<=g.high)return void l("free():"+c+" has already been vacant");if(g===this.ss.front())c+1===g.low?--g.low:this.ss.insert(f);else{const v=this.ss.reverseLowerBound(f);v.high+1===c?c+1===g.low?(this.ss.eraseElementByValue(v),g.low=v.low):v.high=c:c+1===g.low?g.low=c:this.ss.insert(f)}}else{if(g===this.ss.front())return void this.ss.insert(f);const v=this.ss.reverseLowerBound(f);v.high+1===c?v.high=c:this.ss.insert(f)}r("free():"+c)},u.prototype.clear=function(){r("clear()"),this.ss.clear(),this.ss.insert(new o(this.min,this.max))},u.prototype.intervalCount=function(){return this.ss.size()},u.prototype.dump=function(){console.log("length:"+this.ss.size());for(const c of this.ss)console.log(c)},s.exports=u},{debug:18,"js-sdsl":36}],48:[function(i,s,n){var a=i("wrappy");function r(o){var u=function(){return u.called?u.value:(u.called=!0,u.value=o.apply(this,arguments))};return u.called=!1,u}function l(o){var u=function(){if(u.called)throw new Error(u.onceError);return u.called=!0,u.value=o.apply(this,arguments)},c=o.name||"Function wrapped with `once`";return u.onceError=c+" shouldn't be called more than once",u.called=!1,u}s.exports=a(r),s.exports.strict=a(l),r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return l(this)},configurable:!0})})},{wrappy:79}],49:[function(i,s,n){(function(a){(function(){a===void 0||!a.version||a.version.indexOf("v0.")===0||a.version.indexOf("v1.")===0&&a.version.indexOf("v1.8.")!==0?s.exports={nextTick:function(r,l,o,u){if(typeof r!="function")throw new TypeError('"callback" argument must be a function');var c,f,g=arguments.length;switch(g){case 0:case 1:return a.nextTick(r);case 2:return a.nextTick(function(){r.call(null,l)});case 3:return a.nextTick(function(){r.call(null,l,o)});case 4:return a.nextTick(function(){r.call(null,l,o,u)});default:for(c=new Array(g-1),f=0;f1)for(var S=1;S= 0x80 (not a basic code point)","invalid-input":"Invalid input"},$=v-y,Q=Math.floor,R=String.fromCharCode;function T(K){throw new RangeError(D[K])}function P(K,U){for(var tt=K.length,st=[];tt--;)st[tt]=U(K[tt]);return st}function O(K,U){var tt=K.split("@"),st="";return tt.length>1&&(st=tt[0]+"@",K=tt[1]),st+P((K=K.replace(M,".")).split("."),U).join(".")}function Y(K){for(var U,tt,st=[],et=0,ut=K.length;et=55296&&U<=56319&&et65535&&(tt+=R((U-=65536)>>>10&1023|55296),U=56320|1023&U),tt+=R(U)}).join("")}function at(K,U){return K+22+75*(K<26)-((U!=0)<<5)}function V(K,U,tt){var st=0;for(K=tt?Q(K/_):K>>1,K+=Q(K/U);K>$*w>>1;st+=v)K=Q(K/$);return Q(st+($+1)*K/(K+m))}function H(K){var U,tt,st,et,ut,ct,ot,b,k,I,N,X=[],G=K.length,rt=0,mt=x,yt=E;for((tt=K.lastIndexOf(C))<0&&(tt=0),st=0;st=128&&T("not-basic"),X.push(K.charCodeAt(st));for(et=tt>0?tt+1:0;et=G&&T("invalid-input"),((b=(N=K.charCodeAt(et++))-48<10?N-22:N-65<26?N-65:N-97<26?N-97:v)>=v||b>Q((g-rt)/ct))&&T("overflow"),rt+=b*ct,!(b<(k=ot<=yt?y:ot>=yt+w?w:ot-yt));ot+=v)ct>Q(g/(I=v-k))&&T("overflow"),ct*=I;yt=V(rt-ut,U=X.length+1,ut==0),Q(rt/U)>g-mt&&T("overflow"),mt+=Q(rt/U),rt%=U,X.splice(rt++,0,mt)}return Z(X)}function j(K){var U,tt,st,et,ut,ct,ot,b,k,I,N,X,G,rt,mt,yt=[];for(X=(K=Y(K)).length,U=x,tt=0,ut=E,ct=0;ct=U&&NQ((g-tt)/(G=st+1))&&T("overflow"),tt+=(ot-U)*G,U=ot,ct=0;ctg&&T("overflow"),N==U){for(b=tt,k=v;!(b<(I=k<=ut?y:k>=ut+w?w:k-ut));k+=v)mt=b-I,rt=v-I,yt.push(R(at(I+mt%rt,0))),b=Q(mt/rt);yt.push(R(at(b,0))),ut=V(tt,G,st==et),tt=0,++st}++tt,++U}return yt.join("")}if(c={version:"1.4.1",ucs2:{decode:Y,encode:Z},decode:H,encode:j,toASCII:function(K){return O(K,function(U){return L.test(U)?"xn--"+j(U):U})},toUnicode:function(K){return O(K,function(U){return S.test(U)?H(U.slice(4).toLowerCase()):U})}},l&&o)if(s.exports==l)o.exports=c;else for(f in c)c.hasOwnProperty(f)&&(l[f]=c[f]);else r.punycode=c})(this)}).call(this)}).call(this,typeof De<"u"?De:typeof self<"u"?self:typeof window<"u"?window:{})},{}],52:[function(i,s,n){function a(l,o){return Object.prototype.hasOwnProperty.call(l,o)}s.exports=function(l,o,u,c){o=o||"&",u=u||"=";var f={};if(typeof l!="string"||l.length===0)return f;var g=/\+/g;l=l.split(o);var v=1e3;c&&typeof c.maxKeys=="number"&&(v=c.maxKeys);var y=l.length;v>0&&y>v&&(y=v);for(var w=0;w=0?(m=C.substr(0,S),_=C.substr(S+1)):(m=C,_=""),E=decodeURIComponent(m),x=decodeURIComponent(_),a(f,E)?r(f[E])?f[E].push(x):f[E]=[f[E],x]:f[E]=x}return f};var r=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"}},{}],53:[function(i,s,n){var a=function(u){switch(typeof u){case"string":return u;case"boolean":return u?"true":"false";case"number":return isFinite(u)?u:"";default:return""}};s.exports=function(u,c,f,g){return c=c||"&",f=f||"=",u===null&&(u=void 0),typeof u=="object"?l(o(u),function(v){var y=encodeURIComponent(a(v))+f;return r(u[v])?l(u[v],function(w){return y+encodeURIComponent(a(w))}).join(c):y+encodeURIComponent(a(u[v]))}).join(c):g?encodeURIComponent(a(g))+f+encodeURIComponent(a(u)):""};var r=Array.isArray||function(u){return Object.prototype.toString.call(u)==="[object Array]"};function l(u,c){if(u.map)return u.map(c);for(var f=[],g=0;g2?"one of ".concat(u," ").concat(o.slice(0,c-1).join(", "),", or ")+o[c-1]:c===2?"one of ".concat(u," ").concat(o[0]," or ").concat(o[1]):"of ".concat(u," ").concat(o[0])}return"of ".concat(u," ").concat(String(o))}r("ERR_INVALID_OPT_VALUE",function(o,u){return'The value "'+u+'" is invalid for option "'+o+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(o,u,c){var f,g,v;if(typeof u=="string"&&(g="not ",u.substr(0,g.length)===g)?(f="must not be",u=u.replace(/^not /,"")):f="must be",function(w,m,_){return(_===void 0||_>w.length)&&(_=w.length),w.substring(_-m.length,_)===m}(o," argument"))v="The ".concat(o," ").concat(f," ").concat(l(u,"type"));else{var y=function(w,m,_){return typeof _!="number"&&(_=0),!(_+m.length>w.length)&&w.indexOf(m,_)!==-1}(o,".")?"property":"argument";v='The "'.concat(o,'" ').concat(y," ").concat(f," ").concat(l(u,"type"))}return v+=". Received type ".concat(typeof c)},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(o){return"The "+o+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(o){return"Cannot call "+o+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(o){return"Unknown encoding: "+o},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),s.exports.codes=a},{}],56:[function(i,s,n){(function(a){(function(){var r=Object.keys||function(w){var m=[];for(var _ in w)m.push(_);return m};s.exports=g;var l=i("./_stream_readable"),o=i("./_stream_writable");i("inherits")(g,l);for(var u=r(o.prototype),c=0;c0)if(typeof k=="string"||rt.objectMode||Object.getPrototypeOf(k)===c.prototype||(k=function(mt){return c.from(mt)}(k)),N)rt.endEmitted?$(b,new D):O(b,rt,k,!0);else if(rt.ended)$(b,new L);else{if(rt.destroyed)return!1;rt.reading=!1,rt.decoder&&!I?(k=rt.decoder.write(k),rt.objectMode||k.length!==0?O(b,rt,k,!1):H(b,rt)):O(b,rt,k,!1)}else N||(rt.reading=!1,H(b,rt));return!rt.ended&&(rt.lengthk.highWaterMark&&(k.highWaterMark=function(I){return I>=Y?I=Y:(I--,I|=I>>>1,I|=I>>>2,I|=I>>>4,I|=I>>>8,I|=I>>>16,I++),I}(b)),b<=k.length?b:k.ended?k.length:(k.needReadable=!0,0))}function at(b){var k=b._readableState;g("emitReadable",k.needReadable,k.emittedReadable),k.needReadable=!1,k.emittedReadable||(g("emitReadable",k.flowing),k.emittedReadable=!0,a.nextTick(V,b))}function V(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,st(b)}function H(b,k){k.readingMore||(k.readingMore=!0,a.nextTick(j,b,k))}function j(b,k){for(;!k.reading&&!k.ended&&(k.length0,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"),st(b),k.flowing&&!k.reading&&b.read(0)}function st(b){var k=b._readableState;for(g("flow",k.flowing);k.flowing&&b.read()!==null;);}function et(b,k){return k.length===0?null:(k.objectMode?I=k.buffer.shift():!b||b>=k.length?(I=k.decoder?k.buffer.join(""):k.buffer.length===1?k.buffer.first():k.buffer.concat(k.length),k.buffer.clear()):I=k.buffer.consume(b,k.decoder),I);var I}function ut(b){var k=b._readableState;g("endReadable",k.endEmitted),k.endEmitted||(k.ended=!0,a.nextTick(ct,k,b))}function ct(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 I=k._writableState;(!I||I.autoDestroy&&I.finished)&&k.destroy()}}function ot(b,k){for(var I=0,N=b.length;I=k.highWaterMark:k.length>0)||k.ended))return g("read: emitReadable",k.length,k.ended),k.length===0&&k.ended?ut(this):at(this),null;if((b=Z(b,k))===0&&k.ended)return k.length===0&&ut(this),null;var N,X=k.needReadable;return g("need readable",X),(k.length===0||k.length-b0?et(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),I!==b&&k.ended&&ut(this)),N!==null&&this.emit("data",N),N},T.prototype._read=function(b){$(this,new M("_read()"))},T.prototype.pipe=function(b,k){var I=this,N=this._readableState;switch(N.pipesCount){case 0:N.pipes=b;break;case 1:N.pipes=[N.pipes,b];break;default:N.pipes.push(b)}N.pipesCount+=1,g("pipe count=%d opts=%j",N.pipesCount,k);var X=(!k||k.end!==!1)&&b!==a.stdout&&b!==a.stderr?rt:xe;function G(Vt,te){g("onunpipe"),Vt===I&&te&&te.hasUnpiped===!1&&(te.hasUnpiped=!0,g("cleanup"),b.removeListener("close",be),b.removeListener("finish",se),b.removeListener("drain",mt),b.removeListener("error",Tt),b.removeListener("unpipe",G),I.removeListener("end",rt),I.removeListener("end",xe),I.removeListener("data",Et),yt=!0,!N.awaitDrain||b._writableState&&!b._writableState.needDrain||mt())}function rt(){g("onend"),b.end()}N.endEmitted?a.nextTick(X):I.once("end",X),b.on("unpipe",G);var mt=function(Vt){return function(){var te=Vt._readableState;g("pipeOnDrain",te.awaitDrain),te.awaitDrain&&te.awaitDrain--,te.awaitDrain===0&&o(Vt,"data")&&(te.flowing=!0,st(Vt))}}(I);b.on("drain",mt);var yt=!1;function Et(Vt){g("ondata");var te=b.write(Vt);g("dest.write",te),te===!1&&((N.pipesCount===1&&N.pipes===b||N.pipesCount>1&&ot(N.pipes,b)!==-1)&&!yt&&(g("false write response, pause",N.awaitDrain),N.awaitDrain++),I.pause())}function Tt(Vt){g("onerror",Vt),xe(),b.removeListener("error",Tt),o(b,"error")===0&&$(b,Vt)}function be(){b.removeListener("finish",se),xe()}function se(){g("onfinish"),b.removeListener("close",be),xe()}function xe(){g("unpipe"),I.unpipe(b)}return I.on("data",Et),function(Vt,te,xi){if(typeof Vt.prependListener=="function")return Vt.prependListener(te,xi);Vt._events&&Vt._events[te]?Array.isArray(Vt._events[te])?Vt._events[te].unshift(xi):Vt._events[te]=[xi,Vt._events[te]]:Vt.on(te,xi)}(b,"error",Tt),b.once("close",be),b.once("finish",se),b.emit("pipe",I),N.flowing||(g("pipe resume"),I.resume()),b},T.prototype.unpipe=function(b){var k=this._readableState,I={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,I),this);if(!b){var N=k.pipes,X=k.pipesCount;k.pipes=null,k.pipesCount=0,k.flowing=!1;for(var G=0;G0,N.flowing!==!1&&this.resume()):b==="readable"&&(N.endEmitted||N.readableListening||(N.readableListening=N.needReadable=!0,N.flowing=!1,N.emittedReadable=!1,g("on readable",N.length,N.reading),N.length?at(this):N.reading||a.nextTick(U,this))),I},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(b,k){var I=u.prototype.removeListener.call(this,b,k);return b==="readable"&&a.nextTick(K,this),I},T.prototype.removeAllListeners=function(b){var k=u.prototype.removeAllListeners.apply(this,arguments);return b!=="readable"&&b!==void 0||a.nextTick(K,this),k},T.prototype.resume=function(){var b=this._readableState;return b.flowing||(g("resume"),b.flowing=!b.readableListening,function(k,I){I.resumeScheduled||(I.resumeScheduled=!0,a.nextTick(tt,k,I))}(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,I=this._readableState,N=!1;for(var X in b.on("end",function(){if(g("wrapped end"),I.decoder&&!I.ended){var rt=I.decoder.end();rt&&rt.length&&k.push(rt)}k.push(null)}),b.on("data",function(rt){g("wrapped data"),I.decoder&&(rt=I.decoder.write(rt)),(!I.objectMode||rt!=null)&&(I.objectMode||rt&&rt.length)&&(k.push(rt)||(N=!0,b.pause()))}),b)this[X]===void 0&&typeof b[X]=="function"&&(this[X]=function(rt){return function(){return b[rt].apply(b,arguments)}}(X));for(var G=0;G-1))throw new D(H);return this._writableState.defaultEncoding=H,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(H,j,K){K(new E("_write()"))},T.prototype._writev=null,T.prototype.end=function(H,j,K){var U=this._writableState;return typeof H=="function"?(K=H,H=null,j=null):typeof j=="function"&&(K=j,j=null),H!=null&&this.write(H,j),U.corked&&(U.corked=1,this.uncork()),U.ending||function(tt,st,et){st.ending=!0,V(tt,st),et&&(st.finished?a.nextTick(et):tt.once("finish",et)),st.ended=!0,tt.writable=!1}(this,U,K),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(H){this._writableState&&(this._writableState.destroyed=H)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(H,j){j(H)}}).call(this)}).call(this,i("_process"),typeof De<"u"?De: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,s,n){(function(a){(function(){var r;function l(C,S,L){return S in C?Object.defineProperty(C,S,{value:L,enumerable:!0,configurable:!0,writable:!0}):C[S]=L,C}var o=i("./end-of-stream"),u=Symbol("lastResolve"),c=Symbol("lastReject"),f=Symbol("error"),g=Symbol("ended"),v=Symbol("lastPromise"),y=Symbol("handlePromise"),w=Symbol("stream");function m(C,S){return{value:C,done:S}}function _(C){var S=C[u];if(S!==null){var L=C[w].read();L!==null&&(C[v]=null,C[u]=null,C[c]=null,S(m(L,!1)))}}var E=Object.getPrototypeOf(function(){}),x=Object.setPrototypeOf((l(r={get stream(){return this[w]},next:function(){var C=this,S=this[f];if(S!==null)return Promise.reject(S);if(this[g])return Promise.resolve(m(void 0,!0));if(this[w].destroyed)return new Promise(function($,Q){a.nextTick(function(){C[f]?Q(C[f]):$(m(void 0,!0))})});var L,M=this[v];if(M)L=new Promise(function($,Q){return function(R,T){$.then(function(){Q[g]?R(m(void 0,!0)):Q[y](R,T)},T)}}(M,this));else{var D=this[w].read();if(D!==null)return Promise.resolve(m(D,!1));L=new Promise(this[y])}return this[v]=L,L}},Symbol.asyncIterator,function(){return this}),l(r,"return",function(){var C=this;return new Promise(function(S,L){C[w].destroy(null,function(M){M?L(M):S(m(void 0,!0))})})}),r),E);s.exports=function(C){var S,L=Object.create(x,(l(S={},w,{value:C,writable:!0}),l(S,u,{value:null,writable:!0}),l(S,c,{value:null,writable:!0}),l(S,f,{value:null,writable:!0}),l(S,g,{value:C._readableState.endEmitted,writable:!0}),l(S,y,{value:function(M,D){var $=L[w].read();$?(L[v]=null,L[u]=null,L[c]=null,M(m($,!1))):(L[u]=M,L[c]=D)},writable:!0}),S));return L[v]=null,o(C,function(M){if(M&&M.code!=="ERR_STREAM_PREMATURE_CLOSE"){var D=L[c];return D!==null&&(L[v]=null,L[u]=null,L[c]=null,D(M)),void(L[f]=M)}var $=L[u];$!==null&&(L[v]=null,L[u]=null,L[c]=null,$(m(void 0,!0))),L[g]=!0}),C.on("readable",function(M){a.nextTick(_,M)}.bind(null,L)),L}}).call(this)}).call(this,i("_process"))},{"./end-of-stream":64,_process:50}],62:[function(i,s,n){function a(f,g){var v=Object.keys(f);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(f);g&&(y=y.filter(function(w){return Object.getOwnPropertyDescriptor(f,w).enumerable})),v.push.apply(v,y)}return v}function r(f,g,v){return g in f?Object.defineProperty(f,g,{value:v,enumerable:!0,configurable:!0,writable:!0}):f[g]=v,f}function l(f,g){for(var v=0;v0?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,m=""+w.data;w=w.next;)m+=y+w.data;return m}},{key:"concat",value:function(y){if(this.length===0)return o.alloc(0);for(var w,m,_,E=o.allocUnsafe(y>>>0),x=this.head,C=0;x;)w=x.data,m=E,_=C,o.prototype.copy.call(w,m,_),C+=x.data.length,x=x.next;return E}},{key:"consume",value:function(y,w){var m;return yE.length?E.length:y;if(x===E.length?_+=E:_+=E.slice(0,y),(y-=x)===0){x===E.length?(++m,w.next?this.head=w.next:this.head=this.tail=null):(this.head=w,w.data=E.slice(x));break}++m}return this.length-=m,_}},{key:"_getBuffer",value:function(y){var w=o.allocUnsafe(y),m=this.head,_=1;for(m.data.copy(w),y-=m.data.length;m=m.next;){var E=m.data,x=y>E.length?E.length:y;if(E.copy(w,w.length-y,0,x),(y-=x)===0){x===E.length?(++_,m.next?this.head=m.next:this.head=this.tail=null):(this.head=m,m.data=E.slice(x));break}++_}return this.length-=_,w}},{key:c,value:function(y,w){return u(this,function(m){for(var _=1;_0,function(S){w||(w=S),S&&_.forEach(c),C||(_.forEach(c),m(w))})});return v.reduce(f)}},{"../../../errors":55,"./end-of-stream":64}],67:[function(i,s,n){var a=i("../../../errors").codes.ERR_INVALID_OPT_VALUE;s.exports={getHighWaterMark:function(r,l,o,u){var c=function(f,g,v){return f.highWaterMark!=null?f.highWaterMark:g?f[v]:null}(l,u,o);if(c!=null){if(!isFinite(c)||Math.floor(c)!==c||c<0)throw new a(u?o:"highWaterMark",c);return Math.floor(c)}return r.objectMode?16:16384}}},{"../../../errors":55}],68:[function(i,s,n){s.exports=i("events").EventEmitter},{events:22}],69:[function(i,s,n){(n=s.exports=i("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=i("./lib/_stream_writable.js"),n.Duplex=i("./lib/_stream_duplex.js"),n.Transform=i("./lib/_stream_transform.js"),n.PassThrough=i("./lib/_stream_passthrough.js"),n.finished=i("./lib/internal/streams/end-of-stream.js"),n.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,s,n){s.exports=function(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("interval needed");var a;if(arguments.length>0){a=new Array(arguments.length-2);for(var r=0;r>5==6?2:m>>4==14?3:m>>3==30?4:m>>6==2?-1:-2}function u(m){var _=this.lastTotal-this.lastNeed,E=function(x,C,S){if((192&C[0])!=128)return x.lastNeed=0,"\uFFFD";if(x.lastNeed>1&&C.length>1){if((192&C[1])!=128)return x.lastNeed=1,"\uFFFD";if(x.lastNeed>2&&C.length>2&&(192&C[2])!=128)return x.lastNeed=2,"\uFFFD"}}(this,m);return E!==void 0?E:this.lastNeed<=m.length?(m.copy(this.lastChar,_,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(m.copy(this.lastChar,_,0,m.length),void(this.lastNeed-=m.length))}function c(m,_){if((m.length-_)%2==0){var E=m.toString("utf16le",_);if(E){var x=E.charCodeAt(E.length-1);if(x>=55296&&x<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],E.slice(0,-1)}return E}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",_,m.length-1)}function f(m){var _=m&&m.length?this.write(m):"";if(this.lastNeed){var E=this.lastTotal-this.lastNeed;return _+this.lastChar.toString("utf16le",0,E)}return _}function g(m,_){var E=(m.length-_)%3;return E===0?m.toString("base64",_):(this.lastNeed=3-E,this.lastTotal=3,E===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",_,m.length-E))}function v(m){var _=m&&m.length?this.write(m):"";return this.lastNeed?_+this.lastChar.toString("base64",0,3-this.lastNeed):_}function y(m){return m.toString(this.encoding)}function w(m){return m&&m.length?this.write(m):""}n.StringDecoder=l,l.prototype.write=function(m){if(m.length===0)return"";var _,E;if(this.lastNeed){if((_=this.fillLast(m))===void 0)return"";E=this.lastNeed,this.lastNeed=0}else E=0;return E=0?(D>0&&(C.lastNeed=D-1),D):--M=0?(D>0&&(C.lastNeed=D-2),D):--M=0?(D>0&&(D===2?D=0:C.lastNeed=D-3),D):0}(this,m,_);if(!this.lastNeed)return m.toString("utf8",_);this.lastTotal=E;var x=m.length-(E-this.lastNeed);return m.copy(this.lastChar,0,x),m.toString("utf8",_,x)},l.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length}},{"safe-buffer":73}],76:[function(i,s,n){var a=i("punycode"),r=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}n.parse=S,n.resolve=function(L,M){return S(L,!1,!0).resolve(M)},n.resolveObject=function(L,M){return L?S(L,!1,!0).resolveObject(M):M},n.format=function(L){return r.isString(L)&&(L=S(L)),L instanceof l?L.format():l.prototype.format.call(L)},n.Url=l;var o=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,f=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",` `," "]),g=["'"].concat(f),v=["%","/","?",";","#"].concat(g),y=["/","?","#"],w=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_={javascript:!0,"javascript:":!0},E={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},C=i("querystring");function S(L,M,D){if(L&&r.isObject(L)&&L instanceof l)return L;var $=new l;return $.parse(L,M,D),$}l.prototype.parse=function(L,M,D){if(!r.isString(L))throw new TypeError("Parameter 'url' must be a string, not "+typeof L);var $=L.indexOf("?"),Q=$!==-1&&$127?ut+="x":ut+=et[ct];if(!ut.match(w)){var b=tt.slice(0,j),k=tt.slice(j+1),I=et.match(m);I&&(b.push(I[1]),k.unshift(I[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=a.toASCII(this.hostname));var N=this.port?":"+this.port:"",X=this.hostname||"";this.host=X+N,this.href+=this.host,U&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),T[0]!=="/"&&(T="/"+T))}if(!_[Y])for(j=0,st=g.length;j0)&&D.host.split("@"))&&(D.auth=I.shift(),D.host=D.hostname=I.shift())),D.search=L.search,D.query=L.query,r.isNull(D.pathname)&&r.isNull(D.search)||(D.path=(D.pathname?D.pathname:"")+(D.search?D.search:"")),D.href=D.format(),D;if(!et.length)return D.pathname=null,D.search?D.path="/"+D.search:D.path=null,D.href=D.format(),D;for(var ct=et.slice(-1)[0],ot=(D.host||L.host||et.length>1)&&(ct==="."||ct==="..")||ct==="",b=0,k=et.length;k>=0;k--)(ct=et[k])==="."?et.splice(k,1):ct===".."?(et.splice(k,1),b++):b&&(et.splice(k,1),b--);if(!tt&&!st)for(;b--;b)et.unshift("..");!tt||et[0]===""||et[0]&&et[0].charAt(0)==="/"||et.unshift(""),ot&&et.join("/").substr(-1)!=="/"&&et.push("");var I,N=et[0]===""||et[0]&&et[0].charAt(0)==="/";return ut&&(D.hostname=D.host=N?"":et.length?et.shift():"",(I=!!(D.host&&D.host.indexOf("@")>0)&&D.host.split("@"))&&(D.auth=I.shift(),D.host=D.hostname=I.shift())),(tt=tt||D.host&&et.length)&&!N&&et.unshift(""),et.length?D.pathname=et.join("/"):(D.pathname=null,D.path=null),r.isNull(D.pathname)&&r.isNull(D.search)||(D.path=(D.pathname?D.pathname:"")+(D.search?D.search:"")),D.auth=L.auth||D.auth,D.slashes=D.slashes||L.slashes,D.href=D.format(),D},l.prototype.parseHost=function(){var L=this.host,M=u.exec(L);M&&((M=M[0])!==":"&&(this.port=M.substr(1)),L=L.substr(0,L.length-M.length)),L&&(this.hostname=L)}},{"./util":77,punycode:51,querystring:54}],77:[function(i,s,n){s.exports={isString:function(a){return typeof a=="string"},isObject:function(a){return typeof a=="object"&&a!==null},isNull:function(a){return a===null},isNullOrUndefined:function(a){return a==null}}},{}],78:[function(i,s,n){(function(a){(function(){function r(l){try{if(!a.localStorage)return!1}catch{return!1}var o=a.localStorage[l];return o!=null&&String(o).toLowerCase()==="true"}s.exports=function(l,o){if(r("noDeprecation"))return l;var u=!1;return function(){if(!u){if(r("throwDeprecation"))throw new Error(o);r("traceDeprecation")?console.trace(o):console.warn(o),u=!0}return l.apply(this,arguments)}}}).call(this)}).call(this,typeof De<"u"?De:typeof self<"u"?self:typeof window<"u"?window:{})},{}],79:[function(i,s,n){s.exports=function a(r,l){if(r&&l)return a(r)(l);if(typeof r!="function")throw new TypeError("need wrapper function");return Object.keys(r).forEach(function(u){o[u]=r[u]}),o;function o(){for(var u=new Array(arguments.length),c=0;c0)for(var g=0,v=arguments.length;g1)g=f;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=c(g,v.value,y),v=v.next;return g},a.prototype.reduceReverse=function(c,f){var g,v=this.tail;if(arguments.length>1)g=f;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=c(g,v.value,y),v=v.prev;return g},a.prototype.toArray=function(){for(var c=new Array(this.length),f=0,g=this.head;g!==null;f++)c[f]=g.value,g=g.next;return c},a.prototype.toArrayReverse=function(){for(var c=new Array(this.length),f=0,g=this.tail;g!==null;f++)c[f]=g.value,g=g.prev;return c},a.prototype.slice=function(c,f){(f=f||this.length)<0&&(f+=this.length),(c=c||0)<0&&(c+=this.length);var g=new a;if(fthis.length&&(f=this.length);for(var v=0,y=this.head;y!==null&&vthis.length&&(f=this.length);for(var v=this.length,y=this.tail;y!==null&&v>f;v--)y=y.prev;for(;y!==null&&v>c;v--,y=y.prev)g.push(y.value);return g},a.prototype.splice=function(c,f,...g){c>this.length&&(c=this.length-1),c<0&&(c=this.length+c);for(var v=0,y=this.head;y!==null&&v'},info:{color:"#0052d9",icon:''},warning:{color:"#e37318",icon:''},error:{color:"#d54941",icon:''},question:{color:"#0052d9",icon:''}},Je={};class pk{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,"height");W(this,"id");var n;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=Uf[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 s;for(let a=0;a{this.close()},this.duration);let t=-1;Object.keys(Je).forEach(i=>{var s;((s=Je[i])==null?void 0:s.placement)===this.placement&&t++}),this.setPosition(this.placement,t),this.icon.children[0].style.fill=Uf[this.theme].color}setPosition(t,i=0){switch(t){case"top":this.box.style.top=`${30+i*(this.height||60)}px`,this.box.style.left="50%";break;case"bottom":this.box.style.bottom=`${30+i*(this.height||60)}px`,this.box.style.left="50%";break;case"left":this.box.style.top=`${30+i*(this.height||60)}px`,this.box.style.left="30px";break;case"right":this.box.style.top=`${30+i*(this.height||60)}px`,this.box.style.right="30px";break}}close(){Object.keys(Je).forEach(t=>{var i;if(((i=Je[t])==null?void 0:i.placement)===this.placement)switch(this.placement){case"top":case"left":case"right":Je[t].box.style.top=parseInt(Je[t].box.style.top)-60+"px";break;case"bottom":Je[t].box.style.bottom=parseInt(Je[t].box.style.bottom)-60+"px";break}}),Je[this.id]=null,delete Je[this.id],this.box.remove()}}function wk(e,t){if(e.jetLinksList.length){let i=t.url;i.startsWith("/")&&(i=(location.protocol==="https:"?"wss://":"ws://")+window.location.host+i),e.jetLinksClient=new WebSocket(`${i}/${localStorage.getItem("X-Access-Token")||ga("X-Access-Token")||new URLSearchParams(location.search).get("X-Access-Token")||""}`),e.jetLinksClient.onmessage=s=>{var a;const n=JSON.parse(s.data);if(!!n.payload)if((a=n.payload)!=null&&a.properties){const r=[];for(let l in n.payload.properties)r.push({id:`${n.payload.headers.productId}#${n.payload.deviceId}#${l}`,value:n.payload.properties[l]});e.setDatas(r,{history:!1})}else n.topic.startsWith("/notifications")&&_g(e,n)},e.jetLinksClient.onopen=()=>{e.jetLinksList.forEach(s=>{e.jetLinksClient.send(JSON.stringify({type:"sub",topic:`/device${s.topic}/message/property/report`,parameter:{deviceId:s.deviceId,properties:s.properties,history:1},id:s.topic+"-"+It()}))}),t.notification&&e.jetLinksClient.send(JSON.stringify({type:"sub",topic:"/notifications",id:"notification",parameter:{}}))}}}function _g(e,t){var r,l;let i=t.payload.topicName,s=t.payload.message,n=t.payload.notifyTime,a=`
${i}
${bk(n)}
${s}
`;e.message({content:a,duration:0,closeBtn:!0,placement:"right",height:75}),(r=t.payload.detail)!=null&&r.alarmConfigId&&Ek(e,(l=t.payload.detail)==null?void 0:l.alarmConfigId)}globalThis.doWarning=_g;function bk(e){const t=new Date(e),i=t.getFullYear(),s=(t.getMonth()+1+"").padStart(2,"0"),n=(t.getDate()+"").padStart(2,"0"),a=(t.getHours()+"").padStart(2,"0"),r=(t.getMinutes()+"").padStart(2,"0"),l=(t.getSeconds()+"").padStart(2,"0");return i+"-"+s+"-"+n+" "+a+":"+r+":"+l}function xk(e){e.jetLinksClient&&(e.jetLinksClient.close(),e.jetLinksClient=void 0)}function _k(e,t,i){const s=[];return i.list.forEach((n,a)=>{var l,o,u;const r=n.params?e.findOne(n.params):t;s[a]={deviceId:r.deviceId,productId:r.productId,properties:{}};for(let c in n.value)if(n.value[c]===void 0||n.value[c]===""){const f=(l=r.realTimes)==null?void 0:l.find(g=>g.propertyId===c);f&&(s[a].properties[c]=r[f.key])}else if(typeof n.value[c]=="string"&&((o=n.value[c])==null?void 0:o.indexOf("${"))>-1){let f=n.value[c].match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(s[a].properties[c]=(u=r[f[0]])!=null?u:e.getDynamicParam(f[0]))}else s[a].properties[c]=n.value[c]}),s}async function kk(e,t){t.forEach(async i=>{let s=i.deviceId;if(s&&s.indexOf("${")>-1){let a=s.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));a!=null&&a.length&&(s=e.getDynamicParam(a[0])||s)}(await fetch(`/api/device-instance/${s}/property`,{headers:{"X-Access-Token":localStorage.getItem("X-Access-Token")||new URLSearchParams(location.search).get("X-Access-Token")||"","Content-Type":"application/json"},method:"put",body:JSON.stringify(i.properties)})).ok?(console.info("\u53D1\u9001\u6210\u529F"),e.message({theme:"success",content:"\u4E0B\u53D1\u6210\u529F"})):e.message({theme:"error",content:"\u4E0B\u53D1\u5931\u8D25"})})}async function Ek(e,t){const i=await fetch(`/api/alarm/config/${t}`,{headers:{"X-Access-Token":localStorage.getItem("X-Access-Token")||new URLSearchParams(location.search).get("X-Access-Token")||"","Content-Type":"application/json"},method:"GET"});if(i.ok){let s=await i.json();s.result.media&&kg(e,s.result.media,s.result.playTimes)}}function kg(e,t,i){if(e.store.globalAudio||(e.store.globalAudio=document.createElement("audio")),e.store.globalAudio.src=t,e.store.globalAudio.play(),i===-1)e.store.globalAudio.loop=!0;else{e.store.globalAudio.loop=!1;let s=0;e.store.globalAudio.onended=()=>{s++,s{this.store.data.lineAnimateDraws[t]=i,kt.lineAnimateDraws[t]=new Function("ctx","pen","state","index",i)});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,"iotMqttClient");W(this,"iotTimer");W(this,"iotWebsocketClient");W(this,"onEvent",(t,i)=>{switch(t){case"add":i.forEach(s=>{var n;(n=s.onAdd)==null||n.call(s,s)}),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(s=>{this.doEvent(s,t)});break;case"click":if(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.formId){const s=this.store.pens[i.pen.formId];i.pen.formType==="submit"?this.store.data.locked&&s&&!s.disabled&&this.doEvent(s,"submit"):i.pen.formType==="reset"&&(nk(i.pen),this.store.data.locked&&s&&!s.disabled&&this.doEvent(s,"reset"))}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":i&&Hf(i,i.formValue),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":i.pen&&Hf(i.pen),i.pen?this.store.data.locked&&!i.pen.disabled&&this.doEvent(i.pen,t):this.store.data.locked&&i&&!i.disabled&&this.doEvent(i,t);break}this.doMessageEvent(t,i)});W(this,"doEvent",(t,i)=>{var a,r,l,o,u,c,f,g,v,y;if(!t)return;let s=!1,n=[];if((a=t.events)==null||a.forEach((w,m)=>{var _;if(w.actions&&w.actions.length){if(w.name===i){let E=!1;w.conditions&&w.conditions.length?w.conditionType==="and"?E=w.conditions.every(x=>this.judgeCondition(t,x.key,x)):w.conditionType==="or"&&(E=w.conditions.some(x=>this.judgeCondition(t,x.key,x))):E=!0,E&&n.push(m)}}else if(s=!0,this.events[w.action]&&w.name===i){let E=!((_=w.where)!=null&&_.type);if(w.where){const{fn:x,fnJs:C,comparison:S,key:L,value:M}=w.where;if(x)E=x(t,{meta2d:this});else if(C){try{w.where.fn=new Function("pen","context",C)}catch(D){console.error("Error: make function:",D)}w.where.fn&&(E=w.where.fn(t,{meta2d:this}))}else{let D=t[L];switch(["x","y","width","height"].includes(L)&&(D=this.getPenRect(t)[L]),S){case">":E=D>+M;break;case">=":E=D>=+M;break;case"<":E=D<+M;break;case"<=":E=D<=+M;break;case"=":case"==":E=D==M;break;case"!=":E=D!=M;break;case"[)":E=fn(+D,M);break;case"![)":E=!fn(+D,M);break;case"[]":E=dn(D,M);break;case"![]":E=!dn(D,M);break}}}E&&n.push(m)}}),s?(r=t.events)==null||r.forEach((w,m)=>{n.includes(m)&&this.events[w.action](t,w)}):(l=t.events)==null||l.forEach(async(w,m)=>{if(n.includes(m)){if(w.confirm&&!await this.canvas.popconfirm.showModal(t,this.canvas.mousePos,w.confirmTitle))return;w.actions.forEach(_=>{if(_.timeout){let E=setTimeout(()=>{this.events[_.action]&&(this.events[_.action](t,_),clearTimeout(E),E=null)},_.timeout)}else this.events[_.action]&&this.events[_.action](t,_)})}}),i==="valueUpdate"){(o=t.realTimes)==null||o.forEach(m=>{var E,x;let _=[];(E=m.triggers)==null||E.forEach((C,S)=>{var M;let L=!1;(M=C.conditions)!=null&&M.length?C.conditionType==="and"?L=C.conditions.every(D=>this.judgeCondition(t,m.key,D)):C.conditionType==="or"&&(L=C.conditions.some(D=>this.judgeCondition(t,m.key,D))):L=!0,L&&_.push(S)}),(x=m.triggers)==null||x.forEach((C,S)=>{var L;_.includes(S)&&((L=C.actions)==null||L.forEach(M=>{if(M.timeout){let D=setTimeout(()=>{this.events[M.action]&&(this.events[M.action](t,M),clearTimeout(D),D=null)},M.timeout)}else this.events[M.action](t,M)}))})});let w=[];if((u=this.store.globalTriggers[t.id])==null||u.forEach((m,_)=>{var x;let E=!1;(x=m.conditions)!=null&&x.length?m.conditionType==="and"?E=m.conditions.every(C=>this.judgeCondition(this.store.pens[C.source],C.key,C)):m.conditionType==="or"&&(E=m.conditions.some(C=>this.judgeCondition(this.store.pens[C.source],C.key,C))):E=!0,E&&w.push(_)}),(c=this.store.globalTriggers[t.id])==null||c.forEach((m,_)=>{var E;w.includes(_)&&((E=m.actions)==null||E.forEach(x=>{if(x.timeout){let C=setTimeout(()=>{this.events[x.action]&&(this.events[x.action](t,x),clearTimeout(C),C=null)},x.timeout)}else this.events[x.action](t,x)}))}),(f=t.triggers)!=null&&f.length){for(let m of t.triggers)if((g=m.status)!=null&&g.length)for(let _ of m.status){let E=!1;if((v=_.conditions)!=null&&v.length?_.conditionType==="and"?E=_.conditions.every(x=>this.judgeCondition(t,x.key,x)):_.conditionType==="or"&&(E=_.conditions.some(x=>this.judgeCondition(t,x.key,x))):E=!0,E){(y=_.actions)==null||y.forEach(x=>{if(x.timeout){let C=setTimeout(()=>{this.events[x.action]&&(this.events[x.action](t,x),clearTimeout(C),C=null)},x.timeout)}else this.events[x.action](t,x)});break}}}}this.doEvent(this.store.pens[t.parentId],i)});W(this,"doDataEvent",t=>{var n,a,r;if(!((n=this.store.data.dataEvents)!=null&&n.length))return;const i=t.reduce((l,{dataId:o,id:u,value:c})=>(l[u||o]=c,l),{});let s=[];(a=this.store.data.dataEvents)==null||a.forEach((l,o)=>{let u=!1;l.conditions&&l.conditions.length?l.conditionType==="and"?u=l.conditions.every(c=>this.dataJudegeCondition(i,c.key,c)):l.conditionType==="or"&&(u=l.conditions.some(c=>this.dataJudegeCondition(i,c.key,c))):u=!0,u&&s.push(o)}),(r=this.store.data.dataEvents)==null||r.forEach((l,o)=>{var u;s.includes(o)&&((u=l.actions)==null||u.forEach(c=>{this.events[c.action](i,c)}))})});W(this,"renderPenRaw",jr);W(this,"setElemPosition",Re);W(this,"setLifeCycleFunc",O_);this.store=Fx(It()),this.setOptions(i),this.setDatabyOptions(i),this.init(t),this.register(vk()),this.registerCanvasDraw({cube:v2}),this.registerAnchors(yk()),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,s;(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=Yt.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 pg(this.canvas)),this.canvas.scroll.show()):this.canvas.scroll&&this.canvas.scroll.hide()),(s=this.canvas)==null||s.initGlobalStyle()}getOptions(){return this.store.options}registerTheme(t,i){if(!Array.isArray(i))return;const s=/^\s*\S+\s*:\s*\S+\s*$/;if(!i.every(l=>s.test(l)))return;const a={},r=[];for(let l=0;l{var s,n;if(window&&i.value&&typeof i.value=="string"){let a=i.value;if(a.includes("${")){let r=(s=a.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(l=>l.slice(2,-1));r&&(r==null||r.forEach(l=>{a=a.replace(`\${${l}}`,t[l]||this.getDynamicParam(l))}))}window.open(a,(n=i.params)!=null?n:"_blank");return}console.warn("[meta2d] Link param is not a string")},this.events[he.SetProps]=(t,i)=>{var n,a,r;const s=i.value;if(s&&typeof s=="object"){const l=i.params?this.find(i.params):this.find(t.id),o={};for(let u in s)if((n=s[u])!=null&&n.id)o[u]=(a=this.store.pens[s[u].id])==null?void 0:a[s[u].key];else if(typeof s[u]=="string"&&s[u].includes("${")){let c=s[u],f=(r=c.match(/\$\{([^}]+)\}/g))==null?void 0:r.map(g=>g.slice(2,-1));f&&f.forEach(g=>{c=c.replace(`\${${g}}`,t[g]||this.getDynamicParam(g))}),o[u]=c}else o[u]=s[u];l.forEach(u=>{o.hasOwnProperty("visible")&&u.visible!==o.visible&&this.setVisible(u,o.visible),this.setValue({id:u.id,...o},{render:!1,doEvent:!1})}),this.render();return}console.warn("[meta2d] SetProps value is not an object")},this.events[he.StartAnimate]=(t,i)=>{let s=t;if(i.value&&(s=this.findOne(i.value)),!(this.store.animates.has(s)&&!s.calculative.pause&&s.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[he.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[he.StopAnimate]=(t,i)=>{if(!i.value||typeof i.value=="string"){if(i.value){let s=this.findOne(i.value);if(!this.store.animates.has(s))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[he.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[he.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[he.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[he.JS]=(t,i,s)=>{var n;if(i.value&&!i.fn)try{if(typeof i.value!="string")throw new Error("[meta2d] Function value must be string");const a=i.value;i.fn=new Function("pen","params","context",a)}catch(a){console.error("[meta2d]: Error on make a function:",a)}(n=i.fn)==null||n.call(i,t,s||i.params,{meta2d:this,eventName:i.name})},this.events[he.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[he.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[he.SendPropData]=(t,i)=>{const s=ht(i.value);if(s&&typeof s=="object"){const n=i.params?this.findOne(i.params):t;for(let a in s)(s[a]===void 0||s[a]==="")&&(s[a]=n[a]);s.id=n.id,this.doSendDataEvent(s,i.extend);return}console.warn("[meta2d] SendPropData value is not an object")},this.events[he.SendVarData]=(t,i)=>{const s=ht(i.value);if(s&&typeof s=="object"){const n=i.params?this.findOne(i.params):t;let a=[];for(let r in s){let l={dataId:r,value:s[r]};if(!l.value){let o=n.form.find(u=>u.dataIds&&u.dataIds.dataId===l.dataId);o&&(l.value=n[o.key])}a.push(l)}this.doSendDataEvent(a,i.extend);return}console.warn("[meta2d] SendVarData value is not an object")},this.events[he.Navigator]=(t,i)=>{i.value&&typeof i.value=="string"&&this.navigatorTo(i.value)},this.events[he.Dialog]=(t,i)=>{var s;if(i.params&&typeof i.params=="string"){let n=i.params;if(i.params.includes("${")){let r=(s=i.params.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(l=>l.slice(2,-1));r&&(r==null||r.forEach(l=>{n=n.replace(`\${${l}}`,t[l]||this.getDynamicParam(l))}))}Object.keys(i.extend).forEach(r=>{["x","y","width","height"].includes(r)||(n.indexOf("?")!==-1?n+=`&${r}=${i.extend[r]}`:n+=`?${r}=${i.extend[r]}`)});let a=this.getEventData(i.list,t);Object.keys(a).length&&(a=null),this.canvas.dialog.show(i.value,n,i.extend,a)}},this.events[he.SendData]=(t,i)=>{var n,a,r,l,o;if((n=i.data)!=null&&n.length){const u=this.getSendData(i.data);t.formId&&t.formData&&Object.assign(u,t.formData),this.sendDataToNetWork(u,t,i);return}if((a=i.list)!=null&&a.length){if(i.network&&i.network.protocol==="ADIIOT"){const c=_k(this,t,i);c.length&&kk(this,c);return}const u=this.getEventData(i.list,t);t.deviceId&&(u.deviceId=t.deviceId),t.formId&&t.formData&&Object.assign(u,t.formData),this.sendDataToNetWork(u,t,i);return}const s=ht(i.value);if(s&&typeof s=="object"&&i.targetType==="id"){const u=i.params?this.findOne(i.params):t;for(let c in s)if(s[c]===void 0||s[c]==="")s[c]=u[c];else if(typeof s[c]=="string"&&((r=s[c])==null?void 0:r.indexOf("${"))>-1){let f=(l=s[c].match(/\$\{([^}]+)\}/g))==null?void 0:l.map(g=>g.slice(2,-1));f!=null&&f.length&&(s[c]=(o=u[f[0]])!=null?o:this.getDynamicParam(f[0]))}u.deviceId&&(s.deviceId=u.deviceId),this.sendDataToNetWork(s,t,i);return}},this.events[he.PostMessage]=(t,i)=>{if(typeof i.value!="string"){console.warn("[meta2d] Emit value must be a string");return}const s=i.params?this.findOne(i.params):t;if(s.name!=="iframe"||!s.iframe){console.warn("\u4E0D\u662F\u5D4C\u5165\u9875\u9762");return}let n=bn(s.iframe.split("?")[1]);const a=this.getEventData(i.list,s);s.calculative.singleton.div.children[0].contentWindow.postMessage(JSON.stringify({name:i.value,id:n.id,data:a}),"*")},this.events[he.PostMessageToParent]=(t,i)=>{if(typeof i.value!="string"){console.warn("[meta2d] Emit value must be a string");return}const s=this.getEventData(i.list,t);window.parent.postMessage(JSON.stringify({name:i.value,data:s}),"*")},this.events[he.Message]=(t,i)=>{this.message({theme:i.params,content:i.value,...i.extend})}}getSendData(t){const i={};return t.forEach(s=>{var n;if(s.prop)if(s.id&&s.id!=="\u56FA\u5B9A\u503C"){const a=this.findOne(s.id);i[s.prop]=a[s.key]}else if(typeof s.value=="string"&&s.value.includes("${")){let a=s.value,r=(n=a.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(l=>l.slice(2,-1));r&&r.forEach(l=>{a=a.replace(`\${${l}}`,this.getDynamicParam(l))}),i[s.prop]=a}else i[s.prop]=this.convertType(s.value,s.type)}),i}convertType(t,i){if(typeof t=="string"){if(["switch","bool","boolean"].includes(i)){if(t==="false")return!1;if(t==="true")return!0}else if(["integer","number","int","enum","double","float"].includes(i)&&!isNaN(Number(t)))return Number(t)}return t}getEventData(t,i){const s={};return t!=null&&t.length&&t.forEach(n=>{var r,l,o;const a=n.params?this.findOne(n.params):i;for(let u in n.value)if(n.value[u]===void 0||n.value[u]==="")s[u]=a[u];else if(typeof n.value[u]=="string"&&((r=n.value[u])==null?void 0:r.indexOf("${"))>-1){let c=(l=n.value[u].match(/\$\{([^}]+)\}/g))==null?void 0:l.map(f=>f.slice(2,-1));c!=null&&c.length&&(s[u]=(o=a[c[0]])!=null?o:this.getDynamicParam(c[0]))}else s[u]=n.value[u]}),Object.keys(s).length?s:{}}message(t){new pk(this.canvas.parentElement,t).init()}closeAll(){for(let t in Je)Je[t].close()}async navigatorTo(t){var n;if(!t)return;if((n=bn())==null?void 0:n.id){const a=new URL(window.location);a.searchParams.set("id",t),history.pushState({},"",a)}const s=await $d(this.store,t);s&&(this.open(s),this.lock(1),this.fitView(!0,10))}doSendDataEvent(t,i){let s=JSON.stringify(t);this.mqttClient&&this.mqttClient.connected&&(i?i.split(",").forEach(n=>{this.mqttClient.publish(n,s)}):this.store.data.mqttTopics&&this.store.data.mqttTopics.split(",").forEach(n=>{this.mqttClient.publish(n,s)})),this.websocket&&this.websocket.readyState===1&&this.websocket.send(s),(this.store.data.https||this.store.data.http)&&this.sendDatabyHttp(s),this.store.emitter.emit("sendData",s)}async sendDataToNetWork(t,i,s){var a,r,l,o,u,c;const n=ht(s.network);if(n.data&&(Object.assign(n,n.data),delete n.data),n.protocol==="iot"){this.iotMqttClient&&this.iotMqttClient.publish(`le5le-iot/property/set/${(a=this.store.data.iot)==null?void 0:a.token}`,JSON.stringify(t));return}if(!!n.url){if(n.protocol==="http"){if(typeof n.headers=="object"){let y=JSON.stringify(n.headers),w=(r=y.match(/\$\{([^}]+)\}/g))==null?void 0:r.map(m=>m.slice(2,-1));if(w!=null&&w.length)for(let m=0;my+"="+t[y]).join("&")),n.method==="POST"&&g.indexOf("${")>-1){let y=(l=g.match(/\$\{([^}]+)\}/g))==null?void 0:l.map(w=>w.slice(2,-1));y&&y.forEach(w=>{g=g.replace(`\${${w}}`,ms(i,w)||this.getDynamicParam(w))})}const v=await fetch(g+(f||""),{headers:n.headers||{},method:n.method,body:n.method==="POST"?JSON.stringify(t):void 0});if(v.ok){if(s.callback){const y=await v.text();if(!s.fn)try{if(typeof s.callback!="string")throw new Error("[meta2d] Function callback must be string");const w=s.callback;s.fn=new Function("pen","data","context",w)}catch(w){console.error("[meta2d]: Error on make a function:",w)}(o=s.fn)==null||o.call(s,i,y,{meta2d:this,e:s})}console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F")}}else if(n.protocol==="mqtt"){const f=(u=this.mqttClients)==null?void 0:u.filter(g=>g.options.href===n.url);if(f&&f.length)f[0].connected&&n.topics.split(",").forEach(g=>{f[0].publish(g,JSON.stringify(t))});else{let g=ia.exports.connect(n.url,n.options);g.on("connect",()=>{console.info("mqtt\u8FDE\u63A5\u6210\u529F"),n.topics.split(",").forEach(v=>{g.publish(v,JSON.stringify(t)),setTimeout(()=>{g==null||g.end()},1e3)})})}}else if(n.protocol==="websocket"){const f=(c=this.websockets)==null?void 0:c.filter(g=>g.url===n.url);if(f&&f.length)f[0].readyState===1&&f[0].send(JSON.stringify(t));else{let g=new WebSocket(n.url,n.protocols||void 0);g.onopen=function(){console.info("websocket\u8FDE\u63A5\u6210\u529F"),g.send(JSON.stringify(t)),setTimeout(()=>{g.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,s=!0,n=!1){return await this.canvas.addPen(t,i,s,n)}async addPens(t,i,s=!1){return await this.canvas.addPens(t,i,s)}render(t){var i;(i=this.canvas)==null||i.render(t)}async setBackgroundImage(t,i){var l,o,u,c;let s=this;async function n(f){return new Promise(g=>{const v=new Image;v.src=f,s.store.options.cdn&&!(f.startsWith("http")||f.startsWith("//")||f.startsWith("data:image"))&&(v.src=s.store.options.cdn+f),v.crossOrigin="anonymous",v.onload=()=>{g(v)}})}this.store.data.bkImage=t;const a=(i==null?void 0:i.width)||((l=this.store.data)==null?void 0:l.width)||((o=this.store.options)==null?void 0:o.width),r=(i==null?void 0:i.height)||((u=this.store.data)==null?void 0:u.height)||((c=this.store.options)==null?void 0:c.height);if(a&&r?(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 f=await n(t);this.store.bkImg=f,a&&r&&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:s=this.store.data.gridSize,gridRotate:n=this.store.data.gridRotate}={}){this.store.data.grid=t,this.store.data.gridColor=i,this.store.data.gridSize=s<0?0:s,this.store.data.gridRotate=n,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){t.theme&&this.setTheme(t.theme),this.setBackgroundImage(t.bkImage,t),Object.assign(this.store.data,t),this.store.data.pens=[];for(const s of t.pens)s.id||(s.id=It()),!s.calculative&&(s.calculative={canvas:this.canvas}),this.store.pens[s.id]=s;for(const s of t.pens)this.canvas.makePen(s)}if(this.canvas.patchFlagsLines.forEach(s=>{s.type&&this.canvas.initLineRect(s)}),this.store.data.template||(this.store.data.template=It()),i||(this.canvas.opening=!0),this.doInitJS(),this.initBindDatas(),this.initBinds(),this.doInitFn(),this.loadLineAnimateDraws(),this.initMessageEvents(),this.initGlobalTriggers(),this.startAnimate(),this.startVideo(),this.listenSocket(),this.connectSocket(),this.connectNetwork(),this.startDataMock(),this.canvas.initGlobalStyle(),this.render(),setTimeout(()=>{const s=this.store.data.pens.find(n=>n.autofocus);s&&this.focus(s.id)},100),this.store.data.iconUrls)for(const s of this.store.data.iconUrls)jx(s,()=>{this.render()});this.canvas.autoPolylineFlag=!1,this.store.emitter.emit("opened"),this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.init()}dirtyData(t){const i=this.store.data.pens,s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height,a=[];for(let r=i.length-1;r>=0;r--){let l=i[r];if(l.parentId){const o=this.store.pens[l.parentId];(l.x>10||l.y>10||l.width>10||l.height>10||!o.children||!o.children.includes(l.id))&&a.push(l)}if(s&&n){let o=this.getPenRect(l);(o.x<-10||o.y<-10||o.x+o.width>s||o.y+o.height>n)&&a.push(l)}}return(!s||!n)&&M_(i).forEach(l=>{a.filter(u=>u.id===l.id).length||a.push(l)}),t&&this.active(a),a}clearDirtyData(){let t=this.dirtyData();this.delete(t,!0)}cacheData(t){if(t&&this.store.options.cacheLength){let i=this.store.cacheDatas.findIndex(s=>s.data&&s.data._id===t);if(i===-1)this.store.cacheDatas.push({data:ht(this.store.data,!0)}),this.store.cacheDatas.length>this.store.options.cacheLength&&this.store.cacheDatas.shift();else{let s=this.store.cacheDatas.splice(i,1)[0];this.store.cacheDatas.push(s)}}}loadCacheData(t){let i=this.store.cacheDatas.findIndex(s=>s.data&&s.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(s=>{s.calculative.canvas=this.canvas,this.store.pens[s.id]=s,kt.path2dDraws[s.name]&&this.store.path2dMap.set(s,kt.path2dDraws[s.name](s)),s.type&&this.store.path2dMap.set(s,kt.path2dDraws[s.name](s)),s.image&&(s.calculative.imageDrawed=!1,this.canvas.loadImage(s))}),this.render())}loadLineAnimateDraws(){kt.lineAnimateDraws={},Object.entries(this.store.data.lineAnimateDraws).forEach(([t,i])=>{kt.lineAnimateDraws[t]=new Function("ctx","pen","state","index",i)})}statistics(){const t=this.store.data.pens.length,i=this.store.data.pens.filter(l=>l.image).length,s=this.store.data.pens.filter(l=>l.image&&l.calculative.inView).length,n=this.store.data.pens.filter(l=>l.name.endsWith("Dom")||Od.includes(l.name)||this.store.options.domShapes.includes(l.name)||l.externElement).length,a=this.store.animates.size;let r=0;return Object.keys(this.store.bind).forEach(l=>{r+=this.store.bind[l].length}),Object.keys(this.store.bindDatas).forEach(l=>{r+=this.store.bindDatas[l].length}),{\u56FE\u5143\u603B\u6570\u91CF:t,\u56FE\u7247\u56FE\u5143\u6570\u91CF:i,\u56FE\u7247\u56FE\u5143\u7ED8\u5236\u6570\u91CF:s,dom\u56FE\u5143\u6570\u91CF:n,\u6B63\u5728\u6267\u884C\u7684\u52A8\u753B\u6570\u91CF:a,\u6570\u636E\u70B9\u6570\u91CF:r}}initBindDatas(){this.store.bindDatas={},this.store.data.pens.forEach(t=>{var i;(i=t.form)==null||i.forEach(s=>{let n;s.dataIds&&(Array.isArray(s.dataIds)?n=s.dataIds:n=[s.dataIds]),n==null||n.forEach(a=>{this.store.bindDatas[a.dataId]||(this.store.bindDatas[a.dataId]=[]),this.store.bindDatas[a.dataId].push({id:t.id,formItem:s})})})})}initBinds(){this.jetLinksList=[],this.store.bind={};const t=[],i=[];this.store.data.pens.forEach(s=>{var n,a;(n=s.realTimes)==null||n.forEach(r=>{if(r.bind&&r.bind.id){let l=r.productId||s.productId,o=r.deviceId||s.deviceId,u=r.propertyId,c=!1;if(l&&l.indexOf("${")>-1){let f=l.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(l=this.getDynamicParam(f[0])||l),c=!0}if(o&&o.indexOf("${")>-1){let f=o.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(o=this.getDynamicParam(f[0])||o),c=!0}if(u&&u.indexOf("${")>-1){let f=u.match(new RegExp("(?<=\\$\\{).*?(?=\\})","g"));f!=null&&f.length&&(u=this.getDynamicParam(f[0])||u),c=!0}if(c&&r.bind&&(r.bind.id=l+"#"+o+"#"+u),this.store.bind[r.bind.id]||(this.store.bind[r.bind.id]=[]),this.store.bind[r.bind.id].push({id:s.id,key:r.key}),l&&o&&u){const f=this.jetLinksList.findIndex(g=>g.topic.startsWith(`/${l}/${o}`));f>-1?this.jetLinksList[f].properties.includes(r.propertyId)||this.jetLinksList[f].properties.push(r.propertyId):this.jetLinksList.push({topic:`/${l}/${o}`,deviceId:o,properties:[r.propertyId]})}if(r.bind.class==="iot"){let f=r.bind.id.split("#"),g=t.findIndex(y=>y.deviceId===f[0]);g>-1?t[g].properties.includes(f[1])||t[g].properties.push(f[1]):t.push({deviceId:f[0],properties:[f[1]],token:r.bind.token}),i.findIndex(y=>y.key===r.bind.id)===-1&&i.push({key:r.bind.id,label:r.bind.label})}else if(r.bind.class==="sql"){let f=r.bind.id.split("#");const g=this.store.data.sqls.find(v=>v.bindId===f[0]);if(g){g.keys||(g.keys=[]),f.shift();const v=f.join("#");g.keys.includes(v)||g.keys.push(v)}}}}),(a=s.events)==null||a.forEach(r=>{var o;const l=(o=r.actions)==null?void 0:o.filter(u=>u.action===he.SendData);l==null||l.forEach(u=>{var c;(c=u.data)==null||c.forEach(f=>{if(f.class==="iot"){let g=f.prop.split("#"),v=t.findIndex(y=>y.deviceId===g[0]);v>-1?t[v].properties.includes(g[1])||t[v].properties.push(g[1]):t.push({deviceId:g[0],properties:[g[1]],token:f.token})}})})})}),t.length&&(this.store.data.iot||(this.store.data.iot={}),this.store.data.iot.devices=t),i.length&&(this.store.data.iot.list=i)}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=bn(),i=[];for(let s in t)t.hasOwnProperty(s)&&s.startsWith("bind-")&&i.push({id:s.replace("bind-",""),dataId:s.replace("bind-",""),value:t[s]});i.length&&this.setDatas(i,{history:!1})}drawLine(t){t&&wg(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 s;i.externElement===!0&&(s=i.calculative.singleton)!=null&&s.div&&Re(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 s=le(t),n=$t(t);s.prev=void 0,s.next=void 0,n.prev=void 0,n.next=void 0,t.calculative.worldAnchors=[s,n],t.calculative.activeAnchor=s,this.canvas[i](this.store,t,n),t.lineName==="curve"&&(s.prev={penId:s.penId,x:s.x-50,y:s.y},s.next={penId:s.penId,x:s.x+50,y:s.y},n.prev={penId:n.penId,x:n.x-50,y:n.y},n.next={penId:n.penId,x:n.x+50,y:n.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 s;for(const n of this.store.data.pens)(s=n.onDestroy)==null||s.call(n,n);Nx(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}updateLineAnimateDraws(t,i){!i||(delete this.store.data.lineAnimateDraws[t],delete kt.lineAnimateDraws[t],i!==-1&&this.registerLineAnimateDraws(i.name||t,i.code))}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,s=!0){this.canvas.setPenRect(t,i,s)}startAnimate(t,i){this.stopAnimate(t);let s;t?typeof t=="string"?s=this.find(t):s=t:s=this.store.data.pens.filter(n=>(n.type||n.frames)&&n.autoPlay||n.animations&&n.animations.length&&n.animations.findIndex(a=>a.autoPlay)!==-1),s.length&&(s.forEach(n=>{var a,r;if(n.calculative.pause){const l=Date.now()-n.calculative.pause;n.calculative.pause=void 0,n.calculative.frameStart+=l,n.calculative.frameEnd+=l}else{let l=-1;if(i!==void 0&&n.animations){if(typeof i=="string"){if(l=n.animations.findIndex(o=>o.name===i),l===-1)return}else if(typeof i=="number")if(n.animations.length>i)l=i;else return}else i===void 0&&(l=(a=n.animations)==null?void 0:a.findIndex(o=>o.autoPlay),l===-1&&((r=n.animations)==null?void 0:r.length)&&(l=0));if(l!==-1&&l!==void 0){const o=ht(n.animations[l]);o.animateName=o.name,delete o.name,o.currentAnimation=l,!n.type&&o.frames&&(o.showDuration=this.calcAnimateDuration(o)),this.setValue({id:n.id,...o},{doEvent:!1,history:!1})}this.store.animates.add(n),n.type||this.store.animateMap.set(n,n.calculative.canvas.getFrameProps(n))}}),this.initImageCanvas(s),this.canvas.animate())}pauseAnimate(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:this.store.animates.forEach(s=>{i.push(s)}),i.forEach(s=>{s.calculative.pause||(s.calculative.pause=Date.now())})}stopAnimate(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:this.store.animates.forEach(s=>{i.push(s)}),i.forEach(s=>{s.currentAnimation=void 0,s.calculative.pause=void 0,s.calculative.start=void 0,s.calculative.cycleStart=void 0,s.calculative.duration=void 0,s.calculative.animatePos=0,this.store.animates.delete(s),this.canvas.restoreNodeAnimate(s),this.canvas.updateLines(s),this.store.animateMap.delete(s)}),this.initImageCanvas(i),setTimeout(()=>{var s;(s=this.canvas)==null||s.calcActiveRect(),this.render()},20)}startVideo(t){let i;t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(s=>(s.video||s.audio)&&s.autoPlay),i.forEach(s=>{var n,a;(n=s.calculative.media)==null||n.play(),(a=s.onStartVideo)==null||a.call(s,s)})}pauseVideo(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(s=>(s.video||s.audio)&&s.autoPlay),i.forEach(s=>{var n,a;(n=s.calculative.media)==null||n.pause(),(a=s.onPauseVideo)==null||a.call(s,s)})}stopVideo(t){let i=[];t?typeof t=="string"?i=this.find(t):i=t:i=this.store.data.pens.filter(s=>(s.video||s.audio)&&s.autoPlay),i.forEach(s=>{var n;s.calculative.media&&(s.calculative.media.currentTime=0,s.calculative.media.pause()),(n=s.onStopVideo)==null||n.call(s,s)})}calcAnimateDuration(t){return t.frames.reduce((i,s)=>i+s.duration,0)}combine(t=this.store.active,i,s=!0){if(!t||!t.length)return;const n=ht(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:ht(t,!0)}),this.render();return}const a=hi(t);let r={id:It(),name:"combine",...a,children:[],showChild:i};this.canvas.makePen(r);const l=ht(r);let o=1/0;return t.forEach(u=>{var g;const c=this.store.data.pens.findIndex(v=>v.id===u.id);if(c{Yi(u,!0)}),this.initImageCanvas([r])),this.store.emitter.emit("combine",[r]),this.render(),r}uncombine(t){if(!t&&this.store.active&&(t=this.store.active[0]),!t||!t.children)return;const i=t.children.map(a=>this.store.pens[a]);let s=ht(i);i.forEach(a=>{a.parentId=void 0,a.x=a.calculative.worldRect.x,a.y=a.calculative.worldRect.y,a.width=a.calculative.worldRect.width,a.height=a.calculative.worldRect.height,a.locked=Ot.None,a.calculative.active=void 0,a.calculative.hover=!1,this.setVisible(a,!0)});const n=this.isCombine(t)?3:2;this.pushHistory({type:bt.Update,initPens:s,pens:i,step:n}),s=[ht(t)],t.children=void 0,this.pushHistory({type:bt.Update,initPens:s,pens:[t],step:n}),this.isCombine(t)&&(this.delete([t]),this.store.histories[this.store.histories.length-1].step=n),this.inactive()}clearCombine(t){if(!t&&this.store.active&&(t=this.store.active[0]),!t||!t.children)return;const i=Qe(t,this.store);i.forEach(n=>{n.parentId=void 0,n.x=n.calculative.worldRect.x,n.y=n.calculative.worldRect.y,n.width=n.calculative.worldRect.width,n.height=n.calculative.worldRect.height,n.locked=Ot.None,n.calculative.active=void 0,n.calculative.hover=!1,n.showChild!==void 0&&this.setVisible(n,!0),n.children=void 0});const s=[];i.forEach((n,a)=>{n.name==="combine"&&(n.children=void 0,s.push(n))}),this.delete(s,!0,!1),t.children=void 0,this.isCombine(t)&&this.delete([t],!0,!1),this.inactive()}appendChild(t=this.store.active){if(!t||t.length<2)return;const i=t.findIndex(s=>s.name==="combine"&&s.showChild!==void 0);if(i!==-1){let s=t[i];const n=hi(t);Object.assign(s,n),Object.assign(s.calculative.worldRect,n),An(s),s.children.forEach(a=>{const r=this.store.pens[a],l=fs(r.calculative.worldRect,n);Object.assign(r,l)}),t.forEach(a=>{var r;if(a.id!==s.id){s.children.push(a.id),a.parentId=s.id;const l=fs(a.calculative.worldRect,n);Object.assign(a,l),a.locked=(r=a.lockedOnCombine)!=null?r:Ot.DisableMove,a.locked=a.interaction||Cl.includes(a.name)?0:a.locked,Yi(a,!0)}}),this.initImageCanvas(t),this.render()}else console.warn("Invalid operation!")}updateRectbyChild(t,i,s){if(re(t),Qt(t),i.calculative.worldRect=t,s.container&&Xi(t,s.calculative.worldRect,!0)){const n=fs(t,s.calculative.worldRect);Object.assign(i,n)}else{if(s.container){let n=Math.min(t.x,s.calculative.worldRect.x),a=Math.min(t.y,s.calculative.worldRect.y),r=Math.max(t.ex,s.calculative.worldRect.ex),l=Math.max(t.ey,s.calculative.worldRect.ey);s.calculative.worldRect={x:n,y:a,width:r-n,height:l-a,ex:r,ey:l},Qt(s.calculative.worldRect)}else{const n=s.children.map(a=>this.store.pens[a]);s.calculative.worldRect=hi(n)}s.parentId||Object.assign(s,s.calculative.worldRect),s.children.forEach(n=>{const a=this.store.pens[n],r=fs(a.calculative.worldRect,s.calculative.worldRect);Object.assign(a,r)}),s.parentId&&this.updateRectbyChild(s.calculative.worldRect,s,this.store.pens[s.parentId])}this.canvas.updatePenRect(s),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,s=!0){this.canvas.delete(t,i,s)}scale(t,i={x:0,y:0}){this.canvas.scale(t,i)}translate(t,i){this.canvas.translate(t,i)}translatePens(t,i,s){this.canvas.translatePens(t,i,s)}getParent(t,i){return ti(t,i)}getAllChildren(t){return Qe(t,this.store)}getAllFollowers(t){return yc(t,this.store)}data(){const t=ht(this.store.data),{pens:i,paths:s}=this.store.data;t.version=Nd.version,t.paths={};for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&i.find(a=>a.pathId===n)&&(t.paths[n]=s[n]);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:s,password:n}=i;s&&n||!s&&!n?(this.mqttClient=ia.exports.connect(this.store.data.mqtt,i),this.mqttClient.on("message",(a,r)=>{this.socketCallback(r.toString(),{topic:a,type:"mqtt",url:this.store.data.mqtt})}),this.mqttClient.on("error",a=>{this.store.emitter.emit("error",{type:"mqtt",error:a})}),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,s)=>{i.http&&i.httpTimeInterval!==0&&(i.times=0,this.httpTimerList[s]=setInterval(async()=>{this.oldRequestHttp(i),this.store.options.reconnetTimes&&i.times>=this.store.options.reconnetTimes&&(i.times=0,clearInterval(this.httpTimerList[s]),this.httpTimerList[s]=void 0)},i.httpTimeInterval||1e3))});else{const{http:i,httpTimeInterval:s,httpHeaders:n}=this.store.data;i&&(this.httpTimer=setInterval(async()=>{const a=await fetch(i,{headers:n});if(a.ok){const r=await a.text();this.socketCallback(r,{type:"http",url:i})}},s||1e3))}}async oldRequestHttp(t){let i=ht(t);if(i.http){const s=await fetch(i.http,{headers:i.httpHeaders,method:i.method||"GET",body:i.method==="POST"?JSON.stringify(i.body):void 0});if(s.ok){const n=await s.text();this.socketCallback(n,{type:"http",url:i.http})}else t.times++,this.store.emitter.emit("error",{type:"http",error:s})}}async sendDatabyHttp(t){const{https:i}=this.store.data;if(i)i.forEach(async s=>{s.http&&(await fetch(s.http,{method:"post",body:t,headers:s.httpHeaders})).ok&&console.info("http\u6D88\u606F\u53D1\u9001\u6210\u529F")});else{const{http:s,httpHeaders:n}=this.store.data;s&&(await fetch(s,{method:"post",body:t,headers:n})).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 s=0,n=0,a=0,r=0;this.mqttClients=[],this.websockets=[],this.eventSources=[],t.forEach(async l=>{l.protocol==="mqtt"?(l.index=s,this.connectNetMqtt(l),s+=1):l.protocol==="websocket"?(l.index=a,this.connectNetWebSocket(l),a+=1):l.protocol==="http"?(l.index=n,i.push({url:l.url,interval:l.interval,headers:l.headers||void 0,method:l.method,body:l.body,enable:l.enable,index:l.index,once:l.once}),n+=1):l.protocol==="ADIIOT"?wk(this,l):l.protocol==="SSE"&&(l.index=r,this.connectSSE(l),r+=1)})}this.onNetworkConnect(i),this.connectIot(),this.connectSqls()}reconnectNetwork(t){var s,n;const i=this.store.data.networks[t];if(i.protocol==="mqtt")this.mqttClients&&((s=this.mqttClients[i.index])==null||s.end()),this.connectNetMqtt(i);else if(i.protocol==="websocket")this.websockets&&this.websockets[i.index]&&(this.websockets[i.index].onclose=void 0,this.websockets[i.index].close(),this.websockets[i.index]=void 0),this.connectNetWebSocket(i);else if(i.protocol==="http"){this.updateTimerList&&(clearInterval(this.updateTimerList[i.index]),this.updateTimerList[i.index]=void 0);const a=ht(i);this.store.data.cancelFirstConnect||this.requestHttp(a),this.updateTimerList[i.index]=setInterval(async()=>{this.requestHttp(a)},a.interval||1e3)}else i.protocol==="SSE"&&(this.eventSources&&((n=this.eventSources[i.index])==null||n.close(),this.eventSources[i.index]=void 0),this.connectSSE(i))}async connectIot(){var n;const{iot:t}=this.store.data;if(!(t&&((n=t==null?void 0:t.devices)==null?void 0:n.length))||t&&t.enable===!1)return;const i=globalThis.iotUrl||await this.getMqttUrl();if(!i){console.warn("iot Request address error");return}const s=await this.getIotToken(t.devices,t.protocol==="websocket"?1:void 0);t.token=s,this.iotMqttClient=ia.exports.connect(i),this.iotMqttClient.on("message",(a,r)=>{this.socketCallback(r.toString(),{topic:`le5le-iot/properties/${s}`,type:"iot",url:i,method:"mqtt"})}),this.iotMqttClient.on("error",a=>{this.store.emitter.emit("error",{type:"mqtt",error:a})}),this.iotMqttClient.subscribe(`le5le-iot/properties/${s}`),this.iotTimer=setInterval(()=>{this.iotMqttClient&&this.iotMqttClient.publish("le5le-iot/subscribe/ping",s)},3e5)}closeIot(){if(this.iotMqttClient){const{iot:t}=this.store.data;t!=null&&t.token&&this.unsubscribeIot(t.token),this.iotMqttClient.end(),this.iotMqttClient=void 0}clearInterval(this.iotTimer),this.iotTimer=void 0}connectSqls(){const{sqls:t}=this.store.data;t&&t.length&&t.forEach(async(i,s)=>{i.enable!==!1&&(await this.doSqlCode(i),i.interval&&(i.index=s,this.sqlTimerList[s]=setInterval(async()=>{await this.doSqlCode(i)},i.interval)))})}connectSSE(t){t.enable!==!1&&(this.eventSources[t.index]=new EventSource(t.url,{withCredentials:t.withCredentials}),this.eventSources[t.index].onmessage=i=>{this.socketCallback(i.data,{type:"SSE",url:t.url,name:t.name,net:t})},this.eventSources[t.index].onerror=i=>{this.store.emitter.emit("error",{type:"SSE",error:i})})}closeSSE(){this.eventSources&&this.eventSources.forEach(t=>{t&&(t.close(),t=void 0)})}connectNetMqtt(t){var n,a,r,l;if(t.enable===!1)return;t.options.clientId&&!t.options.customClientId&&(t.options.clientId=It());let i=t.url;if(i.indexOf("${")>-1){let o=(n=i.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(u=>u.slice(2,-1));o&&o.forEach(u=>{i=i.replace(`\${${u}}`,this.getDynamicParam(u))})}t.times=0;let s=ht(t.options);if((s==null?void 0:s.username)&&s.username.includes("${")){let o=(a=s.username.match(/\$\{([^}]+)\}/g))==null?void 0:a.map(u=>u.slice(2,-1));o&&o.forEach(u=>{s.username=s.username.replace(`\${${u}}`,this.getDynamicParam(u))})}if((s==null?void 0:s.password)&&s.password.includes("${")){let o=(r=s.password.match(/\$\{([^}]+)\}/g))==null?void 0:r.map(u=>u.slice(2,-1));o&&o.forEach(u=>{s.password=s.password.replace(`\${${u}}`,this.getDynamicParam(u))})}if(this.mqttClients[t.index]=ia.exports.connect(i,s),this.mqttClients[t.index].on("message",(o,u)=>{this.socketCallback(u.toString(),{topic:o,type:"mqtt",url:t.url,name:t.name,net:t})}),this.mqttClients[t.index].on("error",o=>{this.store.emitter.emit("error",{type:"mqtt",error:o})}),this.mqttClients[t.index].on("close",()=>{var o;this.store.options.reconnetTimes&&(t.times++,t.times>=this.store.options.reconnetTimes&&(t.times=0,this.mqttClients&&((o=this.mqttClients[t.index])==null||o.end())))}),t.topics){let o=t.topics;if(o.indexOf("${")>-1){let u=(l=o.match(/\$\{([^}]+)\}/g))==null?void 0:l.map(c=>c.slice(2,-1));u&&u.forEach(c=>{o=o.replace(`\${${c}}`,this.getDynamicParam(c))})}this.mqttClients[t.index].subscribe(o.split(","))}}connectNetWebSocket(t){var s,n;if(this.websockets[t.index]&&(this.websockets[t.index].onclose=void 0,(s=this.websockets[t.index])==null||s.close(),this.websockets[t.index]=void 0),t.enable===!1)return;let i=t.url;if(i.indexOf("${")>-1){let a=(n=i.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(r=>r.slice(2,-1));a&&a.forEach(r=>{i=i.replace(`\${${r}}`,this.getDynamicParam(r))})}this.websockets[t.index]=new WebSocket(i,t.protocols||void 0),this.websockets[t.index].onmessage=a=>{this.socketCallback(a.data,{type:"websocket",url:t.url,name:t.name,net:t})},this.websockets[t.index].onerror=a=>{this.store.emitter.emit("error",{type:"websocket",error:a})},this.websockets[t.index].onclose=()=>{var a;if(this.store.options.reconnetTimes&&(t.times++,t.times>=this.store.options.reconnetTimes)){t.times=0,this.websockets[t.index].onclose=void 0,(a=this.websockets[t.index])==null||a.close(),this.websockets[t.index]=void 0;return}setTimeout(()=>{console.info("Canvas websocket closed and reconneting..."),this.connectNetWebSocket(t)},2e3)}}async getMqttUrl(){const t=await fetch("/api/iot/app/mqtt",{method:"GET",headers:{Authorization:`Bearer ${Ir()}`}});if(t.ok){const i=await t.text();let s=JSON.parse(i);return s.wssPort||s.wsPort?`${location.protocol==="https:"?"wss":"ws"}://${s.host}:${location.protocol==="https:"?s.wssPort:s.wsPort}${s.path}`:void 0}}async getIotToken(t,i){const s=await fetch("/api/iot/subscribe/properties",{method:"POST",headers:{Authorization:`Bearer ${Ir()}`},body:JSON.stringify({devices:t,type:i})});if(s.ok){const n=await s.text();return JSON.parse(n).token}}async unsubscribeIot(t){return await fetch("/api/iot/unsubscribe/properties",{method:"POST",headers:{Authorization:`Bearer ${Ir()}`},body:JSON.stringify({token:t})})}async doSqlCode(t){var a;const i=t.method||"get";let s=t.sql;i==="list"&&(t.dbType==="oracle"?s.includes("OFFSET")||(s+=` OFFSET ${(t.current||1-1)*(t.pageSize||20)} ROWS FETCH NEXT ${t.pageSize||20} ROWS ONLY`):s.includes("LIMIT")||(s+=` LIMIT ${t.pageSize||20}`+(t.current>1?" OFFSET "+(t.current-1)*(t.pageSize||20):"")));const n=await fetch(`/api/iot/data/sql/${i}`,{method:"POST",headers:{Authorization:`Bearer ${ga("token")||localStorage.getItem("token")||new URLSearchParams(location.search).get("token")||""}`},body:JSON.stringify({dbId:t.dbId||t.dbid,sql:s})});if(n.ok){let r=await n.text();if(r){const l=[];if(r=JSON.parse(r),r.error){this.store.emitter.emit("error",{type:"sql",error:r.error});return}(a=t.keys)==null||a.forEach(o=>{l.push({id:t.bindId+"#"+o,value:ms(r,o.split("#").join("."))})}),l.push({id:t.bindId,value:r}),this.socketCallback(JSON.stringify(l),{type:"sql",url:`/api/iot/data/sql/${i}`,method:i})}}}randomString(t){t=t||32;let i="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",s=i.length,n="";for(let a=0;a{let a=this.mockValue(n);a!==void 0&&t.push({id:n.id,value:a})}),t.length&&this.setDatas(t,{render:!0,doEvent:!0,history:!1})}networkMock(){if(this.store.data.networks&&this.store.data.networks.length){let t=[];this.store.data.networks.forEach(i=>{var s;i.enable===!1&&((s=i.children)==null||s.forEach(n=>{let a=ht(n);a.enableMock=!0;let r=this.mockValue(a);r!==void 0&&t.push({id:n.id,value:r})}))}),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.networkMock(),this.render()},this.store.data.networkInterval||1e3)):this.stopDataMock()}stopDataMock(){clearInterval(this.updateTimer),this.updateTimer=void 0}penMock(t){var i;if(t.realTimes){let s={};if(t.realTimes.forEach(n=>{let a=this.mockValue(n);a!==void 0&&(s[n.key]=a)}),Object.keys(s).length){let n=t.onBeforeValue?t.onBeforeValue(t,s):s;this.canvas.updateValue(t,n),(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]}getDynamicParam(t){return bn()[t]||localStorage[t]||ga(t)||globalThis[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=>{i.enable!==!1&&this.requestHttp(i)}),t.forEach((i,s)=>{i.times=0,i.interval!==0&&i.enable!==!1&&(i.once?setTimeout(async()=>{this.requestHttp(i)},i.interval||1e3):this.updateTimerList[s]=setInterval(async()=>{this.requestHttp(i),this.store.options.reconnetTimes&&i.times>=this.store.options.reconnetTimes&&(i.times=0,clearInterval(this.updateTimerList[s]),this.updateTimerList[s]=void 0)},i.interval||1e3))})}}async requestHttp(t){var s,n,a;let i=ht(t);if(i.url){if(i.url.indexOf("${")>-1){let l=(s=i.url.match(/\$\{([^}]+)\}/g))==null?void 0:s.map(o=>o.slice(2,-1));l&&l.forEach(o=>{i.url=i.url.replace(`\${${o}}`,this.getDynamicParam(o))})}if(typeof i.headers=="object"){let l=JSON.stringify(i.headers),o=(n=l.match(/\$\{([^}]+)\}/g))==null?void 0:n.map(u=>u.slice(2,-1));if(o!=null&&o.length)for(let u=0;uu.slice(2,-1));if(o!=null&&o.length)for(let u=0;uu.protocol==="http")[i.index];this.socketCallback(l,{type:"http",url:i.url,name:i.name,net:o})}else t.times++,this.store.emitter.emit("error",{type:"http",error:r})}}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}),this.closeIot(),xk(this),this.closeSSE()}socketCallback(t,i){var a,r;this.store.emitter.emit("socket",{message:t,context:i});let s=t;if((a=i.net)!=null&&a.socketCbJs&&((r=i.net)!=null&&r.socketFn||(i.net.socketFn=new Function("e","context",i.net.socketCbJs)),i.net.socketFn)){if(s=i.net.socketFn(t,{meta2d:this,type:i.type,topic:i.topic,url:i.url,method:i.method}),!s)return;s&&s!==!0&&(t=s)}if(this.socketFn&&(s=this.socketFn(t,{meta2d:this,type:i.type,topic:i.topic,url:i.url,method:i.method}),!s))return;s===!0&&(s=t);let n;if(s.constructor===Object||s.constructor===Array)n=s;else if(typeof s=="string")try{n=JSON.parse(s)}catch(l){console.warn("Invalid socket data:",n,l)}else return;!n||(Array.isArray(n)||(n=[n]),n.length&&(n[0].dataId?this.setDatas(n):n.forEach(l=>{this.setValue(l)})))}setDatas(t,{render:i=!0,doEvent:s=!0,history:n}={}){const a=new Map;t.forEach(o=>{var u,c;(u=this.store.bindDatas[o.dataId])==null||u.forEach(f=>{const g=this.store.pens[f.id];if(!g)return;let v=a.get(g);if(!g.noOnBinds&&typeof g.onBinds=="function"){if(v)return;a.set(g,g.onBinds(g,t,f.formItem));return}v?v[f.formItem.key]=o.value:(v={id:f.id,[f.formItem.key]:o.value},a.set(g,v))}),(c=this.store.bind[o.id||o.dataId])==null||c.forEach(f=>{const g=this.store.pens[f.id];if(!g)return;let v=a.get(g);v?v[f.key]=o.value:(v={id:f.id,[f.key]:o.value},a.set(g,v))})}),this.store.data.locked&&this.doDataEvent(t);let r,l;n&&(r=[]),a.forEach((o,u)=>{this.setValue(o,{render:!1,doEvent:s,history:!1}),n&&(r.push(ht(u,!0)),l.push(u))}),i&&this.render(),n&&this.pushHistory({type:bt.Update,initPens:r,pens:l})}setValue(t,{render:i=!0,doEvent:s=!0,history:n}={}){let a=[];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)a=[l];else{let o=this.store.bind[t.id];if(o&&o.length){a=[],this.setDatas([t],{render:i,doEvent:s,history:n});return}}}else if(t.dataId){a=[],this.setDatas([t],{render:i,doEvent:s,history:n});return}else if(t.tag)a=this.find(t.tag);else{let l=[];for(let o in t)l.push({dataId:o,id:o,value:t[o]});l.length&&this.setDatas(l,{render:i,doEvent:s,history:n});return}n=n&&!this.store.data.locked;let r;if(n&&(r=ht(a)),a.forEach(l=>{var u;const o=l.onBeforeValue?l.onBeforeValue(l,t):t;t.frames&&(this.stopAnimate([l]),t.showDuration||(t.showDuration=t.frames.reduce((c,f)=>c+f.duration,0))),xc(l,o),this.canvas.updateValue(l,o),(u=l.onValue)==null||u.call(l,l)}),!this.store.data.locked&&this.store.active.length&&!this.canvas.movingPens&&this.canvas.calcActiveRect(),n){let l=ht(a);this.pushHistory({type:bt.Update,initPens:r,pens:l})}s&&a.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(s=>{let n=!1;s.event.conditions&&s.event.conditions.length?s.event.conditionType==="and"?n=s.event.conditions.every(a=>this.judgeCondition(s.pen,a.key,a)):s.event.conditionType==="or"&&(n=s.event.conditions.some(a=>this.judgeCondition(s.pen,a.key,a))):n=!0,n&&s.event.actions.forEach(a=>{this.events[a.action](s.pen,a,i)})})}initGlobalTriggers(){var t;this.store.globalTriggers={},(t=this.store.data.triggers)==null||t.forEach(i=>{i.conditions.forEach(s=>{s.source&&(this.store.globalTriggers[s.source]||(this.store.globalTriggers[s.source]=[]),this.store.globalTriggers[s.source].includes(i)||this.store.globalTriggers[s.source].push(i))})})}initMessageEvents(){this.store.messageEvents={},this.store.data.pens.forEach(t=>{var i;(i=t.events)==null||i.forEach(s=>{s.name==="message"&&s.message&&(this.store.messageEvents[s.message]||(this.store.messageEvents[s.message]=[]),this.store.messageEvents[s.message].push({pen:t,event:s}))})})}dataJudegeCondition(t,i,s){const{type:n,target:a,fnJs:r,fn:l,operator:o,valueType:u}=s;let c=!1;if(n==="fn"){if(l)c=l(t,{meta2d:this});else if(r){try{s.fn=new Function("data","context",r)}catch(f){console.error("Error: make function:",f)}s.fn&&(c=s.fn(t,{meta2d:this}))}}else{let f=s.value;u==="prop"&&(f=t[s.value]);let g=t[i];switch(o){case">":c=g>+f;break;case">=":c=g>=+f;break;case"<":c=g<+f;break;case"<=":c=g<=+f;break;case"=":case"==":c=g==f;break;case"!=":c=g!=f;break;case"[)":c=fn(+g,f);break;case"![)":c=!fn(+g,f);break;case"[]":c=dn(g,f);break;case"![]":c=!dn(g,f);break}}return c}judgeCondition(t,i,s){const{type:n,target:a,fnJs:r,fn:l,operator:o,valueType:u}=s;let c=!1;if(n==="fn"){if(l)c=l(t,{meta2d:this});else if(r){try{s.fn=new Function("pen","context",r)}catch(f){console.error("Error: make function:",f)}s.fn&&(c=s.fn(t,{meta2d:this}))}}else{let f=s.value;u==="prop"&&(f=this.store.pens[a][s.value]);let g=ms(t,i);switch(["x","y","width","height"].includes(i)&&(g=this.getPenRect(t)[i]),o){case">":c=g>+f;break;case">=":c=g>=+f;break;case"<":c=g<+f;break;case"<=":c=g<=+f;break;case"=":case"==":c=g==f;break;case"!=":c=g!=f;break;case"[)":c=fn(+g,f);break;case"![)":c=!fn(+g,f);break;case"[]":c=dn(g,f);break;case"![]":c=!dn(g,f);break}}return c}pushChildren(t,i){const s=[ht(t,!0)],n=[];t.children||(t.children=[]);const a=[];i.forEach(l=>{var c;let o=ht(l,!0);if((!l.id||!this.store.pens[l.id])&&(this.canvas.makePen(l),o=null),l.parentId){const f=this.store.pens[l.parentId],g=f.children.findIndex(v=>v===l.id);s.push(ht(f,!0)),f.children.splice(g,1),a.push(ht(f,!0))}t.children.push(l.id),l.parentId=t.id;const u=fs(l.calculative.worldRect,t.calculative.worldRect);Object.assign(l,u),l.locked=(c=l.lockedOnCombine)!=null?c:Ot.DisableMove,l.locked=l.interaction||Cl.includes(l.name)?0:l.locked,o?(s.push(o),a.push(ht(l,!0))):n.push(ht(l,!0))}),a.push(ht(t,!0));let r=1;n.length&&(r=2,this.pushHistory({type:bt.Add,pens:n,step:r})),this.pushHistory({type:bt.Update,initPens:s,pens:a,step:r})}toPng(t,i,s=!1,n){return this.canvas.toPng(t,i,s,n)}activeToPng(t,i){return this.canvas.activeToPng(t,i)}pensToPng(t=this.store.active,i,s){return this.canvas.pensToPng(t,i,s)}downloadPng(t,i,s){var n;for(const a of this.store.data.pens)(a.calculative.img||["iframe"].includes(a.name))&&((n=a.onRenderPenRaw)==null||n.call(a,a));setTimeout(()=>{const a=document.createElement("a");a.setAttribute("download",(t||this.store.data.name||"le5le.meta2d")+".png"),a.setAttribute("href",this.toPng(i,void 0,!0,s));const r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),a.dispatchEvent(r)},1e3)}downloadSvg(t){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");let i=!1;const s=this.store.data.width||this.store.options.width,n=this.store.data.height||this.store.options.height;s&&n&&!this.store.data.component&&(i=!0);const a=this.getRect();i&&(a.x=this.store.data.origin.x,a.y=this.store.data.origin.y,a.width=s*this.store.data.scale,a.height=n*this.store.data.scale),a.x-=10,a.y-=10;const r=new window.C2S(a.width+20,a.height+20);r.textBaseline="middle",r.strokeStyle=this.store.styles.color;const l=this.store.options.downloadBgTransparent?void 0:this.store.data.background||this.store.styles.background;l&&i&&(r.save(),r.fillStyle=l,r.fillRect(0,0,a.width,a.height),r.restore()),this.store.bkImg&&i&&r.drawImage(this.store.bkImg,0,0,a.width,a.height),l&&!i&&(r.save(),r.fillStyle=l,r.fillRect(0,0,a.width+20,a.height+20),r.restore());for(const y of this.store.data.pens)y.visible==!1||!Vr(y,this.store)||jr(r,y,a,!0);let o=r.getSerializedSvg();t!=null&&t.length&&(o=o.replace("",` {{bk}} {{bkRect}}`)),l?(o=o.replace("{{bk}}",""),o=o.replace("{{bkRect}}",``)):(o=o.replace("{{bk}}",""),o=o.replace("{{bkRect}}","")),o=o.replace(/--le5le--/g,"&#x");const u=window.URL,c=new Blob([o]),f=u.createObjectURL(c),g=document.createElement("a");g.setAttribute("download",`${this.store.data.name||"le5le.meta2d"}.svg`),g.setAttribute("href",f);const v=document.createEvent("MouseEvents");v.initEvent("click",!0,!0),g.dispatchEvent(v)}getRect(t=this.store.data.pens){return hi(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 f,g;if(!this.hasView())return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:a}=s;this.resize(n,a);const r=qi(i),l=this.getRect(),o=(n-r[1]-r[3])/l.width,u=(a-r[0]-r[2])/l.height;let c=o;t?c=o>u?u:o:c=o>u?o:u,(f=this.store.data.fits)!=null&&f.length&&(this.canvas.opening=!0),this.scale(c*this.store.data.scale),this.centerView(),(g=this.store.data.fits)!=null&&g.length&&this.fillView()}fillView(){var n,a;const t=this.getRect(),i=this.canvas.width-t.width,s=this.canvas.height-t.height;if(Math.abs(i)>10){(n=this.store.data.fits)==null||n.forEach(o=>{let u=[];o.children.forEach(f=>{this.store.pens[f]&&(this.store.pens[f].locked=Ot.None,u.push(this.store.pens[f]))});let c=i/2;if(o.left&&o.right){let f=o.leftValue,g=o.rightValue;f?f=Math.abs(f)<1?f*this.canvas.width:f:f=0,g?g=Math.abs(g)<1?g*this.canvas.width:g:g=0;let v=(this.canvas.width-f-g)/(t.width-f-g);u.forEach(y=>{var w,m;y.image&&y.imageRatio&&y.calculative.worldRect.width/this.canvas.width>.1&&(y.imageRatio=!1),y.calculative.worldRect.x=t.x-i/2+f+(y.calculative.worldRect.x-t.x)*v,y.calculative.worldRect.width*=v,y.calculative.worldRect.ex=y.calculative.worldRect.x+y.calculative.worldRect.width,y.calculative.width=y.calculative.worldRect.width,y.calculative.x=y.calculative.worldRect.x,y.width=y.calculative.worldRect.width,y.x=y.calculative.worldRect.x,this.canvas.updatePenRect(y,{worldRectIsReady:!1}),y.externElement&&((w=y.onResize)==null||w.call(y,y)),(m=y.children)!=null&&m.length&&Qe(y,this.store).forEach(E=>{var x;E.externElement&&((x=E.onResize)==null||x.call(E,E))})})}else o.left?(c=-c,o.leftValue&&(c+=Math.abs(o.leftValue)<1?o.leftValue*this.canvas.width:o.leftValue),this.translatePens(u,c,0)):o.right&&(o.rightValue&&(c=c-(Math.abs(o.rightValue)<1?o.rightValue*this.canvas.width:o.rightValue)),this.translatePens(u,c,0))});const r=this.store.data.pens.filter(o=>o.name==="iframe");r==null||r.forEach(o=>{var c,f;const u=o.calculative.worldRect;if(u.width/this.store.data.scale>t.width*.8){let g=u.width;o.calculative.worldRect.x=u.x-i/2,o.calculative.worldRect.width=u.width+i,o.calculative.worldRect.ex=u.ex+i,o.operationalRect.x=o.operationalRect.x*g/o.calculative.worldRect.width,o.operationalRect.width=(o.calculative.worldRect.width-(1-o.operationalRect.width)*g)/o.calculative.worldRect.width,(c=o.onBeforeValue)==null||c.call(o,o,{operationalRect:o.operationalRect}),(f=o.onResize)==null||f.call(o,o)}});const l=this.store.data.pens.filter(o=>o.name==="video");l==null||l.forEach(o=>{var c;const u=o.calculative.worldRect;u.width/this.store.data.scale>t.width*.8&&(o.calculative.worldRect.x=u.x-i/2,o.calculative.worldRect.width=u.width+i,o.calculative.worldRect.ex=u.ex+i,(c=o.onResize)==null||c.call(o,o))})}if(Math.abs(s)>10){(a=this.store.data.fits)==null||a.forEach(o=>{let u=[];o.children.forEach(f=>{this.store.pens[f]&&(this.store.pens[f].locked=Ot.None,u.push(this.store.pens[f]))});let c=s/2;if(o.top&&o.bottom){let f=o.topValue,g=o.bottomValue;f?f=Math.abs(f)<1?f*this.canvas.height:f:f=0,g?g=Math.abs(g)<1?g*this.canvas.height:g:g=0;let v=(this.canvas.height-f-g)/t.height;u.forEach(y=>{var w,m;y.image&&y.imageRatio&&y.calculative.worldRect.height/this.canvas.height>.1&&(y.imageRatio=!1),y.calculative.worldRect.y=t.y-s/2+f+(y.calculative.worldRect.y-t.y)*v,y.calculative.worldRect.height*=v,y.calculative.worldRect.ey=y.calculative.worldRect.y+y.calculative.worldRect.height,y.calculative.height=y.calculative.worldRect.height,y.calculative.y=y.calculative.worldRect.y,y.height=y.calculative.worldRect.height,y.y=y.calculative.worldRect.y,this.canvas.updatePenRect(y,{worldRectIsReady:!1}),y.externElement&&((w=y.onResize)==null||w.call(y,y)),(m=y.children)!=null&&m.length&&Qe(y,this.store).forEach(E=>{var x;E.externElement&&((x=E.onResize)==null||x.call(E,E))})})}else o.top?(c=-c,o.topValue&&(c+=Math.abs(o.topValue)<1?o.topValue*this.canvas.height:o.topValue),this.translatePens(u,0,c)):o.bottom&&(o.bottomValue&&(c=c-(Math.abs(o.bottomValue)<1?o.bottomValue*this.canvas.height:o.bottomValue)),this.translatePens(u,0,c))});const r=this.store.data.pens.filter(o=>o.name==="iframe");r==null||r.forEach(o=>{var c,f;const u=o.calculative.worldRect;if(u.height/this.store.data.scale>t.height*.8){let g=u.height;o.calculative.worldRect.y=u.y-s/2,o.calculative.worldRect.height=u.height+s,o.calculative.worldRect.ey=u.ey+s,o.operationalRect.y=o.operationalRect.y*g/o.calculative.worldRect.width,o.operationalRect.height=(o.calculative.worldRect.height-(1-o.operationalRect.height)*g)/o.calculative.worldRect.height,(c=o.onBeforeValue)==null||c.call(o,o,{operationalRect:o.operationalRect}),(f=o.onResize)==null||f.call(o,o)}});const l=this.store.data.pens.filter(o=>o.name==="video");l==null||l.forEach(o=>{var c;const u=o.calculative.worldRect;u.height/this.store.data.scale>t.height*.8&&(o.calculative.worldRect.y=u.y-s/2,o.calculative.worldRect.height=u.height+s,o.calculative.worldRect.ey=u.ey+s,(c=o.onResize)==null||c.call(o,o))})}this.canvas.canvasTemplate.fit=!0,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:s}=this.canvas,{offsetWidth:n,offsetHeight:a}=s,r=qi(i),l=this.getRect(),o=(n-r[1]-r[3])/l.width,u=(a-r[0]-r[2])/l.height;let c=o;t?c=o>u?u:o:c=o>u?o:u,this.canvas.templateScale(c*this.store.data.scale);let f=this.getRect(),g=this.store.data.pens.filter(v=>!v.parentId);this.canvas.templateTranslatePens(g,-f.x,-f.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:s}=this.canvas,{offsetWidth:n,offsetHeight:a}=s;this.resize(n,a);const r=qi(i),l=(this.store.data.width||this.store.options.width)*this.store.data.scale,o=(this.store.data.height||this.store.options.height)*this.store.data.scale,u=(n-r[1]-r[3])/l,c=(a-r[0]-r[2])/o;let f=u;t==="width"?f=u:t==="height"?f=c:t?f=u>c?c:u:f=u>c?u:c,(g=this.store.data.fits)!=null&&g.length&&(this.canvas.opening=!0),this.scale(f*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,s=this.store.data.height||this.store.options.height,n={x:0,y:0,width:i,height:s};Qt(n);const{center:a}=n,{scale:r,origin:l,x:o,y:u}=this.store.data;this.translate((t.x-l.x)/r-a.x-o/r,(t.y-l.y)/r-a.y-u/r);const{canvas:c}=this.canvas,f=(c.scrollWidth-c.offsetWidth)/2,g=(c.scrollHeight-c.offsetHeight)/2;c.scrollTo(f,g)}scrollView(t=10,i=!1){if(!this.hasView()||!this.canvas.scroll)return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:a}=s;this.resize(n,a);const r=qi(t),l=this.getRect(),o=(n-r[1]-r[3])/l.width;this.scale(o*this.store.data.scale),this.topView(r[0]),i&&this.canvas.scroll.changeMode()}screenView(t=10,i=!0){if(!this.hasView())return;const{canvas:s}=this.canvas,{offsetWidth:n,offsetHeight:a}=s;this.resize(n,a);const r=qi(t),l=this.getRect();let o=(n-r[1]-r[3])/l.width;i||(o=(a-r[0]-r[2])/l.height),this.scale(o*this.store.data.scale),this.topView(r[0])}topView(t=10){if(!this.hasView())return;const i=this.getRect(),s=this.getViewCenter(),n=this.getPenRect(i);Qt(n);const{center:a}=n,{scale:r,origin:l,x:o,y:u}=this.store.data;this.translate((s.x-l.x)/r-a.x-o/r,(t-l.y)/r-n.y-u/r);const{canvas:c}=this.canvas,f=(c.scrollWidth-c.offsetWidth)/2,g=(c.scrollHeight-c.offsetHeight)/2;c.scrollTo(f,g)}centerView(){if(!this.hasView())return;const t=this.getRect(),i=this.getViewCenter(),s=this.getPenRect(t);Qt(s);const{center:n}=s,{scale:a,origin:r,x:l,y:o}=this.store.data;this.translate((i.x-r.x)/a-n.x-l/a,(i.y-r.y)/a-n.y-o/a);const{canvas:u}=this.canvas,c=(u.scrollWidth-u.offsetWidth)/2,f=(u.scrollHeight-u.offsetHeight)/2;u.scrollTo(c,f)}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 s=ht(t),n=t[0],{width:a,height:r}=this.getPenRect(n);for(let l=1;l{n[a]=s[a]});for(let a=1;a{n[a]=s[a]});for(let a=0;a0){const s=t[0];Zn.forEach(n=>{i[n]=s[n]!==void 0?s[n]:this.store.options.defaultFormat[n]||this.store.data[n]||this.store.options[n]})}else Zn.forEach(s=>{this.store.options.defaultFormat[s]||this.store.data[s]||this.store.options[s]});localStorage.setItem("meta2d-formatPainter",JSON.stringify(i))}formatPainter(){const t=this.store.active,i=ht(t),s=JSON.parse(localStorage.getItem("meta2d-formatPainter"));for(let n=0;n{for(let n=0;n{u=Math.min(u,g.calculative.worldRect[f]),c=Math.max(c,g.calculative.worldRect["e"+f])}),s=(c-u)/this.store.data.scale}if(i=i.filter(u=>!u.parentId),i.length<=2)return;const n=ht(i),a=i.reduce((u,c)=>{const f=this.getPenRect(c);return u+f[t]},0),r=(s-a)/(i.length-1);i=i.sort((u,c)=>t==="width"?u.x-c.x:u.y-c.y);const l=this.getPenRect(i[0]);let o=t==="width"?l.x:l.y;for(const u of i){const c=this.getPenRect(u);t==="width"?c.x=o:c.y=o,o+=c[t]+r,this.setValue({id:u.id,...c},{render:!1,doEvent:!1})}this.initImageCanvas(i),this.initTemplateCanvas(i),this.render(),this.pushHistory({type:bt.Update,initPens:n,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,s=30){const n=this.getPenRect(hi(t));!i&&(i=n.width),t=t.filter(u=>!u.type&&!u.parentId);const a=ht(t);let r=0;t.forEach(u=>{const c=this.getPenRect(u);c.height>r&&(r=c.height)});let l=n.x,o=n.y;t.forEach((u,c)=>{const f=this.getPenRect(u);if(f.x=l,f.y=o+r/2-f.height/2,this.setValue({id:u.id,...f},{render:!1,doEvent:!1}),c===t.length-1)return;const g=l+f.width-n.x,v=this.getPenRect(t[c+1]);Math.round(i-g)>=Math.round(v.width+s)?l+=f.width+s:(l=n.x,o+=r+s)}),this.initImageCanvas(t),this.initTemplateCanvas(t),this.render(),this.pushHistory({type:bt.Update,initPens:a,pens:t})}gotoView(t){const i=this.getViewCenter(),s=i.x-t.calculative.worldRect.x-t.calculative.worldRect.width/2,n=i.y-t.calculative.worldRect.y-t.calculative.worldRect.height/2;this.canvas.scroll&&this.canvas.scroll.isShow&&this.canvas.scroll.translate(s-this.store.data.x,n-this.store.data.y),this.store.data.x=s,this.store.data.y=n;for(const a of this.store.data.pens)Yi(a);this.canvas.canvasImage.init(),this.canvas.canvasImageBottom.init(),this.render()}showMap(){this.map||(this.map=new mk(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&&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 s=this.store.data.pens,n=[...Qe(i,this.store),i].map(r=>r.id);s.filter(r=>n.includes(r.id)).forEach(r=>{const l=s.findIndex(o=>o.id===r.id);l>-1&&(s.push(s[l]),s.splice(l,1),this.initTemplateCanvas([r]),this.initImageCanvas([r])),this.specificLayerMove(r,"top")})}this.store.emitter.emit("layer",{type:"top",pens:t})}initImageCanvas(t){this.canvas&&this.canvas.initImageCanvas(t)}initTemplateCanvas(t){this.canvas&&this.canvas.initTemplateCanvas(t)}bottom(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const s=this.store.data.pens,n=[...Qe(i,this.store),i].map(r=>r.id),a=s.filter(r=>n.includes(r.id));for(let r=a.length-1;r>=0;r--){const l=a[r],o=s.findIndex(u=>u.id===l.id);o>-1&&(s.unshift(s[o]),s.splice(o+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(o=>o.id===t.id)===-1){console.warn("upByArea: pen not in canvas");return}const s=[t,...Qe(t,this.store)];let n=s.map(o=>this.store.data.pens.findIndex(u=>u.id===o.id));n.includes(-1)&&(console.warn("upByArea: pen children not in canvas"),n=n.filter(o=>o!==-1));const a=Math.min(...n),r=t.calculative.worldRect,l=this.store.data.pens.findIndex((o,u)=>{if(u<=a||o.id===t.id||qx(o,t))return!1;const c=o.calculative.worldRect;return Xi(r,c)});if(l===-1){this.up(t);return}this.store.data.pens.splice(l+1,0,...s);for(const o of s){const u=this.store.data.pens.findIndex(c=>c.id===o.id);u>-1&&this.store.data.pens.splice(u,1)}this.initImageCanvas([t])}specificLayerMove(t,i){var s;if(t.image&&t.name!=="gif"){let n=zt.CanvasImageBottom;i==="top"?n=zt.CanvasImage:(i==="up"||i==="down")&&(n=zt.CanvasMain),this.setValue({id:t.id,canvasLayer:n},{render:!1,doEvent:!1,history:!1})}else if(t.externElement||t.name==="gif"){let n=0;i==="top"?(t.calculative.canvas.maxZindex+=1,n=t.calculative.canvas.maxZindex):i==="up"?n=t.calculative.zIndex===void 0?6:t.calculative.zIndex+1:i==="down"&&(n=t.calculative.zIndex===void 0?3:t.calculative.zIndex-1,n<0&&(n=0)),this.setValue({id:t.id,zIndex:n},{render:!1,doEvent:!1,history:!1}),(s=t.calculative.singleton)!=null&&s.div&&Re(t,t.calculative.singleton.div)}}up(t){t||(t=this.store.active),Array.isArray(t)||(t=[t]);for(const i of t){const s=this.store.data.pens;if(i.children&&i.children.length){const n=[...Qe(i,this.store),i],a=[];for(let o=0;oc.id===u.id)!==-1&&(u.temIndex=o,a.push(u))}let r=-1,l=0;a.forEach(o=>{o.temIndex-=l,s.splice(o.temIndex,1),l+=1,r=o.temIndex,delete o.temIndex,this.specificLayerMove(o,"up")}),s.splice(r+1,0,...a),this.initTemplateCanvas(a),this.initImageCanvas(a)}else{const n=s.findIndex(a=>a.id===i.id);n>-1&&n!==s.length-1&&(s.splice(n+2,0,s[n]),s.splice(n,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 s=this.store.data.pens;if(i.children&&i.children.length){const n=[...Qe(i,this.store),i],a=[];for(let o=0;oc.id===u.id)!==-1&&(u.temIndex=o,a.push(u))}let r=-1,l=0;a.forEach((o,u)=>{o.temIndex-=l,s.splice(o.temIndex,1),l+=1,u===0&&(r=o.temIndex),delete o.temIndex,this.specificLayerMove(o,"down")}),s.splice(r-1,0,...a),this.initTemplateCanvas(a),this.initImageCanvas(a)}else{const n=s.findIndex(a=>a.id===i.id);n>-1&&n!==0&&(s.splice(n-1,0,s[n]),s.splice(n+1,1),this.initTemplateCanvas([i]),this.initImageCanvas([i])),this.specificLayerMove(i,"down")}}this.store.emitter.emit("layer",{type:"down",pens:t})}setLayer(t,i,s=this.store.data.pens){const n=s.findIndex(a=>a.id===t.id);n>-1&&(n>i?(s.splice(i,0,s[n]),s.splice(n+1,1)):n{const r=this.store.pens[a];if(!r){console.warn(t,"node contain a error connectedLine");return}if(!s.find(l=>l.id===r.id))switch(i){case"all":s.push(r);break;case"in":$t(r).connectTo===t.id&&s.push(r);break;case"out":le(r).connectTo===t.id&&s.push(r);break}}),s}nextNode(t){if(t.type===jt.Line){const i=this.store.pens[$t(t).connectTo];return i?[i]:[]}else{const i=this.getLines(t,"out"),s=[];return i.forEach(n=>{const a=this.nextNode(n);for(const r of a)!s.find(o=>o.id===r.id)&&s.push(r)}),s}}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"),s=[];return i.forEach(n=>{const a=this.previousNode(n);for(const r of a)!s.find(o=>o.id===r.id)&&s.push(r)}),s}}getNext(t){var s;if(t.type===jt.Line){console.warn("\u975E\u8FDE\u7EBF\u8282\u70B9");return}const i=[];return(s=t.connectedLines)==null||s.forEach(({lineId:n,anchor:a})=>{var o,u;const r=(o=t.anchors)==null?void 0:o.filter(c=>c.id===a)[0],l=this.findOne(n);if(l.anchors[0].connectTo==t.id){const c=l.anchors[l.anchors.length-1].connectTo;if(c){const f=this.findOne(c),g=(u=f.connectedLines)==null?void 0:u.filter(y=>y.lineId===l.id)[0],v=f.anchors.filter(y=>y.id===g.anchor)[0];i.push({from:t,fromAnchor:r,line:l,to:f,toAnchor:v})}}}),i}addAnchor(t,i,s){if(!t)return;if(t.anchors||(t.anchors=[]),t.calculative.worldAnchors||(t.calculative.worldAnchors=[]),t.type===jt.Line&&(s<0&&(s=t.anchors.length+1+s),s>t.anchors.length&&(s=t.anchors.length),s<0&&(s=0),s==0&&t.anchors[0].connectTo||s==t.anchors.length&&t.anchors[s-1].connectTo)){console.warn("\u7AEF\u70B9\u5B58\u5728\u8FDE\u63A5\u5173\u7CFB");return}let n=null,a=null;i.x<=1&&i.x>=0&&i.y<=1&&i.y>=0?(a={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(a,t.rotate,t.calculative.worldRect.center),n={id:a.id,penId:t.id,x:i.x,y:i.y}):(a={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),n={id:a.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(s,0,a),t.anchors.splice(s,0,n),this.canvas.updateLines(t),this.canvas.initLineRect(t),this.render()):(t.calculative.worldAnchors.push(a),t.anchors.push(n))}connectLine(t,i,s,n,a=!0){if(!s){const u=i.calculative.worldRect;s=xn(t,{x:u.x+u.width/2,y:u.y+u.height/2})}if(!n){const u=t.calculative.worldRect;n=xn(i,{x:u.x+u.width/2,y:u.y+u.height/2})}const r=Math.abs(s.x-n.x),o={height:Math.abs(s.y-n.y),lineName:"line",lineWidth:1,name:"line",type:1,width:r,x:Math.min(s.x,n.x),y:Math.min(s.y,n.y),anchors:[{x:s.x>n.x?1:0,y:s.y>n.y?1:0,id:It()},{x:s.x>n.x?0:1,y:s.x>n.x?0:1,id:It()}]};return this.addPens([o]),we(t,s,o,o.calculative.worldAnchors[0]),we(i,n,o,o.calculative.worldAnchors[1]),o.calculative.active=!1,this.canvas.updateLines(o),this.canvas.updateLines(t),this.canvas.updateLines(i),this.canvas.initLineRect(o),a&&this.render(),o}toComponent(t=this.store.data.pens,i,s){if(t.length===1){const c=ht(t[0]);return c.type=jt.Node,c.id=void 0,[c]}const n=ht(t,!0),a=hi(n);let r={id:It(),name:"combine",...a,children:[],showChild:i};s&&(r.anchors=[{id:"0",penId:r.id,x:.5,y:0},{id:"1",penId:r.id,x:1,y:.5},{id:"2",penId:r.id,x:.5,y:1},{id:"3",penId:r.id,x:0,y:.5}]);const l=n.filter(c=>!c.parentId),o=n.find(c=>c.width===a.width&&c.height===a.height),u=o&&i===void 0;return l.length===1?r=l[0]:u&&(o.children||(o.children=[]),r=o),n.forEach(c=>{var g;if(c===r||c.parentId===r.id||c.parentId)return;r.children.push(c.id),c.parentId=r.id;const f=fs(c.calculative.worldRect,a);Object.assign(c,f),c.locked=(g=c.lockedOnCombine)!=null?g:Ot.DisableMove}),u||l.length===1?ht(n):ht([r,...n])}installPenPlugins(t,i){if(!t.tag&&!t.name&&!t.id)return;let s;t.id?s="id":t.tag?s="tag":t.name&&(s="name"),i.forEach(n=>{let a=n.plugin,r=n.options;if(!!a&&F_(a)&&s)if(a.install(t,r),!this.penPluginMap.has(a))this.penPluginMap.set(a,[{[s]:t[s],option:r}]);else{let l=this.penPluginMap.get(a).find(o=>o[s]===t[s]);l?l.option=r:this.penPluginMap.get(a).push({[s]:t[s],option:r})}})}uninstallPenPlugins(t,i){let s;t.id?s="id":t.tag?s="tag":t.name&&(s="name"),s&&i.forEach(n=>{let a=n.plugin;a.uninstall(t,n.options);let r=this.penPluginMap.get(a),l=r.findIndex(o=>o[s]===t[s]);l!==-1&&(r.splice(l,1),r.length===0&&this.penPluginMap.delete(a))})}setVisible(t,i,s=!0){if(this.onSizeUpdate(),this.setValue({id:t.id,visible:i},{render:!1,doEvent:!1}),t.children)for(const a of t.children){const r=this.store.pens[a];r&&this.setVisible(r,i,!1)}let n=Qe(t,this.store);n.push(t),this.initImageCanvas(n),s&&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(),ta.destroyThemeSheet(this.store.id),this.store.emitter.all.clear(),this.canvas.destroy(),this.canvas=void 0,kt[this.store.id]=void 0,!t){for(const i in kt)delete kt[i];kt.path2dDraws={},kt.canvasDraws={},kt.anchors={},kt.htmlElements={}}}}function Ck(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ey:r}=e.calculative.worldRect,l=a/4;if(i.moveTo(s+l,n),i.lineTo(s,n),i.lineTo(s,r),i.lineTo(s+l,r),i instanceof Path2D)return i}function Rk(e){const t=[{x:.25,y:0},{x:.25,y:1},{x:0,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:n+"",x:i,y:s,penId:e.id}))}function Tk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=e.offsetX;let u=a/7;if(o>1?u=o:o>0&&(u=a*o),i.moveTo(s+u,n),i.lineTo(r,n),i.lineTo(s+a-u,l),i.lineTo(s,l),i.closePath(),i instanceof Path2D)return i}function Sk(e){const t=[{x:.5,y:0},{x:.9285714285714286,y:.5},{x:.5,y:1},{x:.07142857142857142,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function Pk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l,ey:o}=e.calculative.worldRect,u=a/8;if(i.moveTo(s+u,n),i.lineTo(l-u,n),i.bezierCurveTo(l+u/3,n,l+u/3,o,l-u,o),i.lineTo(s+u,o),i.lineTo(s,n+r/2),i.closePath(),i instanceof Path2D)return i}function Ik(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l,center:o}=e.calculative.worldRect,u=o.x,c=n+r*6/7,f=r/6;if(i.moveTo(s,n),i.lineTo(l,n),i.lineTo(l,c),i.bezierCurveTo(l-20,c-f,u+a/5,c-f,u,c),i.bezierCurveTo(u-a/5,c+f,s,c+f,s,c),i.closePath(),i instanceof Path2D)return i}function Lk(e){const t=[{x:.5,y:0},{x:1,y:.5},{x:.5,y:.8571428571428571},{x:0,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function Dk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=a/10;if(i.moveTo(s+o*2,n),i.bezierCurveTo(s-o*2/3,n,s-o*2/3,l,s+o*2,l),i.lineTo(r,l),i.bezierCurveTo(r-o,l,r-o,n,r,n),i.closePath(),i instanceof Path2D)return i}function Mk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect;i.moveTo(s,n),i.lineTo(r,n),i.lineTo(r,l),i.lineTo(s,l),i.closePath();const o=a/7;if(i.moveTo(s,n+o),i.lineTo(r,n+o),i.moveTo(s+o,n),i.lineTo(s+o,l),i instanceof Path2D)return i}function Bk(e,t){const i=t||new Path2D,{x:s,y:n,height:a,ex:r,ey:l}=e.calculative.worldRect,o=a/4;if(i.moveTo(s,n+o),i.lineTo(r,n),i.lineTo(r,l),i.lineTo(s,l),i.closePath(),i instanceof Path2D)return i}function Ok(e){const t=[{x:.5,y:.125},{x:1,y:.5},{x:.5,y:1},{x:0,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function Fk(e,t){const i=t||new Path2D,{x:s,y:n,ex:a,ey:r}=e.calculative.worldRect;if(i.moveTo(s,n),i.lineTo(a,n),i.moveTo(s,r),i.lineTo(a,r),i instanceof Path2D)return i}function Nk(e){const t=[{x:.5,y:0},{x:.5,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:n+"",x:i,y:s,penId:e.id}))}function zk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l,ey:o}=e.calculative.worldRect;if(i.ellipse(s+a/2,n+r/2,a/2,r/2,0,0,Math.PI*2),i.moveTo(s+a/2,o),i.lineTo(l,o),i.closePath(),i instanceof Path2D)return i}function Hk(e,t){const i=t||new Path2D,{x:s,y:n,width:a,ex:r,ey:l}=e.calculative.worldRect,o=a/7;if(i.moveTo(s,n),i.lineTo(r,n),i.lineTo(r,l),i.lineTo(s,l),i.closePath(),i.moveTo(s+o,n),i.lineTo(s+o,l),i.moveTo(r-o,n),i.lineTo(r-o,l),i instanceof Path2D)return i}function Wk(e,t){const i=t||new Path2D,{x:s,y:n,height:a,ex:r,ey:l}=e.calculative.worldRect,o=a/7;if(i.moveTo(s,n+o),i.bezierCurveTo(s,n-o/2|0,r,n-o/2|0,r,n+o),i.lineTo(r,l-o),i.bezierCurveTo(r,l+o/2|0,s,l+o/2|0,s,l-o),i.closePath(),i.moveTo(s,l-o),i.bezierCurveTo(s,l-o*2|0,r,l-o*2|0,r,l-o),i instanceof Path2D)return i}function uR(){return{flowComment:Ck,flowData:Tk,flowDb:Wk,flowDisplay:Pk,flowDocument:Ik,flowExternStorage:Dk,flowInternalStorage:Mk,flowManually:Bk,flowParallel:Fk,flowQueue:zk,flowSubprocess:Hk}}function fR(){return{flowDocument:Lk,flowManually:Ok,flowParallel:Nk,flowComment:Rk,flowData:Sk}}var Xr;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(Xr||(Xr={}));function Eg(e,t){const i=t.calculative.worldRect.height*14/16,n=(e.match(/[\u4e00-\u9fa5]/g)||"").length;return(e.length-n)*i*.6+n*i}function Ag(e){if(e.direction=="horizontal"){const t=[];let i=0;const s=e.height;e.checkboxHeight=s,e.options.forEach((a,r)=>{t.push(r*(40+s)+i),i+=Eg(a.text,e)}),e.optionPos=t;const n=t.length*(40+s)+i;e.checkboxWidth=n,e.width=n,e.calculative.width=n,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}},re(e.calculative.worldRect)}else if(e.direction=="vertical"){e.optionInterval==null&&(e.optionInterval=20),e.optionHeight||(e.optionHeight=20);const t=[];e.options.forEach((s,n)=>{t.push(n*(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}},re(e.calculative.worldRect))}}function $f(e,t){t.onAdd||(t.onAdd=Cg,(!t.rowPos||!t.colPos||!t.calculative.maxOffsetY)&&t.onAdd(t),t.onMouseMove=Kk,t.onMouseLeave=Xk,t.onMouseDown=Gk,t.onShowInput=qk,t.onInput=Yk,t.onValue=Qk,t.onBeforeValue=tE,t.onMouseEnter=aE,t.onWheel=eE,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;if(t.calculative.canvas.store.data,t.calculative.canvas.store.options,t.color=t.color||i.styles.color,t.textColor=t.textColor||t.color||i.styles.textColor,t.activeColor=t.activeColor||i.styles.activeColor,t.hoverColor=t.hoverColor||i.styles.hoverColor,t.activeBackground=t.activeBackground||i.styles.activeBackground,t.hoverBackground=t.hoverBackground||i.styles.hoverBackground,!t.hasHeader){e.save(),e.beginPath();const{x:s,y:n,width:a,height:r}=t.calculative.worldRect;e.fillStyle="#fff0",e.rect(s-1,n-1,a+2,r+2),e.fill(),e.clip()}jk(e,t),Vk(e,t),Uk(e,t),e.restore(),t.isFirstTime=!1}function Uk(e,t){if(!t.calculative.hover||!t.calculative.hoverCell||t.calculative.isInput||!t.calculative.isHover)return;let i=t.calculative.worldRect,s=t.calculative.canvas.mousePos;if(!(s.x>i.x&&s.xi.y&&s.yv.col!==void 0&&v.row===void 0&&v.width);let r={};a&&a.forEach(v=>{r[v.col]=v.width});for(let v=0;vw.col===v&&w.row===void 0);y&&(s[v]=y[0])}let l=0;const o=e.styles&&e.styles.filter(v=>v.col===void 0&&v.row!==void 0&&v.height);let u={};o&&o.forEach(v=>{u[v.row]=v.height});let c=l;for(let v=0;vt.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||t.color||"#424B61",e.stroke()}}if(t.vLine!==!1){let f=t.colPos[t.colPos.length-1];t.colPos.forEach((g,v)=>{if(g===f)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||t.color||"#424B61",e.stroke()})}e.restore()}function Vk(e,t){var s,n,a,r,l;if(!t.colPos)return;t.calculative.texts||(t.calculative.texts=[]);const i=1;for(let o=0;o0){let D=0;g.forEach(($,Q)=>{$.wheres&&$.wheres.every(T=>new Function("attr",`return attr ${T.comparison} ${T.value}`)(f))&&(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}`)(f)}));let y=t.color,w=t.textColor||t.color,m=null,_=null,E=null,x=null;v&&(y=g.color||u.color||t.color,w=g.textColor||u.textColor||t.textColor,m=g.background||u.background,_=(g.fontSize||u.fontSize||0)*t.calculative.canvas.store.data.scale,E=g.fontWeight||u.fontWeight,x=g.fontStyle||u.fontStyle);let C;t.stripe&&(t.hasHeader!==!1?o%2===1&&(m=m||t.stripeColor||"#407FFF1F"):o%2===0&&(m=m||t.stripeColor||"#407FFF1F")),t.calculative.active&&((s=t.calculative.activeCell)==null?void 0:s.row)===o&&((n=t.calculative.activeCell)==null?void 0:n.col)===c&&(y=t.activeColor,m=t.activeBackground,C=y,w=t.activeTextColor||t.activeColor),t.calculative.hover&&((a=t.calculative.hoverCell)==null?void 0:a.row)===o&&((r=t.calculative.hoverCell)==null?void 0:r.col)===c&&(y=t.hoverColor,m=t.hoverBackground,w=t.hoverTextColor||t.hoverColor,C=y);const S=Pg(t,o,c);if(S.y+S.heightt.calculative.worldRect.height+t.calculative.worldRect.y)continue;m&&(e.save(),e.beginPath(),e.fillStyle=m,e.fillRect(S.x,S.y,S.width+.25*t.calculative.canvas.store.data.scale,S.height),e.restore()),C&&(e.save(),e.beginPath(),e.strokeStyle=C,e.strokeRect(S.x,S.y,S.width,S.height),e.restore()),t.calculative.worldTextRect=S;let L=t.calculative.texts[o];if(t.calculative.texts[o]||(L=[],t.calculative.texts.push(L)),L[c]==null){if(typeof f=="object"){const D=t.styles&&t.styles.filter($=>$.col===c&&$.row===void 0&&$.pens);if(D.length>0){if(L[c]="",t.isFirstTime){t.maxNum&&t.hasHeader&&o>=t.maxNum&&(f.visible=!1);let $=JSON.parse(JSON.stringify(D[0].pens));$.forEach(Q=>{Object.assign(Q,{row:o,col:c},f),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}),Jk(t,S,$),t.calculative.canvas.parent.pushChildren(t,$)}continue}}else f===void 0?L[c]="":L[c]=f.text||f+"";if(!L[c])continue;L[c]=_a(t,L[c])}if(!L[c])continue;e.save(),e.beginPath(),e.fillStyle=w,e.textAlign="center",e.textBaseline="middle",e.font=(x||t.calculative.fontStyle||"")+" normal "+(E||t.calculative.fontWeight||"")+" "+(_||t.calculative.fontSize||12)*i+"px "+t.calculative.fontFamily;let M=t.colStyle&&((l=t.colStyle[c])==null?void 0:l.textAlign);if(M&&(e.textAlign=M),L[c].length===1)M==="left"?e.fillText(L[c][0],S.x,S.y+S.height/2):M==="right"?e.fillText(L[c][0],S.x+S.width,S.y+S.height/2):e.fillText(L[c][0],S.x+S.width/2,S.y+S.height/2);else{const $=(_||t.calculative.fontSize)*t.calculative.lineHeight*i,Q=L[c].length*$;let R=(S.height-Q)/2;M==="left"?L[c].forEach((T,P)=>{e.fillText(T,S.x,S.y+R+(P+.55)*$)}):M==="right"?L[c].forEach((T,P)=>{e.fillText(T,S.x+S.width,S.y+R+(P+.55)*$)}):L[c].forEach((T,P)=>{e.fillText(T,S.x+S.width/2,S.y+R+(P+.55)*$)})}e.restore()}}}function Cg(e){var t;Ec(e),(t=e.children)!=null&&t.length||(e.isFirstTime=!0),e.offsetY||(e.offsetY=0),$k(e)}function qk(e,t){if(!e.calculative.hoverCell)return;const{value:i}=Tg(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 s=Pg(e,e.calculative.hoverCell.row,e.calculative.hoverCell.col);e.calculative.tempText=i.text||i+"",e.calculative.canvas.showInput(e,s,"#ffffff")}function Yk(e,t){!e.calculative.inputCell||(Sg(e,e.calculative.inputCell.row,e.calculative.inputCell.col,t),e.calculative.isInput=!1,e.calculative.isHover=!0,e.calculative.canvas.render())}function Kk(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=Rg(e,t),e.calculative.canvas.render()}function Xk(e,t){Ec(e),e.calculative.hoverCell=void 0,e.calculative.canvas.render()}function Gk(e,t){e.calculative.activeCell=Rg(e,t),e.calculative.canvas.render()}function Rg(e,t){const i=e.calculative.worldRect.width/e.tableWidth,s=e.calculative.worldRect.height/e.tableHeight,n={row:0,col:0};for(let a=0;ae.calculative.worldRect.x+e.colPos[a]*i&&(n.col=a+1);for(let a=0;ae.calculative.worldRect.y+e.rowPos[a]*s-e.offsetY*e.calculative.canvas.store.data.scale&&(n.row=a+1);return n}function Tg(e,t,i){if(!e.data||!Array.isArray(e.data))return;const s=e.data[t],n=e.styles&&e.styles.filter(a=>a.row===t&&a.col===i);if(Array.isArray(s))return{value:s[i],style:(n==null?void 0:n.length)>0?n.length>1?n:n[0]:{}};if(!s.data||!Array.isArray(s.data))return}function Zk(e,t){if(!e.data||!Array.isArray(e.data))return;const i=e.data[t],s=e.styles&&e.styles.filter(n=>n.row===t&&n.col===void 0);if(Array.isArray(i))return{value:i,style:(s==null?void 0:s.length)>0?s[0]:{}};if(!i.data||!Array.isArray(i.data))return}function Sg(e,t,i,s){if(!e.data||!Array.isArray(e.data))return;e.isFirstTime=!1,e.calculative.texts=void 0;let n=e.data[t];!n||(n[i]instanceof Object||(n[i]=s),e.calculative.canvas.store.emitter.emit("valueUpdate",e))}function Pg(e,t,i){const s=e.calculative.worldRect.width/e.tableWidth,n=e.calculative.worldRect.height/e.tableHeight;let a=0,r=e.colPos[i]*s;i>0&&(a=e.colPos[i-1]*s);let l=0,o=e.rowPos[t]*n;t>0&&(l=e.rowPos[t-1]*n);let u=e.offsetY*e.calculative.canvas.store.data.scale;return t===0&&e.hasHeader&&(u=0),{x:e.calculative.worldRect.x+a,y:e.calculative.worldRect.y+l-u,ex:e.calculative.worldRect.x+r,ey:e.calculative.worldRect.y+o-u,width:r-a,height:o-l}}function Jk(e,t,i){if(!(i&&i.length))return;const s=e.calculative.worldRect.width/e.tableWidth,n=e.calculative.worldRect.height/e.tableHeight;let a=1,r=1;e.initWorldRect&&(e.calculative.worldRect.width!==e.initWorldRect.width&&(a=e.calculative.worldRect.width/e.initWorldRect.width),e.calculative.worldRect.height!==e.initWorldRect.height&&(r=e.calculative.worldRect.height/e.initWorldRect.height));let l=0,o=0,u=0;const c=e.calculative.canvas.store.data.scale;if(i.length>1){for(const f of i)o+f.width*s+20*c*s{f.width=f.width*a,f.height=f.height*r})}function Qk(e){if(e.calculative.isUpdateData){delete e.calculative.isUpdateData;let t=ht(e.children);e.children=[],Cg(e),t&&t.forEach(i=>{e.calculative.canvas.delForce(e.calculative.canvas.findOne(i))}),e.calculative.texts=void 0}}function tE(e,t){if(e.calculative.isUpdateData=!1,e.swiper!==void 0&&(e.swiper?Ec(e):kc(e)),t.styles&&(e.initWorldRect=void 0),t.table||t.col==null&&t.row==null){if(t.dataY){const s=e.replaceMode;let n=[];return s?s===Xr.Replace?(n=e.data,t.dataX&&t.dataX.forEach((a,r)=>{n[a]=t.dataY[r]})):s===Xr.ReplaceAll&&(t.dataX?n[0]=t.dataX:n[0]=e.data[0],n=n.concat(t.dataY)):n=e.data.concat(t.dataY),delete t.dataX,delete t.dataY,e.calculative.isUpdateData=!0,Object.assign(t,{data:n})}(t.data||t.styles||t.maxNum||t.rowHeight||t.colWidth)&&(e.calculative.isUpdateData=!0,e.initWorldRect=null);for(let s of Object.keys(t))s.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),Sg(e,t.row,t.col,t.value),e.calculative.canvas.render(),delete t.col,delete t.row),t}function eE(e,t){if(!e.locked&&!e.calculative.canvas.store.data.locked||!e.maxNum)return;let i=0;t.deltaY>0?i=4:i=-4,nc(e,i)}function nc(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(s=>{const n=e.calculative.canvas.store.pens[s];iE(e,n)}),e.calculative.canvas.render()}function iE(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 s=e.rowHeight;t.y=t.oldY-e.offsetY*i/e.calculative.worldRect.height;const n=s*(e.initScale||1)/e.tableHeight*e.maxNum;if(e.calculative.canvas.updatePenRect(t),e.hasHeader)if(t.y1){if(t.calculative.visible=!1,t.visible=!1,t.y+t.height/2>1){t.oldY-=n;let a=t.row-e.maxNum;if(!e.data[a])return;let r=ht(e.data[a][t.col]);r.background&&(r.activeBackground=r.background,r.hoverBackground=r.background),r.color&&(r.hoverColor=r.color,r.activeColor=r.color),r.textColor&&(r.activeTextColor=r.textColor,r.hoverTextColor=r.textColor),Object.assign(t,r,{row:a}),Object.assign(t.calculative,r,{row:a})}}else t.visible=!0,t.calculative.visible=!0;else if(t.y<0){if(t.calculative.visible=!1,t.visible=!1,t.y<-s/e.tableHeight/2){t.oldY+=n;let a=t.row+e.maxNum;if(!e.data[a])return;let r=ht(e.data[a][t.col]);r.background&&(r.activeBackground=r.background,r.hoverBackground=r.background),r.color&&(r.hoverColor=r.color,r.activeColor=r.color),r.textColor&&(r.activeTextColor=r.textColor,r.hoverTextColor=r.textColor),Object.assign(t,r,{row:a}),Object.assign(t.calculative,r,{row:a})}}else if(t.y+t.height>1){if(t.calculative.visible=!1,t.visible=!1,t.y+t.height/2>1){t.oldY-=n;let a=t.row-e.maxNum;if(!e.data[a])return;let r=ht(e.data[a][t.col]);r.background&&(r.activeBackground=r.background,r.hoverBackground=r.background),r.color&&(r.hoverColor=r.color,r.activeColor=r.color),r.textColor&&(r.activeTextColor=r.textColor,r.hoverTextColor=r.textColor),Object.assign(t,r,{row:a}),Object.assign(t.calculative,r,{row:a})}}else t.calculative.visible=!0,t.visible=!0}function sE(e){kc(e)}function kc(e){e.interval&&(globalThis.clearInterval(e.interval),e.interval=null)}function Ec(e){if(e.maxNum&&e.swiper){if(e.interval)return;e.interval=globalThis.setInterval(()=>{e.offsetY>=e.calculative.maxOffsetY?(e.offsetY=0,nE(e)):e.offsetY%e.rowHeight?nc(e,1):(e.calculative.stap||(e.calculative.stap=0),e.calculative.stap+=1,e.calculative.stap==12&&(e.calculative.stap=0,nc(e,1)))},50)}}function nE(e){var t;(t=e.children)==null||t.forEach(i=>{const s=e.rowHeight,n=e.calculative.canvas.store.pens[i];if(!n)return;const a=s*(e.initScale||1)/e.tableHeight*e.maxNum;n.oldY-=a;const r=n.row-e.maxNum;if(!e.data[r])return;let l=ht(e.data[r][n.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),n.calculative.visible=!0,n.visible=!0,Object.assign(n,l,{row:r}),Object.assign(n.calculative,l,{row:r})}),e.calculative.canvas.render()}function aE(e){kc(e)}function rE(e,t){t.onClick||(t.onClick=oE,t.setTheme=lE);let i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.width,a=t.calculative.worldRect.height;n2?a/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+a,s+a/2),e.arc(i+a/2,s+a/2,a/2>2?a/2-2:1,0,Math.PI*2),e.fill()),e.closePath()}function oE(e){e.disableDefaultClick||e.disabled||e.disable||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function lE(e,t){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];e.hasOwnProperty(i)&&(e[i]=s),e.calculative.hasOwnProperty(i)&&(e.calculative[i]=s)}e.onStrokeColor=t.borderColor,e.offStrokeColor=t.borderColor}function cE(e,t){t.onAdd||(t.onAdd=sa,t.onResize=sa,t.onMove=sa,t.onMouseMove=hE,t.onMouseDown=Ig,t.onValue=uE,t.onBeforeValue=fE,t.setTheme=dE),t.calculative.barRect||sa(t);const i=t.calculative.canvas.store;t.calculative.canvas.store.options;let s=t.background;t.disabled&&(s=t.disabledBackground||Ae(.6,s)),e.fillStyle=s,e.beginPath();let n=t.calculative.worldRect.x+t.calculative.barRect.x,a=t.calculative.worldRect.y+t.calculative.barRect.y,r=t.calculative.barRect.width,l=t.calculative.barRect.height,o=l/2;e.moveTo(n+o,a),e.arcTo(n+r,a,n+r,a+l,o),e.arcTo(n+r,a+l,n,a+l,o),e.arcTo(n,a+l,t.x,t.y,o),e.arcTo(n,a,n+r,a,o),e.fill();let u=t.activeColor||i.styles.activeColor;t.disabled&&(u=t.disabledColor||Ae(.6,u)),e.fillStyle=u,e.beginPath(),r=t.calculative.ballRect.x,e.moveTo(n+o,a),e.arcTo(n+r,a,n+r,a+l,o),e.arcTo(n+r,a+l,n,a+l,o),e.arcTo(n,a+l,t.x,t.y,o),e.arcTo(n,a,n+r,a,o),e.fill(),e.fillStyle=t.btnBackground||"#fff",e.strokeStyle=u,e.lineWidth=2,e.beginPath(),n=t.calculative.worldRect.x+t.calculative.ballRect.x,a=t.calculative.worldRect.y+t.calculative.ballRect.y+t.calculative.ballRect.height/2,e.lineWidth=t.calculative.ballRect.width/10,e.arc(n,a,t.calculative.ballRect.width/2,0,Math.PI*2),e.fill(),e.stroke()}function sa(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,s=Math.min(t,i);e.fontSize=e._fontSize*s;const n=e.calculative.worldRect.width-e._textWidth*s;e.textLeft=n+10*s,e.calculative.textLeft=e.textLeft,e.calculative.barRect={x:0,y:(e.calculative.worldRect.height-e.barHeight*i)/2,width:n,height:e.barHeight*i},re(e.calculative.barRect),Ac(e)}function Ac(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},re(e.calculative.ballRect),e.calculative.text=e.value+e.unit,Ri(e)}function Ig(e,t){if(e.disabled)return;const i=t.x-e.calculative.worldRect.x;if(i>e.calculative.barRect.width)return;let s=Math.round(i/e.calculative.barRect.width*100);se.max||s<0||s>100||(e.value=s,Ac(e),e.calculative.text=e.value+e.unit,Ri(e),e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function hE(e,t){e.calculative.canvas.mouseDown&&Ig(e,t)}function uE(e){e.calculative.isUpdateData&&(delete e.calculative.isUpdateData,sa(e)),Ac(e)}function fE(e,t){return e.calculative.isUpdateData=!1,(t.textWidth||t.barHeight)&&(t.textWidth&&(e._textWidth=0),e.calculative.isUpdateData=!0),t}function dE(e,t){for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const s=t[i];e.hasOwnProperty(i)&&(e[i]=s),e.calculative.hasOwnProperty(i)&&(e.calculative[i]=s)}e.background=t.sliderBg,e.calculative.background=t.sliderBg,e.btnBackground=t.sliderBtnBg,e.calculative.btnBackground=t.sliderBtnBg,e.activeColor=t.tabActiveBg,e.calculative.activeColor=t.tabActiveBg}function gE(e,t){t.onMouseDown||(t.onMouseDown=vE),t.options||(t.options=t.data);let i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.height;t.calculative.worldRect.width;const{fontStyle:a,fontWeight:r,fontSize:l,fontFamily:o,lineHeight:u}=t.calculative;let c=2;e.beginPath(),e.moveTo(i,s),e.arcTo(i+n,s,i+n,s+n,c),e.arcTo(i+n,s+n,i,s+n,c),e.arcTo(i,s+n,i,s,c),e.arcTo(i,s,i+n,s,c),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=n/10,e.strokeStyle="#ffffff",e.moveTo(i+102/506*n,s+n/2),e.lineTo(i+220/506*n,s+346/460*n),e.lineTo(i+404/506*n,s+142/460*n),e.stroke()),e.restore(),e.save(),e.fillStyle=t.disabled||t.isForbidden?t.disabledTextColor||Ae(.6,t.textColor||t.color)||"#00000040":Ji(t,t.calculative.canvas.parent.store)||"#000000d9",e.textAlign="start",e.textBaseline="middle",e.font=Be({fontStyle:a,fontWeight:r,fontFamily:o||t.calculative.canvas.parent.store.options.fontFamily,fontSize:l,lineHeight:u}),e.fillText(t.value+"",i+n+10,s+n/2),e.restore()}function vE(e,t){e.isForbidden||(e.checked=!e.checked,e.calculative.canvas.store.emitter.emit("valueUpdate",e),e.calculative.canvas.render())}function yE(e,t){t.options||(t.options=t.data),t.onAdd||(t.onAdd=mE,t.optionPos||(t.onAdd(t),t.calculative.canvas.parent.active([t])),t.onMouseDown=pE,t.onValue=wE,t.onBeforeValue=bE);let i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.height,a=t.calculative.worldRect.width;if(!t.optionPos)return;const{fontStyle:r,fontWeight:l,fontSize:o,fontFamily:u,lineHeight:c}=t.calculative;if(t.direction=="horizontal")for(let f=0;fe.calculative.worldRect.x+e.optionPos[i]*e.calculative.worldRect.width/e.checkboxWidth&&t.xe.calculative.worldRect.y+e.optionPos[s]*i&&t.y{const s=t.data.pens.findIndex(n=>n.id===i);s>-1&&(t.data.pens.splice(s,1),t.pens[i]=void 0)}),e.children=void 0}function RE(e,t){e.onDestroy||(e.onDestroy=SE,e.onAdd=TE);const i=t||new Path2D,{x:s,y:n,width:a,height:r,ex:l}=e.calculative.worldRect;let o=e.calculative.borderRadius||0,u=o;o<1&&(o=a*o,u=r*u);let c=o{const s=t.data.pens.findIndex(n=>n.id===i);s>-1&&(t.data.pens.splice(s,1),t.pens[i]=void 0)}),e.children=[]}function yR(){return{interfaceClass:EE,simpleClass:RE}}var la;(function(e){e[e.Add=0]="Add",e[e.Replace=1]="Replace",e[e.ReplaceAll=2]="ReplaceAll"})(la||(la={}));let ac=["fontSize","nameGap","margin","width","symbolSize","itemWidth","itemHeight","fontWeight","top","left","right","bottom","zoom","edgeSymbolSize","nodeWidth","nodeGap","distance","length","length2","offsetCenter","size","symbolOffset","padding","barWidth","symbolOffset","shadowOffsetY","shadowOffsetX"];function PE(e){var n,a;let t=globalThis.echarts;if(!e.echarts||!t)return;if(typeof e.echarts=="string")try{e.echarts=JSON.parse(e.echarts)}catch{}ac=((n=e.calculative.canvas.store.options.diagramOptions.chart)==null?void 0:n.keyWords)||ac,e.onDestroy||(e.onDestroy=LE,e.onMove=Mr,e.onResize=DE,e.onRotate=Mr,e.onValue=BE,e.onBeforeValue=OE,e.onBinds=NE,e.onMouseEnter=Mr,e.onRenderPenRaw=Ml,e.onScale=ME),e.calculative.singleton||(e.calculative.singleton={});const i=new Path2D,s=e.calculative.worldRect;if(!e.calculative.singleton.div){const r=document.createElement("div");r.style.position="absolute",r.style.outline="none",r.style.left="-9999px",r.style.top="-9999px",r.style.width=s.width+"px",r.style.height=s.height+"px",document.body.appendChild(r),(a=e.calculative.canvas.externalElements)==null||a.parentElement.appendChild(r),Re(e,r),e.calculative.singleton.div=r,e.calculative.singleton.echart=t.init(r,e.echarts.theme),IE(e),e.calculative.singleton.echartsReady=!0,e.echarts.geoName&&!t.getMap(e.echarts.geoName)&&(e.echarts.geoJson?t.registerMap(e.echarts.geoName,e.echarts.geoJson):e.echarts.geoUrl&&(e.calculative.singleton.echartsReady=!1,fetch(e.echarts.geoUrl).then(l=>{l.text().then(o=>{if(typeof o=="string")try{o=JSON.parse(o)}catch{}if(o.constructor!==Object&&o.constructor!==Array){console.warn("Invalid data:",o);return}t.registerMap(e.echarts.geoName,o),e.calculative.singleton.echartsReady=!0,e.calculative.singleton.echart.setOption(Gr(e.echarts.option,e.calculative.canvas.store.data.scale),!0),e.calculative.singleton.echart.resize(),setTimeout(()=>{Ml(e)},300)})}))),e.calculative.singleton.echartsReady&&setTimeout(()=>{e.calculative.singleton.echart.setOption(Gr(e.echarts.option,e.calculative.canvas.store.data.scale),!0),setTimeout(()=>Ml(e),300)})}return i}function IE(e){var s;const t=e.calculative.singleton.echart,i=["click","dblclick","mousedown","mousemove","mouseup","mouseover","mouseout","globalout","contextmenu"];i.forEach(n=>{t.off(n)}),(s=e.events)==null||s.forEach(n=>{n.actions&&n.actions.length&&i.includes(n.name)&&t.on(n.name,a=>{let r=!1;n.conditions&&n.conditions.length?n.conditionType==="and"?r=n.conditions.every(l=>e.calculative.canvas.parent.judgeCondition(e,l.key,l)):n.conditionType==="or"&&(r=n.conditions.some(l=>e.calculative.canvas.parent.judgeCondition(e,l.key,l))):r=!0,r&&n.actions.forEach(l=>{if(l.timeout){let o=setTimeout(()=>{e.calculative.canvas.parent.events[l.action]&&(e.calculative.canvas.parent.events[l.action](e,l,a),clearTimeout(o),o=null)},l.timeout)}else e.calculative.canvas.parent.events[l.action]&&e.calculative.canvas.parent.events[l.action](e,l,a)})})})}function LE(e){if(e.calculative.singleton&&e.calculative.singleton.div){e.calculative.singleton.div.remove();let t=globalThis.echarts;t&&t.dispose(e.calculative.singleton.echart),delete e.calculative.singleton.div,delete e.calculative.singleton.echart}}function Mr(e){e.calculative.singleton.div&&Re(e,e.calculative.singleton.div)}function DE(e){var t;Mr(e),(t=e.calculative.singleton)!=null&&t.echart&&e.calculative.singleton.echart.resize()}function ME(e){var i,s;if(!e.calculative.singleton.echart)return;let t=globalThis.echarts;if(Re(e,e.calculative.singleton.div),!(e.echarts.geoName&&!t.getMap(e.echarts.geoName))){if(!e.echarts.diabled){if((i=e.echarts.option)!=null&&i.dataZoom){const a=e.calculative.singleton.echart.getOption().dataZoom;(s=e.echarts.option.dataZoom)==null||s.forEach((r,l)=>{a[l]&&(r.start=a[l].start,r.end=a[l].end)})}e.calculative.singleton.echart.setOption(Gr(e.echarts.option,e.calculative.canvas.store.data.scale),!0)}e.calculative.singleton.echart.resize()}}function BE(e){var t,i;if(!!e.calculative.singleton.echart&&(Re(e,e.calculative.singleton.div),e.calculative.singleton.echartsReady))if(e.calculative.partialOption){const s=e.calculative.partialOption.echarts.option;(Array.isArray((t=e.echarts)==null?void 0:t.replaceMerge)?(i=e.echarts)==null?void 0:i.replaceMerge.some(a=>s[a]):!1)?e.calculative.singleton.echart.setOption(ht(s),{replaceMerge:e.echarts.replaceMerge}):e.calculative.singleton.echart.setOption(ht(s))}else e.calculative.singleton.echart.setOption(Gr(e.echarts.option,e.calculative.canvas.store.data.scale),!0)}function OE(e,t){if(e.calculative.partialOption=null,t.echarts){let y=globalThis.echarts;return t.echarts.geoName&&!y.getMap(t.echarts.geoName)&&(t.echarts.geoJson?y.registerMap(t.echarts.geoName,t.echarts.geoJson):t.echarts.geoUrl&&(e.calculative.singleton.echartsReady=!1,fetch(t.echarts.geoUrl).then(w=>{w.text().then(m=>{if(typeof m=="string")try{m=JSON.parse(m)}catch{}if(m.constructor!==Object&&m.constructor!==Array){console.warn("Invalid data:",m);return}return y.registerMap(t.echarts.geoName,m),e.calculative.singleton.echartsReady=!0,e.onValue(e),!1})}))),t}if(e.realTimes&&e.realTimes.length){e.echarts.dataMap&&t.data&&(t=FE(e,t));let y=Object.keys(t);const{xAxis:w,yAxis:m}=e.echarts.option,{max:_,replaceMode:E,timeFormat:x}=e.echarts;let C=[],S=!1;for(let L in t)if(L.includes("echarts.option")){S=!0;let M=ms(e,L);if(Array.isArray(M)&&E===la.Add&&(M.push(t[L]),_&&M.splice(0,M.length-_),t[L]=M,!y.includes("echarts.option.xAxis.data"))){let D="echarts.option.xAxis.data";Array.isArray(w)&&w.length&&(D="echarts.option.xAxis.0.data");let $=ms(e,D),Q=Zl(x||"`${hours}:${minutes}:${seconds}`");$.push(Q),_&&$.splice(0,$.length-_),t[D]=$}if(L.includes(".data.")){let D=L.substring(0,L.indexOf(".data.")+5);C.includes(D)||C.push(D)}}if(S){const L=ht(t);e.calculative.partialOption=zE(L,e),C.forEach(M=>{let D=ms(e,M);$r(e.calculative.partialOption,M,D)})}return t}if(!t.dataX&&!t.dataY)return t;const i=e.echarts,{max:s,replaceMode:n}=i;let a=t.dataX,r=t.dataY,l=[];r&&l.push("echarts.option.series");const o=i.option.series,u=o.length,{xAxis:c,yAxis:f}=i.option;Array.isArray(c)&&c.length>1&&console.warn("echarts \u53EA\u652F\u6301\u5355 x \u8F74\uFF0C\u591A x \u8F74\u5C06\u88AB\u5FFD\u7565");const g=Array.isArray(c)?c[0]:c,v=Array.isArray(f)?f[0]:f;if(n)if(n===la.Replace){if(!g&&!v)r&&(u===1?(!Array.isArray(r)&&(r=[r]),r.forEach((y,w)=>{const m=o[0].data.find(_=>_.name===y.name);m&&(m.value=y.value)})):o.forEach((y,w)=>{Array.isArray(r[w])||(r[w]=[r[w]]),r[w].forEach((m,_)=>{const E=y.data.find(x=>x.name===m.name);E&&(E.value=m.value)})}));else if((g.type==="category"||v.type==="category")&&a&&r){const y=g.type==="category"?g.data:v.data;!Array.isArray(a)&&(a=[a]),!Array.isArray(r)&&(r=[r]),g.type==="category"?l.push("echarts.option.xAxis"):l.push("echarts.option.yAxis"),u===1?r.forEach((w,m)=>{const _=y.indexOf(a[m]);o[0].data[_]=w}):o.forEach((w,m)=>{r[m].forEach((_,E)=>{const x=y.indexOf(a[E]);w.data[x]=_})})}}else n===la.ReplaceAll&&(a&&(g.data=a,g.data.splice(0,g.data.length-s),l.push("echarts.option.xAxis")),r&&(u===1?(o[0].data=r,o[0].data.splice(0,o[0].data.length-s)):o.forEach((y,w)=>{y.data=r[w],y.data.splice(0,y.data.length-s)})));else{if(a){!Array.isArray(a)&&(a=[a]);const y=g.data;y.push(...a),y.splice(0,y.length-s),l.push("echarts.option.xAxis")}if(r)if(u===1){!Array.isArray(r)&&(r=[r]);const y=o[0].data;y.push(...r),y.splice(0,y.length-s)}else o.forEach((y,w)=>{Array.isArray(r[w])||(r[w]=[r[w]]);const m=y.data;m.push(...r[w]),m.splice(0,m.length-s)})}return e.calculative.partialOption={},l.forEach(y=>{let w=ms(e,y);$r(e.calculative.partialOption,y,w)}),delete t.dataX,delete t.dataY,Object.assign(t,{echarts:i})}function FE(e,t){var i,s;if(!e.echarts.dataMap||!t.data)return t;if(t.data){let n={};if(Array.isArray(t.data))for(const a in e.echarts.dataMap)e.echarts.dataMap.hasOwnProperty(a)&&(((i=e.echarts.timeKeys)==null?void 0:i.length)&&e.echarts.timeKeys.includes(e.echarts.dataMap[a])?n[a]=t.data.map(r=>Zl(e.echarts.timeFormat,r[e.echarts.dataMap[a]])):n[a]=t.data.map(r=>r[e.echarts.dataMap[a]]));else for(const a in e.echarts.dataMap)e.echarts.dataMap.hasOwnProperty(a)&&(((s=e.echarts.timeKeys)==null?void 0:s.length)&&e.echarts.timeKeys.includes(e.echarts.dataMap[a])?n[a]=Zl(e.echarts.timeFormat,t.data[e.echarts.dataMap[a]]):n[a]=t.data[e.echarts.dataMap[a]]);return delete t.data,Object.assign(t,n),t}}function NE(e,t,i){if(i.key!=="dataY")return;const s=e.echarts,{xAxis:n,yAxis:a}=s.option;Array.isArray(n)&&n.length>1&&console.warn("echarts \u53EA\u652F\u6301\u5355 x \u8F74\uFF0C\u591A x \u8F74\u5C06\u88AB\u5FFD\u7565");const r=Array.isArray(n)?n[0]:n,l=Array.isArray(a)?a[0]:a,o=s.option.series;if(!r&&!l){const u=[];if(Array.isArray(o)&&o.length===1)return o[0].data.forEach(c=>{const{dataId:f}=i.dataIds.find(g=>g.name===c.name);if(f){const g=t.find(v=>v.dataId===f);g&&u.push({name:c.name,value:g.value})}}),{id:e.id,dataY:u}}else if(r.type==="category"||l.type==="category"){const u=[],c=[],f=r.type==="category"?r.data:l.data;return f==null||f.forEach(g=>{const{dataId:v}=i.dataIds.find(y=>y.name===g);if(v){const y=t.find(w=>w.dataId===v);y&&(c.push(g),u.push(y.value))}}),{id:e.id,dataY:u,dataX:c}}else if(r.type==="time"){const u=[],c=+new Date;let f=!1;if(o.forEach((g,v)=>{const y=[],{dataId:w}=i.dataIds.find(m=>m.name===g.name);if(w){const m=t.find(_=>_.dataId===w);m&&(y.push([c,m.value]),f=!0)}u[v]=y}),f)u.forEach((g,v)=>{if(!g||g.length===0){const y=o[v].data[o[v].data.length-1];u[v]=[[c,y[1]]]}});else return;return{id:e.id,dataY:u.length===1?u[0]:u}}}function Ml(e){var i,s;const t=new Image;t.src=(s=(i=e.calculative.singleton)==null?void 0:i.echart)==null?void 0:s.getDataURL({pixelRatio:2}),e.calculative.img=t}function Gr(e,t){const i=ht(e);if(i.dataZoom){let s=["right","top","width","height","left","bottom"];for(let n=0;n{isNaN(a[s[n]])||(a[s[n]]*=t)})}return Xl(i,ac,t),i}function zE(e,t){const i={};return Object.keys(e).forEach(s=>{const n=s.split(".");let a=i;n.forEach((r,l)=>{const o=!isNaN(parseInt(r));if(l===6){let u=n.slice(0,7).join(".");$r(t,s,e[s]);let c=ms(t,u);a[n[l]]=c}else{if(l>6)return;if(l===n.length-1)o?(Array.isArray(a)||(a=[]),a[parseInt(r)]=e[s]):a[r]=e[s];else if(o){const u=parseInt(r);if(Array.isArray(a)||a[n[l-1]],a[u]||(a[u]={}),Array.isArray(a))for(let c=0;c=0&&(i=Number.parseFloat(i).toFixed(t)),Number.parseFloat(i)}function Bl(e){return typeof e=="number"&&Number.isFinite(e)}function WE(e){e={max:null,min:null,splitNumber:4,symmetrical:!1,deviation:!1,preferZero:!1,...e};const t=[10,15,20,25,30,40,50,60,70,80,90,100,150];let{max:i,min:s,splitNumber:n,symmetrical:a,deviation:r,preferZero:l}=e;if(!Bl(i)||!Bl(s)||i0&&(i<0?i=0:s=0);const o=(i-s)/n;let u=Math.floor(Math.log10(o)-1);u=Math.pow(10,u);const c=o/u;let f=t[0]*u,g=-1,v;for(v=0;vc){f=t[v]*u;break}let y=i,w=s;function m(E){if(y=parseInt(""+(i/E+1))*E,w=parseInt(""+(s/E-1))*E,i===0&&(y=0),s===0&&(w=0),a&&y*w<0){const x=Math.max(Math.abs(y),Math.abs(w));y=x,w=-x}}if(m(f),r)return{max:Ps(y),min:Ps(w),interval:Ps(f),splitNumber:Math.round((y-w)/f)};if(!a||y*w>0){let E;t:do{if(E=Math.round((y-w)/f),(v-g)*(E-n)<0){for(;E=t.length-1||v<=0||E===n)break;g=v,E>n?f=t[++v]*u:f=t[--v]*u,m(f)}while(E!==n)}y=Ps(y),w=Ps(w);const _=Ps((y-w)/n);return{max:y,min:w,interval:_,splitNumber:n}}function Lg(e,t){var m,_,E,x,C,S,L,M,D,$,Q,R,T,P,O,Y,Z,at,V,H,j,K,U,tt,st,et,ut,ct;const i=t.calculative.worldRect.x,s=t.calculative.worldRect.y,n=t.calculative.worldRect.width,a=t.calculative.worldRect.height;let r=t.calculative.canvas.store.data.scale,l=[];if(t.echarts)for(let ot=0;ot{y=i+(1+o/2)+(o+1)*S,w=s+n-(v[S]-u.min)/(u.max-u.min)*n;let L=i+(1+o/2)+(o+1)*(S+1),M=s+n-(v[S+1]-u.min)/(u.max-u.min)*n,D=i+(1+o/2)+(o+1)*(S-1),$=s+n-(v[S-1]-u.min)/(u.max-u.min)*n,Q=i+(1+o/2)+(o+1)*(S+2),R=s+n-(v[S+2]-u.min)/(u.max-u.min)*n;S===0?(D=i+(1+o/2)+(o+1)*S,$=s+n-(v[S]-u.min)/(u.max-u.min)*n):S===v.length-2&&(Q=i+(1+o/2)+(o+1)*(S+1),R=s+n-(v[S+1]-u.min)/(u.max-u.min)*n),f.push({x:y,y:w}),m=y+(L-D)/4,_=w+(M-$)/4,E=L-(Q-y)/4,x=M-(R-w)/4,e.bezierCurveTo(m,_,E,x,L,M)})}else for(let m=1;m{e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2*a,e.arc(m.x,m.y,4*a,0,Math.PI*2),e.stroke(),e.fill(),e.closePath()}),e.restore(),f=[]}}function Dg(e,t){if(t.xAxisData||t.data||!t.dataX&&!t.dataY)return t;const i=e.xAxisData,s=e.data,n=e.replaceMode;let a=[],r=[];return n?n===In.Replace?(t.dataX.forEach((l,o)=>{let u=i.indexOf(l);s.forEach((c,f)=>{c[u]=t.dataY[f][o]})}),a=i,r=s):n===In.ReplaceAll&&(a=t.dataX,r=t.dataY):(a=[...i,...t.dataX],s.forEach((l,o)=>{let u=[...l,...t.dataY[o]];r.push(u)})),delete t.dataX,delete t.dataY,Object.assign(t,{xAxisData:a,data:r})}function jE(e,t){var c,f;t.onBeforeValue||(t.onBeforeValue=VE);let i=t.calculative.canvas.store.data.scale;const s=t.calculative.worldRect.x,n=t.calculative.worldRect.y,a=t.calculative.worldRect.width,r=t.calculative.worldRect.height,l=!!t.echarts;t.echarts?(t.echarts.option.color||(t.echarts.option.color=["#1890ff","#2FC25B","#FACC14","#c23531","#2f4554","#61a0a8","#d48265"]),t.chartsColor=t.echarts.option.color):t.chartsColor||(t.chartsColor=["#1890ff","#2FC25B","#FACC14","#c23531","#2f4554","#61a0a8","#d48265"]);const o=l?t.echarts.option.series:t.data;let u=0;for(let g=0;gM+D.value,0):_=v.reduce((M,D)=>M+D.value,0);const E=y*parseFloat(l?v.radius[0]:t.chartsRadius[g][0])/100,x=y*parseFloat(l?v.radius[1]:t.chartsRadius[g][1])/100;if(E>x)return;let C=0,S=0;e.strokeStyle=l&&((c=v.itemStyle)==null?void 0:c.borderColor)||"#fff",e.lineWidth=(l&&((f=v.itemStyle)==null?void 0:f.borderWidth)||2)*i;const L=l?v.data:v;L.forEach((M,D)=>{var Y,Z,at,V,H,j,K,U,tt,st,et,ut,ct;S+=Math.PI*2*M.value/_,e.beginPath();let $=u+D;$>=t.chartsColor.length&&($=$%t.chartsColor.length),e.fillStyle=l?t.echarts.option.color[$]:t.chartsColor[$],e.moveTo(w+E*Math.sin(S),m-E*Math.cos(S)),e.arc(w,m,E,-Math.PI/2+S,-Math.PI/2+C,!0),e.lineTo(w+x*Math.sin(C),m-x*Math.cos(C)),e.arc(w,m,x,-Math.PI/2+C,-Math.PI/2+S),e.lineTo(w+E*Math.sin(S),m-E*Math.cos(S)),e.stroke(),e.fill(),e.closePath();let Q=(C+S)/2,R=w+(x+10*i)*Math.sin(Q),T=m-(x+10*i)*Math.cos(Q),P=e.fillStyle;v.label||(v.label={position:"outside",show:!0}),l&&["inner","inside"].includes(v.label.position)?(e.fillStyle="#ffffff",R=w+(x-E)/2*Math.sin(Q),T=m-(x-E)/2*Math.cos(Q)):l&&v.label.position=="outside",v.labelLine||(v.labelLine={show:!0}),(l&&v.labelLine.show!==!1||!l)&&(e.beginPath(),e.strokeStyle=l?t.echarts.option.color[u+D]:t.chartsColor[u+D],e.moveTo(w+x*Math.sin(Q),m-x*Math.cos(Q)),e.lineTo(R,T));let O={fontStyle:((Y=t.tickLabel)==null?void 0:Y.fontStyle)||t.calculative.fontStyle,fontWeight:((Z=t.tickLabel)==null?void 0:Z.fontWeight)||t.calculative.fontWeight,fontFamily:((at=t.tickLabel)==null?void 0:at.fontFamily)||t.calculative.fontFamily,lineHeight:((V=t.tickLabel)==null?void 0:V.lineHeight)||t.calculative.lineHeight,fontSize:(((H=t.tickLabel)==null?void 0:H.fontSize)||t.calculative.fontSize)*i};e.font=Be(O),e.textBaseline="middle",e.textAlign="center",Q>Math.PI?((l&&v.label.position==="outside"||!l)&&(e.textAlign="end"),(l&&v.labelLine.show!==!1||!l&&((U=(K=(j=t.tickLabel)==null?void 0:j.labelLine)==null?void 0:K.show)!=null?U:!0))&&e.lineTo(R-5*i,T),(l&&v.label.show!==!1||!l&&((st=(tt=t.tickLabel)==null?void 0:tt.show)!=null?st:!0))&&e.fillText(M.name,R-5*i,T)):((l&&v.label.position==="outside"||!l)&&(e.textAlign="start"),(l&&v.labelLine.show!==!1||!l)&&e.lineTo(R+5*i,T),(l&&v.label.show!==!1||!l&&((ut=(et=t.tickLabel)==null?void 0:et.show)!=null?ut:!0))&&e.fillText(M.name,R+5*i,T)),e.stroke(),e.closePath(),e.fillStyle=P,e.strokeStyle=l&&((ct=v.itemStyle)==null?void 0:ct.borderColor)||"#fff",C=S}),u+=L.length}}function VE(e,t){if(t.data||!t.dataX&&!t.dataY)return t;const i=e.data,s=e.replaceMode;let n=[];return s?s===In.Replace?(t.dataY.forEach((a,r)=>{a.forEach((l,o)=>{let u=i[r].filter(c=>c.name===l.name);u.length>0&&(u[0].value=l.value)})}),n=i):s===In.ReplaceAll&&(n=t.dataY):i.forEach((a,r)=>{let l=[...a,...t.dataY[r]];n.push(l)}),delete t.dataX,delete t.dataY,Object.assign(t,{data:n})}function qE(e,t){t.onBeforeValue||(t.onBeforeValue=Dg);let i=t.calculative.canvas.store.data.scale;const s=t.calculative.worldRect.x,n=t.calculative.worldRect.y;t.calculative.worldRect.width;const a=t.calculative.worldRect.height;let r=[];if(t.echarts&&!t.echarts.option.color&&(t.echarts.option.color=["#1890ff","#2FC25B","#FACC14","#c23531","#2f4554","#61a0a8","#d48265"]),t.echarts)for(let f=0;fa?a/2*9/10:n/2*9/10,u=i+n/2,c=s+a/2,f=t.echarts?t.echarts.option.series[0].data[0].value:t.value,g,v=t.startAngle-t.endAngle,y=t.background||"#E6EBF8";e.strokeStyle=y;let w=o/10;e.lineWidth=w,e.beginPath(),e.lineCap="round",e.arc(u,c,o,-t.startAngle/180*Math.PI,-t.endAngle/180*Math.PI),e.stroke(),e.closePath();let m=0;if(t.axisLine&&!t.isClock)for(let N=t.axisLine.length-1;N>=0;N--)t.axisLine[N][0]*(t.max-t.min).02?e.textAlign="end":G<-.02?e.textAlign="start":e.textAlign="center",rt>.02?e.textBaseline="top":rt<-.02?e.textBaseline="bottom":e.textBaseline="middle",e.fillText(UE(T*N+t.min,1),u+O*G,c-O*rt),e.fill()}e.closePath();let Y=1,Z=["value"];if(t.isClock&&(Y=3,Z=["hourvalue","minutevalue","secondvalue"]),t.isClock)for(let N=0;N0&&(X=(t.startAngle-(t[Z[N]]-t.min)/(t.max*5-t.min)*v)/180*Math.PI);let G=4/5*o;Z[N]==="hourvalue"&&(G=3/5*o),Z[N]==="minutevalue"&&(G=3.5/5*o);let rt=o*1/40;e.beginPath(),e.setLineDash([]),e.lineWidth=o/(N+1)/20,e.strokeStyle=t.color||"#999999",e.moveTo(u-rt*3*Math.cos(X),c+rt*3*Math.sin(X)),e.lineTo(u+G*Math.cos(X),c-G*Math.sin(X)),e.stroke()}else{let N=(t.startAngle-(f-t.min)/(t.max-t.min)*v)/180*Math.PI,X=4/5*o,G=o*1/40;e.beginPath(),e.setLineDash([]),e.lineWidth=2,e.fillStyle=g,e.moveTo(u-G*3*Math.cos(N),c+G*3*Math.sin(N)),e.lineTo(u+G*Math.cos(N-Math.PI/2),c-G*Math.sin(N-Math.PI/2)),e.lineTo(u+X*Math.cos(N),c-X*Math.sin(N)),e.lineTo(u+G*Math.cos(N+Math.PI/2),c-G*Math.sin(N+Math.PI/2)),e.lineTo(u-G*3*Math.cos(N),c+G*3*Math.sin(N)),e.fill()}e.beginPath(),e.textAlign="center",e.textBaseline="middle";let at={fontStyle:((et=t.titleLabel)==null?void 0:et.fontStyle)||t.calculative.fontStyle,textDecoration:((ut=t.titleLabel)==null?void 0:ut.textDecoration)||t.textDecoration,fontWeight:((ct=t.titleLabel)==null?void 0:ct.fontWeight)||t.calculative.fontWeight,fontFamily:((ot=t.titleLabel)==null?void 0:ot.fontFamily)||t.calculative.fontFamily,fontSize:(((b=t.titleLabel)==null?void 0:b.fontSize)||t.calculative.fontSize)*r,lineHeight:((k=t.titleLabel)==null?void 0:k.lineHeight)||t.calculative.lineHeight};e.font=Be(at),e.fillStyle=((I=t.titleLabel)==null?void 0:I.color)||g,t.isClock?e.fillText(("0"+parseInt(t.hourvalue)).slice(-2)+":"+("0"+parseInt(t.minutevalue)).slice(-2)+":"+("0"+parseInt(t.secondvalue)).slice(-2),u,c+o/2):e.fillText(f+" "+(t.unit||""),u,c+o/2),e.fill(),t.isClock&&(e.beginPath(),e.fillStyle=t.color||"#999999",e.strokeStyle="#ffffff",e.arc(u,c,o/20,0,Math.PI*2),e.stroke(),e.fill(),e.closePath())}function KE(e){if(e.isClock)e.clockInterval=setInterval(()=>{let t=new Date,i=t.getSeconds(),s=t.getMinutes()+i/60,n=t.getHours()%12+s/60;e.calculative.canvas.parent.setValue({id:e.id,hourvalue:n,minutevalue:s,secondvalue:i},{render:!0,doEvent:!1})},1e3);else{const t=e.value;e.value=0,e.frames=[{duration:2e3,value:t}],e.calculative.canvas.parent.startAnimate(e.id),setTimeout(()=>{e.value=t},1e3)}}function XE(e){e.clockInterval&&(clearInterval(e.clockInterval),e.clockInterval=void 0)}function GE(e){e.isClock&&(e.onDestroy(e),e.onAdd(e))}function pR(){return{lineChart:$E,histogram:qE,pieChart:jE,gauge:YE}}function ZE(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;if(i.rect(s,n,a,r),i.closePath(),i instanceof Path2D)return i}function JE(e,t){var g;const i=(g=t.headHeight)!=null?g:50,{x:s,y:n,width:a,height:r,ey:l}=t.calculative.worldRect;let o=t.calculative.borderRadius||0,u=o;t.calculative.borderRadius<1&&(o*=a,u*=r);let c=o({id:`${n}`,penId:e.id,x:i,y:s}))}function tA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r-a,o=.5*a;if(i.moveTo(s+a/2,n),i.lineTo(s+a/2,n+l),i.moveTo(s+a,n+o+l),i.arc(s+a/2,n+o+l,o,0,Math.PI*2,!1),i.closePath(),i instanceof Path2D)return i}function Vf(e){const t=[{x:.5,y:0},{x:.5,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function eA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/2,o=a/5;if(i.moveTo(s,n+l),i.lineTo(s+o,n+l),i.moveTo(s+o*5,n+l),i.ellipse(s+o*3,n+l,2*o,l,0,0,Math.PI*2),i.closePath(),i instanceof Path2D)return i}function iA(e){const t=[{x:.6,y:0},{x:1,y:.5},{x:.6,y:1},{x:0,y:.5}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function sA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/4,o=.5*a;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.moveTo(s,n+l),i.rect(s,n+l,o*2,l*2),i.moveTo(s+o,n+3*l),i.lineTo(s+o,n+4*l),i.closePath(),i instanceof Path2D)return i}function nA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/8,o=.25*a;if(i.moveTo(s+o*2,n),i.lineTo(s+o*2,n+l*2),i.lineTo(s+o*3,n+l*3),i.lineTo(s+o*3,n+l*5),i.lineTo(s+o*2,n+l*6),i.lineTo(s+o*1,n+l*5),i.lineTo(s+o*1,n+l*3),i.lineTo(s+o*2,n+l*2),i.moveTo(s+o*3,n+l*4),i.lineTo(s+o*4,n+l*4),i.moveTo(s+o*2,n+l*6),i.lineTo(s+o*2,n+l*8),i.closePath(),i instanceof Path2D)return i}function aA(e){const t=[{x:.5,y:0},{x:1,y:.5},{x:.5,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function rA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=a/2,o=r/10;if(i.moveTo(s+l,n),i.lineTo(s+l,n+o),i.moveTo(s+l,n+o),i.quadraticCurveTo(s+l*2,n+o,s+l*2,n+o*9),i.moveTo(s+l,n+o),i.quadraticCurveTo(s,n+o,s,n+o*9),i.quadraticCurveTo(s+l,n+o*6,s+l*2,n+o*9),i.moveTo(s+l,n+r*3/4),i.lineTo(s+l,n+r),i.moveTo(s+l*2/5,n+r*201/250),i.lineTo(s+l*2/5,n+r),i.moveTo(s+l*8/5,n+r*201/250),i.lineTo(s+l*8/5,n+r),i.closePath(),i instanceof Path2D)return i}function qf(e){const t=[{x:.5,y:0},{x:.2,y:1},{x:.5,y:1},{x:.8,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function oA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/6,o=a/4;if(i.moveTo(s+o*2,n+0),i.lineTo(s+o*2,n+l),i.moveTo(s,n+l+o*2),i.arc(s+o*2,n+l+o*2,o*2,Math.PI*1,Math.PI*2,!1),i.lineTo(s+o*4,n+l*5),i.lineTo(s,n+l*5),i.lineTo(s,n+l+o*2),i.moveTo(s,n+l*5-l/3),i.lineTo(s+o*4,n+l*5-l/3),i.moveTo(s+o,n+l*5),i.lineTo(s+o,n+l*6),i.moveTo(s+o*2,n+l*5),i.lineTo(s+o*2,n+l*6),i.moveTo(s+o*3,n+l*5),i.lineTo(s+o*3,n+l*6),i.closePath(),i instanceof Path2D)return i}function lA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/4,o=.5*a;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.lineTo(s+o*2,n+l*2),i.lineTo(s+o*2,n+l*4),i.lineTo(s,n+l*4),i.lineTo(s,n+l*2),i.lineTo(s+o,n+l),i.closePath(),i instanceof Path2D)return i}function cA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/4,o=a/2;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.lineTo(s+o*2,n+l*4),i.lineTo(s,n+l*4),i.lineTo(s+o,n+l),i.closePath(),i instanceof Path2D)return i}function hA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect,l=r/3,o=.5*a;if(i.moveTo(s+o,n),i.lineTo(s+o,n+l),i.lineTo(s+a,n+2*l),i.lineTo(s+o,n+r),i.lineTo(s,n+2*l),i.lineTo(s+o,n+l),i.closePath(),i instanceof Path2D)return i}function uA(e){const t=[{x:.5,y:0},{x:1,y:.6666666666666666},{x:.5,y:1},{x:0,y:.6666666666666666}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function fA(e,t){const i=t||new Path2D,{x:s,y:n,width:a,height:r}=e.calculative.worldRect;let l=a/2,o=r/10;if(i.moveTo(s+l,n),i.lineTo(s+l,n+o),i.moveTo(s+l,n+o),i.quadraticCurveTo(s+l*2,n+o,s+l*2,n+o*9),i.moveTo(s+l,n+o),i.quadraticCurveTo(s,n+o,s,n+o*9),i.quadraticCurveTo(s+l,n+o*6,s+l*2,n+o*9),i.moveTo(s,n+o*10),i.quadraticCurveTo(s+l,n+o*7,s+l*2,n+o*10),i.moveTo(s+l*2/5,n+r*201/250+o),i.lineTo(s+l*2/5,n+r),i.moveTo(s+l*8/5,n+r*201/250+o),i.lineTo(s+l*8/5,n+r),i.closePath(),i instanceof Path2D)return i}function dA(e){const t=[{x:.5,y:0},{x:.2,y:1},{x:.8,y:1}];e.anchors=t.map(({x:i,y:s},n)=>({id:`${n}`,penId:e.id,x:i,y:s}))}function gA(e,t){const{x:i,y:s,width:n,height:a}=t.calculative.worldRect,r=n/2,l=a/10;e.beginPath(),e.moveTo(i+r,s),e.lineTo(i+r,s+l),e.moveTo(i+r,s+l),e.quadraticCurveTo(i+r*2,s+l,i+r*2,s+l*9),e.moveTo(i+r,s+l),e.quadraticCurveTo(i,s+l,i,s+l*9),e.quadraticCurveTo(i+r,s+l*6,i+r*2,s+l*9),e.moveTo(i+r,s+a*3/4),e.lineTo(i+r,s+a*9/10),e.moveTo(i+r*2/5,s+a*201/250),e.lineTo(i+r*2/5,s+a*9/10),e.moveTo(i+r*8/5,s+a*201/250),e.lineTo(i+r*8/5,s+a*9/10),e.stroke(),e.closePath(),e.beginPath();const o=r*2>l*10?l:r/5;e.fillStyle="#333333",e.font=o+"px Arial",e.textBaseline="bottom",e.textAlign="center",e.fillText("o",i+r,s+a),e.fillText("m",i+r*2/5,s+a),e.fillText("o",i+r*8/5,s+a),e.closePath()}function xR(){return{andGate:QE,basicEvent:tA,conditionalEvent:eA,event:sA,forbiddenGate:nA,orGate:rA,priorityAndGate:oA,switchEvent:lA,transferSymbol:cA,unexpandedEvent:hA,xorGate:fA}}function _R(){return{votingGate:gA}}function kR(){return{andGate:jf,orGate:qf,priorityAndGate:jf,votingGate:qf,xorGate:dA,forbiddenGate:aA,basicEvent:Vf,unexpandedEvent:uA,conditionalEvent:iA,transferSymbol:Vf}}const ER={background:"#ECE5E5",color:"#fff",textColor:"#fff",anchorColor:"#f90",gridSize:30,grid:!1,gridColor:"rgba(255,255,255,0.1)",drawingLineName:"line"},AR=[{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"}],CR=["triangle","diamond","circle","lineDown","lineUp","triangleSolid","diamondSolid","circleSolid","line"],RR=["#000","#fff","#f00","#0f0","rgba(255,255,255,0.5)"],vA={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"}}]},yA={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"}}]},mA={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"}}]},TR=["time-comp"],SR=[{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:"Echarts\u56FE\u5F62",show:!0,list:[{name:"\u6298\u7EBF\u56FE",icon:"t-icon t-line-chart",data:{name:"echarts",width:400,height:300,externElement:!0,disableAnchor:!0,canDataBind:!0,echarts:{option:{grid:{top:10,bottom:30,left:40,right:50},xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]},yAxis:{type:"value"},series:[{data:[820,932,901,934,1290,1330,1320],type:"line"}]}}}},{name:"\u67F1\u72B6\u56FE",icon:"t-icon t-bar-chart",data:{width:300,height:200,disableAnchor:!0,externElement:!0,name:"echarts",canDataBind:!0,echarts:{option:{tooltip:{trigger:"axis",axisPointer:{type:"shadow"}},grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0},xAxis:{type:"category",data:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],axisTick:{alignWithLabel:!0}},yAxis:[{type:"value"}],series:[{name:"\u76F4\u63A5\u8BBF\u95EE",type:"bar",barWidth:"60%",data:[10,52,200,334,390,330,220]}]},max:100}}},{name:"\u997C\u56FE",icon:"t-icon t-pie-chart",data:{width:200,height:200,disableAnchor:!0,externElement:!0,name:"echarts",canDataBind:!1,echarts:{option:{tooltip:{trigger:"item",formatter:"{a}
{b}: {c} ({d}%)"},legend:{},series:[{name:"\u8BBF\u95EE\u6765\u6E90",type:"pie",radius:["50%","70%"],avoidLabelOverlap:!1,label:{normal:{show:!1,position:"center"},emphasis:{show:!0,textStyle:{fontSize:"30",fontWeight:"bold"}}},labelLine:{normal:{show:!1}},data:[{value:335,name:"\u76F4\u63A5\u8BBF\u95EE"},{value:310,name:"\u90AE\u4EF6\u8425\u9500"},{value:234,name:"\u8054\u76DF\u5E7F\u544A"},{value:135,name:"\u89C6\u9891\u5E7F\u544A"},{value:1548,name:"\u641C\u7D22\u5F15\u64CE"}]}]}}}},{name:"\u4EEA\u8868\u76D8",icon:"t-icon t-dashboard-chart",data:{width:300,height:300,disableAnchor:!0,externElement:!0,name:"echarts",canDataBind:!0,echarts:{option:{series:[{name:"\u4E1A\u52A1\u6307\u6807",type:"gauge",min:0,max:100,detail:{formatter:"{value}%"},data:[{value:50,name:"\u5B8C\u6210\u7387"}]}]}}}}]},{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"}}]},{...vA},{...yA},{...mA},{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 + 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 Qi={};(function(e){var t=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function i(a,r){return Object.prototype.hasOwnProperty.call(a,r)}e.assign=function(a){for(var r=Array.prototype.slice.call(arguments,1);r.length;){var l=r.shift();if(!!l){if(typeof l!="object")throw new TypeError(l+"must be non-object");for(var o in l)i(l,o)&&(a[o]=l[o])}}return a},e.shrinkBuf=function(a,r){return a.length===r?a:a.subarray?a.subarray(0,r):(a.length=r,a)};var s={arraySet:function(a,r,l,o,u){if(r.subarray&&a.subarray){a.set(r.subarray(l,l+o),u);return}for(var c=0;c=0;)e[t]=0}var xA=0,Mg=1,_A=2,kA=3,EA=258,Cc=29,Aa=256,ma=Aa+1+Cc,Cn=30,Rc=19,Bg=2*ma+1,Bs=15,Ol=16,AA=7,Tc=256,Og=16,Fg=17,Ng=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],Br=[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],CA=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],zg=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],RA=512,Vi=new Array((ma+2)*2);Dn(Vi);var ca=new Array(Cn*2);Dn(ca);var pa=new Array(RA);Dn(pa);var wa=new Array(EA-kA+1);Dn(wa);var Sc=new Array(Cc);Dn(Sc);var Zr=new Array(Cn);Dn(Zr);function Fl(e,t,i,s,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=s,this.max_length=n,this.has_stree=e&&e.length}var Hg,Wg,Ug;function Nl(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function $g(e){return e<256?pa[e]:pa[256+(e>>>7)]}function ba(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function je(e,t,i){e.bi_valid>Ol-i?(e.bi_buf|=t<>Ol-e.bi_valid,e.bi_valid+=i-Ol):(e.bi_buf|=t<>>=1,i<<=1;while(--t>0);return i>>>1}function TA(e){e.bi_valid===16?(ba(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 SA(e,t){var i=t.dyn_tree,s=t.max_code,n=t.stat_desc.static_tree,a=t.stat_desc.has_stree,r=t.stat_desc.extra_bits,l=t.stat_desc.extra_base,o=t.stat_desc.max_length,u,c,f,g,v,y,w=0;for(g=0;g<=Bs;g++)e.bl_count[g]=0;for(i[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;uo&&(g=o,w++),i[c*2+1]=g,!(c>s)&&(e.bl_count[g]++,v=0,c>=l&&(v=r[c-l]),y=i[c*2],e.opt_len+=y*(g+v),a&&(e.static_len+=y*(n[c*2+1]+v)));if(w!==0){do{for(g=o-1;e.bl_count[g]===0;)g--;e.bl_count[g]--,e.bl_count[g+1]+=2,e.bl_count[o]--,w-=2}while(w>0);for(g=o;g!==0;g--)for(c=e.bl_count[g];c!==0;)f=e.heap[--u],!(f>s)&&(i[f*2+1]!==g&&(e.opt_len+=(g-i[f*2+1])*i[f*2],i[f*2+1]=g),c--)}}function Vg(e,t,i){var s=new Array(Bs+1),n=0,a,r;for(a=1;a<=Bs;a++)s[a]=n=n+i[a-1]<<1;for(r=0;r<=t;r++){var l=e[r*2+1];l!==0&&(e[r*2]=jg(s[l]++,l))}}function PA(){var e,t,i,s,n,a=new Array(Bs+1);for(i=0,s=0;s>=7;s8?ba(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 IA(e,t,i,s){Yg(e),s&&(ba(e,i),ba(e,~i)),pA.arraySet(e.pending_buf,e.window,t,i,e.pending),e.pending+=i}function Xf(e,t,i,s){var n=t*2,a=i*2;return e[n]>1;r>=1;r--)zl(e,i,r);u=a;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],zl(e,i,1),l=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=l,i[u*2]=i[r*2]+i[l*2],e.depth[u]=(e.depth[r]>=e.depth[l]?e.depth[r]:e.depth[l])+1,i[r*2+1]=i[l*2+1]=u,e.heap[1]=u++,zl(e,i,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],SA(e,t),Vg(i,o,e.bl_count)}function Zf(e,t,i){var s,n=-1,a,r=t[0*2+1],l=0,o=7,u=4;for(r===0&&(o=138,u=3),t[(i+1)*2+1]=65535,s=0;s<=i;s++)a=r,r=t[(s+1)*2+1],!(++l=3&&e.bl_tree[zg[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function DA(e,t,i,s){var n;for(je(e,t-257,5),je(e,i-1,5),je(e,s-4,4),n=0;n>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return Yf;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Kf;for(i=32;i0?(e.strm.data_type===bA&&(e.strm.data_type=MA(e)),oc(e,e.l_desc),oc(e,e.d_desc),r=LA(e),n=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=n&&(n=a)):n=a=i+5,i+4<=n&&t!==-1?Kg(e,t,i,s):e.strategy===wA||a===n?(je(e,(Mg<<1)+(s?1:0),3),Gf(e,Vi,ca)):(je(e,(_A<<1)+(s?1:0),3),DA(e,e.l_desc.max_code+1,e.d_desc.max_code+1,r+1),Gf(e,e.dyn_ltree,e.dyn_dtree)),qg(e),s&&Yg(e)}function NA(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[(wa[i]+Aa+1)*2]++,e.dyn_dtree[$g(t)*2]++),e.last_lit===e.lit_bufsize-1}Ln._tr_init=BA;Ln._tr_stored_block=Kg;Ln._tr_flush_block=FA;Ln._tr_tally=NA;Ln._tr_align=OA;function zA(e,t,i,s){for(var n=e&65535|0,a=e>>>16&65535|0,r=0;i!==0;){r=i>2e3?2e3:i,i-=r;do n=n+t[s++]|0,a=a+n|0;while(--r);n%=65521,a%=65521}return n|a<<16|0}var Xg=zA;function HA(){for(var e,t=[],i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=e&1?3988292384^e>>>1:e>>>1;t[i]=e}return t}var WA=HA();function UA(e,t,i,s){var n=WA,a=s+i;e^=-1;for(var r=s;r>>8^n[(e^t[r])&255];return e^-1}var Gg=UA,Pc={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"},Me=Qi,fi=Ln,Zg=Xg,ds=Gg,$A=Pc,Ks=0,jA=1,VA=3,bs=4,td=5,Si=0,ed=1,di=-2,qA=-3,Hl=-5,YA=-1,KA=1,Cr=2,XA=3,GA=4,ZA=0,JA=2,eo=8,QA=9,tC=15,eC=8,iC=29,sC=256,lc=sC+1+iC,nC=30,aC=19,rC=2*lc+1,oC=15,Wt=3,ps=258,wi=ps+Wt+1,lC=32,io=42,cc=69,Or=73,Fr=91,Nr=103,Os=113,na=666,me=1,Ca=2,Us=3,Mn=4,cC=3;function ws(e,t){return e.msg=$A[t],t}function id(e){return(e<<1)-(e>4?9:0)}function ys(e){for(var t=e.length;--t>=0;)e[t]=0}function gs(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),i!==0&&(Me.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 Ce(e,t){fi._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,gs(e.strm)}function Ut(e,t){e.pending_buf[e.pending++]=t}function Qn(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function hC(e,t,i,s){var n=e.avail_in;return n>s&&(n=s),n===0?0:(e.avail_in-=n,Me.arraySet(t,e.input,e.next_in,n,i),e.state.wrap===1?e.adler=Zg(e.adler,t,n,i):e.state.wrap===2&&(e.adler=ds(e.adler,t,n,i)),e.next_in+=n,e.total_in+=n,n)}function Jg(e,t){var i=e.max_chain_length,s=e.strstart,n,a,r=e.prev_length,l=e.nice_match,o=e.strstart>e.w_size-wi?e.strstart-(e.w_size-wi):0,u=e.window,c=e.w_mask,f=e.prev,g=e.strstart+ps,v=u[s+r-1],y=u[s+r];e.prev_length>=e.good_match&&(i>>=2),l>e.lookahead&&(l=e.lookahead);do if(n=t,!(u[n+r]!==y||u[n+r-1]!==v||u[n]!==u[s]||u[++n]!==u[s+1])){s+=2,n++;do;while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&sr){if(e.match_start=t,r=a,a>=l)break;v=u[s+r-1],y=u[s+r]}}while((t=f[t&c])>o&&--i!==0);return r<=e.lookahead?r:e.lookahead}function $s(e){var t=e.w_size,i,s,n,a,r;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-wi)){Me.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,s=e.hash_size,i=s;do n=e.head[--i],e.head[i]=n>=t?n-t:0;while(--s);s=t,i=s;do n=e.prev[--i],e.prev[i]=n>=t?n-t:0;while(--s);a+=t}if(e.strm.avail_in===0)break;if(s=hC(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=s,e.lookahead+e.insert>=Wt)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if($s(e),e.lookahead===0&&t===Ks)return me;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var s=e.block_start+i;if((e.strstart===0||e.strstart>=s)&&(e.lookahead=e.strstart-s,e.strstart=s,Ce(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-wi&&(Ce(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===bs?(Ce(e,!0),e.strm.avail_out===0?Us:Mn):(e.strstart>e.block_start&&(Ce(e,!1),e.strm.avail_out===0),me)}function Wl(e,t){for(var i,s;;){if(e.lookahead=Wt&&(e.ins_h=(e.ins_h<=Wt)if(s=fi._tr_tally(e,e.strstart-e.match_start,e.match_length-Wt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Wt){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=Wt&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=Wt-1)),e.prev_length>=Wt&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-Wt,s=fi._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Wt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=n&&(e.ins_h=(e.ins_h<=Wt&&e.strstart>0&&(n=e.strstart-1,s=r[n],s===r[++n]&&s===r[++n]&&s===r[++n])){a=e.strstart+ps;do;while(s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&s===r[++n]&&ne.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Wt?(i=fi._tr_tally(e,1,e.match_length-Wt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=fi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(Ce(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===bs?(Ce(e,!0),e.strm.avail_out===0?Us:Mn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ca}function dC(e,t){for(var i;;){if(e.lookahead===0&&($s(e),e.lookahead===0)){if(t===Ks)return me;break}if(e.match_length=0,i=fi._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(Ce(e,!1),e.strm.avail_out===0))return me}return e.insert=0,t===bs?(Ce(e,!0),e.strm.avail_out===0?Us:Mn):e.last_lit&&(Ce(e,!1),e.strm.avail_out===0)?me:Ca}function Ai(e,t,i,s,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=s,this.func=n}var kn;kn=[new Ai(0,0,0,0,uC),new Ai(4,4,8,4,Wl),new Ai(4,5,16,8,Wl),new Ai(4,6,32,32,Wl),new Ai(4,4,16,16,vn),new Ai(8,16,32,32,vn),new Ai(8,16,128,128,vn),new Ai(8,32,128,256,vn),new Ai(32,128,258,1024,vn),new Ai(32,258,258,4096,vn)];function gC(e){e.window_size=2*e.w_size,ys(e.head),e.max_lazy_match=kn[e.level].max_lazy,e.good_match=kn[e.level].good_length,e.nice_match=kn[e.level].nice_length,e.max_chain_length=kn[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Wt-1,e.match_available=0,e.ins_h=0}function vC(){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=eo,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 Me.Buf16(rC*2),this.dyn_dtree=new Me.Buf16((2*nC+1)*2),this.bl_tree=new Me.Buf16((2*aC+1)*2),ys(this.dyn_ltree),ys(this.dyn_dtree),ys(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Me.Buf16(oC+1),this.heap=new Me.Buf16(2*lc+1),ys(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Me.Buf16(2*lc+1),ys(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 Qg(e){var t;return!e||!e.state?ws(e,di):(e.total_in=e.total_out=0,e.data_type=JA,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?io:Os,e.adler=t.wrap===2?0:1,t.last_flush=Ks,fi._tr_init(t),Si)}function tv(e){var t=Qg(e);return t===Si&&gC(e.state),t}function yC(e,t){return!e||!e.state||e.state.wrap!==2?di:(e.state.gzhead=t,Si)}function ev(e,t,i,s,n,a){if(!e)return di;var r=1;if(t===YA&&(t=6),s<0?(r=0,s=-s):s>15&&(r=2,s-=16),n<1||n>QA||i!==eo||s<8||s>15||t<0||t>9||a<0||a>GA)return ws(e,di);s===8&&(s=9);var l=new vC;return e.state=l,l.strm=e,l.wrap=r,l.gzhead=null,l.w_bits=s,l.w_size=1<td||t<0)return e?ws(e,di):di;if(s=e.state,!e.output||!e.input&&e.avail_in!==0||s.status===na&&t!==bs)return ws(e,e.avail_out===0?Hl:di);if(s.strm=e,i=s.last_flush,s.last_flush=t,s.status===io)if(s.wrap===2)e.adler=0,Ut(s,31),Ut(s,139),Ut(s,8),s.gzhead?(Ut(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),Ut(s,s.gzhead.time&255),Ut(s,s.gzhead.time>>8&255),Ut(s,s.gzhead.time>>16&255),Ut(s,s.gzhead.time>>24&255),Ut(s,s.level===9?2:s.strategy>=Cr||s.level<2?4:0),Ut(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length&&(Ut(s,s.gzhead.extra.length&255),Ut(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=ds(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=cc):(Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,0),Ut(s,s.level===9?2:s.strategy>=Cr||s.level<2?4:0),Ut(s,cC),s.status=Os);else{var r=eo+(s.w_bits-8<<4)<<8,l=-1;s.strategy>=Cr||s.level<2?l=0:s.level<6?l=1:s.level===6?l=2:l=3,r|=l<<6,s.strstart!==0&&(r|=lC),r+=31-r%31,s.status=Os,Qn(s,r),s.strstart!==0&&(Qn(s,e.adler>>>16),Qn(s,e.adler&65535)),e.adler=1}if(s.status===cc)if(s.gzhead.extra){for(n=s.pending;s.gzindex<(s.gzhead.extra.length&65535)&&!(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),gs(e),n=s.pending,s.pending===s.pending_buf_size));)Ut(s,s.gzhead.extra[s.gzindex]&255),s.gzindex++;s.gzhead.hcrc&&s.pending>n&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=Or)}else s.status=Or;if(s.status===Or)if(s.gzhead.name){n=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),gs(e),n=s.pending,s.pending===s.pending_buf_size)){a=1;break}s.gzindexn&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),a===0&&(s.gzindex=0,s.status=Fr)}else s.status=Fr;if(s.status===Fr)if(s.gzhead.comment){n=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),gs(e),n=s.pending,s.pending===s.pending_buf_size)){a=1;break}s.gzindexn&&(e.adler=ds(e.adler,s.pending_buf,s.pending-n,n)),a===0&&(s.status=Nr)}else s.status=Nr;if(s.status===Nr&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&gs(e),s.pending+2<=s.pending_buf_size&&(Ut(s,e.adler&255),Ut(s,e.adler>>8&255),e.adler=0,s.status=Os)):s.status=Os),s.pending!==0){if(gs(e),e.avail_out===0)return s.last_flush=-1,Si}else if(e.avail_in===0&&id(t)<=id(i)&&t!==bs)return ws(e,Hl);if(s.status===na&&e.avail_in!==0)return ws(e,Hl);if(e.avail_in!==0||s.lookahead!==0||t!==Ks&&s.status!==na){var o=s.strategy===Cr?dC(s,t):s.strategy===XA?fC(s,t):kn[s.level].func(s,t);if((o===Us||o===Mn)&&(s.status=na),o===me||o===Us)return e.avail_out===0&&(s.last_flush=-1),Si;if(o===Ca&&(t===jA?fi._tr_align(s):t!==td&&(fi._tr_stored_block(s,0,0,!1),t===VA&&(ys(s.head),s.lookahead===0&&(s.strstart=0,s.block_start=0,s.insert=0))),gs(e),e.avail_out===0))return s.last_flush=-1,Si}return t!==bs?Si:s.wrap<=0?ed:(s.wrap===2?(Ut(s,e.adler&255),Ut(s,e.adler>>8&255),Ut(s,e.adler>>16&255),Ut(s,e.adler>>24&255),Ut(s,e.total_in&255),Ut(s,e.total_in>>8&255),Ut(s,e.total_in>>16&255),Ut(s,e.total_in>>24&255)):(Qn(s,e.adler>>>16),Qn(s,e.adler&65535)),gs(e),s.wrap>0&&(s.wrap=-s.wrap),s.pending!==0?Si:ed)}function wC(e){var t;return!e||!e.state?di:(t=e.state.status,t!==io&&t!==cc&&t!==Or&&t!==Fr&&t!==Nr&&t!==Os&&t!==na?ws(e,di):(e.state=null,t===Os?ws(e,qA):Si))}function bC(e,t){var i=t.length,s,n,a,r,l,o,u,c;if(!e||!e.state||(s=e.state,r=s.wrap,r===2||r===1&&s.status!==io||s.lookahead))return di;for(r===1&&(e.adler=Zg(e.adler,t,i,0)),s.wrap=0,i>=s.w_size&&(r===0&&(ys(s.head),s.strstart=0,s.block_start=0,s.insert=0),c=new Me.Buf8(s.w_size),Me.arraySet(c,t,i-s.w_size,s.w_size,0),t=c,i=s.w_size),l=e.avail_in,o=e.next_in,u=e.input,e.avail_in=i,e.next_in=0,e.input=t,$s(s);s.lookahead>=Wt;){n=s.strstart,a=s.lookahead-(Wt-1);do s.ins_h=(s.ins_h<=252?6:hs>=248?5:hs>=240?4:hs>=224?3:hs>=192?2:1;xa[254]=xa[254]=1;Xs.string2buf=function(e){var t,i,s,n,a,r=e.length,l=0;for(n=0;n>>6,t[a++]=128|i&63):i<65536?(t[a++]=224|i>>>12,t[a++]=128|i>>>6&63,t[a++]=128|i&63):(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63,t[a++]=128|i>>>6&63,t[a++]=128|i&63);return t};function nv(e,t){if(t<65534&&(e.subarray&&sv||!e.subarray&&iv))return String.fromCharCode.apply(null,so.shrinkBuf(e,t));for(var i="",s=0;s4){l[s++]=65533,i+=a-1;continue}for(n&=a===2?31:a===3?15:7;a>1&&i1){l[s++]=65533;continue}n<65536?l[s++]=n:(n-=65536,l[s++]=55296|n>>10&1023,l[s++]=56320|n&1023)}return nv(l,s)};Xs.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+xa[e[i]]>t?i:t};function xC(){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 av=xC,ha=Ii,ua=Qi,hc=Xs,uc=Pc,_C=av,rv=Object.prototype.toString,kC=0,Ul=4,Rn=0,sd=1,nd=2,EC=-1,AC=0,CC=8;function js(e){if(!(this instanceof js))return new js(e);this.options=ua.assign({level:EC,method:CC,chunkSize:16384,windowBits:15,memLevel:8,strategy:AC,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 _C,this.strm.avail_out=0;var i=ha.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Rn)throw new Error(uc[i]);if(t.header&&ha.deflateSetHeader(this.strm,t.header),t.dictionary){var s;if(typeof t.dictionary=="string"?s=hc.string2buf(t.dictionary):rv.call(t.dictionary)==="[object ArrayBuffer]"?s=new Uint8Array(t.dictionary):s=t.dictionary,i=ha.deflateSetDictionary(this.strm,s),i!==Rn)throw new Error(uc[i]);this._dict_set=!0}}js.prototype.push=function(e,t){var i=this.strm,s=this.options.chunkSize,n,a;if(this.ended)return!1;a=t===~~t?t:t===!0?Ul:kC,typeof e=="string"?i.input=hc.string2buf(e):rv.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 ua.Buf8(s),i.next_out=0,i.avail_out=s),n=ha.deflate(i,a),n!==sd&&n!==Rn)return this.onEnd(n),this.ended=!0,!1;(i.avail_out===0||i.avail_in===0&&(a===Ul||a===nd))&&(this.options.to==="string"?this.onData(hc.buf2binstring(ua.shrinkBuf(i.output,i.next_out))):this.onData(ua.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||i.avail_out===0)&&n!==sd);return a===Ul?(n=ha.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Rn):(a===nd&&(this.onEnd(Rn),i.avail_out=0),!0)};js.prototype.onData=function(e){this.chunks.push(e)};js.prototype.onEnd=function(e){e===Rn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ua.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Ic(e,t){var i=new js(t);if(i.push(e,!0),i.err)throw i.msg||uc[i.err];return i.result}function RC(e,t){return t=t||{},t.raw=!0,Ic(e,t)}function TC(e,t){return t=t||{},t.gzip=!0,Ic(e,t)}Ea.Deflate=js;Ea.deflate=Ic;Ea.deflateRaw=RC;Ea.gzip=TC;var Ra={},bi={},Rr=30,SC=12,PC=function(t,i){var s,n,a,r,l,o,u,c,f,g,v,y,w,m,_,E,x,C,S,L,M,D,$,Q,R;s=t.state,n=t.next_in,Q=t.input,a=n+(t.avail_in-5),r=t.next_out,R=t.output,l=r-(i-t.avail_out),o=r+(t.avail_out-257),u=s.dmax,c=s.wsize,f=s.whave,g=s.wnext,v=s.window,y=s.hold,w=s.bits,m=s.lencode,_=s.distcode,E=(1<>>24,y>>>=S,w-=S,S=C>>>16&255,S===0)R[r++]=C&65535;else if(S&16){L=C&65535,S&=15,S&&(w>>=S,w-=S),w<15&&(y+=Q[n++]<>>24,y>>>=S,w-=S,S=C>>>16&255,S&16){if(M=C&65535,S&=15,wu){t.msg="invalid distance too far back",s.mode=Rr;break t}if(y>>>=S,w-=S,S=r-l,M>S){if(S=M-S,S>f&&s.sane){t.msg="invalid distance too far back",s.mode=Rr;break t}if(D=0,$=v,g===0){if(D+=c-S,S2;)R[r++]=$[D++],R[r++]=$[D++],R[r++]=$[D++],L-=3;L&&(R[r++]=$[D++],L>1&&(R[r++]=$[D++]))}else{D=r-M;do R[r++]=R[D++],R[r++]=R[D++],R[r++]=R[D++],L-=3;while(L>2);L&&(R[r++]=R[D++],L>1&&(R[r++]=R[D++]))}}else if((S&64)===0){C=_[(C&65535)+(y&(1<>3,n-=L,w-=L<<3,y&=(1<=1&&T[v]===0;v--);if(y>v&&(y=v),v===0)return a[r++]=1<<24|64<<16|0,a[r++]=1<<24|64<<16|0,o.bits=1,0;for(g=1;g0&&(t===ld||v!==1))return-1;for(P[1]=0,c=1;crd||t===cd&&E>od)return 1;for(;;){Z=c-m,l[f]R?(at=O[Y+l[f]],V=$[Q+l[f]]):(at=32+64,V=0),C=1<>m)+S]=Z<<24|at<<16|V|0;while(S!==0);for(C=1<>=1;if(C!==0?(x&=C-1,x+=C):x=0,f++,--T[c]===0){if(c===v)break;c=i[s+l[f]]}if(c>y&&(x&M)!==L){for(m===0&&(m=y),D+=g,w=c-m,_=1<rd||t===cd&&E>od)return 1;L=x&M,a[L]=y<<24|w<<16|D-r|0}}return x!==0&&(a[D+x]=c-m<<24|64<<16|0),o.bits=y,0},ei=Qi,fc=Xg,Ci=Gg,OC=PC,fa=BC,FC=0,ov=1,lv=2,hd=4,NC=5,Tr=6,Vs=0,zC=1,HC=2,gi=-2,cv=-3,hv=-4,WC=-5,ud=8,uv=1,fd=2,dd=3,gd=4,vd=5,yd=6,md=7,pd=8,wd=9,bd=10,Jr=11,Wi=12,jl=13,xd=14,Vl=15,_d=16,kd=17,Ed=18,Ad=19,Sr=20,Pr=21,Cd=22,Rd=23,Td=24,Sd=25,Pd=26,ql=27,Id=28,Ld=29,ae=30,fv=31,UC=32,$C=852,jC=592,VC=15,qC=VC;function Dd(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function YC(){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 ei.Buf16(320),this.work=new ei.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function dv(e){var t;return!e||!e.state?gi:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=uv,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new ei.Buf32($C),t.distcode=t.distdyn=new ei.Buf32(jC),t.sane=1,t.back=-1,Vs)}function gv(e){var t;return!e||!e.state?gi:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,dv(e))}function vv(e,t){var i,s;return!e||!e.state||(s=e.state,t<0?(i=0,t=-t):(i=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?gi:(s.window!==null&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,gv(e))}function yv(e,t){var i,s;return e?(s=new YC,e.state=s,s.window=null,i=vv(e,t),i!==Vs&&(e.state=null),i):gi}function KC(e){return yv(e,qC)}var Md=!0,Yl,Kl;function XC(e){if(Md){var t;for(Yl=new ei.Buf32(512),Kl=new ei.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(fa(ov,e.lens,0,288,Yl,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;fa(lv,e.lens,0,32,Kl,0,e.work,{bits:5}),Md=!1}e.lencode=Yl,e.lenbits=9,e.distcode=Kl,e.distbits=5}function mv(e,t,i,s){var n,a=e.state;return a.window===null&&(a.wsize=1<=a.wsize?(ei.arraySet(a.window,t,i-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>s&&(n=s),ei.arraySet(a.window,t,i-s,n,a.wnext),s-=n,s?(ei.arraySet(a.window,t,i-s,s,0),a.wnext=s,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,i.check=Ci(i.check,$,2,0),u=0,c=0,i.mode=fd;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=ae;break}if((u&15)!==ud){e.msg="unknown compression method",i.mode=ae;break}if(u>>>=4,c-=4,M=(u&15)+8,i.wbits===0)i.wbits=M;else if(M>i.wbits){e.msg="invalid window size",i.mode=ae;break}i.dmax=1<>8&1),i.flags&512&&($[0]=u&255,$[1]=u>>>8&255,i.check=Ci(i.check,$,2,0)),u=0,c=0,i.mode=dd;case dd:for(;c<32;){if(l===0)break t;l--,u+=s[a++]<>>8&255,$[2]=u>>>16&255,$[3]=u>>>24&255,i.check=Ci(i.check,$,4,0)),u=0,c=0,i.mode=gd;case gd:for(;c<16;){if(l===0)break t;l--,u+=s[a++]<>8),i.flags&512&&($[0]=u&255,$[1]=u>>>8&255,i.check=Ci(i.check,$,2,0)),u=0,c=0,i.mode=vd;case vd:if(i.flags&1024){for(;c<16;){if(l===0)break t;l--,u+=s[a++]<>>8&255,i.check=Ci(i.check,$,2,0)),u=0,c=0}else i.head&&(i.head.extra=null);i.mode=yd;case yd:if(i.flags&1024&&(v=i.length,v>l&&(v=l),v&&(i.head&&(M=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),ei.arraySet(i.head.extra,s,a,v,M)),i.flags&512&&(i.check=Ci(i.check,s,v,a)),l-=v,a+=v,i.length-=v),i.length))break t;i.length=0,i.mode=md;case md:if(i.flags&2048){if(l===0)break t;v=0;do M=s[a+v++],i.head&&M&&i.length<65536&&(i.head.name+=String.fromCharCode(M));while(M&&v>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Wi;break;case bd:for(;c<32;){if(l===0)break t;l--,u+=s[a++]<>>=c&7,c-=c&7,i.mode=ql;break}for(;c<3;){if(l===0)break t;l--,u+=s[a++]<>>=1,c-=1,u&3){case 0:i.mode=xd;break;case 1:if(XC(i),i.mode=Sr,t===Tr){u>>>=2,c-=2;break t}break;case 2:i.mode=kd;break;case 3:e.msg="invalid block type",i.mode=ae}u>>>=2,c-=2;break;case xd:for(u>>>=c&7,c-=c&7;c<32;){if(l===0)break t;l--,u+=s[a++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=ae;break}if(i.length=u&65535,u=0,c=0,i.mode=Vl,t===Tr)break t;case Vl:i.mode=_d;case _d:if(v=i.length,v){if(v>l&&(v=l),v>o&&(v=o),v===0)break t;ei.arraySet(n,s,a,v,r),l-=v,a+=v,o-=v,r+=v,i.length-=v;break}i.mode=Wi;break;case kd:for(;c<14;){if(l===0)break t;l--,u+=s[a++]<>>=5,c-=5,i.ndist=(u&31)+1,u>>>=5,c-=5,i.ncode=(u&15)+4,u>>>=4,c-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=ae;break}i.have=0,i.mode=Ed;case Ed:for(;i.have>>=3,c-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,Q={bits:i.lenbits},D=fa(FC,i.lens,0,19,i.lencode,0,i.work,Q),i.lenbits=Q.bits,D){e.msg="invalid code lengths set",i.mode=ae;break}i.have=0,i.mode=Ad;case Ad:for(;i.have>>24,E=m>>>16&255,x=m&65535,!(_<=c);){if(l===0)break t;l--,u+=s[a++]<>>=_,c-=_,i.lens[i.have++]=x;else{if(x===16){for(R=_+2;c>>=_,c-=_,i.have===0){e.msg="invalid bit length repeat",i.mode=ae;break}M=i.lens[i.have-1],v=3+(u&3),u>>>=2,c-=2}else if(x===17){for(R=_+3;c>>=_,c-=_,M=0,v=3+(u&7),u>>>=3,c-=3}else{for(R=_+7;c>>=_,c-=_,M=0,v=11+(u&127),u>>>=7,c-=7}if(i.have+v>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=ae;break}for(;v--;)i.lens[i.have++]=M}}if(i.mode===ae)break;if(i.lens[256]===0){e.msg="invalid code -- missing end-of-block",i.mode=ae;break}if(i.lenbits=9,Q={bits:i.lenbits},D=fa(ov,i.lens,0,i.nlen,i.lencode,0,i.work,Q),i.lenbits=Q.bits,D){e.msg="invalid literal/lengths set",i.mode=ae;break}if(i.distbits=6,i.distcode=i.distdyn,Q={bits:i.distbits},D=fa(lv,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,Q),i.distbits=Q.bits,D){e.msg="invalid distances set",i.mode=ae;break}if(i.mode=Sr,t===Tr)break t;case Sr:i.mode=Pr;case Pr:if(l>=6&&o>=258){e.next_out=r,e.avail_out=o,e.next_in=a,e.avail_in=l,i.hold=u,i.bits=c,OC(e,g),r=e.next_out,n=e.output,o=e.avail_out,a=e.next_in,s=e.input,l=e.avail_in,u=i.hold,c=i.bits,i.mode===Wi&&(i.back=-1);break}for(i.back=0;m=i.lencode[u&(1<>>24,E=m>>>16&255,x=m&65535,!(_<=c);){if(l===0)break t;l--,u+=s[a++]<>C)],_=m>>>24,E=m>>>16&255,x=m&65535,!(C+_<=c);){if(l===0)break t;l--,u+=s[a++]<>>=C,c-=C,i.back+=C}if(u>>>=_,c-=_,i.back+=_,i.length=x,E===0){i.mode=Pd;break}if(E&32){i.back=-1,i.mode=Wi;break}if(E&64){e.msg="invalid literal/length code",i.mode=ae;break}i.extra=E&15,i.mode=Cd;case Cd:if(i.extra){for(R=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=Rd;case Rd:for(;m=i.distcode[u&(1<>>24,E=m>>>16&255,x=m&65535,!(_<=c);){if(l===0)break t;l--,u+=s[a++]<>C)],_=m>>>24,E=m>>>16&255,x=m&65535,!(C+_<=c);){if(l===0)break t;l--,u+=s[a++]<>>=C,c-=C,i.back+=C}if(u>>>=_,c-=_,i.back+=_,E&64){e.msg="invalid distance code",i.mode=ae;break}i.offset=x,i.extra=E&15,i.mode=Td;case Td:if(i.extra){for(R=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=ae;break}i.mode=Sd;case Sd:if(o===0)break t;if(v=g-o,i.offset>v){if(v=i.offset-v,v>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=ae;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=n,y=r-i.offset,v=i.length;v>o&&(v=o),o-=v,i.length-=v;do n[r++]=w[y++];while(--v);i.length===0&&(i.mode=Pr);break;case Pd:if(o===0)break t;n[r++]=i.length,o--,i.mode=Pr;break;case ql:if(i.wrap){for(;c<32;){if(l===0)break t;l--,u|=s[a++]<=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 iR,this.strm.avail_out=0;var i=Tn.inflateInit2(this.strm,t.windowBits);if(i!==de.Z_OK)throw new Error(dc[i]);if(this.header=new sR,Tn.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=zr.string2buf(t.dictionary):wv.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Tn.inflateSetDictionary(this.strm,t.dictionary),i!==de.Z_OK)))throw new Error(dc[i])}qs.prototype.push=function(e,t){var i=this.strm,s=this.options.chunkSize,n=this.options.dictionary,a,r,l,o,u,c=!1;if(this.ended)return!1;r=t===~~t?t:t===!0?de.Z_FINISH:de.Z_NO_FLUSH,typeof e=="string"?i.input=zr.binstring2buf(e):wv.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 da.Buf8(s),i.next_out=0,i.avail_out=s),a=Tn.inflate(i,de.Z_NO_FLUSH),a===de.Z_NEED_DICT&&n&&(a=Tn.inflateSetDictionary(this.strm,n)),a===de.Z_BUF_ERROR&&c===!0&&(a=de.Z_OK,c=!1),a!==de.Z_STREAM_END&&a!==de.Z_OK)return this.onEnd(a),this.ended=!0,!1;i.next_out&&(i.avail_out===0||a===de.Z_STREAM_END||i.avail_in===0&&(r===de.Z_FINISH||r===de.Z_SYNC_FLUSH))&&(this.options.to==="string"?(l=zr.utf8border(i.output,i.next_out),o=i.next_out-l,u=zr.buf2string(i.output,l),i.next_out=o,i.avail_out=s-o,o&&da.arraySet(i.output,i.output,l,o,0),this.onData(u)):this.onData(da.shrinkBuf(i.output,i.next_out))),i.avail_in===0&&i.avail_out===0&&(c=!0)}while((i.avail_in>0||i.avail_out===0)&&a!==de.Z_STREAM_END);return a===de.Z_STREAM_END&&(r=de.Z_FINISH),r===de.Z_FINISH?(a=Tn.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===de.Z_OK):(r===de.Z_SYNC_FLUSH&&(this.onEnd(de.Z_OK),i.avail_out=0),!0)};qs.prototype.onData=function(e){this.chunks.push(e)};qs.prototype.onEnd=function(e){e===de.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=da.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Lc(e,t){var i=new qs(t);if(i.push(e,!0),i.err)throw i.msg||dc[i.err];return i.result}function nR(e,t){return t=t||{},t.raw=!0,Lc(e,t)}Ra.Inflate=qs;Ra.inflate=Lc;Ra.inflateRaw=nR;Ra.ungzip=Lc;var aR=Qi.assign,rR=Ea,oR=Ra,lR=pv,bv={};aR(bv,rR,oR,lR);var PR=bv,gc={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */(function(e,t){(function(){var i,s="4.17.21",n=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",r="Expected a function",l="Invalid `variable` option passed into `_.template`",o="__lodash_hash_undefined__",u=500,c="__lodash_placeholder__",f=1,g=2,v=4,y=1,w=2,m=1,_=2,E=4,x=8,C=16,S=32,L=64,M=128,D=256,$=512,Q=30,R="...",T=800,P=16,O=1,Y=2,Z=3,at=1/0,V=9007199254740991,H=17976931348623157e292,j=0/0,K=4294967295,U=K-1,tt=K>>>1,st=[["ary",M],["bind",m],["bindKey",_],["curry",x],["curryRight",C],["flip",$],["partial",S],["partialRight",L],["rearg",D]],et="[object Arguments]",ut="[object Array]",ct="[object AsyncFunction]",ot="[object Boolean]",b="[object Date]",k="[object DOMException]",I="[object Error]",N="[object Function]",X="[object GeneratorFunction]",G="[object Map]",rt="[object Number]",mt="[object Null]",yt="[object Object]",Et="[object Promise]",Tt="[object Proxy]",be="[object RegExp]",se="[object Set]",xe="[object String]",Vt="[object Symbol]",te="[object Undefined]",xi="[object WeakMap]",xv="[object WeakSet]",Bn="[object ArrayBuffer]",Gs="[object DataView]",no="[object Float32Array]",ao="[object Float64Array]",ro="[object Int8Array]",oo="[object Int16Array]",lo="[object Int32Array]",co="[object Uint8Array]",ho="[object Uint8ClampedArray]",uo="[object Uint16Array]",fo="[object Uint32Array]",_v=/\b__p \+= '';/g,kv=/\b(__p \+=) '' \+/g,Ev=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Dc=/&(?:amp|lt|gt|quot|#39);/g,Mc=/[&<>"']/g,Av=RegExp(Dc.source),Cv=RegExp(Mc.source),Rv=/<%-([\s\S]+?)%>/g,Tv=/<%([\s\S]+?)%>/g,Bc=/<%=([\s\S]+?)%>/g,Sv=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pv=/^\w*$/,Iv=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,go=/[\\^$.*+?()[\]{}|]/g,Lv=RegExp(go.source),vo=/^\s+/,Dv=/\s/,Mv=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bv=/\{\n\/\* \[wrapped with (.+)\] \*/,Ov=/,? & /,Fv=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Nv=/[()=,{}\[\]\/\s]/,zv=/\\(\\)?/g,Hv=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Oc=/\w*$/,Wv=/^[-+]0x[0-9a-f]+$/i,Uv=/^0b[01]+$/i,$v=/^\[object .+?Constructor\]$/,jv=/^0o[0-7]+$/i,Vv=/^(?:0|[1-9]\d*)$/,qv=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ta=/($^)/,Yv=/['\n\r\u2028\u2029\\]/g,Sa="\\ud800-\\udfff",Kv="\\u0300-\\u036f",Xv="\\ufe20-\\ufe2f",Gv="\\u20d0-\\u20ff",Fc=Kv+Xv+Gv,Nc="\\u2700-\\u27bf",zc="a-z\\xdf-\\xf6\\xf8-\\xff",Zv="\\xac\\xb1\\xd7\\xf7",Jv="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Qv="\\u2000-\\u206f",ty=" \\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",Hc="A-Z\\xc0-\\xd6\\xd8-\\xde",Wc="\\ufe0e\\ufe0f",Uc=Zv+Jv+Qv+ty,yo="['\u2019]",ey="["+Sa+"]",$c="["+Uc+"]",Pa="["+Fc+"]",jc="\\d+",iy="["+Nc+"]",Vc="["+zc+"]",qc="[^"+Sa+Uc+jc+Nc+zc+Hc+"]",mo="\\ud83c[\\udffb-\\udfff]",sy="(?:"+Pa+"|"+mo+")",Yc="[^"+Sa+"]",po="(?:\\ud83c[\\udde6-\\uddff]){2}",wo="[\\ud800-\\udbff][\\udc00-\\udfff]",Zs="["+Hc+"]",Kc="\\u200d",Xc="(?:"+Vc+"|"+qc+")",ny="(?:"+Zs+"|"+qc+")",Gc="(?:"+yo+"(?:d|ll|m|re|s|t|ve))?",Zc="(?:"+yo+"(?:D|LL|M|RE|S|T|VE))?",Jc=sy+"?",Qc="["+Wc+"]?",ay="(?:"+Kc+"(?:"+[Yc,po,wo].join("|")+")"+Qc+Jc+")*",ry="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",oy="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",th=Qc+Jc+ay,ly="(?:"+[iy,po,wo].join("|")+")"+th,cy="(?:"+[Yc+Pa+"?",Pa,po,wo,ey].join("|")+")",hy=RegExp(yo,"g"),uy=RegExp(Pa,"g"),bo=RegExp(mo+"(?="+mo+")|"+cy+th,"g"),fy=RegExp([Zs+"?"+Vc+"+"+Gc+"(?="+[$c,Zs,"$"].join("|")+")",ny+"+"+Zc+"(?="+[$c,Zs+Xc,"$"].join("|")+")",Zs+"?"+Xc+"+"+Gc,Zs+"+"+Zc,oy,ry,jc,ly].join("|"),"g"),dy=RegExp("["+Kc+Sa+Fc+Wc+"]"),gy=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,vy=["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"],yy=-1,ie={};ie[no]=ie[ao]=ie[ro]=ie[oo]=ie[lo]=ie[co]=ie[ho]=ie[uo]=ie[fo]=!0,ie[et]=ie[ut]=ie[Bn]=ie[ot]=ie[Gs]=ie[b]=ie[I]=ie[N]=ie[G]=ie[rt]=ie[yt]=ie[be]=ie[se]=ie[xe]=ie[xi]=!1;var ee={};ee[et]=ee[ut]=ee[Bn]=ee[Gs]=ee[ot]=ee[b]=ee[no]=ee[ao]=ee[ro]=ee[oo]=ee[lo]=ee[G]=ee[rt]=ee[yt]=ee[be]=ee[se]=ee[xe]=ee[Vt]=ee[co]=ee[ho]=ee[uo]=ee[fo]=!0,ee[I]=ee[N]=ee[xi]=!1;var my={\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"},py={"&":"&","<":"<",">":">",'"':""","'":"'"},wy={"&":"&","<":"<",">":">",""":'"',"'":"'"},by={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xy=parseFloat,_y=parseInt,eh=typeof De=="object"&&De&&De.Object===Object&&De,ky=typeof self=="object"&&self&&self.Object===Object&&self,_e=eh||ky||Function("return this")(),xo=t&&!t.nodeType&&t,xs=xo&&!0&&e&&!e.nodeType&&e,ih=xs&&xs.exports===xo,_o=ih&&eh.process,ii=function(){try{var it=xs&&xs.require&&xs.require("util").types;return it||_o&&_o.binding&&_o.binding("util")}catch{}}(),sh=ii&&ii.isArrayBuffer,nh=ii&&ii.isDate,ah=ii&&ii.isMap,rh=ii&&ii.isRegExp,oh=ii&&ii.isSet,lh=ii&&ii.isTypedArray;function qe(it,ft,lt){switch(lt.length){case 0:return it.call(ft);case 1:return it.call(ft,lt[0]);case 2:return it.call(ft,lt[0],lt[1]);case 3:return it.call(ft,lt[0],lt[1],lt[2])}return it.apply(ft,lt)}function Ey(it,ft,lt,wt){for(var St=-1,qt=it==null?0:it.length;++St-1}function ko(it,ft,lt){for(var wt=-1,St=it==null?0:it.length;++wt-1;);return lt}function yh(it,ft){for(var lt=it.length;lt--&&Js(ft,it[lt],0)>-1;);return lt}function Dy(it,ft){for(var lt=it.length,wt=0;lt--;)it[lt]===ft&&++wt;return wt}var My=Ro(my),By=Ro(py);function Oy(it){return"\\"+by[it]}function Fy(it,ft){return it==null?i:it[ft]}function Qs(it){return dy.test(it)}function Ny(it){return gy.test(it)}function zy(it){for(var ft,lt=[];!(ft=it.next()).done;)lt.push(ft.value);return lt}function Io(it){var ft=-1,lt=Array(it.size);return it.forEach(function(wt,St){lt[++ft]=[St,wt]}),lt}function mh(it,ft){return function(lt){return it(ft(lt))}}function is(it,ft){for(var lt=-1,wt=it.length,St=0,qt=[];++lt-1}function C0(h,d){var p=this.__data__,A=Ka(p,h);return A<0?(++this.size,p.push([h,d])):p[A][1]=d,this}Li.prototype.clear=_0,Li.prototype.delete=k0,Li.prototype.get=E0,Li.prototype.has=A0,Li.prototype.set=C0;function Di(h){var d=-1,p=h==null?0:h.length;for(this.clear();++d=d?h:d)),h}function ri(h,d,p,A,B,z){var q,J=d&f,nt=d&g,dt=d&v;if(p&&(q=B?p(h,A,B,z):p(h)),q!==i)return q;if(!oe(h))return h;var gt=Pt(h);if(gt){if(q=Pm(h),!J)return Oe(h,q)}else{var vt=Se(h),pt=vt==N||vt==X;if(ls(h))return Qh(h,J);if(vt==yt||vt==et||pt&&!B){if(q=nt||pt?{}:pu(h),!J)return nt?wm(h,U0(q,h)):pm(h,Sh(q,h))}else{if(!ee[vt])return B?h:{};q=Im(h,vt,J)}}z||(z=new yi);var _t=z.get(h);if(_t)return _t;z.set(h,q),Yu(h)?h.forEach(function(Rt){q.add(ri(Rt,d,p,Rt,h,z))}):Vu(h)&&h.forEach(function(Rt,Ft){q.set(Ft,ri(Rt,d,p,Ft,h,z))});var Ct=dt?nt?sl:il:nt?Ne:pe,Mt=gt?i:Ct(h);return si(Mt||h,function(Rt,Ft){Mt&&(Ft=Rt,Rt=h[Ft]),Un(q,Ft,ri(Rt,d,p,Ft,h,z))}),q}function $0(h){var d=pe(h);return function(p){return Ph(p,h,d)}}function Ph(h,d,p){var A=p.length;if(h==null)return!A;for(h=Zt(h);A--;){var B=p[A],z=d[B],q=h[B];if(q===i&&!(B in h)||!z(q))return!1}return!0}function Ih(h,d,p){if(typeof h!="function")throw new ni(r);return Xn(function(){h.apply(i,p)},d)}function $n(h,d,p,A){var B=-1,z=Ia,q=!0,J=h.length,nt=[],dt=d.length;if(!J)return nt;p&&(d=ne(d,Ye(p))),A?(z=ko,q=!1):d.length>=n&&(z=On,q=!1,d=new Es(d));t:for(;++BB?0:B+p),A=A===i||A>B?B:Dt(A),A<0&&(A+=B),A=p>A?0:Xu(A);p0&&p(J)?d>1?ke(J,d-1,p,A,B):es(B,J):A||(B[B.length]=J)}return B}var No=au(),Mh=au(!0);function _i(h,d){return h&&No(h,d,pe)}function zo(h,d){return h&&Mh(h,d,pe)}function Ga(h,d){return ts(d,function(p){return Ni(h[p])})}function Cs(h,d){d=rs(d,h);for(var p=0,A=d.length;h!=null&&pd}function q0(h,d){return h!=null&&Xt.call(h,d)}function Y0(h,d){return h!=null&&d in Zt(h)}function K0(h,d,p){return h>=Te(d,p)&&h=120&>.length>=120)?new Es(q&>):i}gt=h[0];var vt=-1,pt=J[0];t:for(;++vt-1;)J!==h&&Wa.call(J,nt,1),Wa.call(h,nt,1);return h}function Vh(h,d){for(var p=h?d.length:0,A=p-1;p--;){var B=d[p];if(p==A||B!==z){var z=B;Fi(B)?Wa.call(h,B,1):Xo(h,B)}}return h}function qo(h,d){return h+ja(Ah()*(d-h+1))}function om(h,d,p,A){for(var B=-1,z=ye($a((d-h)/(p||1)),0),q=lt(z);z--;)q[A?z:++B]=h,h+=p;return q}function Yo(h,d){var p="";if(!h||d<1||d>V)return p;do d%2&&(p+=h),d=ja(d/2),d&&(h+=h);while(d);return p}function Bt(h,d){return hl(xu(h,d,ze),h+"")}function lm(h){return Th(un(h))}function cm(h,d){var p=un(h);return or(p,As(d,0,p.length))}function qn(h,d,p,A){if(!oe(h))return h;d=rs(d,h);for(var B=-1,z=d.length,q=z-1,J=h;J!=null&&++BB?0:B+d),p=p>B?B:p,p<0&&(p+=B),B=d>p?0:p-d>>>0,d>>>=0;for(var z=lt(B);++A>>1,q=h[z];q!==null&&!Xe(q)&&(p?q<=d:q=n){var dt=d?null:km(h);if(dt)return Da(dt);q=!1,B=On,nt=new Es}else nt=d?[]:J;t:for(;++A=A?h:oi(h,d,p)}var Jh=t0||function(h){return _e.clearTimeout(h)};function Qh(h,d){if(d)return h.slice();var p=h.length,A=bh?bh(p):new h.constructor(p);return h.copy(A),A}function Qo(h){var d=new h.constructor(h.byteLength);return new za(d).set(new za(h)),d}function gm(h,d){var p=d?Qo(h.buffer):h.buffer;return new h.constructor(p,h.byteOffset,h.byteLength)}function vm(h){var d=new h.constructor(h.source,Oc.exec(h));return d.lastIndex=h.lastIndex,d}function ym(h){return Wn?Zt(Wn.call(h)):{}}function tu(h,d){var p=d?Qo(h.buffer):h.buffer;return new h.constructor(p,h.byteOffset,h.length)}function eu(h,d){if(h!==d){var p=h!==i,A=h===null,B=h===h,z=Xe(h),q=d!==i,J=d===null,nt=d===d,dt=Xe(d);if(!J&&!dt&&!z&&h>d||z&&q&&nt&&!J&&!dt||A&&q&&nt||!p&&nt||!B)return 1;if(!A&&!z&&!dt&&h=J)return nt;var dt=p[A];return nt*(dt=="desc"?-1:1)}}return h.index-d.index}function iu(h,d,p,A){for(var B=-1,z=h.length,q=p.length,J=-1,nt=d.length,dt=ye(z-q,0),gt=lt(nt+dt),vt=!A;++J1?p[B-1]:i,q=B>2?p[2]:i;for(z=h.length>3&&typeof z=="function"?(B--,z):i,q&&Ie(p[0],p[1],q)&&(z=B<3?i:z,B=1),d=Zt(d);++A-1?B[z?d[q]:q]:i}}function lu(h){return Oi(function(d){var p=d.length,A=p,B=ai.prototype.thru;for(h&&d.reverse();A--;){var z=d[A];if(typeof z!="function")throw new ni(r);if(B&&!q&&ar(z)=="wrapper")var q=new ai([],!0)}for(A=q?A:p;++A1&&Ht.reverse(),gt&&ntJ))return!1;var dt=z.get(h),gt=z.get(d);if(dt&>)return dt==d&>==h;var vt=-1,pt=!0,_t=p&w?new Es:i;for(z.set(h,d),z.set(d,h);++vt1?"& ":"")+d[A],d=d.join(p>2?", ":" "),h.replace(Mv,`{ /* [wrapped with `+d+`] */ `)}function Dm(h){return Pt(h)||Ss(h)||!!(kh&&h&&h[kh])}function Fi(h,d){var p=typeof h;return d=d==null?V:d,!!d&&(p=="number"||p!="symbol"&&Vv.test(h))&&h>-1&&h%1==0&&h0){if(++d>=T)return arguments[0]}else d=0;return h.apply(i,arguments)}}function or(h,d){var p=-1,A=h.length,B=A-1;for(d=d===i?A:d;++p1?h[d-1]:i;return p=typeof p=="function"?(h.pop(),p):i,Du(h,p)});function Mu(h){var d=F(h);return d.__chain__=!0,d}function jp(h,d){return d(h),h}function lr(h,d){return d(h)}var Vp=Oi(function(h){var d=h.length,p=d?h[0]:0,A=this.__wrapped__,B=function(z){return Fo(z,h)};return d>1||this.__actions__.length||!(A instanceof Nt)||!Fi(p)?this.thru(B):(A=A.slice(p,+p+(d?1:0)),A.__actions__.push({func:lr,args:[B],thisArg:i}),new ai(A,this.__chain__).thru(function(z){return d&&!z.length&&z.push(i),z}))});function qp(){return Mu(this)}function Yp(){return new ai(this.value(),this.__chain__)}function Kp(){this.__values__===i&&(this.__values__=Ku(this.value()));var h=this.__index__>=this.__values__.length,d=h?i:this.__values__[this.__index__++];return{done:h,value:d}}function Xp(){return this}function Gp(h){for(var d,p=this;p instanceof Ya;){var A=Ru(p);A.__index__=0,A.__values__=i,d?B.__wrapped__=A:d=A;var B=A;p=p.__wrapped__}return B.__wrapped__=h,d}function Zp(){var h=this.__wrapped__;if(h instanceof Nt){var d=h;return this.__actions__.length&&(d=new Nt(this)),d=d.reverse(),d.__actions__.push({func:lr,args:[ul],thisArg:i}),new ai(d,this.__chain__)}return this.thru(ul)}function Jp(){return Gh(this.__wrapped__,this.__actions__)}var Qp=tr(function(h,d,p){Xt.call(h,p)?++h[p]:Mi(h,p,1)});function tw(h,d,p){var A=Pt(h)?ch:j0;return p&&Ie(h,d,p)&&(d=i),A(h,At(d,3))}function ew(h,d){var p=Pt(h)?ts:Dh;return p(h,At(d,3))}var iw=ou(Tu),sw=ou(Su);function nw(h,d){return ke(cr(h,d),1)}function aw(h,d){return ke(cr(h,d),at)}function rw(h,d,p){return p=p===i?1:Dt(p),ke(cr(h,d),p)}function Bu(h,d){var p=Pt(h)?si:ns;return p(h,At(d,3))}function Ou(h,d){var p=Pt(h)?Ay:Lh;return p(h,At(d,3))}var ow=tr(function(h,d,p){Xt.call(h,p)?h[p].push(d):Mi(h,p,[d])});function lw(h,d,p,A){h=Fe(h)?h:un(h),p=p&&!A?Dt(p):0;var B=h.length;return p<0&&(p=ye(B+p,0)),gr(h)?p<=B&&h.indexOf(d,p)>-1:!!B&&Js(h,d,p)>-1}var cw=Bt(function(h,d,p){var A=-1,B=typeof d=="function",z=Fe(h)?lt(h.length):[];return ns(h,function(q){z[++A]=B?qe(d,q,p):jn(q,d,p)}),z}),hw=tr(function(h,d,p){Mi(h,p,d)});function cr(h,d){var p=Pt(h)?ne:zh;return p(h,At(d,3))}function uw(h,d,p,A){return h==null?[]:(Pt(d)||(d=d==null?[]:[d]),p=A?i:p,Pt(p)||(p=p==null?[]:[p]),$h(h,d,p))}var fw=tr(function(h,d,p){h[p?0:1].push(d)},function(){return[[],[]]});function dw(h,d,p){var A=Pt(h)?Eo:dh,B=arguments.length<3;return A(h,At(d,4),p,B,ns)}function gw(h,d,p){var A=Pt(h)?Cy:dh,B=arguments.length<3;return A(h,At(d,4),p,B,Lh)}function vw(h,d){var p=Pt(h)?ts:Dh;return p(h,fr(At(d,3)))}function yw(h){var d=Pt(h)?Th:lm;return d(h)}function mw(h,d,p){(p?Ie(h,d,p):d===i)?d=1:d=Dt(d);var A=Pt(h)?z0:cm;return A(h,d)}function pw(h){var d=Pt(h)?H0:um;return d(h)}function ww(h){if(h==null)return 0;if(Fe(h))return gr(h)?tn(h):h.length;var d=Se(h);return d==G||d==se?h.size:$o(h).length}function bw(h,d,p){var A=Pt(h)?Ao:fm;return p&&Ie(h,d,p)&&(d=i),A(h,At(d,3))}var xw=Bt(function(h,d){if(h==null)return[];var p=d.length;return p>1&&Ie(h,d[0],d[1])?d=[]:p>2&&Ie(d[0],d[1],d[2])&&(d=[d[0]]),$h(h,ke(d,1),[])}),hr=e0||function(){return _e.Date.now()};function _w(h,d){if(typeof d!="function")throw new ni(r);return h=Dt(h),function(){if(--h<1)return d.apply(this,arguments)}}function Fu(h,d,p){return d=p?i:d,d=h&&d==null?h.length:d,Bi(h,M,i,i,i,i,d)}function Nu(h,d){var p;if(typeof d!="function")throw new ni(r);return h=Dt(h),function(){return--h>0&&(p=d.apply(this,arguments)),h<=1&&(d=i),p}}var dl=Bt(function(h,d,p){var A=m;if(p.length){var B=is(p,cn(dl));A|=S}return Bi(h,A,d,p,B)}),zu=Bt(function(h,d,p){var A=m|_;if(p.length){var B=is(p,cn(zu));A|=S}return Bi(d,A,h,p,B)});function Hu(h,d,p){d=p?i:d;var A=Bi(h,x,i,i,i,i,i,d);return A.placeholder=Hu.placeholder,A}function Wu(h,d,p){d=p?i:d;var A=Bi(h,C,i,i,i,i,i,d);return A.placeholder=Wu.placeholder,A}function Uu(h,d,p){var A,B,z,q,J,nt,dt=0,gt=!1,vt=!1,pt=!0;if(typeof h!="function")throw new ni(r);d=ci(d)||0,oe(p)&&(gt=!!p.leading,vt="maxWait"in p,z=vt?ye(ci(p.maxWait)||0,d):z,pt="trailing"in p?!!p.trailing:pt);function _t(fe){var pi=A,Hi=B;return A=B=i,dt=fe,q=h.apply(Hi,pi),q}function Ct(fe){return dt=fe,J=Xn(Ft,d),gt?_t(fe):q}function Mt(fe){var pi=fe-nt,Hi=fe-dt,lf=d-pi;return vt?Te(lf,z-Hi):lf}function Rt(fe){var pi=fe-nt,Hi=fe-dt;return nt===i||pi>=d||pi<0||vt&&Hi>=z}function Ft(){var fe=hr();if(Rt(fe))return Ht(fe);J=Xn(Ft,Mt(fe))}function Ht(fe){return J=i,pt&&A?_t(fe):(A=B=i,q)}function Ge(){J!==i&&Jh(J),dt=0,A=nt=B=J=i}function Le(){return J===i?q:Ht(hr())}function Ze(){var fe=hr(),pi=Rt(fe);if(A=arguments,B=this,nt=fe,pi){if(J===i)return Ct(nt);if(vt)return Jh(J),J=Xn(Ft,d),_t(nt)}return J===i&&(J=Xn(Ft,d)),q}return Ze.cancel=Ge,Ze.flush=Le,Ze}var kw=Bt(function(h,d){return Ih(h,1,d)}),Ew=Bt(function(h,d,p){return Ih(h,ci(d)||0,p)});function Aw(h){return Bi(h,$)}function ur(h,d){if(typeof h!="function"||d!=null&&typeof d!="function")throw new ni(r);var p=function(){var A=arguments,B=d?d.apply(this,A):A[0],z=p.cache;if(z.has(B))return z.get(B);var q=h.apply(this,A);return p.cache=z.set(B,q)||z,q};return p.cache=new(ur.Cache||Di),p}ur.Cache=Di;function fr(h){if(typeof h!="function")throw new ni(r);return function(){var d=arguments;switch(d.length){case 0:return!h.call(this);case 1:return!h.call(this,d[0]);case 2:return!h.call(this,d[0],d[1]);case 3:return!h.call(this,d[0],d[1],d[2])}return!h.apply(this,d)}}function Cw(h){return Nu(2,h)}var Rw=dm(function(h,d){d=d.length==1&&Pt(d[0])?ne(d[0],Ye(At())):ne(ke(d,1),Ye(At()));var p=d.length;return Bt(function(A){for(var B=-1,z=Te(A.length,p);++B=d}),Ss=Oh(function(){return arguments}())?Oh:function(h){return ce(h)&&Xt.call(h,"callee")&&!_h.call(h,"callee")},Pt=lt.isArray,Uw=sh?Ye(sh):G0;function Fe(h){return h!=null&&dr(h.length)&&!Ni(h)}function ue(h){return ce(h)&&Fe(h)}function $w(h){return h===!0||h===!1||ce(h)&&Pe(h)==ot}var ls=s0||Al,jw=nh?Ye(nh):Z0;function Vw(h){return ce(h)&&h.nodeType===1&&!Gn(h)}function qw(h){if(h==null)return!0;if(Fe(h)&&(Pt(h)||typeof h=="string"||typeof h.splice=="function"||ls(h)||hn(h)||Ss(h)))return!h.length;var d=Se(h);if(d==G||d==se)return!h.size;if(Kn(h))return!$o(h).length;for(var p in h)if(Xt.call(h,p))return!1;return!0}function Yw(h,d){return Vn(h,d)}function Kw(h,d,p){p=typeof p=="function"?p:i;var A=p?p(h,d):i;return A===i?Vn(h,d,i,p):!!A}function vl(h){if(!ce(h))return!1;var d=Pe(h);return d==I||d==k||typeof h.message=="string"&&typeof h.name=="string"&&!Gn(h)}function Xw(h){return typeof h=="number"&&Eh(h)}function Ni(h){if(!oe(h))return!1;var d=Pe(h);return d==N||d==X||d==ct||d==Tt}function ju(h){return typeof h=="number"&&h==Dt(h)}function dr(h){return typeof h=="number"&&h>-1&&h%1==0&&h<=V}function oe(h){var d=typeof h;return h!=null&&(d=="object"||d=="function")}function ce(h){return h!=null&&typeof h=="object"}var Vu=ah?Ye(ah):Q0;function Gw(h,d){return h===d||Uo(h,d,al(d))}function Zw(h,d,p){return p=typeof p=="function"?p:i,Uo(h,d,al(d),p)}function Jw(h){return qu(h)&&h!=+h}function Qw(h){if(Om(h))throw new St(a);return Fh(h)}function tb(h){return h===null}function eb(h){return h==null}function qu(h){return typeof h=="number"||ce(h)&&Pe(h)==rt}function Gn(h){if(!ce(h)||Pe(h)!=yt)return!1;var d=Ha(h);if(d===null)return!0;var p=Xt.call(d,"constructor")&&d.constructor;return typeof p=="function"&&p instanceof p&&Oa.call(p)==Zy}var yl=rh?Ye(rh):tm;function ib(h){return ju(h)&&h>=-V&&h<=V}var Yu=oh?Ye(oh):em;function gr(h){return typeof h=="string"||!Pt(h)&&ce(h)&&Pe(h)==xe}function Xe(h){return typeof h=="symbol"||ce(h)&&Pe(h)==Vt}var hn=lh?Ye(lh):im;function sb(h){return h===i}function nb(h){return ce(h)&&Se(h)==xi}function ab(h){return ce(h)&&Pe(h)==xv}var rb=nr(jo),ob=nr(function(h,d){return h<=d});function Ku(h){if(!h)return[];if(Fe(h))return gr(h)?vi(h):Oe(h);if(Fn&&h[Fn])return zy(h[Fn]());var d=Se(h),p=d==G?Io:d==se?Da:un;return p(h)}function zi(h){if(!h)return h===0?h:0;if(h=ci(h),h===at||h===-at){var d=h<0?-1:1;return d*H}return h===h?h:0}function Dt(h){var d=zi(h),p=d%1;return d===d?p?d-p:d:0}function Xu(h){return h?As(Dt(h),0,K):0}function ci(h){if(typeof h=="number")return h;if(Xe(h))return j;if(oe(h)){var d=typeof h.valueOf=="function"?h.valueOf():h;h=oe(d)?d+"":d}if(typeof h!="string")return h===0?h:+h;h=gh(h);var p=Uv.test(h);return p||jv.test(h)?_y(h.slice(2),p?2:8):Wv.test(h)?j:+h}function Gu(h){return ki(h,Ne(h))}function lb(h){return h?As(Dt(h),-V,V):h===0?h:0}function Kt(h){return h==null?"":Ke(h)}var cb=on(function(h,d){if(Kn(d)||Fe(d)){ki(d,pe(d),h);return}for(var p in d)Xt.call(d,p)&&Un(h,p,d[p])}),Zu=on(function(h,d){ki(d,Ne(d),h)}),vr=on(function(h,d,p,A){ki(d,Ne(d),h,A)}),hb=on(function(h,d,p,A){ki(d,pe(d),h,A)}),ub=Oi(Fo);function fb(h,d){var p=rn(h);return d==null?p:Sh(p,d)}var db=Bt(function(h,d){h=Zt(h);var p=-1,A=d.length,B=A>2?d[2]:i;for(B&&Ie(d[0],d[1],B)&&(A=1);++p1),z}),ki(h,sl(h),p),A&&(p=ri(p,f|g|v,Em));for(var B=d.length;B--;)Xo(p,d[B]);return p});function Ib(h,d){return Qu(h,fr(At(d)))}var Lb=Oi(function(h,d){return h==null?{}:am(h,d)});function Qu(h,d){if(h==null)return{};var p=ne(sl(h),function(A){return[A]});return d=At(d),jh(h,p,function(A,B){return d(A,B[0])})}function Db(h,d,p){d=rs(d,h);var A=-1,B=d.length;for(B||(B=1,h=i);++Ad){var A=h;h=d,d=A}if(p||h%1||d%1){var B=Ah();return Te(h+B*(d-h+xy("1e-"+((B+"").length-1))),d)}return qo(h,d)}var jb=ln(function(h,d,p){return d=d.toLowerCase(),h+(p?sf(d):d)});function sf(h){return wl(Kt(h).toLowerCase())}function nf(h){return h=Kt(h),h&&h.replace(qv,My).replace(uy,"")}function Vb(h,d,p){h=Kt(h),d=Ke(d);var A=h.length;p=p===i?A:As(Dt(p),0,A);var B=p;return p-=d.length,p>=0&&h.slice(p,B)==d}function qb(h){return h=Kt(h),h&&Cv.test(h)?h.replace(Mc,By):h}function Yb(h){return h=Kt(h),h&&Lv.test(h)?h.replace(go,"\\$&"):h}var Kb=ln(function(h,d,p){return h+(p?"-":"")+d.toLowerCase()}),Xb=ln(function(h,d,p){return h+(p?" ":"")+d.toLowerCase()}),Gb=ru("toLowerCase");function Zb(h,d,p){h=Kt(h),d=Dt(d);var A=d?tn(h):0;if(!d||A>=d)return h;var B=(d-A)/2;return sr(ja(B),p)+h+sr($a(B),p)}function Jb(h,d,p){h=Kt(h),d=Dt(d);var A=d?tn(h):0;return d&&A>>0,p?(h=Kt(h),h&&(typeof d=="string"||d!=null&&!yl(d))&&(d=Ke(d),!d&&Qs(h))?os(vi(h),0,p):h.split(d,p)):[]}var a1=ln(function(h,d,p){return h+(p?" ":"")+wl(d)});function r1(h,d,p){return h=Kt(h),p=p==null?0:As(Dt(p),0,h.length),d=Ke(d),h.slice(p,p+d.length)==d}function o1(h,d,p){var A=F.templateSettings;p&&Ie(h,d,p)&&(d=i),h=Kt(h),d=vr({},d,A,du);var B=vr({},d.imports,A.imports,du),z=pe(B),q=Po(B,z),J,nt,dt=0,gt=d.interpolate||Ta,vt="__p += '",pt=Lo((d.escape||Ta).source+"|"+gt.source+"|"+(gt===Bc?Hv:Ta).source+"|"+(d.evaluate||Ta).source+"|$","g"),_t="//# sourceURL="+(Xt.call(d,"sourceURL")?(d.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++yy+"]")+` `;h.replace(pt,function(Rt,Ft,Ht,Ge,Le,Ze){return Ht||(Ht=Ge),vt+=h.slice(dt,Ze).replace(Yv,Oy),Ft&&(J=!0,vt+=`' + __e(`+Ft+`) + '`),Le&&(nt=!0,vt+=`'; `+Le+`; __p += '`),Ht&&(vt+=`' + ((__t = (`+Ht+`)) == null ? '' : __t) + '`),dt=Ze+Rt.length,Rt}),vt+=`'; `;var Ct=Xt.call(d,"variable")&&d.variable;if(!Ct)vt=`with (obj) { `+vt+` } `;else if(Nv.test(Ct))throw new St(l);vt=(nt?vt.replace(_v,""):vt).replace(kv,"$1").replace(Ev,"$1;"),vt="function("+(Ct||"obj")+`) { `+(Ct?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(J?", __e = _.escape":"")+(nt?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+vt+`return __p }`;var Mt=rf(function(){return qt(z,_t+"return "+vt).apply(i,q)});if(Mt.source=vt,vl(Mt))throw Mt;return Mt}function l1(h){return Kt(h).toLowerCase()}function c1(h){return Kt(h).toUpperCase()}function h1(h,d,p){if(h=Kt(h),h&&(p||d===i))return gh(h);if(!h||!(d=Ke(d)))return h;var A=vi(h),B=vi(d),z=vh(A,B),q=yh(A,B)+1;return os(A,z,q).join("")}function u1(h,d,p){if(h=Kt(h),h&&(p||d===i))return h.slice(0,ph(h)+1);if(!h||!(d=Ke(d)))return h;var A=vi(h),B=yh(A,vi(d))+1;return os(A,0,B).join("")}function f1(h,d,p){if(h=Kt(h),h&&(p||d===i))return h.replace(vo,"");if(!h||!(d=Ke(d)))return h;var A=vi(h),B=vh(A,vi(d));return os(A,B).join("")}function d1(h,d){var p=Q,A=R;if(oe(d)){var B="separator"in d?d.separator:B;p="length"in d?Dt(d.length):p,A="omission"in d?Ke(d.omission):A}h=Kt(h);var z=h.length;if(Qs(h)){var q=vi(h);z=q.length}if(p>=z)return h;var J=p-tn(A);if(J<1)return A;var nt=q?os(q,0,J).join(""):h.slice(0,J);if(B===i)return nt+A;if(q&&(J+=nt.length-J),yl(B)){if(h.slice(J).search(B)){var dt,gt=nt;for(B.global||(B=Lo(B.source,Kt(Oc.exec(B))+"g")),B.lastIndex=0;dt=B.exec(gt);)var vt=dt.index;nt=nt.slice(0,vt===i?J:vt)}}else if(h.indexOf(Ke(B),J)!=J){var pt=nt.lastIndexOf(B);pt>-1&&(nt=nt.slice(0,pt))}return nt+A}function g1(h){return h=Kt(h),h&&Av.test(h)?h.replace(Dc,$y):h}var v1=ln(function(h,d,p){return h+(p?" ":"")+d.toUpperCase()}),wl=ru("toUpperCase");function af(h,d,p){return h=Kt(h),d=p?i:d,d===i?Ny(h)?qy(h):Sy(h):h.match(d)||[]}var rf=Bt(function(h,d){try{return qe(h,i,d)}catch(p){return vl(p)?p:new St(p)}}),y1=Oi(function(h,d){return si(d,function(p){p=Ei(p),Mi(h,p,dl(h[p],h))}),h});function m1(h){var d=h==null?0:h.length,p=At();return h=d?ne(h,function(A){if(typeof A[1]!="function")throw new ni(r);return[p(A[0]),A[1]]}):[],Bt(function(A){for(var B=-1;++BV)return[];var p=K,A=Te(h,K);d=At(d),h-=K;for(var B=So(A,d);++p0||d<0)?new Nt(p):(h<0?p=p.takeRight(-h):h&&(p=p.drop(h)),d!==i&&(d=Dt(d),p=d<0?p.dropRight(-d):p.take(d-h)),p)},Nt.prototype.takeRightWhile=function(h){return this.reverse().takeWhile(h).reverse()},Nt.prototype.toArray=function(){return this.take(K)},_i(Nt.prototype,function(h,d){var p=/^(?:filter|find|map|reject)|While$/.test(d),A=/^(?:head|last)$/.test(d),B=F[A?"take"+(d=="last"?"Right":""):d],z=A||/^find/.test(d);!B||(F.prototype[d]=function(){var q=this.__wrapped__,J=A?[1]:arguments,nt=q instanceof Nt,dt=J[0],gt=nt||Pt(q),vt=function(Ft){var Ht=B.apply(F,es([Ft],J));return A&&pt?Ht[0]:Ht};gt&&p&&typeof dt=="function"&&dt.length!=1&&(nt=gt=!1);var pt=this.__chain__,_t=!!this.__actions__.length,Ct=z&&!pt,Mt=nt&&!_t;if(!z&>){q=Mt?q:new Nt(this);var Rt=h.apply(q,J);return Rt.__actions__.push({func:lr,args:[vt],thisArg:i}),new ai(Rt,pt)}return Ct&&Mt?h.apply(this,J):(Rt=this.thru(vt),Ct?A?Rt.value()[0]:Rt.value():Rt)})}),si(["pop","push","shift","sort","splice","unshift"],function(h){var d=Ma[h],p=/^(?:push|sort|unshift)$/.test(h)?"tap":"thru",A=/^(?:pop|shift)$/.test(h);F.prototype[h]=function(){var B=arguments;if(A&&!this.__chain__){var z=this.value();return d.apply(Pt(z)?z:[],B)}return this[p](function(q){return d.apply(Pt(q)?q:[],B)})}}),_i(Nt.prototype,function(h,d){var p=F[d];if(p){var A=p.name+"";Xt.call(an,A)||(an[A]=[]),an[A].push({name:d,func:p})}}),an[er(i,_).name]=[{name:"wrapper",func:i}],Nt.prototype.clone=g0,Nt.prototype.reverse=v0,Nt.prototype.value=y0,F.prototype.at=Vp,F.prototype.chain=qp,F.prototype.commit=Yp,F.prototype.next=Kp,F.prototype.plant=Gp,F.prototype.reverse=Zp,F.prototype.toJSON=F.prototype.valueOf=F.prototype.value=Jp,F.prototype.first=F.prototype.head,Fn&&(F.prototype[Fn]=Xp),F},en=Yy();xs?((xs.exports=en)._=en,xo._=en):_e._=en}).call(De)})(gc,gc.exports);const IR=gc.exports;export{Ak as M,IR as _,fR as a,gR as b,vR as c,yR as d,bR as e,uR as f,dR as g,pR as h,xR as i,_R as j,kR as k,SR as l,RR as m,AR as n,CR as o,PR as p,TR as q,mR as r,wR as s,ER as t};