import x from"./FormBuilder-xBlzIN4Q.js";import{d as C,aa as B,o as L,f as M,A as d,B as E,J as m,_ as S,P as T,O as H,H as N,c as n,r as O,g as i}from"./index-DOFLUERq.js";import{_ as k}from"./_plugin-vue_export-helper-DlAUqK2U.js";const z={key:0,class:"form-builder-field"},w={class:"field-label"},D={key:0,class:"required"},J=["innerHTML"],V=C({__name:"HTML",props:{df:{},record:{},canEdit:{type:Boolean},ctx:{}},setup(r,{expose:y}){const e=r,p=B(),s=O(null),v=n(()=>e.df.label_layout||"vertical"),a=n(()=>e.df.fieldname==="form_builder"),l=n(()=>e.ctx?.entity==="Customize Form"),g=n(()=>l.value&&e.record?.pg_type?e.record.pg_type:e.record?.name||""),_=n(()=>{if(!a.value)return[];try{const t=e.record?.fields;return typeof t=="string"?JSON.parse(t):Array.isArray(t)?t:[]}catch(t){return console.error("Failed to parse fields:",t),[]}});function c(){return s.value?s.value.getFields():null}function h(){if(!a.value||!e.canEdit)return;const t=c();if(t&&e.record)try{e.record.fields=t}catch(o){console.error("[HTML.vue] Failed to sync fields:",o)}}function f(){h()}L(()=>{window.addEventListener("sync-form-builder-fields",f)}),M(()=>{window.removeEventListener("sync-form-builder-fields",f)});function u(t){if(e.canEdit&&a.value)try{const o=JSON.stringify(t);e.record&&(e.record.fields=o)}catch(o){console.error("Failed to update fields:",o)}}function F(t){u(t),e.ctx?.t&&p.success(e.ctx.t("Fields updated"))}function b(t){}return y({getLatestFields:c}),(t,o)=>a.value?(i(),d("div",z,[E(x,{ref_key:"formBuilderRef",ref:s,fields:_.value,pagetype:g.value,"pagetype-record":r.record,readOnly:!r.canEdit,isCustomizeForm:l.value,"onUpdate:fields":u,onSave:F,onDirtyChange:b},null,8,["fields","pagetype","pagetype-record","readOnly","isCustomizeForm"])])):(i(),d("div",{key:1,class:N(["field-wrapper",`layout-${v.value}`])},[m("label",w,[S(T(r.ctx.t(r.df.label||r.df.fieldname))+" ",1),r.df.reqd?(i(),d("span",D,"*")):H("",!0)]),m("div",{class:"html-content",innerHTML:r.record[r.df.fieldname]},null,8,J)],2))}}),A=k(V,[["__scopeId","data-v-79e1b985"]]),q=Object.freeze(Object.defineProperty({__proto__:null,default:A},Symbol.toStringTag,{value:"Module"}));export{A as H,q as _};
