(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[404],{49880:(y,w,n)=>{"use client";const{createElement:M,useEffect:r,useRef:i}=n(96540);function v({html:u,dangerouslySetInnerHTML:p,allowRerender:x,...S}){const d=i(null),m=i(!0);return r(()=>{if(!u||!d.current)throw new Error("html prop can't be null");if(!m.current)return;m.current=!!x;const g=document.createRange().createContextualFragment(u);d.current.innerHTML="",d.current.appendChild(g)},[u,d]),M("div",{...S,ref:d})}y.exports=v},37683:(y,w,n)=>{"use strict";n.r(w),n.d(w,{plugin:()=>O});var M=n(68256),r=n(74848),i=n(22803),v=n(49880),u=n.n(v),p=n(96540),x=n(40996),S=n(84099),d=n(60997),m=n(29675),g=n(3886),T=n(99134),C=n(88023),s=(e=>(e.Code="code",e.HTML="html",e.Markdown="markdown",e))(s||{}),P=(e=>(e.Go="go",e.Html="html",e.Json="json",e.Markdown="markdown",e.Plaintext="plaintext",e.Sql="sql",e.Typescript="typescript",e.Xml="xml",e.Yaml="yaml",e))(P||{});const R="plaintext",h={language:"plaintext",showLineNumbers:!1,showMiniMap:!1},b={content:`# Title

For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)`,mode:"markdown"};function j(e){const a=(0,m.of)(k),[o,c]=(0,p.useState)({mode:e.options.mode,content:H(e.options,e.replaceVariables,C.Ay.disableSanitizeHtml)});if((0,x.A)(()=>{const{options:t,replaceVariables:f}=e,l=H(t,f,C.Ay.disableSanitizeHtml);(l!==o.content||t.mode!==o.mode)&&c({mode:t.mode,content:l})},100,[e]),o.mode===s.Code){const t=e.options.code??h;return(0,r.jsx)(g.B,{value:o.content,language:t.language??h.language,width:e.width,height:e.height,containerStyles:a.codeEditorContainer,showMiniMap:t.showMiniMap,showLineNumbers:t.showLineNumbers,readOnly:!0},`${t.showLineNumbers}/${t.showMiniMap}`)}return(0,r.jsx)("div",{className:a.containStrict,children:(0,r.jsx)(T.P,{minHeight:"100%",children:(0,r.jsx)(u(),{allowRerender:!0,html:o.content,className:"markdown-html","data-testid":"TextPanel-converted-content"})})})}function H(e,a,o){let{mode:c,content:t}=e;if(t=a(t,{},e.code?.language==="json"?"json":"html"),!t)return" ";switch(c){case s.Code:break;case s.HTML:o||(t=S.sQ.sanitizeTextPanelContent(t));break;case s.Markdown:default:t=(0,d.P)(t,{noSanitize:o})}return t}const k=e=>({codeEditorContainer:(0,i.css)({".monaco-editor .margin, .monaco-editor-background":{backgroundColor:e.colors.background.primary}}),containStrict:(0,i.css)({contain:"strict",height:"100%"})});var N=n(70713),B=n(86266);const E=({value:e,onChange:a,context:o})=>{const c=(0,p.useMemo)(()=>o.options?.mode??s.Markdown,[o]),t=(0,m.of)(V),f=()=>o.getSuggestions?o.getSuggestions().map(l=>(0,B.O)(l)):[];return(0,r.jsx)("div",{className:(0,i.cx)(t.editorBox),children:(0,r.jsx)(N.default,{disableHeight:!0,children:({width:l})=>l===0?null:(0,r.jsx)(g.B,{value:e,onBlur:a,onSave:a,language:c,width:l,showMiniMap:!1,showLineNumbers:!1,height:"500px",getSuggestions:f})})})},V=e=>({editorBox:(0,i.css)({label:"editorBox",border:`1px solid ${e.colors.border.medium}`,borderRadius:e.shape.radius.default,margin:e.spacing(.5,0),width:"100%"})}),L=e=>{const a=parseFloat(e.pluginVersion||"6.1");let o=e.options;if(e.hasOwnProperty("content")&&e.hasOwnProperty("mode")){const t=e,f=t.content,l=t.mode;delete t.content,delete t.mode,a<7.1&&(o={content:f,mode:l})}return[s.Code,s.HTML,s.Markdown].find(t=>t===o.mode)||(o={...o,mode:s.Markdown}),o},O=new M.m(j).setPanelOptions(e=>{e.addRadio({path:"mode",name:"Mode",settings:{options:[{value:s.Markdown,label:"Markdown"},{value:s.HTML,label:"HTML"},{value:s.Code,label:"Code"}]},defaultValue:b.mode}).addSelect({path:"code.language",name:"Language",settings:{options:Object.values(P).map(a=>({value:a,label:a}))},defaultValue:h.language,showIf:a=>a.mode===s.Code}).addBooleanSwitch({path:"code.showLineNumbers",name:"Show line numbers",defaultValue:h.showLineNumbers,showIf:a=>a.mode===s.Code}).addBooleanSwitch({path:"code.showMiniMap",name:"Show mini map",defaultValue:h.showMiniMap,showIf:a=>a.mode===s.Code}).addCustomEditor({id:"content",path:"content",name:"Content",editor:E,defaultValue:b.content})}).setMigrationHandler(L)}}]);

//# sourceMappingURL=textPanel.2d654d6101a5d8f71603.js.map