(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:()=>s});var a=r(21483),n=r(30603),d=r(65259),o=r(43821);const c="jp-mod-searchable",i={id:"@jupyterlab/documentsearch:labShellWidgetListener",requires:[a.ILabShell,d.ISearchProviderRegistry],autoStart:!0,activate:(e,t,r)=>{const a=e=>{if(!e)return;const t=r.getProviderForWidget(e);t&&e.addClass(c),t||e.removeClass(c)};r.changed.connect((()=>a(t.activeWidget))),t.activeChanged.connect(((e,t)=>{const r=t.oldValue;r&&r.removeClass(c),a(t.newValue)}))}},s=[{id:"@jupyterlab/documentsearch:plugin",provides:d.ISearchProviderRegistry,requires:[o.ITranslator],optional:[n.ICommandPalette],autoStart:!0,activate:(e,t,r)=>{const a=t.load("jupyterlab"),n=new d.SearchProviderRegistry;n.register("jp-notebookSearchProvider",d.NotebookSearchProvider),n.register("jp-codeMirrorSearchProvider",d.CodeMirrorSearchProvider);const o=new Map,c="documentsearch:start",i="documentsearch:highlightNext",s="documentsearch:highlightPrevious",l=()=>{const t=e.shell.currentWidget;return!!t&&void 0!==n.getProviderForWidget(t)},u=()=>{const r=e.shell.currentWidget;if(!r)return;const a=r.id;let c=o.get(a);if(!c){const i=n.getProviderForWidget(r);if(!i)return;c=new d.SearchInstance(r,i,t),o.set(a,c),e.commands.notifyCommandChanged(),c.disposed.connect((()=>{o.delete(a),e.commands.notifyCommandChanged()}))}return c};return e.commands.addCommand(c,{label:a.__("Find…"),isEnabled:l,execute:()=>{const e=u();e&&e.focusInput()}}),e.commands.addCommand("documentsearch:startWithReplace",{label:a.__("Find and Replace…"),isEnabled:l,execute:()=>{const e=u();e&&(e.showReplace(),e.focusInput())}}),e.commands.addCommand(i,{label:a.__("Find Next"),isEnabled:()=>{const t=e.shell.currentWidget;return!!t&&o.has(t.id)},execute:async()=>{const t=e.shell.currentWidget;if(!t)return;const r=o.get(t.id);r&&(await r.provider.highlightNext(),r.updateIndices())}}),e.commands.addCommand(s,{label:a.__("Find Previous"),isEnabled:()=>{const t=e.shell.currentWidget;return!!t&&o.has(t.id)},execute:async()=>{const t=e.shell.currentWidget;if(!t)return;const r=o.get(t.id);r&&(await r.provider.highlightPrevious(),r.updateIndices())}}),r&&(r.addItem({command:c,category:a.__("Main Area")}),r.addItem({command:i,category:a.__("Main Area")}),r.addItem({command:s,category:a.__("Main Area")})),n}},i]}}]);