import{g as K}from"./index-Cq7z4i0o.js";import{r as L}from"./codemirror-DpyRu-EA.js";import{r as z}from"./searchcursor-BkXLGAQH.js";import{r as U}from"./dialog-CNuDh2gC.js";function B(m,R){for(var a=0;a<R.length;a++){const d=R[a];if(typeof d!="string"&&!Array.isArray(d)){for(const y in d)if(y!=="default"&&!(y in m)){const g=Object.getOwnPropertyDescriptor(d,y);g&&Object.defineProperty(m,y,g.get?g:{enumerable:!0,get:()=>d[y]})}}}return Object.freeze(Object.defineProperty(m,Symbol.toStringTag,{value:"Module"}))}var F={exports:{}},Q;function M(){return Q||(Q=1,(function(m,R){(function(a){a(L(),z(),U())})(function(a){a.defineOption("search",{bottom:!1});function d(e,t){return typeof e=="string"?e=new RegExp(e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),t?"gi":"g"):e.global||(e=new RegExp(e.source,e.ignoreCase?"gi":"g")),{token:function(n){e.lastIndex=n.pos;var o=e.exec(n.string);if(o&&o.index==n.pos)return n.pos+=o[0].length||1,"searching";o?n.pos=o.index:n.skipToEnd()}}}function y(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function g(e){return e.state.search||(e.state.search=new y)}function O(e){return typeof e=="string"&&e==e.toLowerCase()}function S(e,t,n){return e.getSearchCursor(t,n,{caseFold:O(t),multiline:!0})}function A(e,t,n,o,r){e.openDialog(t,o,{value:n,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){b(e)},onKeyDown:r,bottom:e.options.search.bottom})}function D(e,t,n,o,r){e.openDialog?e.openDialog(t,r,{value:o,selectValueOnOpen:!0,bottom:e.options.search.bottom}):r(prompt(n,o))}function j(e,t,n,o){e.openConfirm?e.openConfirm(t,o):confirm(n)&&o[0]()}function P(e){return e.replace(/\\([nrt\\])/g,function(t,n){return n=="n"?`
`:n=="r"?"\r":n=="t"?"	":n=="\\"?"\\":t})}function C(e){var t=e.match(/^\/(.*)\/([a-z]*)$/);if(t)try{e=new RegExp(t[1],t[2].indexOf("i")==-1?"":"i")}catch{}else e=P(e);return(typeof e=="string"?e=="":e.test(""))&&(e=/x^/),e}function N(e,t,n){t.queryText=n,t.query=C(n),e.removeOverlay(t.overlay,O(t.query)),t.overlay=d(t.query,O(t.query)),e.addOverlay(t.overlay),e.showMatchesOnScrollbar&&(t.annotate&&(t.annotate.clear(),t.annotate=null),t.annotate=e.showMatchesOnScrollbar(t.query,O(t.query)))}function x(e,t,n,o){var r=g(e);if(r.query)return w(e,t);var i=e.getSelection()||r.lastQuery;if(i instanceof RegExp&&i.source=="x^"&&(i=null),n&&e.openDialog){var p=null,f=function(l,v){a.e_stop(v),l&&(l!=r.queryText&&(N(e,r,l),r.posFrom=r.posTo=e.getCursor()),p&&(p.style.opacity=1),w(e,v.shiftKey,function(h,c){var u;c.line<3&&document.querySelector&&(u=e.display.wrapper.querySelector(".CodeMirror-dialog"))&&u.getBoundingClientRect().bottom-4>e.cursorCoords(c,"window").top&&((p=u).style.opacity=.4)}))};A(e,T(e),i,f,function(l,v){var h=a.keyName(l),c=e.getOption("extraKeys"),u=c&&c[h]||a.keyMap[e.getOption("keyMap")][h];u=="findNext"||u=="findPrev"||u=="findPersistentNext"||u=="findPersistentPrev"?(a.e_stop(l),N(e,g(e),v),e.execCommand(u)):(u=="find"||u=="findPersistent")&&(a.e_stop(l),f(v,l))}),o&&i&&(N(e,r,i),w(e,t))}else D(e,T(e),"Search for:",i,function(l){l&&!r.query&&e.operation(function(){N(e,r,l),r.posFrom=r.posTo=e.getCursor(),w(e,t)})})}function w(e,t,n){e.operation(function(){var o=g(e),r=S(e,o.query,t?o.posFrom:o.posTo);!r.find(t)&&(r=S(e,o.query,t?a.Pos(e.lastLine()):a.Pos(e.firstLine(),0)),!r.find(t))||(e.setSelection(r.from(),r.to()),e.scrollIntoView({from:r.from(),to:r.to()},20),o.posFrom=r.from(),o.posTo=r.to(),n&&n(r.from(),r.to()))})}function b(e){e.operation(function(){var t=g(e);t.lastQuery=t.query,t.query&&(t.query=t.queryText=null,e.removeOverlay(t.overlay),t.annotate&&(t.annotate.clear(),t.annotate=null))})}function s(e,t){var n=e?document.createElement(e):document.createDocumentFragment();for(var o in t)n[o]=t[o];for(var r=2;r<arguments.length;r++){var i=arguments[r];n.appendChild(typeof i=="string"?document.createTextNode(i):i)}return n}function T(e){var t=s("label",{className:"CodeMirror-search-label"},e.phrase("Search:"),s("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field",id:"CodeMirror-search-field"}));return t.setAttribute("for","CodeMirror-search-field"),s("",null,t," ",s("span",{style:"color: #666",className:"CodeMirror-search-hint"},e.phrase("(Use /re/ syntax for regexp search)")))}function k(e){return s("",null," ",s("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field"})," ",s("span",{style:"color: #666",className:"CodeMirror-search-hint"},e.phrase("(Use /re/ syntax for regexp search)")))}function I(e){return s("",null,s("span",{className:"CodeMirror-search-label"},e.phrase("With:"))," ",s("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field"}))}function V(e){return s("",null,s("span",{className:"CodeMirror-search-label"},e.phrase("Replace?"))," ",s("button",{},e.phrase("Yes"))," ",s("button",{},e.phrase("No"))," ",s("button",{},e.phrase("All"))," ",s("button",{},e.phrase("Stop")))}function _(e,t,n){e.operation(function(){for(var o=S(e,t);o.findNext();)if(typeof t!="string"){var r=e.getRange(o.from(),o.to()).match(t);o.replace(n.replace(/\$(\d)/g,function(i,p){return r[p]}))}else o.replace(n)})}function E(e,t){if(!e.getOption("readOnly")){var n=e.getSelection()||g(e).lastQuery,o=t?e.phrase("Replace all:"):e.phrase("Replace:"),r=s("",null,s("span",{className:"CodeMirror-search-label"},o),k(e));D(e,r,o,n,function(i){i&&(i=C(i),D(e,I(e),e.phrase("Replace with:"),"",function(p){if(p=P(p),t)_(e,i,p);else{b(e);var f=S(e,i,e.getCursor("from")),l=function(){var h=f.from(),c;!(c=f.findNext())&&(f=S(e,i),!(c=f.findNext())||h&&f.from().line==h.line&&f.from().ch==h.ch)||(e.setSelection(f.from(),f.to()),e.scrollIntoView({from:f.from(),to:f.to()}),j(e,V(e),e.phrase("Replace?"),[function(){v(c)},l,function(){_(e,i,p)}]))},v=function(h){f.replace(typeof i=="string"?p:p.replace(/\$(\d)/g,function(c,u){return h[u]})),l()};l()}}))})}}a.commands.find=function(e){b(e),x(e)},a.commands.findPersistent=function(e){b(e),x(e,!1,!0)},a.commands.findPersistentNext=function(e){x(e,!1,!0,!0)},a.commands.findPersistentPrev=function(e){x(e,!0,!0,!0)},a.commands.findNext=x,a.commands.findPrev=function(e){x(e,!0)},a.commands.clearSearch=b,a.commands.replace=E,a.commands.replaceAll=function(e){E(e,!0)}})})()),F.exports}var $=M();const W=K($),X=B({__proto__:null,default:W},[$]);export{X as s};
//# sourceMappingURL=search-QkkSTJT9.js.map
