!function(){function e(e){return e._searchState||(e._searchState=new function(){this.posFrom=this.posTo=this.query=null,this.marked=[]})}function o(e,o,n){return e.getSearchCursor(o,n,"string"==typeof o&&o==o.toLowerCase())}function n(e,o,n,r){e.openDialog?e.openDialog(o,r):r(prompt(n,""))}function r(e){var o=e.match(/^\/(.*)\/([a-z]*)$/);return o?new RegExp(o[1],-1==o[2].indexOf("i")?"":"i"):e}function t(t,a){var c=e(t);if(c.query)return i(t,a);n(t,f,"Search for:",function(e){t.operation(function(){if(e&&!c.query){if(c.query=r(e),t.lineCount()<2e3)for(var n=o(t,c.query);n.findNext();)c.marked.push(t.markText(n.from(),n.to(),{className:"CodeMirror-searching"}));c.posFrom=c.posTo=t.getCursor(),i(t,a)}})})}function i(n,r){n.operation(function(){var t=e(n),i=o(n,t.query,r?t.posFrom:t.posTo);(i.find(r)||(i=o(n,t.query,r?{line:n.lineCount()-1}:{line:0,ch:0})).find(r))&&(n.setSelection(i.from(),i.to()),t.posFrom=i.from(),t.posTo=i.to())})}function a(o){o.operation(function(){var n=e(o);if(n.query){n.query=null;for(var r=0;r<n.marked.length;++r)n.marked[r].clear();n.marked.length=0}})}function c(e,t){n(e,u,"Replace:",function(i){i&&(i=r(i),n(e,s,"Replace with:",function(n){function r(){var t,a=c.from();!(t=c.findNext())&&(c=o(e,i),!(t=c.findNext())||a&&c.from().line==a.line&&c.from().ch==a.ch)||(e.setSelection(c.from(),c.to()),function(e,o,n,r){e.openConfirm?e.openConfirm(o,r):confirm(n)&&r[0]()}(e,p,"Replace?",[function(){!function(e){c.replace("string"==typeof i?n:n.replace(/\$(\d)/,function(o,n){return e[n]})),r()}(t)},r]))}if(t)e.operation(function(){for(var r=o(e,i);r.findNext();)if("string"!=typeof i){var t=e.getRange(r.from(),r.to()).match(i);r.replace(n.replace(/\$(\d)/,function(e,o){return t[o]}))}else r.replace(n)});else{a(e);var c=o(e,i,e.getCursor());r()}}))})}var f='Search: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)</span>',u='Replace: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)</span>',s='With: <input type="text" style="width: 10em"/>',p="Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";CodeMirror.commands.find=function(e){a(e),t(e)},CodeMirror.commands.findNext=t,CodeMirror.commands.findPrev=function(e){t(e,!0)},CodeMirror.commands.clearSearch=a,CodeMirror.commands.replace=c,CodeMirror.commands.replaceAll=function(e){c(e,!0)}}();