"use strict";(self.webpackChunk_elyra_code_viewer_extension=self.webpackChunk_elyra_code_viewer_extension||[]).push([[509],{434:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CodeViewerWidget=void 0;const i=o(131),n=o(256);class d extends n.Widget{constructor(e){super(),this.getContent=()=>this.model.sharedModel.getSource(),this.getMimeType=()=>this.model.mimeType,this.model=e.model;const t=new i.CodeEditorWrapper({factory:e.factory,model:e.model});this.editor=t.editor,this.editor.setOption("readOnly",!0),(this.layout=new n.StackedLayout).addWidget(t)}static getCodeViewer(e){const t=new i.CodeEditor.Model({mimeType:e.mimeType});return t.sharedModel.source=e.content,new d({factory:e.factory,model:t})}}t.CodeViewerWidget=d},509:function(e,t,o){var i=this&&this.__awaiter||function(e,t,o,i){return new(o||(o=Promise))((function(n,d){function r(e){try{a(i.next(e))}catch(e){d(e)}}function c(e){try{a(i.throw(e))}catch(e){d(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(r,c)}a((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const n=o(909),d=o(200),r=o(131),c=o(460),a=o(53),l=o(434),s="elyra-code-viewer-extension",m="elyra-code-viewer:open",u={id:s,autoStart:!0,requires:[r.IEditorServices],optional:[n.ILayoutRestorer],activate:(e,t,o)=>{console.log("Elyra - code-viewer extension is activated!");const n=new d.WidgetTracker({namespace:s});o&&o.restore(n,{command:m,args:e=>({content:e.content.getContent(),label:e.content.title.label,mimeType:e.content.getMimeType(),widgetId:e.content.id}),name:e=>e.content.id}),e.commands.addCommand(m,{execute:o=>(o=>i(void 0,void 0,void 0,(function*(){var i;const r=t.factoryService.newDocumentEditor;let s=o.mimeType;!s&&o.extension&&(s=t.mimeTypeService.getMimeTypeByFilePath(`temp.${o.extension.replace(/\\.$/,"")}`));const m=l.CodeViewerWidget.getCodeViewer({factory:e=>r(e),content:o.content,mimeType:s});m.title.label=o.label||"Code Viewer",m.title.caption=m.title.label;const u=(0,a.toArray)(e.docRegistry.fileTypes()).find((e=>s?e.mimeTypes.includes(s):void 0));m.title.icon=null!==(i=null==u?void 0:u.icon)&&void 0!==i?i:c.textEditorIcon,o.widgetId&&(m.id=o.widgetId);const y=new d.MainAreaWidget({content:m});return yield n.add(y),e.shell.add(y,"main"),m})))(o)})}};t.default=u}}]);