1import{_ as se}from"./BgB7NTNw.js";import{E as T}from"./NnhnsfVz.js";import{a6 as ie,b,a8 as re,r as S,j as o,c as w,t as le,q as k,k as ne,Y as oe,A as i,p as v,v as F,z as C,_ as ce,h as ue,u as me,e as de,d as pe,a as ve,o as ge,M as B,m as ye,n as V}from"./BnRExl1q.js";import{_ as fe}from"./BVs4uDjF.js";import{_ as Ce}from"./CB_ymccZ.js";/* empty css */import{_ as _e}from"./6Jfy6Ito.js";import{_ as he}from"./CYQFEzp_.js";import{_ as be}from"./BZSMSlP3.js";import{_ as xe,g as we,a as Se,s as Ee}from"./a0ZMtHsv.js";import{l as De}from"./Cwr9eIMu.js";import"./BBOSV3bI.js";import"./l0sNRNKZ.js";import"./C4dCmmat.js";import"./CC4OJa0i.js";import"./8SwHjGLF.js";const $e=ie("/img/cpc-empty-state.png"),ke={class:"w-full"};const Ne={class:"w-full bg-grayscale-200 rounded-full h-1.5"},Pe=["onClick"],Le={__name:"CampaignsTable",props:{campaigns:{type:Array,required:!0}},emits:["viewCampaign"],setup(D,{emit:E}){const u=E,x=i([{key:"title",label:"Name"},{key:"creationDate",label:"Creation Date"},{key:"status",label:"Status"},{key:"consumption",label:"Consumption"},{key:"debt",label:"Debt"},{key:"manage",label:"Manage"}]),s=g=>({running:"bg-success-50 text-success-500",stopped:"bg-[#FDE8E9] text-[#FF4D4D]",paused:"bg-[#FEF3E2] text-[#F59E0B]"})[g.toLowerCase()]||"bg-grayscale-50 text-neutral-200";return(g,_)=>(b(),re(he,{columns:x.value,items:D.campaigns},{"cell-status":S(({item:r})=>[o("span",{class:oe(["px-5 py-1 font-medium inline-flex text-sm font-medium rounded-full",s(r.status)])},le(r.status),3)]),"cell-consumption":S(({item:r})=>[o("div",ke,[k("",!0),o("div",Ne,[o("div",{class:"h-1.5 rounded-full transition-all duration-300",style:ne({width:`${r.consumption.current/r.consumption.total*100}%`,background:"linear-gradient(180deg, #4B88FF 0%, #0101FD 100%)"})},null,4)])])]),"cell-manage":S(({item:r})=>[o("button",{onClick:c=>u("viewCampaign",r.id),class:"text-primary hover:text-primary-dark text-sm font-medium"}," View ",8,Pe)]),_:1},8,["columns","items"]))}},Ae={class:"bg-white rounded-xl shadow-sm p-5"},Ie={class:"my-6"},je={class:"flex items-center justify-between"},Me={class:"flex items-center gap-4"},Ue={class:"max-w-[550px] min-w-[250px]"},Be={class:"mt-6"},Ve={class:"flex justify-end mt-4"},Te={__name:"CampaignListSection",props:{campaigns:{type:Array,required:!0}},emits:["viewCampaign","startCampaign"],setup(D,{emit:E}){const u=D,x=E,s=i(""),g=i({sort:""}),_=C(()=>[{title:"Date",items:[{value:"newest",label:"Newest First"},{value:"oldest",label:"Oldest First"}]},{title:"Price",items:[{value:"price_high",label:"Highest Price"},{value:"price_low",label:"Lowest Price"}]}]),r=C(()=>{let c=[...u.campaigns];if(s.value){const a=s.value.toLowerCase();c=c.filter(l=>l.title&&l.title.toLowerCase().includes(a)||l.status&&l.status.toLowerCase().includes(a))}if(g.value.sort)switch(g.value.sort){case"newest":c.sort((a,l)=>new Date(l.CreateDate)-new Date(a.CreateDate));break;case"oldest":c.sort((a,l)=>new Date(a.CreateDate)-new Date(l.CreateDate));break;case"price_high":c.sort((a,l)=>l.MonthlyLimitGrossPrice-a.MonthlyLimitGrossPrice);break;case"price_low":c.sort((a,l)=>a.MonthlyLimitGrossPrice-l.MonthlyLimitGrossPrice);break}return c});return(c,a)=>{const l=Ce,h=T;return b(),w("div",Ae,[a[5]||(a[5]=o("div",{class:"flex items-center justify-between"},[o("h2",{class:"text-xl font-medium"},"Visibility Campaigns")],-1)),o("div",Ie,[o("div",je,[v(l,{type:"text",id:"campaignsearch",variant:"oppsearch",modelValue:s.value,"onUpdate:modelValue":a[0]||(a[0]=d=>s.value=d),placeholder:"Search",class:"lg:w-[360px] bg-white"},{"left-icon":S(()=>[v(be,{class:"text-[#818181]"})]),_:1},8,["modelValue"]),o("div",Me,[o("div",Ue,[v(_e,{modelValue:g.value.sort,"onUpdate:modelValue":a[1]||(a[1]=d=>g.value.sort=d),options:_.value,placeholder:"Sort by",class:"w-full"},null,8,["modelValue","options"])])])])]),v(Le,{campaigns:r.value,onViewCampaign:a[2]||(a[2]=d=>x("viewCampaign",d))},null,8,["campaigns"]),o("div",Be,[o("div",Ve,[v(h,{variant:"small",onClick:a[3]||(a[3]=d=>x("startCampaign"))},{default:S(()=>[...a[4]||(a[4]=[F(" Start New Campaign ",-1)])]),_:1})])])])}}},Fe={class:"main-container"},We={class:""},Re={key:0,class:"flex flex-col items-center justify-center py-16"},Ge={key:1,class:"flex justify-center items-center py-16"},Ye={key:2},qe={key:3},ze={__name:"index",setup(D){const{t:E}=ue();me();const{$bus:u}=de(),x=pe(),s=C(()=>x.profile),g=C(()=>[{text:E("common.campaignsPlans"),to:"/premium/subscription"},{text:"Campaigns",to:"/premium/campaigns"}]);ve({title:"Campaigns"});const _=i([]),r=i([]),c=i([]),a=i(!0),l=i(!1),h=i(!1),d=i(!1),W=i(!1),R=i(1),p=i({UserId:"",Name:"",Currency:"USD",Categories:[],Cities:[],AllCitySelected:!0,DailyLimit:10,MonthlyLimit:300}
1),N=i([]),P=i(!0),G=i("USA"),L=i([]),Y=i(10),q=i(10),z=i(300),H=i([{Name:"USA",Slug:"usa",Enabled:!0},{Name:"UK",Slug:"uk",Enabled:!0},{Name:"Europe",Slug:"europe",Enabled:!0},{Name:"Canada",Slug:"canada",Enabled:!0},{Name:"Australia",Slug:"australia",Enabled:!0},{Name:"Asia",Slug:"asia",Enabled:!0},{Name:"Mena",Slug:"mena",Enabled:!0}]),O=i([]),A=C(()=>_.value.length>0),K=C(()=>r.value.filter(e=>e.CanInsert).map(e=>{var t,n,y;return((n=(t=e.Category)==null?void 0:t.CategoryTranslation)==null?void 0:n.Name)||((y=e.Category)==null?void 0:y.Name)||"Unknown Service"})),J=C(()=>c.value.map(e=>e.Name)),Q=C(()=>H.value.map(e=>e.Name)),X=async()=>{a.value=!0;try{const e=await De({Project:"DijitalAjanslar"});_.value=(e.data.Data||[]).map(t=>{var n;return{id:t.Id,title:((n=t.Advertisement)==null?void 0:n.Title)||"Campaign",creationDate:t.CreateDateBeauty||"",status:t.IsRunning?"running":"stopped",consumption:{current:t.TotalPaidThisMonthGross||0,total:t.MonthlyLimitGrossPrice||1},debt:t.TotalDebtGrossPrice>0?`${t.TotalDebtGrossPrice} ${t.Currency}`:"-",...t}})}catch(e){console.error("Error fetching campaigns:",e)}finally{a.value=!1}},Z=async()=>{try{const e=await we({PageSize:1e5,Project:"DijitalAjanslar"});r.value=e.data.Data||[],r.value.forEach(t=>{t.CanInsert&&p.value.Categories.push({Id:t.Category.Id,Enabled:t.Enabled,CanInsert:t.CanInsert})})}catch(e){console.error("Error fetching services:",e)}},ee=async()=>{try{const e=await Se({PageSize:1e5,Project:"DijitalAjanslar"});c.value=e.data.Data||[],c.value.forEach(t=>{const n={...t};n.Enabled=!0,p.value.Cities.push(n)}),setTimeout(()=>{O.value=p.value.Cities},150)}catch(e){console.error("Error fetching cities:",e)}},te=e=>{V(`/premium/campaigns/${e}`)},I=()=>{if(!s.value){console.error("User not loaded yet");return}if(r.value.length===0){u.emit("notification",{type:"error",message:"You need add more services to start campaign"}),l.value=!0;return}if(r.value.filter(e=>e.CanInsert).length===0){u.emit("notification",{type:"error",message:"All your services are already in active campaigns. Please add a new service, close an existing campaign, or edit your current campaign."});return}if(s.value.WalletCurrency==="TRY"&&s.value.WalletBalance<1500){u.emit("notification",{type:"error",message:"You need to have min 1500 TRY on your wallet to start campaign"});return}if(s.value.WalletCurrency==="USD"&&s.value.WalletBalance<50){u.emit("notification",{type:"error",message:"You need to have min $50 on your wallet to start campaign"});return}d.value=!0},ae=async e=>{if(!s.value){console.error("User not loaded yet");return}if(e.dailyAverage>=s.value.WalletBalance){u.emit("notification",{type:"error",message:`You need to have a minimum of ${s.value.WalletBalance} ${s.value.WalletCurrency} in your wallet to start campaign.`});return}h.value=!0;try{let t="Campaign";e.selectedServices.length>0&&(t=e.selectedServices.slice(0,2).join(", ")+" Campaign");const n={UserId:s.value.Id||"",Name:t,Project:"DijitalAjanslar",Currency:s.value.WalletCurrency,Categories:[],Cities:[],AllCitySelected:e.allCitiesSelected,DailyLimit:e.dailyAverage,MonthlyLimit:e.monthlyLimit};if(e.selectedServices.forEach(f=>{const m=r.value.find($=>{var j,M,U;return((M=(j=$.Category)==null?void 0:j.CategoryTranslation)==null?void 0:M.Name)===f||((U=$.Category)==null?void 0:U.Name)===f});m&&m.CanInsert&&n.Categories.push({Id:m.Category.Id,Enabled:!0})}),n.Categories.length===0){u.emit("notification",{type:"error",message:"Please select at least one service for your campaign"}),h.value=!1;return}if(!e.allCitiesSelected&&(e.selectedCities.forEach(f=>{const m=c.value.find($=>$.Name===f);m&&n.Cities.push({Id:m.Id,Enabled:!0})}),n.Cities.length===0)){u.emit("notification",{type:"error",message:"Please select at least one city for your campaign"}),h.value=!1;return}const y=await Ee(n);y.data.HasExceptionError===!1?(u.emit("notification",{type:"success",message:"Campaign created successfully"}),V(`/premium/campaigns/${y.data.Data}`)):u.emit("notification",{type:"error",message:y.data.Message||"Failed to create campaign"})}catch(t){console.error("Error creating campaign:",t),u.emit("notification",{type:"error",message:"An error occurred while creating campaign"})}finally{h.value=!1}};return ge(()=>{X(),Z(),ee(),s.value&&(p.value.Currency=s.value.WalletCurrency,p.value.Name=`${s.value.FullName} Campaign`,s.value.WalletCurrency==="TRY"?(p.value.DailyLimit=150,p.value.MonthlyLimit=4500):s.value.WalletCurrency==="USD"&&(p.value.DailyLimit=10,p.value.MonthlyLimit=300))}),B(()=>p.value.DailyLimit,e=>{p.value.MonthlyLimit=e*30}),B(()=>W.value,e=>{e||(R.value=1)}),(e,t)=>{var f;const n=se,y=T;return b(),w("div",Fe,[o("div",null,[v(n,{items:g.value},null,8,["items"]),v(fe,{title:"CPC",description:"Identify your target audiences, set a daily spending limit, and secure top positions in search results for your services. Once launched, your campaign will run automatically, driving high-quality traffic and connections to your agency."}),o("div",We,[!A.value&&!a.value&&!d.value?(b(),w("div",Re,[t[5]||(t[5]=ye('<
1div class="mb-6 shadow-[0px_-8px_8px_0px_rgba(0,0,0,0.06)]" data-v-7e8343f8><img src="'+$e+'" alt="CPC Empty State" class="w-45 h-56 object-cover" data-v-7e8343f8></div><div class="text-center mb-6 max-w-md" data-v-7e8343f8><h2 class="text-xl font-semibold text-gray-800 mb-3" data-v-7e8343f8> When you start a CPC it will appear here </h2><p class="text-base text-gray-500 leading-relaxed" data-v-7e8343f8> Discover How to Attract New Customers Through Effective CPC Campaigns </p></div>',2)),v(y,{variant:"default",class:"px-5 py-4 bg-primary hover:bg-primary-dark text-white font-semibold rounded-lg shadow-sm",onClick:I},{default:S(()=>[...t[4]||(t[4]=[F(" Start Campaign ",-1)])]),_:1})])):k("",!0),a.value?(b(),w("div",Ge,[...t[6]||(t[6]=[o("div",{class:"text-gray-500"},"Loading campaigns...",-1)])])):A.value&&!d.value?(b(),w("div",Ye,[v(Te,{campaigns:_.value,onViewCampaign:te,onStartCampaign:I},null,8,["campaigns"])])):k("",!0),d.value?(b(),w("div",qe,[v(xe,{"selected-services":N.value,"all-cities-selected":P.value,"selected-regions":e.selectedRegions,"selected-cities":L.value,"click-to-profile-price":Y.value,"daily-average":q.value,"monthly-limit":z.value,currency:((f=s.value)==null?void 0:f.WalletCurrency)||"USD",loading:h.value,"available-regions":Q.value,"available-services":K.value,"available-cities":J.value,"cities-with-regions":c.value,"onUpdate:selectedServices":t[0]||(t[0]=m=>N.value=m),"onUpdate:allCitiesSelected":t[1]||(t[1]=m=>P.value=m),"onUpdate:selectedRegion":t[2]||(t[2]=m=>G.value=m),"onUpdate:selectedCities":t[3]||(t[3]=m=>L.value=m),onSave:ae},null,8,["selected-services","all-cities-selected","selected-regions","selected-cities","click-to-profile-price","daily-average","monthly-limit","currency","loading","available-regions","available-services","available-cities","cities-with-regions"])])):k("",!0)])])])}}},ct=ce(ze,[["__scopeId","data-v-7e8343f8"]]);export{ct as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.