UNPKG

leo-mind-map

Version:

一个简单的web在线思维导图

50 lines (47 loc) 266 kB
(function(w,x){typeof exports=="object"&&typeof module<"u"?module.exports=x(require("@svgdotjs/svg.js")):typeof define=="function"&&define.amd?define(["@svgdotjs/svg.js"],x):(w=typeof globalThis<"u"?globalThis:w||self,w.LeoMindMap=x(w.svg_js))})(this,function(w){"use strict";const x={CHANGE_THEME:"changeTheme",CHANGE_LAYOUT:"changeLayout",MODE:{READONLY:"readonly",EDIT:"edit"},LAYOUT:{LOGICAL_STRUCTURE:"logicalStructure",LOGICAL_STRUCTURE_LEFT:"logicalStructureLeft",MIND_MAP:"mindMap",ORGANIZATION_STRUCTURE:"organizationStructure",CATALOG_ORGANIZATION:"catalogOrganization",TIMELINE:"timeline",TIMELINE2:"timeline2",FISHBONE:"fishbone",FISHBONE2:"fishbone2",RIGHT_FISHBONE:"rightFishbone",RIGHT_FISHBONE2:"rightFishbone2",VERTICAL_TIMELINE:"verticalTimeline",VERTICAL_TIMELINE2:"verticalTimeline2",VERTICAL_TIMELINE3:"verticalTimeline3"},DIR:{UP:"up",LEFT:"left",DOWN:"down",RIGHT:"right"},KEY_DIR:{LEFT:"Left",UP:"Up",RIGHT:"Right",DOWN:"Down"},SHAPE:{RECTANGLE:"rectangle",DIAMOND:"diamond",PARALLELOGRAM:"parallelogram",ROUNDED_RECTANGLE:"roundedRectangle",OCTAGONAL_RECTANGLE:"octagonalRectangle",OUTER_TRIANGULAR_RECTANGLE:"outerTriangularRectangle",INNER_TRIANGULAR_RECTANGLE:"innerTriangularRectangle",ELLIPSE:"ellipse",CIRCLE:"circle"},MOUSE_WHEEL_ACTION:{ZOOM:"zoom",MOVE:"move"},INIT_ROOT_NODE_POSITION:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom",CENTER:"center"},LAYOUT_GROW_DIR:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom"},PASTE_TYPE:{CLIP_BOARD:"clipBoard",CANVAS:"canvas"},SCROLL_BAR_DIR:{VERTICAL:"vertical",HORIZONTAL:"horizontal"},CREATE_NEW_NODE_BEHAVIOR:{DEFAULT:"default",NOT_ACTIVE:"notActive",ACTIVE_ONLY:"activeOnly"},TAG_PLACEMENT:{RIGHT:"right",BOTTOM:"bottom"},IMG_PLACEMENT:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom"}},Dt={[x.INIT_ROOT_NODE_POSITION.LEFT]:0,[x.INIT_ROOT_NODE_POSITION.TOP]:0,[x.INIT_ROOT_NODE_POSITION.RIGHT]:1,[x.INIT_ROOT_NODE_POSITION.BOTTOM]:1,[x.INIT_ROOT_NODE_POSITION.CENTER]:.5};x.LAYOUT.LOGICAL_STRUCTURE,x.LAYOUT.LOGICAL_STRUCTURE_LEFT,x.LAYOUT.MIND_MAP,x.LAYOUT.ORGANIZATION_STRUCTURE,x.LAYOUT.CATALOG_ORGANIZATION,x.LAYOUT.TIMELINE,x.LAYOUT.TIMELINE2,x.LAYOUT.VERTICAL_TIMELINE,x.LAYOUT.VERTICAL_TIMELINE2,x.LAYOUT.VERTICAL_TIMELINE3,x.LAYOUT.FISHBONE,x.LAYOUT.FISHBONE2,x.LAYOUT.RIGHT_FISHBONE,x.LAYOUT.RIGHT_FISHBONE2;const Rt=[x.LAYOUT.LOGICAL_STRUCTURE,x.LAYOUT.LOGICAL_STRUCTURE_LEFT,x.LAYOUT.MIND_MAP,x.LAYOUT.CATALOG_ORGANIZATION,x.LAYOUT.ORGANIZATION_STRUCTURE,x.LAYOUT.TIMELINE,x.LAYOUT.TIMELINE2,x.LAYOUT.VERTICAL_TIMELINE,x.LAYOUT.VERTICAL_TIMELINE2,x.LAYOUT.VERTICAL_TIMELINE3,x.LAYOUT.FISHBONE,x.LAYOUT.FISHBONE2,x.LAYOUT.RIGHT_FISHBONE,x.LAYOUT.RIGHT_FISHBONE2],ot=["text","image","imageTitle","imageSize","icon","tag","hyperlink","hyperlinkTitle","note","expand","isActive","generalization","richText","resetRichText","uid","activeStyle","associativeLineTargets","associativeLineTargetControlOffsets","associativeLinePoint","associativeLineText","attachmentUrl","attachmentName","notation","outerFrame","number","range","customLeft","customTop","customTextWidth","checkbox","dir","needUpdate","imgMap","nodeLink"],Z={READ_CLIPBOARD_ERROR:"read_clipboard_error",PARSE_PASTE_DATA_ERROR:"parse_paste_data_error",CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR:"custom_handle_clipboard_text_error",LOAD_CLIPBOARD_IMAGE_ERROR:"load_clipboard_image_error",BEFORE_TEXT_EDIT_ERROR:"before_text_edit_error",EXPORT_ERROR:"export_error",EXPORT_LOAD_IMAGE_ERROR:"export_load_image_error",DATA_CHANGE_DETAIL_EVENT_ERROR:"data_change_detail_event_error"},ue=` /* 鼠标hover和激活时渲染的矩形 */ .smm-hover-node{ display: none; opacity: 0.6; stroke-width: 1; } .smm-node:not(.smm-node-dragging):hover .smm-hover-node{ display: block; } .smm-node.active .smm-hover-node, .smm-node-highlight .smm-hover-node{ display: block; opacity: 1; stroke-width: 2; } .smm-text-node-wrap, .smm-expand-btn-text { user-select: none; } `,ht=1.2,ge=["fontFamily","fontSize","fontWeight","fontStyle","textDecoration","color","textAlign"];class me{constructor(t={}){this.opt=t,this.mindMap=this.opt.mindMap,this.scale=1,this.sx=0,this.sy=0,this.x=0,this.y=0,this.firstDrag=!0,this.setTransformData(this.mindMap.opt.viewData),this.bind()}bind(){this.mindMap.keyCommand.addShortcut("Control+=",()=>{this.enlarge()}),this.mindMap.keyCommand.addShortcut("Control+-",()=>{this.narrow()}),this.mindMap.keyCommand.addShortcut("Control+i",()=>{this.fit()}),this.mindMap.event.on("mousedown",t=>{const{isDisableDrag:e,mousedownEventPreventDefault:i}=this.mindMap.opt;e||(i&&t.preventDefault(),this.sx=this.x,this.sy=this.y)}),this.mindMap.event.on("drag",(t,e)=>{t.ctrlKey||t.metaKey||this.mindMap.opt.isDisableDrag||(this.firstDrag&&(this.firstDrag=!1,this.mindMap.renderer.activeNodeList.length>0&&this.mindMap.execCommand("CLEAR_ACTIVE_NODE")),this.x=this.sx+e.mousemoveOffset.x,this.y=this.sy+e.mousemoveOffset.y,this.transform())}),this.mindMap.event.on("mouseup",()=>{this.firstDrag=!0}),this.mindMap.event.on("mousewheel",(t,e,i,n)=>{const{customHandleMousewheel:s,mousewheelAction:a,mouseScaleCenterUseMousePosition:h,mousewheelMoveStep:r,mousewheelZoomActionReverse:l,disableMouseWheelZoom:d,translateRatio:c}=this.mindMap.opt;if(s&&typeof s=="function")return s(t);if(a===x.MOUSE_WHEEL_ACTION.ZOOM||t.ctrlKey||t.metaKey){if(d)return;const{x:p,y:g}=this.mindMap.toPos(t.clientX,t.clientY),f=h?p:void 0,m=h?g:void 0;switch(n&&(e.includes(x.DIR.LEFT)||e.includes(x.DIR.RIGHT))&&(e=e.filter(u=>![x.DIR.LEFT,x.DIR.RIGHT].includes(u))),!0){case e.includes(x.DIR.UP||x.DIR.LEFT):l?this.enlarge(f,m,n):this.narrow(f,m,n);break;case e.includes(x.DIR.DOWN||x.DIR.RIGHT):l?this.narrow(f,m,n):this.enlarge(f,m,n);break}}else{let p=0,g=0;n?(p=Math.abs(t.wheelDeltaX),g=Math.abs(t.wheelDeltaY)):p=g=r;let f=0,m=0;e.includes(x.DIR.DOWN)&&(m=-g),e.includes(x.DIR.UP)&&(m=g),e.includes(x.DIR.LEFT)&&(f=p),e.includes(x.DIR.RIGHT)&&(f=-p),this.translateXY(f*c,m*c)}}),this.mindMap.on("resize",()=>{this.checkNeedMindMapInCanvas()&&this.transform()})}getTransformData(){return{transform:this.mindMap.draw.transform(),state:{scale:this.scale,x:this.x,y:this.y,sx:this.sx,sy:this.sy}}}setTransformData(t){t&&(Object.keys(t.state).forEach(e=>{this[e]=t.state[e]}),this.mindMap.draw.transform({...t.transform}),this.mindMap.emit("view_data_change",this.getTransformData()),this.emitEvent("scale"),this.emitEvent("translate"))}translateXY(t,e){t===0&&e===0||(this.x+=t,this.y+=e,this.transform(),this.emitEvent("translate"))}translateX(t){t!==0&&(this.x+=t,this.transform(),this.emitEvent("translate"))}translateXTo(t){this.x=t,this.transform(),this.emitEvent("translate")}translateY(t){t!==0&&(this.y+=t,this.transform(),this.emitEvent("translate"))}translateYTo(t){this.y=t,this.transform(),this.emitEvent("translate")}transform(){try{this.limitMindMapInCanvas()}catch{}this.mindMap.draw.transform({origin:[0,0],scale:this.scale,translate:[this.x,this.y]}),this.mindMap.emit("view_data_change",this.getTransformData())}reset(){const t=this.scale!==1,e=this.x!==0||this.y!==0;this.scale=1,this.x=0,this.y=0,this.transform(),t&&this.emitEvent("scale"),e&&this.emitEvent("translate")}narrow(t,e,i){let{scaleRatio:n,minZoomRatio:s}=this.mindMap.opt;n=n/(i?5:1);const a=Math.max(this.scale-n,s/100);this.scaleInCenter(a,t,e),this.transform(),this.emitEvent("scale")}enlarge(t,e,i){let{scaleRatio:n,maxZoomRatio:s}=this.mindMap.opt;n=n/(i?5:1);let a=0;s===-1?a=this.scale+n:a=Math.min(this.scale+n,s/100),this.scaleInCenter(a,t,e),this.transform(),this.emitEvent("scale")}scaleInCenter(t,e,i){(e===void 0||i===void 0)&&(e=this.mindMap.width/2,i=this.mindMap.height/2);const n=this.scale,s=1-t/n,a=(e-this.x)*s,h=(i-this.y)*s;this.x+=a,this.y+=h,this.scale=t}setScale(t,e,i){e!==void 0&&i!==void 0?this.scaleInCenter(t,e,i):this.scale=t,this.transform(),this.emitEvent("scale")}fit(t=()=>{},e=!1,i){i=i===void 0?this.mindMap.opt.fitPadding:i;const n=this.mindMap.draw,s=n.transform(),a=t()||n.rbox(),h=a.width/s.scaleX,r=a.height/s.scaleY,l=h/r;let{width:d,height:c}=this.mindMap.elRect;d=d-i*2,c=c-i*2;const p=d/c;let g=0,f="";if(h<=d&&r<=c&&!e)g=1,f=1;else{let T=0;l>p?(T=d,f=2):(T=c*l,f=3),g=T/h}this.setScale(g);const m=t()||n.rbox();m.x-=this.mindMap.elRect.left,m.y-=this.mindMap.elRect.top;let u=0,E=0;f===1?(u=-m.x+i+(d-m.width)/2,E=-m.y+i+(c-m.height)/2):f===2?(u=-m.x+i,E=-m.y+i+(c-m.height)/2):f===3&&(u=-m.x+i+(d-m.width)/2,E=-m.y+i),this.translateXY(u,E)}checkNeedMindMapInCanvas(){if(this.mindMap.demonstrate&&this.mindMap.demonstrate.isInDemonstrate)return!1;const{isLimitMindMapInCanvasWhenHasScrollbar:t,isLimitMindMapInCanvas:e}=this.mindMap.opt;return this.mindMap.scrollbar?t:e}limitMindMapInCanvas(){if(!this.checkNeedMindMapInCanvas())return;let{scale:t,left:e,top:i,right:n,bottom:s}=this.getPositionLimit();const a=(this.mindMap.width-this.mindMap.initWidth)/2*t,h=(this.mindMap.height-this.mindMap.initHeight)/2*t,r=this.scale/t;e*=r,n*=r,i*=r,s*=r;const l=this.mindMap.width/2,d=this.mindMap.height/2,c=this.scale-1;e-=c*l-a,n-=c*l-a,i-=c*d-h,s-=c*d-h,this.x>e&&(this.x=e),this.x<n&&(this.x=n),this.y>i&&(this.y=i),this.y<s&&(this.y=s)}getPositionLimit(){const{scaleX:t,scaleY:e}=this.mindMap.draw.transform(),i=this.mindMap.draw.rbox(),n=this.mindMap.renderer.root.group.rbox(),s=this.mindMap.renderer.layout.getRootCenterOffset(n.width,n.height),a=n.x-i.x-s.x*t,h=n.x-i.x2-s.x*t,r=n.y-i.y-s.y*e,l=n.y-i.y2-s.y*e;return{scale:t,left:a,right:h,top:r,bottom:l}}emitEvent(t){switch(t){case"scale":this.mindMap.emit("scale",this.scale);case"translate":this.mindMap.emit("translate",this.x,this.y)}}}function xe(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var At={exports:{}};(function(o){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(r,l,d){this.fn=r,this.context=l,this.once=d||!1}function s(r,l,d,c,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var g=new n(d,c||r,p),f=e?e+l:l;return r._events[f]?r._events[f].fn?r._events[f]=[r._events[f],g]:r._events[f].push(g):(r._events[f]=g,r._eventsCount++),r}function a(r,l){--r._eventsCount===0?r._events=new i:delete r._events[l]}function h(){this._events=new i,this._eventsCount=0}h.prototype.eventNames=function(){var l=[],d,c;if(this._eventsCount===0)return l;for(c in d=this._events)t.call(d,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},h.prototype.listeners=function(l){var d=e?e+l:l,c=this._events[d];if(!c)return[];if(c.fn)return[c.fn];for(var p=0,g=c.length,f=new Array(g);p<g;p++)f[p]=c[p].fn;return f},h.prototype.listenerCount=function(l){var d=e?e+l:l,c=this._events[d];return c?c.fn?1:c.length:0},h.prototype.emit=function(l,d,c,p,g,f){var m=e?e+l:l;if(!this._events[m])return!1;var u=this._events[m],E=arguments.length,T,M;if(u.fn){switch(u.once&&this.removeListener(l,u.fn,void 0,!0),E){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,d),!0;case 3:return u.fn.call(u.context,d,c),!0;case 4:return u.fn.call(u.context,d,c,p),!0;case 5:return u.fn.call(u.context,d,c,p,g),!0;case 6:return u.fn.call(u.context,d,c,p,g,f),!0}for(M=1,T=new Array(E-1);M<E;M++)T[M-1]=arguments[M];u.fn.apply(u.context,T)}else{var N=u.length,v;for(M=0;M<N;M++)switch(u[M].once&&this.removeListener(l,u[M].fn,void 0,!0),E){case 1:u[M].fn.call(u[M].context);break;case 2:u[M].fn.call(u[M].context,d);break;case 3:u[M].fn.call(u[M].context,d,c);break;case 4:u[M].fn.call(u[M].context,d,c,p);break;default:if(!T)for(v=1,T=new Array(E-1);v<E;v++)T[v-1]=arguments[v];u[M].fn.apply(u[M].context,T)}}return!0},h.prototype.on=function(l,d,c){return s(this,l,d,c,!1)},h.prototype.once=function(l,d,c){return s(this,l,d,c,!0)},h.prototype.removeListener=function(l,d,c,p){var g=e?e+l:l;if(!this._events[g])return this;if(!d)return a(this,g),this;var f=this._events[g];if(f.fn)f.fn===d&&(!p||f.once)&&(!c||f.context===c)&&a(this,g);else{for(var m=0,u=[],E=f.length;m<E;m++)(f[m].fn!==d||p&&!f[m].once||c&&f[m].context!==c)&&u.push(f[m]);u.length?this._events[g]=u.length===1?u[0]:u:a(this,g)}return this},h.prototype.removeAllListeners=function(l){var d;return l?(d=e?e+l:l,this._events[d]&&a(this,d)):(this._events=new i,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=e,h.EventEmitter=h,o.exports=h})(At);var Ee=At.exports;const Me=xe(Ee);class Ne extends Me{constructor(t={}){super(),this.opt=t,this.mindMap=t.mindMap,this.isLeftMousedown=!1,this.isRightMousedown=!1,this.isMiddleMousedown=!1,this.mousedownPos={x:0,y:0},this.mousemovePos={x:0,y:0},this.mousemoveOffset={x:0,y:0},this.bindFn(),this.bind()}bindFn(){this.onBodyMousedown=this.onBodyMousedown.bind(this),this.onBodyClick=this.onBodyClick.bind(this),this.onDrawClick=this.onDrawClick.bind(this),this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onNodeMouseup=this.onNodeMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onContextmenu=this.onContextmenu.bind(this),this.onSvgMousedown=this.onSvgMousedown.bind(this),this.onKeyup=this.onKeyup.bind(this),this.onMouseenter=this.onMouseenter.bind(this),this.onMouseleave=this.onMouseleave.bind(this)}bind(){document.body.addEventListener("mousedown",this.onBodyMousedown),document.body.addEventListener("click",this.onBodyClick),this.mindMap.svg.on("click",this.onDrawClick),this.mindMap.el.addEventListener("mousedown",this.onMousedown),this.mindMap.svg.on("mousedown",this.onSvgMousedown),window.addEventListener("mousemove",this.onMousemove),window.addEventListener("mouseup",this.onMouseup),this.on("node_mouseup",this.onNodeMouseup),this.mindMap.el.addEventListener("wheel",this.onMousewheel),this.mindMap.svg.on("contextmenu",this.onContextmenu),this.mindMap.svg.on("mouseenter",this.onMouseenter),this.mindMap.svg.on("mouseleave",this.onMouseleave),window.addEventListener("keyup",this.onKeyup)}unbind(){document.body.removeEventListener("mousedown",this.onBodyMousedown),document.body.removeEventListener("click",this.onBodyClick),this.mindMap.svg.off("click",this.onDrawClick),this.mindMap.el.removeEventListener("mousedown",this.onMousedown),window.removeEventListener("mousemove",this.onMousemove),window.removeEventListener("mouseup",this.onMouseup),this.off("node_mouseup",this.onNodeMouseup),this.mindMap.el.removeEventListener("wheel",this.onMousewheel),this.mindMap.svg.off("contextmenu",this.onContextmenu),this.mindMap.svg.off("mouseenter",this.onMouseenter),this.mindMap.svg.off("mouseleave",this.onMouseleave),window.removeEventListener("keyup",this.onKeyup)}onDrawClick(t){this.emit("draw_click",t)}onBodyMousedown(t){this.emit("body_mousedown",t)}onBodyClick(t){this.emit("body_click",t)}onSvgMousedown(t){this.emit("svg_mousedown",t)}onMousedown(t){t.which===1?this.isLeftMousedown=!0:t.which===3?this.isRightMousedown=!0:t.which===2&&(this.isMiddleMousedown=!0),this.mousedownPos.x=t.clientX,this.mousedownPos.y=t.clientY,this.emit("mousedown",t,this)}onMousemove(t){let{useLeftKeySelectionRightKeyDrag:e}=this.mindMap.opt;this.mousemovePos.x=t.clientX,this.mousemovePos.y=t.clientY,this.mousemoveOffset.x=t.clientX-this.mousedownPos.x,this.mousemoveOffset.y=t.clientY-this.mousedownPos.y,this.emit("mousemove",t,this),(this.isMiddleMousedown||(e?this.isRightMousedown:this.isLeftMousedown))&&(t.preventDefault(),this.emit("drag",t,this))}onMouseup(t){this.onNodeMouseup(),this.emit("mouseup",t,this)}onNodeMouseup(){this.isLeftMousedown=!1,this.isRightMousedown=!1,this.isMiddleMousedown=!1}onMousewheel(t){t.stopPropagation(),t.preventDefault();const e=[];t.deltaY<0&&e.push(x.DIR.UP),t.deltaY>0&&e.push(x.DIR.DOWN),t.deltaX<0&&e.push(x.DIR.LEFT),t.deltaX>0&&e.push(x.DIR.RIGHT);let i=!1;const{customCheckIsTouchPad:n}=this.mindMap.opt;typeof n=="function"?i=n(t):i=Math.abs(t.deltaY)<=10,this.emit("mousewheel",t,e,this,i)}onContextmenu(t){t.preventDefault(),!t.ctrlKey&&this.emit("contextmenu",t)}onKeyup(t){this.emit("keyup",t)}onMouseenter(t){this.emit("svg_mouseenter",t)}onMouseleave(t){this.emit("svg_mouseleave",t)}}var rt=function(t){return Te(t)&&!we(t)};function Te(o){return!!o&&typeof o=="object"}function we(o){var t=Object.prototype.toString.call(o);return t==="[object RegExp]"||t==="[object Date]"||ye(o)}var ve=typeof Symbol=="function"&&Symbol.for,Ce=ve?Symbol.for("react.element"):60103;function ye(o){return o.$$typeof===Ce}function Le(o){return Array.isArray(o)?[]:{}}function tt(o,t){var e=t&&t.clone===!0;return e&&rt(o)?j(Le(o),o,t):o}function It(o,t,e){var i=o.slice();return t.forEach(function(n,s){typeof i[s]>"u"?i[s]=tt(n,e):rt(n)?i[s]=j(o[s],n,e):o.indexOf(n)===-1&&i.push(tt(n,e))}),i}function _e(o,t,e){var i={};return rt(o)&&Object.keys(o).forEach(function(n){i[n]=tt(o[n],e)}),Object.keys(t).forEach(function(n){!rt(t[n])||!o[n]?i[n]=tt(t[n],e):i[n]=j(o[n],t[n],e)}),i}function j(o,t,e){var i=Array.isArray(t),n=Array.isArray(o),s=e||{arrayMerge:It},a=i===n;if(a)if(i){var h=s.arrayMerge||It;return h(o,t,e)}else return _e(o,t,e);else return tt(t,e)}j.all=function(t,e){if(!Array.isArray(t)||t.length<2)throw new Error("first argument should be an array with at least two elements");return t.reduce(function(i,n){return j(i,n,e)})};var lt=j;let dt;const Se=new Uint8Array(16);function De(){if(!dt&&(dt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!dt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return dt(Se)}const I=[];for(let o=0;o<256;++o)I.push((o+256).toString(16).slice(1));function Re(o,t=0){return I[o[t+0]]+I[o[t+1]]+I[o[t+2]]+I[o[t+3]]+"-"+I[o[t+4]]+I[o[t+5]]+"-"+I[o[t+6]]+I[o[t+7]]+"-"+I[o[t+8]]+I[o[t+9]]+"-"+I[o[t+10]]+I[o[t+11]]+I[o[t+12]]+I[o[t+13]]+I[o[t+14]]+I[o[t+15]]}const Ot={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ae(o,t,e){if(Ot.randomUUID&&!t&&!o)return Ot.randomUUID();o=o||{};const i=o.random||(o.rng||De)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let n=0;n<16;++n)t[e+n]=i[n];return t}return Re(i)}function Mt(o){this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,this.init_genrand(o)}Mt.prototype.init_genrand=function(o){for(this.mt[0]=o>>>0,this.mti=1;this.mti<this.N;this.mti++)o=this.mt[this.mti-1]^this.mt[this.mti-1]>>>30,this.mt[this.mti]=(((o&4294901760)>>>16)*1812433253<<16)+(o&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0},Mt.prototype.genrand_int32=function(){var o,t=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var e;for(this.mti==this.N+1&&this.init_genrand(5489),e=0;e<this.N-this.M;e++)o=this.mt[e]&this.UPPER_MASK|this.mt[e+1]&this.LOWER_MASK,this.mt[e]=this.mt[e+this.M]^o>>>1^t[o&1];for(;e<this.N-1;e++)o=this.mt[e]&this.UPPER_MASK|this.mt[e+1]&this.LOWER_MASK,this.mt[e]=this.mt[e+(this.M-this.N)]^o>>>1^t[o&1];o=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^o>>>1^t[o&1],this.mti=0}return o=this.mt[this.mti++],o^=o>>>11,o^=o<<7&2636928640,o^=o<<15&4022730752,o^=o>>>18,o>>>0};const zt={paddingX:15,paddingY:5,imgMaxWidth:200,imgMaxHeight:100,iconSize:20,lineWidth:1,lineColor:"#549688",lineDasharray:"none",lineFlow:!1,lineFlowDuration:1,lineFlowForward:!0,lineStyle:"straight",rootLineKeepSameInCurve:!0,rootLineStartPositionKeepSameInCurve:!1,lineRadius:5,showLineMarker:!1,generalizationLineWidth:1,generalizationLineColor:"#549688",generalizationLineMargin:0,generalizationNodeMargin:20,associativeLineWidth:2,associativeLineColor:"rgb(51, 51, 51)",associativeLineActiveWidth:8,associativeLineActiveColor:"rgba(2, 167, 240, 1)",associativeLineDasharray:"6,4",associativeLineTextColor:"rgb(51, 51, 51)",associativeLineTextFontSize:14,associativeLineTextLineHeight:1.2,associativeLineTextFontFamily:"微软雅黑, Microsoft YaHei",backgroundColor:"#fafafa",backgroundImage:"none",backgroundRepeat:"no-repeat",backgroundPosition:"center center",backgroundSize:"cover",nodeUseLineStyle:!1,root:{shape:"rectangle",fillColor:"#549688",fontFamily:"微软雅黑, Microsoft YaHei",color:"#fff",fontSize:16,fontWeight:"bold",fontStyle:"normal",borderColor:"transparent",borderWidth:0,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},second:{shape:"rectangle",marginX:100,marginY:40,fillColor:"#fff",fontFamily:"微软雅黑, Microsoft YaHei",color:"#565656",fontSize:16,fontWeight:"normal",fontStyle:"normal",borderColor:"#549688",borderWidth:1,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},node:{shape:"rectangle",marginX:50,marginY:0,fillColor:"transparent",fontFamily:"微软雅黑, Microsoft YaHei",color:"#6a6d6c",fontSize:14,fontWeight:"normal",fontStyle:"normal",borderColor:"transparent",borderWidth:0,borderRadius:5,borderDasharray:"none",textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},generalization:{shape:"rectangle",marginX:100,marginY:40,fillColor:"#fff",fontFamily:"微软雅黑, Microsoft YaHei",color:"#565656",fontSize:16,fontWeight:"normal",fontStyle:"normal",borderColor:"#549688",borderWidth:1,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"}},Ie=["lineWidth","lineColor","lineDasharray","lineStyle","generalizationLineWidth","generalizationLineColor","associativeLineWidth","associativeLineColor","associativeLineActiveWidth","associativeLineActiveColor","associativeLineTextColor","associativeLineTextFontSize","associativeLineTextLineHeight","associativeLineTextFontFamily","backgroundColor","backgroundImage","backgroundRepeat","backgroundPosition","backgroundSize","rootLineKeepSameInCurve","rootLineStartPositionKeepSameInCurve","showLineMarker","lineRadius","hoverRectColor","hoverRectRadius","lineFlow","lineFlowDuration","lineFlowForward","textAlign"],Oe=o=>{let t=Object.keys(o);for(let e=0;e<t.length;e++)if(!Ie.find(i=>i===t[e]))return!1;return!0},Nt=["lineColor","lineDasharray","lineWidth","lineMarkerDir","lineFlow","lineFlowDuration","lineFlowForward"],y=(o,t,e,i,n,s=0,a=0,h=[])=>{let r=!1;if(e&&(r=e(o,t,n,s,a,h)),!r&&o.children&&o.children.length>0){let l=s+1;o.children.forEach((d,c)=>{y(d,o,e,i,!1,l,c,[...h,o])})}i&&i(o,t,n,s,a,h)},ze=(o,t)=>{let e=[o],i=!1;for(t(o,null)==="stop"&&(i=!0);e.length&&!i;){let n=e.shift();n.children&&n.children.length&&n.children.forEach(s=>{i||(e.push(s),t(s,n)==="stop"&&(i=!0))})}},Fe=(o,t,e,i)=>{let n=o/t,s=[];if(e&&i)if(o<=e&&t<=i)s=[o,t];else{let a=e/i;n>a?s=[e,e/n]:s=[n*i,i]}else e?o<=e?s=[o,t]:s=[e,e/n]:i&&(t<=i?s=[o,t]:s=[n*i,i]);return s},be=o=>{o=o.replace(/<br>/gim,` `);let t=document.createElement("div");return t.innerHTML=o,o=t.textContent,o},b=o=>{try{return JSON.parse(JSON.stringify(o))}catch{return null}},Ft=(o,t,e=!1)=>(o.data=b(t.data),e&&(o.data.isActive=!1,gt(o.data).forEach(n=>{n.isActive=!1})),o.children=[],t.children&&t.children.length>0&&t.children.forEach((i,n)=>{o.children[n]=Ft({},i,e)}),Object.keys(t).forEach(i=>{!["data","children"].includes(i)&&!/^_/.test(i)&&(o[i]=t[i])}),o),et=(o,t,e=!1,i=!0)=>{const n=t.nodeData?t.nodeData:t;return o.data=b(n.data),i?delete o.data.uid:o.data.uid||(o.data.uid=P()),e&&(o.data.isActive=!1),o.children=[],t.children&&t.children.length>0?t.children.forEach((s,a)=>{o.children[a]=et({},s,e,i)}):t.nodeData&&t.nodeData.children&&t.nodeData.children.length>0&&t.nodeData.children.forEach((s,a)=>{o.children[a]=et({},s,e,i)}),Object.keys(n).forEach(s=>{!["data","children"].includes(s)&&!/^_/.test(s)&&(o[s]=n[s])}),o},bt=(o,t=300,e)=>{let i=null;return(...n)=>{i||(i=setTimeout(()=>{o.call(e,...n),i=null},t))}},Be=(o,t=300,e)=>{let i=null;return(...n)=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,o.apply(e,n)},t)}},$=(o,t=()=>{})=>{let e=0,i=o.length;if(i<=0)return t();let n=()=>{if(e>=i){t();return}o[e](),setTimeout(()=>{e++,n()},0)};n()},q=o=>o*(Math.PI/180),Pe=o=>o.replace(/([a-z])([A-Z])/g,(...t)=>t[1]+"-"+t[2].toLowerCase()),ke=function(o,t){let e=!1,i=null,n=()=>{e=!1,t?o.call(t):o()};if(typeof MutationObserver<"u"){let s=1,a=new MutationObserver(n),h=document.createTextNode(s);a.observe(h,{characterData:!0}),i=function(){s=(s+1)%2,h.data=s}}else i=setTimeout;return function(){e||(e=!0,i(n,0))}},He=(o,t,e=0,i=0)=>{let n=o.elRect,{scaleX:s,scaleY:a,translateX:h,translateY:r}=o.draw.transform(),{left:l,top:d,width:c,height:p}=t,g=(l+c)*s+h,f=(d+p)*a+r;l=l*s+h,d=d*a+r;let m=0,u=0;return l<0+e&&(m=-l+e),g>n.width-e&&(m=-(g-n.width)-e),d<0+i&&(u=-d+i),f>n.height-i&&(u=-(f-n.height)-i),{isOuter:m!==0||u!==0,offsetLeft:m,offsetTop:u}};let ct=null;const Bt=o=>(ct||(ct=document.createElement("div")),ct.innerHTML=o,ct.textContent),Ge=o=>new Promise(t=>{let e=new Image;e.src=o,e.onload=()=>{t({width:e.width,height:e.height})},e.onerror=()=>{t({width:0,height:0})}}),P=()=>Ae(),Ue=o=>new Promise((t,e)=>{let i=new FileReader;i.readAsDataURL(o),i.onload=async n=>{let s=n.target.result,a=await Ge(s);t({url:s,size:a})},i.onerror=n=>{e(n)}}),W=o=>Object.prototype.toString.call(o).slice(8,-1),H=o=>o==null||o==="";let ft=null;const $e=o=>{ft||(ft=document.createElement("div")),ft.innerHTML=o;for(let t=ft.childNodes,e=t.length;e--;)if(t[e].nodeType==1)return!0;return!1},Pt=o=>(o=String(o).replace(/\s+/g,""),["#fff","#ffffff","#FFF","#FFFFFF","rgb(255,255,255)"].includes(o)||/rgba\(255,255,255,[^)]+\)/.test(o)),We=o=>(o=String(o).replace(/\s+/g,""),["","transparent"].includes(o)||/rgba\(\d+,\d+,\d+,0\)/.test(o)),Ye=o=>{let{lineColor:t,root:e,second:i,node:n}=o,s=[t,e.fillColor,e.color,i.fillColor,i.color,n.fillColor,n.color,e.borderColor,i.borderColor,n.borderColor];for(let a=0;a<s.length;a++){let h=s[a];if(!We(h)&&!Pt(h))return h}};let G=null;const Ve=o=>{G||(G=document.createElement("div")),G.innerHTML=o;const t=G.querySelectorAll(".ql-formula");Array.from(t).forEach(n=>{const s=document.createTextNode("$smmformula$");n.parentNode.replaceChild(s,n)});const e=G.childNodes;let i=[];for(let n=0;n<e.length;n++){const s=e[n];s.nodeType===1?i.push(s.textContent):s.nodeType===3&&i.push(s.nodeValue)}if(o=i.map(n=>`<p><span>${ut(n)}</span></p>`).join(""),t.length>0){o=o.replace(/\$smmformula\$/g,'<span class="smmformula"></span>'),G.innerHTML=o;const n=G.querySelectorAll(".smmformula");Array.from(n).forEach((s,a)=>{s.parentNode.replaceChild(t[a],s)}),o=G.innerHTML}return o},Xe=(o,t)=>{const e={};return Object.keys(t).forEach(i=>{const n=o[i],s=t[i];if(W(n)!==W(s)){e[i]=s;return}if(W(n)==="Object"){if(JSON.stringify(n)!==JSON.stringify(s)){e[i]=s;return}}else if(n!==s){e[i]=s;return}}),e},Tt=o=>/^_/.test(o)?!1:!ot.includes(o),Ke=o=>{const t=[...Nt],e=Object.keys(o);for(let i=0;i<e.length;i++)if(!t.includes(e[i]))return!1;return!0},Ze=o=>o.reduce((t,e)=>{const i=t.find(n=>n.type===e.type);return i?e.list.forEach(n=>{const s=i.list.find(a=>a.name===n.name);s?s.icon=n.icon:i.list.push(n)}):t.push({...e}),t},[]),kt=o=>{let t=[];return o.forEach(e=>{o.find(i=>i.uid!==e.uid&&i.isAncestor(e))||t.push(e)}),t},je=o=>{const t={},e={};o.forEach(n=>{const s=n.parent;if(s){const a=s.uid;e[a]=s;const h=n.getIndexInBrothers(),r={node:n,index:h};t[a]?t[a].find(l=>l.index===r.index)||t[a].push(r):t[a]=[r]}});const i=[];return Object.keys(t).forEach(n=>{if(t[n].length>1){const s=t[n].map(a=>a.index).sort((a,h)=>a-h);i.push({node:e[n],range:[s[0],s[s.length-1]]})}else i.push({node:t[n][0].node})}),i},qe=o=>{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(o),e.collapse(),t.removeAllRanges(),t.addRange(e)},Qe=o=>{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(o),t.removeAllRanges(),t.addRange(e)},pt=(o,t={})=>{t={...t},t&&t.richText&&t.resetRichText&&delete t.resetRichText;const i=n=>{n.forEach(s=>{s.data={...s.data,...t},s.children&&s.children.length>0&&i(s.children)})};return i(o),o},it=(o,t=!1,e=null,i=!1)=>{const n=s=>{s.forEach(a=>{a.data||(a.data={}),(t||H(a.data.uid))&&(a.data.uid=P()),i&&gt(a.data).forEach(r=>{(t||H(r.uid))&&(r.uid=P())}),e&&e(a),a.children&&a.children.length>0&&n(a.children)})};return n(o),o},z=o=>o?Array.isArray(o)?o:[o]:[],nt=o=>o.parent?o.parent.nodeData.children.findIndex(t=>t.data.uid===o.uid):0,O=(o,t)=>t.findIndex(e=>e.uid===o.uid),Ht=o=>{let t=0;for(let n=0;n<o.length;n++)t=o.charCodeAt(n)+((t<<5)-t);return"hsla("+new Mt(t).genrand_int32()%360+", 50%, 50%, 1)"},ut=o=>([["&","&amp;"],["<","&lt;"],[">","&gt;"]].forEach(t=>{o=o.replace(new RegExp(t[0],"g"),t[1])}),o),wt=(o,t)=>{const e=W(o);if(e!==W(t))return!1;if(e==="Object"){const i=Object.keys(o),n=Object.keys(t);if(i.length!==n.length)return!1;for(let s=0;s<i.length;s++){const a=i[s];if(!n.includes(a)||!wt(o[a],t[a]))return!1}return!0}else if(e==="Array"){if(o.length!==t.length)return!1;for(let i=0;i<o.length;i++){const n=o[i],s=t[i],a=W(n),h=W(s);if(a!==h||!wt(n,s))return!1}return!0}else return o===t},Gt=()=>navigator.clipboard&&typeof navigator.clipboard.read=="function",Ut=o=>{navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(JSON.stringify(o))},Je=async()=>{let o=null,t=null;if(Gt()){const e=await navigator.clipboard.read();if(e&&e.length>0)for(const i of e)for(const n of i.types)/^image\//.test(n)?t=await i.getType(n):n==="text/plain"&&(o=await(await i.getType(n)).text())}return{text:o,img:t}},vt=o=>{if(!o||!o.parent)return;const t=nt(o);t!==-1&&o.parent.nodeData.children.splice(t,1)},ti=(o,t)=>{if(o.length!==t.length)return!1;for(let e=0;e<o.length;e++)if(!t.find(i=>i.uid===o[e].uid))return!1;return!0},$t=o=>({simpleMindMap:!0,data:o}),Ct=o=>{let t=null;if(typeof o=="string")try{const i=JSON.parse(o);typeof i=="object"&&i.simpleMindMap&&(t=i.data)}catch{}else typeof o=="object"&&o.simpleMindMap&&(t=o.data);const e=!!t;return{isSmm:e,data:e?t:String(o)}},Wt=(o,t)=>{o.preventDefault();const e=window.getSelection();if(!e.rangeCount)return;e.deleteFromDocument(),t=t||o.clipboardData.getData("text"),t=ut(t),t=Bt(t);const i=t.split(/\n/g),n=document.createDocumentFragment();i.forEach((s,a)=>{const h=document.createTextNode(s);if(n.appendChild(h),a<i.length-1){const r=document.createElement("br");n.appendChild(r)}}),e.getRangeAt(0).insertNode(n),e.collapseToEnd()},Yt=o=>{const t={},e=(i,n)=>{const s=i.data.uid;n&&n.children.push(s),t[s]={isRoot:!n,data:{...i.data},children:[]},i.children&&i.children.length>0&&i.children.forEach(a=>{e(a,t[s])})};return e(o,null),t},ei=({addContentToHeader:o,addContentToFooter:t})=>{const e=[];let i=null,n=0,s=null,a=0;const h=(r,l)=>{if(typeof r=="function"){const d=r();if(!d)return;const{el:c,cssText:p,height:g}=d;if(c instanceof HTMLElement){J(c);const f=Q({el:c,height:g});l(f,g)}p&&e.push(p)}};return h(o,(r,l)=>{i=r,n=l}),h(t,(r,l)=>{s=r,a=l}),{cssTextList:e,header:i,headerHeight:n,footer:s,footerHeight:a}},ii=(o,t=0,e=0,i=0,n=0,s=!1,a=!1)=>{let h=1/0,r=-1/0,l=1/0,d=-1/0;const c=(p,g)=>{if(!(g&&s)&&p.group)try{const{x:f,y:m,width:u,height:E}=p.group.findOne(".smm-node-shape").rbox();f<h&&(h=f),f+u>r&&(r=f+u),m<l&&(l=m),m+E>d&&(d=m+E)}catch{}!a&&p._generalizationList.length>0&&p._generalizationList.forEach(f=>{c(f.generalizationNode)}),p.children&&p.children.forEach(f=>{c(f)})};return c(o,!0),h=h-t+i,l=l-e+n,r=r-t+i,d=d-e+n,{left:h,top:l,width:r-h,height:d-l}};(()=>{if(document.documentElement.requestFullScreen)return"fullscreenchange";if(document.documentElement.webkitRequestFullScreen)return"webkitfullscreenchange";if(document.documentElement.mozRequestFullScreen)return"mozfullscreenchange";if(document.documentElement.msRequestFullscreen)return"msfullscreenchange"})();const Q=({el:o,width:t,height:e})=>{const i=new w.ForeignObject;return t!==void 0&&i.width(t),e!==void 0&&i.height(e),i.add(o),i},gt=o=>{const t=o.generalization;return t?Array.isArray(t)?t:[t]:[]},J=o=>{o.setAttribute("xmlns","http://www.w3.org/1999/xhtml")},Vt=o=>(o=[...o],o.sort((t,e)=>t.sortIndex-e.sortIndex),o),Xt=(o,t)=>lt(o,t,{arrayMerge:(e,i)=>i}),ni=o=>{const t={};return ge.forEach(e=>{let i=o.style.merge(e);e==="fontSize"&&(i=i+"px"),t[e]=i}),t},Kt=["backgroundColor","backgroundImage","backgroundRepeat","backgroundPosition","backgroundSize"],Zt=["gradientStyle","startColor","endColor","startDir","endDir","fillColor","borderColor","borderWidth","borderDasharray"];class B{static setBackgroundStyle(t,e){if(!t)return;if(!B.cacheStyle){B.cacheStyle={};let r=window.getComputedStyle(t);Kt.forEach(l=>{B.cacheStyle[l]=r[l]})}let{backgroundColor:i,backgroundImage:n,backgroundRepeat:s,backgroundPosition:a,backgroundSize:h}=e;t.style.backgroundColor=i,n&&n!=="none"?(t.style.backgroundImage=`url(${n})`,t.style.backgroundRepeat=s,t.style.backgroundPosition=a,t.style.backgroundSize=h):t.style.backgroundImage="none"}static removeBackgroundStyle(t){B.cacheStyle&&(Kt.forEach(e=>{t.style[e]=B.cacheStyle[e]}),B.cacheStyle=null)}addShadow(t){const e={boxShadowHorizontal:this.merge("boxShadowHorizontal"),boxShadowVertical:this.merge("boxShadowVertical"),boxShadowBlur:this.merge("boxShadowBlur"),boxShadowColor:this.merge("boxShadowColor")};if(e.boxShadowColor&&(e.boxShadowHorizontal||e.boxShadowVertical||e.boxShadowBlur)){const i=e.boxShadowHorizontal||0,n=e.boxShadowVertical||0,s=e.boxShadowBlur||0,a=e.boxShadowColor;t.attr("filter",`drop-shadow(${i}px ${n}px ${s}px ${a})`)}}constructor(t){this.ctx=t,this._markerPath=null,this._marker=null,this._gradient=null}merge(t,e){let i=this.ctx.mindMap.themeConfig,n=null,s=!1;e?(s=!0,n=i):this.ctx.isGeneralization?n=i.generalization:this.ctx.layerIndex===0?n=i.root:this.ctx.layerIndex===1?n=i.second:n=i.node;let a="";return this.getSelfStyle(t)!==void 0?a=this.getSelfStyle(t):n[t]!==void 0?a=n[t]:a=i[t],s||this.addToEffectiveStyles({[t]:a}),a}getStyle(t,e){return this.merge(t,e)}getSelfStyle(t){return this.ctx.getData(t)}addToEffectiveStyles(t){this.ctx.mindMap.painter&&(this.ctx.effectiveStyles={...this.ctx.effectiveStyles,...t})}shape(t){const e={};Zt.forEach(i=>{e[i]=this.merge(i)}),e.gradientStyle?(this._gradient||(this._gradient=this.ctx.nodeDraw.gradient("linear")),this._gradient.update(i=>{i.stop(0,e.startColor),i.stop(1,e.endColor)}),this._gradient.from(...e.startDir).to(...e.endDir),t.fill(this._gradient)):t.fill({color:e.fillColor}),this.addShadow(t),t.stroke({color:e.borderColor,width:e.borderWidth,dasharray:e.borderDasharray})}text(t){const e={color:this.merge("color"),fontFamily:this.merge("fontFamily"),fontSize:this.merge("fontSize"),fontWeight:this.merge("fontWeight"),fontStyle:this.merge("fontStyle"),textDecoration:this.merge("textDecoration")};t.fill({color:e.color}).css({"font-family":e.fontFamily,"font-size":e.fontSize+"px","font-weight":e.fontWeight,"font-style":e.fontStyle,"text-decoration":e.textDecoration})}domText(t,e=1){const i={color:this.merge("color"),fontFamily:this.merge("fontFamily"),fontSize:this.merge("fontSize"),fontWeight:this.merge("fontWeight"),fontStyle:this.merge("fontStyle"),textDecoration:this.merge("textDecoration"),textAlign:this.merge("textAlign")};t.style.color=i.color,t.style.textDecoration=i.textDecoration,t.style.fontFamily=i.fontFamily,t.style.fontSize=i.fontSize*e+"px",t.style.fontWeight=i.fontWeight||"normal",t.style.fontStyle=i.fontStyle,t.style.textAlign=i.textAlign}tagText(t,e){t.fill({color:"#fff"}).css({"font-size":e.fontSize+"px"})}tagRect(t,e){t.fill({color:e.fill}),e.radius&&t.radius(e.radius)}iconNode(t,e){t.attr({fill:e||this.merge("color")})}line(t,{width:e,color:i,dasharray:n}={},s,a){const{customHandleLine:h}=this.ctx.mindMap.opt;if(typeof h=="function"&&h(this.ctx,t,{width:e,color:i,dasharray:n}),t.stroke({color:i,dasharray:n,width:e}).fill({color:"none"}),s){const r=this.merge("showLineMarker",!0),l=a.style;if(r){l._marker=l._marker||l.createMarker(),l._markerPath.stroke({color:i}).fill({color:i}),t.attr("marker-start",""),t.attr("marker-end","");const d=l.merge("lineMarkerDir");t.marker(d,l._marker)}else l._marker&&(t.attr("marker-start",""),t.attr("marker-end",""),l._marker.remove(),l._marker=null)}}createMarker(){return this.ctx.lineDraw.marker(20,20,t=>{t.ref(8,5),t.size(20,20),t.attr("markerUnits","userSpaceOnUse"),t.attr("orient","auto-start-reverse"),this._markerPath=t.path("M0,0 L2,5 L0,10 L10,5 Z")})}generalizationLine(t){t.stroke({width:this.merge("generalizationLineWidth",!0),color:this.merge("generalizationLineColor",!0)}).fill({color:"none"})}iconBtn(t,e,i){let{color:n,fill:s,fontSize:a,fontColor:h}=this.ctx.mindMap.opt.expandBtnStyle||{color:"#808080",fill:"#fff",fontSize:12,strokeColor:"#333333",fontColor:"#333333"};t.fill({color:n}),e.fill({color:n}),i.fill({color:s}),this.ctx.mindMap.opt.isShowExpandNum&&t.attr({"font-size":a+"px","font-color":h})}hasCustomStyle(){let t=!1;return Object.keys(this.ctx.getData()).forEach(e=>{Tt(e)&&(t=!0)}),t}getCustomStyle(){const t={};return Object.keys(this.ctx.getData()).forEach(e=>{Tt(e)&&(t[e]=this.ctx.getData(e))}),t}hoverNode(t){const e=this.merge("hoverRectColor")||this.ctx.mindMap.opt.hoverRectColor,i=this.merge("hoverRectRadius");t.radius(i).fill("none").stroke({color:e})}onRemove(){this._marker&&(this._marker.remove(),this._marker=null),this._markerPath&&(this._markerPath.remove(),this._markerPath=null),this._gradient&&(this._gradient.remove(),this._gradient=null)}}B.cacheStyle=null;class si{constructor(t){this.node=t,this.mindMap=t.mindMap}getShapePadding(t,e,i,n){const s=this.node.getShape(),a=15,h=5,r=t+i*2,l=e+n*2,d=Math.abs(r-l);switch(s){case x.SHAPE.ROUNDED_RECTANGLE:return{paddingX:e>t?(e-t)/2:0,paddingY:0};case x.SHAPE.DIAMOND:return{paddingX:t/2,paddingY:e/2};case x.SHAPE.PARALLELOGRAM:return{paddingX:i<=0?a:0,paddingY:0};case x.SHAPE.OUTER_TRIANGULAR_RECTANGLE:return{paddingX:i<=0?a:0,paddingY:0};case x.SHAPE.INNER_TRIANGULAR_RECTANGLE:return{paddingX:i<=0?a:0,paddingY:0};case x.SHAPE.ELLIPSE:return{paddingX:i<=0?a:0,paddingY:n<=0?h:0};case x.SHAPE.CIRCLE:return{paddingX:l>r?d/2:0,paddingY:l<r?d/2:0}}const c=this.getShapeFromExtendList(s);return c?c.getPadding({node:this.node,width:t,height:e,paddingX:i,paddingY:n})||{paddingX:0,paddingY:0}:{paddingX:0,paddingY:0}}getShapeFromExtendList(t){return this.mindMap.extendShapeList.find(e=>e.name===t)}createShape(){const t=this.node.getShape();let e=null;if(t===x.SHAPE.RECTANGLE?e=this.createRect():t===x.SHAPE.DIAMOND?e=this.createDiamond():t===x.SHAPE.PARALLELOGRAM?e=this.createParallelogram():t===x.SHAPE.ROUNDED_RECTANGLE?e=this.createRoundedRectangle():t===x.SHAPE.OCTAGONAL_RECTANGLE?e=this.createOctagonalRectangle():t===x.SHAPE.OUTER_TRIANGULAR_RECTANGLE?e=this.createOuterTriangularRectangle():t===x.SHAPE.INNER_TRIANGULAR_RECTANGLE?e=this.createInnerTriangularRectangle():t===x.SHAPE.ELLIPSE?e=this.createEllipse():t===x.SHAPE.CIRCLE&&(e=this.createCircle()),!e){const i=this.getShapeFromExtendList(t);i&&(e=i.createShape(this.node))}return e||this.createRect()}getNodeSize(){const t=this.node.getBorderWidth();let{width:e,height:i}=this.node;return e-=t,i-=t,{width:e,height:i}}createPath(t){const{customCreateNodePath:e}=this.mindMap.opt;return e?w.SVG(e(t)):new w.Path().plot(t)}createPolygon(t){const{customCreateNodePolygon:e}=this.mindMap.opt;return e?w.SVG(e(t)):new w.Polygon().plot(t)}createRect(){let{width:t,height:e}=this.getNodeSize(),i=this.node.style.merge("borderRadius");const n=` M${i},0 L${t-i},0 C${t-i},0 ${t},0 ${t},${i} L${t},${e-i} C${t},${e-i} ${t},${e} ${t-i},${e} L${i},${e} C${i},${e} 0,${e} 0,${e-i} L0,${i} C0,${i} 0,0 ${i},0 Z `;return this.createPath(n)}createDiamond(){let{width:t,height:e}=this.getNodeSize(),i=t/2,n=e/2;const g=[[i,0],[t,n],[i,e],[0,n]];return this.createPolygon(g)}createParallelogram(){let{paddingX:t}=this.node.getPaddingVale();t=t||this.node.shapePadding.paddingX;let{width:e,height:i}=this.getNodeSize();const n=[[t,0],[e,0],[e-t,i],[0,i]];return this.createPolygon(n)}createRoundedRectangle(){let{width:t,height:e}=this.getNodeSize(),i=e/2;const n=` M${i},0 L${t-i},0 A${e/2},${e/2} 0 0,1 ${t-i},${e} L${i},${e} A${e/2},${e/2} 0 0,1 ${i},0 `;return this.createPath(n)}createOctagonalRectangle(){let t=5,{width:e,height:i}=this.getNodeSize();const n=[[0,t],[t,0],[e-t,0],[e,t],[e,i-t],[e-t,i],[t,i],[0,i-t]];return this.createPolygon(n)}createOuterTriangularRectangle(){let{paddingX:t}=this.node.getPaddingVale();t=t||this.node.shapePadding.paddingX;let{width:e,height:i}=this.getNodeSize();const n=[[t,0],[e-t,0],[e,i/2],[e-t,i],[t,i],[0,i/2]];return this.createPolygon(n)}createInnerTriangularRectangle(){let{paddingX:t}=this.node.getPaddingVale();t=t||this.node.shapePadding.paddingX;let{width:e,height:i}=this.getNodeSize();const n=[[0,0],[e,0],[e-t/2,i/2],[e,i],[0,i],[t/2,i/2]];return this.createPolygon(n)}createEllipse(){let{width:t,height:e}=this.getNodeSize(),i=t/2,n=e/2;const s=` M${i},0 A${i},${n} 0 0,1 ${i},${e} M${i},${e} A${i},${n} 0 0,1 ${i},0 `;return this.createPath(s)}createCircle(){let{width:t,height:e}=this.getNodeSize(),i=t/2,n=e/2;const s=` M${i},0 A${i},${n} 0 0,1 ${i},${e} M${i},${e} A${i},${n} 0 0,1 ${i},0 `;return this.createPath(s)}}const ai=[x.SHAPE.RECTANGLE,x.SHAPE.DIAMOND,x.SHAPE.PARALLELOGRAM,x.SHAPE.ROUNDED_RECTANGLE,x.SHAPE.OCTAGONAL_RECTANGLE,x.SHAPE.OUTER_TRIANGULAR_RECTANGLE,x.SHAPE.INNER_TRIANGULAR_RECTANGLE,x.SHAPE.ELLIPSE,x.SHAPE.CIRCLE];function oi(){const o=this.getData("generalization");return Array.isArray(o)?o:o?[o]:[]}function hi(){return this.formatGetGeneralization().length>0}function ri(){return!!this.formatGetGeneralization().find(t=>!t.range||t.range.length<=0)}function li(o){return this._generalizationList.findIndex(t=>t.generalizationNode.uid===o.uid)}function di(){if(this.isGeneralization||!this.checkHasGeneralization())return;let o=0,t=0;this.formatGetGeneralization().forEach((i,n)=>{let s=this._generalizationList[n];s||(s=this._generalizationList[n]={}),s.node=this,s.range=i.range,s.generalizationLine||(s.generalizationLine=this.lineDraw.path()),s.generalizationNode||(s.generalizationNode=new xt({data:{inserting:i.inserting,data:i},uid:P(),renderer:this.renderer,mindMap:this.mindMap,isGeneralization:!0})),delete i.inserting,s.generalizationNode.generalizationBelongNode=this,s.generalizationNode.width>o&&(o=s.generalizationNode.width),s.generalizationNode.height>t&&(t=s.generalizationNode.height),i.isActive&&this.renderer.addNodeToActiveList(s.generalizationNode)}),this._generalizationNodeWidth=o,this._generalizationNodeHeight=t}function ci(){this.isGeneralization||(this.removeGeneralization(),this.createGeneralizationNode())}function fi(o){if(this.isGeneralization)return;this.updateGeneralizationData();const t=this.formatGetGeneralization();if(t.length<=0||this.getData("expand")===!1){this.removeGeneralization();return}t.length!==this._generalizationList.length&&this.removeGeneralization(),this.createGeneralizationNode(),this.renderer.layout.renderGeneralization(this._generalizationList),this._generalizationList.forEach(e=>{this.style.generalizationLine(e.generalizationLine),e.generalizationNode.render(()=>{},o)})}function pi(){const o=this.getChildrenLength(),t=this.formatGetGeneralization(),e=[];t.forEach(i=>{if(!i.range){e.push(i);return}i.range.length>0&&i.range[0]<=o-1&&i.range[1]<=o-1&&e.push(i)}),e.length!==t.length&&this.setData({generalization:e})}function ui(){this.isGeneralization||(this._generalizationList.forEach(o=>{o.generalizationNode.style.onRemove(),o.generalizationLine&&(o.generalizationLine.remove(),o.generalizationLine=null),o.generalizationNode&&(this.renderer.removeNodeFromActiveList(o.generalizationNode),o.generalizationNode.remove(),o.generalizationNode=null)}),this._generalizationList=[],this.generalizationBelongNode&&this.nodeDraw.find(".generalization_"+this.generalizationBelongNode.uid).remove())}function gi(){this.isGeneralization||this._generalizationList.forEach(o=>{o.generalizationLine&&o.generalizationLine.hide(),o.generalizationNode&&o.generalizationNode.hide()})}function mi(){this.isGeneralization||this._generalizationList.forEach(o=>{o.generalizationLine&&o.generalizationLine.show(),o.generalizationNode&&o.generalizationNode.show()})}function xi(o){this._generalizationList.forEach(t=>{t.generalizationLine.opacity(o),t.generalizationNode.group.opacity(o)})}function Ei(){const o=this.generalizationBelongNode,t=o.formatGetGeneralization(),e=o.getGeneralizationNodeIndex(this),i=t[e],s=this.getStyle("hoverRectColor")||this.mindMap.opt.hoverRectColor,a=s?{stroke:s}:null;Array.isArray(i.range)&&i.range.length>0?this.mindMap.renderer.highlightNode(o,i.range,a):this.mindMap.renderer.highlightNode(o,null,a)}function Mi(){this.mindMap.renderer.closeHighlightNode()}const jt={formatGetGeneralization:oi,checkHasGeneralization:hi,checkHasSelfGeneralization:ri,getGeneralizationNodeIndex:li,createGeneralizationNode:di,updateGeneralization:ci,updateGeneralizationData:pi,renderGeneralization:fi,removeGeneralization:ui,hideGeneralization:gi,showGeneralization:mi,setGeneralizationOpacity:xi,handleGeneralizationMouseenter:Ei,handleGeneralizationMouseleave:Mi},yt={open:'<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M475.136 327.168v147.968h-147.968v74.24h147.968v147.968h74.24v-147.968h147.968v-74.24h-147.968v-147.968h-74.24z m36.864-222.208c225.28 0 407.04 181.76 407.04 407.04s-181.76 407.04-407.04 407.04-407.04-181.76-407.04-407.04 181.76-407.04 407.04-407.04z m0-74.24c-265.216 0-480.768 215.552-480.768 480.768s215.552 480.768 480.768 480.768 480.768-215.552 480.768-480.768-215.552-480.768-480.768-480.768z"></path></svg>',close:'<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M512 105.472c225.28 0 407.04 181.76 407.04 407.04s-181.76 407.04-407.04 407.04-407.04-181.76-407.04-407.04 181.76-407.04 407.04-407.04z m0-74.24c-265.216 0-480.768 215.552-480.768 480.768s215.552 480.768 480.768 480.768 480.768-215.552 480.768-480.768-215.552-480.768-480.768-480.768z"></path><path d="M252.928 474.624h518.144v74.24h-518.144z"></path></svg>',remove:'<svg width="14px" height="14px" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path fill="#ffffff" d="M512 105.472c225.28 0 407.04 181.76 407.04 407.04s-181.76 407.04-407.04 407.04-407.04-181.76-407.04-407.04 181.76-407.04 407.04-407.04z m0-74.24c-265.216 0-480.768 215.552-480.768 480.768s215.552 480.768 480.768 480.768 480.768-215.552 480.768-480.768-215.552-480.768-480.768-480.768z"></path><path fill="#ffffff" d="M252.928 474.624h518.144v74.24h-518.144z"></path></svg>',imgAdjust:'<svg width="12px" height="12px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M1008.128 614.4a25.6 25.6 0 0 0-27.648 5.632l-142.848 142.848L259.072 186.88 401.92 43.52A25.6 25.6 0 0 0 384 0h-358.4a25.6 25.6 0 0 0-25.6 25.6v358.4a25.6 25.6 0 0 0 43.52 17.92l143.36-142.848 578.048 578.048-142.848 142.848a25.6 25.6 0 0 0 17.92 43.52h358.4a25.6 25.6 0 0 0 25.6-25.6v-358.4a25.6 25.6 0 0 0-15.872-25.088z" /></svg>',quickCreateChild:'<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48"><path d="M514.048 62.464q93.184 0 175.616 35.328t143.872 96.768 96.768 143.872 35.328 175.616q0 94.208-35.328 176.128t-96.768 143.36-143.872 96.768-175.616 35.328q-94.208 0-176.64-35.328t-143.872-96.768-96.768-143.36-35.328-176.128q0-93.184 35.328-175.616t96.768-143.872 143.872-96.768 176.64-35.328zM772.096 576.512q26.624 0 45.056-18.944t18.432-45.568-18.432-45.056-45.056-18.432l-192.512 0 0-192.512q0-26.624-18.944-45.568t-45.568-18.944-45.056 18.944-18.432 45.568l0 192.512-192.512 0q-26.624 0-45.056 18.432t-18.432 45.056 18.432 45.568 45.056 18.944l192.512 0 0 191.488q0 26.624 18.432 45.568t45.056 18.944 45.568-18.944 18.944-45.568l0-191.488 192.512 0z"></path></svg>'};function Ni(){if(this._openExpandNode)return;const{expandBtnSize:o,expandBtnIcon:t,isShowExpandNum:e}=this.mindMap.opt;let{close:i,open:n}=t||{};e?(this._openExpandNode=new w.Text,this._openExpandNode.addClass("smm-expand-btn-text"),this._openExpandNode.attr({"text-anchor":"middle","dominant-baseline":"middle",x:o/2,y:2})):(this._openExpandNode=w.SVG(n||yt.open).size(o,o),this._openExpandNode.x(0).y(-o/2)),this._closeExpandNode=w.SVG(i||yt.close).size(o,o),this._closeExpandNode.x(0).y(-o/2),this._fillExpandNode=new w.Circle().size(o),this._fillExpandNode.x(0).y(-o/2),this.style.iconBtn(this._openExpandNode,this._closeExpandNode,this._fillExpandNode)}function Ti(o=[]){return o.reduce((t,e)=>t+this.sumNode(e.children||[]),o.length)}function wi(){let{expand:o}=this.getData();if(o===this._lastExpandBtnType)return;this._expandBtn&&this._expandBtn.clear(),this.createExpandNodeContent();let t;if(o===!1?(t=this._openExpandNode,this._lastExpandBtnType=!1):(t=this._closeExpandNode,this._lastExpandBtnType=!0),this._expandBtn){let{isShowExpandNum:e,expandBtnStyle:i,expandBtnNumHandler:n}=this.mindMap.opt;if(e)if(o)this._fillExpandNode.stroke("none");else{this._fillExpandNode.stroke({color:i.strokeColor});let s=this.sumNode(this.nodeData.children||[]);if(typeof n=="function"){const a=n(s,this);H(a)||(s=a)}t.text(String(s))}this._expandBtn.add(this._fillExpandNode).add(t)}}function vi(){this._expandBt