(function(){var a={ol:1,ul:1},b=/^[\n\r\t ]*$/;CKEDITOR.plugins.list={listToArray:function(q,r,s,t,u){if(!a[q.getName()])return[];if(!t)t=0;if(!s)s=[];for(var v=0,w=q.getChildCount();v<w;v++){var x=q.getChild(v);if(x.$.nodeName.toLowerCase()!='li')continue;var y={parent:q,indent:t,element:x,contents:[]};if(!u){y.grandparent=q.getParent();if(y.grandparent&&y.grandparent.$.nodeName.toLowerCase()=='li')y.grandparent=y.grandparent.getParent();}else y.grandparent=u;if(r)CKEDITOR.dom.element.setMarker(r,x,'listarray_index',s.length);s.push(y);for(var z=0,A=x.getChildCount(),B;z<A;z++){B=x.getChild(z);if(B.type==CKEDITOR.NODE_ELEMENT&&a[B.getName()])CKEDITOR.plugins.list.listToArray(B,r,s,t+1,y.grandparent);else y.contents.push(B);}}return s;},arrayToList:function(q,r,s,t){if(!s)s=0;if(!q||q.length<s+1)return null;var u=q[s].parent.getDocument(),v=new CKEDITOR.dom.documentFragment(u),w=null,x=s,y=Math.max(q[s].indent,0),z=null,A=t==CKEDITOR.ENTER_P?'p':'div';for(;;){var B=q[x];if(B.indent==y){if(!w||q[x].parent.getName()!=w.getName()){w=q[x].parent.clone(false,true);v.append(w);}z=w.append(B.element.clone(false,true));for(var C=0;C<B.contents.length;C++)z.append(B.contents[C].clone(true,true));x++;}else if(B.indent==Math.max(y,0)+1){var D=CKEDITOR.plugins.list.arrayToList(q,null,x,t);z.append(D.listNode);x=D.nextIndex;}else if(B.indent==-1&&!s&&B.grandparent){z;if(a[B.grandparent.getName()])z=B.element.clone(false,true);else if(t!=CKEDITOR.ENTER_BR&&B.grandparent.getName()!='td')z=u.createElement(A);else z=new CKEDITOR.dom.documentFragment(u);for(C=0;C<B.contents.length;C++)z.append(B.contents[C].clone(true,true));if(z.type==CKEDITOR.NODE_DOCUMENT_FRAGMENT&&x!=q.length-1){if(z.getLast()&&z.getLast().type==CKEDITOR.NODE_ELEMENT&&z.getLast().getAttribute('type')=='_moz')z.getLast().remove();z.appendBogus();}if(z.type==CKEDITOR.NODE_ELEMENT&&z.getName()==A&&z.$.firstChild){z.trim();var E=z.getFirst();if(E.type==CKEDITOR.NODE_ELEMENT&&E.isBlockBoundary()){var F=new CKEDITOR.dom.documentFragment(u);z.moveChildren(F);z=F;}}var G=z.$.nodeName.toLowerCase();if(!CKEDITOR.env.ie&&(G=='div'||G=='p'))z.appendBogus();v.append(z);w=null;x++;}else return null;if(q.length<=x||Math.max(q[x].indent,0)<y)break;}if(r){var H=v.getFirst();while(H){if(H.type==CKEDITOR.NODE_ELEMENT)CKEDITOR.dom.element.clearMarkers(r,H);H=H.getNextSourceNode();}}return{listNode:v,nextIndex:x};}};function c(q,r){q.getCommand(this.name).setState(r);};function d(q){var r=q.data.path,s=r.blockLimit,t=r.elements,u;
for(var v=0;v<t.length&&(u=t[v])&&!u.equals(s);v++){if(a[t[v].getName()])return c.call(this,q.editor,this.type==t[v].getName()?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF);}return c.call(this,q.editor,CKEDITOR.TRISTATE_OFF);};function e(q,r,s,t){var u=CKEDITOR.plugins.list.listToArray(r.root,s),v=[];for(var w=0;w<r.contents.length;w++){var x=r.contents[w];x=x.getAscendant('li',true);if(!x||x.getCustomData('list_item_processed'))continue;v.push(x);CKEDITOR.dom.element.setMarker(s,x,'list_item_processed',true);}var y=r.root.getDocument().createElement(this.type);for(w=0;w<v.length;w++){var z=v[w].getCustomData('listarray_index');u[z].parent=y;}var A=CKEDITOR.plugins.list.arrayToList(u,s,null,q.config.enterMode),B,C=A.listNode.getChildCount();for(w=0;w<C&&(B=A.listNode.getChild(w));w++){if(B.getName()==this.type)t.push(B);}A.listNode.replace(r.root);};var f=/^h[1-6]$/;function g(q,r,s){var t=r.contents,u=r.root.getDocument(),v=[];if(t.length==1&&t[0].equals(r.root)){var w=u.createElement('div');t[0].moveChildren&&t[0].moveChildren(w);t[0].append(w);t[0]=w;}var x=r.contents[0].getParent();for(var y=0;y<t.length;y++)x=x.getCommonAncestor(t[y].getParent());for(y=0;y<t.length;y++){var z=t[y],A;while(A=z.getParent()){if(A.equals(x)){v.push(z);break;}z=A;}}if(v.length<1)return;var B=v[v.length-1].getNext(),C=u.createElement(this.type);s.push(C);while(v.length){var D=v.shift(),E=u.createElement('li');if(f.test(D.getName()))D.appendTo(E);else{D.copyAttributes(E);D.moveChildren(E);D.remove();}E.appendTo(C);if(!CKEDITOR.env.ie)E.appendBogus();}if(B)C.insertBefore(B);else C.appendTo(x);};function h(q,r,s){var t=CKEDITOR.plugins.list.listToArray(r.root,s),u=[];for(var v=0;v<r.contents.length;v++){var w=r.contents[v];w=w.getAscendant('li',true);if(!w||w.getCustomData('list_item_processed'))continue;u.push(w);CKEDITOR.dom.element.setMarker(s,w,'list_item_processed',true);}var x=null;for(v=0;v<u.length;v++){var y=u[v].getCustomData('listarray_index');t[y].indent=-1;x=y;}for(v=x+1;v<t.length;v++){if(t[v].indent>t[v-1].indent+1){var z=t[v-1].indent+1-t[v].indent,A=t[v].indent;while(t[v]&&t[v].indent>=A){t[v].indent+=z;v++;}v--;}}var B=CKEDITOR.plugins.list.arrayToList(t,s,null,q.config.enterMode),C=B.listNode,D,E;function F(G){if((D=C[G?'getFirst':'getLast']())&&!(D.is&&D.isBlockBoundary())&&(E=r.root[G?'getPrevious':'getNext'](CKEDITOR.dom.walker.whitespaces(true)))&&!(E.is&&E.isBlockBoundary({br:1})))q.document.createElement('br')[G?'insertBefore':'insertAfter'](D);};F(true);
F();C.replace(r.root);};function i(q,r){this.name=q;this.type=r;};i.prototype={exec:function(q){q.focus();var r=q.document,s=q.getSelection(),t=s&&s.getRanges();if(!t||t.length<1)return;if(this.state==CKEDITOR.TRISTATE_OFF){var u=r.getBody();u.trim();if(!u.getFirst()){var v=r.createElement(q.config.enterMode==CKEDITOR.ENTER_P?'p':q.config.enterMode==CKEDITOR.ENTER_DIV?'div':'br');v.appendTo(u);t=[new CKEDITOR.dom.range(r)];if(v.is('br')){t[0].setStartBefore(v);t[0].setEndAfter(v);}else t[0].selectNodeContents(v);s.selectRanges(t);}else{var w=t.length==1&&t[0],x=w&&w.getEnclosedNode();if(x&&x.is&&this.type==x.getName())c.call(this,q,CKEDITOR.TRISTATE_ON);}}var y=s.createBookmarks(true),z=[],A={};while(t.length>0){w=t.shift();var B=w.getBoundaryNodes(),C=B.startNode,D=B.endNode;if(C.type==CKEDITOR.NODE_ELEMENT&&C.getName()=='td')w.setStartAt(B.startNode,CKEDITOR.POSITION_AFTER_START);if(D.type==CKEDITOR.NODE_ELEMENT&&D.getName()=='td')w.setEndAt(B.endNode,CKEDITOR.POSITION_BEFORE_END);var E=w.createIterator(),F;E.forceBrBreak=this.state==CKEDITOR.TRISTATE_OFF;while(F=E.getNextParagraph()){var G=new CKEDITOR.dom.elementPath(F),H=G.elements,I=H.length,J=null,K=false,L=G.blockLimit,M;for(var N=I-1;N>=0&&(M=H[N]);N--){if(a[M.getName()]&&L.contains(M)){L.removeCustomData('list_group_object');var O=M.getCustomData('list_group_object');if(O)O.contents.push(F);else{O={root:M,contents:[F]};z.push(O);CKEDITOR.dom.element.setMarker(A,M,'list_group_object',O);}K=true;break;}}if(K)continue;var P=L;if(P.getCustomData('list_group_object'))P.getCustomData('list_group_object').contents.push(F);else{O={root:P,contents:[F]};CKEDITOR.dom.element.setMarker(A,P,'list_group_object',O);z.push(O);}}}var Q=[];while(z.length>0){O=z.shift();if(this.state==CKEDITOR.TRISTATE_OFF){if(a[O.root.getName()])e.call(this,q,O,A,Q);else g.call(this,q,O,Q);}else if(this.state==CKEDITOR.TRISTATE_ON&&a[O.root.getName()])h.call(this,q,O,A);}for(N=0;N<Q.length;N++){J=Q[N];var R,S=this;(R=function(T){var U=J[T?'getPrevious':'getNext'](CKEDITOR.dom.walker.whitespaces(true));if(U&&U.getName&&U.getName()==S.type){U.remove();U.moveChildren(J,T?true:false);}})();R(true);}CKEDITOR.dom.element.clearAllMarkers(A);s.selectBookmarks(y);q.focus();}};var j=CKEDITOR.dtd,k=/[\t\r\n ]*(?:&nbsp;|\xa0)$/;function l(q,r){var s,t=q.children,u=t.length;for(var v=0;v<u;v++){s=t[v];if(s.name&&s.name in r)return v;}return u;};function m(q){return function(r){var s=r.children,t=l(r,j.$list),u=s[t],v=u&&u.previous,w;if(v&&(v.name&&v.name=='br'||v.value&&(w=v.value.match(k)))){var x=v;
if(!(w&&w.index)&&x==s[0])s[0]=q||CKEDITOR.env.ie?new CKEDITOR.htmlParser.text('\xa0'):new CKEDITOR.htmlParser.element('br',{});else if(x.name=='br')s.splice(t-1,1);else x.value=x.value.replace(k,'');}};};var n={elements:{}};for(var o in j.$listItem)n.elements[o]=m();var p={elements:{}};for(o in j.$listItem)p.elements[o]=m(true);CKEDITOR.plugins.add('list',{init:function(q){var r=new i('numberedlist','ol'),s=new i('bulletedlist','ul');q.addCommand('numberedlist',r);q.addCommand('bulletedlist',s);q.ui.addButton('NumberedList',{label:q.lang.numberedlist,command:'numberedlist'});q.ui.addButton('BulletedList',{label:q.lang.bulletedlist,command:'bulletedlist'});q.on('selectionChange',CKEDITOR.tools.bind(d,r));q.on('selectionChange',CKEDITOR.tools.bind(d,s));},afterInit:function(q){var r=q.dataProcessor;if(r){r.dataFilter.addRules(n);r.htmlFilter.addRules(p);}},requires:['domiterator']});})();
