"use strict";(self.webpackChunk_elyra_metadata_extension=self.webpackChunk_elyra_metadata_extension||[]).push([[509],{8509:function(e,t,a){var n=this&&this.__awaiter||function(e,t,a,n){return new(a||(a=Promise))((function(d,i){function o(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?d(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(o,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const d=a(5432),i=a(8482),o=a(792),s=a(5607),l=a(9246),r=a(8745),c=a(9104),m=a(9346),u=a(4053),h="elyra-metadata-editor",p="elyra-metadata",f="@elyra/metadata-extension",y="elyra-metadata:open",v={id:p,autoStart:!0,requires:[l.ICommandPalette,r.IEditorServices,s.ILabStatus,m.IFormRendererRegistry,c.ITranslator],activate:(e,t,a,s,r,c)=>n(void 0,void 0,void 0,(function*(){var n,v;console.log("Elyra - metadata extension is activated!"),r.addRenderer(`${f}:plugin.code`,{fieldRenderer:e=>(0,o.CodeBlock)(e)}),r.addRenderer(`${f}:plugin.tags`,{fieldRenderer:e=>(0,o.TagsField)(e)}),r.addRenderer(`${f}:plugin.dropdown`,{fieldRenderer:e=>(0,o.DropDown)(e)}),r.addRenderer(`${f}:plugin.password`,{fieldRenderer:e=>(0,o.PasswordField)(e)}),e.commands.addCommand(`${h}:open`,{label:e=>`New ${e.title} ${e.appendToTitle?e.titleContext:""}`,execute:t=>{(t=>{let n;n=t.name?t.name:`New ${t.schema}`;const i=`${h}:${t.schemaspace}:${t.schema}:${t.name?t.name:"new"}`;if((0,u.find)(e.shell.widgets("main"),(e=>e.id===i)))return void e.shell.activateById(i);const o=new d.MetadataEditorWidget(Object.assign(Object.assign({},t),{schemaName:t.schema,editorServices:a,status:s,translator:c.load("jupyterlab"),componentRegistry:r})),p=new l.MainAreaWidget({content:o});p.title.label=n,p.id=i,p.title.closable=!0,p.title.icon=m.textEditorIcon,o.addClass(h),e.shell.add(p,"main")})(t)}});const g=y;e.commands.addCommand(g,{label:e=>e.label,execute:t=>{(t=>{const a=m.LabIcon.resolve({icon:t.icon}),n=`${p}:${t.schemaspace}`,i=new d.MetadataWidget({app:e,display_name:t.display_name,schemaspace:t.schemaspace,icon:a,addLabel:t.addLabel});i.id=n,i.title.icon=a,i.title.caption=t.display_name,void 0===(0,u.find)(e.shell.widgets("left"),(e=>e.id===n))&&e.shell.add(i,"left",{rank:1e3}),e.shell.activateById(n)})(t)}});const w="elyra-metadata:close";e.commands.addCommand(w,{label:"Close Tab",execute:t=>{const a=e.contextMenuHitTest((e=>!!e.dataset.id));if(a){const t=a.dataset.id,n=(0,u.find)(e.shell.widgets("left"),((e,a)=>e.id===t));n&&n.dispose()}}}),e.contextMenu.addItem({selector:'[data-id^="elyra-metadata:"]:not([data-id$="code-snippets"]):not([data-id$="runtimes"])',command:w});try{const e=yield i.MetadataService.getAllSchema();if(!e)throw new Error("Failed to retrieve metadata schemas");for(const a of e){let e="ui-components:text-editor",d=a.title;a.uihints&&(a.uihints.icon&&(e=a.uihints.icon),a.uihints.title&&(d=a.uihints.title)),t.addItem({command:y,args:{label:`Manage ${d}`,display_name:null!==(v=null===(n=a.uihints)||void 0===n?void 0:n.title)&&void 0!==v?v:"",schemaspace:a.schemaspace,icon:e},category:"Elyra"})}}catch(e){yield o.RequestErrors.serverError(e)}}))};t.default=v}}]);