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.0";import{C as r}from"../../../../_CustomSegementSettings.js?ver=3.1.0";import{P as l}from"../../../../PageHeader.js?ver=3.1.0";import{r as o,K as m,c as d,o as g,d as c,b as u,w as _,O as f,P as p,a as h}from"../../../../vendor.js?ver=3.1.0";import{_ as v}from"../../../../fc-bits-ui.js?ver=3.1.0";import"../Contacts/RichFilters/Filters.js?ver=3.1.0";import"../../../../_AjaxSelector.js?ver=3.1.0";import"../../../../_TaxonomyTermsSelector.js?ver=3.1.0";import"../../../../_OptionSelector.js?ver=3.1.0";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:l,CustomSegmentSettings:r,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,r,l,v,j,b){const w=i,V=a,A=s,F=o("page-header"),P=n,x=o("custom-segment-settings"),N=t;return m((g(),d("div",S,[c(F,null,{breadcrumb:_(()=>[c(V,{"separator-icon":e.ArrowRightBold},{default:_(()=>[c(w,{to:{name:"dynamic_segments"}},{default:_(()=>[f(p(e.$t("Dynamic Segments")),1)],void 0,!0),_:1}),c(w,null,{default:_(()=>{var t;return[f(p((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:_(()=>[c(A,{onClick:r[0]||(r[0]=e=>b.clearFilters())},{default:_(()=>[f(p(e.$t("Clear Filters")),1)],void 0,!0),_:1}),m((g(),h(A,{onClick:r[1]||(r[1]=e=>b.createSegment()),type:"primary"},{default:_(()=>[f(p(e.$t("Create Custom Segment")),1)],void 0,!0),_:1})),[[N,j.saving]])]),_:1}),u("div",y,[u("div",C,[u("label",$,p(e.$t("Name this Custom Segment")),1),c(P,{class:"fcrm_segment_name_field",placeholder:e.$t("eg: Active contacts"),type:"text",modelValue:j.segment.title,"onUpdate:modelValue":r[2]||(r[2]=e=>j.segment.title=e)},null,8,["placeholder","modelValue"])]),c(x,{onLoaded:r[3]||(r[3]=()=>{j.field_loading=!1}),modelValue:j.segment.filters,"onUpdate:modelValue":r[4]||(r[4]=e=>j.segment.filters=e),segment_id:!1},null,8,["modelValue"])])])),[[N,j.field_loading]])}]]);export{j as default};
