/*! * ==================================================== * kityminder - v1.3.5 - 2015-05-15 * https://github.com/fex-team/kityminder * GitHub: https://github.com/fex-team/kityminder.git * Copyright (c) 2015 f-cube @ FEX; Licensed MIT * ==================================================== */ SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(toElement) { return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM()); }; !function(window){function getMetaKeyCode(a){var b=4096,c=8192,d=16384,e=0;return"string"==typeof a?a.toLowerCase().split(/\+\s*/).forEach(function(a){switch(a){case"ctrl":case"cmd":e|=b;break;case"alt":e|=c;break;case"shift":e|=d;break;default:e|=keymap[a]}}):((a.ctrlKey||a.metaKey)&&(e|=b),a.altKey&&(e|=c),a.shiftKey&&(e|=d),e|=a.keyCode),e}function updateCircle(a,b,c){var d=b.getStyle("padding-left"),e=b.getStyle("padding-right"),f=b.getStyle("padding-top"),g=b.getStyle("padding-bottom"),h=Math.max(c.width,c.height),i={x:c.x-d,y:c.y-f,width:h+d+e,height:h+f+g},j=b.isSelected()?"selected-":"";return h=Math.max(i.width,i.height),a.setPosition(i.x,i.y).setSize(h,h).setRadius(h/2).fill(b.getData("background")||b.getStyle(j+"background")||b.getStyle("background")).stroke(b.getStyle(j+"stroke"||b.getStyle("stroke")),b.getStyle(j+"stroke-width")),new kity.Box(i)}function asc(a,b){return a.getIndex()-b.getIndex()}function desc(a,b){return-asc(a,b)}function canArrange(a){var b=a.getSelectedNode();return b&&b.parent&&b.parent.children.length>1}!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b=a.length,c=_.type(a);return"function"===c||_.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(_.isFunction(b))return _.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return _.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(ha.test(b))return _.filter(b,a,c);b=_.filter(b,a)}return _.grep(a,function(a){return U.call(b,a)>=0!==c})}function e(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function f(a){var b=oa[a]={};return _.each(a.match(na)||[],function(a,c){b[c]=!0}),b}function g(){Z.removeEventListener("DOMContentLoaded",g,!1),a.removeEventListener("load",g,!1),_.ready()}function h(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=_.expando+Math.random()}function i(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(ua,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:ta.test(c)?_.parseJSON(c):c}catch(e){}sa.set(a,b,c)}else c=void 0;return c}function j(){return!0}function k(){return!1}function l(){try{return Z.activeElement}catch(a){}}function m(a,b){return _.nodeName(a,"table")&&_.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function n(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function o(a){var b=Ka.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function p(a,b){for(var c=0,d=a.length;d>c;c++)ra.set(a[c],"globalEval",!b||ra.get(b[c],"globalEval"))}function q(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(ra.hasData(a)&&(f=ra.access(a),g=ra.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)_.event.add(b,e,j[e][c])}sa.hasData(a)&&(h=sa.access(a),i=_.extend({},h),sa.set(b,i))}}function r(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&_.nodeName(a,b)?_.merge([a],c):c}function s(a,b){var c=b.nodeName.toLowerCase();"input"===c&&ya.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function t(b,c){var d,e=_(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:_.css(e[0],"display");return e.detach(),f}function u(a){var b=Z,c=Oa[a];return c||(c=t(a,b),"none"!==c&&c||(Na=(Na||_("').appendTo(this.__element),f(this.__element).addClass(c.classPrefix+"ppanel")},__position:function(){var a=null,b=c.classPrefix+"ppanel-position";f(this.__element).addClass(b),a=this.__getLocation(),f(this.__element).css("top",a.top+"px").css("left",a.left+"px")},__resize:function(){var a=b.getBound(this.__target);switch(this.__options.resize){case"all":this.__resizeWidth(a),this.__resizeHeight();break;case"width":this.__resizeWidth(a);break;case"height":this.__resizeHeight()}},__resizeWidth:function(a){if(this.__target){var b=f(this.__element),c=b.outerWidth(),d=b.outerHeight(),e=a.width-c-d;this.__element.style.minWidth=e+"px"}},__resizeHeight:function(){var a=null,c=null,d=0;c=b.getRect(this.__element),c.height=this.__element.scrollHeight,c.bottom=c.top+c.height,a=this.__getBoundRect(),d=c.bottom-a.bottom,d>0?(this.__height_resized=!0,d=c.height-d-this.__options.diff,f(this.__element).css("height",d+"px")):this.__height_resized&&(this.__element.style.height=null)},__getLocation:function(){var a=b.getBound(this.__target);switch(this.__layout){case e.CENTER:case e.MIDDLE:return this.__getCenterLayout(a);case e.LEFT:case e.RIGHT:case e.BOTTOM:case e.TOP:return this.__getOuterLayout(a);default:return this.__getInnerLayout(a)}return location},__getCenterLayout:function(a){var c={top:0,left:0},d=b.getRect(this.__element),e=0;return e=a.height-d.height,e>0&&(c.top=a.top+e/2),e=a.width-d.width,e>0&&(c.left=a.left+e/2),c},__getOuterLayout:function(a){var c={top:0,left:0},d=b.getRect(this.__element);switch(this.__layout){case e.TOP:c.left=a.left,c.top=a.top-d.height;break;case e.LEFT:c.top=a.top,c.left=a.left-d.width;break;case e.RIGHT:c.top=a.top,c.left=a.right;break;case e.BOTTOM:default:c.left=a.left,c.top=a.bottom}return c},__getInnerLayout:function(a){var c={top:0,left:0},d=a,f=b.getRect(this.__element);switch(this.__layout){case e.LEFT_TOP:c.top=d.top,c.left=d.left;break;case e.RIGHT_TOP:c.top=d.top,c.left=d.left+d.width-f.width;break;case e.LEFT_BOTTOM:c.top=d.top+d.height-f.height,c.left=d.left;break;case e.RIGHT_BOTTOM:c.top=d.top+d.height-f.height,c.left=d.left+d.width-f.width}return this.__correctionLocation(c)},__getBoundRect:function(){var a=-1,c=-1,d=null;return"body"===this.__options.bound.tagName.toLowerCase()?(d=b.getView(this.__options.bound),a=f(d).width(),c=f(d).height(),{top:0,left:0,right:a,bottom:c,width:a,height:c}):b.getRect(this.__options.bound)},__correctionLocation:function(a){var c=b.getRect(this.__element),d=b.getRect(this.__target),f=this.__getBoundRect();switch(this.__layout){case e.LEFT_TOP:case e.LEFT_BOTTOM:a.left+c.width>f.right&&(a.left+=d.width-c.width);break;case e.RIGHT_TOP:case e.RIGHT_BOTTOM:a.lefta||a>=this.__options.items.length||(c=this.__currentSelected,this.__currentSelected=a,e=this.__options.items[this.__currentSelected],d=e+" "+(this.__options.suffix||""),this.__inputWidget.setValue(d),b!==!1&&this.trigger("change",{from:this.__options.items[c]||null,to:e}))},__initOptions:function(){var a=this.__options.items;this.callBase(),this.widgetName="SpinButton",this.__tpl=d,this.__buttons=[],this.__panelWidget=null,this.__inputWidget=null,this.__currentSelected=-1,b.each(a,function(b,c){a[b]=c+""})}})}},_p[58]={value:function(a){var b=_p.r(4),c=_p.r(12),d=_p.r(33),e=_p.r(37),f=_p.r(51);return _p.r(13).createClass("Tabs",{base:_p.r(60),constructor:function(a){var c={selected:0,buttons:[],panels:[]};a=b.extend({},c,a),this.callBase(a)},getButtons:function(){return this.__btns},getButton:function(a){return this.getButtons()[a]||null},getButtonByValue:function(a){var c=null;return b.each(this.__btns,function(b,d){return d.getValue()===a?(c=d,!1):void 0}),c},getPanels:function(){return this.__panels},getPanel:function(a){return this.getPanels()[a]||null},getPanelByValue:function(a){var c=null;return b.each(this.__panels,function(b,d){return d.getValue()===a?(c=d,!1):void 0}),c},getSelectedIndex:function(){return this.__selected},getSelected:function(){var a=this.getSelectedIndex();return{button:this.getButton(a),panel:this.getPanel(a)}},appendTab:function(a){return a.panels=a.panels||[],this.__renderByOptions(a)},removeTab:function(a){if(0>a)return null;var b=this.__btns.splice(a,1),c=this.__panels.splice(a,1);return b.length?(b=b[0],c=c[0],b.remove(),c.remove(),{button:b,panel:c}):null},select:function(a){var b=null;return this.__selectItem(a)?(b=this.__getInfo(a),this.trigger("tabsselect",b),this.__prevSelected!==this.__selected&&this.trigger("tabschange",{from:this.__getInfo(this.__prevSelected),to:b}),this):this},getIndexByButton:function(a){return b.inArray(a,this.__btns)},appendButtonTo:function(a){b.each(this.__btns,function(b,c){c.appendTo(a)})},appendPanelTo:function(a){b.each(this.__panels,function(b,c){c.appendTo(a)})},__render:function(){this.callBase(),this.__btnWrap=b(".fui-tabs-button-wrap",this.__element)[0],this.__panelWrap=b(".fui-tabs-panel-wrap",this.__element)[0],this.__renderByOptions(this.__options),this.__selectItem(this.__options.selected)},__renderByOptions:function(a){var c=this,d=[],g=this.__btns,h=this.__panels,i=this.__btnWrap,j=this.__panelWrap;return b.each(a.buttons,function(b,k){var l=null,m=null;"object"!=typeof k&&(k={label:k}),l=new e(k),l.on("click",function(){c.select(c.getIndexByButton(this))}),k=a.panels[b]||{},k.hide=!0,m=new f(k),g.push(l),h.push(m),d.push({button:l,panel:m}),l.appendTo(i),m.appendTo(j)}),d},__initOptions:function(){this.callBase(),this.widgetName="Tabs",this.__tpl=d,this.__btns=[],this.__panels=[],this.__prevSelected=-1,this.__selected=-1,this.__btnWrap=null,this.__panelWrap=null,null===this.__options.panels&&(this.__options.panels=[],this.__options.panels.length=this.__options.buttons.length)},__selectItem:function(a){var b=this.getButton(a),d=this.getButton(this.__selected),e=c.classPrefix+"selected";return b?(d&&(d.removeClass(e),this.getPanel(this.__selected).hide()),b.addClass(e),this.getPanel(a).show(),this.__prevSelected=this.__selected,this.__selected=a,!0):!1},__getInfo:function(a){return{index:a,button:this.getButton(a),panel:this.getPanel(a)}}})}},_p[59]={value:function(a){var b=_p.r(4),c=_p.r(12);return _p.r(13).createClass("ToggleButton",{base:_p.r(37),constructor:function(a){var c={pressed:!1};a=b.extend({},c,a),this.callBase(a)},isPressed:function(){return this.__state},press:function(){var a=c.classPrefix+"button-pressed";b(this.__element).addClass(a), this.__updateState(!0)},bounce:function(){var a=c.classPrefix+"button-pressed";b(this.__element).removeClass(a),this.__updateState(!1)},toggle:function(){this.__state?this.bounce():this.press()},__initOptions:function(){this.callBase(),this.widgetName="ToggleButton",this.__state=!1},__render:function(){return this.callBase(),b(this.__element).addClass(c.classPrefix+"toggle-button"),this.__initButtonState(),this},__initButtonState:function(){this.__options.pressed&&(b(this.__element).addClass(c.classPrefix+"button-pressed"),this.__state=!0)},__initEvent:function(){this.callBase(),this.on("click",function(){this.toggle()})},__updateState:function(a){a=!!a,this.__state=a,this.trigger("change",a,!a)}})}},_p[60]={value:function(a){function b(){return c+ ++d}var c="_fui_",d=0,e=_p.r(12),f=_p.r(11),g=_p.r(4),h=_p.r(13),i=h.createClass("Widget",{constructor:function(a){var b={id:null,className:"",disabled:!1,preventDefault:!1,text:"",value:null,hide:!1,width:null,height:null};this.__widgetType="widget",this.__tpl="",this.__compiledTpl="",this.__options={},this.__element=null,this.__allow_focus=!!e.allowFocus,this.widgetName="Widget",this.__extendOptions(b,a),this.__initOptions(),this.__render(),this.__initEvent(),this.__initWidgets&&this.__initWidgets()},getId:function(){return this.id},getValue:function(){return this.__options.value},getOptions:function(){return this.__options},setValue:function(a){return this.__options.value=a,this},show:function(){return this.__show(),this},hide:function(){return this.__hide(),this},addClass:function(a){return g(this.__element).addClass(a),this},removeClass:function(a){return g(this.__element).removeClass(a),this},setStyle:function(){return g.fn.css.apply(g(this.__element),arguments),this},getStyle:function(){return g.fn.css.apply(g(this.__element),arguments)},isDisabled:function(){return this.__options.disabled},enable:function(){return this.__options.disabled=!1,g(this.__element).removeClass(e.classPrefix+"disabled"),this},disable:function(){return this.__options.disabled=!0,g(this.__element).addClass(e.classPrefix+"disabled"),this},cloneElement:function(){return this.__element.cloneNode(!0)},getElement:function(){return this.__element},appendTo:function(a){if(h.isElement(a))a.appendChild(this.__element);else{if(!(a instanceof i))throw new Error("TypeError: Widget.appendTo()");a.__appendChild(this)}return this},remove:function(){var a=this.__element.parentNode;return a&&a.removeChild(this.__element),this},off:function(a,b){return g(this.__element).off(b&&b.__fui_listener),this},on:function(a,b){return this.__options.preventDefault||this.__on(a,b),this},__initOptions:function(){},__render:function(){var a=null,b=this.__tpl,c=this.__options,d=null;return this.id=this.__id(),f.__registerInstance(this),this.__compiledTpl=h.Tpl.compile(b,c),this.__element=g(this.__compiledTpl)[0],this.__element.setAttribute("id",this.id),a=g(this.__element),c.disabled&&a.addClass(e.classPrefix+"disabled"),a.addClass(e.classPrefix+"widget"),d=c.className,d.length>0&&a.addClass(g.isArray(d)?d.join(" "):d),this.__initBasicEnv(),c.hide&&this.__hide(),c.style&&this.setStyle(c.style),this},__appendChild:function(a){return this.__element.appendChild(a.getElement())},__initEvent:function(){this.on("mousedown",function(a){var b=a.target.tagName.toLowerCase();e.control[b]||this.__allowFocus()?a.stopPropagation():a.preventDefault()})},__on:function(a,b){var c=this;return b.__fui_listener=function(a,d){for(var e=[],f=0,g=arguments.length;g>f;f++)1!==f&&e.push(arguments[f]);return a.widget=d,c.isDisabled()?void 0:b.apply(c,e)},g(this.__element).on(a,b.__fui_listener),this},trigger:function(a,b){return this.__options.preventDefault||this.__trigger.apply(this,arguments),this},__allowShowTitle:function(){return!0},__allowFocus:function(){return!!this.__allow_focus},__trigger:function(a,b){var c=[].slice.call(arguments,1);return g(this.__element).trigger(a,[this].concat(c)),this},__triggerHandler:function(a,b){var c=[this].concat([].slice.call(arguments,1));return g(this.__element).triggerHandler(a,c)},__fire:function(a,b){var c={cancel:!1};return/^(before|after)/.test(a)?this:(this.__trigger("before"+a,c),c.cancel===!0?this:(c=b.call(this,a),this.__trigger(a),this.__trigger("after"+a,c),this))},__extendOptions:function(){var a=[{},this.__options],b=[!0];a=a.concat([].slice.call(arguments,0));for(var c=0,d=a.length;d>c;c++)"string"!=typeof a[c]&&b.push(a[c]);this.__options=g.extend.apply(g,b)},__hide:function(){g(this.__element).addClass(e.classPrefix+"hide")},__show:function(){g(this.__element).removeClass(e.classPrefix+"hide")},__initBasicEnv:function(){this.__options.text&&this.__allowShowTitle()&&this.__element.setAttribute("title",this.__options.text),this.__options.width&&(this.__element.style.width=this.__options.width+"px"),this.__options.height&&(this.__element.style.height=this.__options.height+"px"),this.widgetName&&this.__element.setAttribute("rule",this.widgetName)},__id:function(){return this.__options.id||b()}});return i}},_p[61]={value:function(a){_p.r(1),_p.r(2)}};var moduleMapping={"fui.export":61};use("fui.export")}(),function(a){function b(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a}function c(){Error.apply(this,arguments)}function d(a){if(Error.call(this,a),"object"==typeof a)for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);else this.detail=a}function e(a,b){this.id=a,this.username=b}function f(a){this.content=a,a instanceof Blob?this.type=j.file.TYPE_BLOB:"string"==typeof a?this.type=j.file.TYPE_TEXT:"object"==typeof a?this.type=j.file.TYPE_JSON:this.type=j.file.TYPE_UNKNOWN}function g(a){this.setPath(a),this.isDir=!1,this.data=null,this.size=0,this.createTime=new Date,this.modifyTime=new Date}function h(a,b,c){this.user=a,this.file=b,this.access=c||0}function i(a,b,c){this.path=a,this.method=b,this.user=c,this.dupPolicy=j.file.DUP_FAIL,this.newPath=null,this.acl=null,this.extra=null,this.dataType=j.file.TYPE_TEXT}var j={version:"1.0"};j.provider={},j.file={},j.user={};var k={},l=null,m=function(){return new a.resolve(null)},n={check:m,login:m,logout:m,init:m,current:m};b(c,Error),b(d,Error),j.AuthError=c,j.FileRequestError=d,g.prototype.setPath=function(a){j.file.anlysisPath(a,this)},j.file.anlysisPath=function(a,b){b=b||{};for(var c=a.split("/");"/"==c[0]||""===c[0];)c.shift();for(;"/"==c[c.length-1]||""===c[c.length-1];)c.pop();if(b.filename=c.pop()||null,c.length?b.parentPath="/"+c.join("/")+"/":b.parentPath=b.filename?"/":null,b.filename){var d=b.filename.split(".");d.length>1?b.extension="."+d.pop():b.extension=null,b.name=d.join("."),b.path=b.parentPath+b.filename}else b.path="/";return b},j.user.User=e,j.file.Data=f,j.file.File=g,j.file.Acl=h,j.file.FileRequest=i,j.file.TYPE_TEXT="text",j.file.TYPE_JSON="json",j.file.TYPE_BLOB="blob",j.file.TYPE_UNKNOWN="unknown",j.file.METHOD_READ="read",j.file.METHOD_WRITE="write",j.file.METHOD_LIST="list",j.file.METHOD_MOVE="move",j.file.METHOD_DELETE="delete",j.file.METHOD_MKDIR="mkdir",j.file.METHOD_ACL_READ="readAcl",j.file.METHOD_ACL_WRITE="writeAcl",j.file.DUP_OVERWRITE="overwrite",j.file.DUP_FAIL="fail",j.file.DUP_RENAME="rename",j.file.ACCESS_PUBLIC=1,j.file.ACCESS_READ=2,j.file.ACCESS_WRITE=4,j.file.ACCESS_CREATE=8,j.file.ACCESS_DELETE=16,j.file.ACCESS_ACL_READ=32,j.file.ACCESS_ACL_WRITE=64,j.file.ACCESS_ALL=65534,j.provider.register=function(a,b){if(k[a]=b,l||(l=b),"function"!=typeof b.handle)throw new Error("Not implement: provider.handle()")},j.provider.use=function(a){l=k[a]},j.provider.init=function(a,b){var c=k[a];return c&&"function"==typeof c.init?c.init.call(c,b):null},j.user.impl=function(a){n=a},["check","login","logout","init","current"].forEach(function(a){j.user[a]=function(){return n[a].apply(n,arguments)}}),["read","write","list","move","delete","mkdir","readAcl","writeAcl"].forEach(function(b){j.file[b]=function(c){return j.user.check().then(function(d){var e=c.provider?k[c.provider]:l,f=new i(c.path,b,d);"read"==b&&(f.dataType=c.dataType||j.file.TYPE_TEXT),"write"==b&&(f.dupPolicy=c.ondup,f.data=new j.file.Data(c.content),delete c.ondup),"move"==b&&(f.dupPolicy=c.ondup,f.newPath=c.newPath,delete c.newPath),"writeAcl"==b&&(f.acl=c.acl,delete c.acl),delete c.provider,delete c.path,f.extra=c;var g=e.handle(f);return a.resolve(g)})}}),window.fio=j}(Promise),function(a,b){function c(a){m=a.apiKey||m}function d(a){return new Promise(function(c,d){b.ajax(a).done(c).fail(d)})}function e(){for(var a,b=p.current,c=/[&\?#](\w+?)=([^&]+)/g,d={};a=c.exec(b);)d[a[1]]=a[2];return d}function f(){var a=document.cookie,b=new RegExp(m+"_ak=(.*?)(;|$)"),c=b.exec(a);return c&&decodeURIComponent(c[1])||null}function g(a,b){var c=m+"_ak="+encodeURIComponent(a);c+="; max-age="+(b||60),document.cookie=c}function h(){document.cookie=m+"_ak="}function i(){return o}function j(){function a(){return new Promise(function(a,b){function c(){return clearTimeout(g),!e&&f.length&&(g=setTimeout(c,f.shift())),d({url:p.getLoggedInUser,data:{access_token:n},dataType:"jsonp"}).then(function(b){clearTimeout(g),e||a(b),e=!0})}var e=!1,f=[1e3,2e3,3e3],g=0;c()})}if(o&&+new Date-o.validateTime<36e5)return Promise.resolve(o);if(j.pendingRequest)return j.pendingRequest;var b=e();return b.access_token?(g(b.access_token,b.state),document.location.href=p.current.substr(0,document.location.href.indexOf("#")),j.pendingRequest=new Promise(function(){})):(n=f())?j.pendingRequest=a().then(function(a){return a.error_code?(n=null,h(),null):(o=new fio.user.User(a.uid,a.uname),o.smallImage="http://tb.himg.baidu.com/sys/portraitn/item/"+a.portrait,o.largeImage="http://tb.himg.baidu.com/sys/portrait/item/"+a.portrait,o.access_token=n,o.validateTime=+new Date,j.pendingRequest=null,o)}):Promise.resolve(null)}function k(b){return a.location.href=p.authorize+"?"+["client_id="+m,"response_type=token","scope=basic netdisk","redirect_uri="+(b.redirectUrl||p.current),"display=page","force_login="+(b&&b.force?1:0),"state="+(b.remember||60)].join("&"),new Promise(function(){})}function l(){var a=o;return o=null,n=null,h(),Promise.resolve(a)}var m,n,o,p={authorize:"https://openapi.baidu.com/oauth/2.0/authorize",getLoggedInUser:"https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser",current:a.location.href};fio.user.impl({check:j,login:k,logout:l,init:c,current:i})}(window,jQuery),function(a,b){function c(a){return a.cache=!1,new Promise(function(c,d){b.ajax(a).done(c).fail(d)})}function d(a){return new Promise(function(b){setTimeout(function(){b()},a)})}function e(a){var b=new fio.file.File(a.path);return b.createTime=new Date(1e3*a.ctime),b.modifyTime=new Date(1e3*a.mtime),b.size=a.size,b.isDir=!!a.isdir,b.provider="netdisk",b}function f(a){function b(){return c({url:h.file,data:{method:"meta",access_token:e,path:a},dataType:"json"})["catch"](function(a){if(b.retry++>2)throw a;return new Promise(function(a){setTimeout(function(){a(b())},200*b.retry)})})}var d=fio.user.current(),e=d&&d.access_token;if(!e)throw new Error("Not Authorized");return b.retry=0,b()}function g(g){function i(){function b(b){if(a.console.warn("PCS Fail("+ ++p+"): ",{request:g,error:b}),o--)return d(1e3*p).then(i);throw b.requestMethod=g.method,b.requestPath=g.path,b.requestUser=g.user&&g.user.username||null,b.requestParam=l,g.dataType&&(b.requestDataType=g.dataType),b}function h(a){function b(a){return a.list[0]}if(a.error_code)throw new fio.FileRequestError(a);if(g.method===fio.file.METHOD_READ)return f(l.path).then(b).then(e).then(function(b){return b.data=new fio.file.Data(a),b});if(g.method==fio.file.METHOD_LIST)return a.list.map(e);if(g.method==fio.file.METHOD_MOVE)return new Promise(function(c){setTimeout(function(){c(f(a.extra.list[0].to).then(b).then(e))},200)});if(g.method==fio.file.METHOD_DELETE)return new fio.file.File(g.path);var c=e(a);return g.method===fio.file.METHOD_WRITE&&(c.data=g.data),c}function j(a){var c=a.responseText,d={readyState:a.readyState,status:a.status,statusText:a.statusText,headers:a.getAllResponseHeaders(),responseText:c};if(c)try{d.detail=JSON.parse(c)}catch(e){}return b(new fio.FileRequestError(d))}return c(m).then(h,j)}var j=fio.user.current(),k=j&&j.access_token;if(!k)throw new Error("Not Authorized");var l={},m={url:h.file,type:"GET",dataType:"JSON"};switch(g.method){case fio.file.METHOD_ACL_READ:case fio.file.METHOD_ACL_WRITE:throw new Error("Not Supported File Request:"+g.method);case fio.file.METHOD_READ:m.dataType=g.dataType,l.method="download";break;case fio.file.METHOD_WRITE:m.type="POST",l.method="upload",l.ondup=g.dupPolicy==fio.file.DUP_OVERWRITE?"overwrite":"newcopy";var n=new FormData;g.data.type==fio.file.TYPE_BLOB?n.append("file",g.data.content):n.append("file",new Blob([g.data.content],{type:"text/plain"})),m.data=n,m.processData=!1,m.contentType=!1;break;case fio.file.METHOD_LIST:l.method="list";break;case fio.file.METHOD_MKDIR:m.type="POST",l.method="mkdir";break;case fio.file.METHOD_MOVE:m.type="POST",l.method="move",l.to=g.newPath,g.dupPolicy==fio.file.DUP_RENAME&&(l.ondup="newcopy");break;case fio.file.METHOD_DELETE:m.type="POST",l.method="delete"}g.method==fio.file.METHOD_MOVE?l.from=g.path:l.path=g.path,m.url+="?"+b.param(l)+"&access_token="+k;var o=void 0===g.extra.retry?3:parseInt(g.extra.retry,10),p=0;return i()}var h={file:"https://pcs.baidu.com/rest/2.0/pcs/file"};fio.provider.register("netdisk",{handle:g})}(window,jQuery),function(){function a(a){this.tokens=[],this.tokens.links={},this.options=a||j.defaults,this.rules=k.normal,this.options.gfm&&(this.options.tables?this.rules=k.tables:this.rules=k.gfm)}function b(a,b){if(this.options=b||j.defaults,this.links=a,this.rules=l.normal,this.renderer=this.options.renderer||new c,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=l.breaks:this.rules=l.gfm:this.options.pedantic&&(this.rules=l.pedantic)}function c(a){this.options=a||{}}function d(a){this.tokens=[],this.token=null,this.options=a||j.defaults,this.options.renderer=this.options.renderer||new c,this.renderer=this.options.renderer,this.renderer.options=this.options}function e(a,b){return a.replace(b?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function f(a){return a.replace(/&([#\w]+);/g,function(a,b){return b=b.toLowerCase(),"colon"===b?":":"#"===b.charAt(0)?String.fromCharCode("x"===b.charAt(1)?parseInt(b.substring(2),16):+b.substring(1)):""})}function g(a,b){return a=a.source,b=b||"",function c(d,e){return d?(e=e.source||e,e=e.replace(/(^|[^\[])\^/g,"$1"),a=a.replace(d,e),c):new RegExp(a,b)}}function h(){}function i(a){for(var b,c,d=1;dAn error occured:

"+e(m.message+"",!0)+"
";throw m}}var k={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:h,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:h,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:h,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};k.bullet=/(?:[*+-]|\d+\.)/,k.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,k.item=g(k.item,"gm")(/bull/g,k.bullet)(),k.list=g(k.list)(/bull/g,k.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+k.def.source+")")(),k.blockquote=g(k.blockquote)("def",k.def)(),k._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",k.html=g(k.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,k._tag)(),k.paragraph=g(k.paragraph)("hr",k.hr)("heading",k.heading)("lheading",k.lheading)("blockquote",k.blockquote)("tag","<"+k._tag)("def",k.def)(),k.normal=i({},k),k.gfm=i({},k.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),k.gfm.paragraph=g(k.paragraph)("(?!","(?!"+k.gfm.fences.source.replace("\\1","\\2")+"|"+k.list.source.replace("\\1","\\3")+"|")(),k.tables=i({},k.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),a.rules=k,a.lex=function(b,c){var d=new a(c);return d.lex(b)},a.prototype.lex=function(a){return a=a.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(a,!0)},a.prototype.token=function(a,b,c){for(var d,e,f,g,h,i,j,l,m,a=a.replace(/^ +$/gm,"");a;)if((f=this.rules.newline.exec(a))&&(a=a.substring(f[0].length),f[0].length>1&&this.tokens.push({type:"space"})),f=this.rules.code.exec(a))a=a.substring(f[0].length),f=f[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?f:f.replace(/\n+$/,"")});else if(f=this.rules.fences.exec(a))a=a.substring(f[0].length),this.tokens.push({type:"code",lang:f[2],text:f[3]});else if(f=this.rules.heading.exec(a))a=a.substring(f[0].length),this.tokens.push({type:"heading",depth:f[1].length,text:f[2]});else if(b&&(f=this.rules.nptable.exec(a))){for(a=a.substring(f[0].length),i={type:"table",header:f[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:f[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:f[3].replace(/\n$/,"").split("\n")},l=0;l ?/gm,""),this.token(f,b,!0),this.tokens.push({type:"blockquote_end"});else if(f=this.rules.list.exec(a)){for(a=a.substring(f[0].length),g=f[2],this.tokens.push({type:"list_start",ordered:g.length>1}),f=f[0].match(this.rules.item),d=!1,m=f.length,l=0;m>l;l++)i=f[l],j=i.length,i=i.replace(/^ *([*+-]|\d+\.) +/,""),~i.indexOf("\n ")&&(j-=i.length,i=this.options.pedantic?i.replace(/^ {1,4}/gm,""):i.replace(new RegExp("^ {1,"+j+"}","gm"),"")),this.options.smartLists&&l!==m-1&&(h=k.bullet.exec(f[l+1])[0],g===h||g.length>1&&h.length>1||(a=f.slice(l+1).join("\n")+a,l=m-1)),e=d||/\n\n(?!\s*$)/.test(i),l!==m-1&&(d="\n"===i.charAt(i.length-1),e||(e=d)),this.tokens.push({type:e?"loose_item_start":"list_item_start"}),this.token(i,!1,c),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(f=this.rules.html.exec(a))a=a.substring(f[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===f[1]||"script"===f[1]||"style"===f[1],text:f[0]});else if(!c&&b&&(f=this.rules.def.exec(a)))a=a.substring(f[0].length),this.tokens.links[f[1].toLowerCase()]={href:f[2],title:f[3]};else if(b&&(f=this.rules.table.exec(a))){for(a=a.substring(f[0].length),i={type:"table",header:f[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:f[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:f[3].replace(/(?: *\| *)?\n$/,"").split("\n")},l=0;l])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:h,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:h,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,l.link=g(l.link)("inside",l._inside)("href",l._href)(),l.reflink=g(l.reflink)("inside",l._inside)(),l.normal=i({},l),l.pedantic=i({},l.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),l.gfm=i({},l.normal,{escape:g(l.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:g(l.text)("]|","~]|")("|","|https?://|")()}),l.breaks=i({},l.gfm,{br:g(l.br)("{2,}","*")(),text:g(l.gfm.text)("{2,}","*")()}),b.rules=l,b.output=function(a,c,d){var e=new b(c,d);return e.output(a)},b.prototype.output=function(a){for(var b,c,d,f,g="";a;)if(f=this.rules.escape.exec(a))a=a.substring(f[0].length),g+=f[1];else if(f=this.rules.autolink.exec(a))a=a.substring(f[0].length),"@"===f[2]?(c=this.mangle(":"===f[1].charAt(6)?f[1].substring(7):f[1]),d=this.mangle("mailto:")+c):(c=e(f[1]),d=c),g+=this.renderer.link(d,null,c);else if(this.inLink||!(f=this.rules.url.exec(a))){if(f=this.rules.tag.exec(a))!this.inLink&&/^/i.test(f[0])&&(this.inLink=!1),a=a.substring(f[0].length),g+=this.options.sanitize?e(f[0]):f[0];else if(f=this.rules.link.exec(a))a=a.substring(f[0].length),this.inLink=!0,g+=this.outputLink(f,{href:f[2],title:f[3]}),this.inLink=!1;else if((f=this.rules.reflink.exec(a))||(f=this.rules.nolink.exec(a))){if(a=a.substring(f[0].length),b=(f[2]||f[1]).replace(/\s+/g," "),b=this.links[b.toLowerCase()],!b||!b.href){g+=f[0].charAt(0),a=f[0].substring(1)+a;continue}this.inLink=!0,g+=this.outputLink(f,b),this.inLink=!1}else if(f=this.rules.strong.exec(a))a=a.substring(f[0].length),g+=this.renderer.strong(this.output(f[2]||f[1]));else if(f=this.rules.em.exec(a))a=a.substring(f[0].length),g+=this.renderer.em(this.output(f[2]||f[1]));else if(f=this.rules.code.exec(a))a=a.substring(f[0].length),g+=this.renderer.codespan(e(f[2],!0));else if(f=this.rules.br.exec(a))a=a.substring(f[0].length),g+=this.renderer.br();else if(f=this.rules.del.exec(a))a=a.substring(f[0].length),g+=this.renderer.del(this.output(f[1]));else if(f=this.rules.text.exec(a))a=a.substring(f[0].length),g+=e(this.smartypants(f[0]));else if(a)throw new Error("Infinite loop on byte: "+a.charCodeAt(0))}else a=a.substring(f[0].length),c=e(f[1]),d=c,g+=this.renderer.link(d,null,c);return g},b.prototype.outputLink=function(a,b){var c=e(b.href),d=b.title?e(b.title):null;return"!"!==a[0].charAt(0)?this.renderer.link(c,d,this.output(a[1])):this.renderer.image(c,d,e(a[1]))},b.prototype.smartypants=function(a){return this.options.smartypants?a.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):a},b.prototype.mangle=function(a){for(var b,c="",d=a.length,e=0;d>e;e++)b=a.charCodeAt(e),Math.random()>.5&&(b="x"+b.toString(16)),c+="&#"+b+";";return c},c.prototype.code=function(a,b,c){if(this.options.highlight){var d=this.options.highlight(a,b);null!=d&&d!==a&&(c=!0,a=d)}return b?'
'+(c?a:e(a,!0))+"\n
\n":"
"+(c?a:e(a,!0))+"\n
"},c.prototype.blockquote=function(a){return"
\n"+a+"
\n"},c.prototype.html=function(a){return a},c.prototype.heading=function(a,b,c){return"'+a+"\n"},c.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"},c.prototype.list=function(a,b){var c=b?"ol":"ul";return"<"+c+">\n"+a+"\n"},c.prototype.listitem=function(a){return"
  • "+a+"
  • \n"},c.prototype.paragraph=function(a){return"

    "+a+"

    \n"},c.prototype.table=function(a,b){return"\n\n"+a+"\n\n"+b+"\n
    \n"},c.prototype.tablerow=function(a){return"\n"+a+"\n"},c.prototype.tablecell=function(a,b){var c=b.header?"th":"td",d=b.align?"<"+c+' style="text-align:'+b.align+'">':"<"+c+">";return d+a+"\n"},c.prototype.strong=function(a){return""+a+""},c.prototype.em=function(a){return""+a+""},c.prototype.codespan=function(a){return""+a+""},c.prototype.br=function(){return this.options.xhtml?"
    ":"
    "},c.prototype.del=function(a){return""+a+""},c.prototype.link=function(a,b,c){if(this.options.sanitize){try{var d=decodeURIComponent(f(a)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(0===d.indexOf("javascript:"))return""}var g='
    "},c.prototype.image=function(a,b,c){var d=''+c+'":">"},d.parse=function(a,b,c){var e=new d(b,c);return e.parse(a)},d.prototype.parse=function(a){this.inline=new b(a.links,this.options,this.renderer),this.tokens=a.reverse();for(var c="";this.next();)c+=this.tok();return c},d.prototype.next=function(){return this.token=this.tokens.pop()},d.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},d.prototype.parseText=function(){for(var a=this.token.text;"text"===this.peek().type;)a+="\n"+this.next().text;return this.inline.output(a)},d.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var a,b,c,d,e,f="",g="";for(c="",a=0;a$e&&setTimeout(pe(yb,this,!0),20),Cb(this),De(),_a(this),this.curOp.forceUpdate=!0,Cd(this,e),d.autofocus&&!jf||xe()==f.input?setTimeout(pe(Zb,this),20):$b(this);for(var g in Hf)Hf.hasOwnProperty(g)&&Hf[g](this,d[g],If);u(this);for(var h=0;h$e&&(c.gutters.style.zIndex=-1,c.scroller.style.paddingRight=0),hf&&(d.style.width="0px"),_e||(c.scroller.draggable=!0),ef&&(c.inputDiv.style.height="1px",c.inputDiv.style.position="absolute"),Ze&&8>$e&&(c.scrollbarH.style.minHeight=c.scrollbarV.style.minWidth="18px"),a.appendChild?a.appendChild(c.wrapper):a(c.wrapper),c.viewFrom=c.viewTo=b.first, c.view=[],c.externalMeasured=null,c.viewOffset=0,c.lastSizeC=0,c.updateLineNumbers=null,c.lineNumWidth=c.lineNumInnerWidth=c.lineNumChars=null,c.prevInput="",c.alignWidgets=!1,c.pollingFast=!1,c.poll=new he,c.cachedCharWidth=c.cachedTextHeight=c.cachedPaddingH=null,c.inaccurateSelection=!1,c.maxLine=null,c.maxLineLength=0,c.maxLineChanged=!1,c.wheelDX=c.wheelDY=c.wheelStartX=c.wheelStartY=null,c.shift=!1,c.selForContextMenu=null}function c(b){b.doc.mode=a.getMode(b.options,b.doc.modeOption),d(b)}function d(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null)}),a.doc.frontier=a.doc.first,wa(a,100),a.state.modeGen++,a.curOp&&ob(a)}function e(a){a.options.lineWrapping?(Ae(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth=""):(ze(a.display.wrapper,"CodeMirror-wrap"),n(a)),g(a),ob(a),Oa(a),setTimeout(function(){r(a)},100)}function f(a){var b=Za(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/$a(a.display)-3);return function(e){if(bd(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;gb.maxLineLength&&(b.maxLineLength=c,b.maxLine=a)})}function o(a){var b=le(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):b>-1&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function p(a){return a.display.scroller.clientHeight-a.display.wrapper.clientHeightb.clientWidth;f&&b.scrollWidth<=b.clientWidth+1&&d>0&&!b.hScrollbarTakesSpace&&(f=!1);var g=e>b.clientHeight;if(g?(c.scrollbarV.style.display="block",c.scrollbarV.style.bottom=f?d+"px":"0",c.scrollbarV.firstChild.style.height=Math.max(0,e-b.clientHeight+(b.barHeight||c.scrollbarV.clientHeight))+"px"):(c.scrollbarV.style.display="",c.scrollbarV.firstChild.style.height="0"),f?(c.scrollbarH.style.display="block",c.scrollbarH.style.right=g?d+"px":"0",c.scrollbarH.firstChild.style.width=b.scrollWidth-b.clientWidth+(b.barWidth||c.scrollbarH.clientWidth)+"px"):(c.scrollbarH.style.display="",c.scrollbarH.firstChild.style.width="0"),f&&g?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=c.scrollbarFiller.style.width=d+"px"):c.scrollbarFiller.style.display="",f&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d+"px",c.gutterFiller.style.width=c.gutters.offsetWidth+"px"):c.gutterFiller.style.display="",!a.state.checkedOverlayScrollbar&&b.clientHeight>0){if(0===d){var h=kf&&!ff?"12px":"18px";c.scrollbarV.style.minWidth=c.scrollbarH.style.minHeight=h;var i=function(b){_d(b)!=c.scrollbarV&&_d(b)!=c.scrollbarH&&jb(a,Gb)(b)};ig(c.scrollbarV,"mousedown",i),ig(c.scrollbarH,"mousedown",i)}a.state.checkedOverlayScrollbar=!0}}function s(a,b,c){var d=c&&null!=c.top?Math.max(0,c.top):a.scroller.scrollTop;d=Math.floor(d-Aa(a));var e=c&&null!=c.bottom?c.bottom:d+a.wrapper.clientHeight,f=Id(b,d),g=Id(b,e);if(c&&c.ensure){var h=c.ensure.from.line,i=c.ensure.to.line;if(f>h)return{from:h,to:Id(b,Jd(Dd(b,h))+a.wrapper.clientHeight)};if(Math.min(i,b.lastLine())>=g)return{from:Id(b,Jd(Dd(b,i))-a.wrapper.clientHeight),to:i}}return{from:f,to:Math.max(g,f+1)}}function t(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=w(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo)&&0==ub(a))return!1;u(a)&&(qb(a),b.dims=F(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),g=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFromg&&c.viewTo-g<20&&(g=Math.min(e,c.viewTo)),qf&&(f=_c(a.doc,f),g=ad(a.doc,g));var h=f!=c.viewFrom||g!=c.viewTo||c.lastSizeC!=b.wrapperHeight;tb(a,f,g),c.viewOffset=Jd(Dd(a.doc,c.viewFrom)),a.display.mover.style.top=c.viewOffset+"px";var i=ub(a);if(!h&&0==i&&!b.force&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;var j=xe();return i>4&&(c.lineDiv.style.display="none"),G(a,c.updateLineNumbers,b.dims),i>4&&(c.lineDiv.style.display=""),j&&xe()!=j&&j.offsetHeight&&j.focus(),ue(c.cursorDiv),ue(c.selectionDiv),h&&(c.lastSizeC=b.wrapperHeight,wa(a,400)),c.updateLineNumbers=null,!0}function z(a,b){for(var c=b.force,d=b.viewport,e=!0;;e=!1){if(e&&a.options.lineWrapping&&b.oldScrollerWidth!=a.display.scroller.clientWidth)c=!0;else if(c=!1,d&&null!=d.top&&(d={top:Math.min(a.doc.height+Ba(a.display)-mg-a.display.scroller.clientHeight,d.top)}),b.visible=s(a.display,a.doc,d),b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)break;if(!y(a,b))break;D(a);var f=q(a);sa(a),B(a,f),r(a,f)}be(a,"update",a),(a.display.viewFrom!=b.oldViewFrom||a.display.viewTo!=b.oldViewTo)&&be(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo)}function A(a,b){var c=new x(a,b);if(y(a,c)){D(a),z(a,c);var d=q(a);sa(a),B(a,d),r(a,d)}}function B(a,b){a.display.sizer.style.minHeight=a.display.heightForcer.style.top=b.docHeight+"px",a.display.gutters.style.height=Math.max(b.docHeight,b.clientHeight-mg)+"px"}function C(a,b){a.display.sizer.offsetWidth+a.display.gutters.offsetWidth$e){var g=f.node.offsetTop+f.node.offsetHeight;e=g-c,c=g}else{var h=f.node.getBoundingClientRect();e=h.bottom-h.top}var i=f.line.height-e;if(2>e&&(e=Za(b)),(i>.001||-.001>i)&&(Gd(f.line,e),E(f.line),f.rest))for(var j=0;j=b&&l.lineNumber;l.changes&&(le(l.changes,"gutter")>-1&&(m=!1),H(a,l,j,c)),m&&(ue(l.lineNumber),l.lineNumber.appendChild(document.createTextNode(v(a.options,j)))),h=l.node.nextSibling}else{var n=P(a,l,j,c);g.insertBefore(n,h)}j+=l.size}for(;h;)h=d(h)}function H(a,b,c,d){for(var e=0;e$e&&(a.node.style.zIndex=2)),a.node}function J(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;if(b&&(b+=" CodeMirror-linebackground"),a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),a.background=null);else if(b){var c=I(a);a.background=c.insertBefore(te("div",null,b),c.firstChild)}}function K(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):qd(a,b)}function L(a,b){var c=b.text.className,d=K(a,b);b.text==b.node&&(b.node=d.pre),b.text.parentNode.replaceChild(d.pre,b.text),b.text=d.pre,d.bgClass!=b.bgClass||d.textClass!=b.textClass?(b.bgClass=d.bgClass,b.textClass=d.textClass,M(b)):c&&(b.text.className=c)}function M(a){J(a),a.line.wrapClass?I(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");var b=a.textClass?a.textClass+" "+(a.line.textClass||""):a.line.textClass;a.text.className=b||""}function N(a,b,c,d){b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null);var e=b.line.gutterMarkers;if(a.options.lineNumbers||e){var f=I(b),g=b.gutter=f.insertBefore(te("div",null,"CodeMirror-gutter-wrapper","position: absolute; left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px"),b.text);if(!a.options.lineNumbers||e&&e["CodeMirror-linenumbers"]||(b.lineNumber=g.appendChild(te("div",v(a.options,c),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+"px"))),e)for(var h=0;h=0){var g=V(f.from(),e.from()),h=U(f.to(),e.to()),i=f.empty()?e.from()==e.head:f.from()==f.head;b>=d&&--b,a.splice(--d,2,new X(i?h:g,i?g:h))}}return new W(a,b)}function Z(a,b){return new W([new X(a,b||a)],0)}function $(a,b){return Math.max(a.first,Math.min(b,a.first+a.size-1))}function _(a,b){if(b.linec?rf(c,Dd(a,c).text.length):aa(b,Dd(a,b.line).text.length)}function aa(a,b){var c=a.ch;return null==c||c>b?rf(a.line,b):0>c?rf(a.line,0):a}function ba(a,b){return b>=a.first&&b=f.ch:j.to>f.ch))){if(d&&(kg(k,"beforeCursorEnter"),k.explicitlyCleared)){if(h.markedSpans){--i;continue}break}if(!k.atomic)continue;var l=k.find(0>g?-1:1);if(0==sf(l,f)&&(l.ch+=g,l.ch<0?l=l.line>a.first?_(a,rf(l.line-1)):null:l.ch>h.text.length&&(l=l.lineb&&(b=0),b=Math.round(b),d=Math.round(d),h.appendChild(te("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?k-a:c)+"px; height: "+(d-b)+"px"))}function e(b,c,e){function f(c,d){return Ta(a,rf(b,c),"div",l,d)}var h,i,l=Dd(g,b),m=l.text.length;return Je(Kd(l),c||0,null==e?m:e,function(a,b,g){var l,n,o,p=f(a,"left");if(a==b)l=p,n=o=p.left;else{if(l=f(b-1,"right"),"rtl"==g){var q=p;p=l,l=q}n=p.left,o=l.right}null==c&&0==a&&(n=j),l.top-p.top>3&&(d(n,p.top,null,p.bottom),n=j,p.bottomi.bottom||l.bottom==i.bottom&&l.right>i.right)&&(i=l),j+1>n&&(n=j),d(n,l.top,o-n,l.bottom)}),{start:h,end:i}}var f=a.display,g=a.doc,h=document.createDocumentFragment(),i=Ca(a.display),j=i.left,k=f.lineSpace.offsetWidth-i.right,l=b.from(),m=b.to();if(l.line==m.line)e(l.line,l.ch,m.ch);else{var n=Dd(g,l.line),o=Dd(g,m.line),p=Zc(n)==Zc(o),q=e(l.line,l.ch,p?n.text.length+1:null).end,r=e(m.line,p?0:null,m.ch).start;p&&(q.top0?b.blinker=setInterval(function(){b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate):a.options.cursorBlinkRate<0&&(b.cursorDiv.style.visibility="hidden")}}function wa(a,b){a.doc.mode.startState&&a.doc.frontier=a.display.viewTo)){var c=+new Date+a.options.workTime,d=Of(b.mode,za(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var g=f.styles,h=md(a,f,d,!0);f.styles=h.styles;var i=f.styleClasses,j=h.classes;j?f.styleClasses=j:i&&(f.styleClasses=null);for(var k=!g||g.length!=f.styles.length||i!=j&&(!i||!j||i.bgClass!=j.bgClass||i.textClass!=j.textClass),l=0;!k&&lc?(wa(a,a.options.workDelay),!0):void 0}),e.length&&ib(a,function(){for(var b=0;bg;--h){if(h<=f.first)return f.first;var i=Dd(f,h-1);if(i.stateAfter&&(!c||h<=f.frontier))return h;var j=rg(i.text,null,a.options.tabSize);(null==e||d>j)&&(e=h-1,d=j)}return e}function za(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var f=ya(a,b,c),g=f>d.first&&Dd(d,f-1).stateAfter;return g=g?Of(d.mode,g):Pf(d.mode),d.iter(f,b,function(c){od(a,c.text,g);var h=f==b-1||f%5==0||f>=e.viewFrom&&f2&&f.push((i.bottom+j.top)/2-c.top)}}f.push(c.bottom-c.top)}}function Ea(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;dc)return{map:a.measure.maps[d],cache:a.measure.caches[d],before:!0}}function Fa(a,b){b=Zc(b);var c=Hd(b),d=a.display.externalMeasured=new mb(a.doc,b,c);d.lineN=c;var e=d.built=qd(a,d);return d.text=e.pre,ve(a.display.lineMeasure,e.pre),d}function Ga(a,b,c,d){return Ja(a,Ia(a,b),c,d)}function Ha(a,b){if(b>=a.display.viewFrom&&b=c.lineN&&bc?(f=0,g=1,h="left"):l>c?(f=c-k,g=f+1):(j==i.length-3||c==l&&i[j+3]>c)&&(g=l-k,f=g-1,c>=l&&(h="right")),null!=f){if(e=i[j+2],k==l&&d==(e.insertLeft?"left":"right")&&(h=d),"left"==d&&0==f)for(;j&&i[j-2]==i[j-3]&&i[j-1].insertLeft;)e=i[(j-=3)+2],h="left";if("right"==d&&f==l-k)for(;jj;j++){for(;f&&se(b.line.text.charAt(k+f));)--f;for(;l>k+g&&se(b.line.text.charAt(k+g));)++g;if(Ze&&9>$e&&0==f&&g==l-k)m=e.parentNode.getBoundingClientRect();else if(Ze&&a.options.lineWrapping){var n=ug(e,f,g).getClientRects();m=n.length?n["right"==d?n.length-1:0]:wf}else m=ug(e,f,g).getBoundingClientRect()||wf;if(m.left||m.right||0==f)break;g=f,f-=1,h="right"}Ze&&11>$e&&(m=La(a.display.measure,m))}else{f>0&&(h=d="right");var n;m=a.options.lineWrapping&&(n=e.getClientRects()).length>1?n["right"==d?n.length-1:0]:e.getBoundingClientRect()}if(Ze&&9>$e&&!f&&(!m||!m.left&&!m.right)){var o=e.parentNode.getClientRects()[0];m=o?{left:o.left,right:o.left+$a(a.display),top:o.top,bottom:o.bottom}:wf}for(var p=m.top-b.rect.top,q=m.bottom-b.rect.top,r=(p+q)/2,s=b.view.measure.heights,j=0;jc.from?g(a-1):g(a,d)}d=d||Dd(a.doc,b.line),e||(e=Ia(a,d));var i=Kd(d),j=b.ch;if(!i)return g(j);var k=Se(i,j),l=h(j,k);return null!=Ig&&(l.other=h(j,Ig)),l}function Va(a,b){var c=0,b=_(a.doc,b);a.options.lineWrapping||(c=$a(a.display)*b.ch);var d=Dd(a.doc,b.line),e=Jd(d)+Aa(a.display);return{left:c,right:c,top:e,bottom:e+d.height}}function Wa(a,b,c,d){var e=rf(a,b);return e.xRel=d,c&&(e.outside=!0),e}function Xa(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,0>c)return Wa(d.first,0,!0,-1);var e=Id(d,c),f=d.first+d.size-1;if(e>f)return Wa(d.first+d.size-1,Dd(d,f).text.length,!0,1);0>b&&(b=0);for(var g=Dd(d,e);;){var h=Ya(a,g,e,b,c),i=Xc(g),j=i&&i.find(0,!0);if(!i||!(h.ch>j.from.ch||h.ch==j.from.ch&&h.xRel>0))return h;e=Hd(g=j.to.line)}}function Ya(a,b,c,d,e){function f(d){var e=Ua(a,rf(c,d),"line",b,j);return h=!0,g>e.bottom?e.left-i:gq)return Wa(c,n,r,1);for(;;){if(k?n==m||n==Ue(b,m,1):1>=n-m){for(var s=o>d||q-d>=d-o?m:n,t=d-(s==m?o:q);se(b.text.charAt(s));)++s;var u=Wa(c,s,s==m?p:r,-1>t?-1:t>1?1:0);return u}var v=Math.ceil(l/2),w=m+v;if(k){w=m;for(var x=0;v>x;++x)w=Ue(b,w,1)}var y=f(w);y>d?(n=w,q=y,(r=h)&&(q+=1e3),l=v):(m=w,o=y,p=h,l-=v)}}function Za(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==tf){tf=te("pre");for(var b=0;49>b;++b)tf.appendChild(document.createTextNode("x")),tf.appendChild(te("br"));tf.appendChild(document.createTextNode("x"))}ve(a.measure,tf);var c=tf.offsetHeight/50;return c>3&&(a.cachedTextHeight=c),ue(a.measure),c||1}function $a(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=te("span","xxxxxxxxxx"),c=te("pre",[b]);ve(a.measure,c);var d=b.getBoundingClientRect(),e=(d.right-d.left)/10;return e>2&&(a.cachedCharWidth=e),e||10}function _a(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++yf},xf?xf.ops.push(a.curOp):a.curOp.ownsGroup=xf={ops:[a.curOp],delayedCallbacks:[]}}function ab(a){var b=a.delayedCallbacks,c=0;do{for(;c=c.viewTo)||c.maxLineChanged&&b.options.lineWrapping,a.update=a.mustUpdate&&new x(b,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function eb(a){a.updatedDisplay=a.mustUpdate&&y(a.cm,a.update)}function fb(a){var b=a.cm,c=b.display;a.updatedDisplay&&D(b),a.barMeasure=q(b),c.maxLineChanged&&!b.options.lineWrapping&&(a.adjustWidthTo=Ga(b,c.maxLine,c.maxLine.text.length).left+3,a.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+a.adjustWidthTo+mg-c.scroller.clientWidth)),(a.updatedDisplay||a.selectionChanged)&&(a.newSelectionNodes=qa(b))}function gb(a){var b=a.cm;null!=a.adjustWidthTo&&(b.display.sizer.style.minWidth=a.adjustWidthTo+"px",a.maxScrollLeft1&&r(b),a.updatedDisplay&&z(b,a.update),null==c.wheelStartX||null==a.scrollTop&&null==a.scrollLeft&&!a.scrollToPos||(c.wheelStartX=c.wheelStartY=null),null!=a.scrollTop&&(c.scroller.scrollTop!=a.scrollTop||a.forceScroll)){var e=Math.max(0,Math.min(c.scroller.scrollHeight-c.scroller.clientHeight,a.scrollTop));c.scroller.scrollTop=c.scrollbarV.scrollTop=d.scrollTop=e}if(null!=a.scrollLeft&&(c.scroller.scrollLeft!=a.scrollLeft||a.forceScroll)){var f=Math.max(0,Math.min(c.scroller.scrollWidth-c.scroller.clientWidth,a.scrollLeft));c.scroller.scrollLeft=c.scrollbarH.scrollLeft=d.scrollLeft=f,t(b)}if(a.scrollToPos){var g=oc(b,_(d,a.scrollToPos.from),_(d,a.scrollToPos.to),a.scrollToPos.margin);a.scrollToPos.isCursor&&b.state.focused&&nc(b,g)}var h=a.maybeHiddenMarkers,i=a.maybeUnhiddenMarkers;if(h)for(var j=0;ja.barMeasure.clientWidth&&a.barMeasure.scrollWidthf;f=d){var g=new mb(a.doc,Dd(a.doc,f),f);d=f+g.size,e.push(g)}return e}function ob(a,b,c,d){null==b&&(b=a.doc.first),null==c&&(c=a.doc.first+a.doc.size),d||(d=0);var e=a.display;if(d&&cb)&&(e.updateLineNumbers=b),a.curOp.viewChanged=!0,b>=e.viewTo)qf&&_c(a.doc,b)e.viewFrom?qb(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)qb(a);else if(b<=e.viewFrom){var f=sb(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):qb(a)}else if(c>=e.viewTo){var f=sb(a,b,b,-1);f?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):qb(a)}else{var g=sb(a,b,b,-1),h=sb(a,c,c+d,1);g&&h?(e.view=e.view.slice(0,g.index).concat(nb(a,g.lineN,h.lineN)).concat(e.view.slice(h.index)),e.viewTo+=d):qb(a)}var i=e.externalMeasured;i&&(c=e.lineN&&b=d.viewTo)){var f=d.view[rb(a,b)];if(null!=f.node){var g=f.changes||(f.changes=[]);-1==le(g,c)&&g.push(c)}}}function qb(a){a.display.viewFrom=a.display.viewTo=a.doc.first,a.display.view=[],a.display.viewOffset=0}function rb(a,b){if(b>=a.display.viewTo)return null;if(b-=a.display.viewFrom,0>b)return null;for(var c=a.display.view,d=0;db)return d}function sb(a,b,c,d){var e,f=rb(a,b),g=a.display.view;if(!qf||c==a.doc.first+a.doc.size)return{index:f,lineN:c};for(var h=0,i=a.display.viewFrom;f>h;h++)i+=g[h].size;if(i!=b){if(d>0){if(f==g.length-1)return null;e=i+g[f].size-b,f++}else e=i-b;b+=e,c+=e}for(;_c(a.doc,c)!=c;){if(f==(0>d?0:g.length-1))return null;c+=d*g[f-(0>d?1:0)].size,f+=d}return{index:f,lineN:c}}function tb(a,b,c){var d=a.display,e=d.view;0==e.length||b>=d.viewTo||c<=d.viewFrom?(d.view=nb(a,b,c),d.viewFrom=b):(d.viewFrom>b?d.view=nb(a,b,d.viewFrom).concat(d.view):d.viewFromc&&(d.view=d.view.slice(0,rb(a,c)))),d.viewTo=c}function ub(a){for(var b=a.display.view,c=0,d=0;d=9&&a.display.inputHasSelection===e||kf&&/[\uf700-\uf7ff]/.test(e))return yb(a),!1;var f=!a.curOp;f&&_a(a),a.display.shift=!1,8203!=e.charCodeAt(0)||d.sel!=a.display.selForContextMenu||c||(c="​");for(var g=0,h=Math.min(c.length,e.length);h>g&&c.charCodeAt(g)==e.charCodeAt(g);)++g;var i=e.slice(g),j=Dg(i),k=null;a.state.pasteIncoming&&d.sel.ranges.length>1&&(zf&&zf.join("\n")==i?k=d.sel.ranges.length%zf.length==0&&me(zf,Dg):j.length==d.sel.ranges.length&&(k=me(j,function(a){return[a]})));for(var l=d.sel.ranges.length-1;l>=0;l--){var m=d.sel.ranges[l],n=m.from(),o=m.to();g-1){uc(a,s.line,"smart");break}}else r.electricInput&&r.electricInput.test(Dd(d,s.line).text.slice(0,s.ch))&&uc(a,s.line,"smart")}}return sc(a),a.curOp.updateInput=p,a.curOp.typing=!0,e.length>1e3||e.indexOf("\n")>-1?b.value=a.display.prevInput="":a.display.prevInput=e,f&&bb(a),a.state.pasteIncoming=a.state.cutIncoming=!1,!0}function yb(a,b){var c,d,e=a.doc;if(a.somethingSelected()){a.display.prevInput="";var f=e.sel.primary();c=Fg&&(f.to().line-f.from().line>100||(d=a.getSelection()).length>1e3);var g=c?"-":d||a.getSelection();a.display.input.value=g,a.state.focused&&tg(a.display.input),Ze&&$e>=9&&(a.display.inputHasSelection=g)}else b||(a.display.prevInput=a.display.input.value="",Ze&&$e>=9&&(a.display.inputHasSelection=null));a.display.inaccurateSelection=c}function zb(a){"nocursor"==a.options.readOnly||jf&&xe()==a.display.input||a.display.input.focus()}function Ab(a){a.state.focused||(zb(a),Zb(a))}function Bb(a){return a.options.readOnly||a.doc.cantEdit}function Cb(a){function b(){a.state.focused&&setTimeout(pe(zb,a),0)}function c(b){de(a,b)||hg(b)}function d(b){if(a.somethingSelected())zf=a.getSelections(),e.inaccurateSelection&&(e.prevInput="",e.inaccurateSelection=!1,e.input.value=zf.join("\n"),tg(e.input));else{for(var c=[],d=[],f=0;f$e?ig(e.scroller,"dblclick",jb(a,function(b){if(!de(a,b)){var c=Fb(a,b);if(c&&!Lb(a,b)&&!Eb(a.display,b)){fg(b);var d=a.findWordAt(c);ea(a.doc,d.anchor,d.head)}}})):ig(e.scroller,"dblclick",function(b){de(a,b)||fg(b)}),ig(e.lineSpace,"selectstart",function(a){Eb(e,a)||fg(a)}),of||ig(e.scroller,"contextmenu",function(b){_b(a,b)}),ig(e.scroller,"scroll",function(){e.scroller.clientHeight&&(Ob(a,e.scroller.scrollTop),Pb(a,e.scroller.scrollLeft,!0),kg(a,"scroll",a))}),ig(e.scrollbarV,"scroll",function(){e.scroller.clientHeight&&Ob(a,e.scrollbarV.scrollTop)}),ig(e.scrollbarH,"scroll",function(){e.scroller.clientHeight&&Pb(a,e.scrollbarH.scrollLeft)}),ig(e.scroller,"mousewheel",function(b){Qb(a,b)}),ig(e.scroller,"DOMMouseScroll",function(b){Qb(a,b)}),ig(e.scrollbarH,"mousedown",b),ig(e.scrollbarV,"mousedown",b),ig(e.wrapper,"scroll",function(){e.wrapper.scrollTop=e.wrapper.scrollLeft=0}),ig(e.input,"keyup",function(b){Xb.call(a,b)}),ig(e.input,"input",function(){Ze&&$e>=9&&a.display.inputHasSelection&&(a.display.inputHasSelection=null),wb(a)}),ig(e.input,"keydown",jb(a,Vb)),ig(e.input,"keypress",jb(a,Yb)),ig(e.input,"focus",pe(Zb,a)),ig(e.input,"blur",pe($b,a)),a.options.dragDrop&&(ig(e.scroller,"dragstart",function(b){Nb(a,b)}),ig(e.scroller,"dragenter",c),ig(e.scroller,"dragover",c),ig(e.scroller,"drop",jb(a,Mb))),ig(e.scroller,"paste",function(b){Eb(e,b)||(a.state.pasteIncoming=!0,zb(a),wb(a))}),ig(e.input,"paste",function(){if(_e&&!a.state.fakedLastChar&&!(new Date-a.state.lastMiddleDown<200)){var b=e.input.selectionStart,c=e.input.selectionEnd;e.input.value+="$",e.input.selectionEnd=c,e.input.selectionStart=b,a.state.fakedLastChar=!0}a.state.pasteIncoming=!0,wb(a)}),ig(e.input,"cut",d),ig(e.input,"copy",d),ef&&ig(e.sizer,"mouseup",function(){xe()==e.input&&e.input.blur(),zb(a)})}function Db(a){var b=a.display;b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,a.setSize()}function Eb(a,b){for(var c=_d(b);c!=a.wrapper;c=c.parentNode)if(!c||c.ignoreEvents||c.parentNode==a.sizer&&c!=a.mover)return!0}function Fb(a,b,c,d){var e=a.display;if(!c){var f=_d(b);if(f==e.scrollbarH||f==e.scrollbarV||f==e.scrollbarFiller||f==e.gutterFiller)return null}var g,h,i=e.lineSpace.getBoundingClientRect();try{g=b.clientX-i.left,h=b.clientY-i.top}catch(b){return null}var j,k=Xa(a,g,h);if(d&&1==k.xRel&&(j=Dd(a.doc,k.line).text).length==k.ch){var l=rg(j,j.length,a.options.tabSize)-j.length;k=rf(k.line,Math.max(0,Math.round((g-Ca(a.display).left)/$a(a.display))-l))}return k}function Gb(a){if(!de(this,a)){var b=this,c=b.display;if(c.shift=a.shiftKey,Eb(c,a))return void(_e||(c.scroller.draggable=!1,setTimeout(function(){c.scroller.draggable=!0},100)));if(!Lb(b,a)){var d=Fb(b,a);switch(window.focus(),ae(a)){case 1:d?Hb(b,a,d):_d(a)==c.scroller&&fg(a);break;case 2:_e&&(b.state.lastMiddleDown=+new Date),d&&ea(b.doc,d),setTimeout(pe(zb,b),20),fg(a);break;case 3:of&&_b(b,a)}}}}function Hb(a,b,c){setTimeout(pe(Ab,a),0);var d,e=+new Date;vf&&vf.time>e-400&&0==sf(vf.pos,c)?d="triple":uf&&uf.time>e-400&&0==sf(uf.pos,c)?(d="double",vf={time:e,pos:c}):(d="single",uf={time:e,pos:c});var f=a.doc.sel,g=kf?b.metaKey:b.ctrlKey;a.options.dragDrop&&Cg&&!Bb(a)&&"single"==d&&f.contains(c)>-1&&f.somethingSelected()?Ib(a,b,c,g):Jb(a,b,c,d,g)}function Ib(a,b,c,d){var e=a.display,f=jb(a,function(g){_e&&(e.scroller.draggable=!1),a.state.draggingText=!1,jg(document,"mouseup",f),jg(e.scroller,"drop",f),Math.abs(b.clientX-g.clientX)+Math.abs(b.clientY-g.clientY)<10&&(fg(g),d||ea(a.doc,c),zb(a),Ze&&9==$e&&setTimeout(function(){document.body.focus(),zb(a)},20))});_e&&(e.scroller.draggable=!0),a.state.draggingText=f,e.scroller.dragDrop&&e.scroller.dragDrop(),ig(document,"mouseup",f),ig(e.scroller,"drop",f)}function Jb(a,b,c,d,e){function f(b){if(0!=sf(p,b))if(p=b,"rect"==d){for(var e=[],f=a.options.tabSize,g=rg(Dd(j,c.line).text,c.ch,f),h=rg(Dd(j,b.line).text,b.ch,f),i=Math.min(g,h),n=Math.max(g,h),o=Math.min(c.line,b.line),q=Math.min(a.lastLine(),Math.max(c.line,b.line));q>=o;o++){var r=Dd(j,o).text,s=ie(r,i,f);i==n?e.push(new X(rf(o,s),rf(o,s))):r.length>s&&e.push(new X(rf(o,s),rf(o,ie(r,n,f))))}e.length||e.push(new X(c,c)),ka(j,Y(m.ranges.slice(0,l).concat(e),l),{origin:"*mouse",scroll:!1}),a.scrollIntoView(b)}else{var t=k,u=t.anchor,v=b;if("single"!=d){if("double"==d)var w=a.findWordAt(b);else var w=new X(rf(b.line,0),_(j,rf(b.line+1,0)));sf(w.anchor,u)>0?(v=w.head,u=V(t.from(),w.anchor)):(v=w.anchor,u=U(t.to(),w.head))}var e=m.ranges.slice(0);e[l]=new X(_(j,u),v),ka(j,Y(e,l),pg)}}function g(b){var c=++r,e=Fb(a,b,!0,"rect"==d);if(e)if(0!=sf(e,p)){Ab(a),f(e);var h=s(i,j);(e.line>=h.to||e.lineq.bottom?20:0;k&&setTimeout(jb(a,function(){r==c&&(i.scroller.scrollTop+=k,g(b))}),50)}}function h(b){r=1/0,fg(b),zb(a),jg(document,"mousemove",t),jg(document,"mouseup",u),j.history.lastSelOrigin=null}var i=a.display,j=a.doc;fg(b);var k,l,m=j.sel;if(e&&!b.shiftKey?(l=j.sel.contains(c),k=l>-1?j.sel.ranges[l]:new X(c,c)):k=j.sel.primary(),b.altKey)d="rect",e||(k=new X(c,c)),c=Fb(a,b,!0,!0),l=-1;else if("double"==d){var n=a.findWordAt(c);k=a.display.shift||j.extend?da(j,k,n.anchor,n.head):n}else if("triple"==d){var o=new X(rf(c.line,0),_(j,rf(c.line+1,0)));k=a.display.shift||j.extend?da(j,k,o.anchor,o.head):o}else k=da(j,k,c);e?l>-1?ga(j,l,k,pg):(l=j.sel.ranges.length,ka(j,Y(j.sel.ranges.concat([k]),l),{scroll:!1,origin:"*mouse"})):(l=0,ka(j,new W([k],0),pg),m=j.sel);var p=c,q=i.wrapper.getBoundingClientRect(),r=0,t=jb(a,function(a){ae(a)?g(a):h(a)}),u=jb(a,h);ig(document,"mousemove",t),ig(document,"mouseup",u)}function Kb(a,b,c,d,e){try{var f=b.clientX,g=b.clientY}catch(b){return!1}if(f>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&fg(b);var h=a.display,i=h.lineDiv.getBoundingClientRect();if(g>i.bottom||!fe(a,c))return $d(b);g-=i.top-h.viewOffset;for(var j=0;j=f){var l=Id(a.doc,g),m=a.options.gutters[j];return e(a,c,a,l,m,b),$d(b)}}}function Lb(a,b){return Kb(a,b,"gutterClick",!0,be)}function Mb(a){var b=this;if(!de(b,a)&&!Eb(b.display,a)){fg(a),Ze&&(Af=+new Date);var c=Fb(b,a,!0),d=a.dataTransfer.files;if(c&&!Bb(b))if(d&&d.length&&window.FileReader&&window.File)for(var e=d.length,f=Array(e),g=0,h=function(a,d){var h=new FileReader;h.onload=jb(b,function(){if(f[d]=h.result,++g==e){c=_(b.doc,c);var a={from:c,to:c,text:Dg(f.join("\n")),origin:"paste"};gc(b.doc,a),ja(b.doc,Z(c,Ff(a)))}}),h.readAsText(a)},i=0;e>i;++i)h(d[i],i);else{if(b.state.draggingText&&b.doc.sel.contains(c)>-1)return b.state.draggingText(a),void setTimeout(pe(zb,b),20);try{var f=a.dataTransfer.getData("Text");if(f){if(b.state.draggingText&&!(kf?a.metaKey:a.ctrlKey))var j=b.listSelections();if(la(b.doc,Z(c,c)),j)for(var i=0;if.clientWidth||d&&f.scrollHeight>f.clientHeight){if(d&&kf&&_e)a:for(var g=b.target,h=e.view;g!=f;g=g.parentNode)for(var i=0;ij?k=Math.max(0,k+j-50):l=Math.min(a.doc.height,l+j+50),A(a,{top:k,bottom:l})}20>Bf&&(null==e.wheelStartX?(e.wheelStartX=f.scrollLeft,e.wheelStartY=f.scrollTop,e.wheelDX=c,e.wheelDY=d,setTimeout(function(){if(null!=e.wheelStartX){var a=f.scrollLeft-e.wheelStartX,b=f.scrollTop-e.wheelStartY,c=b&&e.wheelDY&&b/e.wheelDY||a&&e.wheelDX&&a/e.wheelDX;e.wheelStartX=e.wheelStartY=null,c&&(Cf=(Cf*Bf+c)/(Bf+1),++Bf)}},200)):(e.wheelDX+=c,e.wheelDY+=d))}}function Rb(a,b,c){if("string"==typeof b&&(b=Qf[b],!b))return!1;a.display.pollingFast&&xb(a)&&(a.display.pollingFast=!1);var d=a.display.shift,e=!1;try{Bb(a)&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=ng}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function Sb(a){var b=a.state.keyMaps.slice(0);return a.options.extraKeys&&b.push(a.options.extraKeys),b.push(a.options.keyMap),b}function Tb(a,b){var c=Ac(a.options.keyMap),d=c.auto;clearTimeout(Df),d&&!Tf(b)&&(Df=setTimeout(function(){Ac(a.options.keyMap)==c&&(a.options.keyMap=d.call?d.call(null,a):d,h(a))},50));var e=Uf(b,!0),f=!1;if(!e)return!1;var g=Sb(a);return f=b.shiftKey?Sf("Shift-"+e,g,function(b){return Rb(a,b,!0)})||Sf(e,g,function(b){return("string"==typeof b?/^go[A-Z]/.test(b):b.motion)?Rb(a,b):void 0}):Sf(e,g,function(b){return Rb(a,b)}),f&&(fg(b),va(a),be(a,"keyHandled",a,e,b)),f}function Ub(a,b,c){var d=Sf("'"+c+"'",Sb(a),function(b){return Rb(a,b,!0)});return d&&(fg(b),va(a),be(a,"keyHandled",a,"'"+c+"'",b)),d}function Vb(a){var b=this;if(Ab(b),!de(b,a)){Ze&&11>$e&&27==a.keyCode&&(a.returnValue=!1);var c=a.keyCode;b.display.shift=16==c||a.shiftKey;var d=Tb(b,a);cf&&(Ef=d?c:null,!d&&88==c&&!Fg&&(kf?a.metaKey:a.ctrlKey)&&b.replaceSelection("",null,"cut")),18!=c||/\bCodeMirror-crosshair\b/.test(b.display.lineDiv.className)||Wb(b)}}function Wb(a){function b(a){18!=a.keyCode&&a.altKey||(ze(c,"CodeMirror-crosshair"),jg(document,"keyup",b),jg(document,"mouseover",b))}var c=a.display.lineDiv;Ae(c,"CodeMirror-crosshair"),ig(document,"keyup",b),ig(document,"mouseover",b)}function Xb(a){16==a.keyCode&&(this.doc.sel.shift=!1),de(this,a)}function Yb(a){var b=this;if(!(de(b,a)||a.ctrlKey&&!a.altKey||kf&&a.metaKey)){var c=a.keyCode,d=a.charCode;if(cf&&c==Ef)return Ef=null,void fg(a);if(!(cf&&(!a.which||a.which<10)||ef)||!Tb(b,a)){var e=String.fromCharCode(null==d?c:d);Ub(b,a,e)||(Ze&&$e>=9&&(b.display.inputHasSelection=null),wb(b))}}}function Zb(a){"nocursor"!=a.options.readOnly&&(a.state.focused||(kg(a,"focus",a),a.state.focused=!0,Ae(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(yb(a),_e&&setTimeout(pe(yb,a,!0),0))),vb(a),va(a))}function $b(a){a.state.focused&&(kg(a,"blur",a),a.state.focused=!1,ze(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150)}function _b(a,b){function c(){if(null!=e.input.selectionStart){var b=a.somethingSelected(),c=e.input.value="​"+(b?e.input.value:"");e.prevInput=b?"":"​",e.input.selectionStart=1,e.input.selectionEnd=c.length,e.selForContextMenu=a.doc.sel}}function d(){if(e.inputDiv.style.position="relative",e.input.style.cssText=i,Ze&&9>$e&&(e.scrollbarV.scrollTop=e.scroller.scrollTop=g),vb(a),null!=e.input.selectionStart){(!Ze||Ze&&9>$e)&&c();var b=0,d=function(){e.selForContextMenu==a.doc.sel&&0==e.input.selectionStart?jb(a,Qf.selectAll)(a):b++<10?e.detectingSelectAll=setTimeout(d,500):yb(a)};e.detectingSelectAll=setTimeout(d,200)}}if(!de(a,b,"contextmenu")){var e=a.display;if(!Eb(e,b)&&!ac(a,b)){var f=Fb(a,b),g=e.scroller.scrollTop;if(f&&!cf){var h=a.options.resetSelectionOnContextMenu;h&&-1==a.doc.sel.contains(f)&&jb(a,ka)(a.doc,Z(f),og);var i=e.input.style.cssText;if(e.inputDiv.style.position="absolute",e.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(b.clientY-5)+"px; left: "+(b.clientX-5)+"px; z-index: 1000; background: "+(Ze?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",_e)var j=window.scrollY;if(zb(a),_e&&window.scrollTo(null,j),yb(a),a.somethingSelected()||(e.input.value=e.prevInput=" "),e.selForContextMenu=a.doc.sel,clearTimeout(e.detectingSelectAll),Ze&&$e>=9&&c(),of){hg(b);var k=function(){jg(window,"mouseup",k),setTimeout(d,20)};ig(window,"mouseup",k)}else setTimeout(d,50)}}}}function ac(a,b){return fe(a,"gutterContextMenu")?Kb(a,b,"gutterContextMenu",!1,kg):!1}function bc(a,b){if(sf(a,b.from)<0)return a;if(sf(a,b.to)<=0)return Ff(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;return a.line==b.to.line&&(d+=Ff(b).ch-b.to.ch),rf(c,d)}function cc(a,b){for(var c=[],d=0;d=0;--e)hc(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text});else hc(a,b)}}function hc(a,b){if(1!=b.text.length||""!=b.text[0]||0!=sf(b.from,b.to)){var c=cc(a,b);Pd(a,b,c,a.cm?a.cm.curOp.id:NaN),kc(a,b,c,Mc(a,b));var d=[];Bd(a,function(a,c){c||-1!=le(d,a.history)||(Zd(a.history,b),d.push(a.history)),kc(a,b,null,Mc(a,b))})}}function ic(a,b,c){if(!a.cm||!a.cm.state.suppressEdits){for(var d,e=a.history,f=a.sel,g="undo"==b?e.done:e.undone,h="undo"==b?e.undone:e.done,i=0;i=0;--i){var l=d.changes[i];if(l.origin=b,k&&!fc(a,l,!1))return void(g.length=0);j.push(Md(a,l));var m=i?cc(a,l):ke(g);kc(a,l,m,Oc(a,l)),!i&&a.cm&&a.cm.scrollIntoView({from:l.from,to:Ff(l)});var n=[];Bd(a,function(a,b){b||-1!=le(n,a.history)||(Zd(a.history,l),n.push(a.history)),kc(a,l,null,Oc(a,l))})}}}}function jc(a,b){if(0!=b&&(a.first+=b,a.sel=new W(me(a.sel.ranges,function(a){return new X(rf(a.anchor.line+b,a.anchor.ch),rf(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){ob(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;da.lastLine())){if(b.from.linef&&(b={from:b.from,to:rf(f,Dd(a,f).text.length),text:[b.text[0]],origin:b.origin}),b.removed=Ed(a,b.from,b.to),c||(c=cc(a,b)),a.cm?lc(a.cm,b,d):yd(a,b,d),la(a,c,og)}}function lc(a,b,c){var d=a.doc,e=a.display,g=b.from,h=b.to,i=!1,j=g.line;a.options.lineWrapping||(j=Hd(Zc(Dd(d,g.line))),d.iter(j,h.line+1,function(a){return a==e.maxLine?(i=!0,!0):void 0})),d.sel.contains(b.from,b.to)>-1&&ee(a),yd(d,b,c,f(a)),a.options.lineWrapping||(d.iter(j,g.line+b.text.length,function(a){var b=m(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,i=!1)}),i&&(a.curOp.updateMaxLine=!0)),d.frontier=Math.min(d.frontier,g.line),wa(a,400);var k=b.text.length-(h.line-g.line)-1;g.line!=h.line||1!=b.text.length||xd(a.doc,b)?ob(a,g.line,h.line+1,k):pb(a,g.line,"text");var l=fe(a,"changes"),n=fe(a,"change");if(n||l){var o={from:g,to:h,text:b.text,removed:b.removed,origin:b.origin};n&&be(a,"change",a,o),l&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(o)}a.display.selForContextMenu=null}function mc(a,b,c,d,e){if(d||(d=c),sf(d,c)<0){var f=d;d=c,c=f}"string"==typeof b&&(b=Dg(b)),gc(a,{from:c,to:d,text:b,origin:e})}function nc(a,b){var c=a.display,d=c.sizer.getBoundingClientRect(),e=null;if(b.top+d.top<0?e=!0:b.bottom+d.top>(window.innerHeight||document.documentElement.clientHeight)&&(e=!1),null!=e&&!gf){var f=te("div","​",null,"position: absolute; top: "+(b.top-c.viewOffset-Aa(a.display))+"px; height: "+(b.bottom-b.top+mg)+"px; left: "+b.left+"px; width: 2px;");a.display.lineSpace.appendChild(f),f.scrollIntoView(e),a.display.lineSpace.removeChild(f)}}function oc(a,b,c,d){null==d&&(d=0);for(var e=0;5>e;e++){var f=!1,g=Ua(a,b),h=c&&c!=b?Ua(a,c):g,i=qc(a,Math.min(g.left,h.left),Math.min(g.top,h.top)-d,Math.max(g.left,h.left),Math.max(g.bottom,h.bottom)+d),j=a.doc.scrollTop,k=a.doc.scrollLeft;if(null!=i.scrollTop&&(Ob(a,i.scrollTop),Math.abs(a.doc.scrollTop-j)>1&&(f=!0)),null!=i.scrollLeft&&(Pb(a,i.scrollLeft),Math.abs(a.doc.scrollLeft-k)>1&&(f=!0)),!f)return g}}function pc(a,b,c,d,e){var f=qc(a,b,c,d,e);null!=f.scrollTop&&Ob(a,f.scrollTop),null!=f.scrollLeft&&Pb(a,f.scrollLeft)}function qc(a,b,c,d,e){var f=a.display,g=Za(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,i=f.scroller.clientHeight-mg,j={};e-c>i&&(e=c+i);var k=a.doc.height+Ba(f),l=g>c,m=e>k-g;if(h>c)j.scrollTop=l?0:c;else if(e>h+i){var n=Math.min(c,(m?k:e)-i);n!=h&&(j.scrollTop=n)}var o=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft,p=f.scroller.clientWidth-mg-f.gutters.offsetWidth,q=d-b>p;return q&&(d=b+p),10>b?j.scrollLeft=0:o>b?j.scrollLeft=Math.max(0,b-(q?0:10)):d>p+o-3&&(j.scrollLeft=d+(q?0:10)-p),j}function rc(a,b,c){(null!=b||null!=c)&&tc(a),null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b),null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function sc(a){tc(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?rf(b.line,b.ch-1):b,d=rf(b.line,b.ch+1)),a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function tc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=Va(a,b.from),d=Va(a,b.to),e=qc(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(e.scrollLeft,e.scrollTop)}}function uc(a,b,c,d){var e,f=a.doc;null==c&&(c="add"),"smart"==c&&(f.mode.indent?e=za(a,b):c="prev");var g=a.options.tabSize,h=Dd(f,b),i=rg(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var j,k=h.text.match(/^\s*/)[0];if(d||/\S/.test(h.text)){if("smart"==c&&(j=f.mode.indent(e,h.text.slice(k.length),h.text),j==ng||j>150)){if(!d)return;c="prev"}}else j=0,c="not";"prev"==c?j=b>f.first?rg(Dd(f,b-1).text,null,g):0:"add"==c?j=i+a.options.indentUnit:"subtract"==c?j=i-a.options.indentUnit:"number"==typeof c&&(j=i+c),j=Math.max(0,j);var l="",m=0;if(a.options.indentWithTabs)for(var n=Math.floor(j/g);n;--n)m+=g,l+=" ";if(j>m&&(l+=je(j-m)),l!=k)mc(f,l,rf(b,0),rf(b,k.length),"+input");else for(var n=0;n=0;b--)mc(a.doc,"",d[b].from,d[b].to,"+delete");sc(a)})}function xc(a,b,c,d,e){function f(){var b=h+c;return b=a.first+a.size?l=!1:(h=b,k=Dd(a,b))}function g(a){var b=(e?Ue:Ve)(k,i,c,!0);if(null==b){if(a||!f())return l=!1;i=e?(0>c?Ne:Me)(k):0>c?k.text.length:0}else i=b;return!0}var h=b.line,i=b.ch,j=c,k=Dd(a,h),l=!0;if("char"==d)g();else if("column"==d)g(!0);else if("word"==d||"group"==d)for(var m=null,n="group"==d,o=a.cm&&a.cm.getHelper(b,"wordChars"),p=!0;!(0>c)||g(!p);p=!1){var q=k.text.charAt(i)||"\n",r=qe(q,o)?"w":n&&"\n"==q?"n":!n||/\s/.test(q)?null:"p";if(!n||p||r||(r="s"),m&&m!=r){0>c&&(c=1,g());break}if(r&&(m=r),c>0&&!g(!p))break}var s=pa(a,rf(h,i),j,!0);return l||(s.hitSide=!0),s}function yc(a,b,c,d){var e,f=a.doc,g=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);e=b.top+c*(h-(0>c?1.5:.5)*Za(a.display))}else"line"==d&&(e=c>0?b.bottom+3:b.top-3);for(;;){var i=Xa(a,g,e);if(!i.outside)break;if(0>c?0>=e:e>=f.height){i.hitSide=!0;break}e+=5*c}return i}function zc(b,c,d,e){a.defaults[b]=c,d&&(Hf[b]=e?function(a,b,c){c!=If&&d(a,b,c)}:d)}function Ac(a){return"string"==typeof a?Rf[a]:a}function Bc(a,b,c,d,e){if(d&&d.shared)return Cc(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return jb(a.cm,Bc)(a,b,c,d,e);var f=new Wf(a,e),g=sf(b,c);if(d&&oe(d,f,!1),g>0||0==g&&f.clearWhenEmpty!==!1)return f;if(f.replacedWith&&(f.collapsed=!0,f.widgetNode=te("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||(f.widgetNode.ignoreEvents=!0),d.insertLeft&&(f.widgetNode.insertLeft=!0)),f.collapsed){if(Yc(a,b.line,b,c,f)||b.line!=c.line&&Yc(a,c.line,b,c,f))throw new Error("Inserting collapsed marker partially overlapping an existing one");qf=!0}f.addToHistory&&Pd(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var h,i=b.line,j=a.cm;if(a.iter(i,c.line+1,function(a){j&&f.collapsed&&!j.options.lineWrapping&&Zc(a)==j.display.maxLine&&(h=!0),f.collapsed&&i!=b.line&&Gd(a,0),Jc(a,new Gc(f,i==b.line?b.ch:null,i==c.line?c.ch:null)),++i}),f.collapsed&&a.iter(b.line,c.line+1,function(b){bd(a,b)&&Gd(b,0)}),f.clearOnEnter&&ig(f,"beforeCursorEnter",function(){f.clear()}),f.readOnly&&(pf=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory()),f.collapsed&&(f.id=++Xf,f.atomic=!0),j){if(h&&(j.curOp.updateMaxLine=!0),f.collapsed)ob(j,b.line,c.line+1);else if(f.className||f.title||f.startStyle||f.endStyle)for(var k=b.line;k<=c.line;k++)pb(j,k,"text");f.atomic&&na(j.doc),be(j,"markerAdded",j,f)}return f}function Cc(a,b,c,d,e){d=oe(d),d.shared=!1;var f=[Bc(a,b,c,d,e)],g=f[0],h=d.widgetNode;return Bd(a,function(a){h&&(d.widgetNode=h.cloneNode(!0)),f.push(Bc(a,_(a,b),_(a,c),d,e));for(var i=0;i=b:f.to>b);(d||(d=[])).push(new Gc(g,f.from,i?null:f.to))}}return d}function Lc(a,b,c){if(a)for(var d,e=0;e=b:f.to>b);if(h||f.from==b&&"bookmark"==g.type&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from0&&h)for(var l=0;ll;++l)o.push(p);o.push(i)}return o}function Nc(a){for(var b=0;b0)){var k=[i,1],l=sf(j.from,h.from),m=sf(j.to,h.to);(0>l||!g.inclusiveLeft&&!l)&&k.push({from:j.from,to:h.from}),(m>0||!g.inclusiveRight&&!m)&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-1}}return e}function Qc(a){var b=a.markedSpans;if(b){for(var c=0;c=0&&0>=l||0>=k&&l>=0)&&(0>=k&&(sf(j.to,c)>0||i.marker.inclusiveRight&&e.inclusiveLeft)||k>=0&&(sf(j.from,d)<0||i.marker.inclusiveLeft&&e.inclusiveRight)))return!0}}}function Zc(a){for(var b;b=Wc(a);)a=b.find(-1,!0).line;return a}function $c(a){for(var b,c;b=Xc(a);)a=b.find(1,!0).line,(c||(c=[])).push(a);return c}function _c(a,b){var c=Dd(a,b),d=Zc(c);return c==d?b:Hd(d)}function ad(a,b){if(b>a.lastLine())return b;var c,d=Dd(a,b);if(!bd(a,d))return b;for(;c=Xc(d);)d=c.find(1,!0).line;return Hd(d)+1}function bd(a,b){var c=qf&&b.markedSpans;if(c)for(var d,e=0;ed;d++){var e=a.token(b,c);if(b.pos>b.start)return e}throw new Error("Mode "+a.name+" failed to advance stream.")}function ld(b,c,d,e,f,g,h){var i=d.flattenSpans;null==i&&(i=b.options.flattenSpans);var j,k=0,l=null,m=new Vf(c,b.options.tabSize);for(""==c&&id(jd(d,e),g);!m.eol();){if(m.pos>b.options.maxHighlightLength?(i=!1,h&&od(b,c,e,m.pos),m.pos=c.length,j=null):j=id(kd(d,m,e),g),b.options.addModeClass){var n=a.innerMode(d,e).mode.name;n&&(j="m-"+(j?n+" "+j:n))}i&&l==j||(kj;){var d=e[i];d>a&&e.splice(i,1,a,e[i+1],d),i+=2,j=Math.min(a,d)}if(b)if(h.opaque)e.splice(c,i-c,a,"cm-overlay "+b),i=c+2;else for(;i>c;c+=2){var f=e[c+1];e[c+1]=(f?f+" ":"")+"cm-overlay "+b}},f)}return{styles:e,classes:f.bgClass||f.textClass?f:null}}function nd(a,b){if(!b.styles||b.styles[0]!=a.state.modeGen){var c=md(a,b,b.stateAfter=za(a,Hd(b)));b.styles=c.styles,c.classes?b.styleClasses=c.classes:b.styleClasses&&(b.styleClasses=null)}return b.styles}function od(a,b,c,d){var e=a.doc.mode,f=new Vf(b,a.options.tabSize);for(f.start=f.pos=d||0,""==b&&jd(e,c);!f.eol()&&f.pos<=a.options.maxHighlightLength;)kd(e,f,c),f.start=f.pos}function pd(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?ag:_f;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function qd(a,b){var c=te("span",null,null,_e?"padding-right: .1px":null),d={pre:te("pre",[c]),content:c,col:0,pos:0,cm:a};b.measure={};for(var e=0;e<=(b.rest?b.rest.length:0);e++){var f,g=e?b.rest[e-1]:b.line;d.pos=0,d.addToken=sd,(Ze||_e)&&a.getOption("lineWrapping")&&(d.addToken=td(d.addToken)),He(a.display.measure)&&(f=Kd(g))&&(d.addToken=ud(d.addToken,f)),d.map=[],wd(g,d,nd(a,g)),g.styleClasses&&(g.styleClasses.bgClass&&(d.bgClass=Be(g.styleClasses.bgClass,d.bgClass||"")),g.styleClasses.textClass&&(d.textClass=Be(g.styleClasses.textClass,d.textClass||""))),0==d.map.length&&d.map.push(0,0,d.content.appendChild(Ge(a.display.measure))),0==e?(b.measure.map=d.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(d.map),(b.measure.caches||(b.measure.caches=[])).push({}))}return kg(a,"renderLine",a,b.line,d.pre),d.pre.className&&(d.textClass=Be(d.pre.className,d.textClass||"")),d}function rd(a){var b=te("span","•","cm-invalidchar");return b.title="\\u"+a.charCodeAt(0).toString(16),b}function sd(a,b,c,d,e,f){if(b){var g=a.cm.options.specialChars,h=!1;if(g.test(b))for(var i=document.createDocumentFragment(),j=0;;){g.lastIndex=j;var k=g.exec(b),l=k?k.index-j:b.length-j;if(l){var m=document.createTextNode(b.slice(j,j+l));i.appendChild(Ze&&9>$e?te("span",[m]):m),a.map.push(a.pos,a.pos+l,m),a.col+=l,a.pos+=l}if(!k)break;if(j+=l+1," "==k[0]){var n=a.cm.options.tabSize,o=n-a.col%n,m=i.appendChild(te("span",je(o),"cm-tab"));a.col+=o}else{var m=a.cm.options.specialCharPlaceholder(k[0]);i.appendChild(Ze&&9>$e?te("span",[m]):m),a.col+=1}a.map.push(a.pos,a.pos+1,m),a.pos++}else{a.col+=b.length;var i=document.createTextNode(b);a.map.push(a.pos,a.pos+b.length,i),Ze&&9>$e&&(h=!0),a.pos+=b.length}if(c||d||e||h){var p=c||"";d&&(p+=d),e&&(p+=e);var q=te("span",[i],p);return f&&(q.title=f),a.content.appendChild(q)}a.content.appendChild(i)}}function td(a){function b(a){for(var b=" ",c=0;ci&&l.from<=i)break}if(l.to>=j)return a(c,d,e,f,g,h);a(c,d.slice(0,l.to-i),e,f,null,h),f=null,d=d.slice(l.to-i),i=l.to}}}function vd(a,b,c,d){var e=!d&&c.widgetNode;e&&(a.map.push(a.pos,a.pos+b,e),a.content.appendChild(e)),a.pos+=b}function wd(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(d)for(var g,h,i,j,k,l,m=e.length,n=0,o=1,p="",q=0;;){if(q==n){h=i=j=k="",l=null,q=1/0;for(var r=[],s=0;sn)?(null!=t.to&&q>t.to&&(q=t.to,i=""),u.className&&(h+=" "+u.className),u.startStyle&&t.from==n&&(j+=" "+u.startStyle),u.endStyle&&t.to==q&&(i+=" "+u.endStyle),u.title&&!k&&(k=u.title),u.collapsed&&(!l||Uc(l.marker,u)<0)&&(l=t)):t.from>n&&q>t.from&&(q=t.from),"bookmark"==u.type&&t.from==n&&u.widgetNode&&r.push(u)}if(l&&(l.from||0)==n&&(vd(b,(null==l.to?m+1:l.to)-n,l.marker,null==l.from),null==l.to))return;if(!l&&r.length)for(var s=0;s=m)break;for(var v=Math.min(m,q);;){if(p){var w=n+p.length;if(!l){var x=w>v?p.slice(0,v-n):p;b.addToken(b,x,g?g+h:h,j,n+x.length==q?i:"",k)}if(w>=v){p=p.slice(v-n),n=v;break}n=w,j=""}p=e.slice(f,f=c[o++]),g=pd(c[o++],b.cm.options)}}else for(var o=1;o1&&a.remove(g.line+1,n-1),a.insert(g.line+1,p)}be(a,"change",a,b)}function zd(a){this.lines=a,this.parent=null;for(var b=0,c=0;bb||b>=a.size)throw new Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(f>b){c=e;break}b-=f}return c.lines[b]}function Ed(a,b,c){var d=[],e=b.line;return a.iter(b.line,c.line+1,function(a){var f=a.text;e==c.line&&(f=f.slice(0,c.ch)),e==b.line&&(f=f.slice(b.ch)),d.push(f),++e}),d}function Fd(a,b,c){var d=[];return a.iter(b,c,function(a){d.push(a.text)}),d}function Gd(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function Hd(a){if(null==a.parent)return null;for(var b=a.parent,c=le(b.lines,a),d=b.parent;d;b=d,d=d.parent)for(var e=0;d.children[e]!=b;++e)c+=d.children[e].chunkSize();return c+b.first}function Id(a,b){var c=a.first;a:do{for(var d=0;db){a=e;continue a}b-=f,c+=e.chunkSize()}return c}while(!a.lines);for(var d=0;db)break;b-=h}return c+d}function Jd(a){a=Zc(a);for(var b=0,c=a.parent,d=0;d1&&!a.done[a.done.length-2].ranges?(a.done.pop(),ke(a.done)):void 0}function Pd(a,b,c,d){var e=a.history;e.undone.length=0;var f,g=+new Date;if((e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>g-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))&&(f=Od(e,e.lastOp==d))){var h=ke(f.changes);0==sf(b.from,b.to)&&0==sf(b.from,h.to)?h.to=Ff(b):f.changes.push(Md(a,b))}else{var i=ke(e.done);for(i&&i.ranges||Sd(a.sel,e.done),f={changes:[Md(a,b)],generation:e.generation},e.done.push(f);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift()}e.done.push(c),e.generation=++e.maxGeneration,e.lastModTime=e.lastSelTime=g,e.lastOp=e.lastSelOp=d,e.lastOrigin=e.lastSelOrigin=b.origin,h||kg(a,"historyAdded")}function Qd(a,b,c,d){var e=b.charAt(0);return"*"==e||"+"==e&&c.ranges.length==d.ranges.length&&c.somethingSelected()==d.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function Rd(a,b,c,d){var e=a.history,f=d&&d.origin;c==e.lastSelOp||f&&e.lastSelOrigin==f&&(e.lastModTime==e.lastSelTime&&e.lastOrigin==f||Qd(a,f,ke(e.done),b))?e.done[e.done.length-1]=b:Sd(b,e.done),e.lastSelTime=+new Date,e.lastSelOrigin=f,e.lastSelOp=c,d&&d.clearRedo!==!1&&Nd(e.undone)}function Sd(a,b){var c=ke(b);c&&c.ranges&&c.equals(a)||b.push(a)}function Td(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f})}function Ud(a){if(!a)return null;for(var b,c=0;c-1&&(ke(h)[l]=k[l],delete k[l])}}}return e}function Xd(a,b,c,d){c0}function ge(a){a.prototype.on=function(a,b){ig(this,a,b)},a.prototype.off=function(a,b){jg(this,a,b)}}function he(){this.id=null}function ie(a,b,c){for(var d=0,e=0;;){var f=a.indexOf(" ",d);-1==f&&(f=a.length);var g=f-d;if(f==a.length||e+g>=b)return d+Math.min(g,b-e);if(e+=f-d,e+=c-e%c,d=f+1,e>=b)return d}}function je(a){for(;sg.length<=a;)sg.push(ke(sg)+" ");return sg[a]}function ke(a){return a[a.length-1]}function le(a,b){for(var c=0;c-1&&wg(a)?!0:b.test(a):wg(a)}function re(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function se(a){return a.charCodeAt(0)>=768&&xg.test(a)}function te(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)e.appendChild(document.createTextNode(b));else if(b)for(var f=0;f0;--b)a.removeChild(a.firstChild);return a}function ve(a,b){return ue(a).appendChild(b)}function we(a,b){if(a.contains)return a.contains(b);for(;b=b.parentNode;)if(b==a)return!0}function xe(){return document.activeElement}function ye(a){return new RegExp("\\b"+a+"\\b\\s*")}function ze(a,b){var c=ye(b);c.test(a.className)&&(a.className=a.className.replace(c,""))}function Ae(a,b){ye(b).test(a.className)||(a.className+=" "+b)}function Be(a,b){for(var c=a.split(" "),d=0;d2&&!(Ze&&8>$e))}return zg?te("span","​"):te("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function He(a){if(null!=Ag)return Ag;var b=ve(a,document.createTextNode("AخA")),c=ug(b,0,1).getBoundingClientRect();if(!c||c.left==c.right)return!1;var d=ug(b,1,2).getBoundingClientRect();return Ag=d.right-c.right<3}function Ie(a){if(null!=Gg)return Gg;var b=ve(a,te("span","x")),c=b.getBoundingClientRect(),d=ug(b,0,1).getBoundingClientRect();return Gg=Math.abs(c.left-d.left)>1}function Je(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;fb||b==c&&g.to==b)&&(d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0)}e||d(b,c,"ltr")}function Ke(a){return a.level%2?a.to:a.from}function Le(a){return a.level%2?a.from:a.to}function Me(a){var b=Kd(a);return b?Ke(b[0]):0}function Ne(a){var b=Kd(a);return b?Le(ke(b)):a.text.length}function Oe(a,b){var c=Dd(a.doc,b),d=Zc(c);d!=c&&(b=Hd(d));var e=Kd(d),f=e?e[0].level%2?Ne(d):Me(d):0;return rf(b,f)}function Pe(a,b){for(var c,d=Dd(a.doc,b);c=Xc(d);)d=c.find(1,!0).line,b=null;var e=Kd(d),f=e?e[0].level%2?Me(d):Ne(d):d.text.length;return rf(null==b?Hd(d):b,f)}function Qe(a,b){var c=Oe(a,b.line),d=Dd(a.doc,c.line),e=Kd(d);if(!e||0==e[0].level){var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;return rf(c.line,g?0:f)}return c}function Re(a,b,c){var d=a[0].level;return b==d?!0:c==d?!1:c>b}function Se(a,b){Ig=null;for(var c,d=0;db)return d;if(e.from==b||e.to==b){if(null!=c)return Re(a,e.level,a[c].level)?(e.from!=e.to&&(Ig=c),d):(e.from!=e.to&&(Ig=d),c);c=d}}return c}function Te(a,b,c,d){if(!d)return b+c;do b+=c;while(b>0&&se(a.text.charAt(b)));return b}function Ue(a,b,c,d){var e=Kd(a);if(!e)return Ve(a,b,c,d);for(var f=Se(e,b),g=e[f],h=Te(a,b,g.level%2?-c:c,d);;){if(h>g.from&&h0==g.level%2?g.to:g.from);if(g=e[f+=c],!g)return null;h=c>0==g.level%2?Te(a,g.to,-1,d):Te(a,g.from,1,d)}}function Ve(a,b,c,d){var e=b+c;if(d)for(;e>0&&se(a.text.charAt(e));)e+=c;return 0>e||e>a.text.length?null:e}var We=/gecko\/\d/i.test(navigator.userAgent),Xe=/MSIE \d/.test(navigator.userAgent),Ye=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ze=Xe||Ye,$e=Ze&&(Xe?document.documentMode||6:Ye[1]),_e=/WebKit\//.test(navigator.userAgent),af=_e&&/Qt\/\d+\.\d+/.test(navigator.userAgent),bf=/Chrome\//.test(navigator.userAgent),cf=/Opera\//.test(navigator.userAgent),df=/Apple Computer/.test(navigator.vendor),ef=/KHTML\//.test(navigator.userAgent),ff=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),gf=/PhantomJS/.test(navigator.userAgent),hf=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),jf=hf||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),kf=hf||/Mac/.test(navigator.platform),lf=/win/i.test(navigator.platform),mf=cf&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);mf&&(mf=Number(mf[1])),mf&&mf>=15&&(cf=!1,_e=!0);var nf=kf&&(af||cf&&(null==mf||12.11>mf)),of=We||Ze&&$e>=9,pf=!1,qf=!1,rf=a.Pos=function(a,b){return this instanceof rf?(this.line=a,void(this.ch=b)):new rf(a,b)},sf=a.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch};W.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(a){if(a==this)return!0;if(a.primIndex!=this.primIndex||a.ranges.length!=this.ranges.length)return!1;for(var b=0;b=0&&sf(a,d.to())<=0)return c}return-1}},X.prototype={from:function(){return V(this.anchor,this.head)},to:function(){return U(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var tf,uf,vf,wf={left:0,right:0,top:0,bottom:0},xf=null,yf=0,zf=null,Af=0,Bf=0,Cf=null;Ze?Cf=-.53:We?Cf=15:bf?Cf=-.7:df&&(Cf=-1/3);var Df,Ef=null,Ff=a.changeEnd=function(a){return a.text?rf(a.from.line+a.text.length-1,ke(a.text).length+(1==a.text.length?a.from.ch:0)):a.to};a.prototype={constructor:a,focus:function(){window.focus(),zb(this),wb(this)},setOption:function(a,b){var c=this.options,d=c[a];(c[a]!=b||"mode"==a)&&(c[a]=b,Hf.hasOwnProperty(a)&&jb(this,Hf[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](a)},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;cc&&(uc(this,e.head.line,a,!0),c=e.head.line,d==this.doc.sel.primIndex&&sc(this));else{var f=e.from(),g=e.to(),h=Math.max(c,f.line);c=Math.min(this.lastLine(),g.line-(g.ch?0:1))+1;for(var i=h;c>i;++i)uc(this,i,a);var j=this.doc.sel.ranges;0==f.ch&&b.length==j.length&&j[d].from().ch>0&&ga(this.doc,d,new X(f,j[d].to()),og)}}}),getTokenAt:function(a,b){var c=this.doc;a=_(c,a);for(var d=za(this,a.line,b),e=this.doc.mode,f=Dd(c,a.line),g=new Vf(f.text,this.options.tabSize);g.pos>1;if((g?c[2*g-1]:0)>=f)e=g;else{if(!(c[2*g+1]h?b:0==h?null:b.slice(0,h-1)},getModeAt:function(b){var c=this.doc.mode;return c.innerMode?a.innerMode(c,this.getTokenAt(b).state).mode:c},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var c=[];if(!Nf.hasOwnProperty(b))return Nf;var d=Nf[b],e=this.getModeAt(a);if("string"==typeof e[b])d[e[b]]&&c.push(d[e[b]]);else if(e[b])for(var f=0;fd&&(a=d,c=!0);var e=Dd(this.doc,a);return Ra(this,e,{top:0,left:0},b||"page").top+(c?this.doc.height-Jd(e):0)},defaultTextHeight:function(){return Za(this.display)},defaultCharWidth:function(){return $a(this.display)},setGutterMarker:kb(function(a,b,c){return vc(this.doc,a,"gutter",function(a){var d=a.gutterMarkers||(a.gutterMarkers={});return d[b]=c,!c&&re(d)&&(a.gutterMarkers=null),!0})}),clearGutter:kb(function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,pb(b,d,"gutter"),re(c.gutterMarkers)&&(c.gutterMarkers=null)),++d})}),addLineWidget:kb(function(a,b,c){return fd(this,a,b,c)}),removeLineWidget:function(a){a.clear()},lineInfo:function(a){if("number"==typeof a){if(!ba(this.doc,a))return null;var b=a;if(a=Dd(this.doc,a),!a)return null}else{var b=Hd(a);if(null==b)return null}return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=Ua(this,_(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&pc(this,h,g,h+b.offsetWidth,g+b.offsetHeight)},triggerOnKeyDown:kb(Vb),triggerOnKeyPress:kb(Yb),triggerOnKeyUp:Xb,execCommand:function(a){return Qf.hasOwnProperty(a)?Qf[a](this):void 0},findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,g=_(this.doc,a);b>f&&(g=xc(this.doc,g,e,c,d),!g.hitSide);++f);return g},moveH:kb(function(a,b){var c=this;c.extendSelectionsBy(function(d){return c.display.shift||c.doc.extend||d.empty()?xc(c.doc,d.head,a,b,c.options.rtlMoveVisually):0>a?d.from():d.to()},qg)}),deleteH:kb(function(a,b){var c=this.doc.sel,d=this.doc;c.somethingSelected()?d.replaceSelection("",null,"+delete"):wc(this,function(c){var e=xc(d,c.head,a,b,!1);return 0>a?{from:e,to:c.head}:{from:c.head,to:e}})}),findPosV:function(a,b,c,d){var e=1,f=d;0>b&&(e=-1,b=-b);for(var g=0,h=_(this.doc,a);b>g;++g){var i=Ua(this,h,"div");if(null==f?f=i.left:i.left=f,h=yc(this,i,e,c),h.hitSide)break}return h},moveV:kb(function(a,b){var c=this,d=this.doc,e=[],f=!c.display.shift&&!d.extend&&d.sel.somethingSelected();if(d.extendSelectionsBy(function(g){if(f)return 0>a?g.from():g.to();var h=Ua(c,g.head,"div");null!=g.goalColumn&&(h.left=g.goalColumn),e.push(h.left);var i=yc(c,h,a,b);return"page"==b&&g==d.sel.primary()&&rc(c,null,Ta(c,i,"div").top-h.top),i},qg),e.length)for(var g=0;g0&&h(c.charAt(d-1));)--d;for(;e.5)&&g(this),kg(this,"refresh",this)}),swapDoc:kb(function(a){var b=this.doc;return b.cm=null,Cd(this,a),Oa(this),yb(this),this.scrollTo(a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,be(this,"swapDoc",this,b),b}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},ge(a);var Gf=a.defaults={},Hf=a.optionHandlers={},If=a.Init={toString:function(){return"CodeMirror.Init"}};zc("value","",function(a,b){a.setValue(b)},!0),zc("mode",null,function(a,b){a.doc.modeOption=b,c(a)},!0),zc("indentUnit",2,c,!0),zc("indentWithTabs",!1),zc("smartIndent",!0),zc("tabSize",4,function(a){d(a),Oa(a),ob(a)},!0),zc("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(a,b){a.options.specialChars=new RegExp(b.source+(b.test(" ")?"":"| "),"g"),a.refresh()},!0),zc("specialCharPlaceholder",rd,function(a){a.refresh()},!0),zc("electricChars",!0),zc("rtlMoveVisually",!lf),zc("wholeLineUpdateBefore",!0),zc("theme","default",function(a){i(a),j(a)},!0),zc("keyMap","default",h),zc("extraKeys",null),zc("lineWrapping",!1,e,!0),zc("gutters",[],function(a){o(a.options),j(a)},!0),zc("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?w(a.display)+"px":"0",a.refresh()},!0),zc("coverGutterNextToScrollbar",!1,r,!0),zc("lineNumbers",!1,function(a){o(a.options),j(a)},!0),zc("firstLineNumber",1,j,!0),zc("lineNumberFormatter",function(a){return a},j,!0),zc("showCursorWhenSelecting",!1,sa,!0),zc("resetSelectionOnContextMenu",!0),zc("readOnly",!1,function(a,b){"nocursor"==b?($b(a),a.display.input.blur(),a.display.disabled=!0):(a.display.disabled=!1,b||yb(a))}),zc("disableInput",!1,function(a,b){b||yb(a)},!0),zc("dragDrop",!0),zc("cursorBlinkRate",530),zc("cursorScrollMargin",0),zc("cursorHeight",1,sa,!0),zc("singleCursorHeightPerLine",!0,sa,!0),zc("workTime",100),zc("workDelay",100),zc("flattenSpans",!0,d,!0),zc("addModeClass",!1,d,!0),zc("pollInterval",100),zc("undoDepth",200,function(a,b){a.doc.history.undoDepth=b}),zc("historyEventDelay",1250),zc("viewportMargin",10,function(a){a.refresh()},!0),zc("maxHighlightLength",1e4,d,!0),zc("moveInputWithCursor",!0,function(a,b){b||(a.display.inputDiv.style.top=a.display.inputDiv.style.left=0)}),zc("tabindex",null,function(a,b){a.display.input.tabIndex=b||""}),zc("autofocus",null);var Jf=a.modes={},Kf=a.mimeModes={};a.defineMode=function(b,c){a.defaults.mode||"null"==b||(a.defaults.mode=b),arguments.length>2&&(c.dependencies=Array.prototype.slice.call(arguments,2)),Jf[b]=c},a.defineMIME=function(a,b){Kf[a]=b},a.resolveMode=function(b){if("string"==typeof b&&Kf.hasOwnProperty(b))b=Kf[b];else if(b&&"string"==typeof b.name&&Kf.hasOwnProperty(b.name)){var c=Kf[b.name];"string"==typeof c&&(c={name:c}),b=ne(c,b),b.name=c.name}else if("string"==typeof b&&/^[\w\-]+\/[\w\-]+\+xml$/.test(b))return a.resolveMode("application/xml");return"string"==typeof b?{name:b}:b||{name:"null"}},a.getMode=function(b,c){var c=a.resolveMode(c),d=Jf[c.name];if(!d)return a.getMode(b,"text/plain");var e=d(b,c);if(Lf.hasOwnProperty(c.name)){var f=Lf[c.name];for(var g in f)f.hasOwnProperty(g)&&(e.hasOwnProperty(g)&&(e["_"+g]=e[g]),e[g]=f[g])}if(e.name=c.name,c.helperType&&(e.helperType=c.helperType),c.modeProps)for(var g in c.modeProps)e[g]=c.modeProps[g];return e},a.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),a.defineMIME("text/plain","null");var Lf=a.modeExtensions={};a.extendMode=function(a,b){var c=Lf.hasOwnProperty(a)?Lf[a]:Lf[a]={};oe(b,c)},a.defineExtension=function(b,c){a.prototype[b]=c},a.defineDocExtension=function(a,b){cg.prototype[a]=b},a.defineOption=zc;var Mf=[];a.defineInitHook=function(a){Mf.push(a)};var Nf=a.helpers={};a.registerHelper=function(b,c,d){Nf.hasOwnProperty(b)||(Nf[b]=a[b]={_global:[]}),Nf[b][c]=d},a.registerGlobalHelper=function(b,c,d,e){a.registerHelper(b,c,e),Nf[b]._global.push({pred:d,val:e})};var Of=a.copyState=function(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c},Pf=a.startState=function(a,b,c){return a.startState?a.startState(b,c):!0};a.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);if(!c||c.mode==a)break;b=c.state,a=c.mode}return c||{mode:a,state:b}};var Qf=a.commands={selectAll:function(a){a.setSelection(rf(a.firstLine(),0),rf(a.lastLine()),og)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),og)},killLine:function(a){wc(a,function(b){if(b.empty()){var c=Dd(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line0)e=new rf(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),rf(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var g=Dd(a.doc,e.line-1).text;g&&a.replaceRange(f.charAt(0)+"\n"+g.charAt(g.length-1),rf(e.line-1,g.length-1),rf(e.line,1),"+transpose")}c.push(new X(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){ib(a,function(){for(var b=a.listSelections().length,c=0;b>c;c++){var d=a.listSelections()[c];a.replaceRange("\n",d.anchor,d.head,"+input"),a.indentLine(d.from().line+1,null,!0),sc(a)}})},toggleOverwrite:function(a){a.toggleOverwrite()}},Rf=a.keyMap={};Rf.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Rf.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Rf.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Rf.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},Rf["default"]=kf?Rf.macDefault:Rf.pcDefault;var Sf=a.lookupKey=function(a,b,c){function d(b){b=Ac(b);var e=b[a];if(e===!1)return"stop";if(null!=e&&c(e))return!0;if(b.nofallthrough)return"stop";var f=b.fallthrough;if(null==f)return!1;if("[object Array]"!=Object.prototype.toString.call(f))return d(f);for(var g=0;g=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.posb},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);return b>-1?(this.pos=b,!0):void 0},backUp:function(a){this.pos-=a},column:function(){return this.lastColumnPos0?null:(d&&b!==!1&&(this.pos+=d[0].length),d)}var e=function(a){return c?a.toLowerCase():a},f=this.string.substr(this.pos,a.length);return e(f)==e(a)?(b!==!1&&(this.pos+=a.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}}};var Wf=a.TextMarker=function(a,b){this.lines=[],this.type=b,this.doc=a};ge(Wf),Wf.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;if(b&&_a(a),fe(this,"clear")){var c=this.find();c&&be(this,"clear",c.from,c.to)}for(var d=null,e=null,f=0;fa.display.maxLineLength&&(a.display.maxLine=i,a.display.maxLineLength=j,a.display.maxLineChanged=!0)}null!=d&&a&&this.collapsed&&ob(a,d,e+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&na(a.doc)),a&&be(a,"markerCleared",a,this),b&&bb(a),this.parent&&this.parent.clear()}},Wf.prototype.find=function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;ec;++c){var e=this.lines[c];this.height-=e.height,hd(e),be(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0;da;++a)if(c(this.lines[a]))return!0}},Ad.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;ca){var f=Math.min(b,e-a),g=d.height;if(d.removeInner(a,f),this.height-=g-d.height,e==f&&(this.children.splice(c--,1),d.parent=null),0==(b-=f))break;a=0}else a-=e}if(this.size-b<25&&(this.children.length>1||!(this.children[0]instanceof zd))){var h=[];this.collapse(h),this.children=[new zd(h)],this.children[0].parent=this}},collapse:function(a){for(var b=0;b=a){if(e.insertInner(a,b,c),e.lines&&e.lines.length>50){for(;e.lines.length>50;){var g=e.lines.splice(e.lines.length-25,25),h=new zd(g);e.height-=h.height,this.children.splice(d+1,0,h),h.parent=this}this.maybeSpill()}break}a-=f}},maybeSpill:function(){if(!(this.children.length<=10)){var a=this;do{var b=a.children.splice(a.children.length-5,5),c=new Ad(b);if(a.parent){a.size-=c.size,a.height-=c.height;var d=le(a.parent.children,a);a.parent.children.splice(d+1,0,c)}else{var e=new Ad(a.children);e.parent=a,a.children=[e,c],a=e}c.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0;da){var g=Math.min(b,f-a);if(e.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=f}}};var bg=0,cg=a.Doc=function(a,b,c){if(!(this instanceof cg))return new cg(a,b,c);null==c&&(c=0),Ad.call(this,[new zd([new $f("",null)])]),this.first=c,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=c;var d=rf(c,0);this.sel=Z(d),this.history=new Ld(null),this.id=++bg,this.modeOption=b,"string"==typeof a&&(a=Dg(a)),yd(this,{from:d,to:d,text:a}),ka(this,Z(d),og)};cg.prototype=ne(Ad.prototype,{constructor:cg,iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0;d=0;f--)gc(this,d[f]);h?ja(this,h):this.cm&&sc(this.cm)}),undo:lb(function(){ic(this,"undo")}),redo:lb(function(){ic(this,"redo")}),undoSelection:lb(function(){ic(this,"undo",!0)}),redoSelection:lb(function(){ic(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=_(this,a),b=_(this,b);var d=[],e=a.line;return this.iter(a.line,b.line+1,function(f){var g=f.markedSpans;if(g)for(var h=0;hi.to||null==i.from&&e!=a.line||e==b.line&&i.from>b.ch||c&&!c(i.marker)||d.push(i.marker.parent||i.marker)}++e}),d},getAllMarks:function(){var a=[];return this.iter(function(b){var c=b.markedSpans;if(c)for(var d=0;da?(b=a,!0):(a-=e,void++c)}),_(this,rf(c,b))},indexFromPos:function(a){a=_(this,a);var b=a.ch;return a.lineb&&(b=a.from),null!=a.to&&a.toh||h>=b)return g+(b-f);g+=h-f,g+=c-g%c,f=h+1}},sg=[""],tg=function(a){a.select()};hf?tg=function(a){a.selectionStart=0,a.selectionEnd=a.value.length}:Ze&&(tg=function(a){try{a.select()}catch(b){}}),[].indexOf&&(le=function(a,b){return a.indexOf(b)}),[].map&&(me=function(a,b){return a.map(b)});var ug,vg=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,wg=a.isWordChar=function(a){return/\w/.test(a)||a>"€"&&(a.toUpperCase()!=a.toLowerCase()||vg.test(a))},xg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;ug=document.createRange?function(a,b,c){var d=document.createRange();return d.setEnd(a,c),d.setStart(a,b),d}:function(a,b,c){var d=document.body.createTextRange();return d.moveToElementText(a.parentNode),d.collapse(!0),d.moveEnd("character",c),d.moveStart("character",b),d},Ze&&11>$e&&(xe=function(){try{return document.activeElement}catch(a){return document.body}});var yg,zg,Ag,Bg=!1,Cg=function(){if(Ze&&9>$e)return!1;var a=te("div");return"draggable"in a||"dragDrop"in a}(),Dg=a.splitLines=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)},Eg=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},Fg=function(){var a=te("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),Gg=null,Hg={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown", 35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};a.keyNames=Hg,function(){for(var a=0;10>a;a++)Hg[a+48]=Hg[a+96]=String(a);for(var a=65;90>=a;a++)Hg[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)Hg[a+111]=Hg[a+63235]="F"+a}();var Ig,Jg=function(){function a(a){return 247>=a?c.charAt(a):a>=1424&&1524>=a?"R":a>=1536&&1773>=a?d.charAt(a-1536):a>=1774&&2220>=a?"r":a>=8192&&8203>=a?"w":8204==a?"b":"L"}function b(a,b,c){this.level=a,this.from=b,this.to=c}var c="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",d="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,f=/[stwN]/,g=/[LRr]/,h=/[Lb1n]/,i=/[1n]/,j="L";return function(c){if(!e.test(c))return!1;for(var d,k=c.length,l=[],m=0;k>m;++m)l.push(d=a(c.charCodeAt(m)));for(var m=0,n=j;k>m;++m){var d=l[m];"m"==d?l[m]=n:n=d}for(var m=0,o=j;k>m;++m){var d=l[m];"1"==d&&"r"==o?l[m]="n":g.test(d)&&(o=d,"r"==d&&(l[m]="R"))}for(var m=1,n=l[0];k-1>m;++m){var d=l[m];"+"==d&&"1"==n&&"1"==l[m+1]?l[m]="1":","!=d||n!=l[m+1]||"1"!=n&&"n"!=n||(l[m]=n),n=d}for(var m=0;k>m;++m){var d=l[m];if(","==d)l[m]="N";else if("%"==d){for(var p=m+1;k>p&&"%"==l[p];++p);for(var q=m&&"!"==l[m-1]||k>p&&"1"==l[p]?"1":"N",r=m;p>r;++r)l[r]=q;m=p-1}}for(var m=0,o=j;k>m;++m){var d=l[m];"L"==o&&"1"==d?l[m]="L":g.test(d)&&(o=d)}for(var m=0;k>m;++m)if(f.test(l[m])){for(var p=m+1;k>p&&f.test(l[p]);++p);for(var s="L"==(m?l[m-1]:j),t="L"==(k>p?l[p]:j),q=s||t?"L":"R",r=m;p>r;++r)l[r]=q;m=p-1}for(var u,v=[],m=0;k>m;)if(h.test(l[m])){var w=m;for(++m;k>m&&h.test(l[m]);++m);v.push(new b(0,w,m))}else{var x=m,y=v.length;for(++m;k>m&&"L"!=l[m];++m);for(var r=x;m>r;)if(i.test(l[r])){r>x&&v.splice(y,0,new b(1,x,r));var z=r;for(++r;m>r&&i.test(l[r]);++r);v.splice(y,0,new b(2,z,r)),x=r}else++r;m>x&&v.splice(y,0,new b(1,x,m))}return 1==v[0].level&&(u=c.match(/^\s+/))&&(v[0].from=u[0].length,v.unshift(new b(0,0,u[0].length))),1==ke(v).level&&(u=c.match(/\s+$/))&&(ke(v).to-=u[0].length,v.push(new b(0,k-u[0].length,k))),v[0].level!=ke(v).level&&v.push(new b(v[0].level,k,k)),v}}();return a.version="4.7.0",a}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("xml",function(b,c){function d(a,b){function c(c){return b.tokenize=c,c(a,b)}var d=a.next();if("<"==d)return a.eat("!")?a.eat("[")?a.match("CDATA[")?c(g("atom","]]>")):null:a.match("--")?c(g("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),c(h(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=g("meta","?>"),"meta"):(x=a.eat("/")?"closeTag":"openTag",b.tokenize=e,"tag bracket");if("&"==d){var f;return f=a.eat("#")?a.eat("x")?a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):a.eatWhile(/[\d]/)&&a.eat(";"):a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),f?"atom":"error"}return a.eatWhile(/[^&<]/),null}function e(a,b){var c=a.next();if(">"==c||"/"==c&&a.eat(">"))return b.tokenize=d,x=">"==c?"endTag":"selfcloseTag","tag bracket";if("="==c)return x="equals",null;if("<"==c){b.tokenize=d,b.state=l,b.tagName=b.tagStart=null;var e=b.tokenize(a,b);return e?e+" tag error":"tag error"}return/[\'\"]/.test(c)?(b.tokenize=f(c),b.stringStartCol=a.column(),b.tokenize(a,b)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function f(a){var b=function(b,c){for(;!b.eol();)if(b.next()==a){c.tokenize=e;break}return"string"};return b.isInAttribute=!0,b}function g(a,b){return function(c,e){for(;!c.eol();){if(c.match(b)){e.tokenize=d;break}c.next()}return a}}function h(a){return function(b,c){for(var e;null!=(e=b.next());){if("<"==e)return c.tokenize=h(a+1),c.tokenize(b,c);if(">"==e){if(1==a){c.tokenize=d;break}return c.tokenize=h(a-1),c.tokenize(b,c)}}return"meta"}}function i(a,b,c){this.prev=a.context,this.tagName=b,this.indent=a.indented,this.startOfLine=c,(z.doNotIndent.hasOwnProperty(b)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function j(a){a.context&&(a.context=a.context.prev)}function k(a,b){for(var c;;){if(!a.context)return;if(c=a.context.tagName,!z.contextGrabbers.hasOwnProperty(c)||!z.contextGrabbers[c].hasOwnProperty(b))return;j(a)}}function l(a,b,c){return"openTag"==a?(c.tagStart=b.column(),m):"closeTag"==a?n:l}function m(a,b,c){return"word"==a?(c.tagName=b.current(),y="tag",q):(y="error",m)}function n(a,b,c){if("word"==a){var d=b.current();return c.context&&c.context.tagName!=d&&z.implicitlyClosed.hasOwnProperty(c.context.tagName)&&j(c),c.context&&c.context.tagName==d?(y="tag",o):(y="tag error",p)}return y="error",p}function o(a,b,c){return"endTag"!=a?(y="error",o):(j(c),l)}function p(a,b,c){return y="error",o(a,b,c)}function q(a,b,c){if("word"==a)return y="attribute",r;if("endTag"==a||"selfcloseTag"==a){var d=c.tagName,e=c.tagStart;return c.tagName=c.tagStart=null,"selfcloseTag"==a||z.autoSelfClosers.hasOwnProperty(d)?k(c,d):(k(c,d),c.context=new i(c,d,e==c.indented)),l}return y="error",q}function r(a,b,c){return"equals"==a?s:(z.allowMissing||(y="error"),q(a,b,c))}function s(a,b,c){return"string"==a?t:"word"==a&&z.allowUnquoted?(y="string",q):(y="error",q(a,b,c))}function t(a,b,c){return"string"==a?t:q(a,b,c)}var u=b.indentUnit,v=c.multilineTagIndentFactor||1,w=c.multilineTagIndentPastTag;null==w&&(w=!0);var x,y,z=c.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},A=c.alignCDATA;return{startState:function(){return{tokenize:d,state:l,indented:0,tagName:null,tagStart:null,context:null}},token:function(a,b){if(!b.tagName&&a.sol()&&(b.indented=a.indentation()),a.eatSpace())return null;x=null;var c=b.tokenize(a,b);return(c||x)&&"comment"!=c&&(y=null,b.state=b.state(x||c,a,b),y&&(c="error"==y?c+" error":y)),c},indent:function(b,c,f){var g=b.context;if(b.tokenize.isInAttribute)return b.tagStart==b.indented?b.stringStartCol+1:b.indented+u;if(g&&g.noIndent)return a.Pass;if(b.tokenize!=e&&b.tokenize!=d)return f?f.match(/^(\s*)/)[0].length:0;if(b.tagName)return w?b.tagStart+b.tagName.length+2:b.tagStart+u*v;if(A&&/$/,blockCommentStart:"",configuration:c.htmlMode?"html":"xml",helperType:c.htmlMode?"html":"xml"}}),a.defineMIME("text/xml","xml"),a.defineMIME("application/xml","xml"),a.mimeModes.hasOwnProperty("text/html")||a.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("javascript",function(b,c){function d(a){for(var b,c=!1,d=!1;null!=(b=a.next());){if(!c){if("/"==b&&!d)return;"["==b?d=!0:d&&"]"==b&&(d=!1)}c=!c&&"\\"==b}}function e(a,b,c){return oa=a,pa=c,b}function f(a,b){var c=a.next();if('"'==c||"'"==c)return b.tokenize=g(c),b.tokenize(a,b);if("."==c&&a.match(/^\d+(?:[eE][+\-]?\d+)?/))return e("number","number");if("."==c&&a.match(".."))return e("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(c))return e(c);if("="==c&&a.eat(">"))return e("=>","operator");if("0"==c&&a.eat(/x/i))return a.eatWhile(/[\da-f]/i),e("number","number");if(/\d/.test(c))return a.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),e("number","number");if("/"==c)return a.eat("*")?(b.tokenize=h,h(a,b)):a.eat("/")?(a.skipToEnd(),e("comment","comment")):"operator"==b.lastType||"keyword c"==b.lastType||"sof"==b.lastType||/^[\[{}\(,;:]$/.test(b.lastType)?(d(a),a.eatWhile(/[gimy]/),e("regexp","string-2")):(a.eatWhile(xa),e("operator","operator",a.current()));if("`"==c)return b.tokenize=i,i(a,b);if("#"==c)return a.skipToEnd(),e("error","error");if(xa.test(c))return a.eatWhile(xa),e("operator","operator",a.current());if(va.test(c)){a.eatWhile(va);var f=a.current(),j=wa.propertyIsEnumerable(f)&&wa[f];return j&&"."!=b.lastType?e(j.type,j.style,f):e("variable","variable",f)}}function g(a){return function(b,c){var d,g=!1;if(sa&&"@"==b.peek()&&b.match(ya))return c.tokenize=f,e("jsonld-keyword","meta");for(;null!=(d=b.next())&&(d!=a||g);)g=!g&&"\\"==d;return g||(c.tokenize=f),e("string","string")}}function h(a,b){for(var c,d=!1;c=a.next();){if("/"==c&&d){b.tokenize=f;break}d="*"==c}return e("comment","comment")}function i(a,b){for(var c,d=!1;null!=(c=a.next());){if(!d&&("`"==c||"$"==c&&a.eat("{"))){b.tokenize=f;break}d=!d&&"\\"==c}return e("quasi","string-2",a.current())}function j(a,b){b.fatArrowAt&&(b.fatArrowAt=null);var c=a.string.indexOf("=>",a.start);if(!(0>c)){for(var d=0,e=!1,f=c-1;f>=0;--f){var g=a.string.charAt(f),h=za.indexOf(g);if(h>=0&&3>h){if(!d){++f;break}if(0==--d)break}else if(h>=3&&6>h)++d;else if(va.test(g))e=!0;else if(e&&!d){++f;break}}e&&!d&&(b.fatArrowAt=f)}}function k(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,null!=d&&(this.align=d)}function l(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0;for(var d=a.context;d;d=d.prev)for(var c=d.vars;c;c=c.next)if(c.name==b)return!0}function m(a,b,c,d,e){var f=a.cc;for(Ba.state=a,Ba.stream=e,Ba.marked=null,Ba.cc=f,Ba.style=b,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);;){var g=f.length?f.pop():ta?w:v;if(g(c,d)){for(;f.length&&f[f.length-1].lex;)f.pop()();return Ba.marked?Ba.marked:"variable"==c&&l(a,d)?"variable-2":b}}}function n(){for(var a=arguments.length-1;a>=0;a--)Ba.cc.push(arguments[a])}function o(){return n.apply(null,arguments),!0}function p(a){function b(b){for(var c=b;c;c=c.next)if(c.name==a)return!0;return!1}var d=Ba.state;if(d.context){if(Ba.marked="def",b(d.localVars))return;d.localVars={name:a,next:d.localVars}}else{if(b(d.globalVars))return;c.globalVars&&(d.globalVars={name:a,next:d.globalVars})}}function q(){Ba.state.context={prev:Ba.state.context,vars:Ba.state.localVars},Ba.state.localVars=Ca}function r(){Ba.state.localVars=Ba.state.context.vars,Ba.state.context=Ba.state.context.prev}function s(a,b){var c=function(){var c=Ba.state,d=c.indented;if("stat"==c.lexical.type)d=c.lexical.indented;else for(var e=c.lexical;e&&")"==e.type&&e.align;e=e.prev)d=e.indented;c.lexical=new k(d,Ba.stream.column(),a,null,c.lexical,b)};return c.lex=!0,c}function t(){var a=Ba.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function u(a){function b(c){return c==a?o():";"==a?n():o(b)}return b}function v(a,b){return"var"==a?o(s("vardef",b.length),R,u(";"),t):"keyword a"==a?o(s("form"),w,v,t):"keyword b"==a?o(s("form"),v,t):"{"==a?o(s("}"),O,t):";"==a?o():"if"==a?("else"==Ba.state.lexical.info&&Ba.state.cc[Ba.state.cc.length-1]==t&&Ba.state.cc.pop()(),o(s("form"),w,v,t,W)):"function"==a?o(aa):"for"==a?o(s("form"),X,v,t):"variable"==a?o(s("stat"),H):"switch"==a?o(s("form"),w,s("}","switch"),u("{"),O,t,t):"case"==a?o(w,u(":")):"default"==a?o(u(":")):"catch"==a?o(s("form"),q,u("("),ba,u(")"),v,t,r):"module"==a?o(s("form"),q,ga,r,t):"class"==a?o(s("form"),ca,t):"export"==a?o(s("form"),ha,t):"import"==a?o(s("form"),ia,t):n(s("stat"),w,u(";"),t)}function w(a){return y(a,!1)}function x(a){return y(a,!0)}function y(a,b){if(Ba.state.fatArrowAt==Ba.stream.start){var c=b?G:F;if("("==a)return o(q,s(")"),M(S,")"),t,u("=>"),c,r);if("variable"==a)return n(q,S,u("=>"),c,r)}var d=b?C:B;return Aa.hasOwnProperty(a)?o(d):"function"==a?o(aa,d):"keyword c"==a?o(b?A:z):"("==a?o(s(")"),z,na,u(")"),t,d):"operator"==a||"spread"==a?o(b?x:w):"["==a?o(s("]"),la,t,d):"{"==a?N(J,"}",null,d):"quasi"==a?n(D,d):o()}function z(a){return a.match(/[;\}\)\],]/)?n():n(w)}function A(a){return a.match(/[;\}\)\],]/)?n():n(x)}function B(a,b){return","==a?o(w):C(a,b,!1)}function C(a,b,c){var d=0==c?B:C,e=0==c?w:x;return"=>"==a?o(q,c?G:F,r):"operator"==a?/\+\+|--/.test(b)?o(d):"?"==b?o(w,u(":"),e):o(e):"quasi"==a?n(D,d):";"!=a?"("==a?N(x,")","call",d):"."==a?o(I,d):"["==a?o(s("]"),z,u("]"),t,d):void 0:void 0}function D(a,b){return"quasi"!=a?n():"${"!=b.slice(b.length-2)?o(D):o(w,E)}function E(a){return"}"==a?(Ba.marked="string-2",Ba.state.tokenize=i,o(D)):void 0}function F(a){return j(Ba.stream,Ba.state),n("{"==a?v:w)}function G(a){return j(Ba.stream,Ba.state),n("{"==a?v:x)}function H(a){return":"==a?o(t,v):n(B,u(";"),t)}function I(a){return"variable"==a?(Ba.marked="property",o()):void 0}function J(a,b){return"variable"==a||"keyword"==Ba.style?(Ba.marked="property",o("get"==b||"set"==b?K:L)):"number"==a||"string"==a?(Ba.marked=sa?"property":Ba.style+" property",o(L)):"jsonld-keyword"==a?o(L):"["==a?o(w,u("]"),L):void 0}function K(a){return"variable"!=a?n(L):(Ba.marked="property",o(aa))}function L(a){return":"==a?o(x):"("==a?n(aa):void 0}function M(a,b){function c(d){if(","==d){var e=Ba.state.lexical;return"call"==e.info&&(e.pos=(e.pos||0)+1),o(a,c)}return d==b?o():o(u(b))}return function(d){return d==b?o():n(a,c)}}function N(a,b,c){for(var d=3;d!?|~^]/,ya=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,za="([{}])",Aa={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},Ba={state:null,column:null,marked:null,cc:null},Ca={name:"this",next:{name:"arguments"}};return t.lex=!0,{startState:function(a){var b={tokenize:f,lastType:"sof",cc:[],lexical:new k((a||0)-qa,0,"block",!1),localVars:c.localVars,context:c.localVars&&{vars:c.localVars},indented:0};return c.globalVars&&"object"==typeof c.globalVars&&(b.globalVars=c.globalVars),b},token:function(a,b){if(a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation(),j(a,b)),b.tokenize!=h&&a.eatSpace())return null;var c=b.tokenize(a,b);return"comment"==oa?c:(b.lastType="operator"!=oa||"++"!=pa&&"--"!=pa?oa:"incdec",m(b,c,oa,pa,a))},indent:function(b,d){if(b.tokenize==h)return a.Pass;if(b.tokenize!=f)return 0;var e=d&&d.charAt(0),g=b.lexical;if(!/^\s*else\b/.test(d))for(var i=b.cc.length-1;i>=0;--i){var j=b.cc[i];if(j==t)g=g.prev;else if(j!=W)break}"stat"==g.type&&"}"==e&&(g=g.prev),ra&&")"==g.type&&"stat"==g.prev.type&&(g=g.prev);var k=g.type,l=e==k;return"vardef"==k?g.indented+("operator"==b.lastType||","==b.lastType?g.info+1:0):"form"==k&&"{"==e?g.indented:"form"==k?g.indented+qa:"stat"==k?g.indented+("operator"==b.lastType||","==b.lastType?ra||qa:0):"switch"!=g.info||l||0==c.doubleIndentSwitch?g.align?g.column+(l?0:1):g.indented+(l?0:qa):g.indented+(/^(?:case|default)\b/.test(d)?qa:2*qa)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:ta?null:"/*",blockCommentEnd:ta?null:"*/",lineComment:ta?null:"//",fold:"brace",helperType:ta?"json":"javascript",jsonldMode:sa,jsonMode:ta}}),a.registerHelper("wordChars","javascript",/[\w$]/),a.defineMIME("text/javascript","javascript"),a.defineMIME("text/ecmascript","javascript"),a.defineMIME("application/javascript","javascript"),a.defineMIME("application/x-javascript","javascript"),a.defineMIME("application/ecmascript","javascript"),a.defineMIME("application/json",{name:"javascript",json:!0}),a.defineMIME("application/x-json",{name:"javascript",json:!0}),a.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),a.defineMIME("text/typescript",{name:"javascript",typescript:!0}),a.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){for(var b={},c=0;c")?(a.match("-->"),b.tokenize=null):a.skipToEnd(),["comment","comment"]}a.defineMode("css",function(b,c){function d(a,b){return n=b,a}function e(a,b){var c=a.next();if(q[c]){var e=q[c](a,b);if(e!==!1)return e}return"@"==c?(a.eatWhile(/[\w\\\-]/),d("def",a.current())):"="==c||("~"==c||"|"==c)&&a.eat("=")?d(null,"compare"):'"'==c||"'"==c?(b.tokenize=f(c),b.tokenize(a,b)):"#"==c?(a.eatWhile(/[\w\\\-]/),d("atom","hash")):"!"==c?(a.match(/^\s*\w*/),d("keyword","important")):/\d/.test(c)||"."==c&&a.eat(/\d/)?(a.eatWhile(/[\w.%]/),d("number","unit")):"-"!==c?/[,+>*\/]/.test(c)?d(null,"select-op"):"."==c&&a.match(/^-?[_a-z][_a-z0-9-]*/i)?d("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(c)?d(null,c):"u"==c&&a.match("rl(")?(a.backUp(1),b.tokenize=g,d("property","word")):/[\w\\\-]/.test(c)?(a.eatWhile(/[\w\\\-]/),d("property","word")):d(null,null):/[\d.]/.test(a.peek())?(a.eatWhile(/[\w.%]/),d("number","unit")):a.match(/^\w+-/)?d("meta","meta"):void 0}function f(a){return function(b,c){for(var e,f=!1;null!=(e=b.next());){if(e==a&&!f){")"==a&&b.backUp(1);break}f=!f&&"\\"==e}return(e==a||!f&&")"!=a)&&(c.tokenize=null),d("string","string")}}function g(a,b){return a.next(),a.match(/\s*[\"\')]/,!1)?b.tokenize=null:b.tokenize=f(")"),d(null,"(")}function h(a,b,c){this.type=a,this.indent=b,this.prev=c}function i(a,b,c){return a.context=new h(c,b.indentation()+p,a.context),c}function j(a){return a.context=a.context.prev,a.context.type}function k(a,b,c){return z[c.context.type](a,b,c)}function l(a,b,c,d){for(var e=d||1;e>0;e--)c.context=c.context.prev;return k(a,b,c)}function m(a){var b=a.current().toLowerCase();o=w.hasOwnProperty(b)?"atom":v.hasOwnProperty(b)?"keyword":"variable"}c.propertyKeywords||(c=a.resolveMode("text/css"));var n,o,p=b.indentUnit,q=c.tokenHooks,r=c.mediaTypes||{},s=c.mediaFeatures||{},t=c.propertyKeywords||{},u=c.nonStandardPropertyKeywords||{},v=c.colorKeywords||{},w=c.valueKeywords||{},x=c.fontProperties||{},y=c.allowNested,z={};return z.top=function(a,b,c){if("{"==a)return i(c,b,"block");if("}"==a&&c.context.prev)return j(c);if("@media"==a)return i(c,b,"media");if("@font-face"==a)return"font_face_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(a))return"keyframes";if(a&&"@"==a.charAt(0))return i(c,b,"at");if("hash"==a)o="builtin";else if("word"==a)o="tag";else{if("variable-definition"==a)return"maybeprop";if("interpolation"==a)return i(c,b,"interpolation");if(":"==a)return"pseudo";if(y&&"("==a)return i(c,b,"parens")}return c.context.type},z.block=function(a,b,c){if("word"==a){var d=b.current().toLowerCase();return t.hasOwnProperty(d)?(o="property","maybeprop"):u.hasOwnProperty(d)?(o="string-2","maybeprop"):y?(o=b.match(/^\s*:/,!1)?"property":"tag","block"):(o+=" error","maybeprop")}return"meta"==a?"block":y||"hash"!=a&&"qualifier"!=a?z.top(a,b,c):(o="error","block")},z.maybeprop=function(a,b,c){return":"==a?i(c,b,"prop"):k(a,b,c)},z.prop=function(a,b,c){if(";"==a)return j(c);if("{"==a&&y)return i(c,b,"propBlock");if("}"==a||"{"==a)return l(a,b,c);if("("==a)return i(c,b,"parens");if("hash"!=a||/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(b.current())){if("word"==a)m(b);else if("interpolation"==a)return i(c,b,"interpolation")}else o+=" error";return"prop"},z.propBlock=function(a,b,c){return"}"==a?j(c):"word"==a?(o="property","maybeprop"):c.context.type},z.parens=function(a,b,c){return"{"==a||"}"==a?l(a,b,c):")"==a?j(c):"("==a?i(c,b,"parens"):("word"==a&&m(b),"parens")},z.pseudo=function(a,b,c){return"word"==a?(o="variable-3",c.context.type):k(a,b,c)},z.media=function(a,b,c){if("("==a)return i(c,b,"media_parens");if("}"==a)return l(a,b,c);if("{"==a)return j(c)&&i(c,b,y?"block":"top");if("word"==a){var d=b.current().toLowerCase();o="only"==d||"not"==d||"and"==d?"keyword":r.hasOwnProperty(d)?"attribute":s.hasOwnProperty(d)?"property":"error"}return c.context.type},z.media_parens=function(a,b,c){return")"==a?j(c):"{"==a||"}"==a?l(a,b,c,2):z.media(a,b,c)},z.font_face_before=function(a,b,c){return"{"==a?i(c,b,"font_face"):k(a,b,c)},z.font_face=function(a,b,c){return"}"==a?j(c):"word"==a?(o=x.hasOwnProperty(b.current().toLowerCase())?"property":"error","maybeprop"):"font_face"},z.keyframes=function(a,b,c){return"word"==a?(o="variable","keyframes"):"{"==a?i(c,b,"top"):k(a,b,c)},z.at=function(a,b,c){return";"==a?j(c):"{"==a||"}"==a?l(a,b,c):("word"==a?o="tag":"hash"==a&&(o="builtin"),"at")},z.interpolation=function(a,b,c){return"}"==a?j(c):"{"==a||";"==a?l(a,b,c):("variable"!=a&&(o="error"),"interpolation")},{startState:function(a){return{tokenize:null,state:"top",context:new h("top",a||0,null)}},token:function(a,b){if(!b.tokenize&&a.eatSpace())return null;var c=(b.tokenize||e)(a,b);return c&&"object"==typeof c&&(n=c[1],c=c[0]),o=c,b.state=z[b.state](n,a,b),o},indent:function(a,b){var c=a.context,d=b&&b.charAt(0),e=c.indent;return"prop"!=c.type||"}"!=d&&")"!=d||(c=c.prev),!c.prev||("}"!=d||"block"!=c.type&&"top"!=c.type&&"interpolation"!=c.type&&"font_face"!=c.type)&&(")"!=d||"parens"!=c.type&&"media_parens"!=c.type)&&("{"!=d||"at"!=c.type&&"media"!=c.type)||(e=c.indent-p,c=c.prev),e},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var e=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],f=b(e),g=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"],h=b(g),i=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],j=b(i),k=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],l=b(k),m=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],n=b(m),o=["above","absolute","activeborder","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","cover","crop","cross","crosshair","currentcolor","cursive","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ew-resize","expanded","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-table","inset","inside","intrinsic","invert","italic","justify","kannada","katakana","katakana-iroha","keep-all","khmer","landscape","lao","large","larger","left","level","lighter","line-through","linear","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","single","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","x-large","x-small","xor","xx-large","xx-small"],p=b(o),q=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],r=b(q),s=e.concat(g).concat(i).concat(k).concat(m).concat(o); a.registerHelper("hintWords","css",s),a.defineMIME("text/css",{mediaTypes:f,mediaFeatures:h,propertyKeywords:j,nonStandardPropertyKeywords:l,colorKeywords:n,valueKeywords:p,fontProperties:r,tokenHooks:{"<":function(a,b){return a.match("!--")?(b.tokenize=d,d(a,b)):!1},"/":function(a,b){return a.eat("*")?(b.tokenize=c,c(a,b)):!1}},name:"css"}),a.defineMIME("text/x-scss",{mediaTypes:f,mediaFeatures:h,propertyKeywords:j,nonStandardPropertyKeywords:l,colorKeywords:n,valueKeywords:p,fontProperties:r,allowNested:!0,tokenHooks:{"/":function(a,b){return a.eat("/")?(a.skipToEnd(),["comment","comment"]):a.eat("*")?(b.tokenize=c,c(a,b)):["operator","operator"]},":":function(a){return a.match(/\s*\{/)?[null,"{"]:!1},$:function(a){return a.match(/^[\w-]+/),a.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(a){return a.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),a.defineMIME("text/x-less",{mediaTypes:f,mediaFeatures:h,propertyKeywords:j,nonStandardPropertyKeywords:l,colorKeywords:n,valueKeywords:p,fontProperties:r,allowNested:!0,tokenHooks:{"/":function(a,b){return a.eat("/")?(a.skipToEnd(),["comment","comment"]):a.eat("*")?(b.tokenize=c,c(a,b)):["operator","operator"]},"@":function(a){return a.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)?!1:(a.eatWhile(/[\w\\\-]/),a.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("htmlmixed",function(b,c){function d(a,b){var c=b.htmlState.tagName;c&&(c=c.toLowerCase());var d=h.token(a,b.htmlState);if("script"==c&&/\btag\b/.test(d)&&">"==a.current()){var e=a.string.slice(Math.max(0,a.pos-100),a.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i);e=e?e[1]:"",e&&/[\"\']/.test(e.charAt(0))&&(e=e.slice(1,e.length-1));for(var k=0;k"==a.current()&&(b.token=g,b.localMode=i,b.localState=i.startState(h.indent(b.htmlState,"")));return d}function e(a,b,c){var d,e=a.current(),f=e.search(b);return f>-1?a.backUp(e.length-f):(d=e.match(/<\/?$/))&&(a.backUp(e.length),a.match(b,!1)||a.match(e)),c}function f(a,b){return a.match(/^<\/\s*script\s*>/i,!1)?(b.token=d,b.localState=b.localMode=null,d(a,b)):e(a,/<\/\s*script\s*>/,b.localMode.token(a,b.localState))}function g(a,b){return a.match(/^<\/\s*style\s*>/i,!1)?(b.token=d,b.localState=b.localMode=null,d(a,b)):e(a,/<\/\s*style\s*>/,i.token(a,b.localState))}var h=a.getMode(b,{name:"xml",htmlMode:!0,multilineTagIndentFactor:c.multilineTagIndentFactor,multilineTagIndentPastTag:c.multilineTagIndentPastTag}),i=a.getMode(b,"css"),j=[],k=c&&c.scriptTypes;if(j.push({matches:/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,mode:a.getMode(b,"javascript")}),k)for(var l=0;l=0?(b.indentationDiff<4&&(b.indentation-=b.indentationDiff),b.list=null):b.list!==!1&&b.indentation>0?(b.list=null,b.listDepth=Math.floor(b.indentation/4)):b.list!==!1&&(b.list=!1,b.listDepth=0);var h=null;if(b.indentationDiff>=4)return b.indentation-=4,a.skipToEnd(),z;if(a.eatSpace())return null;if(h=a.match(R))return b.header=h[0].length<=6?h[0].length:6,c.highlightFormatting&&(b.formatting="header"),b.f=b.inline,j(b);if(b.prevLineHasContent&&(h=a.match(S)))return b.header="="==h[0].charAt(0)?1:2,c.highlightFormatting&&(b.formatting="header"),b.f=b.inline,j(b);if(a.eat(">"))return b.indentation++,b.quote=f?1:b.quote+1,c.highlightFormatting&&(b.formatting="quote"),a.eatSpace(),j(b);if("["===a.peek())return d(a,b,p);if(a.match(N,!0))return E;if((!b.prevLineHasContent||g)&&(a.match(O,!1)||a.match(P,!1))){var k=null;return a.match(O,!0)?k="ul":(a.match(P,!0),k="ol"),b.indentation+=4,b.list=!0,b.listDepth++,c.taskLists&&a.match(Q,!1)&&(b.taskList=!0),b.f=b.inline,c.highlightFormatting&&(b.formatting=["list","list-"+k]),j(b)}return c.fencedCodeBlocks&&a.match(/^```([\w+#]*)/,!0)?(b.localMode=w(RegExp.$1),b.localMode&&(b.localState=b.localMode.startState()),e(a,b,i),c.highlightFormatting&&(b.formatting="code-block"),b.code=!0,j(b)):d(a,b,b.inline)}function h(a,b){var c=u.token(a,b.htmlState);return(t&&null===b.htmlState.tagStart&&!b.htmlState.context||b.md_inside&&a.current().indexOf(">")>-1)&&(b.f=l,b.block=g,b.htmlState=null),c}function i(a,b){if(a.sol()&&a.match(/^```/,!0)){b.localMode=b.localState=null,b.f=l,b.block=g,c.highlightFormatting&&(b.formatting="code-block"),b.code=!0;var d=j(b);return b.code=!1,d}return b.localMode?b.localMode.token(a,b.localState):(a.skipToEnd(),z)}function j(a){var b=[];if(a.formatting){b.push(G),"string"==typeof a.formatting&&(a.formatting=[a.formatting]);for(var d=0;d=a.quote?G+"-"+a.formatting[d]+"-"+a.quote:"error")}if(a.taskOpen)return b.push("meta"),b.length?b.join(" "):null;if(a.taskClosed)return b.push("property"),b.length?b.join(" "):null;if(a.linkHref)return b.push(K),b.length?b.join(" "):null;if(a.strong&&b.push(M),a.em&&b.push(L),a.linkText&&b.push(J),a.code&&b.push(z),a.header&&(b.push(y),b.push(y+"-"+a.header)),a.quote&&(b.push(A),b.push(!c.maxBlockquoteDepth||c.maxBlockquoteDepth>=a.quote?A+"-"+a.quote:A+"-"+c.maxBlockquoteDepth)),a.list!==!1){var e=(a.listDepth-1)%3;b.push(e?1===e?C:D:B)}return a.trailingSpaceNewLine?b.push("trailing-space-new-line"):a.trailingSpace&&b.push("trailing-space-"+(a.trailingSpace%2?"a":"b")),b.length?b.join(" "):null}function k(a,b){return a.match(T,!0)?j(b):void 0}function l(b,d){var f=d.text(b,d);if("undefined"!=typeof f)return f;if(d.list)return d.list=null,j(d);if(d.taskList){var g="x"!==b.match(Q,!0)[1];return g?d.taskOpen=!0:d.taskClosed=!0,c.highlightFormatting&&(d.formatting="task"),d.taskList=!1,j(d)}if(d.taskOpen=!1,d.taskClosed=!1,d.header&&b.match(/^#+$/,!0))return c.highlightFormatting&&(d.formatting="header"),j(d);var i=b.sol(),k=b.next();if("\\"===k&&(b.next(),c.highlightFormatting)){var l=j(d);return l?l+" formatting-escape":"formatting-escape"}if(d.linkTitle){d.linkTitle=!1;var o=k;"("===k&&(o=")"),o=(o+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var p="^\\s*(?:[^"+o+"\\\\]+|\\\\\\\\|\\\\.)"+o;if(b.match(new RegExp(p),!0))return K}if("`"===k){var q=d.formatting;c.highlightFormatting&&(d.formatting="code");var r=j(d),s=b.pos;b.eatWhile("`");var t=1+b.pos-s;return d.code?t===x?(d.code=!1,r):(d.formatting=q,j(d)):(x=t,d.code=!0,j(d))}if(d.code)return j(d);if("!"===k&&b.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return b.match(/\[[^\]]*\]/),d.inline=d.f=n,F;if("["===k&&b.match(/.*\](\(| ?\[)/,!1))return d.linkText=!0,c.highlightFormatting&&(d.formatting="link"),j(d);if("]"===k&&d.linkText){c.highlightFormatting&&(d.formatting="link");var l=j(d);return d.linkText=!1,d.inline=d.f=n,l}if("<"===k&&b.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){d.f=d.inline=m,c.highlightFormatting&&(d.formatting="link");var l=j(d);return l?l+=" ":l="",l+H}if("<"===k&&b.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){d.f=d.inline=m,c.highlightFormatting&&(d.formatting="link");var l=j(d);return l?l+=" ":l="",l+I}if("<"===k&&b.match(/^\w/,!1)){if(-1!=b.string.indexOf(">")){var v=b.string.substring(1,b.string.indexOf(">"));/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(v)&&(d.md_inside=!0)}return b.backUp(1),d.htmlState=a.startState(u),e(b,d,h)}if("<"===k&&b.match(/^\/\w*?>/))return d.md_inside=!1,"tag";var w=!1;if(!c.underscoresBreakWords&&"_"===k&&"_"!==b.peek()&&b.match(/(\w)/,!1)){var y=b.pos-2;if(y>=0){var z=b.string.charAt(y);"_"!==z&&z.match(/(\w)/,!1)&&(w=!0)}}if("*"===k||"_"===k&&!w)if(i&&" "===b.peek());else{if(d.strong===k&&b.eat(k)){c.highlightFormatting&&(d.formatting="strong");var r=j(d);return d.strong=!1,r}if(!d.strong&&b.eat(k))return d.strong=k,c.highlightFormatting&&(d.formatting="strong"),j(d);if(d.em===k){c.highlightFormatting&&(d.formatting="em");var r=j(d);return d.em=!1,r}if(!d.em)return d.em=k,c.highlightFormatting&&(d.formatting="em"),j(d)}else if(" "===k&&(b.eat("*")||b.eat("_"))){if(" "===b.peek())return j(d);b.backUp(1)}return" "===k&&(b.match(/ +$/,!1)?d.trailingSpace++:d.trailingSpace&&(d.trailingSpaceNewLine=!0)),j(d)}function m(a,b){var d=a.next();if(">"===d){b.f=b.inline=l,c.highlightFormatting&&(b.formatting="link");var e=j(b);return e?e+=" ":e="",e+H}return a.match(/^[^>]+/,!0),H}function n(a,b){if(a.eatSpace())return null;var d=a.next();return"("===d||"["===d?(b.f=b.inline=o("("===d?")":"]"),c.highlightFormatting&&(b.formatting="link-string"),b.linkHref=!0,j(b)):"error"}function o(a){return function(b,d){var e=b.next();if(e===a){d.f=d.inline=l,c.highlightFormatting&&(d.formatting="link-string");var f=j(d);return d.linkHref=!1,f}return b.match(s(a),!0)&&b.backUp(1),d.linkHref=!0,j(d)}}function p(a,b){return a.match(/^[^\]]*\]:/,!1)?(b.f=q,a.next(),c.highlightFormatting&&(b.formatting="link"),b.linkText=!0,j(b)):d(a,b,l)}function q(a,b){if(a.match(/^\]:/,!0)){b.f=b.inline=r,c.highlightFormatting&&(b.formatting="link");var d=j(b);return b.linkText=!1,d}return a.match(/^[^\]]+/,!0),J}function r(a,b){return a.eatSpace()?null:(a.match(/^[^\s]+/,!0),void 0===a.peek()?b.linkTitle=!0:a.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),b.f=b.inline=l,K)}function s(a){return U[a]||(a=(a+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),U[a]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+a+")")),U[a]}var t=a.modes.hasOwnProperty("xml"),u=a.getMode(b,t?{name:"xml",htmlMode:!0}:"text/plain"),v={html:"htmlmixed",js:"javascript",json:"application/json",c:"text/x-csrc","c++":"text/x-c++src",java:"text/x-java",csharp:"text/x-csharp","c#":"text/x-csharp",scala:"text/x-scala"},w=function(){var c,d,e={},f={},g=[];for(var h in a.modes)a.modes.propertyIsEnumerable(h)&&g.push(h);for(c=0;c` "'(]+/,U=[],V={startState:function(){return{f:g,prevLineHasContent:!1,thisLineHasContent:!1,block:g,htmlState:null,indentation:0,inline:l,text:k,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,em:!1,strong:!1,header:0,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1}},copyState:function(b){return{f:b.f,prevLineHasContent:b.prevLineHasContent,thisLineHasContent:b.thisLineHasContent,block:b.block,htmlState:b.htmlState&&a.copyState(u,b.htmlState),indentation:b.indentation,localMode:b.localMode,localState:b.localMode?a.copyState(b.localMode,b.localState):null,inline:b.inline,text:b.text,formatting:!1,linkTitle:b.linkTitle,em:b.em,strong:b.strong,header:b.header,taskList:b.taskList,list:b.list,listDepth:b.listDepth,quote:b.quote,trailingSpace:b.trailingSpace,trailingSpaceNewLine:b.trailingSpaceNewLine,md_inside:b.md_inside}},token:function(a,b){if(b.formatting=!1,a.sol()){var c=!!b.header;if(b.header=0,a.match(/^\s*$/,!0)||c)return b.prevLineHasContent=!1,f(b),c?this.token(a,b):null;b.prevLineHasContent=b.thisLineHasContent,b.thisLineHasContent=!0,b.taskList=!1,b.code=!1,b.trailingSpace=0,b.trailingSpaceNewLine=!1,b.f=b.block;var d=a.match(/^\s*/,!0)[0].replace(/\t/g," ").length,e=4*Math.floor((d-b.indentation)/4);e>4&&(e=4);var g=b.indentation+e;if(b.indentationDiff=g-b.indentation,b.indentation=g,d>0)return null}var h=b.f(a,b);return a.start==a.pos?this.token(a,b):h},innerMode:function(a){return a.block==h?{state:a.htmlState,mode:u}:a.localState?{state:a.localState,mode:a.localMode}:{state:a,mode:V}},blankLine:f,getType:j,fold:"markdown"};return V},"xml"),a.defineMIME("text/x-markdown","markdown")}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.overlayMode=function(b,c,d){return{startState:function(){return{base:a.startState(b),overlay:a.startState(c),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,lineSeen:null}},copyState:function(d){return{base:a.copyState(b,d.base),overlay:a.copyState(c,d.overlay),basePos:d.basePos,baseCur:null,overlayPos:d.overlayPos,overlayCur:null}},token:function(a,e){return(a.sol()||a.string!=e.lineSeen||Math.min(e.basePos,e.overlayPos)]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i)&&"]("!=a.string.slice(a.start-2,a.start)?(b.combineTokens=!0,"link"):(a.next(),null)},blankLine:d},g={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:!0};for(var h in c)g[h]=c[h];return g.name="markdown",a.defineMIME("gfmBase",g),a.overlayMode(a.getMode(b,"gfmBase"),f)},"markdown")}),function(){function use(a){_p.r([moduleMapping[a]])}var _p={r:function(a){if(_p[a].inited)return _p[a].value;if("function"!=typeof _p[a].value)return _p[a].inited=!0,_p[a].value;var b={exports:{}},c=_p[a].value(null,b.exports,b);if(_p[a].inited=!0,_p[a].value=c,void 0!==c)return c;for(var d in b.exports)if(b.exports.hasOwnProperty(d))return _p[a].inited=!0,_p[a].value=b.exports,b.exports}};_p[0]={value:function(a){function b(a){var b=parseFloat(a,10);return/ms/.test(a)?b:/s/.test(a)?1e3*b:/min/.test(a)?60*b*1e3:b}var c=_p.r(8),d=_p.r(1),e=_p.r(11).createClass("Animator",{constructor:function(a,b,c){if(1==arguments.length){var d=arguments[0];this.beginValue=d.beginValue,this.finishValue=d.finishValue,this.setter=d.setter}else this.beginValue=a,this.finishValue=b,this.setter=c},start:function(a,c,d,e,f){2===arguments.length&&"object"==typeof c&&(d=c.easing,e=c.delay,f=c.callback,c=c.duration),4===arguments.length&&"function"==typeof e&&(f=e,e=0);var g=this.create(a,c,d,f);return e=b(e),e>0?setTimeout(function(){g.play()},e):g.play(),g},create:function(a,f,g,h){var i;return f=f&&b(f)||e.DEFAULT_DURATION,g=g||e.DEFAULT_EASING,"string"==typeof g&&(g=d[g]),i=new c(this,a,f,g),"function"==typeof h&&i.on("finish",h),i},reverse:function(){return new e(this.finishValue,this.beginValue,this.setter)}});e.DEFAULT_DURATION=300,e.DEFAULT_EASING="linear";var f=_p.r(60);return _p.r(11).extendClass(f,{animate:function(a,b,c,d,e){function f(){g.shift(),g.length&&setTimeout(g[0].t.play.bind(g[0].t),g[0].d)}var g=this._KityAnimateQueue=this._KityAnimateQueue||[],h=a.create(this,b,c,e);return h.on("finish",f),g.push({t:h,d:d}),1==g.length&&setTimeout(h.play.bind(h),d),this},timeline:function(){return this._KityAnimateQueue[0].t},stop:function(){var a=this._KityAnimateQueue;if(a)for(;a.length;)a.shift().t.stop();return this}}),e}},_p[1]={value:function(a,b,c){var d={linear:function(a,b,c,d){return c*(a/d)+b},swing:function(a,b,c,e){return d.easeOutQuad(a,b,c,e)},ease:function(a,b,c,e){return d.easeInOutCubic(a,b,c,e)},easeInQuad:function(a,b,c,d){return c*(a/=d)*a+b},easeOutQuad:function(a,b,c,d){return-c*(a/=d)*(a-2)+b},easeInOutQuad:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a+b:-c/2*(--a*(a-2)-1)+b},easeInCubic:function(a,b,c,d){return c*(a/=d)*a*a+b},easeOutCubic:function(a,b,c,d){return c*((a=a/d-1)*a*a+1)+b},easeInOutCubic:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a*a+b:c/2*((a-=2)*a*a+2)+b},easeInQuart:function(a,b,c,d){return c*(a/=d)*a*a*a+b},easeOutQuart:function(a,b,c,d){return-c*((a=a/d-1)*a*a*a-1)+b},easeInOutQuart:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a*a*a+b:-c/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(a,b,c,d){return c*(a/=d)*a*a*a*a+b},easeOutQuint:function(a,b,c,d){return c*((a=a/d-1)*a*a*a*a+1)+b},easeInOutQuint:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a*a*a*a+b:c/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(a,b,c,d){return-c*Math.cos(a/d*(Math.PI/2))+c+b},easeOutSine:function(a,b,c,d){return c*Math.sin(a/d*(Math.PI/2))+b},easeInOutSine:function(a,b,c,d){return-c/2*(Math.cos(Math.PI*a/d)-1)+b},easeInExpo:function(a,b,c,d){return 0===a?b:c*Math.pow(2,10*(a/d-1))+b},easeOutExpo:function(a,b,c,d){return a==d?b+c:c*(-Math.pow(2,-10*a/d)+1)+b},easeInOutExpo:function(a,b,c,d){return 0===a?b:a==d?b+c:(a/=d/2)<1?c/2*Math.pow(2,10*(a-1))+b:c/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(a,b,c,d){return-c*(Math.sqrt(1-(a/=d)*a)-1)+b},easeOutCirc:function(a,b,c,d){return c*Math.sqrt(1-(a=a/d-1)*a)+b},easeInOutCirc:function(a,b,c,d){return(a/=d/2)<1?-c/2*(Math.sqrt(1-a*a)-1)+b:c/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(a,b,c,d){var e=1.70158,f=0,g=c;return 0===a?b:1==(a/=d)?b+c:(f||(f=.3*d),ga?-.5*g*Math.pow(2,10*(a-=1))*Math.sin(2*(a*d-e)*Math.PI/f)+b:g*Math.pow(2,-10*(a-=1))*Math.sin(2*(a*d-e)*Math.PI/f)*.5+c+b},easeInBack:function(a,b,c,d,e){return void 0==e&&(e=1.70158),c*(a/=d)*a*((e+1)*a-e)+b},easeOutBack:function(a,b,c,d,e){return void 0==e&&(e=1.70158),c*((a=a/d-1)*a*((e+1)*a+e)+1)+b},easeInOutBack:function(a,b,c,d,e){return void 0==e&&(e=1.70158),(a/=d/2)<1?c/2*a*a*(((e*=1.525)+1)*a-e)+b:c/2*((a-=2)*a*(((e*=1.525)+1)*a+e)+2)+b},easeInBounce:function(a,b,c,e){return c-d.easeOutBounce(e-a,0,c,e)+b},easeOutBounce:function(a,b,c,d){return(a/=d)<1/2.75?7.5625*c*a*a+b:2/2.75>a?c*(7.5625*(a-=1.5/2.75)*a+.75)+b:2.5/2.75>a?c*(7.5625*(a-=2.25/2.75)*a+.9375)+b:c*(7.5625*(a-=2.625/2.75)*a+.984375)+b},easeInOutBounce:function(a,b,c,e){return e/2>a?.5*d.easeInBounce(2*a,0,c,e)+b:.5*d.easeOutBounce(2*a-e,0,c,e)+.5*c+b}};return d}},_p[2]={value:function(a,b){function c(a){1===l.push(a)&&(i=j(d))}function d(){var a=l;for(l=[];a.length;)h(a.pop());i=0}function e(a){var b=g(a);return c(b),b}function f(a){var b=l.indexOf(a);~b&&l.splice(b,1),0===l.length&&k(i)}function g(a){var b={index:0,time:+new Date,elapsed:0,action:a,next:function(){c(b)}};return b}function h(a){var b=+new Date,c=b-a.time;c>200&&(c=1e3/60),a.dur=c,a.elapsed+=c,a.time=b,a.action.call(null,a),a.index++}var i,j=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return setTimeout(a,1e3/60)},k=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||window.clearTimeout,l=[];b.requestFrame=e,b.releaseFrame=f}},_p[3]={value:function(a){var b=_p.r(0),c=_p.r(34),d=_p.r(46),e=_p.r(60),f=_p.r(11).createClass("MotionAnimator",{base:b,constructor:function(a,b){var e=this;this.callBase({beginValue:0,finishValue:1,setter:function(a,b){var f=e.motionPath instanceof d?e.motionPath.getPathData():e.motionPath,g=c.pointAtPath(f,b);a.setTranslate(g.x,g.y),this.doRotate&&a.setRotate(g.tan.getAngle())}}),this.doRotate=b,this.motionPath=a}});return _p.r(11).extendClass(e,{motion:function(a,b,c,d,e){return this.animate(new f(a),b,c,d,e)}}),f}},_p[4]={value:function(a){var b=_p.r(0),c=_p.r(11).createClass("OpacityAnimator",{base:b,constructor:function(a){this.callBase({beginValue:function(a){return a.getOpacity()},finishValue:a,setter:function(a,b){a.setOpacity(b)}})}}),d=_p.r(60);return _p.r(11).extendClass(d,{fxOpacity:function(a,b,d,e,f){return this.animate(new c(a),b,d,e,f)},fadeTo:function(){return this.fxOpacity.apply(this,arguments)},fadeIn:function(){return this.fxOpacity.apply(this,[1].concat([].slice.call(arguments)))},fadeOut:function(){return this.fxOpacity.apply(this,[0].concat([].slice.call(arguments)))}}),c}},_p[5]={value:function(a){var b=_p.r(0),c=_p.r(34),d=_p.r(11).createClass("OpacityAnimator",{base:b,constructor:function(a){this.callBase({beginValue:function(a){return this.beginPath=a.getPathData(),0},finishValue:1,setter:function(b,d){b.setPathData(c.pathTween(this.beginPath,a,d))}})}}),e=_p.r(46);return _p.r(11).extendClass(e,{fxPath:function(a,b,c,e,f){return this.animate(new d(a),b,c,e,f)}}),d}},_p[6]={value:function(a){var b=_p.r(0),c=_p.r(11).createClass("RotateAnimator",{base:b,constructor:function(a){this.callBase({beginValue:0,finishValue:a,setter:function(a,b,c){var d=c.getDelta();a.rotate(d,ax,ay)}})}}),d=_p.r(60);return _p.r(11).extendClass(d,{fxRotate:function(a,b,d,e,f){return this.animate(new c(a),b,d,e,f)}}),c}},_p[7]={value:function(a){var b=_p.r(0),c=_p.r(11).createClass("ScaleAnimator",{base:b,constructor:function(a,b){this.callBase({beginValue:0,finishValue:1,setter:function(c,d,e){var f=e.getDelta(),g=Math.pow(a,f),h=Math.pow(b,f);c.scale(h,g)}})}}),d=_p.r(60);return _p.r(11).extendClass(d,{fxScale:function(a,b,d,e,f,g){return this.animate(new c(a,b),d,e,f,g)}}),c}},_p[8]={value:function(a){function b(a,b,c){return f.paralle(a,b,function(a,b){return a+(b-a)*c})}function c(a,b){return f.paralle(a,b,function(a,b){return b-a})}function d(a,b,c){this.timeline=a,this.target=a.target,this.type=b;for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d])}var e=_p.r(33),f=_p.r(12),g=_p.r(2),h=_p.r(11).createClass("Timeline",{mixins:[e],constructor:function(a,b,c,d){this.callMixin(),this.target=b,this.time=0,this.duration=c,this.easing=d,this.animator=a,this.beginValue=a.beginValue,this.finishValue=a.finishValue,this.setter=a.setter,this.status="ready"},nextFrame:function(a){"playing"==this.status&&(this.time+=a.dur,this.setValue(this.getValue()),this.time>=this.duration&&this.timeUp(),a.next())},getPlayTime:function(){return this.rollbacking?this.duration-this.time:this.time},getTimeProportion:function(){return this.getPlayTime()/this.duration},getValueProportion:function(){return this.easing(this.getPlayTime(),0,1,this.duration)},getValue:function(){var a=this.beginValue,c=this.finishValue,d=this.getValueProportion();return b(a,c,d)},setValue:function(a){this.lastValue=this.currentValue,this.currentValue=a,this.setter.call(this.target,this.target,a,this)},getDelta:function(){return this.lastValue=void 0===this.lastValue?this.beginValue:this.lastValue,c(this.lastValue,this.currentValue)},play:function(){var a=this.status;switch(this.status="playing",a){case"ready":f.isFunction(this.beginValue)&&(this.beginValue=this.beginValue.call(this.target,this.target)),f.isFunction(this.finishValue)&&(this.finishValue=this.finishValue.call(this.target,this.target)),this.time=0,this.setValue(this.beginValue),this.frame=g.requestFrame(this.nextFrame.bind(this));break;case"finished":case"stoped":this.time=0,this.frame=g.requestFrame(this.nextFrame.bind(this));break;case"paused":this.frame.next()}return this.fire("play",new d(this,"play",{lastStatus:a})),this},pause:function(){return this.status="paused",this.fire("pause",new d(this,"pause")),g.releaseFrame(this.frame),this},stop:function(){return this.status="stoped",this.setValue(this.finishValue),this.rollbacking=!1,this.fire("stop",new d(this,"stop")),g.releaseFrame(this.frame),this},timeUp:function(){this.repeatOption?(this.time=0,this.rollback?this.rollbacking?(this.decreaseRepeat(),this.rollbacking=!1):(this.rollbacking=!0,this.fire("rollback",new d(this,"rollback"))):this.decreaseRepeat(),this.repeatOption?this.fire("repeat",new d(this,"repeat")):this.finish()):this.finish()},finish:function(){this.setValue(this.finishValue),this.status="finished",this.fire("finish",new d(this,"finish")),g.releaseFrame(this.frame)},decreaseRepeat:function(){this.repeatOption!==!0&&this.repeatOption--},repeat:function(a,b){return this.repeatOption=a,this.rollback=b,this}});return h.requestFrame=g.requestFrame,h.releaseFrame=g.releaseFrame,h}},_p[9]={value:function(a){var b=_p.r(0),c=_p.r(11).createClass("TranslateAnimator",{base:b,constructor:function(a,b){this.callBase({x:0,y:0},{x:a,y:b},function(a,b,c){var d=c.getDelta();a.translate(d.x,d.y)})}}),d=_p.r(60);return _p.r(11).extendClass(d,{fxTranslate:function(a,b,d,e,f,g){return this.animate(new c(a,b),d,e,f,g)}}),c}},_p[10]={value:function(){var a=function(){var a,b=navigator.userAgent.toLowerCase(),c=window.opera;a={ie:/(msie\s|trident.*rv:)([\w.]+)/.test(b),opera:!!c&&c.version,webkit:b.indexOf(" applewebkit/")>-1,mac:b.indexOf("macintosh")>-1},a.gecko="Gecko"==navigator.product&&!a.webkit&&!a.opera&&!a.ie;var d=0;if(a.ie&&(d=1*(b.match(/(msie\s|trident.*rv:)([\w.]+)/)[2]||0),a.ie11Compat=11==document.documentMode,a.ie9Compat=9==document.documentMode),a.gecko){var e=b.match(/rv:([\d\.]+)/);e&&(e=e[1].split("."),d=1e4*e[0]+100*(e[1]||0)+1*(e[2]||0))}return/chrome\/(\d+\.\d)/i.test(b)&&(a.chrome=+RegExp.$1),/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(b)&&!/chrome/i.test(b)&&(a.safari=+(RegExp.$1||RegExp.$2)),a.opera&&(d=parseFloat(c.version())),a.webkit&&(d=parseFloat(b.match(/ applewebkit\/(\d+)/)[1])),a.version=d,a.isCompatible=!a.mobile&&(a.ie&&d>=6||a.gecko&&d>=10801||a.opera&&d>=9.5||a.air&&d>=1||a.webkit&&d>=522||!1),a}();return a}},_p[11]={value:function(require,exports){function Class(){}function checkBaseConstructorCall(a,b){var c=a.toString();if(!/this\.callBase/.test(c))throw new Error(b+" : 类构造函数没有调用父类的构造函数!为了安全,请调用父类的构造函数")}function inherit(constructor,BaseClass,classname){var KityClass=eval("(function "+classname+"( __inherit__flag ) {if( __inherit__flag != KITY_INHERIT_FLAG ) {KityClass.__KityConstructor.apply(this, arguments);}this.__KityClassName = KityClass.__KityClassName;})");KityClass.__KityConstructor=constructor,KityClass.prototype=new BaseClass(KITY_INHERIT_FLAG);for(var methodName in BaseClass.prototype)BaseClass.prototype.hasOwnProperty(methodName)&&0!==methodName.indexOf("__Kity")&&(KityClass.prototype[methodName]=BaseClass.prototype[methodName]);return KityClass.prototype.constructor=KityClass,KityClass}function mixin(a,b){if(!1==b instanceof Array)return a;var c,d,e,f=b.length;for(a.__KityMixins={constructor:[]},c=0;f>c;c++){d=b[c].prototype;for(e in d)!1!==d.hasOwnProperty(e)&&0!==e.indexOf("__Kity")&&("constructor"===e?a.__KityMixins.constructor.push(d[e]):a.prototype[e]=a.__KityMixins[e]=d[e])}return a}function extend(a,b){b.__KityClassName&&(b=b.prototype);for(var c in b)if(b.hasOwnProperty(c)&&c.indexOf("__Kity")&&"constructor"!=c){var d=a.prototype[c]=b[c];d.__KityMethodClass=a,d.__KityMethodName=c}return a}exports.Class=Class,Class.__KityClassName="Class",Class.prototype.base=function(a){var b=arguments.callee.caller,c=b.__KityMethodClass.__KityBaseClass.prototype[a];return c.apply(this,Array.prototype.slice.call(arguments,1))},Class.prototype.callBase=function(){var a=arguments.callee.caller,b=a.__KityMethodClass.__KityBaseClass.prototype[a.__KityMethodName];return b.apply(this,arguments)},Class.prototype.mixin=function(a){var b=arguments.callee.caller,c=b.__KityMethodClass.__KityMixins;if(!c)return this;var d=c[a];return d.apply(this,Array.prototype.slice.call(arguments,1))},Class.prototype.callMixin=function(){var a=arguments.callee.caller,b=a.__KityMethodName,c=a.__KityMethodClass.__KityMixins;if(!c)return this;var d=c[b];if("constructor"==b){for(var e=0,f=d.length;f>e;e++)d[e].call(this);return this}return d.apply(this,arguments)},Class.prototype.pipe=function(a){return"function"==typeof a&&a.call(this,this),this},Class.prototype.getType=function(){return this.__KityClassName},Class.prototype.getClass=function(){return this.constructor};var KITY_INHERIT_FLAG="__KITY_INHERIT_FLAG_"+ +new Date;exports.createClass=function(a,b){var c,d,e;return 1===arguments.length&&(b=arguments[0], a="AnonymousClass"),e=b.base||Class,b.hasOwnProperty("constructor")?(c=b.constructor,e!=Class&&checkBaseConstructorCall(c,a)):c=function(){this.callBase.apply(this,arguments),this.callMixin.apply(this,arguments)},d=inherit(c,e,a),d=mixin(d,b.mixins),d.__KityClassName=c.__KityClassName=a,d.__KityBaseClass=c.__KityBaseClass=e,d.__KityMethodName=c.__KityMethodName="constructor",d.__KityMethodClass=c.__KityMethodClass=d,delete b.mixins,delete b.constructor,delete b.base,d=extend(d,b)},exports.extendClass=extend}},_p[12]={value:function(){var a={each:function(a,b,c){if(null!==a)if(a.length===+a.length){for(var d=0,e=a.length;e>d;d++)if(b.call(c,a[d],d,a)===!1)return!1}else for(var f in a)if(a.hasOwnProperty(f)&&b.call(c,a[f],f,a)===!1)return!1},extend:function(a){for(var b=arguments,c=this.isBoolean(b[b.length-1])?b[b.length-1]:!1,d=this.isBoolean(b[b.length-1])?b.length-1:b.length,e=1;d>e;e++){var f=b[e];for(var g in f)c&&a.hasOwnProperty(g)||(a[g]=f[g])}return a},deepExtend:function(a,b){for(var c=arguments,d=this.isBoolean(c[c.length-1])?c[c.length-1]:!1,e=this.isBoolean(c[c.length-1])?c.length-1:c.length,f=1;e>f;f++){var g=c[f];for(var h in g)d&&a.hasOwnProperty(h)||(this.isObject(a[h])&&this.isObject(g[h])?this.deepExtend(a[h],g[h],d):a[h]=g[h])}return a},clone:function(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b},copy:function(a){return"object"!=typeof a?a:"function"==typeof a?null:JSON.parse(JSON.stringify(a))},queryPath:function(a,b){for(var c=a.split("."),d=0,e=b,f=c.length;f>d;){if(!(c[d]in e))return void 0;if(e=e[c[d]],d++,d>=f||void 0===e)return e}},getValue:function(a,b){return void 0!==a?a:b},flatten:function(b){var c,d=[],e=b.length;for(c=0;e>c;c++)b[c]instanceof Array?d=d.concat(a.flatten(b[c])):d.push(b[c]);return d},paralle:function(b,c,d){var e,f,g,h;if(b instanceof Array){for(h=[],f=0;fd;d++)b[5*d+3]=c[d]/255;return b[18]=a.get("a"),this.colorMatrixEffect.set("values",b.join(" ")),this},setOpacity:function(a){var b=this.colorMatrixEffect.get("values").split(" ");return b[18]=a,this.colorMatrixEffect.set("values",b.join(" ")),this},setOffset:function(a,b){this.setOffsetX(a),this.setOffsetY(b)},setOffsetX:function(a){this.offsetEffect.set("dx",a)},setOffsetY:function(a){this.offsetEffect.set("dy",a)},setDeviation:function(a){this.gaussianblurEffect.set("stdDeviation",a)}})}},_p[23]={value:function(a,b,c){return _p.r(11).createClass("Bezier",{mixins:[_p.r(51)],base:_p.r(46),constructor:function(a){this.callBase(),a=a||[],this.changeable=!0,this.setBezierPoints(a)},getBezierPoints:function(){return this.getPoints()},setBezierPoints:function(a){return this.setPoints(a)},onContainerChanged:function(){this.changeable&&this.update()},update:function(){var a=null,b=this.getBezierPoints();if(!(b.length<2)){a=this.getDrawer(),a.clear();var c=b[0].getVertex(),d=null,e=null;a.moveTo(c.x,c.y);for(var f=1,g=b.length;g>f;f++)c=b[f].getVertex(),e=b[f].getBackward(),d=b[f-1].getForward(),a.bezierTo(d.x,d.y,e.x,e.y,c.x,c.y);return this}}})}},_p[24]={value:function(a,b,c){var d=_p.r(63),e=_p.r(73),f=_p.r(11).createClass("BezierPoint",{constructor:function(a,b,c){this.vertex=new d(a,b),this.forward=new d(a,b),this.backward=new d(a,b),this.setSmooth(void 0===c||c),this.setSymReflaction(!0)},clone:function(){var a=new f,b=null;return b=this.getVertex(),a.setVertex(b.x,b.y),b=this.getForward(),a.setForward(b.x,b.y),b=this.getBackward(),a.setBackward(b.x,b.y),a.setSymReflaction(this.isSymReflaction),a.setSmooth(this.isSmooth()),a},setVertex:function(a,b){return this.vertex.setPoint(a,b),this.update(),this},moveTo:function(a,b){var c=this.forward.getPoint(),d=this.backward.getPoint(),e=this.vertex.getPoint(),f={left:a-e.x,top:b-e.y};this.forward.setPoint(c.x+f.left,c.y+f.top),this.backward.setPoint(d.x+f.left,d.y+f.top),this.vertex.setPoint(a,b),this.update()},setForward:function(a,b){return this.forward.setPoint(a,b),this.smooth&&this.updateAnother(this.forward,this.backward),this.update(),this.lastControlPointSet=this.forward,this},setBackward:function(a,b){return this.backward.setPoint(a,b),this.smooth&&this.updateAnother(this.backward,this.forward),this.update(),this.lastControlPointSet=this.backward,this},setSymReflaction:function(a){return this.symReflaction=a,this.smooth&&this.setSmooth(!0),this},isSymReflaction:function(){return this.symReflaction},updateAnother:function(a,b){var c=this.getVertex(),d=e.fromPoints(a.getPoint(),c),f=e.fromPoints(c,b.getPoint());return f=d.normalize(this.isSymReflaction()?d.length():f.length()),b.setPoint(c.x+f.x,c.y+f.y),this},setSmooth:function(a){var b;return this.smooth=!!a,this.smooth&&(b=this.lastControlPointSet)&&this.updateAnother(b,b==this.forward?this.backward:this.forward),this},isSmooth:function(){return this.smooth},getVertex:function(){return this.vertex.getPoint()},getForward:function(){return this.forward.getPoint()},getBackward:function(){return this.backward.getPoint()},update:function(){return this.container?void(this.container.update&&this.container.update(this)):this}});return f}},_p[25]={value:function(a,b,c){var d=_p.r(11).createClass("Box",{constructor:function(a,b,c,d){var e=arguments[0];e&&"object"==typeof e&&(a=e.x,b=e.y,c=e.width,d=e.height),0>c&&(a-=c=-c),0>d&&(b-=d=-d),this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0,this.left=this.x,this.right=this.x+this.width,this.top=this.y,this.bottom=this.y+this.height,this.cx=this.x+this.width/2,this.cy=this.y+this.height/2},getRangeX:function(){return[this.left,this.right]},getRangeY:function(){return[this.top,this.bottom]},merge:function(a){if(this.isEmpty())return new d(a.x,a.y,a.width,a.height);var b=Math.min(this.left,a.left),c=Math.max(this.right,a.right),e=Math.min(this.top,a.top),f=Math.max(this.bottom,a.bottom);return new d(b,e,c-b,f-e)},intersect:function(a){!a instanceof d&&(a=new d(a));var b=Math.max(this.left,a.left),c=Math.min(this.right,a.right),e=Math.max(this.top,a.top),f=Math.min(this.bottom,a.bottom);return b>c||e>f?new d:new d(b,e,c-b,f-e)},expand:function(a,b,c,e){if(arguments.length<1)return new d(this);arguments.length<2&&(b=a),arguments.length<3&&(c=a),arguments.length<4&&(e=b);var f=this.left-e,g=this.top-a,h=this.width+b,i=this.height+a;return new d(f,g,h,i)},valueOf:function(){return[this.x,this.y,this.width,this.height]},toString:function(){return this.valueOf().join(" ")},isEmpty:function(){return!this.width||!this.height}});return d.parse=function(a){return"string"==typeof a?d.parse(a.split(/[\s,]+/).map(parseFloat)):a instanceof Array?new d(a[0],a[1],a[2],a[3]):"x"in a?new d(a):null},d}},_p[26]={value:function(a,b,c){return _p.r(11).createClass("Circle",{base:_p.r(32),constructor:function(a,b,c){this.callBase(a,a,b,c)},getRadius:function(){return this.getRadiusX()},setRadius:function(a){return this.callBase(a,a)}})}},_p[27]={value:function(a,b,c){var d=_p.r(11),e=_p.r(60),f=d.createClass("Clip",{base:e,mixins:[_p.r(61)],constructor:function(a){this.callBase("clipPath",a)},clip:function(a){return a.getNode().setAttribute("clip-path",this),this}});return d.extendClass(e,{clipWith:function(a){return a instanceof e&&(a=new f(a.getPaper()).addShape(a)),a.clip(this),this}}),f}},_p[28]={value:function(a,b,c){var d=_p.r(12),e=_p.r(64),f={},g=_p.r(11).createClass("Color",{constructor:function(){var a=null;"string"==typeof arguments[0]?(a=f.parseToValue(arguments[0]),null===a&&(a={r:0,g:0,b:0,h:0,s:0,l:0,a:1})):(a={r:0|arguments[0],g:0|arguments[1],b:0|arguments[2],a:void 0===arguments[3]?1:parseFloat(arguments[3])},a=f.overflowFormat(a),a=d.extend(a,f.rgbValueToHslValue(a))),this._color=a},set:function(a,b){if(!g._MAX_VALUE[a])throw new Error("Color set(): Illegal parameter");return"a"!==a&&(b=Math.floor(b)),"h"==a&&(b=(b+360)%360),this._color[a]=Math.max(g._MIN_VALUE[a],Math.min(g._MAX_VALUE[a],b)),-1!=="rgb".indexOf(a)?this._color=d.extend(this._color,f.rgbValueToHslValue(this._color)):-1!=="hsl".indexOf(a)&&(this._color=d.extend(this._color,f.hslValueToRGBValue(this._color))),this},inc:function(a,b){return b=this.get(a)+b,"h"==a?b=(b+360)%360:(b=Math.min(g._MAX_VALUE[a],b),b=Math.max(g._MIN_VALUE[a],b)),this.clone().set(a,b)},dec:function(a,b){return this.inc(a,-b)},clone:function(){return new g(this.toRGBA())},get:function(a){return g._MAX_VALUE[a]?this._color[a]:null},getValues:function(){return d.clone(this._color)},valueOf:function(){return this.getValues()},toRGB:function(){return f.toString(this._color,"rgb")},toRGBA:function(){return f.toString(this._color,"rgba")},toHEX:function(){return f.toString(this._color,"hex")},toHSL:function(){return f.toString(this._color,"hsl")},toHSLA:function(){return f.toString(this._color,"hsla")},toString:function(){return 1===this._color.a?this.toRGB():this.toRGBA()}});return d.extend(g,{_MAX_VALUE:{r:255,g:255,b:255,h:360,s:100,l:100,a:1},_MIN_VALUE:{r:0,g:0,b:0,h:0,s:0,l:0,a:0},R:"r",G:"g",B:"b",H:"h",S:"s",L:"l",A:"a",parse:function(a){var b;return d.isString(a)&&(b=f.parseToValue(a)),d.isObject(a)&&"r"in a&&(b=a),null===b?new g:new g(b.r,b.g,b.b,b.a)},createHSL:function(a,b,c){return g.createHSLA(a,b,c,1)},createHSLA:function(a,b,c,d){var e=null;return b+="%",c+="%",e=["hsla("+a,b,c,d+")"],g.parse(e.join(", "))},createRGB:function(a,b,c){return g.createRGBA(a,b,c,1)},createRGBA:function(a,b,c,d){return new g(a,b,c,d)}}),d.extend(f,{parseToValue:function(a){var b={};if(a=e.EXTEND_STANDARD[a]||e.COLOR_STANDARD[a]||a,/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(a))b=f.hexToValue(a);else if(/^(rgba?)/i.test(a))b=f.rgbaToValue(a);else{if(!/^(hsla?)/i.test(a))return null;b=f.hslaToValue(a)}return f.overflowFormat(b)},hexToValue:function(a){var b={},c=["r","g","b"];return/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(a)?(a=RegExp.$1.split(""),d.each(c,function(c,d){3===a.length?b[c]=f.toNumber(a[d]+a[d]):b[c]=f.toNumber(a[2*d]+a[2*d+1])}),b=d.extend(b,f.rgbValueToHslValue(b)),b.a=1,b):null},rgbaToValue:function(a){var b={},c=!1,e=["r","g","b"];return/^(rgba?)/i.test(a)?(c=4===RegExp.$1.length,a=a.replace(/^rgba?/i,"").replace(/\s+/g,"").replace(/[^0-9,.]/g,"").split(","),d.each(e,function(c,d){b[c]=0|a[d]}),b=d.extend(b,f.rgbValueToHslValue(b)),b.a=c?parseFloat(a[3]):1,b):null},hslaToValue:function(a){var b={},c=!1;return/^(hsla?)/i.test(a)?(c=4===RegExp.$1.length,a=a.replace(/^hsla?/i,"").replace(/\s+/g,"").replace(/[^0-9,.]/g,"").split(","),b.h=0|a[0],b.s=0|a[1],b.l=0|a[2],b=d.extend(b,f.hslValueToRGBValue(b)),b=f.hslValueToRGBValue(b),b.a=c?parseFloat(a[3]):1,b):null},hslValueToRGBValue:function(a){function b(a,b,c){return 0>c?c+=1:c>1&&(c-=1),1>6*c?a+6*(b-a)*c:1>2*c?b:2>3*c?a+6*(b-a)*(2/3-c):a}var c=null,e=null,f={};return a=d.extend({},a),a.h=a.h/360,a.s=a.s/100,a.l=a.l/100,0===a.s?f.r=f.g=f.b=a.l:(c=a.l<.5?a.l*(1+a.s):a.l+a.s-a.l*a.s,e=2*a.l-c,f.r=b(e,c,a.h+1/3),f.g=b(e,c,a.h),f.b=b(e,c,a.h-1/3)),f.r=Math.min(Math.round(255*f.r),255),f.g=Math.min(Math.round(255*f.g),255),f.b=Math.min(Math.round(255*f.b),255),f},rgbValueToHslValue:function(a){var b=null,c=null,e={};return a=d.extend({},a),a.r=a.r/255,a.g=a.g/255,a.b=a.b/255,b=Math.max(a.r,a.g,a.b),c=Math.min(a.r,a.g,a.b),b===c?e.h=0:b===a.r?a.g>=a.b?e.h=60*(a.g-a.b)/(b-c):e.h=60*(a.g-a.b)/(b-c)+360:b===a.g?e.h=60*(a.b-a.r)/(b-c)+120:b===a.b&&(e.h=60*(a.r-a.g)/(b-c)+240),e.l=(b+c)/2,0===e.l||b===c?e.s=0:e.l>0&&e.l<=.5?e.s=(b-c)/(b+c):e.s=(b-c)/(2-b-c),e.h=Math.round(e.h),e.s=Math.round(100*e.s),e.l=Math.round(100*e.l),e},toString:function(a,b){var c=[];return a=d.extend({},a),-1!==b.indexOf("hsl")&&(a.s+="%",a.l+="%"),"hex"!==b?(d.each(b.split(""),function(b){c.push(a[b])}),(b+"("+c.join(", ")+")").toLowerCase()):(c.push(f.toHexValue(+a.r)),c.push(f.toHexValue(+a.g)),c.push(f.toHexValue(+a.b)),("#"+c.join("")).toLowerCase())},toNumber:function(a){return 0|Number("0x"+a)},toHexValue:function(a){var b=a.toString(16);return 1===b.length?"0"+b:b},overflowFormat:function(a){var b=d.extend({},a),c="rgba";return d.each(c.split(""),function(a){b.hasOwnProperty(a)&&(b[a]=Math.min(g._MAX_VALUE[a],b[a]),b[a]=Math.max(g._MIN_VALUE[a],b[a]))}),b}}),g}},_p[29]={value:function(a,b,c){function d(){return this.container.removeItem(this),this}return _p.r(11).createClass("Container",{getItems:function(){return this.items||(this.items=[])},getItem:function(a){return this.getItems()[a]},getFirstItem:function(){return this.getItem(0)},getLastItem:function(){return this.getItem(this.getItems().length-1)},indexOf:function(a){return this.getItems().indexOf(a)},eachItem:function(a){var b,c=this.getItems(),d=c.length;for(b=0;d>b;b++)a.call(this,b,c[b]);return this},addItem:function(a,b,c){var e=this.getItems(),f=e.length;return~e.indexOf(a)?this:(b>=0&&f>b||(b=f),e.splice(b,0,a),"object"==typeof a&&(a.container=this,a.remove=d),this.handleAdd(a,b),c||this.onContainerChanged("add",[a]),this)},addItems:function(a){for(var b=0,c=a.length;c>b;b++)this.addItem(a[b],-1,!0);return this.onContainerChanged("add",a),this},setItems:function(a){return this.clear().addItems(a)},appendItem:function(a){return this.addItem(a)},prependItem:function(a){return this.addItem(a,0)},removeItem:function(a,b){if("number"!=typeof a)return this.removeItem(this.indexOf(a));var c=this.getItems(),d=(c.length,c[a]);return void 0===d?this:(c.splice(a,1),d.container&&delete d.container,d.remove&&delete d.remove,this.handleRemove(d,a),b||this.onContainerChanged("remove",[d]),this)},clear:function(){for(var a,b=[];a=this.getFirstItem();)b.push(a),this.removeItem(0,!0);return this.onContainerChanged("remove",b),this},onContainerChanged:function(a,b){},handleAdd:function(a,b){},handleRemove:function(a,b){}})}},_p[30]={value:function(a,b,c){var d=_p.r(12),e={getCurvePanLines:function(a,b){var c=e.getCenterPoints(a),d=e.getPanLine(a.length,c);return e.getMovedPanLines(a,d,b)},getCenterPoints:function(a){for(var b={},c=null,d=0,e=0,f=a.length;f>d;d++)e=d===f-1?0:d+1,c=d+","+e,b[c]={x:(a[d].x+a[e].y)/2,y:(a[d].x+a[e].y)/2};return b},getPanLine:function(a,b){for(var c,d={},e=null,f=0;a>f;f++){var g=null,h=null;c=(f+1)%a,e=c,g=b[f+","+c],f=c,c=(f+1)%a,h=b[f+","+c],d[e]={points:[{x:g.x,y:g.y},{x:h.x,y:h.y}],center:{x:(g.x+h.x)/2,y:(g.y+h.y)/2}},f=(e+a-1)%a}return d},getMovedPanLines:function(a,b,c){var e={};return d.each(a,function(a,f){var g=b[f],h=g.center,i={x:h.x-a.x,y:h.y-a.y},j=e[f]={points:[],center:{x:a.x,y:a.y}};d.each(g.points,function(a,b){var d={x:a.x-i.x,y:a.y-i.y},e=j.center,f=d.x-e.x,g=d.y-e.y;d.x=e.x+c*f,d.y=e.y+c*g,j.points.push(d)})}),e}};return _p.r(11).createClass("Curve",{base:_p.r(46),mixins:[_p.r(51)],constructor:function(a,b){this.callBase(),this.setPoints(a||[]),this.closeState=!!b,this.changeable=!0,this.smoothFactor=1,this.update()},onContainerChanged:function(){this.changeable&&this.update()},setSmoothFactor:function(a){return this.smoothFactor=0>a?0:a,this.update(),this},getSmoothFactor:function(){return this.smoothFactor},update:function(){var a=this.getPoints(),b=null,c=this.getDrawer(),d=null,f=null,g=null;if(c.clear(),0===a.length)return this;if(c.moveTo(a[0]),1===a.length)return this;if(2===a.length)return c.lineTo(a[1]),this;b=e.getCurvePanLines(a,this.getSmoothFactor());for(var h=1,i=a.length;i>h;h++)d=b[h].center,f=this.closeState||h!=i-1?b[h].points[0]:b[h].center,g=this.closeState||1!=h?b[h-1].points[1]:b[h-1].center,c.bezierTo(g.x,g.y,f.x,f.y,d.x,d.y);return this.closeState&&(d=b[0].center,f=b[0].points[0],g=b[a.length-1].points[1],c.bezierTo(g.x,g.y,f.x,f.y,d.x,d.y)),this},close:function(){return this.closeState=!0,this.update()},open:function(){return this.closeState=!1,this.update()},isClose:function(){return!!this.closeState}})}},_p[31]={value:function(a,b,c){return _p.r(11).createClass("Data",{constructor:function(){this._data={}},setData:function(a,b){return this._data[a]=b,this},getData:function(a){return this._data[a]},removeData:function(a){return delete this._data[a],this}})}},_p[32]={value:function(a,b,c){var d=(_p.r(12),_p.r(50));return _p.r(11).createClass("Ellipse",{base:_p.r(46),constructor:function(a,b,c,d){this.callBase(),this.rx=a||0,this.ry=b||0,this.cx=c||0,this.cy=d||0,this.update()},update:function(){var a=this.rx,b=this.ry,c=this.cx+a,d=this.cx-a,e=this.cy,f=this.getDrawer();return f.clear(),f.moveTo(c,e),f.arcTo(a,b,0,1,1,d,e),f.arcTo(a,b,0,1,1,c,e),this},getRadius:function(){return{x:this.rx,y:this.ry}},getRadiusX:function(){return this.rx},getRadiusY:function(){return this.ry},getCenter:function(){return new d(this.cx,this.cy)},getCenterX:function(){return this.cx},getCenterY:function(){return this.cy},setRadius:function(a,b){return this.rx=a,this.ry=b,this.update()},setRadiusX:function(a){return this.rx=a,this.update()},setRadiusY:function(a){return this.ry=a,this.update()},setCenter:function(a,b){if(1==arguments.length){var c=d.parse(arguments[0]);a=c.x,b=c.y}return this.cx=a,this.cy=b,this.update()},setCenterX:function(a){return this.cx=a,this.update()},setCenterY:function(a){return this.cy=a,this.update()}})}},_p[33]={value:function(a,b,c){function d(a,b,c){return c=!!c,j.isString(a)&&(a=a.match(/\S+/g)),j.each(a,function(a){f.call(this,this.node,a,b,c)},this),this}function e(a,b){var c=null,d=this._EVNET_UID,e=void 0===b;return c=m[d][a],e||(e=!0,j.each(c,function(a,d){a===b?delete c[d]:e=!1})),e&&(h(this.node,a,l[d][a]),delete m[d][a],delete l[d][a]),this}function f(a,b,c,d){var e=this._EVNET_UID,f=this;l[e]||(l[e]={}),l[e][b]||(l[e][b]=function(a){a=new k(a||window.event),j.each(m[e][b],function(c){var e;return c&&(e=c.call(f,a),d&&f.off(b,c)),e},f)}),m[e]||(m[e]={}),m[e][b]?m[e][b].push(c):(m[e][b]=[c],a&&"on"+b in a&&g(a,b,l[e][b]))}function g(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)}function h(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent(b,c)}function i(a,b,c){var d=null,e=null,f=l[a._EVNET_UID];f&&(e=f[b],e&&(d=j.extend({type:b,target:a},c||{}),e.call(a,d)))}!function(){function a(a,b){b=b||{bubbles:!1,cancelable:!1,detail:void 0};var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,b.bubbles,b.cancelable,b.detail),c}a.prototype=window.Event.prototype,window.CustomEvent=a}();var j=_p.r(12),k=_p.r(62),l={},m={},n=0;return _p.r(11).createClass("EventHandler",{constructor:function(){this._EVNET_UID=++n},addEventListener:function(a,b){return d.call(this,a,b,!1)},addOnceEventListener:function(a,b){return d.call(this,a,b,!0)},removeEventListener:function(a,b){return e.call(this,a,b)},on:function(a,b){return this.addEventListener.apply(this,arguments)},once:function(a,b){return this.addOnceEventListener.apply(this,arguments)},off:function(){return this.removeEventListener.apply(this,arguments)},fire:function(a,b){return this.trigger.apply(this,arguments)},trigger:function(a,b){return i(this,a,b),this}})}},_p[34]={value:function(a){function b(a){var b,c,d,e,f;for(b=[],c=0;cc;c++)if(a[c]===b)return a.push(a.splice(c,1)[0])}function e(){var f=Array.prototype.slice.call(arguments,0),g=f.join("␀"),h=e.cache=e.cache||{},i=e.count=e.count||[];return h.hasOwnProperty(g)?(d(i,g),c?c(h[g]):h[g]):(i.length>=1e3&&delete h[i.shift()],i.push(g),h[g]=a.apply(b,f),c?c(h[g]):h[g])}return e}function d(a,b,c,e,f,g,h,i,j,k){var l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q=Math,R=Q.PI,S=Math.abs,T=120*R/180,U=R/180*(+f||0),V=[],W=function(a,b,c){var d=a*Q.cos(c)-b*Q.sin(c),e=a*Q.sin(c)+b*Q.cos(c);return{x:d,y:e}};if(k?(w=k[0],x=k[1],u=k[2],v=k[3]):(l=W(a,b,-U),a=l.x,b=l.y,l=W(i,j,-U),i=l.x,j=l.y,m=Q.cos(R/180*f),n=Q.sin(R/180*f),p=(a-i)/2,q=(b-j)/2,o=p*p/(c*c)+q*q/(e*e),o>1&&(o=Q.sqrt(o),c=o*c,e=o*e),r=c*c,s=e*e,t=(g==h?-1:1)*Q.sqrt(S((r*s-r*q*q-s*p*p)/(r*q*q+s*p*p))),u=t*c*q/e+(a+i)/2,v=t*-e*p/c+(b+j)/2,w=Q.asin(((b-v)/e).toFixed(9)),x=Q.asin(((j-v)/e).toFixed(9)),w=u>a?R-w:w,x=u>i?R-x:x,0>w&&(w=2*R+w),0>x&&(x=2*R+x),h&&w>x&&(w-=2*R),!h&&x>w&&(x-=2*R)),y=x-w,S(y)>T&&(z=x,A=i,B=j,x=w+T*(h&&x>w?1:-1),i=u+c*Q.cos(x),j=v+e*Q.sin(x),V=d(i,j,c,e,f,0,h,A,B,[x,z,u,v])),y=x-w,C=Q.cos(w),D=Q.sin(w),E=Q.cos(x),F=Q.sin(x),G=Q.tan(y/4),H=4/3*c*G,I=4/3*e*G,J=[a,b],K=[a+H*D,b-I*C],L=[i+H*F,j-I*E],M=[i,j],K[0]=2*J[0]-K[0],K[1]=2*J[1]-K[1],k)return[K,L,M].concat(V);for(V=[K,L,M].concat(V).join().split(","),N=[],O=0,P=V.length;P>O;O++)N[O]=O%2?W(V[O-1],V[O],U).y:W(V[O],V[O+1],U).x;return N}function e(a,b,c,d,e,f){var g=1/3,h=2/3;return[g*a+h*c,g*b+h*d,g*e+h*c,g*f+h*d,e,f]}function f(a,b){function c(a){return function(b,c){return b+a*(c-b)}}var d=c(b||.5),e=a,f=e[0],g=e[1],h=e[2],i=e[3],j=e[4],k=e[5],l=e[6],m=e[7],n=d(f,h),o=d(g,i),p=d(h,j),q=d(i,k),r=d(j,l),s=d(k,m),t=d(n,p),u=d(o,q),v=d(p,r),w=d(q,s),x=d(t,v),y=d(u,w);return[[f,g,n,o,t,u,x,y],[x,y,v,w,r,s,l,m]]}var g=_p.r(12),h=_p.r(50),i=_p.r(73),j=_p.r(43),k={},l=/([achlmrqstvz])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?\s*)+)/gi,m=/(-?\d*\.?\d*(?:e[\-+]?\d+)?)\s*,?\s*/gi,n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0};k.pathToString=function(a){return a=a||this,"string"==typeof a?a:a instanceof Array?(a=g.flatten(a),a.join(",").replace(/,?([achlmqrstvxz]),?/gi,"$1")):void 0},k.parsePathString=c(function(a){var b=[];return a.replace(l,function(a,c,d){var e=[],f=c.toLowerCase();if(d.replace(m,function(a,b){b&&e.push(+b)}),"m"==f&&e.length>2&&(b.push([c].concat(e.splice(0,2))),f="l",c="m"==c?"l":"L"),"r"==f)b.push([c].concat(e));else for(;e.length>=n[f]&&(b.push([c].concat(e.splice(0,n[f]))),n[f]););}),b.isUniform=!0,b.toString=k.pathToString,b}),k.pathToAbsolute=c(function(a){var b,c,d,e,f,g,h,i,j=a.isUniform?a:k.parsePathString(k.pathToString(a)),l=[],m=0,n=0,o=0,p=0,q=0;for("M"==j[0][0]&&(m=+j[0][1],n=+j[0][2],o=m,p=n,q++,l[0]=["M",m,n]),d=q,g=j.length;g>d;d++){if(l.push(b=[]),c=j[d],c[0]!=c[0].toUpperCase())switch(b[0]=c[0].toUpperCase(),b[0]){case"A":b[1]=c[1],b[2]=c[2],b[3]=c[3],b[4]=c[4],b[5]=c[5],b[6]=+(c[6]+m),b[7]=+(c[7]+n);break;case"V":b[1]=+c[1]+n;break;case"H":b[1]=+c[1]+m;break;case"M":o=+c[1]+m,p=+c[2]+n;break;default:for(e=1,h=c.length;h>e;e++)b[e]=+c[e]+(e%2?m:n)}else for(f=0,i=c.length;i>f;f++)b[f]=c[f];switch(b[0]){case"Z":m=o,n=p;break;case"H":m=b[1];break;case"V":n=b[1];break;case"M":o=b[b.length-2],p=b[b.length-1];break;default:m=b[b.length-2],n=b[b.length-1]}}return l.isUniform=!0,l.isAbsolute=!0,l.toString=k.pathToString,l}),k.pathToCurve=c(function(a){var b,c,f,g,h,i,j,l,m,n,o,p,q=[];for(a.isAbsolute||(a=k.pathToAbsolute(a)),b=0;bb&&(b=0),Math.pow(b,.5)}var c,d,e,f,g,h,i,j,k,l,m,n=a;return c=-3*n[0]+9*n[2]-9*n[4]+3*n[6],d=6*n[0]-12*n[2]+6*n[4],e=-3*n[0]+3*n[2],f=-3*n[1]+9*n[3]-9*n[5]+3*n[7],g=6*n[1]-12*n[3]+6*n[5],h=-3*n[1]+3*n[3],i=Math.pow(c,2)+Math.pow(f,2),j=2*(c*d+f*g),k=2*(c*e+f*h)+Math.pow(d,2)+Math.pow(g,2),l=2*(d*e+g*h),m=Math.pow(e,2)+Math.pow(h,2),(b(0)+b(1)+4*(b(.125)+b(.375)+b(.625)+b(.875))+2*(b(.25)+b(.5)+b(.75)))/24});var o=c(function(a){var b,c,d,e,f,g,h;for(g=[],h=0,b=0,c=a.length;c>b;b++)d=a[b],"M"!=d[0]?"Z"!=d[0]?(f=k.bezierLength(e.concat(d.slice(1))),g.push([h,h+f]),h+=f,e=d.slice(4)):g.push(null):(e=d.slice(1),g.push(null));return g.totalLength=h,g});k.subPath=function(a,b,c){var d;if(c=c||0,d=b-c,d-=0|d,c-=0|c,b=c+d,b>1)return k.subPath(a,1,c).concat(k.subPath(a,b-1));a.isCurve||(a=k.pathToCurve(a));var e,f,g,h,i,j,l,m,n,p=o(a),q=p.totalLength,r=q*b,s=q*(c||0),t=[];for(e=0,f=a.length;f>e;e++)if("M"!=a[e][0]){if("Z"!=a[e][0])if(g=p[e][0],h=p[e][1],i=h-g,l=j.concat(a[e].slice(1)),s>h)j=l.slice(l.length-2);else{if(s>=g)m=k.subBezier(l,Math.min((r-g)/i,1),(s-g)/i),n=!0,j=m.slice(0,2),t.push(["M"].concat(m.slice(0,2))),t.push(["C"].concat(m.slice(2)));else if(r>=h)t.push(a[e].slice());else{if(!(r>=g))break;m=k.subBezier(l,(r-g)/i),t.push(["C"].concat(m.slice(2))),n=!1}j=l.slice(l.length-2)}}else j=a[e].slice(1),n&&t.push(a[e].slice());return t.isAbsolute=!0,t.isCurve=!0,t.isUniform=!0,t.toString=k.pathToString,t},k.pointAtPath=function(a,b){a.isCurve||(a=k.pathToCurve(a));var c=k.subPath(a,b),d="Z"==c[c.length-1][0]?c[c.length-2]:c[c.length-1];d=d.slice(1);var e=h.parse(d.slice(4)),f=h.parse(d.slice(2,4));return e.tan=i.fromPoints(f,e).normalize(),e},k.pathLength=c(function(a){a.isCurve||(a=k.pathToCurve(a));var b=o(a);return b.totalLength}),k.pathKeyPoints=c(function(a){var b,c,d;for(a.isCurve||(a=k.pathToCurve(a)),d=[],b=0,c=a.length;c>b;b++)"z"!=a[b][0]&&d.push(a[b].slice(a[b].length-2));return d});var p=c(function(a,c){function d(a,b){return a[b||a.i]&&a[b||a.i][0]}function e(a,b){return a[b||a.i]&&a[b||a.i].slice(1)}function f(a,b){var c=e(a,b);return c&&c.slice(-2)}function g(a){return"Z"==d(a)?(a.splice(a.i,1),!0):!1}function h(a){return"M"==d(a)?(a.o.splice(a.o.i,0,["M"].concat(f(a.o,a.o.i-1))), a.i++,a.o.i++,!0):!1}function i(a){for(var b,c=1;!b;)b=f(a,a.length-c++);for(a.o.i=a.i;a.lengthc;c++)for(f.push(g=[a[c][0]]),e=1;ec&&e.setAttribute("stop-opacity",c),this.node.appendChild(e),this}})}},_p[36]={value:function(a,b,c){var d=_p.r(61);return _p.r(11).createClass("Group",{mixins:[d],base:_p.r(60),constructor:function(){this.callBase("g")}})}},_p[37]={value:function(a,b,c){var d=_p.r(61);return _p.r(11).createClass("HyperLink",{mixins:[d],base:_p.r(60),constructor:function(a){this.callBase("a"),this.setHref(a)},setHref:function(a){return this.node.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a),this},getHref:function(){return this.node.getAttributeNS("xlink:href")},setTarget:function(a){return this.node.setAttribute("target",a),this},getTarget:function(){return this.node.getAttribute("target")}})}},_p[38]={value:function(a,b,c){return _p.r(11).createClass("Image",{base:_p.r(60),constructor:function(a,b,c,d,e){this.callBase("image"),this.url=a,this.width=b||0,this.height=c||0,this.x=d||0,this.y=e||0,this.update()},update:function(){return this.node.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.url),this.node.setAttribute("x",this.x),this.node.setAttribute("y",this.y),this.node.setAttribute("width",this.width),this.node.setAttribute("height",this.height),this},setUrl:function(a){return this.url=""===a?null:a,this.update()},getUrl:function(){return this.url},setWidth:function(a){return this.width=a,this.update()},getWidth:function(){return this.width},setHeight:function(a){return this.height=a,this.update()},getHeight:function(){return this.height},setX:function(a){return this.x=a,this.update()},getX:function(){return this.x},setY:function(a){return this.y=a,this.update()},getY:function(){return this.y}})}},_p[39]={value:function(a,b,c){return _p.r(11).createClass("Line",{base:_p.r(46),constructor:function(a,b,c,d){this.callBase(),this.point1={x:a||0,y:b||0},this.point2={x:c||0,y:d||0},this.update()},setPoint1:function(a,b){return this.point1.x=a,this.point1.y=b,this.update()},setPoint2:function(a,b){return this.point2.x=a,this.point2.y=b,this.update()},getPoint1:function(){return{x:this.point1.x,y:this.point1.y}},getPoint2:function(){return{x:this.point2.x,y:this.point2.y}},update:function(){var a=this.getDrawer();return a.clear(),a.moveTo(this.point1.x,this.point1.y),a.lineTo(this.point2.x,this.point2.y),this}})}},_p[40]={value:function(a,b,c){var d=(_p.r(67),_p.r(35));return _p.r(11).createClass("LinearGradientBrush",{base:d,constructor:function(a){this.callBase("linearGradient",a),this.setStartPosition(0,0),this.setEndPosition(1,0)},setStartPosition:function(a,b){return this.node.setAttribute("x1",a),this.node.setAttribute("y1",b),this},setEndPosition:function(a,b){return this.node.setAttribute("x2",a),this.node.setAttribute("y2",b),this},getStartPosition:function(){return{x:+this.node.getAttribute("x1"),y:+this.node.getAttribute("y1")}},getEndPosition:function(){return{x:+this.node.getAttribute("x2"),y:+this.node.getAttribute("y2")}}})}},_p[41]={value:function(a,b,c){var d=_p.r(50),e=_p.r(11).createClass("Marker",{base:_p.r(58),mixins:[_p.r(61),_p.r(75)],constructor:function(){this.callBase("marker"),this.setOrient("auto")},setRef:function(a,b){return 1===arguments.length&&(b=a.y,a=a.x),this.node.setAttribute("refX",a),this.node.setAttribute("refY",b),this},getRef:function(){return new d(+this.node.getAttribute("refX"),+this.node.getAttribute("refY"))},setWidth:function(a){return this.node.setAttribute("markerWidth",this.width=a),this},setOrient:function(a){return this.node.setAttribute("orient",this.orient=a),this},getOrient:function(){return this.orient},getWidth:function(){return+this.width},setHeight:function(a){return this.node.setAttribute("markerHeight",this.height=a),this},getHeight:function(){return+this.height}}),f=_p.r(46);return _p.r(11).extendClass(f,{setMarker:function(a,b){return b=b||"end",a?this.node.setAttribute("marker-"+b,a.toString()):this.node.removeAttribute("marker-"+b),this}}),e}},_p[42]={value:function(a,b,c){var d=_p.r(11),e=_p.r(60),f=d.createClass("Mask",{base:e,mixins:[_p.r(61)],constructor:function(){this.callBase("mask")},mask:function(a){return a.getNode().setAttribute("mask","url(#"+this.getId()+")"),this}});return d.extendClass(e,{maskWith:function(a){return a.mask(this),this}}),f}},_p[43]={value:function(a,b,c){function d(a,b){return{a:b.a*a.a+b.c*a.b,b:b.b*a.a+b.d*a.b,c:b.a*a.c+b.c*a.d,d:b.b*a.c+b.d*a.d,e:b.a*a.e+b.c*a.f+b.e,f:b.b*a.e+b.d*a.f+b.f}}function e(a){return a*Math.PI/180}var f=_p.r(12),g=_p.r(25),h=/matrix\s*\((.+)\)/i,i=_p.r(50),j=_p.r(11).createClass("Matrix",{constructor:function(){arguments.length?this.setMatrix.apply(this,arguments):this.setMatrix(1,0,0,1,0,0)},translate:function(a,b){return this.m=d(this.m,{a:1,c:0,e:a,b:0,d:1,f:b}),this},rotate:function(a){var b=e(a),c=Math.sin(b),f=Math.cos(b);return this.m=d(this.m,{a:f,c:-c,e:0,b:c,d:f,f:0}),this},scale:function(a,b){return void 0===b&&(b=a),this.m=d(this.m,{a:a,c:0,e:0,b:0,d:b,f:0}),this},skew:function(a,b){void 0===b&&(b=a);var c=Math.tan(e(a)),f=Math.tan(e(b));return this.m=d(this.m,{a:1,c:c,e:0,b:f,d:1,f:0}),this},inverse:function(){var a,b,c,d,e,f,g,h=this.m,i=h.a,k=h.b,l=h.c,m=h.d,n=h.e,o=h.f;return a=i*m-k*l,b=m/a,c=-k/a,d=-l/a,e=i/a,f=(l*o-n*m)/a,g=(k*n-i*o)/a,new j(b,c,d,e,f,g)},setMatrix:function(a,b,c,d,e,g){return 1===arguments.length?this.m=f.clone(arguments[0]):this.m={a:a,b:b,c:c,d:d,e:e,f:g},this},getMatrix:function(){return f.clone(this.m)},getTranslate:function(){var a=this.m;return{x:a.e/a.a,y:a.f/a.d}},mergeMatrix:function(a){return new j(d(this.m,a.m))},merge:function(a){return this.mergeMatrix(a)},toString:function(){return this.valueOf().join(" ")},valueOf:function(){var a=this.m;return[a.a,a.b,a.c,a.d,a.e,a.f]},equals:function(a){var b=this.m,c=a.m;return b.a==c.a&&b.b==c.b&&b.c==c.c&&b.d==c.d&&b.e==c.e&&b.f==c.f},transformPoint:function(){return j.transformPoint.apply(null,[].slice.call(arguments).concat([this.m]))},transformBox:function(a){return j.transformBox(a,this.m)},clone:function(){return new j(this.m)}});return j.parse=function(a){var b,c=parseFloat;if(a instanceof Array)return new j({a:a[0],b:a[1],c:a[2],d:a[3],e:a[4],f:a[5]});if(b=h.exec(a)){var d=b[1].split(",");return 6!=d.length&&(d=b[1].split(" ")),new j({a:c(d[0]),b:c(d[1]),c:c(d[2]),d:c(d[3]),e:c(d[4]),f:c(d[5])})}return new j},j.transformPoint=function(a,b,c){return 2===arguments.length&&(c=b,b=a.y,a=a.x),new i(c.a*a+c.c*b+c.e,c.b*a+c.d*b+c.f)},j.transformBox=function(a,b){for(var c,d,e=Number.MAX_VALUE,h=-Number.MAX_VALUE,i=Number.MAX_VALUE,k=-Number.MAX_VALUE,l=[[a.x,a.y],[a.x+a.width,a.y],[a.x,a.y+a.height],[a.x+a.width,a.y+a.height]],m=[];c=l.pop();)d=j.transformPoint(c[0],c[1],b),m.push(d),e=Math.min(e,d.x),h=Math.max(h,d.x),i=Math.min(i,d.y),k=Math.max(k,d.y);return a=new g({x:e,y:i,width:h-e,height:k-i}),f.extend(a,{closurePoints:m}),a},j.getCTM=function(a,b){var c={a:1,b:0,c:0,d:1,e:0,f:0},d=a.shapeNode||a.node;switch(b=b||"parent"){case"screen":c=d.getScreenCTM();break;case"doc":case"paper":c=d.getCTM();break;case"view":case"top":a.getPaper()&&(c=d.getTransformToElement(a.getPaper().shapeNode));break;case"parent":a.node.parentNode&&(c=d.getTransformToElement(a.node.parentNode));break;default:b.node&&(c=d.getTransformToElement(b.shapeNode||b.node))}return c?new j(c.a,c.b,c.c,c.d,c.e,c.f):new j},j}},_p[44]={value:function(a,b,c){var d=_p.r(64),e=_p.r(28),f=_p.r(12),g=_p.r(11).createClass("Palette",{constructor:function(){this.color={}},get:function(a){var b=this.color[a]||d.EXTEND_STANDARD[a]||d.COLOR_STANDARD[a]||"";return b?new e(b):null},getColorValue:function(a){return this.color[a]||d.EXTEND_STANDARD[a]||d.COLOR_STANDARD[a]||""},add:function(a,b){return"string"==typeof b?this.color[a]=new e(b).toRGBA():this.color[a]=b.toRGBA(),b},remove:function(a){return this.color.hasOwnProperty(a)?(delete this.color[a],!0):!1}});return f.extend(g,{getColor:function(a){var b=d.EXTEND_STANDARD[a]||d.COLOR_STANDARD[a];return b?new e(b):null},getColorValue:function(a){return d.EXTEND_STANDARD[a]||d.COLOR_STANDARD[a]||""},addColor:function(a,b){return"string"==typeof b?d.EXTEND_STANDARD[a]=new e(b).toRGBA():d.EXTEND_STANDARD[a]=b.toRGBA(),b},removeColor:function(a){return d.EXTEND_STANDARD.hasOwnProperty(a)?(delete d.EXTEND_STANDARD[a],!0):!1}}),g}},_p[45]={value:function(a,b,c){var d=_p.r(11),e=_p.r(12),f=_p.r(67),g=_p.r(29),h=_p.r(61),i=_p.r(75),j=_p.r(33),k=_p.r(66),l=_p.r(43),m=d.createClass("Paper",{mixins:[h,j,k,i],constructor:function(a){this.callBase(),this.node=this.createSVGNode(),this.node.paper=this,this.node.appendChild(this.resourceNode=f.createNode("defs")),this.node.appendChild(this.shapeNode=f.createNode("g")),this.resources=new g,this.setWidth("100%").setHeight("100%"),a&&this.renderTo(a),this.callMixin()},renderTo:function(a){e.isString(a)&&(a=document.getElementById(a)),this.container=a,a.appendChild(this.node)},createSVGNode:function(){var a=f.createNode("svg");return a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),a.setAttribute("version","1.1"),a},getNode:function(){return this.node},getContainer:function(){return this.container},getWidth:function(){return this.node.clientWidth},setWidth:function(a){return this.node.setAttribute("width",a),this},getHeight:function(){return this.node.clientHeight},setHeight:function(a){return this.node.setAttribute("height",a),this},setViewPort:function(a,b,c){var d,e;1==arguments.length&&(d=arguments[0],a=d.center.x,b=d.center.y,c=d.zoom),c=c||1,e=this.getViewBox();var f=new l,g=e.x+e.width/2-a,h=e.y+e.height/2-b;return f.translate(-a,-b),f.scale(c),f.translate(a,b),f.translate(g,h),this.shapeNode.setAttribute("transform","matrix("+f+")"),this.viewport={center:{x:a,y:b},offset:{x:g,y:h},zoom:c},this},getViewPort:function(){if(!this.viewport){var a=this.getViewBox();return{zoom:1,center:{x:a.x+a.width/2,y:a.y+a.height/2},offset:{x:0,y:0}}}return this.viewport},getViewPortMatrix:function(){return l.parse(this.shapeNode.getAttribute("transform"))},getViewPortTransform:function(){var a=this.shapeNode.getCTM();return new l(a.a,a.b,a.c,a.d,a.e,a.f)},getTransform:function(){return this.getViewPortTransform().reverse()},addResource:function(a){return this.resources.appendItem(a),a.node&&this.resourceNode.appendChild(a.node),this},removeResource:function(a){return a.remove&&a.remove(),a.node&&this.resourceNode.removeChild(a.node),this},getPaper:function(){return this}}),n=_p.r(60);return d.extendClass(n,{getPaper:function(){for(var a=this.container;a&&a instanceof m==!1;)a=a.container;return a},isAttached:function(){return!!this.getPaper()},whenPaperReady:function(a){function b(){var b=c.getPaper();return b&&a&&a.call(c,b),b}var c=this;return b()||this.on("add treeadd",function d(){b()&&(c.off("add",d),c.off("treeadd",d))}),this}}),m}},_p[46]={value:function(a,b,c){var d=_p.r(12),e=_p.r(11).createClass,f=_p.r(60),g=_p.r(67),h=_p.r(34),i=Array.prototype.slice,j=(d.flatten,e("PathDrawer",{constructor:function(a){this.segment=[],this.path=a,this.__clear=!1},getPath:function(){return this.path},redraw:function(){return this._transation=this._transation||[],this.clear()},done:function(){var a=this._transation;return this._transation=null,this.push(a),this},clear:function(){return this._transation?this._transation=[]:this.path.setPathData("M 0 0"),this._clear=!0,this},push:function(){var a,b=i.call(arguments);return this._transation?(this._transation.push(b),this):(this._clear?(a="",this._clear=!1):a=this.path.getPathData(),a=a||"",this.path.setPathData(a+h.pathToString(b)),this)},moveTo:function(a,b){return this.push("M",i.call(arguments))},moveBy:function(a,b){return this.push("m",i.call(arguments))},lineTo:function(a,b){return this.push("L",i.call(arguments))},lineBy:function(a,b){return this.push("l",i.call(arguments))},arcTo:function(a,b,c,d,e,f,g){return this.push("A",i.call(arguments))},arcBy:function(a,b,c,d,e,f,g){return this.push("a",arguments)},carcTo:function(a,b,c,d,e){return this.push("A",[a,a,0].concat(i.call(arguments,1)))},carcBy:function(a,b,c,d,e){return this.push("a",[a,a,0].concat(i.call(arguments,1)))},bezierTo:function(a,b,c,d,e,f){return this.push("C",i.call(arguments))},bezierBy:function(a,b,c,d,e,f){return this.push("c",i.call(arguments))},close:function(){return this.push("z")}}));return e("Path",{base:f,constructor:function(a){this.callBase("path"),a&&this.setPathData(a),this.node.setAttribute("fill",g.defaults.fill),this.node.setAttribute("stroke",g.defaults.stroke)},setPathData:function(a){return a=a||"M0,0",this.pathdata=h.pathToString(a),this.node.setAttribute("d",this.pathdata),this.trigger("shapeupdate",{type:"pathdata"}),this},getPathData:function(){return this.pathdata||""},getDrawer:function(){return new j(this)},isClosed:function(){var a=this.getPathData();return!!~a.indexOf("z")||!!~a.indexOf("Z")}})}},_p[47]={value:function(a,b,c){var d=_p.r(58),e=_p.r(61);_p.r(67);return _p.r(11).createClass("PatternBrush",{base:d,mixins:[e],constructor:function(a){this.callBase("pattern",a),this.node.setAttribute("patternUnits","userSpaceOnUse")},setX:function(a){return this.x=a,this.node.setAttribute("x",a),this},setY:function(a){return this.y=a,this.node.setAttribute("y",a),this},setWidth:function(a){return this.width=a,this.node.setAttribute("width",a),this},setHeight:function(a){return this.height=a,this.node.setAttribute("height",a),this},getWidth:function(){return this.width},getHeight:function(){return this.height}})}},_p[48]={value:function(a,b,c){var d=_p.r(28);return _p.r(11).createClass("Pen",{constructor:function(a,b){this.brush=a,this.width=b||1,this.linecap=null,this.linejoin=null,this.dashArray=null,this.opacity=1},getBrush:function(){return this.brush},setBrush:function(a){return this.brush=a,this},setColor:function(a){return this.setBrush(a)},getColor:function(){return this.brush instanceof d?this.brush:null},getWidth:function(){return this.width},setWidth:function(a){return this.width=a,this},getOpacity:function(){return this.opacity},setOpacity:function(a){this.opacity=a},getLineCap:function(){return this.linecap},setLineCap:function(a){return this.linecap=a,this},getLineJoin:function(){return this.linejoin},setLineJoin:function(a){return this.linejoin=a,this},getDashArray:function(){return this.dashArray},setDashArray:function(a){return this.dashArray=a,this},stroke:function(a){var b=a.node;b.setAttribute("stroke",this.brush.toString()),b.setAttribute("stroke-width",this.getWidth()),this.getOpacity()<1&&b.setAttribute("stroke-opacity",this.getOpacity()),this.getLineCap()&&b.setAttribute("stroke-linecap",this.getLineCap()),this.getLineJoin()&&b.setAttribute("stroke-linejoin",this.getLineJoin()),this.getDashArray()&&b.setAttribute("stroke-dasharray",this.getDashArray())}})}},_p[49]={value:function(a,b,c){return _p.r(11).createClass({base:_p.r(68),constructor:function(a,b,c){this.callBase([0,a],b,c)},getRadius:function(){return this.getSectionArray()[1]},setRadius:function(a){this.setSectionArray([0,a])}})}},_p[50]={value:function(a,b,c){var d=_p.r(11).createClass("Point",{constructor:function(a,b){this.x=a||0,this.y=b||0},offset:function(a,b){return 1==arguments.length&&(b=a.y,a=a.x),new d(this.x+a,this.y+b)},valueOf:function(){return[this.x,this.y]},toString:function(){return this.valueOf().join(" ")},spof:function(){return new d((0|this.x)+.5,(0|this.y)+.5)},round:function(){return new d(0|this.x,0|this.y)},isOrigin:function(){return 0===this.x&&0===this.y}});return d.fromPolar=function(a,b,c){return"rad"!=c&&(b=b/180*Math.PI),new d(a*Math.cos(b),a*Math.sin(b))},d.parse=function(a){return a?a instanceof d?a:"string"==typeof a?d.parse(a.split(/\s*[\s,]\s*/)):"0"in a&&"1"in a?new d(a[0],a[1]):void 0:new d},d}},_p[51]={value:function(a,b,c){return _p.r(11).createClass("PointContainer",{base:_p.r(29),constructor:function(){this.callBase()},addPoint:function(a,b){return this.addItem.apply(this,arguments)},prependPoint:function(){return this.prependItem.apply(this,arguments)},appendPoint:function(){return this.appendItem.apply(this,arguments)},removePoint:function(a){return this.removeItem.apply(this,arguments)},addPoints:function(){return this.addItems.apply(this,arguments)},setPoints:function(){return this.setItems.apply(this,arguments)},getPoint:function(){return this.getItem.apply(this,arguments)},getPoints:function(){return this.getItems.apply(this,arguments)},getFirstPoint:function(){return this.getFirstItem.apply(this,arguments)},getLastPoint:function(){return this.getLastItem.apply(this,arguments)}})}},_p[52]={value:function(a,b,c){_p.r(12);return _p.r(11).createClass("Poly",{base:_p.r(46),mixins:[_p.r(51)],constructor:function(a,b){this.callBase(),this.closeable=!!b,this.setPoints(a||[]),this.changeable=!0,this.update()},onContainerChanged:function(){this.changeable&&this.update()},update:function(){var a=this.getDrawer(),b=this.getPoints();if(a.clear(),!b.length)return this;a.moveTo(b[0]);for(var c,d=1,e=b.length;e>d;d++)c=b[d],a.lineTo(c);return this.closeable&&b.length>2&&a.close(),this}})}},_p[53]={value:function(a,b,c){return _p.r(11).createClass("Polygon",{base:_p.r(52),constructor:function(a){this.callBase(a,!0)}})}},_p[54]={value:function(a,b,c){return _p.r(11).createClass("Polyline",{base:_p.r(52),constructor:function(a){this.callBase(a)}})}},_p[55]={value:function(a,b,c){var d=_p.r(35);return _p.r(11).createClass("RadialGradientBrush",{base:d,constructor:function(a){this.callBase("radialGradient",a),this.setCenter(.5,.5),this.setFocal(.5,.5),this.setRadius(.5)},setCenter:function(a,b){return this.node.setAttribute("cx",a),this.node.setAttribute("cy",b),this},getCenter:function(){return{x:+this.node.getAttribute("cx"),y:+this.node.getAttribute("cy")}},setFocal:function(a,b){return this.node.setAttribute("fx",a),this.node.setAttribute("fy",b),this},getFocal:function(){return{x:+this.node.getAttribute("fx"),y:+this.node.getAttribute("fy")}},setRadius:function(a){return this.node.setAttribute("r",a),this},getRadius:function(){return+this.node.getAttribute("r")}})}},_p[56]={value:function(a,b,c){var d={},e=_p.r(12),f=_p.r(50),g=_p.r(25);e.extend(d,{formatRadius:function(a,b,c){var d=Math.floor(Math.min(a/2,b/2));return Math.min(d,c)}});var h=_p.r(11).createClass("Rect",{base:_p.r(46),constructor:function(a,b,c,e,f){this.callBase(),this.x=c||0,this.y=e||0,this.width=a||0,this.height=b||0,this.radius=d.formatRadius(this.width,this.height,f||0),this.update()},update:function(){var a=this.x,b=this.y,c=this.width,d=this.height,e=this.radius,f=this.getDrawer().redraw();return e?(c-=2*e,d-=2*e,f.push("M",a+e,b),f.push("h",c),f.push("a",e,e,0,0,1,e,e),f.push("v",d),f.push("a",e,e,0,0,1,-e,e),f.push("h",-c),f.push("a",e,e,0,0,1,-e,-e),f.push("v",-d),f.push("a",e,e,0,0,1,e,-e),f.push("z")):(f.push("M",a,b),f.push("h",c),f.push("v",d),f.push("h",-c),f.push("z")),f.done(),this},setWidth:function(a){return this.width=a,this.update()},setHeight:function(a){return this.height=a,this.update()},setSize:function(a,b){return this.width=a,this.height=b,this.update()},setBox:function(a){return this.x=a.x,this.y=a.y,this.width=a.width,this.height=a.height,this.update()},getBox:function(){return new g(this.x,this.y,this.width,this.height)},getRadius:function(){return this.radius},setRadius:function(a){return this.radius=d.formatRadius(this.width,this.height,a||0),this.update()},getPosition:function(){return new f(this.x,this.y)},setPosition:function(a,b){if(1==arguments.length){var c=f.parse(arguments[0]);b=c.y,a=c.x}return this.x=a,this.y=b,this.update()},getWidth:function(){return this.width},getHeight:function(){return this.height},getPositionX:function(){return this.x},getPositionY:function(){return this.y},setPositionX:function(a){return this.x=a,this.update()},setPositionY:function(a){return this.y=a,this.update()}});return h}},_p[57]={value:function(a,b,c){var d=_p.r(50);return _p.r(11).createClass("RegularPolygon",{base:_p.r(46),constructor:function(a,b,c,e){this.callBase(),this.radius=b||0,this.side=Math.max(a||3,3),arguments.length>2&&3==arguments.length&&(e=c.y,c=c.x),this.center=new d(c,e),this.draw()},getSide:function(){return this.side},setSide:function(a){return this.side=a,this.draw()},getRadius:function(){return this.radius},setRadius:function(a){return this.radius=a,this.draw()},draw:function(){var a,b=this.radius,c=this.side,e=2*Math.PI/c,f=this.getDrawer();for(f.clear(),f.moveTo(d.fromPolar(b,Math.PI/2,"rad").offset(this.center)),a=0;c>=a;a++)f.lineTo(d.fromPolar(b,e*a+Math.PI/2,"rad").offset(this.center));return f.close(),this}})}},_p[58]={value:function(a,b,c){var d=_p.r(67);return _p.r(11).createClass("Resource",{constructor:function(a,b){this.callBase(),this.node=d.createNode(a),b&&b.addResource(this)},toString:function(){return"url(#"+this.node.id+")"}})}},_p[59]={value:function(a,b,c){return _p.r(11).createClass({base:_p.r(68),constructor:function(a,b){this.callBase([a,b],360,0)},getInnerRadius:function(){return this.getSectionArray()[0]},getOuterRadius:function(){return this.getSectionArray()[1]},setInnerRadius:function(a){this.setSectionArray([a,this.getOuterRadius()])},setOuterRadius:function(a){this.setSectionArray([this.getInnerRadius(),a])}})}},_p[60]={value:function(a,b,c){var d=_p.r(67),e=_p.r(12),f=_p.r(33),g=_p.r(66),h=_p.r(31),i=_p.r(43),j=(_p.r(48),Array.prototype.slice),k=_p.r(25),l=_p.r(11).createClass("Shape",{mixins:[f,g,h],constructor:function(a){this.node=d.createNode(a),this.node.shape=this,this.transform={translate:null,rotate:null,scale:null,matrix:null},this.callMixin()},getId:function(){return this.node.id},setId:function(a){return this.node.id=a,this},getNode:function(){return this.node},getBoundaryBox:function(){var a;try{a=this.node.getBBox()}catch(b){a={x:this.node.clientLeft,y:this.node.clientTop,width:this.node.clientWidth,height:this.node.clientHeight}}return new k(a)},getRenderBox:function(a){var b=this.getBoundaryBox(),c=this.getTransform(a);return c.transformBox(b)},getWidth:function(){return this.getRenderBox().width},getHeight:function(){return this.getRenderBox().height},getSize:function(){var a=this.getRenderBox();return delete a.x,delete a.y,a},setOpacity:function(a){return this.node.setAttribute("opacity",a),this},getOpacity:function(){var a=this.node.getAttribute("opacity");return a?+a:1},setVisible:function(a){return a?this.node.removeAttribute("display"):this.node.setAttribute("display","none"),this},getVisible:function(){this.node.getAttribute("display")},hasAncestor:function(a){for(var b=this.container;b;){if(b===a)return!0;b=b.container}return!1},getTransform:function(a){return i.getCTM(this,a)},clearTransform:function(){return this.node.removeAttribute("transform"),this.transform={translate:null,rotate:null,scale:null,matrix:null},this.trigger("shapeupdate",{type:"transform"}),this},_applyTransform:function(){var a=this.transform,b=[];return a.translate&&b.push(["translate(",a.translate,")"]),a.rotate&&b.push(["rotate(",a.rotate,")"]),a.scale&&b.push(["scale(",a.scale,")"]),a.matrix&&b.push(["matrix(",a.matrix,")"]),this.node.setAttribute("transform",e.flatten(b).join(" ")),this},setMatrix:function(a){return this.transform.matrix=a,this._applyTransform()},setTranslate:function(a){return this.transform.translate=null!==a&&j.call(arguments)||null,this._applyTransform()},setRotate:function(a){return this.transform.rotate=null!==a&&j.call(arguments)||null,this._applyTransform()},setScale:function(a){return this.transform.scale=null!==a&&j.call(arguments)||null,this._applyTransform()},translate:function(a,b){var c=this.transform.matrix||new i;return void 0===b&&(b=0),this.transform.matrix=c.translate(a,b),this._applyTransform()},rotate:function(a){var b=this.transform.matrix||new i;return this.transform.matrix=b.rotate(a),this._applyTransform()},scale:function(a,b){var c=this.transform.matrix||new i;return void 0===b&&(b=a),this.transform.matrix=c.scale(a,b),this._applyTransform()},skew:function(a,b){var c=this.transform.matrix||new i;return void 0===b&&(b=a),this.transform.matrix=c.skew(a,b),this._applyTransform()},stroke:function(a,b){return a&&a.stroke?a.stroke(this):a?(this.node.setAttribute("stroke",a.toString()),b&&this.node.setAttribute("stroke-width",b)):null===a&&this.node.removeAttribute("stroe"),this},fill:function(a){return a&&this.node.setAttribute("fill",a.toString()),null===a&&this.node.removeAttribute("fill"),this},setAttr:function(a,b){var c=this;return e.isObject(a)&&e.each(a,function(a,b){c.setAttr(b,a)}),void 0===b||null===b||""===b?this.node.removeAttribute(a):this.node.setAttribute(a,b),this},getAttr:function(a){return this.node.getAttribute(a)}});return l}},_p[61]={value:function(a,b,c){var d=_p.r(29),e=_p.r(12),f=_p.r(11).createClass("ShapeContainer",{base:d,isShapeContainer:!0,handleAdd:function(a,b){var c=this.getShapeNode();c.insertBefore(a.node,c.childNodes[b]||null),a.trigger("add",{container:this}),a.notifyTreeModification&&a.notifyTreeModification("treeadd",this)},handleRemove:function(a,b){var c=this.getShapeNode();c.removeChild(a.node),a.trigger("remove",{container:this}),a.notifyTreeModification&&a.notifyTreeModification("treeremove",this)},notifyTreeModification:function(a,b){this.eachItem(function(c,d){d.notifyTreeModification&&d.notifyTreeModification(a,b),d.trigger(a,{container:b})})},getShape:function(a){return this.getItem(a)},addShape:function(a,b){return this.addItem(a,b)},put:function(a){return this.addShape(a),a},appendShape:function(a){return this.addShape(a)},prependShape:function(a){return this.addShape(a,0)},replaceShape:function(a,b){var c=this.indexOf(b);if(-1!==c)return this.removeShape(c),this.addShape(a,c),this},addShapeBefore:function(a,b){var c=this.indexOf(b);return this.addShape(a,c)},addShapeAfter:function(a,b){var c=this.indexOf(b);return this.addShape(a,-1===c?void 0:c+1)},addShapes:function(a){return this.addItems(a)},removeShape:function(a){return this.removeItem(a)},getShapes:function(){return this.getItems()},getShapesByType:function(a){function b(d){a.toLowerCase()==d.getType().toLowerCase()&&c.push(d),d.isShapeContainer&&e.each(d.getShapes(),function(a){b(a)})}var c=[];return b(this),c},getShapeById:function(a){return this.getShapeNode().getElementById(a).shape},arrangeShape:function(a,b){return this.removeShape(a).addShape(a,b)},getShapeNode:function(){return this.shapeNode||this.node}}),g=_p.r(60);return _p.r(11).extendClass(g,{bringTo:function(a){return this.container.arrangeShape(this,a),this},bringFront:function(){return this.bringTo(this.container.indexOf(this)+1)},bringBack:function(){return this.bringTo(this.container.indexOf(this)-1)},bringTop:function(){return this.container.removeShape(this).addShape(this),this},bringRear:function(){return this.bringTo(0)},bringRefer:function(a,b){return a.container&&(this.remove&&this.remove(),a.container.addShape(this,a.container.indexOf(a)+(b||0))),this},bringAbove:function(a){return this.bringRefer(a)},bringBelow:function(a){return this.bringRefer(a,1)},replaceBy:function(a){return this.container&&(a.bringAbove(this),this.remove()),this}}),f}},_p[62]={value:function(a,b,c){var d=_p.r(43),e=_p.r(12),f=_p.r(50);return _p.r(11).createClass("ShapeEvent",{constructor:function(a){var b=null;e.isObject(a.target)?e.extend(this,a):(this.type=a.type,b=a.target,b.correspondingUseElement&&(b=b.correspondingUseElement),this.originEvent=a,this.targetShape=b.shape||b.paper||a.currentTarget&&(a.currentTarget.shape||a.currentTarget.paper),a._kityParam&&e.extend(this,a._kityParam))},preventDefault:function(){var a=this.originEvent;return a?a.preventDefault?(a.preventDefault(),a.cancelable):(a.returnValue=!1,!0):!0},getPosition:function(a,b){if(!this.originEvent)return null;var c=this.originEvent.touches?this.originEvent.touches[b||0]:this.originEvent,e=this.targetShape,g=e.shapeNode||e.node,h=new f(c&&c.clientX||0,c&&c.clientY||0),i=d.transformPoint(h,g.getScreenCTM().inverse()),j=d.getCTM(e,a||"view").transformPoint(i);return j},stopPropagation:function(){var a=this.originEvent;return a?void(a.stopPropagation?a.stopPropagation():a.cancelBubble=!1):!0}})}},_p[63]={value:function(a,b,c){return _p.r(11).createClass("ShapePoint",{base:_p.r(50),constructor:function(a,b){this.callBase(a,b)},setX:function(a){return this.setPoint(a,this.y)},setY:function(a){return this.setPoint(this.x,a)},setPoint:function(a,b){return this.x=a,this.y=b,this.update(),this},getPoint:function(){return this},update:function(){return this.container&&this.container.update&&this.container.update(),this}})}},_p[64]={value:{COLOR_STANDARD:{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080", oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00"},EXTEND_STANDARD:{}}},_p[65]={value:function(a,b,c){var d={3:.2,5:.38196601125,6:.57735026919,8:.541196100146,10:.726542528005,12:.707106781187},e=_p.r(50);return _p.r(11).createClass("Star",{base:_p.r(46),constructor:function(a,b,c,d,f){this.callBase(),this.vertex=a||3,this.radius=b||0,this.shrink=c,this.offset=d||new e(0,0),this.angleOffset=f||0,this.draw()},getVertex:function(){return this.vertex},setVertex:function(a){return this.vertex=a,this.draw()},getRadius:function(){return this.radius},setRadius:function(a){return this.radius=a,this.draw()},getShrink:function(){return this.shrink},setShrink:function(a){return this.shrink=a,this.draw()},getOffset:function(){return this.offset},setOffset:function(a){return this.offset=a,this.draw()},getAngleOffset:function(){return this.angleOffset},setAngleOffset:function(a){return this.angleOffset=a,this.draw()},draw:function(){var a,b,c=this.radius,f=this.radius*(this.shrink||d[this.vertex]||.5),g=this.vertex,h=this.offset,i=90,j=180/g,k=this.angleOffset,l=this.getDrawer();for(l.clear(),l.moveTo(e.fromPolar(f,i)),a=1;2*g>=a;a++)b=i+j*a,l.lineTo(a%2?e.fromPolar(c,b+k).offset(h):e.fromPolar(f,b));l.close()}})}},_p[66]={value:function(a,b,c){function d(a){return a.classList||(a.classList=new e(a)),a.classList}var e=_p.r(11).createClass("ClassList",{constructor:function(a){this._node=a,this._list=a.className.toString().split(" ")},_update:function(){this._node.className=this._list.join(" ")},add:function(a){this._list.push(a),this._update()},remove:function(a){var b=this._list.indexOf(a);~b&&this._list.splice(b,1),this._update()},contains:function(a){return!!~this._list.indexOf(a)}});return _p.r(11).createClass("Styled",{addClass:function(a){return d(this.node).add(a),this},removeClass:function(a){return d(this.node).remove(a),this},hasClass:function(a){return d(this.node).contains(a)},setStyle:function(a){if(2==arguments.length)return this.node.style[arguments[0]]=arguments[1],this;for(var b in a)a.hasOwnProperty(b)&&(this.node.style[b]=a[b]);return this}})}},_p[67]={value:function(a,b,c){var d=document,e=0,f={createNode:function(a){var b=d.createElementNS(f.ns,a);return b.id="kity_"+a+"_"+e++,b},defaults:{stroke:"none",fill:"none"},xlink:"http://www.w3.org/1999/xlink",ns:"http://www.w3.org/2000/svg"};return f}},_p[68]={value:function(a,b,c){var d=_p.r(50);return _p.r(11).createClass("Sweep",{base:_p.r(46),constructor:function(a,b,c){this.callBase(),this.sectionArray=a||[],this.angle=b||0,this.angleOffset=c||0,this.draw()},getSectionArray:function(){return this.sectionArray},setSectionArray:function(a){return this.sectionArray=a,this.draw()},getAngle:function(){return this.angle},setAngle:function(a){return this.angle=a,this.draw()},getAngleOffset:function(){return this.angleOffset},setAngleOffset:function(a){return this.angleOffset=a,this.draw()},draw:function(){var a,b=this.sectionArray;for(a=0;ac?0:1,i=this.getDrawer();return i.redraw(),0===c?void i.done():(i.moveTo(d.fromPolar(a,e)),i.lineTo(d.fromPolar(b,e)),b&&(i.carcTo(b,0,h,d.fromPolar(b,f)),i.carcTo(b,0,h,d.fromPolar(b,g))),i.lineTo(d.fromPolar(a,g)),a&&(i.carcTo(a,0,h,d.fromPolar(a,f)),i.carcTo(a,0,h,d.fromPolar(a,e))),i.close(),void i.done())}})}},_p[69]={value:function(a,b,c){function d(a){var b=a._cachedFontHash;if(i[b])return i[b];var c=a.getContent();a.setContent("百度Fex");var d=a.getBoundaryBox(),e=a.getY(),f=e-d.y+ +a.node.getAttribute("dy"),g=f-d.height;return a.setContent(c),i[b]={top:f,bottom:g,middle:(f+g)/2}}var e=_p.r(70),f=_p.r(61),g=_p.r(67),h=_p.r(12),i={};return _p.r(11).createClass("Text",{base:e,mixins:[f],constructor:function(a){this.callBase("text"),void 0!==a&&this.setContent(a),this._buildFontHash()},_buildFontHash:function(){var a=window.getComputedStyle(this.node);this._cachedFontHash=[a.fontFamily,a.fontSize,a.fontStretch,a.fontStyle,a.fontVariant,a.fontWeight].join("-")},_fontChanged:function(a){var b=this._lastFont,c=h.extend({},b,a);if(!b)return this._lastFont=a,!0;var d=b.family!=c.family||b.size!=c.size||b.style!=c.style||b.weight!=c.weight;return this._lastFont=c,d},setX:function(a){return this.node.setAttribute("x",a),this},setPosition:function(a,b){return this.setX(a).setY(b)},setY:function(a){return this.node.setAttribute("y",a),this},getX:function(){return+this.node.getAttribute("x")||0},getY:function(){return+this.node.getAttribute("y")||0},setFont:function(a){return this.callBase(a),this._fontChanged(a)&&(this._buildFontHash(),this.setVerticalAlign(this.getVerticalAlign())),this},setTextAnchor:function(a){return this.node.setAttribute("text-anchor",a),this},getTextAnchor:function(){return this.node.getAttribute("text-anchor")||"start"},setVerticalAlign:function(a){return this.whenPaperReady(function(){var b;switch(a){case"top":b=d(this).top;break;case"bottom":b=d(this).bottom;break;case"middle":b=d(this).middle;break;default:b=0}this.node.setAttribute("dy",b)}),this.verticalAlign=a,this},getVerticalAlign:function(){return this.verticalAlign||"baseline"},setStartOffset:function(a){this.shapeNode!=this.node&&this.shapeNode.setAttribute("startOffset",100*a+"%")},addSpan:function(a){return this.addShape(a),this},setPath:function(a){var b=this.shapeNode;if(this.shapeNode==this.node){for(b=this.shapeNode=g.createNode("textPath");this.node.firstChild;)this.shapeNode.appendChild(this.node.firstChild);this.node.appendChild(b)}return b.setAttributeNS(g.xlink,"xlink:href","#"+a.node.id),this.setTextAnchor(this.getTextAnchor()),this}})}},_p[70]={value:function(a,b,c){var d=_p.r(60);return _p.r(11).createClass("TextContent",{base:d,constructor:function(a){this.callBase(a),this.shapeNode=this.shapeNode||this.node,this.shapeNode.setAttribute("text-rendering","geometricPrecision")},clearContent:function(){for(;this.shapeNode.firstChild;)this.shapeNode.removeChild(this.shapeNode.firstChild);return this},setContent:function(a){return this.shapeNode.textContent=a,this},getContent:function(){return this.shapeNode.textContent},appendContent:function(a){return this.shapeNode.textContent+=a,this},setSize:function(a){return this.setFontSize(a)},setFontSize:function(a){return this.setFont({size:a})},setFontFamily:function(a){return this.setFont({family:a})},setFontBold:function(a){return this.setFont({weight:a?"bold":"normal"})},setFontItalic:function(a){return this.setFont({style:a?"italic":"normal"})},setFont:function(a){var b=this.node;return["family","size","weight","style"].forEach(function(c){null===a[c]?b.removeAttribute("font-"+c):a[c]&&b.setAttribute("font-"+c,a[c])}),this},getExtentOfChar:function(a){return this.node.getExtentOfChar(a)},getRotationOfChar:function(a){return this.node.getRotationOfChar(a)},getCharNumAtPosition:function(a,b){return this.node.getCharNumAtPosition(this.node.viewportElement.createSVGPoint(a,b))}})}},_p[71]={value:function(a,b,c){var d=_p.r(70),e=_p.r(66);return _p.r(11).createClass("TextSpan",{base:d,mixins:[e],constructor:function(a){this.callBase("tspan"),this.setContent(a)}})}},_p[72]={value:function(a,b,c){var d=_p.r(67),e=_p.r(11),f=e.createClass("Use",{base:_p.r(60),constructor:function(a){this.callBase("use"),this.ref(a)},ref:function(a){if(!a)return this.node.removeAttributeNS(d.xlink,"xlink:href"),this;var b=a.getId();return b&&this.node.setAttributeNS(d.xlink,"xlink:href","#"+b),"none"===a.node.getAttribute("fill")&&a.node.removeAttribute("fill"),"none"===a.node.getAttribute("stroke")&&a.node.removeAttribute("stroke"),this}}),g=_p.r(60);return e.extendClass(g,{use:function(){return new f(this)}}),f}},_p[73]={value:function(a,b,c){var d=_p.r(50),e=_p.r(43),f=_p.r(11).createClass("Vector",{base:d,constructor:function(a,b){this.callBase(a,b)},square:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.square())},add:function(a){return new f(this.x+a.x,this.y+a.y)},minus:function(a){return new f(this.x-a.x,this.y-a.y)},dot:function(a){return this.x*a.x+this.y*a.y},project:function(a){return a.multipy(this.dot(a)/a.square())},normalize:function(a){return void 0===a&&(a=1),this.multipy(a/this.length())},multipy:function(a){return new f(this.x*a,this.y*a)},rotate:function(a,b){"rad"==b&&(a=a/Math.PI*180);var c=(new e).rotate(a).transformPoint(this);return new f(c.x,c.y)},vertical:function(){return new f(this.y,-this.x)},reverse:function(){return this.multipy(-1)},getAngle:function(){var a=this.length();if(0===a)return 0;var b=Math.acos(this.x/a),c=this.y>0?1:-1;return 180*c*b/Math.PI}});return f.fromPoints=function(a,b){return new f(b.x-a.x,b.y-a.y)},f.fromPolar=function(){var a=d.fromPolar.apply(d,arguments);return new f(a.x,a.y)},_p.r(11).extendClass(d,{asVector:function(){return new f(this.x,this.y)}}),f}},_p[74]={value:function(a,b,c){var d=_p.r(61),e=_p.r(75);return _p.r(11).createClass("View",{mixins:[d,e],base:_p.r(74),constructor:function(){this.callBase("view")}})}},_p[75]={value:function(a,b,c){return _p.r(11).createClass("ViewBox",{getViewBox:function(){var a=this.node.getAttribute("viewBox");return null===a?{x:0,y:0,width:this.node.clientWidth||this.node.parentNode.clientWidth,height:this.node.clientHeight||this.node.parentNode.clientHeight}:(a=a.split(" "),{x:+a[0],y:+a[1],width:+a[2],height:+a[3]})},setViewBox:function(a,b,c,d){return this.node.setAttribute("viewBox",[a,b,c,d].join(" ")),this}})}},_p[76]={value:function(a,b,c){var d={},e=_p.r(12);return d.version="2.0.0",e.extend(d,{createClass:_p.r(11).createClass,extendClass:_p.r(11).extendClass,Utils:e,Browser:_p.r(10),Box:_p.r(25),Bezier:_p.r(23),BezierPoint:_p.r(24),Circle:_p.r(26),Clip:_p.r(27),Color:_p.r(28),Container:_p.r(29),Curve:_p.r(30),Ellipse:_p.r(32),Group:_p.r(36),Gradient:_p.r(35),HyperLink:_p.r(37),Image:_p.r(38),Line:_p.r(39),LinearGradient:_p.r(40),Mask:_p.r(42),Matrix:_p.r(43),Marker:_p.r(41),Palette:_p.r(44),Paper:_p.r(45),Path:_p.r(46),Pattern:_p.r(47),Pen:_p.r(48),Point:_p.r(50),PointContainer:_p.r(51),Polygon:_p.r(53),Polyline:_p.r(54),Pie:_p.r(49),RadialGradient:_p.r(55),Resource:_p.r(58),Rect:_p.r(56),RegularPolygon:_p.r(57),Ring:_p.r(59),Shape:_p.r(60),ShapePoint:_p.r(63),ShapeContainer:_p.r(61),Sweep:_p.r(68),Star:_p.r(65),Text:_p.r(69),TextSpan:_p.r(71),Use:_p.r(72),Vector:_p.r(73),g:_p.r(34),Animator:_p.r(0),Easing:_p.r(1),OpacityAnimator:_p.r(4),RotateAnimator:_p.r(6),ScaleAnimator:_p.r(7),Timeline:_p.r(8),TranslateAnimator:_p.r(9),PathAnimator:_p.r(5),MotionAnimator:_p.r(3),requestFrame:_p.r(2).requestFrame,releaseFrame:_p.r(2).releaseFrame,Filter:_p.r(20),GaussianblurFilter:_p.r(21),ProjectionFilter:_p.r(22),ColorMatrixEffect:_p.r(13),CompositeEffect:_p.r(14),ConvolveMatrixEffect:_p.r(15),Effect:_p.r(16),GaussianblurEffect:_p.r(17),OffsetEffect:_p.r(18)}),window.kity=d}};var moduleMapping={kity:76};use("kity")}();var KityMinder=window.KM=window.KityMinder=function(){var a={},b=0,c={};return{version:"1.3.5",uuid:function(a){return a=a||"unknown",c[a]=c[a]||0,++c[a],a+"_"+c[a]},createMinder:function(a,b){b=b||{},b.renderTo=Utils.isString(a)?document.getElementById(a):a;var c=new Minder(b);return this.addMinder(b.renderTo,c),c},addMinder:function(c,d){var e;e="string"==typeof c?c:c.id||"KM_INSTANCE_"+b++,a[e]=d},getMinder:function(c,d){var e;return e="string"==typeof c?c:c.id||"KM_INSTANCE_"+b++,a[e]||this.createMinder(c,d)},LANG:{}}}(),utils=Utils=KityMinder.Utils={extend:kity.Utils.extend.bind(kity.Utils),listen:function(a,b,c){var d=utils.isArray(b)?b:utils.trim(b).split(/\s+/),e=d.length;if(e)for(;e--;)if(b=d[e],a.addEventListener)a.addEventListener(b,c,!1);else{c._d||(c._d={els:[]});var f=b+c.toString(),g=utils.indexOf(c._d.els,a);c._d[f]&&-1!=g||(-1==g&&c._d.els.push(a),c._d[f]||(c._d[f]=function(a){return c.call(a.srcElement,a||window.event)}),a.attachEvent("on"+b,c._d[f]))}a=null},trim:function(a){return a.replace(/(^[ \t\n\r]+)|([ \t\n\r]+$)/g,"")},each:function(a,b,c){if(null!=a)if(a.length===+a.length){for(var d=0,e=a.length;e>d;d++)if(b.call(c,d,a[d],a)===!1)return!1}else for(var f in a)if(a.hasOwnProperty(f)&&b.call(c,f,a[f],a)===!1)return!1},addCssRule:function(a,b,c){var d;return void 0===b||b&&b.nodeType&&9==b.nodeType?(c=b&&b.nodeType&&9==b.nodeType?b:c||document,d=c.getElementById(a),d?d.innerHTML:void 0):(c=c||document,d=c.getElementById(a),""===b?d?(d.parentNode.removeChild(d),!0):!1:void(d?d.innerHTML=b:(d=c.createElement("style"),d.id=a,d.innerHTML=b,c.getElementsByTagName("head")[0].appendChild(d))))},keys:function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b},proxy:function(a,b){return function(){return a.apply(b,arguments)}},indexOf:function(a,b,c){var d=-1;return c=this.isNumber(c)?c:0,this.each(a,function(a,e){return e>=c&&a===b?(d=e,!1):void 0}),d},argsToArray:function(a,b){return Array.prototype.slice.call(a,b||0)},clonePlainObject:function(a,b){var c;b=b||{};for(var d in a)a.hasOwnProperty(d)&&(c=a[d],utils.isObject(c)||utils.isArray(c)?(b[d]=utils.isArray(c)?[]:{},utils.clonePlainObject(a[d],b[d])):b[d]=c);return b},compareObject:function(a,b){var c;if(this.isEmptyObject(a)!==this.isEmptyObject(b))return!1;if(this.getObjectLength(a)!=this.getObjectLength(b))return!1;for(var d in a)if(a.hasOwnProperty(d)){if(c=a[d],void 0===b[d])return!1;if(this.isObject(c)||this.isArray(c)){if(this.isObject(b[d])!==this.isObject(c))return!1;if(this.isArray(c)!==this.isArray(b[d]))return!1;if(this.compareObject(c,b[d])===!1)return!1}else if(c!=b[d])return!1}return!0},getObjectLength:function(a){if(this.isArray(a)||this.isString(a))return a.length;var b=0;for(var c in a)a.hasOwnProperty(c)&&b++;return b},isEmptyObject:function(a){if(null==a)return!0;if(this.isArray(a)||this.isString(a))return 0===a.length;for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},loadFile:function(){function a(a,c){try{for(var d,e=0;d=b[e++];)if(d.doc===a&&d.url==(c.src||c.href))return d}catch(f){return null}}var b=[];return function(c,d,e){var f=a(c,d);if(f)return void(f.ready?e&&e():f.funs.push(e));if(b.push({doc:c,url:d.src||d.href,funs:[e]}),!c.body){var g=[];for(var h in d)"tag"!=h&&g.push(h+'="'+d[h]+'"');return void c.write("<"+d.tag+" "+g.join(" ")+" >")}if(!d.id||!c.getElementById(d.id)){var i=c.createElement(d.tag);delete d.tag;for(var h in d)i.setAttribute(h,d[h]);i.onload=i.onreadystatechange=function(){if(!this.readyState||/loaded|complete/.test(this.readyState)){if(f=a(c,d),f.funs.length>0){f.ready=1;for(var b;b=f.funs.pop();)b()}i.onload=i.onreadystatechange=null}},c.getElementsByTagName("head")[0].appendChild(i)}}}(),clone:function(a,b){var c;b=b||{};for(var d in a)a.hasOwnProperty(d)&&(c=a[d],"object"==typeof c?(b[d]=utils.isArray(c)?[]:{},utils.clone(a[d],b[d])):b[d]=c);return b},unhtml:function(a,b){return a?a.replace(b||/[&<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g,function(a,b){return b?a:{"<":"<","&":"&",'"':""",">":">","'":"'"}[a]}):""},cloneArr:function(a){return[].concat(a)},clearWhitespace:function(a){return a.replace(/[\u200b\t\r\n]/g,"")},getValueByIndex:function(a,b){var c=0,d=0;return utils.each(a,function(a,e){if(c+e.length>=b){if(b-c==e.length){if(1==e.length&&0===e[0].width)return void c++;d={x:e[e.length-1].x+e[e.length-1].width,y:e[e.length-1].y}}else d=e[b-c];return!1}c+=e.length+(1==e.length&&0===e[0].width?0:1)}),d},getNodeIndex:function(a,b){for(var c=a,d=0;c=c.previousSibling;)b&&3==c.nodeType?c.nodeType!=c.nextSibling.nodeType&&d++:d++;return d}};Utils.each(["String","Function","Array","Number","RegExp","Object"],function(a,b){KityMinder.Utils["is"+b]=function(a){return Object.prototype.toString.apply(a)=="[object "+b+"]"}});var browser=KityMinder.browser=function(){var a=navigator.userAgent.toLowerCase(),b=window.opera,c={ie:/(msie\s|trident.*rv:)([\w.]+)/.test(a),opera:!!b&&b.version,webkit:a.indexOf(" applewebkit/")>-1,mac:a.indexOf("macintosh")>-1,quirks:"BackCompat"==document.compatMode,ipad:a.indexOf("ipad")>-1};c.gecko="Gecko"==navigator.product&&!c.webkit&&!c.opera&&!c.ie;var d=0;if(c.ie){var e=a.match(/(?:msie\s([\w.]+))/),f=a.match(/(?:trident.*rv:([\w.]+))/);d=e&&f&&e[1]&&f[1]?Math.max(1*e[1],1*f[1]):e&&e[1]?1*e[1]:f&&f[1]?1*f[1]:0,c.ie11Compat=11==document.documentMode,c.ie9Compat=9==document.documentMode,c.ie8=!!document.documentMode,c.ie8Compat=8==document.documentMode,c.ie7Compat=7==d&&!document.documentMode||7==document.documentMode,c.ie6Compat=7>d||c.quirks,c.ie9above=d>8,c.ie9below=9>d}if(c.gecko){var g=a.match(/rv:([\d\.]+)/);g&&(g=g[1].split("."),d=1e4*g[0]+100*(g[1]||0)+1*(g[2]||0))}return/chrome\/(\d+\.\d)/i.test(a)&&(c.chrome=+RegExp.$1),/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(a)&&!/chrome/i.test(a)&&(c.safari=+(RegExp.$1||RegExp.$2)),c.opera&&(d=parseFloat(b.version())),c.webkit&&(d=parseFloat(a.match(/ applewebkit\/(\d+)/)[1])),c.version=d,c.isCompatible=!c.mobile&&(c.ie&&d>=6||c.gecko&&d>=10801||c.opera&&d>=9.5||c.air&&d>=1||c.webkit&&d>=522||!1),c}(),ie=browser.ie,webkit=browser.webkit,gecko=browser.gecko,opera=browser.opera,Minder=KityMinder.Minder=kity.createClass("KityMinder",{constructor:function(a){this._options=Utils.extend(window.KITYMINDER_CONFIG||{},a);for(var b=Minder._initFnQueue.slice();b.length;)b.shift().call(this,a);this.fire("ready")}});Minder._initFnQueue=[],Minder.registerInit=function(a){Minder._initFnQueue.push(a)};var Command=kity.createClass("Command",{constructor:function(){this._isContentChange=!0,this._isSelectionChange=!1},execute:function(a,b){},setContentChanged:function(a){this._isContentChange=!!a},isContentChanged:function(){return this._isContentChange},setSelectionChanged:function(a){this._isSelectionChange=!!a},isSelectionChanged:function(){return this._isContentChange},queryState:function(a){return 0},queryValue:function(a){return 0},isNeedUndo:function(){return!0}});kity.extendClass(Minder,{_getCommand:function(a){return this._commands[a.toLowerCase()]},_queryCommand:function(a,b,c){var d=this._getCommand(a);if(d){var e=d["query"+b];if(e)return e.apply(d,[this].concat(c))}return 0},queryCommandState:function(a){return this._queryCommand(a,"State",Utils.argsToArray(1))},queryCommandValue:function(a){return this._queryCommand(a,"Value",Utils.argsToArray(1))},execCommand:function(a){a=a.toLowerCase();var b,c,d,e,f=Utils.argsToArray(arguments,1),g=this;return b=this._getCommand(a),e={command:b,commandName:a.toLowerCase(),commandArgs:f},b&&~this.queryCommandState(a)?(!this._hasEnterExecCommand&&b.isNeedUndo()?(this._hasEnterExecCommand=!0,c=this._fire(new MinderEvent("beforeExecCommand",e,!0)),c||(this._fire(new MinderEvent("saveScene")),this._fire(new MinderEvent("preExecCommand",e,!1)),d=b.execute.apply(b,[g].concat(f)),this._fire(new MinderEvent("execCommand",e,!1)),this._fire(new MinderEvent("saveScene")),b.isContentChanged()&&this._firePharse(new MinderEvent("contentchange")),this._interactChange()),this._hasEnterExecCommand=!1):(d=b.execute.apply(b,[g].concat(f)),this._hasEnterExecCommand||this._interactChange()),void 0===d?null:d):!1}});var MinderNode=KityMinder.MinderNode=kity.createClass("MinderNode",{constructor:function(a){this.parent=null,this.root=this,this.children=[],this.data={},this.tmpData={},this.initContainers(),Utils.isString(a)?this.setText(a):this.setData(a)},initContainers:function(){this.rc=(new kity.Group).setId(KityMinder.uuid("minder_node")),this.rc.minderNode=this},isRoot:function(){return this.root===this},isLeaf:function(){return 0===this.children.length},getRoot:function(){return this.root||this},getParent:function(){return this.parent},getLevel:function(){for(var a=0,b=this.parent;b;)a++,b=b.parent;return a},getComplex:function(){var a=0;return this.traverse(function(){a++}),a},getType:function(a){return this.type=["root","main","sub"][Math.min(this.getLevel(),2)],this.type},isAncestorOf:function(a){for(var b=a.parent;b;){if(b==this)return!0;b=b.parent}return!1},setText:function(a){return utils.isArray(a)&&(a=a.join("\n")),this.setData("text",a)},getText:function(a){var b=this.getData("text")||"";return a&&(b=b.split("\n")),b},preTraverse:function(a,b){var c=this.getChildren();b||a(this);for(var d=0;d=0&&(b=this.children.splice(c,1)[0],b.parent=null,b.root=b)},getChild:function(a){return this.children[a]},getFirstChild:function(){return this.children[0]},getLastChild:function(){return this.children[this.children.length-1]},getData:function(a){return void 0===a?this.data:this.data[a]},setData:function(a,b){return void 0===a?this.data={}:utils.isObject(a)?Utils.extend(this.data,a):void 0===b?(this.data[a]=null,delete this.data[a]):this.data[a]=b,this},getRenderContainer:function(){return this.rc},getCommonAncestor:function(a){return Utils.getNodeCommonAncestor(this,a)},contains:function(a){return this==a||this.isAncestorOf(a)},clone:function(){function a(b,c){var d=new KM.MinderNode;d.data=Utils.clonePlainObject(c.getData()),d.tmpData=Utils.clonePlainObject(c.getTmpData()),b&&b.appendChild(d);for(var e,f=0;e=c.children[f++];)a(d,e);return d}return a(null,this)},equals:function(a,b){function c(){e&&d.setSelectedFlag(),f&&a.setSelectedFlag()}var d=this;if(b){var e=!1,f=!1;d.isSelected()&&(e=!0,d.clearSelectedFlag()),a.isSelected()&&(f=!0,a.clearSelectedFlag())}if(a.children.length!=this.children.length)return c(),!1;if(utils.compareObject(a.getData(),d.getData())===!1)return c(),!1;if(utils.compareObject(a.getTmpData(),d.getTmpData())===!1)return c(),!1;for(var g,h=0;g=d.children[h];h++)if(g.equals(a.children[h],b)===!1)return c(),!1;return c(),!0},clearChildren:function(){this.children=[]},setTmpData:function(a,b){var c=this;utils.isObject(a)&&utils.each(a,function(a,b){c.setTmpData(a,b)}),void 0===b||null===b||""===b?delete this.tmpData[a]:this.tmpData[a]=b},getTmpData:function(a){return void 0===a?this.tmpData:this.tmpData[a]},setValue:function(a){return this.data={},this.setData(utils.clonePlainObject(a.getData())),this.tmpData={},this.setTmpData(utils.clonePlainObject(a.getTmpData())),this}});MinderNode.getCommonAncestor=function(a,b){if(a instanceof Array)return MinderNode.getCommonAncestor.apply(this,a);switch(arguments.length){case 1:return a.parent||a;case 2:if(a.isAncestorOf(b))return a;if(b.isAncestorOf(a))return b;for(var c=a.parent;c&&!c.isAncestorOf(b);)c=c.parent;return c;default:return Array.prototype.reduce.call(arguments,function(a,b){return MinderNode.getCommonAncestor(a,b)},a)}},kity.extendClass(Minder,{getRoot:function(){return this._root},setRoot:function(a){this._root=a,a.minder=this},createNode:function(a,b,c){var d=new MinderNode(a);return this.fire("nodecreate",{node:d,parent:b,index:c}),this.appendNode(d,b,c),d},appendNode:function(a,b,c){return b&&b.insertChild(a,c),this.attachNode(a),this},removeNode:function(a){a.parent&&(a.parent.removeChild(a),this.detachNode(a),this.fire("noderemove",{node:a}))},attachNode:function(a){var b=this._rc;a.traverse(function(a){a.attached=!0,b.addShape(a.getRenderContainer())}),b.addShape(a.getRenderContainer()),this.fire("nodeattach",{node:a})},detachNode:function(a){var b=this._rc;a.traverse(function(a){a.attached=!1,b.removeShape(a.getRenderContainer())}),this.fire("nodedetach",{node:a})},getMinderTitle:function(){return this.getRoot().getText()}}),kity.extendClass(MinderNode,{getMinder:function(){return this.getRoot().minder}}),kity.extendClass(Minder,{getOptions:function(a){var b;return a?(b=this.getPreferences(a),b&&b[a]||this._options[a]):(b=this.getPreferences(),utils.extend(b,this._options,!0))},setDefaultOptions:function(a,b,c){var d={};Utils.isString(a)?d[a]=b:d=a,utils.extend(this._options,d,!c)},setOptions:function(a,b){this.setPreferences(a,b)}}),Minder.registerInit(function(a){this.setDefaultOptions(KM.defaultOptions)});var MinderEvent=kity.createClass("MindEvent",{constructor:function(a,b,c){b=b||{},b.getType&&"ShapeEvent"==b.getType()?(this.kityEvent=b,this.originEvent=b.originEvent,this.getPosition=b.getPosition.bind(b)):b.target&&b.preventDefault?this.originEvent=b:kity.Utils.extend(this,b),this.type=a,this._canstop=c||!1},getTargetNode:function(){var a=this.kityEvent&&this.kityEvent.targetShape;if(!a)return null;for(;!a.minderNode&&a.container;)a=a.container;var b=a.minderNode;return b&&a.getOpacity()<1?null:b||null},stopPropagation:function(){this._stoped=!0},stopPropagationImmediately:function(){this._immediatelyStoped=!0,this._stoped=!0},shouldStopPropagation:function(){return this._canstop&&this._stoped},shouldStopPropagationImmediately:function(){return this._canstop&&this._immediatelyStoped},preventDefault:function(){this.originEvent.preventDefault()},isRightMB:function(){var a=!1;return this.originEvent?("which"in this.originEvent?a=3==this.originEvent.which:"button"in this.originEvent&&(a=2==this.originEvent.button),a):!1},getKeyCode:function(){var a=this.originEvent;return a.keyCode||a.which}});Minder.registerInit(function(){this._initEvents()}),kity.extendClass(Minder,{_initEvents:function(){this._eventCallbacks={}},_bindEvents:function(){this._bindPaperEvents(),this._bindKeyboardEvents()},_resetEvents:function(){this._initEvents(),this._bindEvents()},_bindPaperEvents:function(){this._paper.on("click dblclick mousedown contextmenu mouseup mousemove mouseover mousewheel DOMMouseScroll touchstart touchmove touchend dragenter dragleave drop",this._firePharse.bind(this)),window&&(window.addEventListener("resize",this._firePharse.bind(this)),window.addEventListener("blur",this._firePharse.bind(this)))},_bindKeyboardEvents:function(){-1==navigator.userAgent.indexOf("iPhone")&&-1==navigator.userAgent.indexOf("iPod")&&-1==navigator.userAgent.indexOf("iPad")&&Utils.listen(document.body,"keydown keyup keypress paste",this._firePharse.bind(this))},_firePharse:function(a){var b,c,d;"DOMMouseScroll"==a.type&&(a.type="mousewheel",a.wheelDelta=a.originEvent.wheelDelta=-10*a.originEvent.detail,a.wheelDeltaX=a.originEvent.mozMovementX,a.wheelDeltaY=a.originEvent.mozMovementY),b=new MinderEvent("before"+a.type,a,!0),this._fire(b)||(c=new MinderEvent("pre"+a.type,a,!0),d=new MinderEvent(a.type,a,!0),(this._fire(c)||this._fire(d))&&this._fire(new MinderEvent("after"+a.type,a,!1)))},_interactChange:function(a){var b=this;b._interactScheduled||(setTimeout(function(){b._fire(new MinderEvent("interactchange")),b._interactScheduled=!1},100),b._interactScheduled=!0)},_listen:function(a,b){var c=this._eventCallbacks[a]||(this._eventCallbacks[a]=[]);c.push(b)},_fire:function(a){var b=this.getStatus(),c=this._eventCallbacks[a.type.toLowerCase()]||[];if(b&&(c=c.concat(this._eventCallbacks[b+"."+a.type.toLowerCase()]||[])),0!==c.length){for(var d=(this.getStatus(),0);d",this._status),b&&console.trace())),this):this}}(),rollbackStatus:function(){this.setStatus(this._rollbackStatus)},getRollbackStatus:function(){return this._rollbackStatus},getStatus:function(){return this._status}}),Minder.registerInit(function(){this._initPaper()}),kity.extendClass(Minder,{_initPaper:function(){this._paper=new kity.Paper,this._paper.getNode().setAttribute("contenteditable",!0),this._paper.getNode().ondragstart=function(a){a.preventDefault()},this._paper.shapeNode.setAttribute("transform","translate(0.5, 0.5)"),this._addRenderContainer(),this.setRoot(this.createNode(this.getLang().maintopic)),this._options.renderTo&&this.renderTo(this._options.renderTo)},_addRenderContainer:function(){this._rc=(new kity.Group).setId(KityMinder.uuid("minder")),this._paper.addShape(this._rc)},renderTo:function(a){this._paper.renderTo(this._renderTarget=a),this._bindEvents()},getRenderContainer:function(){return this._rc},getPaper:function(){return this._paper},getRenderTarget:function(){return this._renderTarget}}),Minder.registerInit(function(){this._initSelection()}),kity.extendClass(Minder,{_initSelection:function(){this._selectedNodes=[]},renderChangedSelection:function(a){var b=this.getSelectedNodes(),c=[],d=0;for(b.forEach(function(b){-1==a.indexOf(b)&&(c.push(b),b.setTmpData("selected",!0))}),a.forEach(function(a){-1==b.indexOf(a)&&(c.push(a),a.setTmpData("selected",!1))}),c.length&&(this._interactChange(),this.fire("selectionchange"));d=0;--c)if(a[c].isAncestorOf(b))return!0;return!1}var c,d=this.getSelectedNodes().slice(0),e=[],f=d.indexOf(this.getRoot());for(~f&&!a&&d.splice(f,1),d.sort(function(a,b){return a.getLevel()-b.getLevel()});c=d.pop();)b(d,c)||e.push(c);return e}}),kity.extendClass(MinderNode,{isSelected:function(){return this.getTmpData("selected")},clearSelectedFlag:function(){ this.setTmpData("selected")},setSelectedFlag:function(){this.setTmpData("selected",!0)}}),kity.extendClass(MinderEvent,{isShortcutKey:function(a){var b=this.originEvent;return b?getMetaKeyCode(a)==getMetaKeyCode(b):!1}}),Minder.registerInit(function(){this._initShortcutKey()}),kity.extendClass(Minder,{_initShortcutKey:function(){this._bindShortcutKeys()},_bindShortcutKeys:function(){var a=this._shortcutKeys={},b="hasOwnProperty";this.on("keydown",function(c){for(var d in a)if(a[b](d)&&c.isShortcutKey(d)){var e=a[d];if(e.__statusCondition&&e.__statusCondition!=this.getStatus())return;e(),c.preventDefault()}})},addShortcut:function(a,b){var c=this._shortcutKeys;a.split(/\|\s*/).forEach(function(a){var d,e=a.split("::");e.length>1&&(a=e[1],d=e[0],b.__statusCondition=d),c[a]=b})},addCommandShortcutKeys:function(a,b){var c=this._commandShortcutKeys||(this._commandShortcutKeys={}),d={};b?d[a]=b:d=a;var e=this;utils.each(d,function(a,b){c[a]=b,e.addShortcut(b,function(){0===e.queryCommandState(a)&&e.execCommand(a)})})},getCommandShortcutKey:function(a){var b=this._commandShortcutKeys;return b&&b[a]||null}}),Minder.registerInit(function(){this._initContextMenu()}),kity.extendClass(Minder,{_initContextMenu:function(){this.contextmenus=[]},addContextMenu:function(a){return utils.isArray(a)?this.contextmenus=this.contextmenus.concat(a):this.contextmenus.push(a),this},getContextMenu:function(){return this.contextmenus}}),function(){var a;KityMinder.registerModule=function(b,c){a||(a={}),a[b]=c},KityMinder.getModules=function(){return a}}(),Minder.registerInit(function(){this._initModules()}),kity.extendClass(Minder,{_initModules:function(){var a=KityMinder.getModules(),b=this._options.modules||Utils.keys(a);this._commands={},this._query={},this._modules={},this._rendererClasses={};var c,d,e,f,g,h,i,j=this;for(c=0;c200&&(b=0),e(a,a.parent?a.parent.getGlobalLayoutTransform():new kity.Matrix),h}});var Layout=kity.createClass("Layout",{doLayout:function(a){throw new Error("Not Implement: Layout.doLayout()")},align:function(a,b,c){var d=this;c=c||0,a.forEach(function(a){var e=d.getTreeBox([a]),f=a.getLayoutTransform();switch(b){case"left":return f.translate(c-e.left,0);case"right":return f.translate(c-e.right,0);case"top":return f.translate(0,c-e.top);case"bottom":return f.translate(0,c-e.bottom)}})},stack:function(a,b,c){var d=this,e=0;return c=c||function(a,b,c){return a.getStyle({x:"margin-right",y:"margin-bottom"}[c])+b.getStyle({x:"margin-left",y:"margin-top"}[c])},a.forEach(function(a,f,g){var h=d.getTreeBox([a]),i={x:h.width,y:h.height}[b],j={x:h.left,y:h.top}[b],k=a.getLayoutTransform();"x"==b?k.translate(e-j,0):k.translate(0,e-j),e+=i,g[f+1]&&(e+=c(a,g[f+1],b))}),e},move:function(a,b,c){a.forEach(function(a){a.getLayoutTransform().translate(b,c)})},getBranchBox:function(a){var b,c,d,e,f=new kity.Box;for(b=0;bc;c++){for(d=0;d0?"down":"up");KityMinder.registerLayout(b,kity.createClass({base:Layout,doLayout:function(b,c,d){var e=b.getContentBox(),f=20;if(b.setVertexOut(new kity.Point(e.left+f,a>0?e.bottom:e.top)),b.setLayoutVectorOut(new kity.Vector(0,a)),c.length){c.forEach(function(a){var b=a.getContentBox();a.setLayoutTransform(new kity.Matrix),a.setVertexIn(new kity.Point(b.left,b.cy)),a.setLayoutVectorIn(new kity.Vector(1,0))}),this.align(c,"left"),this.stack(c,"y");var g=0;g+=e.left,g+=f,g+=c[0].getStyle("margin-left");var h=0;a>0?(h+=e.bottom,h+=b.getStyle("margin-bottom"),h+=c[0].getStyle("margin-top")):(h-=this.getTreeBox(c).bottom,h+=e.top,h-=b.getStyle("margin-top"),h-=c[0].getStyle("margin-bottom")),this.move(c,g,h)}},getOrderHint:function(a){var b=[],c=a.getLayoutBox(),d=a.getLevel()>1?3:5;return b.push({type:"up",node:a,area:{x:c.x,y:c.top-a.getStyle("margin-top")-d,width:c.width,height:a.getStyle("margin-top")},path:["M",c.x,c.top-d,"L",c.right,c.top-d]}),b.push({type:"down",node:a,area:{x:c.x,y:c.bottom+d,width:c.width,height:a.getStyle("margin-bottom")},path:["M",c.x,c.bottom+d,"L",c.right,c.bottom+d]}),b}}))});var layouts=["left","right","top","bottom"];layouts.forEach(function(a){function b(a){var b=[],d=a.getLayoutBox(),e=5;return"x"==c?(b.push({type:"up",node:a,area:{x:d.x,y:d.top-a.getStyle("margin-top")-e,width:d.width,height:a.getStyle("margin-top")},path:["M",d.x,d.top-e,"L",d.right,d.top-e]}),b.push({type:"down",node:a,area:{x:d.x,y:d.bottom+e,width:d.width,height:a.getStyle("margin-bottom")},path:["M",d.x,d.bottom+e,"L",d.right,d.bottom+e]})):(b.push({type:"up",node:a,area:{x:d.left-a.getStyle("margin-left")-e,y:d.top,width:a.getStyle("margin-left"),height:d.height},path:["M",d.left-e,d.top,"L",d.left-e,d.bottom]}),b.push({type:"down",node:a,area:{x:d.right+e,y:d.top,width:a.getStyle("margin-right"),height:d.height},path:["M",d.right+e,d.top,"L",d.right+e,d.bottom]})),b}var c="left"==a||"right"==a?"x":"y",d="left"==a||"top"==a?-1:1,e={left:"right",right:"left",top:"bottom",bottom:"top",x:"y",y:"x"};KityMinder.registerLayout(a,kity.createClass({base:Layout,doLayout:function(b,f){var g=b.getContentBox();if("x"==c?(b.setVertexOut(new kity.Point(g[a],g.cy)),b.setLayoutVectorOut(new kity.Vector(d,0))):(b.setVertexOut(new kity.Point(g.cx,g[a])),b.setLayoutVectorOut(new kity.Vector(0,d))),!f.length)return!1;f.forEach(function(b){var f=b.getContentBox();b.setLayoutTransform(new kity.Matrix),"x"==c?(b.setVertexIn(new kity.Point(f[e[a]],f.cy)),b.setLayoutVectorIn(new kity.Vector(d,0))):(b.setVertexIn(new kity.Point(f.cx,f[e[a]])),b.setLayoutVectorIn(new kity.Vector(0,d)))}),this.align(f,e[a]),this.stack(f,e[c]);var h,i,j=this.getBranchBox(f);"x"==c?(h=g[a],h+=d*b.getStyle("margin-"+a),h+=d*f[0].getStyle("margin-"+e[a]),i=g.bottom,i-=g.height/2,i-=j.height/2,i-=j.y):(h=g.right,h-=g.width/2,h-=j.width/2,h-=j.x,i=g[a],i+=d*b.getStyle("margin-"+a),i+=d*f[0].getStyle("margin-"+e[a])),this.move(f,h,i)},getOrderHint:b}))}),KityMinder.registerLayout("fish-bone-master",kity.createClass("FishBoneMasterLayout",{base:Layout,doLayout:function(a,b,c){var d=[],e=[],f=b[0],g=a.getContentBox();if(a.setVertexOut(new kity.Point(g.right,g.cy)),a.setLayoutVectorOut(new kity.Vector(1,0)),f){var h=(f.getContentBox(),a.getStyle("margin-right")),i=f.getStyle("margin-left"),j=f.getStyle("margin-top"),k=f.getStyle("margin-bottom");b.forEach(function(a,b){a.setLayoutTransform(new kity.Matrix);var c=a.getContentBox();b%2?(e.push(a),a.setVertexIn(new kity.Point(c.left,c.top)),a.setLayoutVectorIn(new kity.Vector(1,1))):(d.push(a),a.setVertexIn(new kity.Point(c.left,c.bottom)),a.setLayoutVectorIn(new kity.Vector(1,-1)))}),this.stack(d,"x"),this.stack(e,"x"),this.align(d,"bottom"),this.align(e,"top");var l=g.right+h+i,m=g.cy-k-a.getStyle("margin-top"),n=g.cy+j+a.getStyle("margin-bottom");this.move(d,l,m),this.move(e,l+i,n)}}})),KityMinder.registerLayout("fish-bone-slave",kity.createClass("FishBoneSlaveLayout",{base:Layout,doLayout:function(a,b,c){var d=this,e=Math.abs,f=.382,g=a.getContentBox(),h=a.getLayoutVectorIn();a.setLayoutVectorOut(h);var i=g.left+g.width*f,j=new kity.Point(i,h.y>0?g.bottom:g.top);a.setVertexOut(j);var k=b[0];if(k){var l=k.getContentBox();b.forEach(function(a,b){a.setLayoutTransform(new kity.Matrix),a.setLayoutVectorIn(new kity.Vector(1,0)),a.setVertexIn(new kity.Point(l.left,l.cy))}),this.stack(b,"y"),this.align(b,"left");var m=0,n=0;m+=j.x,a.getLayoutVectorOut().y<0?(n-=this.getTreeBox(b).bottom,n+=a.getContentBox().top,n-=a.getStyle("margin-top"),n-=k.getStyle("margin-bottom")):(n+=a.getContentBox().bottom,n+=a.getStyle("margin-bottom"),n+=k.getStyle("margin-top")),this.move(b,m,n),2==c&&b.forEach(function(a){var b=a.getLayoutTransform(),c=a.getContentBox(),f=b.transformPoint(new kity.Point(c.left,0));d.move([a],e(f.y-j.y),0)})}}})),KityMinder.registerLayout("tianpan",kity.createClass({base:Layout,doLayout:function(a,b){if(0!=b.length){var c,d,e,f=this,g=a.getContentBox(),h=5,i=Math.max(g.width,50);b.forEach(function(a,b){a.setLayoutTransform(new kity.Matrix),e=f.getTreeBox(a),i=Math.max(Math.max(e.width,e.height),i)}),i=i/1.5/Math.PI,b.forEach(function(a,b){c=i*(Math.cos(h)+Math.sin(h)*h),d=i*(Math.sin(h)-Math.cos(h)*h),h+=.9-.02*b,a.setLayoutVectorIn(new kity.Vector(1,0)),a.setVertexIn(new kity.Point(g.cx,g.cy)),a.setLayoutTransform(new kity.Matrix),f.move([a],c,d)})}},getOrderHint:function(a){var b=[],c=a.getLayoutBox(),d=5;return b.push({type:"up",node:a,area:{x:c.x,y:c.top-a.getStyle("margin-top")-d,width:c.width,height:a.getStyle("margin-top")},path:["M",c.x,c.top-d,"L",c.right,c.top-d]}),b.push({type:"down",node:a,area:{x:c.x,y:c.bottom+d,width:c.width,height:a.getStyle("margin-bottom")},path:["M",c.x,c.bottom+d,"L",c.right,c.bottom+d]}),b}})),KityMinder.registerConnectProvider("bezier",function(a,b,c){var d=b.getLayoutVertexOut(),e=a.getLayoutVertexIn(),f=b.getLayoutVectorOut().normalize(),g=Math.round,h=Math.abs,i=[];if(i.push("M",g(d.x),g(d.y)),h(f.x)>h(f.y)){var j=(e.x+d.x)/2;i.push("C",j,d.y,j,e.y,e.x,e.y)}else{var k=(e.y+d.y)/2;i.push("C",d.x,k,e.x,k,e.x,e.y)}c.setMarker(null),c.setPathData(i)}),KityMinder.registerConnectProvider("poly",function(a,b,c,d){var e=b.getLayoutVertexOut(),f=a.getLayoutVertexIn(),g=b.getLayoutVectorOut().normalize(),h=Math.round,i=Math.abs,j=[];switch(j.push("M",h(e.x),h(e.y)),!0){case i(g.x)>i(g.y)&&g.x<0:j.push("h",-b.getStyle("margin-left")),j.push("v",f.y-e.y),j.push("H",f.x);break;case i(g.x)>i(g.y)&&g.x>=0:j.push("h",b.getStyle("margin-right")),j.push("v",f.y-e.y),j.push("H",f.x);break;case i(g.x)<=i(g.y)&&g.y<0:j.push("v",-b.getStyle("margin-top")),j.push("h",f.x-e.x),j.push("V",f.y);break;case i(g.x)<=i(g.y)&&g.y>=0:j.push("v",b.getStyle("margin-bottom")),j.push("h",f.x-e.x),j.push("V",f.y)}c.setMarker(null),c.setPathData(j)});var connectMarker=(new kity.Marker).pipe(function(){var a=7,b=new kity.Circle(a-1);this.addShape(b),this.setRef(a-1,0).setViewBox(-a,-a,a+a,a+a).setWidth(a).setHeight(a),this.dot=b,this.node.setAttribute("markerUnits","userSpaceOnUse")});KityMinder.registerConnectProvider("arc",function(a,b,c,d,e){var f,g,h,i=a.getLayoutBox(),j=b.getLayoutBox(),k=Math.abs,l=[],m=i.x>j.x?"right":"left";a.getMinder().getPaper().addResource(connectMarker),f=new kity.Point(j.cx,j.cy),g="left"==m?new kity.Point(i.right+2,i.cy):new kity.Point(i.left-2,i.cy),h=kity.Vector.fromPoints(f,g),l.push("M",f),l.push("A",k(h.x),k(h.y),0,0,h.x*h.y>0?0:1,g),c.setMarker(connectMarker),connectMarker.dot.fill(e),c.setPathData(l)}),KityMinder.registerConnectProvider("under",function(a,b,c,d,e){var f,g,h,i,j=a.getLayoutBox(),k=b.getLayoutBox(),l=(Math.abs,[]),m=j.x>k.x?"right":"left",n=(a.getStyle("connect-radius"),j.bottom+3),o="sub"==b.getType()?k.bottom+3:k.cy;"right"==m?(f=new kity.Point(k.right,o),g=new kity.Point(j.left-10,n),h=new kity.Point(j.right,n)):(f=new kity.Point(k.left,o),g=new kity.Point(j.right+10,n),h=new kity.Point(j.left,n)),i=(f.x+g.x)/2,l.push("M",f),l.push("C",i,f.y,i,g.y,g),l.push("L",h),c.setMarker(null),c.setPathData(l)}),KityMinder.registerConnectProvider("l",function(a,b,c){var d=b.getLayoutVertexOut(),e=a.getLayoutVertexIn(),f=b.getLayoutVectorOut(),g=[],h=Math.round,i=Math.abs;g.push("M",d.round()),i(f.x)>i(f.y)?g.push("H",h(e.x)):g.push("V",e.y),g.push("L",e),c.setPathData(g)}),KityMinder.registerConnectProvider("fish-bone-master",function(a,b,c){var d=b.getLayoutVertexOut(),e=a.getLayoutVertexIn(),f=Math.abs,g=f(d.y-e.y),h=f(d.x-e.x),i=[];i.push("M",d.x,d.y),i.push("h",h-g),i.push("L",e.x,e.y),c.setMarker(null),c.setPathData(i)});var connectMarker=(new kity.Marker).pipe(function(){var a=7,b=new kity.Circle(a-1); this.addShape(b),this.setRef(a-1,0).setViewBox(-a,-a,a+a,a+a).setWidth(a).setHeight(a),this.dot=b,this.node.setAttribute("markerUnits","userSpaceOnUse")});KityMinder.registerConnectProvider("arc_tp",function(a,b,c,d,e){var f=a.getLayoutBox(),g=b.getLayoutBox();if(a.getIndex()>0){var h=a.getIndex();g=b.getChildren()[h-1].getLayoutBox()}var i,j,k,l=(Math.abs,[]);f.x>g.x?"right":"left";a.getMinder().getPaper().addResource(connectMarker),i=new kity.Point(g.cx,g.cy),j=new kity.Point(f.cx,f.cy);var m=Math.sqrt(Math.abs(i.x-j.x)*Math.abs(i.x-j.x)+Math.abs(i.y-j.y)*Math.abs(i.y-j.y));m=0==a.getIndex()?.4*m:m,k=kity.Vector.fromPoints(i,j),l.push("M",i),l.push("A",m,m,0,0,1,j),c.setMarker(connectMarker),connectMarker.dot.fill(e),c.setPathData(l)}),["classic","classic-compact"].forEach(function(a){var b="classic-compact"==a;KityMinder.registerTheme(a,{background:"#3A4144 url(ui/theme/default/images/grid.png) repeat","root-color":"#430","root-background":"#e9df98","root-stroke":"#e9df98","root-font-size":24,"root-padding":b?[10,25]:[15,25],"root-margin":b?[15,25]:[30,100],"root-radius":30,"root-space":10,"root-shadow":"rgba(0, 0, 0, .25)","main-color":"#333","main-background":"#a4c5c0","main-stroke":"#a4c5c0","main-font-size":16,"main-padding":b?[5,15]:[6,20],"main-margin":b?[5,10]:20,"main-radius":10,"main-space":5,"main-shadow":"rgba(0, 0, 0, .25)","sub-color":"white","sub-background":"transparent","sub-stroke":"none","sub-font-size":12,"sub-padding":[5,10],"sub-margin":b?[5,10]:[15,20],"sub-tree-margin":30,"sub-radius":5,"sub-space":5,"connect-color":"white","connect-width":2,"main-connect-width":3,"connect-radius":5,"selected-background":"rgb(254, 219, 0)","selected-stroke":"rgb(254, 219, 0)","selected-color":"black","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","sub-drop-hint-width":2,"main-drop-hint-width":4,"root-drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.5})}),["snow","snow-compact"].forEach(function(a){var b="snow-compact"==a;KityMinder.registerTheme(a,{background:"#3A4144 url(ui/theme/default/images/grid.png) repeat","root-color":"#430","root-background":"#e9df98","root-stroke":"#e9df98","root-font-size":24,"root-padding":b?[5,10]:[15,25],"root-margin":b?15:30,"root-radius":5,"root-space":10,"root-shadow":"rgba(0, 0, 0, .25)","main-color":"#333","main-background":"#a4c5c0","main-stroke":"#a4c5c0","main-font-size":16,"main-padding":b?[4,10]:[6,20],"main-margin":b?[5,10]:[20,40],"main-radius":5,"main-space":5,"main-shadow":"rgba(0, 0, 0, .25)","sub-color":"black","sub-background":"white","sub-stroke":"white","sub-font-size":12,"sub-padding":[5,10],"sub-margin":b?[5,10]:[10,20],"sub-radius":5,"sub-space":5,"connect-color":"white","connect-width":2,"main-connect-width":3,"connect-radius":5,"selected-background":"rgb(254, 219, 0)","selected-stroke":"rgb(254, 219, 0)","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.5})}),function(){function a(a,b,c){return kity.Color.createHSL(a,b,c)}function b(b,c){return{background:"#fbfbfb","root-color":"white","root-background":a(b,37,60),"root-stroke":a(b,37,60),"root-font-size":16,"root-padding":c?[6,12]:[12,24],"root-margin":c?10:[30,100],"root-radius":5,"root-space":10,"main-color":"black","main-background":a(b,33,95),"main-stroke":a(b,37,60),"main-stroke-width":1,"main-font-size":14,"main-padding":[6,20],"main-margin":c?8:20,"main-radius":3,"main-space":5,"sub-color":"black","sub-background":"transparent","sub-stroke":"none","sub-font-size":12,"sub-padding":c?[3,5]:[5,10],"sub-margin":c?[4,8]:[15,20],"sub-radius":5,"sub-space":5,"connect-color":a(b,37,60),"connect-width":1,"connect-radius":5,"selected-stroke":a(b,26,30),"selected-stroke-width":"3","marquee-background":a(b,100,80).set("a",.1),"marquee-stroke":a(b,37,60),"drop-hint-color":a(b,26,35),"drop-hint-width":5,"order-hint-area-color":a(b,100,30).set("a",.5),"order-hint-path-color":a(b,100,25),"order-hint-path-width":1,"text-selection-color":a(b,100,20),"line-height":1.5}}var c,d={red:0,soil:25,green:122,blue:204,purple:246,pink:334};for(c in d)KityMinder.registerTheme("fresh-"+c,b(d[c])),KityMinder.registerTheme("fresh-"+c+"-compat",b(d[c],!0))}(),KityMinder.registerTheme("fish",{background:"#3A4144 url(ui/theme/default/images/grid.png) repeat","root-color":"#430","root-background":"#e9df98","root-stroke":"#e9df98","root-font-size":24,"root-padding":[35,35],"root-margin":30,"root-radius":100,"root-space":10,"root-shadow":"rgba(0, 0, 0, .25)","main-color":"#333","main-background":"#a4c5c0","main-stroke":"#a4c5c0","main-font-size":16,"main-padding":[6,20],"main-margin":[20,20],"main-radius":5,"main-space":5,"main-shadow":"rgba(0, 0, 0, .25)","sub-color":"black","sub-background":"white","sub-stroke":"white","sub-font-size":12,"sub-padding":[5,10],"sub-margin":[10],"sub-radius":5,"sub-space":5,"connect-color":"white","connect-width":3,"main-connect-width":3,"connect-radius":5,"selected-background":"rgb(254, 219, 0)","selected-stroke":"rgb(254, 219, 0)","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.5}),KityMinder.registerTheme("wire",{background:"black",color:"#999",stroke:"none",padding:10,margin:20,"font-size":14,"connect-color":"#999","connect-width":1,"selected-background":"#999","selected-color":"black","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","sub-drop-hint-width":2,"main-drop-hint-width":4,"root-drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.5}),["tianpan","tianpan-compact"].forEach(function(a){var b="tianpan-compact"==a;KityMinder.registerTheme(a,{background:"#3A4144 url(ui/theme/default/images/grid.png) repeat","root-color":"#430","root-background":"#e9df98","root-stroke":"#e9df98","root-font-size":25,"root-padding":b?15:20,"root-margin":b?[15,25]:100,"root-radius":30,"root-space":10,"root-shadow":"rgba(0, 0, 0, .25)","root-shape":"circle","main-color":"#333","main-background":"#a4c5c0","main-stroke":"#a4c5c0","main-font-size":15,"main-padding":b?10:12,"main-margin":b?10:12,"main-radius":10,"main-space":5,"main-shadow":"rgba(0, 0, 0, .25)","main-shape":"circle","sub-color":"#333","sub-background":"#99ca6a","sub-stroke":"#a4c5c0","sub-font-size":13,"sub-padding":5,"sub-margin":b?6:10,"sub-tree-margin":30,"sub-radius":5,"sub-space":5,"sub-shadow":"rgba(0, 0, 0, .25)","sub-shape":"circle","connect-color":"white","connect-width":2,"main-connect-width":3,"connect-radius":5,"selected-background":"rgb(254, 219, 0)","selected-stroke":"rgb(254, 219, 0)","selected-color":"black","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","sub-drop-hint-width":2,"main-drop-hint-width":4,"root-drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.4})}),KityMinder.registerTemplate("default",{getLayout:function(a){if(a.getData("layout"))return a.getData("layout");var b=a.getLevel();return 0===b?"mind":1===b?a.getLayoutPointPreview().x>0?"right":"left":a.parent.getLayout()},getConnect:function(a){return 1==a.getLevel()?"arc":"under"}}),KityMinder.registerTemplate("structure",{getLayout:function(a){return a.getData("layout")||"bottom"},getConnect:function(a){return"poly"}}),KityMinder.registerTemplate("filetree",{getLayout:function(a){return a.getData("layout")?a.getData("layout"):a.isRoot()?"bottom":"filetree-down"},getConnect:function(a){return 1==a.getLevel()?"poly":"l"}}),KityMinder.registerTemplate("right",{getLayout:function(a){return a.getData("layout")||"right"},getConnect:function(a){return 1==a.getLevel()?"arc":"bezier"}}),KityMinder.registerTemplate("fish-bone",{getLayout:function(a){if(a.getData("layout"))return a.getData("layout");var b=a.getLevel();return 0===b?"fish-bone-master":1===b?"fish-bone-slave":a.getLayoutPointPreview().y>0?"filetree-up":"filetree-down"},getConnect:function(a){switch(a.getLevel()){case 1:return"fish-bone-master";case 2:return"line";default:return"l"}}}),KityMinder.registerTemplate("tianpan",{getLayout:function(a){if(a.getData("layout"))return a.getData("layout");var b=a.getLevel();return 0===b?"tianpan":a.parent.getLayout()},getConnect:function(a){return"arc_tp"}});var AppendChildCommand=kity.createClass("AppendChildCommand",{base:Command,execute:function(a,b){var c=a.getSelectedNode();if(!c)return null;b=b||a.getLang("topic"),c.expand();var d=a.createNode(b,c);a.select(d,!0),d.render(),a.layout(600)},queryState:function(a){var b=a.getSelectedNode();return b?0:-1}}),AppendSiblingCommand=kity.createClass("AppendSiblingCommand",{base:Command,execute:function(a,b){var c=a.getSelectedNode(),d=c.parent;if(!d)return a.execCommand("AppendChildNode",b);b=b||a.getLang("topic");var e=a.createNode(b,d,c.getIndex()+1);a.select(e,!0),e.render(),a.layout(600)},queryState:function(a){var b=a.getSelectedNode();return b?0:-1}}),RemoveNodeCommand=kity.createClass("RemoverNodeCommand",{base:Command,execute:function(a,b){var c=a.getSelectedNodes(),d=MinderNode.getCommonAncestor.apply(null,c);c.forEach(function(b){b.isRoot()||a.removeNode(b)}),a.select(d||a.getRoot(),!0),a.layout(600)},queryState:function(a){var b=a.getSelectedNode();return b?0:-1}}),EditNodeCommand=kity.createClass("EditNodeCommand",{base:Command,execute:function(a){var b=a.getSelectedNode();return b?(a.select(b,!0),void a.textEditNode(b)):null},queryState:function(a){var b=a.getSelectedNode();return b?0:-1},isNeedUndo:function(){return!1}}),$importDialog,$exportDialog,ImportTextNode=kity.createClass("ImportTextNode",{base:Command,execute:function(a,b){function c(a){var b;if(a)try{g=d.decode(a,!0)}catch(c){b="文本格式解析错误. "+c.message}else b="内容不能为空";b?(h.addClass("validate-error"),j.text(b),i.disable()):(h.removeClass("validate-error"),j.text(""),i.enable())}if(!$importDialog){var d=a.getProtocol("plain"),e=400;$importDialog=new FUI.Dialog({width:600,height:e,prompt:!0,caption:a.getLang("ui.importtextnode")}).appendTo(document.getElementById("content-wrapper"));var f=$($importDialog.getBodyElement());f.html([''].join(""));var g,h=f.find("textarea"),i=$importDialog.getButton(0),j=$('');h.after(j),h.on("input",function(){c(h.val())}),h.on("keydown keyup",function(a){if(9===a.keyCode&&"keydown"===a.type){a.preventDefault();var b=this.selectionStart;this.value=this.value.substring(0,this.selectionStart)+" "+this.value.substring(this.selectionEnd),this.selectionEnd=b+1}(13!==a.keyCode||a.shiftKey)&&a.stopPropagation()}),$importDialog.on("open",function(){c(h.val()),setTimeout(function(){h[0].focus()},10)}),$importDialog.on("ok",function(){function b(c,d,e){if(c&&d){var f=a.createNode(d.data.text,c);return d.children&&d.children.forEach(function(a){b(f,a)}),f.render(),f}}var c=[],d=a.getSelectedNode();g&&g.children&&d&&(d.expand(),g.children.forEach(function(a){c.push(b(d,a))})),a.select(c,!0),a.layout(300),h.val(""),c=null,g=null})}$importDialog.open()},queryState:function(a){var b=a.getSelectedNode();return b?0:-1}}),ExportTextNode=kity.createClass("ExportTextNode",{base:Command,execute:function(a,b){if(!$exportDialog){var c=a.getProtocol("plain"),d=400;$exportDialog=new FUI.Dialog({width:600,height:d,prompt:!0,caption:a.getLang("ui.exporttextnode")}).appendTo(document.getElementById("content-wrapper"));var e=$($exportDialog.getBodyElement());e.html([''].join(""));var f=e.find("textarea");f.on("keydown keyup",function(a){if(9===a.keyCode&&"keydown"===a.type){a.preventDefault();var b=this.selectionStart;this.value=this.value.substring(0,this.selectionStart)+" "+this.value.substring(this.selectionEnd),this.selectionEnd=b+1}(13!==a.keyCode||a.shiftKey)&&a.stopPropagation()}),$exportDialog.on("open",function(){f.val(c.encode(a.getSelectedNode())),setTimeout(function(){f[0].focus()},10)})}$exportDialog.open()},queryState:function(a){var b=a.getSelectedNode();return b?0:-1}});KityMinder.registerModule("NodeModule",function(){return{commands:{AppendChildNode:AppendChildCommand,AppendSiblingNode:AppendSiblingCommand,ImportTextNode:ImportTextNode,ExportTextNode:ExportTextNode,RemoveNode:RemoveNodeCommand,EditNode:EditNodeCommand},contextmenu:[{command:"appendsiblingnode"},{command:"appendchildnode"},{command:"editnode"},{command:"removenode"},{command:"importtextnode"},{command:"exporttextnode"},{divider:1}],commandShortcutKeys:{appendsiblingnode:"normal::Enter",appendchildnode:"normal::Insert|Tab",editnode:"normal::F2",removenode:"normal::Del|Backspace"}}});var FONT_ADJUST={"微软雅黑,Microsoft YaHei":-.15,"arial black,avant garde":-.17,"default":-.15},TextRenderer=KityMinder.TextRenderer=kity.createClass("TextRenderer",{base:Renderer,create:function(){return(new kity.Group).setId(KityMinder.uuid("node_text"))},update:function(a,b){function c(a){return b.getData(a)||b.getStyle(a)}var d=b.getText(!0),e=b.getStyle("line-height"),f=c("font-size"),g=c("font-family")||"default",h=e*f*d.length-(e-1)*f,i=-h/2,j=FONT_ADJUST[g]||0;a.setTranslate(0,j*f);var k=new kity.Box,l=Math.round;this.setTextStyle(b,a);var m=d.length,n=a.getItems().length;if(n>m)for(var o,p=m;o=a.getItem(p);)a.removeItem(p);else if(m>n)for(var q=m-n,p=0;q>p;p++){var r=(new kity.Text).setAttr("text-rendering","inherit");kity.Browser.ie?r.setVerticalAlign("top"):r.setAttr("dominant-baseline","text-before-edge"),a.addItem(r)}for(var s,r,p=0;s=d[p],r=a.getItem(p);p++)r.setContent(s);this.setTextStyle(b,a);var t=b.getText()+[c("font-size"),c("font-name"),c("font-weight"),c("font-style")].join("/");return b._currentTextHash==t&&b._currentTextGroupBox?b._currentTextGroupBox:(b._currentTextHash=t,function(){a.eachItem(function(a,b){var c=i+a*f*e;b.setY(c),k=k.merge(new kity.Box(0,c,b.getBoundaryBox().width||1,f))});var c=0,d=b.getStyle("shape");d&&"circle"==d&&(c=Math.max(k.width,k.height)/2-k.height/2);var g=new kity.Box(l(k.x),l(k.y-c),l(k.width),l(k.height));return b._currentTextGroupBox=g,g})},setTextStyle:function(a,b){var c=TextRenderer._styleHooks;c.forEach(function(c){c(a,b)})}});utils.extend(TextRenderer,{_styleHooks:[],registerStyleHook:function(a){TextRenderer._styleHooks.push(a)}}),kity.extendClass(MinderNode,{getTextGroup:function(){return this.getRenderer("TextRenderer").getRenderShape()}}),KityMinder.registerModule("text",{renderers:{center:TextRenderer}}),KityMinder.registerModule("Expand",function(){var a=this,b="expandState",c="expand",d="collapse";kity.extendClass(MinderNode,{expand:function(){return this.setData(b,c),this},collapse:function(){return this.setData(b,d),this},isExpanded:function(){var a=this.getData(b)!==d;return a&&(this.isRoot()||this.parent.isExpanded())},isCollapsed:function(){return!this.isExpanded()}});var e=kity.createClass("ExpandCommand",{base:Command,execute:function(a,b){var c=a.getSelectedNode();if(c){for(b&&(c=c.parent);c.parent;)c.expand(),c=c.parent;c.renderTree(),a.layout(100)}},queryState:function(a){return a.getSelectedNode()?0:-1}}),f=kity.createClass("ExpandToLevelCommand",{base:Command,execute:function(a,b){a.getRoot().traverse(function(a){a.getLevel()d;d++)a.isShortcutKey("Alt+"+d)&&this.execCommand("expandtolevel",d)}}},renderers:{outside:h},contextmenu:[{command:"expandtoleaf",query:function(){return!a.getSelectedNode()},fn:function(a){a.execCommand("expandtolevel",9999)}},{command:"expandtolevel1",query:function(){return!a.getSelectedNode()},fn:function(a){a.execCommand("expandtolevel",1)}},{command:"expandtolevel2",query:function(){return!a.getSelectedNode()},fn:function(a){a.execCommand("expandtolevel",2)}},{command:"expandtolevel3",query:function(){return!a.getSelectedNode()},fn:function(a){a.execCommand("expandtolevel",3)}},{divider:!0}]}});var OutlineRenderer=kity.createClass("OutlineRenderer",{base:Renderer,create:function(a){var b=(new kity.Rect).setId(KityMinder.uuid("node_outline"));return this.bringToBack=!0,b},update:function(a,b,c){var d=b.getStyle("shape");if(d&&"circle"==d)return updateCircle(a,b,c);var e=b.getStyle("padding-left"),f=b.getStyle("padding-right"),g=b.getStyle("padding-top"),h=b.getStyle("padding-bottom"),i={x:c.x-e,y:c.y-g,width:c.width+e+f,height:c.height+g+h},j=b.isSelected()?"selected-":"";return a.setPosition(i.x,i.y).setSize(i.width,i.height).setRadius(b.getStyle("radius")).fill(b.getData("background")||b.getStyle(j+"background")||b.getStyle("background")).stroke(b.getStyle(j+"stroke"||b.getStyle("stroke")),b.getStyle(j+"stroke-width")),new kity.Box(i)}}),ShadowRenderer=kity.createClass("ShadowRenderer",{base:Renderer,create:function(a){return this.bringToBack=!0,new kity.Rect},shouldRender:function(a){return a.getStyle("shadow")},update:function(a,b,c){a.setPosition(c.x+4,c.y+5).fill(b.getStyle("shadow"));var d=b.getStyle("shape");if(d){if("circle"==d){var e=Math.max(c.width,c.height);a.setSize(e,e),a.setRadius(e/2)}}else a.setSize(c.width,c.height),a.setRadius(b.getStyle("radius"))}}),marker=new kity.Marker;marker.setWidth(10),marker.setHeight(12),marker.setRef(0,0),marker.setViewBox(-6,-4,8,10),marker.addShape((new kity.Path).setPathData("M-5-3l5,3,-5,3").stroke("#33ffff"));var wireframeOption=/wire/.test(window.location.href),WireframeRenderer=kity.createClass("WireframeRenderer",{base:Renderer,create:function(){var a=new kity.Group,b=this.oxy=(new kity.Path).stroke("#f6f").setPathData("M0,-50L0,50M-50,0L50,0"),c=this.wireframe=(new kity.Rect).stroke("lightgreen"),d=this.vectorIn=(new kity.Path).stroke("#66ffff"),e=this.vectorOut=(new kity.Path).stroke("#66ffff");return d.setMarker(marker,"end"),e.setMarker(marker,"end"),a.addShapes([b,c,d,e])},shouldRender:function(){return wireframeOption},update:function(a,b,c){this.wireframe.setPosition(c.x,c.y).setSize(c.width,c.height);var d=b.getVertexIn(),e=b.getVertexOut(),f=b.getLayoutVectorIn().normalize(30),g=b.getLayoutVectorOut().normalize(30);this.vectorIn.setPathData(["M",d.offset(f.reverse()),"L",d]),this.vectorOut.setPathData(["M",e,"l",g])}});KityMinder.registerModule("OutlineModule",function(){return{events:wireframeOption?{ready:function(){this.getPaper().addResource(marker)},layoutallfinish:function(){this.getRoot().traverse(function(a){a.getRenderer("WireframeRenderer").update(null,a,a.getContentBox())})}}:null,renderers:{outline:OutlineRenderer,outside:[ShadowRenderer,WireframeRenderer]}}}),KityMinder.Geometry=function(){function a(a){return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a.cx=a.x+a.width/2,a.cy=a.y+a.height/2,a}function b(a){"x"in a&&(a.left=a.x,a.right=a.x+a.width,a.top=a.y,a.bottom=a.y+a.height)}var c={},d=Math.min,e=Math.max,f=(Math.abs,Object.prototype.hasOwnProperty);return c.isNumberInRange=function(a,b){return a>b[0]&&ag&&j>h?a({left:g,right:i,top:h,bottom:j}):null},c.snapToSharp=function(a){return utils.isNumber(a)?(0|a)+.5:utils.isArray(a)?a.map(c.snapToSharp):(["x","y","left","top","right","bottom"].forEach(function(b){f.call(a,b)&&(a[b]=c.snapToSharp(a[b]))}),a)},c.expandBox=function(b,c,d){return void 0===d&&(d=c),a({left:b.left-c,top:b.top-d,right:b.right+c,bottom:b.bottom+d})},c}(),KityMinder.registerModule("HistoryModule",function(){var a=this,b=kity.createClass("Scene",{constructor:function(a,b){this.data=a.clone(),this.inputStatus=b},getData:function(){return this.data},cloneData:function(){return this.getData().clone()},equals:function(a){return this.getData().equals(a.getData())},isInputStatus:function(){return this.inputStatus},setInputStatus:function(a){this.inputStatus=a}}),c=kity.createClass("HistoryManager",{constructor:function(a){this.list=[],this.index=0,this.hasUndo=!1,this.hasRedo=!1,this.km=a},undo:function(){if(this.hasUndo){var a=this.list[this.index];if(a&&a.isInputStatus())return this.saveScene(),this.restore(--this.index),void a.setInputStatus(!1);if(1==this.list.length)return void this.restore(0);if(!this.list[this.index-1]&&1==this.list.length)return void this.reset();for(;this.list[this.index].equals(this.list[this.index-1]);)if(this.index--,0===this.index)return this.restore(0);this.restore(--this.index)}},redo:function(){if(this.hasRedo){for(;this.list[this.index].equals(this.list[this.index+1]);)if(this.index++,this.index==this.list.length-1)return this.restore(this.index);this.restore(++this.index)}},partialRenewal:function(b){function c(a,b){return a.getText()!=b.getText()?!1:utils.compareObject(a.getData(),b.getData())===!1?!1:utils.compareObject(a.getTmpData(),b.getTmpData())===!1?!1:!0}function d(b,c){c.isSelected()&&f.push(c),a.appendNode(c,b),c.render();for(var e,g=utils.cloneArr(c.children),h=0;e=g[h++];)d(c,e)}function e(b,g){c(b,g)===!1&&b.setValue(g),b.render(),b.isSelected()&&f.push(b);for(var h,i,j=0,k=0;h=b.children[j],i=g.children[k],h||i;j++,k++)h&&!i?(j--,a.removeNode(h)):!h&&i?(k--,d(b,i)):e(h,i)}var f=[];e(a.getRoot(),b),a.layout(200),a.select(f,!0),f=[]},restore:function(a){a=void 0===a?this.index:a;var b=this.list[a];this.partialRenewal(b.cloneData()),this.update(),this.km.fire("restoreScene"),this.km.fire("contentChange")},getScene:function(a){return new b(this.km.getRoot(),a)},saveScene:function(a){var b=this.getScene(a),c=this.list[this.index];return c&&c.equals(b)?void(a&&(c.setInputStatus(!0),this.update())):(this.list=this.list.slice(0,this.index+1),this.list.push(b),this.list.length>this.km.getOptions("maxUndoCount")&&this.list.shift(),this.index=this.list.length-1,void this.update())},update:function(){this.hasRedo=!!this.list[this.index+1],this.hasUndo=!!this.list[this.index-1];var a=this.list[this.index];a&&a.isInputStatus()&&(this.hasUndo=!0)},reset:function(){this.list=[],this.index=0,this.hasUndo=!1,this.hasRedo=!1}});return this.historyManager=new c(this),{defaultOptions:{maxUndoCount:20,maxInputCount:20},commands:{undo:kity.createClass("UndoCommand",{base:Command,execute:function(a){a.historyManager.undo()},queryState:function(a){return a.historyManager.hasUndo?0:-1},isNeedUndo:function(){return!1}}),redo:kity.createClass("RedoCommand",{base:Command,execute:function(a){a.historyManager.redo()},queryState:function(a){return a.historyManager.hasRedo?0:-1},isNeedUndo:function(){return!1}})},commandShortcutKeys:{undo:"ctrl+z",redo:"ctrl+y"},events:{saveScene:function(a){this.historyManager.saveScene(a.inputStatus)},"import":function(){this.historyManager.reset()}}}}),KityMinder.registerModule("ProgressModule",function(){var a=this,b="progress",c="#FFED83",d="#43BC00",e="M10,3c4.418,0,8,3.582,8,8h1c0-5.523-3.477-10-9-10S1,5.477,1,11h1C2,6.582,5.582,3,10,3z",f="#8E8E8E",g="M10,0C4.477,0,0,4.477,0,10c0,5.523,4.477,10,10,10s10-4.477,10-10C20,4.477,15.523,0,10,0zM10,18c-4.418,0-8-3.582-8-8s3.582-8,8-8s8,3.582,8,8S14.418,18,10,18z",h=(new kity.LinearGradient).pipe(function(a){a.setStartPosition(0,0),a.setEndPosition(0,1),a.addStop(0,"#fff"),a.addStop(1,"#ccc")}),i="M15.812,7.896l-6.75,6.75l-4.5-4.5L6.25,8.459l2.812,2.803l5.062-5.053L15.812,7.896z",j="#EEE";a.getPaper().addResource(h);var k=kity.createClass("ProgressIcon",{base:kity.Group,constructor:function(a){this.callBase(),this.setSize(20),this.create(),this.setValue(a),this.setId(KityMinder.uuid("node_progress")),this.translate(.5,.5)},setSize:function(a){this.width=this.height=a},create:function(){var a,b,k,l,m;a=new kity.Circle(9).fill(c),b=new kity.Pie(9,0).fill(d),k=(new kity.Path).setPathData(e).setTranslate(-10,-10).fill(f),l=(new kity.Path).setTranslate(-10,-10).setPathData(g).fill(h),m=(new kity.Path).setTranslate(-10,-10).setPathData(i).fill(j),this.addShapes([a,b,k,m,l]),this.pie=b,this.check=m},setValue:function(a){this.pie.setAngle(-360*(a-1)/8),this.check.setVisible(9==a)}}),l=kity.createClass("ProgressCommand",{base:Command,execute:function(a,c){for(var d=a.getSelectedNodes(),e=0;ec&&e>f?(a=c,b=a/e):b>d&&(b=d,a=b*e),{width:0|a,height:0|b}}var c=kity.createClass("ImageCommand",{base:Command,execute:function(c,d,e){var f=c.getSelectedNodes();a(d,function(a,g){a&&(utils.each(f,function(f,h){var i=b(a,g,c.getOptions("maxImageWidth"),c.getOptions("maxImageHeight"));h.setData("image",d),h.setData("imageTitle",e),h.setData("imageSize",i),h.render()}),c.fire("saveScene"),c.layout(300))})},queryState:function(a){var b=a.getSelectedNodes(),c=0;return 0===b.length?-1:(utils.each(b,function(a,b){return b&&b.getData("image")?(c=0,!1):void 0}),c)},queryValue:function(a){var b=a.getSelectedNode();return{url:b.getData("image"),title:b.getData("imageTitle")}}}),d=kity.createClass("RemoveImageCommand",{base:Command,execute:function(a){var b=a.getSelectedNodes();utils.each(b,function(a,b){b.setData("image").render()}),a.layout(300)},queryState:function(a){var b=a.getSelectedNodes();if(0===b.length)return-1;var c=!1;return utils.each(b,function(a,b){return b.getData("image")?(c=!0,!1):void 0}),c?0:-1}}),e=kity.createClass("ImageRenderer",{base:KityMinder.Renderer,create:function(a){return new kity.Image(a.getData("image"))},shouldRender:function(a){return a.getData("image")},update:function(a,b,c){var d=b.getData("image"),e=b.getData("imageTitle"),f=b.getData("imageSize"),g=b.getStyle("space-top");if(f){e&&a.node.setAttributeNS("http://www.w3.org/1999/xlink","title",e);var h=c.cx-f.width/2,i=c.y-f.height-g;return a.setUrl(d).setX(0|h).setY(0|i).setWidth(0|f.width).setHeight(0|f.height),new kity.Box(0|h,0|i,0|f.width,0|f.height)}}});return{defaultOptions:{maxImageWidth:200,maxImageHeight:200},commands:{image:c,removeimage:d},renderers:{top:e}}}),KityMinder.registerModule("Resource",function(){ var a=function(){var a,b,c,d,e,f,g,h,i,j,k;return k=4*(1<<30),a=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],e=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479],j=function(a){return 0>a&&(a+=k),("00000000"+a.toString(16)).slice(-8)},f=[[16,50,84,118,152,186,220,254],[174,132,249,109,193,32,123,53],[139,12,37,223,234,99,23,73],[151,19,205,235,98,165,4,143],[9,117,66,250,30,203,134,211],[194,166,176,56,212,87,239,145],[92,241,222,164,112,54,41,184],[189,231,28,147,5,79,104,162],[246,158,59,128,44,125,65,90],[42,72,103,81,191,233,195,13]],g=function(a,b,c){var d=h[a]^h[b];h[a]=d>>>c|d<<32-c},b=function(a,b,j,k,l){var m=d+f[c][a]%16,n=d+(f[c][a]>>4);b%=4,j=4+j%4,k=8+k%4,l=12+l%4,h[b]+=h[j]+(i[m]^e[n%16]),g(l,b,16),h[k]+=h[l],g(j,k,12),h[b]+=h[j]+(i[n]^e[m%16]),g(l,b,8),h[k]+=h[l],g(j,k,7)},function(f,g){g instanceof Array&&4===g.length||(g=[0,0,0,0]);var k,l,m,n,o,p,q,r;for(l=a.slice(0),k=e.slice(0,8),c=0;4>c;c+=1)k[c]^=g[c];if(m=16*f.length,o=m%512>446||m%512===0?0:m,m%512===432)f+="老";else{for(f+="耀";f.length%32!==27;)f+="\x00";f+=""}for(i=[],r=0;rc;c+=1)for(r=0;8>r;r+=1)4>r?b(r,r,r,r,r):b(r,r,r+1,r+2,r+3);for(r=0;8>r;r+=1)l[r]^=g[r%4]^h[r]^h[r+8]}return l.map(j).join("")}}(),b=[51,303,75,200,157,0,26,254].map(function(a){return kity.Color.createHSL(a,100,85)});kity.extendClass(Minder,{getHashCode:function(b){b=a(b);var c,d,e=1315423911;for(c=b.length-1;c>=0;c--)d=b.charCodeAt(c),e^=(e<<5)+d+(e>>2);return 2147483647&e},getResourceColor:function(a){var c,d=this._getResourceColorIndexMapping();return d.hasOwnProperty(a)||(c=this._getNextResourceColorIndex(),d[a]=c),b[d[a]]||kity.Color.createHSL(Math.floor(this.getHashCode(a)/2147483647*359),100,85)},getUsedResource:function(){var a,b=this._getResourceColorIndexMapping(),c=[];for(a in b)b.hasOwnProperty(a)&&c.push(a);return c},_getNextResourceColorIndex:function(){var a,c,d,e=this._getResourceColorIndexMapping();c=[];for(a in e)e.hasOwnProperty(a)&&c.push(e[a]);for(d=0;d10){this.setStatus("hand",!0);var f=b._minder.getPaper();f.setStyle("cursor","-webkit-grabbing")}}}).on("hand.beforemousedown hand.beforetouchstart",function(a){if(b.isEnabled()){d=a.getPosition(),a.stopPropagation();var c=b._minder.getPaper();c.setStyle("cursor","-webkit-grabbing")}}).on("hand.beforemousemove hand.beforetouchmove",function(a){if(d){e=a.getPosition();var c=kity.Vector.fromPoints(d,e);b.move(c),a.stopPropagation(),a.preventDefault(),a.originEvent.preventDefault(),d=e}}).on("mouseup touchend",a),window.addEventListener("mouseup",a),this._minder.on("contextmenu",function(a){a.preventDefault()})}});KityMinder.registerModule("View",function(){var a=kity.createClass("ToggleHandCommand",{base:Command,execute:function(a){"hand"!=a.getStatus()?a.setStatus("hand",!0):a.rollbackStatus(),this.setContentChanged(!1)},queryState:function(a){return"hand"==a.getStatus()?1:0},enableReadOnly:!0}),b=kity.createClass("CameraCommand",{base:Command,execute:function(a,b,c){b=b||a.getRoot();var d=a.getPaper().getViewPort(),e=b.getRenderContainer().getRenderBox("view"),f=d.center.x-e.x-e.width/2,g=d.center.y-e.y,h=a._viewDragger;h.move(new kity.Point(f,g),c),this.setContentChanged(!1)},enableReadOnly:!0}),c=kity.createClass("MoveCommand",{base:Command,execute:function(a,b,c){var d=a._viewDragger,e=a._lastClientSize;switch(b){case"up":d.move(new kity.Point(0,e.height/2),c);break;case"down":d.move(new kity.Point(0,-e.height/2),c);break;case"left":d.move(new kity.Point(e.width/2,0),c);break;case"right":d.move(new kity.Point(-e.width/2,0),c)}},enableReadOnly:!0});return{init:function(){this._viewDragger=new ViewDragger(this)},commands:{hand:a,camera:b,move:c},events:{keydown:function(a){var b=this;["up","down","left","right"].forEach(function(c){a.isShortcutKey("ctrl+"+c)&&"textedit"!=b.getStatus()&&(b.removeAllSelectedNodes(),b.execCommand("move",c,100),a.preventDefault())}),a.isShortcutKey("ctrl+enter")&&b.execCommand("camera",b.getRoot(),100)},statuschange:function(a){this._viewDragger.setEnabled("hand"==a.currentStatus)},mousewheel:function(a){var b,c;a=a.originEvent,a.ctrlKey||a.shiftKey||("wheelDeltaX"in a?(b=a.wheelDeltaX||0,c=a.wheelDeltaY||0):(b=0,c=a.wheelDelta),this._viewDragger.move({x:b/2.5,y:c/2.5}),a.preventDefault())},"normal.dblclick readonly.dblclick":function(a){a.kityEvent.targetShape instanceof kity.Paper&&this.execCommand("camera",this.getRoot(),800)},ready:function(){this.execCommand("camera",null,0),this._lastClientSize={width:this.getRenderTarget().clientWidth,height:this.getRenderTarget().clientHeight}},resize:function(a){var b={width:this.getRenderTarget().clientWidth,height:this.getRenderTarget().clientHeight},c=this._lastClientSize;this._viewDragger.move(new kity.Point((b.width-c.width)/2|0,(b.height-c.height)/2|0)),this._lastClientSize=b},"selectionchange layoutallfinish":function(a){var b=this.getSelectedNode();if(b){var c=this._viewDragger,d=c.getView(),e=b.getLayoutBox(),f=50,g=0,h=0;e.right>d.right?g+=d.right-e.right-f:e.leftd.bottom&&(h+=d.bottom-e.bottom-f),e.top=0;e--)d=b[e],d.parent&&(d.parent.removeChild(d),c.appendChild(d),d.render());c.expand(),a.select(b,!0)}}),DropHinter=kity.createClass("DropHinter",{base:kity.Group,constructor:function(){this.callBase(),this.rect=new kity.Rect,this.addShape(this.rect)},render:function(a){this.setVisible(!!a),a&&(this.rect.setBox(a.getLayoutBox()).setRadius(a.getStyle("radius")||0).stroke(a.getStyle("drop-hint-color")||"yellow",a.getStyle("drop-hint-width")||2),this.bringTop())}}),OrderHinter=kity.createClass("OrderHinter",{base:kity.Group,constructor:function(){this.callBase(),this.area=new kity.Rect,this.path=new kity.Path,this.addShapes([this.area,this.path])},render:function(a){this.setVisible(!!a),a&&(this.area.setBox(a.area),this.area.fill(a.node.getStyle("order-hint-area-color")||"rgba(0, 255, 0, .5)"),this.path.setPathData(a.path),this.path.stroke(a.node.getStyle("order-hint-path-color")||"#0f0",a.node.getStyle("order-hint-path-width")||1))}}),TreeDragger=kity.createClass("TreeDragger",{constructor:function(a){this._minder=a,this._dropHinter=new DropHinter,this._orderHinter=new OrderHinter,a.getRenderContainer().addShapes([this._dropHinter,this._orderHinter])},dragStart:function(a){this._startPosition=a},dragMove:function(a){var b=10;if(this._startPosition){var c=kity.Vector.fromPoints(this._dragPosition||this._startPosition,a),d=this._minder;if(this._dragPosition=a,!this._dragMode){if(GM.getDistance(this._dragPosition,this._startPosition)b&&"down"==a.type&&b++,b>d&&"up"==a.type&&b--,a.node.setLayoutOffset(null),this._minder.execCommand("arrange",this._dragSources,b),this._renderOrderHint(null)}else this._minder.fire("savescene");this._minder.layout(300),this._leaveDragMode(),this._minder.fire("contentchange")}},_enterDragMode:function(){return this._calcDragSources(),this._dragSources.length?(this._fadeDragSources(.5),this._calcDropTargets(),this._calcOrderHints(),this._dragMode=!0,this._minder.setStatus("dragtree"),!0):(this._startPosition=null,!1)},_calcDragSources:function(){this._dragSources=this._minder.getSelectedAncestors()},_fadeDragSources:function(a){var b=this._minder;this._dragSources.forEach(function(c){c.getRenderContainer().setOpacity(a,200),c.traverse(function(c){1>a?b.detachNode(c):b.attachNode(c)},!0)})},_calcDropTargets:function(){function a(b,c){var d,e=[];return e.push(c),c.getChildren().forEach(function(c){for(d=0;d.5*Math.min(d(b),d(c))?!0:a.width+1>=Math.min(b.width,c.width)?!0:a.height+1>=Math.min(b.height,c.height)?!0:!1:!1}),this._renderDropHint(this._dropSucceedTarget),!!this._dropSucceedTarget},_orderTest:function(){return this._orderSucceedHint=this._boxTest(this._orderHints,function(a){return a.area}),this._renderOrderHint(this._orderSucceedHint),!!this._orderSucceedHint},_renderDropHint:function(a){this._dropHinter.render(a)},_renderOrderHint:function(a){this._orderHinter.render(a)},preventDragMove:function(){this._startPosition=null}});KityMinder.registerModule("DragTree",function(){var a;return{init:function(){a=new TreeDragger(this),window.addEventListener("mouseup",function(){a.dragEnd()})},events:{"normal.mousedown inputready.mousedown":function(b){b.originEvent.button||b.getTargetNode()&&b.getTargetNode()!=this.getRoot()&&a.dragStart(b.getPosition(this.getRenderContainer()))},"normal.mousemove dragtree.mousemove":function(b){a.dragMove(b.getPosition(this.getRenderContainer()))},"normal.mouseup dragtree.beforemouseup":function(b){a.dragEnd(),b.preventDefault()},statuschange:function(b){"textedit"==b.lastStatus&&"normal"==b.currentStatus&&a.preventDragMove()}},commands:{movetoparent:MoveToParentCommand}}}),KityMinder.registerModule("KeyboardModule",function(){function a(a){var b,d=[];a.traverse(function(a){b=a.getLayoutBox(),b.width&&b.height&&d.push({left:b.x,top:b.y,right:b.x+b.width,bottom:b.y+b.height,width:b.width,height:b.height,node:a,text:a.getText()})});for(var e=0;ej?k:0>k?j:g(j*j+k*k),{cx:l,cy:l}}function c(a,c){for(var d,e,f=a[c],g={},h=0;hf.right&&(!g.right||e.cxf.bottom&&(!g.down||e.cy$$_kityminder_bookmark_$$")[0]);var a=[];utils.each(b.container.getElementsByTagName("br"),function(b,c){a.push(c)}),utils.each(a,function(a,b){var c=document.createTextNode("\n");b.parentNode.insertBefore(c,b),b.parentNode.removeChild(b)});var c=b.container.textContent.replace(/[\u200b\t\r]/g,""),e=c.indexOf("$$_kityminder_bookmark_$$");b.re.setContainerTxt(c.replace("$$_kityminder_bookmark_$$","")),b.range.setStartOffset(e).collapse(!0).select(),b._setTextToContainer(d)},50);if(d==keymap.x)return void setTimeout(function(){b._setTextToContainer(d)},50)}this.isShortcutCopyKey=!1,b._setTextToContainer(d)},_beforeKeyup:function(a){var b=this,c=a.originEvent,d=c.keyCode;switch(d){case keymap.Enter:case keymap.Tab:case keymap.Insert:case keymap.F2:return browser.ipad?void(this.selection.isShow()?(this.re.clear(),this.km.setStatus("inputready"),clearTimeout(b.inputTextTimer),a.preventDefault()):(this.km.setStatus("normal"),this.km.fire("contentchange"))):(keymap.Enter==d&&(this.isTypeText||browser.mac&&browser.gecko)&&b._setTextToContainer(d,!0),this.re.keydownNode===this.re.minderNode&&(this.km.rollbackStatus(),this.re.clear()),void a.preventDefault());case keymap.Del:case keymap.Backspace:case keymap.Spacebar:return browser.ipad&&this.selection.isHide()?void this.km.setStatus("normal"):void b._setTextToContainer(d,!0)}return this.isTypeText?void b._setTextToContainer(d,!0):browser.mac&&browser.gecko?void b._setTextToContainer(d,!0):(b._setTextToContainer(d,!0),!0)},_keyup:function(a){var b,c=this,d=this.km.getSelectedNode();if("normal"==this.km.getStatus()&&d&&this.selection.isHide()){if(this.isShortcutCopyKey)return;d&&this.km.isSingleSelect()&&d.isSelected()&&(this.re.updateByMinderNode(d),this.selection.setHide().setStartOffset(0).setEndOffset(this.re.getTxtOfContainer().length).setColor(d.getStyle("text-selection-color")),setTimeout(function(){c.re.updateContainerRangeBySel()}),browser.ie&&(b=setInterval(function(){var a=c.range.nativeSel.getRangeAt(0);!a||a.collapsed?c.range.select():clearInterval(b)})),this.km.setStatus("inputready"))}},_handlerEnterkey:function(){function a(a){a&&3==a.nodeType&&0===a.nodeValue.length&&a.parentNode.removeChild(a)}var b=this.range,c=document.createElement("br"),d=this;b.collapsed||b.deleteContents(),b.insertNode(c),a(c.previousSibling),a(c.nextSibling),b.setStartAfter(c),b.collapse(!0);var e=b.startContainer.childNodes[b.startOffset];e||(c=c.cloneNode(!1),b.startContainer.appendChild(c),b.setStartBefore(c),b.collapse(!0)),b.select(),d._setTextToContainer(keymap.Enter)}}}()),Minder.Range=kity.createClass("Range",function(){function a(a,b){var c=a[b+"Container"],d=a[b+"Offset"],e=0;return 1==c.nodeType&&(c=c.childNodes[d],!c&&a.startContainer&&"DIV"==a.startContainer.nodeName?(a.startContainer.innerHTML="

    ",d=0):3==c.nodeType&&(d=0)),utils.each(a.container.childNodes,function(a,b){return b===c?1==b.nodeType?!1:(e+=d,!1):void(e+=1==b.nodeType?1:utils.clearWhitespace(b.nodeValue).length)}),e}function b(a,b,c){var d=0,e=a.container;utils.each(e.childNodes,function(f,g){if(1==g.nodeType)return d==b?(a["set"+c](e,f),!1):void d++;var h=utils.clearWhitespace(g.nodeValue).length;return d+h>=b?(a["set"+c](g,b-d),!1):void(d+=h)})}return{constructor:function(a){this.nativeRange=document.createRange(),this.nativeSel=window.getSelection(),this.startContainer=this.endContainer=this.startOffset=this.endOffset=null,this.collapsed=!1,this.container=a||null},hasNativeRange:function(){return 0!==this.nativeSel.rangeCount},deleteContents:function(){return this.nativeRange.deleteContents(),this._updateBoundary()},select:function(){var a=this.nativeRange.startContainer;if(1==a.nodeType&&0===a.childNodes.length){var b=document.createTextNode("​");a.appendChild(b),this.nativeRange.setStart(b,1),this.nativeRange.collapse(!0)}else this.collapsed&&1==a.nodeType&&(a=a.childNodes[this.startOffset],a&&3==a.nodeType&&0===a.nodeValue.length&&(this.nativeRange.setStart(a,1),this.nativeRange.collapse(!0)));try{this.nativeSel.removeAllRanges()}catch(c){}return this.nativeSel.addRange(this.nativeRange),this},_updateBoundary:function(){var a=this.nativeRange;return this.startContainer=a.startContainer, this.startContainer=a.startContainer,this.endContainer=a.endContainer,this.startOffset=a.startOffset,this.endOffset=a.endOffset,this.collapsed=a.collapsed,this},setStartOffset:function(a){return b(this,a,"Start"),this},setEndOffset:function(a){return b(this,a,"End"),this},setStart:function(a,b){return this.nativeRange.setStart(a,b),this._updateBoundary(),this},setStartAfter:function(a){return this.setStart(a.parentNode,utils.getNodeIndex(a)+1)},setStartBefore:function(a){return this.setStart(a.parentNode,utils.getNodeIndex(a))},setEnd:function(a,b){return this.nativeRange.setEnd(a,b),this._updateBoundary(),this},update:function(){return this.updateNativeRange()._updateBoundary(),this},getStart:function(){return this.update(),{startContainer:this.startContainer,startOffset:this.startOffset}},getStartOffset:function(){return a(this,"start")},getEndOffset:function(){return a(this,"end")},collapse:function(a){return this.nativeRange.collapse(a===!0),this._updateBoundary(),this},isCollapsed:function(){return this._updateBoundary(),this.collapsed},insertNode:function(a){return this.nativeRange.insertNode(a),this._updateBoundary()},updateNativeRange:function(){return this.nativeRange=this.nativeSel.getRangeAt(0),this},clear:function(){return this.nativeSel.removeAllRanges(),this}}}()),Minder.Receiver=kity.createClass("Receiver",{clear:function(){return this.container.innerHTML="",this.selection&&this.selection.setHide(),this.range&&this.range.clear(),this.index=0,this},constructor:function(a,b,c){this.setKityMinder(a);var d=document.createElement("div");d.setAttribute("contenteditable",!0),d.className="km_receiver",this.container=d,utils.addCssRule("km_receiver_css"," .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;"+(/\?debug#?/.test(location.href)?"":"clip:rect(1em 1em 1em 1em);")),this.index=0,this.selection=b,this.range=c,this.range.container=d},setRange:function(a,b){this.index=b||this.index,this.range=a,a.setStartOffset(this.index),a.collapse(!0);var c=this;return setTimeout(function(){c.container.focus(),a.select()}),this},setTextGroup:function(a){return this.textGroup=a,this},setKityMinder:function(a){return this.km=a,this},updateByMinderNode:function(a){return this.setMinderNode(a),this._addSelection(),this.setTextGroup(a.getTextGroup()),this.setContainerStyle(),this.updateTextOffsetData(),this.setSelectionHeight(),this.setContainerTxt(),this},setMinderNode:function(a){return this.minderNode=a,this.selection.setMinderNode(a),this},_addSelection:function(){return this.selection.container&&this.selection.remove(),this.minderNode.getRenderContainer().addShape(this.selection),this},getMinderNode:function(){return this.minderNode},updateIndex:function(){return this.index=this.range.getStartOffset(),this},setSelection:function(a){return this.selection=a,this},updateSelection:function(a){return this.selection.update(this.textData,a),this},getOffsetByIndex:function(a){return utils.getValueByIndex(this.textData,void 0!==a?a:this.index)},getBaseOffset:function(){var a=this.textGroup.getRenderBox("screen");return a},setContainerStyle:function(){var a=this.getBaseOffset();return this.container.style.cssText=";left:"+(browser.ipad?"-":"")+a.x+"px;top:"+(a.y+(/\?debug#?/.test(location.href)?this.textGroup.getItems().length*this.getlineHeight():0))+"px;width:"+a.width+"px;height:"+a.height+"px;",this},updateTextOffsetData:function(){var a,b=this,c=this.minderNode.getData("font-size")||this.minderNode.getStyle("font-size"),d=this.minderNode.getStyle("line-height")*c,e=(b.textGroup.getShapes().length*d-(d-c))/2;return this.textData=[],b.textGroup.eachItem(function(c,f){b.textData[c]=[];for(var g=c*d+1,h=f.getContent(),i=0,j=h.length;j>i;i++){try{a=f.getExtentOfChar(i)}catch(k){console.log(k)}b.textData[c].push({x:a.x,y:g-e,width:a.width,height:a.height})}0===h.length&&b.textData[c].push({x:0,y:g-e,width:0,height:d})}),this},getlineHeight:function(){return this.minderNode.getStyle("line-height")*(this.minderNode.getData("font-size")||this.minderNode.getStyle("font-size"))},updateIndexByMouse:function(a){var b=this;b.updateTextOffsetData(),this.index=0;var c=this.getlineHeight();return utils.each(this.textData,function(d,e){var f=e[0];return f.y<=a.y&&f.y+c>=a.y?(utils.each(e,function(c,d){return 0===c&&a.x<=d.x?!1:a.x>=d.x&&a.x<=d.x+d.width?(a.x-d.x>d.width/2?b.index+=c+1:b.index+=c,!1):c==e.length-1&&a.x>=d.x?(b.index+=1==e.length&&0===e[0].width?0:e.length,!1):void 0}),!1):void(b.index+=e.length+(1==e.length&&0===e[0].width?0:1))}),this.selection.setStartOffset(this.index).collapse(!0),this},setSelectionHeight:function(){return this.selection.setHeight(1*(this.minderNode.getData("font-size")||this.minderNode.getStyle("font-size"))),this},updateSelectionByMousePosition:function(a){var b=this,c=0,d=this.getlineHeight();return utils.each(this.textData,function(e,f){var g=f[0];return g.y<=a.y&&g.y+d>=a.y?(utils.each(f,function(b,d){return 0===b&&a.x<=d.x?!1:a.x>=d.x&&a.x<=d.x+d.width?(c+=b,a.x-d.x>d.width/2&&(c+=1),!1):b==f.length-1&&a.x>=d.x?(c+=1==f.length&&0===f[0].width?0:f.length,!1):void 0}),!1):g.y>a.y&&0===e?(c=0,!1):e==b.textData.length-1&&g.y+d/g,">")}return a?(a=b(a),a=a.replace(/[\n]/g,"
    ")):(a="",this.textGroup.eachItem(function(c,d){a+=b(d.getContent())+"
    "})),this.container.innerHTML=a,this},setReady:function(){this._ready=!0},clearReady:function(){this._ready=!1},isReady:function(){return this._ready},focus:function(){this.container.focus()},getTxtOfContainer:function(){var a="",b=this.container;return utils.each(b.childNodes,function(c,d){3==d.nodeType?a+=d.nodeValue.replace(/[\u200b]/g,""):d!==b.lastChild&&(a+="\n")}),a}}),Minder.Selection=kity.createClass("Selection",{base:kity.Path,constructor:function(a,b,c){this.callBase(),this.height=a||20,this.setAttr("id","_kity_selection"),this.width=2,this.fill("rgb(27,171,255)"),this.setHide(),this.timer=null,this.collapsed=!0,this.startOffset=this.endOffset=0,this.setOpacity(.5),this.setStyle("cursor","text"),this._show=!1,this.offset=[],this.setTranslate(-.5,-1.5)},setMinderNode:function(a){this.minderNode=a},setColor:function(a){this.fill(a)},updateOffsetByTextData:function(a,b){if(this.collapsed)return this.offset=utils.getValueByIndex(a,this.startOffset),this;var c=[],d={},e=this.startOffset,f=this.endOffset,g=0;return utils.each(a,function(a,b){return d={width:0,x:0,y:0},utils.each(b,function(a,b){if(g>=e&&f>=g)if(0===a||g===e)d.x=b.x,d.y=b.y,d.width=b.width;else if(f>g)d.width+=b.width;else if(g===f)return!1;g++}),void 0!==d.x&&c.push(d),g===f?!1:void((1!=b.length||0!==b[0].width)&&g++)}),this.offset=c,this},updatePosition:function(a){var b=this,c=Math.round,d=function(a,b,d,e){return["M",c(a),c(b),"h",c(d),"v",c(e),"h",-c(d),"v",-c(e),"z"]};if(a=void 0!==a?a:this.offset,this.collapsed){if(isNaN(a.x)||isNaN(a.y))return console&&console.warn("editor.selection.js 不正确的偏移位置"),this;this.setPathData(d(a.x,a.y,this.width,this.height))}else this.setPathData(a.reduce(function(a,c){return a.concat(d(c.x,c.y,c.width,b.height))},[]));return this._show=!0,this},collapse:function(a){return this.setOpacity(1),this.collapsed=!0,a?this.endOffset=this.startOffset:this.startOffset=this.endOffset,this},setStartOffset:function(a){return this.startOffset=a,this.startOffset>=this.endOffset?(this.collapse(!0),this):(this.collapsed=!1,this.setOpacity(.5),this)},setEndOffset:function(a){return this.endOffset=a,this.endOffset<=this.startOffset?(this.startOffset=a,this.collapse(!0),this):(this.collapsed=!1,this.setOpacity(.5),this)},update:function(a,b){return a&&this.updateOffsetByTextData(a,b),this.updatePosition(),this.setShow(),this},setHeight:function(a){return this.height=Math.round(a)+2,this},setHide:function(){return clearInterval(this.timer),this.setStyle("display","none"),this._show=!1,this},setHoldShow:function(){return this.setStyle("display",""),clearInterval(this.timer),this},setShow:function(){this.bringTop(),clearInterval(this.timer);var a=this,b="";return a.setStyle("display",""),a._show=!0,this.collapsed&&(a.setOpacity(1),this.timer=setInterval(function(){a.setStyle("display",b),b=b?"":"none"},400)),this},setShowStatus:function(){return this._show=!0,this},isShow:function(){return this._show},isHide:function(){return!this._show}}),KityMinder.registerModule("basestylemodule",function(){function a(a,b){return a.getData(b)||a.getStyle(b)}var b=this;return KityMinder.TextRenderer.registerStyleHook(function(b,c){var d=a(b,"font-weight"),e=a(b,"font-style");[d,e].join("/");c.eachItem(function(a,b){b.setFont({weight:d,style:e})})}),{commands:{bold:kity.createClass("boldCommand",{base:Command,execute:function(a){var b=a.getSelectedNodes();1==this.queryState("bold")?utils.each(b,function(a,b){b.setData("font-weight").render()}):utils.each(b,function(a,b){b.setData("font-weight","bold").render()}),a.layout()},queryState:function(){var a=b.getSelectedNodes(),c=0;return 0===a.length?-1:(utils.each(a,function(a,b){return b&&b.getData("font-weight")?(c=1,!1):void 0}),c)}}),italic:kity.createClass("italicCommand",{base:Command,execute:function(a){var b=a.getSelectedNodes();1==this.queryState("italic")?utils.each(b,function(a,b){b.setData("font-style").render()}):utils.each(b,function(a,b){b.setData("font-style","italic").render()}),a.layout()},queryState:function(){var a=b.getSelectedNodes(),c=0;return 0===a.length?-1:(utils.each(a,function(a,b){return b&&b.getData("font-style")?(c=1,!1):void 0}),c)}})},commandShortcutKeys:{bold:"ctrl+b",italic:"ctrl+i"}}}),KityMinder.registerModule("fontmodule",function(){function a(a,b){return a.getData(b)||a.getStyle(b)}return KityMinder.TextRenderer.registerStyleHook(function(b,c){var d=b.getData("color"),e=b.getStyle("selected-color"),f=b.getStyle("color"),g=d||(b.isSelected()&&e?e:f),h=a(b,"font-family"),i=a(b,"font-size"),j=[h,i].join("/");c.fill(g),b.setTmpData("fore-color",g.toString()),c.eachItem(function(a,b){b.setFont({family:h,size:i})}),b.setTmpData("font-hash",j)}),{defaultOptions:{fontfamily:[{name:"宋体",val:"宋体,SimSun"},{name:"微软雅黑",val:"微软雅黑,Microsoft YaHei"},{name:"楷体",val:"楷体,楷体_GB2312,SimKai"},{name:"黑体",val:"黑体, SimHei"},{name:"隶书",val:"隶书, SimLi"},{name:"Andale Mono",val:"andale mono"},{name:"Arial",val:"arial,helvetica,sans-serif"},{name:"arialBlack",val:"arial black,avant garde"},{name:"Comic Sans Ms",val:"comic sans ms"},{name:"Impact",val:"impact,chicago"},{name:"Times New Roman",val:"times new roman"},{name:"Sans-Serif",val:"sans-serif"}],fontsize:[10,12,16,18,24,32,48]},commands:{forecolor:kity.createClass("fontcolorCommand",{base:Command,execute:function(a,b){var c=a.getSelectedNodes();utils.each(c,function(a,c){c.setData("color",b),c.render()})},queryState:function(a){return 0==a.getSelectedNodes().length?-1:0},queryValue:function(a){return 1==a.getSelectedNodes().length?a.getSelectedNodes()[0].getData("color"):"mixed"}}),background:kity.createClass("backgroudCommand",{base:Command,execute:function(a,b){var c=a.getSelectedNodes();utils.each(c,function(a,c){c.setData("background",b),c.render()})},queryState:function(a){return 0==a.getSelectedNodes().length?-1:0},queryValue:function(a){return 1==a.getSelectedNodes().length?a.getSelectedNodes()[0].getData("background"):"mixed"}}),fontfamily:kity.createClass("fontfamilyCommand",{base:Command,execute:function(a,b){var c=a.getSelectedNodes();utils.each(c,function(c,d){d.setData("font-family",b),d.render(),a.layout()})},queryState:function(a){return 0===a.getSelectedNodes().length?-1:0},queryValue:function(a){var b=a.getSelectedNode();return b?b.getData("font-family"):null}}),fontsize:kity.createClass("fontsizeCommand",{base:Command,execute:function(a,b){var c=a.getSelectedNodes();utils.each(c,function(c,d){d.setData("font-size",b),d.render(),a.layout(300)})},queryState:function(a){return 0==a.getSelectedNodes().length?-1:0},queryValue:function(a){var b=a.getSelectedNode();return b?b.getData("font-size"):null}})}}}),KityMinder.registerModule("Zoom",function(){function a(){var a=e._zoomValue>=100?"optimize-speed":"geometricPrecision";e.getRenderContainer().setAttr("text-rendering",a)}function b(a){var b=a.shapeNode,c=b.getCTM(),d=new kity.Matrix(c.a,c.b,c.c,c.d,(0|c.e)+.5,(0|c.f)+.5);b.setAttribute("transform","matrix("+d.toString()+")")}function c(b,c){var e=b.getPaper();e.getViewPort();if(c){if(a(),b.getRoot().getComplex()>200)b._zoomValue=c,b.zoom(c),b.fire("viewchange");else{var f=new kity.Animator({beginValue:b._zoomValue,finishValue:c,setter:function(a,b){a.zoom(b)}});b._zoomValue=c,d&&d.pause(),d=f.start(b,300,"easeInOutSine"),d.on("finish",function(){b.fire("viewchange")})}b.fire("zoom",{zoom:c})}}var d,e=this;e.setDefaultOptions("zoom",[10,20,30,50,80,100,120,150,200]),kity.extendClass(Minder,{zoom:function(a){var c=this.getPaper(),d=c.getViewPort();d.zoom=a/100,d.center={x:d.center.x,y:d.center.y},c.setViewPort(d),100==a&&b(c)},getZoomValue:function(){return this._zoomValue}});var f=kity.createClass("Zoom",{base:Command,execute:c,queryValue:function(a){return a._zoomValue}}),g=kity.createClass("ZoomInCommand",{base:Command,execute:function(a){c(a,this.nextValue(a))},queryState:function(a){return+!this.nextValue(a)},nextValue:function(a){var b,c=a.getOptions("zoom");for(b=0;ba._zoomValue)return c[b];return 0},enableReadOnly:!0}),h=kity.createClass("ZoomOutCommand",{base:Command,execute:function(a){c(a,this.nextValue(a))},queryState:function(a){return+!this.nextValue(a)},nextValue:function(a){var b,c=a.getOptions("zoom");for(b=c.length-1;b>=0;b--)if(c[b]100&&(clearTimeout(this._wheelZoomTimeout),this._wheelZoomTimeout=setTimeout(function(){c.getPaper()._zoom||1;0>b?c.execCommand("zoom-in"):b>0&&c.execCommand("zoom-out")},100),a.originEvent.preventDefault())}}},commandShortcutKeys:{"zoom-in":"ctrl+=","zoom-out":"ctrl+-"}}}),KityMinder.registerModule("hyperlink",function(){var a="M16.614,10.224h-1.278c-1.668,0-3.07-1.07-3.599-2.556h4.877c0.707,0,1.278-0.571,1.278-1.278V3.834 c0-0.707-0.571-1.278-1.278-1.278h-4.877C12.266,1.071,13.668,0,15.336,0h1.278c2.116,0,3.834,1.716,3.834,3.834V6.39 C20.448,8.508,18.73,10.224,16.614,10.224z M5.112,5.112c0-0.707,0.573-1.278,1.278-1.278h7.668c0.707,0,1.278,0.571,1.278,1.278 S14.765,6.39,14.058,6.39H6.39C5.685,6.39,5.112,5.819,5.112,5.112z M2.556,3.834V6.39c0,0.707,0.573,1.278,1.278,1.278h4.877 c-0.528,1.486-1.932,2.556-3.599,2.556H3.834C1.716,10.224,0,8.508,0,6.39V3.834C0,1.716,1.716,0,3.834,0h1.278 c1.667,0,3.071,1.071,3.599,2.556H3.834C3.129,2.556,2.556,3.127,2.556,3.834z";return{commands:{hyperlink:kity.createClass("hyperlink",{base:Command,execute:function(a,b,c){var d=a.getSelectedNodes();utils.each(d,function(a,d){d.setData("hyperlink",b),d.setData("hyperlinkTitle",c),d.render()}),a.layout()},queryState:function(a){var b=a.getSelectedNodes(),c=0;return 0===b.length?-1:(utils.each(b,function(a,b){return b&&b.getData("hyperlink")?(c=0,!1):void 0}),c)},queryValue:function(a){var b=a.getSelectedNode();return{url:b.getData("hyperlink"),title:b.getData("hyperlinkTitle")}}}),unhyperlink:kity.createClass("hyperlink",{base:Command,execute:function(a){var b=a.getSelectedNodes();utils.each(b,function(a,b){b.setData("hyperlink"),b.render()}),a.layout()},queryState:function(a){var b=a.getSelectedNodes();if(0===b.length)return-1;var c=!1;return utils.each(b,function(a,b){return b.getData("hyperlink")?(c=!0,!1):void 0}),c?0:-1}})},renderers:{right:kity.createClass("hyperlinkrender",{base:KityMinder.Renderer,create:function(){var b=new kity.HyperLink,c=new kity.Path,d=new kity.Rect(24,22,-2,-6,4).fill("rgba(255, 255, 255, 0)");return c.setPathData(a).fill("#666"),b.addShape(d),b.addShape(c),b.setTarget("_blank"),b.setStyle("cursor","pointer"),b.on("mouseover",function(){d.fill("rgba(255, 255, 200, .8)")}).on("mouseout",function(){d.fill("rgba(255, 255, 255, 0)")}),b},shouldRender:function(a){return a.getData("hyperlink")},update:function(a,b,c){var d=b.getData("hyperlink");a.setHref(d);var e=b.getData("hyperlinkTitle");e=e?[e,"(",d,")"].join(""):d,a.node.setAttributeNS("http://www.w3.org/1999/xlink","title",e);var f=b.getStyle("space-right");return a.setTranslate(c.right+f+2,-5),new kity.Box({x:c.right+f,y:-11,width:24,height:22})}})}}}),kity.extendClass(MinderNode,{arrange:function(a){var b=this.parent;if(b){var c=b.children;if(!(0>a||a>=c.length))return c.splice(this.getIndex(),1),c.splice(a,0,this),this}}});var ArrangeUpCommand=kity.createClass("ArrangeUpCommand",{base:Command,execute:function(a){var b=a.getSelectedNodes();b.sort(asc);var c=b.map(function(a){return a.getIndex()});b.forEach(function(a,b){a.arrange(c[b]-1)}),a.layout(300)},queryState:function(a){var b=a.getSelectedNode();return b?0:-1}}),ArrangeDownCommand=kity.createClass("ArrangeUpCommand",{base:Command,execute:function(a){var b=a.getSelectedNodes();b.sort(desc);var c=b.map(function(a){return a.getIndex()});b.forEach(function(a,b){a.arrange(c[b]+1)}),a.layout(300)},queryState:function(a){var b=a.getSelectedNode();return b?0:-1}}),ArrangeCommand=kity.createClass("ArrangeCommand",{base:Command,execute:function(a,b,c){if(b=b&&b.slice()||a.getSelectedNodes().slice(),b.length){var d=MinderNode.getCommonAncestor(b);if(d==b[0].parent){var e=b.map(function(a){return{index:a.getIndex(),node:a}}),f=Math.min.apply(Math,e.map(function(a){return a.index}))>=c;e.sort(function(a,b){return f?b.index-a.index:a.index-b.index}),e.forEach(function(a){a.node.arrange(c)}),a.layout(300)}}},queryState:function(a){var b=a.getSelectedNode();return b?0:-1}});KityMinder.registerModule("ArrangeModule",{commands:{arrangeup:ArrangeUpCommand,arrangedown:ArrangeDownCommand,arrange:ArrangeCommand},contextmenu:[{command:"arrangeup"},{command:"arrangedown"},{divider:!0}],commandShortcutKeys:{arrangeup:"normal::alt+Up",arrangedown:"normal::alt+Down"}}),KityMinder.registerModule("ClipboardModule",function(){function a(b,d){e.push(d),c.appendNode(d,b),d.render(),d.setLayoutOffset(null);for(var f,g=utils.cloneArr(d.children),h=0;f=g[h];h++)a(d,f)}function b(a){a.length&&(a.sort(function(a,b){return a.getIndex()-b.getIndex()}),d=a.map(function(a){return a.clone()}))}var c=this,d=[],e=[],f=kity.createClass("CopyCommand",{base:Command,execute:function(a){b(a.getSelectedAncestors(!0)),this.setContentChanged(!1)}}),g=kity.createClass("CutCommand",{base:Command,execute:function(a){var c=a.getSelectedAncestors();0!==c.length&&(b(c),a.select(MinderNode.getCommonAncestor(c),!0),c.slice().forEach(function(b){a.removeNode(b)}),a.layout(300))}}),h=kity.createClass("PasteCommand",{base:Command,execute:function(b){if(d.length){var c=b.getSelectedNode();if(!c)return;for(var f,g=0;f=d[g];g++)a(c,f.clone());b.select(e,!0),e=[],b.layout(300)}},queryState:function(a){return a.getSelectedNode()?0:-1}});return{commands:{copy:f,cut:g,paste:h},commandShortcutKeys:{copy:"normal::ctrl+c|",cut:"normal::ctrl+x",paste:"normal::ctrl+v"}}}),KityMinder.registerModule("StyleModule",function(){function a(a){for(var c=a.getData(),d=0;d0)for(var g in f)e=b[f[g].marker_id],e&&(d.data[e[0]]=e[1]);else e=b[f.marker_id],e&&(d.data[e[0]]=e[1])}a["xlink:href"]&&(d.data.hyperlink=a["xlink:href"]);var h=a.children&&a.children.topics,i=h&&(h.topic||h[0]&&h[0].topic);if(i){var j=i;if(j.length&&j.length>0){d.children=[];for(var g in j)d.children.push({}),c(j[g],d.children[g])}else d.children=[{}],c(j,d.children[0])}}function d(a){var b=$.xml2json(a),d={},e=b.sheet,f=utils.isArray(e)?e[0].topic:e.topic;return c(f,d),d}function e(a,b){return new Promise(function(b,c){zip.createReader(new zip.BlobReader(a),function(a){a.getEntries(b)},c)})}function f(a){return new Promise(function(b,c){for(var e,f;(e=a.pop())&&"content.xml"!=e.filename.split("/").pop();)e=null;e?e.getData(new zip.TextWriter,function(a){try{f=d($.parseXML(a)),b(f)}catch(e){c(e)}}):c(new Error("Content document missing"))})}return e(a).then(f)},encode:function(a,b,c){function d(){return new Promise(function(a,b){var c=new XMLHttpRequest;c.open("POST",f),c.responseType="blob",c.onload=a,c.onerror=b;var d=new FormData;d.append("type","xmind"),d.append("data",g),c.send(d)}).then(function(a){return a.target.response})}function e(){function a(a,b){var c=document.createElement("input");return c.type="hidden",c.name=a,c.value=b,c}var b=c.filename||"xmind.xmind",d=document.createElement("form");d.setAttribute("action",f),d.setAttribute("method","POST"),d.appendChild(a("filename",b)),d.appendChild(a("type","xmind")),d.appendChild(a("data",g)),d.appendChild(a("download","1")),document.body.appendChild(d),d.submit(),document.body.removeChild(d)}var f="native-support/export.php",g=JSON.stringify(a);return c&&c.download?e():d()},recognizePriority:-1}}),KityMinder.registerProtocol("freemind",function(a){function b(a,c){c.data={text:a.TEXT};var e;if(a.icon){var f,g=a.icon;if(g.length&&g.length>0)for(e in g)f=d[g[e].BUILTIN],f&&(c.data[f[0]]=f[1]);else f=d[g.BUILTIN],f&&(c.data[f[0]]=f[1])}if(a.LINK&&(c.data.hyperlink=a.LINK),a.node){var h=a.node;if(h.length&&h.length>0){c.children=[];for(e in h)c.children.push({}),b(h[e],c.children[e])}else c.children=[{}],b(h,c.children[0])}}function c(a){var c=$.xml2json(a),d={};return b(c.node,d),d}var d={"full-1":["priority",1],"full-2":["priority",2],"full-3":["priority",3],"full-4":["priority",4],"full-5":["priority",5],"full-6":["priority",6],"full-7":["priority",7],"full-8":["priority",8]};return{fileDescription:"Freemind 格式",fileExtension:".mm",dataType:"text",decode:function(a){return new Promise(function(b,d){try{b(c(a))}catch(e){d(new Error("XML 文件损坏!"))}})},encode:function(a,b,c){function d(){return new Promise(function(a,b){var c=new XMLHttpRequest;c.open("POST",f),c.responseType="blob",c.onload=a,c.onerror=b;var d=new FormData;d.append("type","freemind"),d.append("data",g),c.send(d)}).then(function(a){return a.target.response})}function e(){function a(a,b){var c=document.createElement("input");return c.type="hidden",c.name=a,c.value=b,c}var b=c.filename||"freemind.mm",d=document.createElement("form");d.setAttribute("action",f),d.setAttribute("method","POST"),d.appendChild(a("filename",b)),d.appendChild(a("type","freemind")),d.appendChild(a("data",g)),d.appendChild(a("download","1")),document.body.appendChild(d),d.submit(),document.body.removeChild(d)}var f="native-support/export.php",g=JSON.stringify(a);return c&&c.download?e():d()}}}),KityMinder.registerProtocol("mindmanager",function(a){function b(a,c){if(c.data={text:a.Text&&a.Text.PlainText||""},a.Task){var d;a.Task.TaskPriority&&(d=f[a.Task.TaskPriority],d&&(c.data[d[0]]=d[1])),a.Task.TaskPercentage&&(d=f[a.Task.TaskPercentage],d&&(c.data[d[0]]=d[1]))}if(a.Hyperlink&&(c.data.hyperlink=a.Hyperlink.Url),a.SubTopics&&a.SubTopics.Topic){var e=a.SubTopics.Topic;if(e.length&&e.length>0){c.children=[];for(var g in e)c.children.push({}),b(e[g],c.children[g])}else c.children=[{}],b(e,c.children[0])}}function c(a){var c=$.xml2json(a),d={};return b(c.OneTopic.Topic,d),d}function d(a){return new Promise(function(b,c){zip.createReader(new zip.BlobReader(a),function(a){a.getEntries(b)},c)})}function e(a){return new Promise(function(b,d){for(var e,f;(e=a.pop())&&"Document.xml"!=e.filename.split("/").pop();)e=null;e?e.getData(new zip.TextWriter,function(a){f=c($.parseXML(a)),b(f)}):d(new Error("Main document missing"))})}var f={"urn:mindjet:Prio1":["PriorityIcon",1],"urn:mindjet:Prio2":["PriorityIcon",2],"urn:mindjet:Prio3":["PriorityIcon",3],"urn:mindjet:Prio4":["PriorityIcon",4],"urn:mindjet:Prio5":["PriorityIcon",5],0:["ProgressIcon",1],25:["ProgressIcon",2],50:["ProgressIcon",3],75:["ProgressIcon",4],100:["ProgressIcon",5]};return{fileDescription:"MindManager 格式",fileExtension:".mmap",dataType:"blob",decode:function(a){return d(a).then(e)},encode:null,recognizePriority:-1}}),KityMinder.registerProtocol("plain",function(a){function b(a,b){for(var c="";b--;)c+=a;return c}function c(a,d){var e="";return d=d||0,e+=b(j,d),e+=a.data.text+h,a.children&&a.children.forEach(function(a){e+=c(a,d+1)}),e}function d(a){return!/\S/.test(a)}function e(a){for(var b=0;a.charAt(b)===j;)b++;return b}function f(a){return{data:{text:a.replace(new RegExp("^"+j+"*"),"")}}}function g(a,b){function c(a,b){var c=a.children||(a.children=[]);c.push(b)}var g,h,j,k,l,m={},n=a.split(i);b?(m[0]=g=f("root"),h=1):h=0;for(var o=0;oj+1?k&&f(k,c):(j=d.level,k=e(d.content,n[j-1]),n[j]=k));return h(n[1]),n[1]}function e(a,b){var c={data:{text:a,note:""}};return b&&(b.children?b.children.push(c):b.children=[c]),c}function f(a,b){a.data.note+=b+"\n"}function g(a){var b=/^(#+)?\s*(.*)$/.exec(a);return{level:b[1]&&b[1].length||null,content:b[2],noteStart:a==k,noteClose:a==l,codeBlock:/^\s*```/.test(a)}}function h(a){if(/\S/.test(a.data.note)){for(var b=a.data.note.split("\n");b.length&&!/\S/.test(b[0]);)b.shift();for(;b.length&&!/\S/.test(b[b.length-1]);)b.pop();a.data.note=b.join("\n")}else a.data.note=null,delete a.data.note;a.children&&a.children.forEach(h)}var i=/\r\n|\r|\n/,j="",k="",l="";return{fileDescription:"Markdown/GFM 格式",fileExtension:".md",mineType:"text/markdown",dataType:"text",encode:function(b){return a(b)},decode:function(a){return d(a)},recognizePriority:-1}}),KityMinder.registerProtocol("json",function(a){return{fileDescription:"KityMinder 格式",fileExtension:".km",dataType:"text",mineType:"application/json",encode:function(a){return JSON.stringify(a)},decode:function(a){return JSON.parse(a)}}}),kity.Browser.ie||KityMinder.registerProtocol("png",function(a){function b(a,b){return new Promise(function(b,c){var d=document.createElement("img");d.onload=function(){b(this)},d.onerror=function(a){c(a)},d.crossOrigin="",d.src=a})}function c(){var b,c,d,f,g,h=a.getPaper(),i=(h.container,a.getRenderContainer()),j=i.getRenderBox(),k=j.width+1,l=j.height+1;return b=h.shapeNode.getAttribute("transform"),h.shapeNode.setAttribute("transform","translate(0.5, 0.5)"),i.translate(-j.x,-j.y),c=h.container.innerHTML,i.translate(j.x,j.y),h.shapeNode.setAttribute("transform",b),d=$(c).filter("svg"),d.attr({width:j.width+1,height:j.height+1,style:'font-family: Arial, "Microsoft Yahei","Heiti SC";'}),c=$("
    ").append(d).html(),c=c.replace(' xmlns="http://www.w3.org/2000/svg" xmlns:NS1="" NS1:ns1:xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:NS2="" NS2:xmlns:ns1=""',""),c=c.replace(/ /g," "),f=new Blob([c],{type:"image/svg+xml"}),g=e.createObjectURL(f),{width:k,height:l,dataUrl:g,xml:c}}function d(d){function f(a,b){a.save(),a.fillStyle=b,a.fillRect(0,0,j.width,j.height),a.restore()}function g(a,b,c,d){a.drawImage(b,c,d)}function h(a){try{var b=a.toDataURL("png");return b}catch(c){throw new Error("当前浏览器版本不支持导出 PNG 功能,请尝试升级到最新版本!")}}function i(){return"undefined"!=typeof window.canvg?new Promise(function(a){window.canvg(j,o.xml,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:s,offsetY:s,renderCallback:function(){a(h(j))}})}):b(r).then(function(a){return g(k,a,s,s),e.revokeObjectURL(r),h(j)})}var j=document.createElement("canvas"),k=j.getContext("2d"),l=a.getStyle("background").toString(),m=/url\((.+)\)/.exec(l),n=kity.Color.parse(l),o=c(),p=o.width,q=o.height,r=o.dataUrl,s=20;return j.width=p+2*s,j.height=q+2*s,m?b(m[1]).then(function(a){return f(k,k.createPattern(a,"repeat")),i()}):(f(k,n.toString()),i())}var e=window.URL||window.webkitURL||window;return{fileDescription:"PNG 图片",fileExtension:".png",mineType:"image/png",dataType:"base64",encode:d,recognizePriority:-1}}),kity.Browser.ie||KityMinder.registerProtocol("svg",function(a){return{fileDescription:"SVG 矢量图",fileExtension:".svg",mineType:"image/svg+xml",dataType:"text",encode:function(b){var c,d,e=a.getPaper(),f=e.shapeNode.getAttribute("transform"),g=a.getRenderContainer(),h=g.getRenderBox(),i=(g.getTransform(),h.width),j=h.height,k=20;return e.shapeNode.setAttribute("transform","translate(0.5, 0.5)"),c=e.container.innerHTML,e.shapeNode.setAttribute("transform",f), d=$(c).filter("svg"),d.attr({width:i+2*k|0,height:j+2*k|0,style:'font-family: Arial, "Microsoft Yahei", "Heiti SC"; background: '+a.getStyle("background")}),d[0].setAttribute("viewBox",[h.x-k|0,h.y-k|0,i+2*k|0,j+2*k|0].join(" ")),c=$("
    ").append(d).html(),c=$("
    ").append(d).html(),c=c.replace(/ /g," ")},recognizePriority:-1}}),function(){var a=[];KityMinder.registerUI=function(b,c,d){"function"==typeof c&&(d=c,c=null),a.push({id:b,ui:d,deps:c})},kity.extendClass(Minder,{initUI:function(){var b=this._ui={},c=this;a.forEach(function(a){var d=a.deps;d&&(d=d.map(function(a){return c.getUI(a)})),b[a.id]=a.ui.apply(null,[c].concat(d||[]))}),$("#content-wrapper").delegate("#panel, #tab-container, .fui-dialog, #main-menu","keydown keyup",function(a){a.stopPropagation()}),$("#content-wrapper").delegate("input","mousedown mousemove mouseup contextmenu",function(a){a.stopPropagation()}),c.getPaper().addClass("loading-target"),this.fire("interactchange"),this.fire("uiready")},getUI:function(a){return this._ui[a]}}),$.ajaxSetup({cache:!1}),$.extend($,{pajax:function(){var a=$.ajax.apply($,arguments);return new Promise(function(b,c){a.done(b),a.fail(function(a,b,d){var e=new Error(b);e.getDetail=function(){try{return"jQuery XHR Error: \n"+JSON.stringify(d)}catch(a){return d}},c(e)})})}}),$(function(){var a=["kmcat_warn.png","kmcat_sad.png","icons.png","template_large.png","history.png","feedback.png","iconpriority.png","iconprogress.png","template.png","layout.png","next-level.png","prev-level.png"];a.forEach(function(a){(new Image).src="ui/theme/default/images/"+a})})}(),KityMinder.registerUI("eve",function(a){return{setup:function(a){var b={};return a.on=function(a,c){var d=b[a]||(b[a]=[]);return d.push(c),this},a.off=function(a,c){var d=b[a];if(d){var e=d.indexOf(c);~e?d.splice(e,1):c[a]=null}return this},a.once=function(b,c){return this.on(b,function d(){c.apply(a,arguments),a.off(b,d)})},a.fire=function(c){var d=b[c],e=[].slice.call(arguments,1);return d&&d.forEach(function(b){b.apply(a,e)}),this},a}}}),KityMinder.registerUI("memory",function(){var a=window.localStorage,b=a.uiMemory?JSON.parse(a.uiMemory):{};return{get:function(a){return b[a]||null},set:function(c,d){b[c]=d,a.uiMemory=JSON.stringify(b)}}}),kity.extendClass(FUI.Widget,{setEnable:function(a){a===!1?this.disable():this.enable()},setActive:function(a){a===!1?this.removeClass("active"):this.addClass("active")},bindExecution:function(a,b){var c=this;c.on(a,function(){c.interactFlag||b.apply(c,arguments)})},bindCommandState:function(a,b,c){var d=this;a.on("interactchange",function(){if(d.interactFlag=!0,c){var a=this.queryCommandValue(b);a!=d.lastHandleCommandValue&&(c.call(d,a),d.lastHandleCommandValue=a)}d.setEnable(-1!==this.queryCommandState(b)),d.setActive(1===this.queryCommandState(b)),d.interactFlag=!1})}}),KityMinder.registerUI("axss",function(){function a(a){var b=document.createElement("div");b.innerHTML=a,$(b).find("script, iframe, link").remove();for(var c in b)0===c.indexOf("on")&&b.removeAttribute(c);return b.innerHTML}return a}),KityMinder.registerUI("fiox",function(a){var b=a.getUI("eve");b.setup(fio.user),fio.user.init({apiKey:"wiE55BGOG8BkGnpPs6UNtPbb"})}),KityMinder.registerUI("widget/commandbutton",function(a){return{generate:function(b,c){var d=new FUI.Button({label:a.getLang("ui.command."+b)||a.getLang("ui."+b),text:a.getLang("ui.command."+b)||a.getLang("ui."+b),className:["command-widget","command-button",b]});return d.bindExecution("click",c||function(){a.execCommand(b)}),d.bindCommandState(a,b),d}}}),KityMinder.registerUI("widget/commandbuttonset",function(a){function b(b,c){return c.map(function(c){var d=a.getLang([b,c].join("."))||c;return{label:d,text:d,value:c,className:[b,c].join(" ")}})}function c(c,d){var e=new FUI.Buttonset({id:"template-set",buttons:"object"==typeof d[0]?d:b(c,d),className:["command-widget","command-buttonset",c].join(" ")});return e.bindExecution("change",function(){a.execCommand(c,e.getValue())}),e.bindCommandState(a,c,function(a){this.selectByValue(a)}),e}return{generate:c}}),KityMinder.registerUI("widget/commandinputmenu",function(a){function b(b,c){var d=new FUI.InputMenu({menu:{items:c},input:{placeholder:a.getLang("ui."+b)},className:["command-widget","command-inputmenu",b]});d.bindCommandState(a,b,function(a){d.selectByValue(a)||d.clearSelect()});var e=-1;return d.bindExecution("select",function(c,f){~f.index?a.execCommand(b,f.value):d.select(e),e=f.index}),d}return{generate:b}}),KityMinder.registerUI("widget/commandselectmenu",function(a){function b(b,c){return c.map(function(c){var d=a.getLang([b,c].join("."))||c;return{clazz:"Button",label:d,text:d,value:c,className:[b,c].join(" ")}})}function c(c,d,e){var f=new FUI.SelectMenu({widgets:"object"==typeof d[0]?d:b(c,d),className:["command-widget","command-selectmenu",c].join(" "),column:e||3});return f.bindExecution("change",function(){a.execCommand(c,f.getValue())}),f.bindCommandState(a,c,function(a){void 0!==a&&this.selectByValue(a)}),f}return{generate:c}}),KityMinder.registerUI("widget/notice",function(a){function b(a,b){function c(){var b=a.text(),c=new RegExp("at.+"+o+".+\\:(\\d+)\\:(\\d+)\\)?","g");a.text(b.replace(c,function(a,b,c){var d={line:+b,column:+c},e=m.originalPositionFor(d),f=e.name;d={line:e.line,column:e.column},e=l.originalPositionFor(d),f=f||"";var g="at "+f+" ("+e.source.replace("../","")+":"+e.line+":"+e.column+")";return-1!=g.indexOf("promise")&&(g="at Promise."+f),g}))}if(o){if(l)return c();b.addClass("loading"),setTimeout(function(){b.removeClass("loading")},5e3);var d=document.createElement("script");d.onload=function(){Promise.all([$.pajax({url:o.replace("min.js","js.map"),dataType:"json"}),$.pajax({url:o.replace(".js",".map"),dataType:"json"})]).then(function(a){l=new window.sourceMap.SourceMapConsumer(a[0]),m=new window.sourceMap.SourceMapConsumer(a[1]),c(),b.removeClass("loading")})},d.src="lib/source-map.min.js",document.head.appendChild(d)}}function c(b,d,e){j.hasClass("show")||j.empty(),clearTimeout(c.ttl2),d?j.addClass("warn"):j.removeClass("warn");var f=a.getUI("menu/menu");j.css({top:f&&f.isVisible()?$("#main-menu .main-menu-level1").offset().top:$("#kityminder").offset().top+20}),j.append($("

    ").text(b)),j.addClass("show"),clearTimeout(c.ttl),e=e||(d?5e3:3e3),c.ttl=setTimeout(function(){j.removeClass("show"),c.ttl2=setTimeout(function(){j.empty()},1e3)},e)}function d(a){c(a,d)}function e(a){return a=a||new Error,"string"==typeof a&&(a=new Error(a)),a.getDetail?a:("undefined"!=typeof fio&&a instanceof fio.FileRequestError?(a.status?a.description=h.pcs_code[a.detail.error_code]:a.description=h.err_network,a.getDetail=function(){return JSON.stringify(a,null,4)}):"readyState"in a||(a.getDetail=function(){return a.stack||(new Error).stack}),a)}function f(c,d){1==arguments.length&&(d=c,c="unknown"),n.empty(),d=e(d);var j=$("

    ").addClass("error-content").appendTo(n);$("

    ").text(h[c]||h.err_unknown).appendTo(j),$("

    ").text(d.message||d.description||h.unknownreason).appendTo(j);if(d.getDetail){var l=$("

    ").addClass("error-detail").append($('').text(a.getLang("ui.error_detail"))).appendTo(n),m=$("
    ").addClass("error-detail-wrapper").appendTo(l),o=$("