(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[4212],{24212:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>l});var a=r(21521),n=r(71574),o=r(12033),d=r(67215),c=r(56615);const i="jp-mod-searchable",s={id:"@jupyterlab/documentsearch:labShellWidgetListener",requires:[a.ILabShell,o.ISearchProviderRegistry],autoStart:!0,activate:(e,t,r)=>{const a=e=>{if(!e)return;const t=r.getProviderForWidget(e);t&&e.addClass(i),t||e.removeClass(i)};r.changed.connect((()=>a(t.activeWidget))),t.activeChanged.connect(((e,t)=>{const r=t.oldValue;r&&r.removeClass(i),a(t.newValue)}))}},l=[{id:"@jupyterlab/documentsearch:plugin",provides:o.ISearchProviderRegistry,requires:[c.ITranslator],optional:[n.ICommandPalette,d.ISettingRegistry],autoStart:!0,activate:(e,t,r,a)=>{const n=t.load("jupyterlab");let d=500;const c=new o.SearchProviderRegistry;c.register("jp-notebookSearchProvider",o.NotebookSearchProvider),c.register("jp-codeMirrorSearchProvider",o.CodeMirrorSearchProvider);const i=new Map,s="documentsearch:start",l="documentsearch:highlightNext",u="documentsearch:highlightPrevious";if(a){const t=a.load("@jupyterlab/documentsearch-extension:plugin"),r=e=>{d=e.get("searchDebounceTime").composite};Promise.all([t,e.restored]).then((([e])=>{r(e),e.changed.connect((e=>{r(e)}))})).catch((e=>{console.error(e.message)}))}const h=()=>{const t=e.shell.currentWidget;return!!t&&void 0!==c.getProviderForWidget(t)},m=()=>{const r=e.shell.currentWidget;if(!r)return;const a=r.id;let n=i.get(a);if(!n){const s=c.getProviderForWidget(r);if(!s)return;n=new o.SearchInstance(r,s,t,d),i.set(a,n),e.commands.notifyCommandChanged(),n.disposed.connect((()=>{i.delete(a),e.commands.notifyCommandChanged()}))}return n};return e.commands.addCommand(s,{label:n.__("Find…"),isEnabled:h,execute:()=>{const e=m();e&&e.focusInput()}}),e.commands.addCommand("documentsearch:startWithReplace",{label:n.__("Find and Replace…"),isEnabled:h,execute:()=>{const e=m();e&&(e.showReplace(),e.focusInput())}}),e.commands.addCommand(l,{label:n.__("Find Next"),isEnabled:()=>{const t=e.shell.currentWidget;return!!t&&i.has(t.id)},execute:async()=>{const t=e.shell.currentWidget;if(!t)return;const r=i.get(t.id);r&&(await r.provider.highlightNext(),r.updateIndices())}}),e.commands.addCommand(u,{label:n.__("Find Previous"),isEnabled:()=>{const t=e.shell.currentWidget;return!!t&&i.has(t.id)},execute:async()=>{const t=e.shell.currentWidget;if(!t)return;const r=i.get(t.id);r&&(await r.provider.highlightPrevious(),r.updateIndices())}}),r&&(r.addItem({command:s,category:n.__("Main Area")}),r.addItem({command:l,category:n.__("Main Area")}),r.addItem({command:u,category:n.__("Main Area")})),c}},s]}}]);