import{k as e,aT as t,aD as i,aA as r,aB as s}from"../../../../vendor-element-plus.js?ver=3.1.0";import{F as a}from"../../../../_FormBuilder2.js?ver=3.1.0";import{r as o,c as n,a as d,o as l,b as c,L as h,P as _,d as m,w as f,O as u,n as p}from"../../../../vendor.js?ver=3.1.0";import{_ as v}from"../../../../fc-bits-ui.js?ver=3.1.0";import"../../../../PhotoWidget.js?ver=3.1.0";import"../../../../input-popover-dropdown.js?ver=3.1.0";import"../../../../data_config.js?ver=3.1.0";import"../../../../_OptionSelector.js?ver=3.1.0";import"../../../../_AjaxSelector.js?ver=3.1.0";import"../../../../_VerifiedEmailInput.js?ver=3.1.0";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:a},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(a,v,D,C,S,$){const V=e,z=o("form-builder"),A=t,E=s,B=r,L=i;return S.loading?(l(),d(E,{key:1,style:{"margin-top":"20px"},class:"fc_skeleton_loader",animated:""},{template:f(()=>[m(L,{gutter:30},{default:f(()=>[m(B,{span:12},{default:f(()=>[m(E,{rows:10})],void 0,!0),_:1}),m(B,{span:12},{default:f(()=>[m(E,{rows:3})],void 0,!0),_:1})],void 0,!0),_:1})]),_:1})):(l(),n("div",g,[c("div",b,[c("h3",w,_(S.heading),1),S.crud&&S.crud.btn_label?(l(),n("div",y,[m(V,{onClick:v[0]||(v[0]=e=>$.initCrudForm()),size:"small"},{default:f(()=>[u(_(S.crud.btn_label),1)],void 0),_:1})])):h("",!0)]),c("div",{class:p(["fcrm_external_profile_data","fcrm_section_"+S.profile_section]),innerHTML:S.content_html},null,10,x),S.crud&&S.crud.btn_label?(l(),n("div",j,[m(A,{direction:S.direction,class:"fc_company_info_drawer","with-header":!0,size:a.globalDrawerSize,title:S.crud.form_heading,"append-to-body":!0,modelValue:S.showForm,"onUpdate:modelValue":v[2]||(v[2]=e=>S.showForm=e)},{default:f(()=>[S.showForm?(l(),n("div",F,[m(z,{formData:S.crudConfig.model,fields:S.crud.fields},null,8,["formData","fields"]),c("div",k,[m(V,{type:"primary",onClick:v[1]||(v[1]=e=>$.saveData())},{default:f(()=>[u(_(S.crud.save_btn_text||"Save"),1)],void 0,!0),_:1})])])):h("",!0)],void 0),_:1},8,["direction","size","title","modelValue"])])):h("",!0)]))}]]);export{D as default};
