(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[404],{49880(S,w,o){"use client";const{createElement:p,useEffect:i,useRef:g}=o(96540);function r({html:l,dangerouslySetInnerHTML:y,allowRerender:v,...f}){const d=g(null),x=g(!0);return i(()=>{if(!l||!d.current)throw new Error("html prop can't be null");if(!x.current)return;x.current=!!v;const M=document.createRange().createContextualFragment(l);d.current.innerHTML="",d.current.appendChild(M)},[l,d]),p("div",{...f,ref:d})}S.exports=r},40425(S,w,o){"use strict";o.r(w),o.d(w,{plugin:()=>z});var p=o(16207),i=o(92745),g=o(43173),r=o(74848),l=o(22803),y=o(49880),v=o.n(y),f=o(96540),d=o(40996),x=o(63704),M=o(67458),C=o(63142),b=o(50992),k=o(92807),H=o(65642),a=(t=>(t.Code="code",t.HTML="html",t.Markdown="markdown",t))(a||{}),P=(t=>(t.Go="go",t.Html="html",t.Json="json",t.Markdown="markdown",t.Plaintext="plaintext",t.Sql="sql",t.Typescript="typescript",t.Xml="xml",t.Yaml="yaml",t))(P||{});const F="plaintext",u={language:"plaintext",showLineNumbers:!1,showMiniMap:!1},T={content:`# Title

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

//# sourceMappingURL=textPanel.22b4c77d45b2a81983ce.js.map