import{A as e,O as t,Pt as n,Tt as r,Z as i,et as a,k as o}from"./vue-vendor-DMUmTARL.js";import{K as s,v as c,yt as l}from"./index-kSn5YXd0.js";import{n as u,t as d}from"./vue-codemirror-CgLyDusf.js";var f={class:`h-full`},p={__name:`TextViewer`,props:{fileUrl:{type:String,default:``},fileName:{type:String,default:``}},setup(p,{expose:m}){let h=c(),g=l(),_=p,v=s(_.fileName),y=r(null),b=r(),x=r(``),S=r(!1),C=e=>(e??``).replace(/\r\n/g,`
`),w=()=>b.value?.getCode?.()??``;i(()=>{let e=_.fileUrl;u(e).then(e=>{y.value=e.request.response}).catch(()=>{h.error(`加载文本文件失败. 请检查此地址是否有效或是否限制了跨域访问.`,{duration:0,grouping:!0})})});let T=e=>{S.value||=(x.value=C(e),!0)},E=()=>{x.value=C(w())};return m({isDirty:()=>!g?.permission?.textEdit||!S.value?!1:C(w())!==x.value}),(r,i)=>(a(),e(`div`,f,[n(y)?(a(),t(d,{key:0,ref_key:`vceRef`,ref:b,"file-name":p.fileName,"model-value":n(y),language:n(v),readonly:!n(g).permission.textEdit,onLoadText:T,onSaved:E},null,8,[`file-name`,`model-value`,`language`,`readonly`])):o(``,!0)]))}};export{p as default};