import{d as y,c as b,r as x,z as d,e as l,f as p,s as T,g as L,k as $,B as C,n as u}from"./index-a0da86f0.js";import{_ as E}from"./_plugin-vue_export-helper-c27b6911.js";const H={class:"field-label"},k={key:0,class:"required"},M=["innerHTML"],j=y({__name:"HTML",props:{df:{},record:{},canEdit:{type:Boolean},ctx:{}},setup(m,{expose:f}){const t=m,v=b(()=>t.df.label_layout||"vertical"),n=x(""),i=()=>{if(t.df.fieldname==="preview_html")return _();let e=t.df.options||"";e=t.ctx.t?t.ctx.t(e):e;try{return t.ctx.render?t.ctx.render(e,t):e}catch(o){return console.warn("HTML模板渲染失败:",o),e}},_=()=>{var c;const e=t.record,o=e.file_url,a=(c=e.file_type)==null?void 0:c.toLowerCase();return o?g(o)?`<div class="img_preview">
      <img
        class="img-responsive"
        src="${s(o)}"
        onerror="this.parentElement.style.display='none'"
      />
    </div>`:w(o)?`<div class="img_preview">
      <video width="480" height="320" controls>
        <source src="${s(o)}">
        ${t.ctx.t?t.ctx.t("Your browser does not support the video element."):"Your browser does not support the video element."}
      </video>
    </div>`:a==="pdf"?`<div class="img_preview">
      <object style="background:#323639;" width="100%">
        <embed
          style="background:#323639;"
          width="100%"
          height="1190"
          src="${s(o)}" type="application/pdf"
        >
      </object>
    </div>`:a==="mp3"?`<div class="img_preview">
      <audio width="480" height="60" controls>
        <source src="${s(o)}" type="audio/mpeg">
        ${t.ctx.t?t.ctx.t("Your browser does not support the audio element."):"Your browser does not support the audio element."}
      </audio>
    </div>`:"":""},g=e=>/\.(gif|jpg|jpeg|tiff|png|webp|bmp|svg)$/i.test(e),w=e=>/\.(mp4|avi|mov|wmv|flv|webm|mkv)$/i.test(e),s=e=>{const o=document.createElement("div");return o.textContent=e,o.innerHTML},r=()=>{n.value=i()},h=e=>{e&&typeof e=="object"&&e.appendTo?(console.warn("jQuery对象在Vue中需要特殊处理"),t.df.options=e.toString()):t.df.options=e,r()};return d(()=>t.df.options,()=>{r()},{immediate:!0}),d(()=>t.record,()=>{r()},{deep:!0,immediate:!0}),f({setValue:h,refreshContent:r,getContent:i}),(e,o)=>(u(),l("div",{class:C(["field-wrapper",`layout-${v.value}`])},[p("label",H,[T(L(e.ctx.t(e.df.label||e.df.fieldname))+" ",1),e.df.reqd?(u(),l("span",k,"*")):$("",!0)]),p("div",{class:"html-content",innerHTML:n.value},null,8,M)],2))}});const Y=E(j,[["__scopeId","data-v-de6666a8"]]);export{Y as default};
