import{k as e,aT as t,aD as i,aA as r,aB as s}from"../../../../vendor-element-plus.js?ver=3.1.10";import{aQ as a,W as o,X as n,Z as d,aa as l,ab as c,a5 as h,a9 as _,a8 as m,a0 as f,Y as u}from"../../../../vendor.js?ver=3.1.10";import{F as p}from"../../../../_FormBuilder2.js?ver=3.1.10";import{_ as v}from"../../../../fc-bits-ui.js?ver=3.1.10";import"../../../../PhotoWidget.js?ver=3.1.10";import"../../../../input-popover-dropdown.js?ver=3.1.10";import"../../../../data_config.js?ver=3.1.10";import"../../../../_OptionSelector.js?ver=3.1.10";import"../../../../_AjaxSelector.js?ver=3.1.10";import"../../../../_VerifiedEmailInput.js?ver=3.1.10";const g={key:0,class:"fcrm_external_profile_wrapper"},b={class:"fcrm_external_profile_header"},w={class:"fcrm_external_profile_header--title"},y={key:0,class:"fcrm_external_profile_header--actions"},x=["innerHTML"],j={key:0},F={key:0,style:{padding:"10px 15px"}},k={class:"fc_drawer_footer"};const D=v({name:"SubscriberProfileExternalView",props:["subscriber","subscriber_id"],components:{FormBuilder:p},data(){return{direction:"rtl",profile_section:this.$route.query.handler,heading:"",content_html:"",loading:!0,crud:null,showForm:!1,crudConfig:{},saving:!1}},methods:{fetchData(){this.loading=!0,this.$get(`subscribers/${this.subscriber_id}/external_view`,{section_provider:this.profile_section}).then(e=>{this.heading=e.heading,this.content_html=e.content_html,e.crud&&(this.crud=e.crud)}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading=!1})},initCrudForm(){if(!this.crud.fields)return;const e={};this.each(this.crud.fields,(t,i)=>{e[i]=t.default_value||""}),this.crudConfig.model=e,this.showForm=!0},saveData(){this.saving=!0,this.$post(`subscribers/${this.subscriber_id}/external_view`,{section_provider:this.profile_section,data:this.crudConfig.model}).then(e=>{this.$notify.success(e.message||"Saved successfully"),this.showForm=!1,e.content_html?(this.content_html=e.content_html,e.heading&&(this.heading=e.heading)):this.fetchData()}).catch(e=>{this.handleError(e)}).finally(()=>{this.saving=!1})}},mounted(){window.fcAdmin&&window.fcAdmin.is_rtl&&(this.direction="ltr"),this.fetchData()}},[["render",function(p,v,D,C,S,$){const V=e,z=a("form-builder"),A=t,E=s,B=r,T=i;return S.loading?(o(),u(E,{key:1,style:{"margin-top":"20px"},class:"fc_skeleton_loader",animated:""},{template:h(()=>[c(T,{gutter:30},{default:h(()=>[c(B,{span:12},{default:h(()=>[c(E,{rows:10})],void 0,!0),_:1}),c(B,{span:12},{default:h(()=>[c(E,{rows:3})],void 0,!0),_:1})],void 0,!0),_:1})]),_:1})):(o(),n("div",g,[d("div",b,[d("h3",w,l(S.heading),1),S.crud&&S.crud.btn_label?(o(),n("div",y,[c(V,{onClick:v[0]||(v[0]=e=>$.initCrudForm()),size:"small"},{default:h(()=>[_(l(S.crud.btn_label),1)],void 0),_:1})])):m("",!0)]),d("div",{class:f(["fcrm_external_profile_data","fcrm_section_"+S.profile_section]),innerHTML:S.content_html},null,10,x),S.crud&&S.crud.btn_label?(o(),n("div",j,[c(A,{direction:S.direction,class:"fc_company_info_drawer","with-header":!0,size:p.globalDrawerSize,title:S.crud.form_heading,"append-to-body":!0,modelValue:S.showForm,"onUpdate:modelValue":v[2]||(v[2]=e=>S.showForm=e)},{default:h(()=>[S.showForm?(o(),n("div",F,[c(z,{formData:S.crudConfig.model,fields:S.crud.fields},null,8,["formData","fields"]),d("div",k,[c(V,{type:"primary",onClick:v[1]||(v[1]=e=>$.saveData())},{default:h(()=>[_(l(S.crud.save_btn_text||"Save"),1)],void 0,!0),_:1})])])):m("",!0)],void 0),_:1},8,["direction","size","title","modelValue"])])):m("",!0)]))}]]);export{D as default};
