(function(){'use strict';var tools=CKEDITOR.tools,pastetools=CKEDITOR.plugins.pastetools,commonFilter=pastetools.filters.common,Style=commonFilter.styles,createAttributeStack=commonFilter.createAttributeStack,getElementIndentation=commonFilter.lists.getElementIndentation,invalidTags=['o:p','xml','script','meta','link'],shapeTags=['v:arc','v:curve','v:line','v:oval','v:polyline','v:rect','v:roundrect','v:group'],links={},inComment=0,plug={},List,Heuristics;CKEDITOR.plugins.pastetools.filters.word=plug;CKEDITOR.plugins.pastefromword=plug;plug.rules=function(html,editor,filter){var msoListsDetected=Boolean(html.match(/mso-list:\s*l\d+\s+level\d+\s+lfo\d+/)),shapesIds=[],rules={root:function(element){element.filterChildren(filter);CKEDITOR.plugins.pastefromword.lists.cleanup(List.createLists(element));},elementNames:[[(/^\?xml:namespace$/),''],[/^v:shapetype/,''],[new RegExp(invalidTags.join('|')),'']],elements:{'a':function(element){if(element.attributes.name){if(element.attributes.name=='_GoBack'){delete element.name;return;}
if(element.attributes.name.match(/^OLE_LINK\d+$/)){delete element.name;return;}}
if(element.attributes.href&&element.attributes.href.match(/#.+$/)){var name=element.attributes.href.match(/#(.+)$/)[1];links[name]=element;}
if(element.attributes.name&&links[element.attributes.name]){var link=links[element.attributes.name];link.attributes.href=link.attributes.href.replace(/.*#(.*)$/,'#$1');}},'div':function(element){if(editor.plugins.pagebreak&&element.attributes['data-cke-pagebreak']){return element;}
Style.createStyleStack(element,filter,editor);},'img':function(element){if(element.parent&&element.parent.attributes){var attrs=element.parent.attributes,style=attrs.style||attrs.STYLE;if(style&&style.match(/mso\-list:\s?Ignore/)){element.attributes['cke-ignored']=true;}}
Style.mapCommonStyles(element);if(element.attributes.src&&element.attributes.src.match(/^file:\/\//)&&element.attributes.alt&&element.attributes.alt.match(/^https?:\/\//)){element.attributes.src=element.attributes.alt;}
var imgShapesIds=element.attributes['v:shapes']?element.attributes['v:shapes'].split(' '):[];var isShapeFromList=CKEDITOR.tools.array.every(imgShapesIds,function(shapeId){return shapesIds.indexOf(shapeId)>-1;});if(imgShapesIds.length&&isShapeFromList){return false;}},'p':function(element){element.filterChildren(filter);if(element.attributes.style&&element.attributes.style.match(/display:\s*none/i)){return false;}
if(List.thisIsAListItem(editor,element)){if(Heuristics.isEdgeListItem(editor,element)){Heuristics.cleanupEdgeListItem(element);}
List.convertToFakeListItem(editor,element);tools.array.reduce(element.children,function(paragraphsReplaced,node){if(node.name==='p'){if(paragraphsReplaced>0){var br=new CKEDITOR.htmlParser.element('br');br.insertBefore(node);}
node.replaceWithChildren();paragraphsReplaced+=1;}
return paragraphsReplaced;},0);}else{var container=element.getAscendant(function(element){return element.name=='ul'||element.name=='ol';}),style=tools.parseCssText(element.attributes.style);if(container&&!container.attributes['cke-list-level']&&style['mso-list']&&style['mso-list'].match(/level/)){container.attributes['cke-list-level']=style['mso-list'].match(/level(\d+)/)[1];}
if(editor.config.enterMode==CKEDITOR.ENTER_BR){delete element.name;element.add(new CKEDITOR.htmlParser.element('br'));}}
Style.createStyleStack(element,filter,editor);},'pre':function(element){if(List.thisIsAListItem(editor,element))List.convertToFakeListItem(editor,element);Style.createStyleStack(element,filter,editor);},'h1':function(element){if(List.thisIsAListItem(editor,element))List.convertToFakeListItem(editor,element);Style.createStyleStack(element,filter,editor);},'h2':function(element){if(List.thisIsAListItem(editor,element))List.convertToFakeListItem(editor,element);Style.createStyleStack(element,filter,editor);},'h3':function(element){if(List.thisIsAListItem(editor,element))List.convertToFakeListItem(editor,element);Style.createStyleStack(element,filter,editor);},'h4':function(element){if(List.thisIsAListItem(editor,element))List.convertToFakeListItem(editor,element);Style.createStyleStack(element,filter,editor);},'h5':function(element){if(List.thisIsAListItem(editor,element))List.convertToFakeListItem(editor,element);Style.createStyleStack(element,filter,editor);},'h6':function(element){if(List.thisIsAListItem(editor,element))List.convertToFakeListItem(editor,element);Style.createStyleStack(element,filter,editor);},'font':function(element){if(element.getHtml().match(/^\s*$/)){if(element.parent.type===CKEDITOR.NODE_ELEMENT){new CKEDITOR.htmlParser.text(' ').insertAfter(element);}
return false;}
if(editor&&editor.config.pasteFromWordRemoveFontStyles===true&&element.attributes.size){delete element.attributes.size;}
if(CKEDITOR.dtd.tr[element.parent.name]&&CKEDITOR.tools.arrayCompare(CKEDITOR.tools.object.keys(element.attributes),['class','style'])){Style.createStyleStack(element,filter,editor);}else{createAttributeStack(element,filter);}},'ul':function(element){if(!msoListsDetected){return;}
if(element.parent.name=='li'&&tools.indexOf(element.parent.children,element)===0){Style.setStyle(element.parent,'list-style-type','none');}
List.dissolveList(element);return false;},'li':function(element){Heuristics.correctLevelShift(element);if(!msoListsDetected){return;}
element.attributes.style=Style.normalizedStyles(element,editor);Style.pushStylesLower(element);},'ol':function(element){if(!msoListsDetected){return;}
if(element.parent.name=='li'&&tools.indexOf(element.parent.children,element)===0){Style.setStyle(element.parent,'list-style-type','none');}
List.dissolveList(element);return false;},'span':function(element){element.filterChildren(filter);element.attributes.style=Style.normalizedStyles(element,editor);if(!element.attributes.style||element.attributes.style.match(/^mso\-bookmark:OLE_LINK\d+$/)||element.getHtml().match(/^(\s|&nbsp;)+$/)){commonFilter.elements.replaceWithChildren(element);return false;}
if(element.attributes.style.match(/FONT-FAMILY:\s*Symbol/i)){element.forEach(function(node){node.value=node.value.replace(/&nbsp;/g,'');},CKEDITOR.NODE_TEXT,true);}
Style.createStyleStack(element,filter,editor);},'v:imagedata':remove,'v:shape':function(element){var duplicate=false,child=element.getFirst('v:imagedata');if(child===null){shapeTagging(element);return;}
element.parent.find(function(child){if(child.name=='img'&&child.attributes&&child.attributes['v:shapes']==element.attributes.id){duplicate=true;}},true);if(duplicate){return false;}else{var src='';if(element.parent.name==='v:group'){shapeTagging(element);return;}
element.forEach(function(child){if(child.attributes&&child.attributes.src){src=child.attributes.src;}},CKEDITOR.NODE_ELEMENT,true);element.filterChildren(filter);element.name='img';element.attributes.src=element.attributes.src||src;delete element.attributes.type;}
return;},'style':function(){return false;},'object':function(element){return!!(element.attributes&&element.attributes.data);},'br':function(element){if(!editor.plugins.pagebreak){return;}
var styles=tools.parseCssText(element.attributes.style,true);if(styles['page-break-before']==='always'||styles['break-before']==='page'){var pagebreakEl=CKEDITOR.plugins.pagebreak.createElement(editor);return CKEDITOR.htmlParser.fragment.fromHtml(pagebreakEl.getOuterHtml()).children[0];}}},attributes:{'style':function(styles,element){return Style.normalizedStyles(element,editor)||false;},'class':function(classes){return falseIfEmpty(classes.replace(/(el\d+)|(font\d+)|msonormal|msolistparagraph\w*/ig,''));},'cellspacing':remove,'cellpadding':remove,'border':remove,'v:shapes':remove,'o:spid':remove},comment:function(element){if(element.match(/\[if.* supportFields.*\]/)){inComment++;}
if(element=='[endif]'){inComment=inComment>0?inComment-1:0;}
return false;},text:function(content,node){if(inComment){return'';}
var grandparent=node.parent&&node.parent.parent;if(grandparent&&grandparent.attributes&&grandparent.attributes.style&&grandparent.attributes.style.match(/mso-list:\s*ignore/i)){return content.replace(/&nbsp;/g,' ');}
return content;}};tools.array.forEach(shapeTags,function(shapeTag){rules.elements[shapeTag]=shapeTagging;});return rules;function shapeTagging(element){if(element.attributes['o:gfxdata']||element.parent.name==='v:group'){shapesIds.push(element.attributes.id);}}};plug.lists={thisIsAListItem:function(editor,element){if(Heuristics.isEdgeListItem(editor,element)){return true;}
if((element.attributes.style&&element.attributes.style.match(/mso\-list:\s?l\d/)&&element.parent.name!=='li')||element.attributes['cke-dissolved']||element.getHtml().match(/<!\-\-\[if !supportLists]\-\->/)){return true;}
return false;},convertToFakeListItem:function(editor,element){if(Heuristics.isDegenerateListItem(editor,element)){Heuristics.assignListLevels(editor,element);}
this.getListItemInfo(element);if(!element.attributes['cke-dissolved']){var symbol;element.forEach(function(element){if(!symbol&&element.name=='img'&&element.attributes['cke-ignored']&&element.attributes.alt=='*'){symbol='·';element.remove();}},CKEDITOR.NODE_ELEMENT);element.forEach(function(element){if(!symbol&&!element.value.match(/^ /)){symbol=element.value;}},CKEDITOR.NODE_TEXT);if(typeof symbol=='undefined'){return;}
element.attributes['cke-symbol']=symbol.replace(/(?: |&nbsp;).*$/,'');List.removeSymbolText(element);}
var styles=element.attributes&&tools.parseCssText(element.attributes.style);if(styles['margin-left']){var margin=styles['margin-left'],level=element.attributes['cke-list-level'];margin=Math.max(CKEDITOR.tools.convertToPx(margin)-40*level,0);if(margin){styles['margin-left']=margin+'px';}else{delete styles['margin-left'];}
element.attributes.style=CKEDITOR.tools.writeCssText(styles);}
element.name='cke:li';},convertToRealListItems:function(root){var listElements=[];root.forEach(function(element){if(element.name=='cke:li'){element.name='li';listElements.push(element);}},CKEDITOR.NODE_ELEMENT,false);return listElements;},removeSymbolText:function(element){var symbol=element.attributes['cke-symbol'],node=element.findOne(function(node){return node.value&&node.value.indexOf(symbol)>-1;},true),parent;if(node){node.value=node.value.replace(symbol,'');parent=node.parent;if(parent.getHtml().match(/^(\s|&nbsp;)*$/)&&parent!==element){parent.remove();}else if(!node.value){node.remove();}}},setListSymbol:function(list,symbol,level){level=level||1;var style=tools.parseCssText(list.attributes.style);if(list.name=='ol'){if(list.attributes.type||style['list-style-type'])return;var typeMap={'[ivx]':'lower-roman','[IVX]':'upper-roman','[a-z]':'lower-alpha','[A-Z]':'upper-alpha','\\d':'decimal'};for(var type in typeMap){if(List.getSubsectionSymbol(symbol).match(new RegExp(type))){style['list-style-type']=typeMap[type];break;}}
list.attributes['cke-list-style-type']=style['list-style-type'];}else{var symbolMap={'·':'disc','o':'circle','§':'square'};if(!style['list-style-type']&&symbolMap[symbol]){style['list-style-type']=symbolMap[symbol];}}
List.setListSymbol.removeRedundancies(style,level);(list.attributes.style=CKEDITOR.tools.writeCssText(style))||delete list.attributes.style;},setListStart:function(list){var symbols=[],offset=0;for(var i=0;i<list.children.length;i++){symbols.push(list.children[i].attributes['cke-symbol']||'');}
if(!symbols[0]){offset++;}
switch(list.attributes['cke-list-style-type']){case'lower-roman':case'upper-roman':list.attributes.start=List.toArabic(List.getSubsectionSymbol(symbols[offset]))-offset;break;case'lower-alpha':case'upper-alpha':list.attributes.start=List.getSubsectionSymbol(symbols[offset]).replace(/\W/g,'').toLowerCase().charCodeAt(0)-96-offset;break;case'decimal':list.attributes.start=(parseInt(List.getSubsectionSymbol(symbols[offset]),10)-offset)||1;break;}
if(list.attributes.start=='1'){delete list.attributes.start;}
delete list.attributes['cke-list-style-type'];},numbering:{toNumber:function(marker,markerType){function fromAlphabet(str){var alpahbets='ABCDEFGHIJKLMNOPQRSTUVWXYZ';str=str.toUpperCase();var l=alpahbets.length,retVal=1;for(var x=1;str.length>0;x*=l){retVal+=alpahbets.indexOf(str.charAt(str.length-1))*x;str=str.substr(0,str.length-1);}
return retVal;}
function fromRoman(str){var romans=[[1000,'M'],[900,'CM'],[500,'D'],[400,'CD'],[100,'C'],[90,'XC'],[50,'L'],[40,'XL'],[10,'X'],[9,'IX'],[5,'V'],[4,'IV'],[1,'I']];str=str.toUpperCase();var l=romans.length,retVal=0;for(var i=0;i<l;++i){for(var j=romans[i],k=j[1].length;str.substr(0,k)==j[1];str=str.substr(k))
retVal+=j[0];}
return retVal;}
if(markerType=='decimal'){return Number(marker);}else if(markerType=='upper-roman'||markerType=='lower-roman'){return fromRoman(marker.toUpperCase());}else if(markerType=='lower-alpha'||markerType=='upper-alpha'){return fromAlphabet(marker);}else{return 1;}},getStyle:function(marker){var typeMap={'i':'lower-roman','v':'lower-roman','x':'lower-roman','l':'lower-roman','m':'lower-roman','I':'upper-roman','V':'upper-roman','X':'upper-roman','L':'upper-roman','M':'upper-roman'},firstCharacter=marker.slice(0,1),type=typeMap[firstCharacter];if(!type){type='decimal';if(firstCharacter.match(/[a-z]/)){type='lower-alpha';}
if(firstCharacter.match(/[A-Z]/)){type='upper-alpha';}}
return type;}},getSubsectionSymbol:function(symbol){return(symbol.match(/([\da-zA-Z]+).?$/)||['placeholder','1'])[1];},setListDir:function(list){var dirs={ltr:0,rtl:0};list.forEach(function(child){if(child.name=='li'){var dir=child.attributes.dir||child.attributes.DIR||'';if(dir.toLowerCase()=='rtl'){dirs.rtl++;}else{dirs.ltr++;}}},CKEDITOR.ELEMENT_NODE);if(dirs.rtl>dirs.ltr){list.attributes.dir='rtl';}},createList:function(element){if((element.attributes['cke-symbol'].match(/([\da-np-zA-NP-Z]).?/)||[])[1]){return new CKEDITOR.htmlParser.element('ol');}
return new CKEDITOR.htmlParser.element('ul');},createLists:function(root){var element,level,i,j,listElements=List.convertToRealListItems(root);if(listElements.length===0){return[];}
var lists=List.groupLists(listElements);for(i=0;i<lists.length;i++){var list=lists[i],firstLevel1Element=list[0];for(j=0;j<list.length;j++){if(list[j].attributes['cke-list-level']==1){firstLevel1Element=list[j];break;}}
var containerStack=[List.createList(firstLevel1Element)],innermostContainer=containerStack[0],allContainers=[containerStack[0]];innermostContainer.insertBefore(list[0]);for(j=0;j<list.length;j++){element=list[j];level=element.attributes['cke-list-level'];while(level>containerStack.length){var content=List.createList(element);var children=innermostContainer.children;if(children.length>0){children[children.length-1].add(content);}else{var container=new CKEDITOR.htmlParser.element('li',{style:'list-style-type:none'});container.add(content);innermostContainer.add(container);}
containerStack.push(content);allContainers.push(content);innermostContainer=content;if(level==containerStack.length){List.setListSymbol(content,element.attributes['cke-symbol'],level);}}
while(level<containerStack.length){containerStack.pop();innermostContainer=containerStack[containerStack.length-1];if(level==containerStack.length){List.setListSymbol(innermostContainer,element.attributes['cke-symbol'],level);}}
element.remove();innermostContainer.add(element);}
var level1Symbol;if(containerStack[0].children.length){level1Symbol=containerStack[0].children[0].attributes['cke-symbol'];if(!level1Symbol&&containerStack[0].children.length>1){level1Symbol=containerStack[0].children[1].attributes['cke-symbol'];}
if(level1Symbol){List.setListSymbol(containerStack[0],level1Symbol);}}
for(j=0;j<allContainers.length;j++){List.setListStart(allContainers[j]);}
for(j=0;j<list.length;j++){this.determineListItemValue(list[j]);}}
CKEDITOR.tools.array.forEach(listElements,function(element){var listParents=getParentListItems(element),leftOffset=getTotalMarginLeft(listParents),styles,marginLeft;if(!leftOffset){return;}
element.attributes=element.attributes||{};styles=CKEDITOR.tools.parseCssText(element.attributes.style);marginLeft=styles['margin-left']||0;marginLeft=Math.max(parseInt(marginLeft,10)-leftOffset,0);if(marginLeft){styles['margin-left']=marginLeft+'px';}else{delete styles['margin-left'];}
element.attributes.style=CKEDITOR.tools.writeCssText(styles);});return listElements;function getParentListItems(element){var parents=[],parent=element.parent;while(parent){if(parent.name==='li'){parents.push(parent);}
parent=parent.parent;}
return parents;}
function getTotalMarginLeft(elements){return CKEDITOR.tools.array.reduce(elements,function(total,element){if(element.attributes&&element.attributes.style){var marginLeft=CKEDITOR.tools.parseCssText(element.attributes.style)['margin-left'];}
return marginLeft?total+parseInt(marginLeft,10):total;},0);}},cleanup:function(listElements){var tempAttributes=['cke-list-level','cke-symbol','cke-list-id','cke-indentation','cke-dissolved'],i,j;for(i=0;i<listElements.length;i++){for(j=0;j<tempAttributes.length;j++){delete listElements[i].attributes[tempAttributes[j]];}}},determineListItemValue:function(element){if(element.parent.name!=='ol'){return;}
var assumedValue=this.calculateValue(element),cleanSymbol=element.attributes['cke-symbol'].match(/[a-z0-9]+/gi),computedValue,listType;if(cleanSymbol){cleanSymbol=cleanSymbol[cleanSymbol.length-1];listType=element.parent.attributes['cke-list-style-type']||this.numbering.getStyle(cleanSymbol);computedValue=this.numbering.toNumber(cleanSymbol,listType);if(computedValue!==assumedValue){element.attributes.value=computedValue;}}},calculateValue:function(element){if(!element.parent){return 1;}
var list=element.parent,elementIndex=element.getIndex(),valueFound=null,valueElementIndex,curElement,i;for(i=elementIndex;i>=0&&valueFound===null;i--){curElement=list.children[i];if(curElement.attributes&&curElement.attributes.value!==undefined){valueElementIndex=i;valueFound=parseInt(curElement.attributes.value,10);}}
if(valueFound===null){valueFound=list.attributes.start!==undefined?parseInt(list.attributes.start,10):1;valueElementIndex=0;}
return valueFound+(elementIndex-valueElementIndex);},dissolveList:function(element){var nameIs=function(name){return function(element){return element.name==name;};},isList=function(element){return nameIs('ul')(element)||nameIs('ol')(element);},arrayTools=CKEDITOR.tools.array,elements=[],children,i;element.forEach(function(child){elements.push(child);},CKEDITOR.NODE_ELEMENT,false);var items=arrayTools.filter(elements,nameIs('li')),lists=arrayTools.filter(elements,isList);arrayTools.forEach(lists,function(list){var type=list.attributes.type,start=parseInt(list.attributes.start,10)||1,level=countParents(isList,list)+1;if(!type){var style=tools.parseCssText(list.attributes.style);type=style['list-style-type'];}
arrayTools.forEach(arrayTools.filter(list.children,nameIs('li')),function(child,index){var symbol;switch(type){case'disc':symbol='·';break;case'circle':symbol='o';break;case'square':symbol='§';break;case'1':case'decimal':symbol=(start+index)+'.';break;case'a':case'lower-alpha':symbol=String.fromCharCode('a'.charCodeAt(0)+start-1+index)+'.';break;case'A':case'upper-alpha':symbol=String.fromCharCode('A'.charCodeAt(0)+start-1+index)+'.';break;case'i':case'lower-roman':symbol=toRoman(start+index)+'.';break;case'I':case'upper-roman':symbol=toRoman(start+index).toUpperCase()+'.';break;default:symbol=list.name=='ul'?'·':(start+index)+'.';}
child.attributes['cke-symbol']=symbol;child.attributes['cke-list-level']=level;});});children=arrayTools.reduce(items,function(acc,listElement){var child=listElement.children[0];if(child&&child.name&&child.attributes.style&&child.attributes.style.match(/mso-list:/i)){Style.pushStylesLower(listElement,{'list-style-type':true,'display':true});var childStyle=tools.parseCssText(child.attributes.style,true);Style.setStyle(listElement,'mso-list',childStyle['mso-list'],true);Style.setStyle(child,'mso-list','');delete listElement['cke-list-level'];var styleName=childStyle.display?'display':childStyle.DISPLAY?'DISPLAY':'';if(styleName){Style.setStyle(listElement,'display',childStyle[styleName],true);}}
if(listElement.children.length===1&&isList(listElement.children[0])){return acc;}
listElement.name='p';listElement.attributes['cke-dissolved']=true;acc.push(listElement);return acc;},[]);for(i=children.length-1;i>=0;i--){children[i].insertAfter(element);}
for(i=lists.length-1;i>=0;i--){delete lists[i].name;}
function toRoman(number){if(number>=50)return'l'+toRoman(number-50);if(number>=40)return'xl'+toRoman(number-40);if(number>=10)return'x'+toRoman(number-10);if(number==9)return'ix';if(number>=5)return'v'+toRoman(number-5);if(number==4)return'iv';if(number>=1)return'i'+toRoman(number-1);return'';}
function countParents(condition,element){return count(element,0);function count(parent,number){if(!parent||!parent.parent){return number;}
if(condition(parent.parent)){return count(parent.parent,number+1);}else{return count(parent.parent,number);}}}},groupLists:function(listElements){var i,element,lists=[[listElements[0]]],lastList=lists[0];element=listElements[0];element.attributes['cke-indentation']=element.attributes['cke-indentation']||getElementIndentation(element);for(i=1;i<listElements.length;i++){element=listElements[i];var previous=listElements[i-1];element.attributes['cke-indentation']=element.attributes['cke-indentation']||getElementIndentation(element);if(element.previous!==previous){List.chopDiscontinuousLists(lastList,lists);lists.push(lastList=[]);}
lastList.push(element);}
List.chopDiscontinuousLists(lastList,lists);return lists;},chopDiscontinuousLists:function(list,lists){var levelSymbols={};var choppedLists=[[]],lastListInfo;for(var i=0;i<list.length;i++){var lastSymbol=levelSymbols[list[i].attributes['cke-list-level']],currentListInfo=this.getListItemInfo(list[i]),currentSymbol,forceType;if(lastSymbol){forceType=lastSymbol.type.match(/alpha/)&&lastSymbol.index==7?'alpha':forceType;forceType=list[i].attributes['cke-symbol']=='o'&&lastSymbol.index==14?'alpha':forceType;currentSymbol=List.getSymbolInfo(list[i].attributes['cke-symbol'],forceType);currentListInfo=this.getListItemInfo(list[i]);if(lastSymbol.type!=currentSymbol.type||(lastListInfo&&currentListInfo.id!=lastListInfo.id&&!this.isAListContinuation(list[i]))){choppedLists.push([]);}}else{currentSymbol=List.getSymbolInfo(list[i].attributes['cke-symbol']);}
for(var j=parseInt(list[i].attributes['cke-list-level'],10)+1;j<20;j++){if(levelSymbols[j]){delete levelSymbols[j];}}
levelSymbols[list[i].attributes['cke-list-level']]=currentSymbol;choppedLists[choppedLists.length-1].push(list[i]);lastListInfo=currentListInfo;}
[].splice.apply(lists,[].concat([tools.indexOf(lists,list),1],choppedLists));},isAListContinuation:function(listElement){var prev=listElement;do{prev=prev.previous;if(prev&&prev.type===CKEDITOR.NODE_ELEMENT){if(prev.attributes['cke-list-level']===undefined){return false;}
if(prev.attributes['cke-list-level']===listElement.attributes['cke-list-level']){return prev.attributes['cke-list-id']===listElement.attributes['cke-list-id'];}}}while(prev);return false;},toArabic:function(symbol){if(!symbol.match(/[ivxl]/i))return 0;if(symbol.match(/^l/i))return 50+List.toArabic(symbol.slice(1));if(symbol.match(/^lx/i))return 40+List.toArabic(symbol.slice(1));if(symbol.match(/^x/i))return 10+List.toArabic(symbol.slice(1));if(symbol.match(/^ix/i))return 9+List.toArabic(symbol.slice(2));if(symbol.match(/^v/i))return 5+List.toArabic(symbol.slice(1));if(symbol.match(/^iv/i))return 4+List.toArabic(symbol.slice(2));if(symbol.match(/^i/i))return 1+List.toArabic(symbol.slice(1));return List.toArabic(symbol.slice(1));},getSymbolInfo:function(symbol,type){var symbolCase=symbol.toUpperCase()==symbol?'upper-':'lower-',symbolMap={'·':['disc',-1],'o':['circle',-2],'§':['square',-3]};if(symbol in symbolMap||(type&&type.match(/(disc|circle|square)/))){return{index:symbolMap[symbol][1],type:symbolMap[symbol][0]};}
if(symbol.match(/\d/)){return{index:symbol?parseInt(List.getSubsectionSymbol(symbol),10):0,type:'decimal'};}
symbol=symbol.replace(/\W/g,'').toLowerCase();if((!type&&symbol.match(/[ivxl]+/i))||(type&&type!='alpha')||type=='roman'){return{index:List.toArabic(symbol),type:symbolCase+'roman'};}
if(symbol.match(/[a-z]/i)){return{index:symbol.charCodeAt(0)-97,type:symbolCase+'alpha'};}
return{index:-1,type:'disc'};},getListItemInfo:function(list){if(list.attributes['cke-list-id']!==undefined){return{id:list.attributes['cke-list-id'],level:list.attributes['cke-list-level']};}
var propValue=tools.parseCssText(list.attributes.style)['mso-list'],ret={id:'0',level:'1'};if(propValue){propValue+=' ';ret.level=propValue.match(/level(.+?)\s+/)[1];ret.id=propValue.match(/l(\d+?)\s+/)[1];}
list.attributes['cke-list-level']=list.attributes['cke-list-level']!==undefined?list.attributes['cke-list-level']:ret.level;list.attributes['cke-list-id']=ret.id;return ret;}};List=plug.lists;plug.heuristics={isEdgeListItem:function(editor,item){if(!CKEDITOR.env.edge||!editor.config.pasteFromWord_heuristicsEdgeList){return false;}
var innerText='';item.forEach&&item.forEach(function(text){innerText+=text.value;},CKEDITOR.NODE_TEXT);if(innerText.match(/^(?: |&nbsp;)*\(?[a-zA-Z0-9]+?[\.\)](?: |&nbsp;){2,}/)){return true;}
return Heuristics.isDegenerateListItem(editor,item);},cleanupEdgeListItem:function(item){var textOccurred=false;item.forEach(function(node){if(!textOccurred){node.value=node.value.replace(/^(?:&nbsp;|[\s])+/,'');if(node.value.length){textOccurred=true;}}},CKEDITOR.NODE_TEXT);},isDegenerateListItem:function(editor,item){return!!item.attributes['cke-list-level']||(item.attributes.style&&!item.attributes.style.match(/mso\-list/)&&!!item.find(function(child){if(child.type==CKEDITOR.NODE_ELEMENT&&item.name.match(/h\d/i)&&child.getHtml().match(/^[a-zA-Z0-9]+?[\.\)]$/)){return true;}
var css=tools.parseCssText(child.attributes&&child.attributes.style,true);if(!css){return false;}
var fontSize=css.font||css['font-size']||'',fontFamily=css['font-family']||'';return(fontSize.match(/7pt/i)&&!!child.previous)||fontFamily.match(/symbol/i);},true).length);},assignListLevels:function(editor,item){if(item.attributes&&item.attributes['cke-list-level']!==undefined){return;}
var indents=[getElementIndentation(item)],items=[item],levels=[],array=CKEDITOR.tools.array,map=array.map;while(item.next&&item.next.attributes&&!item.next.attributes['cke-list-level']&&Heuristics.isDegenerateListItem(editor,item.next)){item=item.next;indents.push(getElementIndentation(item));items.push(item);}
var indentationDiffs=map(indents,function(curIndent,i){return i===0?0:curIndent-indents[i-1];}),indentationPerLevel=this.guessIndentationStep(array.filter(indents,function(val){return val!==0;}));levels=map(indents,function(val){return Math.round(val / indentationPerLevel);});if(array.indexOf(levels,0)!==-1){levels=map(levels,function(val){return val+1;});}
array.forEach(items,function(curItem,index){curItem.attributes['cke-list-level']=levels[index];});return{indents:indents,levels:levels,diffs:indentationDiffs};},guessIndentationStep:function(indentations){return indentations.length?Math.min.apply(null,indentations):null;},correctLevelShift:function(element){var isShiftedList=function(list){return list.children&&list.children.length==1&&Heuristics.isShifted(list.children[0]);};if(this.isShifted(element)){var lists=CKEDITOR.tools.array.filter(element.children,function(child){return(child.name=='ul'||child.name=='ol');});var listChildren=CKEDITOR.tools.array.reduce(lists,function(acc,list){var preceding=isShiftedList(list)?[list]:list.children;return preceding.concat(acc);},[]);CKEDITOR.tools.array.forEach(lists,function(list){list.remove();});CKEDITOR.tools.array.forEach(listChildren,function(child){element.add(child);});delete element.name;}},isShifted:function(element){if(element.name!=='li'){return false;}
return CKEDITOR.tools.array.filter(element.children,function(child){if(child.name){if(child.name=='ul'||child.name=='ol'){return false;}
if(child.name=='p'&&child.children.length===0){return false;}}
return true;}).length===0;}};Heuristics=plug.heuristics;List.setListSymbol.removeRedundancies=function(style,level){if((level===1&&style['list-style-type']==='disc')||style['list-style-type']==='decimal'){delete style['list-style-type'];}};function falseIfEmpty(value){if(value===''){return false;}
return value;}
function remove(){return false;}
CKEDITOR.cleanWord=CKEDITOR.pasteFilters.word=pastetools.createFilter({rules:[commonFilter.rules,plug.rules],additionalTransforms:function(html){if(CKEDITOR.plugins.clipboard.isCustomDataTypesSupported){html=commonFilter.styles.inliner.inline(html).getBody().getHtml();}
return html.replace(/<!\[/g,'<!--[').replace(/\]>/g,']-->');}});CKEDITOR.config.pasteFromWord_heuristicsEdgeList=true;})();