UNPKG

iobroker.javascript

Version:
1 lines 1.5 kB
import{Hn as e,It as t,Lt as n,Pt as r,Un as i,bt as a,cr as o,f as s,mr as c,or as l,vt as u,yr as d,zt as f}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-CxICLr5Z.js";d();var p=({originalCode:d,modifiedCode:p,language:m,themeType:h,onAccept:g,onReject:_})=>{let v=c(null),y=c(null),b=c(null);o(()=>{let e=window.monaco;if(!e||!v.current)return;let t=e.editor.createDiffEditor(v.current,{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,theme:h===`dark`?`vs-dark`:`vs`,scrollBeyondLastLine:!1,minimap:{enabled:!1}}),n=e.editor.createModel(d,m),r=e.editor.createModel(p,m);return b.current=r,t.setModel({original:n,modified:r}),y.current=t,()=>{t.dispose(),n.dispose(),r.dispose(),y.current=null,b.current=null}},[d,p,m,h]);let x=l(()=>{var e;g(((e=b.current)==null?void 0:e.getValue())||p)},[p,g]);return i(n,{sx:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`},children:[i(r,{variant:`dense`,sx:{minHeight:36,bgcolor:`background.paper`,borderBottom:`1px solid`,borderColor:`divider`,gap:1,flexShrink:0},children:[e(t,{variant:`subtitle2`,sx:{flex:1},children:s.t(`AI suggested changes`)}),e(f,{variant:`contained`,color:`success`,size:`small`,startIcon:e(a,{}),onClick:x,children:s.t(`Accept`)}),e(f,{variant:`outlined`,color:`error`,size:`small`,startIcon:e(u,{}),onClick:_,children:s.t(`Reject`)})]}),e(n,{ref:v,sx:{flex:1,overflow:`hidden`}})]})};export{p as default};