import{ap as e,ay as t,k as s,a_ as a,aZ as i,e as n}from"../../../../vendor-element-plus.js?ver=3.1.10";import{aQ as r,a6 as l,W as m,X as o,ab as d,a5 as g,a9 as c,aa as u,Y as _,Z as f}from"../../../../vendor.js?ver=3.1.10";import{C as p}from"../../../../_CustomSegementSettings.js?ver=3.1.10";import{P as h}from"../../../../PageHeader.js?ver=3.1.10";import{_ as v}from"../../../../fc-bits-ui.js?ver=3.1.10";import"../Contacts/RichFilters/Filters.js?ver=3.1.10";import"../../../../_AjaxSelector.js?ver=3.1.10";import"../../../../_TaxonomyTermsSelector.js?ver=3.1.10";import"../../../../_OptionSelector.js?ver=3.1.10";const S={class:"fcrm_create_custom_segment"},y={class:"fcrm_create_segment_content"},C={class:"fcrm_segment_name_input"},$={class:"fcrm_input_label"};const j=v({name:"CreateCustomSegment",components:{PageHeader:h,CustomSegmentSettings:p,ArrowRightBold:e},data:()=>({loading:!1,saving:!1,field_loading:!0,segment:{title:"",filters:[[]]}}),created(){this.ArrowRightBold=e},methods:{createSegment(){this.segment.title?(this.saving=!0,this.$post("dynamic-segments",{segment:JSON.stringify(this.segment),with_subscribers:!1}).then(e=>{this.$notify.success(e.message),this.$router.push({name:"view_segment",params:{slug:e.segment.slug,id:e.segment.id}})}).catch(e=>{this.handleError(e)}).finally(()=>{this.saving=!1})):this.$notify.error(this.$t("Cre_Please_pNotS"))},clearFilters(){this.segment.filters=[[]]}},mounted(){this.changeTitle(this.$t("New Dynamic Segment"))}},[["render",function(e,p,h,v,j,b){const w=i,V=a,A=s,F=r("page-header"),x=n,N=r("custom-segment-settings"),P=t;return l((m(),o("div",S,[d(F,null,{breadcrumb:g(()=>[d(V,{"separator-icon":e.ArrowRightBold},{default:g(()=>[d(w,{to:{name:"dynamic_segments"}},{default:g(()=>[c(u(e.$t("Dynamic Segments")),1)],void 0,!0),_:1}),d(w,null,{default:g(()=>{var t;return[c(u((null==(t=j.segment)?void 0:t.title)?j.segment.title:e.$t("Untitled Segment")),1)]},void 0,!0),_:1})],void 0,!0),_:1},8,["separator-icon"])]),actions:g(()=>[d(A,{onClick:p[0]||(p[0]=e=>b.clearFilters())},{default:g(()=>[c(u(e.$t("Clear Filters")),1)],void 0,!0),_:1}),l((m(),_(A,{onClick:p[1]||(p[1]=e=>b.createSegment()),type:"primary"},{default:g(()=>[c(u(e.$t("Create Custom Segment")),1)],void 0,!0),_:1})),[[P,j.saving]])]),_:1}),f("div",y,[f("div",C,[f("label",$,u(e.$t("Name this Custom Segment")),1),d(x,{class:"fcrm_segment_name_field",placeholder:e.$t("eg: Active contacts"),type:"text",modelValue:j.segment.title,"onUpdate:modelValue":p[2]||(p[2]=e=>j.segment.title=e)},null,8,["placeholder","modelValue"])]),d(N,{onLoaded:p[3]||(p[3]=()=>{j.field_loading=!1}),modelValue:j.segment.filters,"onUpdate:modelValue":p[4]||(p[4]=e=>j.segment.filters=e),segment_id:!1},null,8,["modelValue"])])])),[[P,j.field_loading]])}]]);export{j as default};
