!function(e,t){"use strict";functionn(e,t){for(varn,r=[],i=0;i<e.length;++i){if(n=s[e[i]]||o(e[i]),!n)throw"module definition dependecy not found: "+e[i];r.push(n)}t.apply(null,r)}functionr(e,r,i){if("string"!=typeofe)throw"invalid module definition, module id must be defined and be a string";if(r===t)throw"invalid module definition, dependencies must be specified";if(i===t)throw"invalid module definition, definition function must be specified";n(r,function(){s[e]=i.apply(null,arguments)})}functioni(e){return!!s[e]}functiono(t){for(varn=e,r=t.split(/[.\/]/),i=0;i<r.length;++i){if(!n[r[i]])return;n=n[r[i]]}returnn}functiona(n){for(varr=0;r<n.length;r++){for(vari=e,o=n[r],a=o.split(/[.\/]/),l=0;l<a.length-1;++l)i[a[l]]===t&&(i[a[l]]={}),i=i[a[l]];i[a[a.length-1]]=s[o]}}vars={},l="tinymce/spellcheckerplugin/DomTextMatcher",c="tinymce/spellcheckerplugin/Plugin",u="tinymce/PluginManager",d="tinymce/util/Tools",f="tinymce/ui/Menu",p="tinymce/dom/DOMUtils",m="tinymce/util/XHR",h="tinymce/util/URI",g="tinymce/util/JSON";r(l,[],function(){returnfunction(e,t){functionn(e,t){if(!e[0])throw"findAndReplaceDOMText cannot handle zero-length matches";return{start:e.index,end:e.index+e[0].length,text:e[0],data:t}}functionr(e){vart;if(3===e.nodeType)returne.data;if(N[e.nodeName]&&!k[e.nodeName])return"";if(t="",(k[e.nodeName]||E[e.nodeName])&&(t+="\n"),e=e.firstChild)dot+=r(e);while(e=e.nextSibling);returnt}functioni(e,t,n){varr,i,o,a,s=[],l=0,c=e,u,d=0;t=t.slice(0),t.sort(function(e,t){returne.start-t.start}),u=t.shift();e:for(;;){if((k[c.nodeName]||E[c.nodeName])&&l++,3===c.nodeType&&(!i&&c.length+l>=u.end?(i=c,a=u.end-l):r&&s.push(c),!r&&c.length+l>u.start&&(r=c,o=u.start-l),l+=c.length),r&&i){if(c=n({startNode:r,startNodeIndex:o,endNode:i,endNodeIndex:a,innerNodes:s,match:u.text,matchIndex:d}),l-=i.length-a,r=null,i=null,s=[],u=t.shift(),d++,!u)break}else{if((!N[c.nodeName]||k[c.nodeName])&&c.firstChild){c=c.firstChild;continue}if(c.nextSibling){c=c.nextSibling;continue}}for(;;){if(c.nextSibling){c=c.nextSibling;break}if(c.parentNode===e)breake;c=c.parentNode}}}functiono(e){functiont(t,n){varr=x[n];r.stencil||(r.stencil=e(r));vari=r.stencil.cloneNode(!1);returni.setAttribute("data-mce-index",n),t&&i.appendChild(_.doc.createTextNode(t)),i}returnfunction(e){varn,r,i,o=e.startNode,a=e.endNode,s=e.matchIndex,l=_.doc;if(o===a){varc=o;i=c.parentNode,e.startNodeIndex>0&&(n=l.createTextNode(c.data.substring(0,e.startNodeIndex)),i.insertBefore(n,c));varu=t(e.match,s);returni.insertBefore(u,c),e.endNodeIndex<c.length&&(r=l.createTextNode(c.data.substring(e.endNodeIndex)),i.insertBefore(r,c)),c.parentNode.removeChild(c),u}n=l.createTextNode(o.data.substring(0,e.startNodeIndex)),r=l.createTextNode(a.data.substring(e.endNodeIndex));for(vard=t(o.data.substring(e.startNodeIndex),s),f=[],p=0,m=e.innerNodes.length;m>p;++p){varh=e.innerNodes[p],g=t(h.data,s);h.parentNode.replaceChild(g,h),f.push(g)}varv=t(a.data.substring(0,e.endNodeIndex),s);returni=o.parentNode,i.insertBefore(n,o),i.insertBefore(d,o),i.removeChild(o),i=a.parentNode,i.insertBefore(v,a),i.insertBefore(r,a),i.removeChild(a),v}}functiona(e){vart=e.parentNode;t.insertBefore(e.firstChild,e),e.parentNode.removeChild(e)}functions(t){varn=e.getElementsByTagName("*"),r=[];t="number"==typeoft?""+t:null;for(vari=0;i<n.length;i++){varo=n[i],a=o.getAttribute("data-mce-index");null!==a&&a.length&&(a===t||null===t)&&r.push(o)}returnr}functionl(e){for(vart=x.length;t--;)if(x[t]===e)returnt;return-1}functionc(e){vart=[];returnu(function(n,r){e(n,r)&&t.push(n)}),x=t,this}functionu(e){for(vart=0,n=x.length;n>t&&e(x[t],t)!==!1;t++);returnthis}functiond(t){returnx.length&&i(e,x,o(t)),this}functionf(e,t){if(w&&e.global)for(;C=e.exec(w);)x.push(n(C,t));returnthis}functionp(e){vart,n=s(e?l(e):null);for(t=n.length;t--;)a(n[t]);returnthis}functionm(e){returnx[e.getAttribute("data-mce-index")]}functionh(e){returns(l(e))[0]}functiong(e,t,n){returnx.push({start:e,end:e+t,text:w.substr(e,t),data:n}),this}functionv(e){varn=s(l(e)),r=t.dom.createRng();returnr.setStartBefore(n[0]),r.setEndAfter(n[n.length-1]),r}functiony(e,n){varr=v(e);returnr.deleteContents(),n.length>0&&r.insertNode(t.dom.doc.createTextNode(n)),r}functionb(){returnx.splice(0,x.length),p(),this}varC,x=[],w,_=t.dom,k,N,E;returnk=t.schema.getBlockElements(),N=t.schema.getWhiteSpaceElements(),E=t.schema.getShortEndedElements(),w=r(e),{text:w,matches:x,each:u,filter:c,reset:b,matchFromElement:m,elementFromMatch:h,find:f,add:g,wrap:d,unwrap:p,replace:y,rangeFromMatch:v,indexOf:l}}}),r(c,[l,u,d,f,p,m,h,g],function(e,t,n,r,i,o,a,s){t.add("spellchecker",function(t,l){functionc(){returnE.textMatcher||(E.textMatcher=newe(t.getBody(),t)),E.textMatcher}functionu(e,t){varr=[];returnn.each(t,function(e){r.push({selectable:!0,text:e.name,data:e.value})}),r}functiond(e){for(vartine)return!1;return!0}functionf(e,o){vara=[],s=S[e];n.each(s,function(e){a.push({text:e,onclick:function(){t.insertContent(t.dom.encode(e)),t.dom.remove(o),v()}})}),a.push({text:"-"}),B&&a.push({text:"Add to Dictionary",onclick:function(){y(e,o)}}),a.push.apply(a,[{text:"Ignore",onclick:function(){b(e,o)}},{text:"Ignore all",onclick:function(){b(e,o,!0)}}]),R=newr({items:a,context:"contextmenu",onautohide:function(e){-1!=e.target.className.indexOf("spellchecker")&&e.preventDefault()},onhide:function(){R.remove(),R=null}}),R.renderTo(document.body);varl=i.DOM.getPos(t.getContentAreaContainer()),c=t.dom.getPos(o[0]),u=t.dom.getRoot();"BODY"==u.nodeName?(c.x-=u.ownerDocument.documentElement.scrollLeft||u.scrollLeft,c.y-=u.ownerDocument.documentElement.scrollTop||u.scrollTop):(c.x-=u.scrollLeft,c.y-=u.scrollTop),l.x+=c.x,l.y+=c.y,R.moveTo(l.x,l.y+o[0].offsetHeight)}functionp(){returnt.getParam("spellchecker_wordchar_pattern")||newRegExp('[^\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`\xa7\xa9\xab\xae\xb1\xb6\xb7\xb8\xbb\xbc\xbd\xbe\xbf\xd7\xf7\xa4\u201d\u201c\u201e\xa0\u2002\u2003\u2009]+',"g")}functionm(e,t,r,i){varc={method:e},u="";"spellcheck"==e&&(c.text=t,c.lang=A.spellchecker_language),"addToDictionary"==e&&(c.word=t),n.each(c,function(e,t){u&&(u+="&"),u+=t+"="+encodeURIComponent(e)}),o.send({url:newa(l).toAbsolute(A.spellchecker_rpc_url),type:"post",content_type:"application/x-www-form-urlencoded",data:u,success:function(e){e=s.parse(e),e?e.error?i(e.error):r(e):i("Sever response wasn't proper JSON.")},error:function(e,t){i("Spellchecker request error: "+t.status)}})}functionh(e,t,n,r){vari=A.spellchecker_callback||m;i.call(E,e,t,n,r)}functiong(){functione(e){t.windowManager.alert(e),t.setProgressState(!1),C()}returnT?voidC():(C(),T=!0,t.setProgressState(!0),h("spellcheck",c().text,k,e),voidt.focus())}functionv(){t.dom.select("span.mce-spellchecker-word").length||C()}functiony(e,n){t.setProgressState(!0),h("addToDictionary",e,function(){t.setProgressState(!1),t.dom.remove(n,!0),v()},function(e){t.windowManager.alert(e),t.setProgressState(!1)})}functionb(e,r,i){t.selection.collapse(),i?n.each(t.dom.select("span.mce-spellchecker-word"),function(n){n.getAttribute("data-mce-word")==e&&t.dom.remove(n,!0)}):t.dom.remove(r,!0),v()}functionC(){c().reset(),E.textMatcher=null,T&&(T=!1,t.fire("SpellcheckEnd"))}functionx(e){vart=e.getAttribute("data-mce-index");return"number"==typeoft?""+t:t}functionw(e){varr,i=[];if(r=n.toArray(t.getBody().getElementsByTagName("span")),r.length)for(varo=0;o<r.length;o++){vara=x(r[o]);null!==a&&a.length&&a===e.toString()&&i.push(r[o])}returni}function_(e){vart=A.spellchecker_language;e.control.items().each(function(e){e.active(e.settings.data===t)})}functionk(e){varn;returne.words?(B=!!e.dictionary,n=e.words):n=e,t.setProgressState(!1),d(n)?(t.windowManager.alert("No misspellings found"),void(T=!1)):(S=n,c().find(p()).filter(function(e){return!!n[e.text]}).wrap(function(e){returnt.dom.create("span",{"class":"mce-spellchecker-word","data-mce-bogus":1,"data-mce-word":e.text})}),voidt.fire("SpellcheckStart"),void(T=1))}varN,E=this,S,T,R,A=t.settings,B,D=A.spellchecker_languages||"English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,German=de,Italian=it,Polish=pl,Portuguese=pt_BR,Spanish=es,Swedish=sv";N=u("Language",n.map(D.split(","),function(e){returne=e.split("="),{name:e[0],value:e[1]}})),t.on("click",function(e){varn=e.target;if("mce-spellchecker-word"==n.className){e.preventDefault();varr=w(x(n));if(r.length>0){vari=t.dom.createRng();i.setStartBefore(r[0]),i.setEndAfter(r[r.length-1]),t.selection.setRng(i),f(n.getAttribute("data-mce-word"),r)}}}),t.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:g,selectable:!0,onPostRender:function(){vare=this;t.on("SpellcheckStart SpellcheckEnd",function(){e.active(T)})}});varP={tooltip:"Spellcheck",onclick:g,onPostRender:function(){vare=this;t.on("SpellcheckStart SpellcheckEnd",function(){e.active(T)})}};N.length>1&&(P.type="splitbutton",P.menu=N,P.onshow=_,P.onselect=function(e){A.spellchecker_language=e.control.settings.data}),t.addButton("spellchecker",P),t.addCommand("mceSpellCheck",g),t.on("remove",function(){R&&(R.remove(),R=null)}),t.on("change",v),this.getTextMatcher=c,this.getWordCharPattern=p,this.markErrors=k,this.getLanguage=function(){returnA.spellchecker_language},A.spellchecker_language=A.spellchecker_language||A.language||"en"})}),a([l])}(this);