PageSourceSearch

https://www.affirmly.ai/_nuxt/DqCe-DJt.js

js affirmly.ai collected 2026-10-05 11:54:36 UTC 15,928 bytes, 1 lines download raw bytes

1import{d as I,j as J,G as x,o as c,b as i,c as j,D as L,w as d,a as n,L as T,M as q,e as P,E as k,f as A,K as F,_ as Z,at as ee,a6 as te,O as S,k as ae,ax as oe,P as K,g as re,aJ as ne}from"./DWBTFSs4.js";import{_ as R}from"./CdY_-mzU.js";import{_ as G}from"./B22Y1cRN.js";import{_ as W}from"./CrPppqVZ.js";import{_ as Q}from"./DPrJNNYe.js";import{_ as le}from"./CE1uSi0C.js";import{u as se}from"./D-B3WzuT.js";import{u as H}from"./D8_vfc4b.js";import{_ as ie}from"./DkKwW8ui.js";import{_ as de}from"./CNkTqS6l.js";import"./CzCEorJq.js";import"./WD-CLJgk.js";import"./C7iHY1xY.js";import"./CDmeRWlv.js";import"./BkUdjZ_h.js";import"./CxIZtCgj.js";import"./BeOjpRKa.js";const ue={class:"space-y-4"},ce={class:"space-y-2"},me={class:"overflow-x-auto pb-2"},fe={class:"flex space-x-2 min-w-min"},pe={key:0,class:"overflow-x-auto pb-2"},_e={class:"flex space-x-2 min-w-min"},ye={class:"overflow-x-auto pb-2"},ge={class:"flex space-x-2 min-w-min"},ve={key:1,class:"text-sm text-gray-600"},he=I({__name:"CategorySelector",props:{modelValue:{}},emits:["update:modelValue"],setup(V,{emit:E}){const g=V,$=E,{categories:f,selectedCategories:p,selectedSubcategories:w,availableSubcategories:O,addCategory:B,removeCategory:l,addSubcategory:o,removeSubcategory:_,currentState:v}=se(g.modelValue),b=J(()=>{const t=new Set(f.map(e=>e.name));return p.value.filter(e=>!t.has(e))});function m(t){p.value.includes(t)?l(t):B(t),C()}function s(t){w.value.includes(t)?_(t):o(t),C()}function C(){$("update:modelValue",v.value)}return(t,e)=>{const a=P,u=Z,h=G;return c(),x("div",ue,[i(h,{label:"Categories"},{default:d(()=>[n("div",ce,[n("div",me,[n("div",fe,[(c(!0),x(T,null,q(k(f),r=>(c(),j(a,{key:r.name,color:k(p).includes(r.name)?"primary":"gray",variant:"soft",size:"xs",class:"whitespace-nowrap",onClick:U=>m(r.name)},{default:d(()=>[A(F(r.name),1)]),_:2},1032,["color","onClick"]))),128))])]),b.value.length>0?(c(),x("div",pe,[n("div",_e,[(c(!0),x(T,null,q(b.value,r=>(c(),j(a,{key:r,color:"primary",variant:"outline",size:"xs",class:"whitespace-nowrap"},{default:d(()=>[A(F(r)+" ",1),i(u,{name:"i-heroicons-x-mark",class:"ml-1 w-3 h-3",onClick:ee(U=>k(l)(r),["stop"])},null,8,["onClick"])]),_:2},1024))),128))])])):L("",!0)])]),_:1}),k(p).length>0?(c(),j(h,{key:0,label:"Subcategories"},{default:d(()=>[n("div",ye,[n("div",ge,[(c(!0),x(T,null,q(k(O),r=>(c(),j(a,{key:r,color:k(w).includes(r)?"primary":"gray",variant:"soft",size:"xs",class:"whitespace-nowrap",onClick:U=>s(r)},{default:d(()=>[A(F(r),1)]),_:2},1032,["color","onClick"]))),128))])])]),_:1})):L("",!0),k(p).length>0?(c(),x("div",ve," Selected: "+F(k(p).join(", "))+" "+F(k(w).length?" → "+k(w).join(", "):""),1)):L("",!0)])}}}),X=te(he,[["__scopeId","data-v-0bc6aa3f"]]),be={class:"p-4 space-y-4"},xe={class:"flex items-center space-x-3 mb-4"},we=["src","alt"],Ce={class:"font-medium"},Ue={class:"overflow-y-auto max-h-[2.5rem]"},ke={class:"text-sm text-gray-600 dark:text-gray-300"},$e={class:"flex justify-end gap-3"},Fe=I({__name:"AddToFeaturedModal",props:{isOpen:{type:Boolean},affirmation:{},isLoading:{type:Boolean}},emits:["update:isOpen","add"],setup(V,{emit:E}){var o,_,v,b;H();const g=V,$=E,f=S({placement:"home",featuredUntil:"",displayOrder:0,categories:"",subcategories:""}),p=S({categories:((_=(o=g.affirmation)==null?void 0:o.categories)==null?void 0:_.split(",").filter(Boolean))||[],subcategories:((b=(v=g.affirmation)==null?void 0:v.subcategories)==null?void 0:b.split(",").filter(Boolean))||[]});function w(m){p.value=m,f.value.categories=m.categories.join(","),f.value.subcategories=m.subcategories.join(",")}const O=[{label:"Home",value:"home"},{label:"Affirmation of the Day",value:"affirmation-of-the-day"}],B=()=>{var m,s,C,t;f.value={placement:"home",featuredUntil:"",displayOrder:0,categories:"",subcategories:""},p.value={categories:((s=(m=g.affirmation)==null?void 0:m.categories)==null?void 0:s.split(",").filter(Boolean))||[],subcategories:((t=(C=g.affirmation)==null?void 0:C.subcategories)==null?void 0:t.split(",").filter(Boolean))||[]},$("update:isOpen",!1)},l=()=>{$("add",g.affirmation,{...f.value,expiresAt:f.value.featuredUntil||null,categoryState:{categories:p.value.categories,subcategories:p.value.subcategories}})};return ae(()=>g.isOpen,m=>{var s,C,t,e;m&&(p.value={categories:((C=(s=g.affirmation)==null?void 0:s.categories)==null?void 0:C.split(",").filter(
1Boolean))||[],subcategories:((e=(t=g.affirmation)==null?void 0:t.subcategories)==null?void 0:e.split(",").filter(Boolean))||[]})}),(m,s)=>{const C=R,t=G,e=W,a=P,u=Q,h=le;return c(),j(h,{modelValue:m.isOpen,"onUpdate:modelValue":s[4]||(s[4]=r=>m.$emit("update:isOpen",r))},{default:d(()=>[i(u,null,{header:d(()=>s[5]||(s[5]=[n("div",{class:"flex items-center justify-between"},[n("h3",{class:"text-base font-semibold"},"Add to Featured Content")],-1)])),footer:d(()=>[n("div",$e,[i(a,{color:"gray",variant:"soft",onClick:B},{default:d(()=>s[6]||(s[6]=[A(" Cancel ")])),_:1}),i(a,{color:"primary",loading:m.isLoading,onClick:l},{default:d(()=>s[7]||(s[7]=[A(" Add to Featured ")])),_:1},8,["loading"])])]),default:d(()=>[n("div",be,[n("div",xe,[n("img",{src:m.affirmation.thumbnail_url||"/default-thumbnail.jpg",alt:m.affirmation.title,class:"w-12 h-12 rounded object-cover"},null,8,we),n("div",null,[n("h4",Ce,F(m.affirmation.title),1)])]),n("div",Ue,[n("p",ke,F(m.affirmation.text),1)]),i(t,{label:"Placement"},{default:d(()=>[i(C,{modelValue:f.value.placement,"onUpdate:modelValue":s[0]||(s[0]=r=>f.value.placement=r),options:O},null,8,["modelValue"])]),_:1}),i(t,{label:"Featured Until (Optional)"},{default:d(()=>[i(e,{modelValue:f.value.featuredUntil,"onUpdate:modelValue":s[1]||(s[1]=r=>f.value.featuredUntil=r),type:"datetime-local"},null,8,["modelValue"])]),_:1}),i(t,{label:"Display Order"},{default:d(()=>[i(e,{modelValue:f.value.displayOrder,"onUpdate:modelValue":s[2]||(s[2]=r=>f.value.displayOrder=r),type:"number",min:"0"},null,8,["modelValue"])]),_:1}),i(X,{modelValue:p.value,"onUpdate:modelValue":[s[3]||(s[3]=r=>p.value=r),w]},null,8,["modelValue"])]),A(" "+F(f.value),1)]),_:1})]),_:1},8,["modelValue"])}}}),Y=()=>{const V=H(),E=oe(),g=S(!1),$=S([]),f=async()=>{try{g.value=!0;const{data:l,error:o}=await V.from("affirmly_shared_content").select("*").eq("share_type","featured").eq("is_active",!0).order("display_order",{ascending:!0});if(o)throw o;return $.value=l||[],{data:l,error:null}}catch(l){return{data:null,error:l}}finally{g.value=!1}},p=async(l,o)=>{try{const{error:_}=await V.from("affirmly_content_shares").update({placement:o.placement,display_order:o.displayOrder,expires_at:o.expiresAt||null}).eq("id",l);return{error:_}}catch(_){return{error:_}}},w=async(l,o,_)=>{var v,b;try{const m=o==="affirmation"?"affirmly_affirmations":"affirmly_prayers",{error:s}=await V.from(m).update({category:((v=_.categories)==null?void 0:v.join(","))||"",subcategory:((b=_.subcategories)==null?void 0:b.join(","))||""}).eq("id",l);return{error:s}}catch(m){return{error:m}}};return{isLoading:g,featuredContent:$,loadFeaturedContent:f,updateFeaturedAttributes:p,updateContentAttributes:w,removeFeatured:async l=>{try{const{error:o}=await V.from("affirmly_content_shares").update({is_active:!1}).eq("id",l);return{error:o}}catch(o){return{error:o}}},addToFeatured:async(l,o)=>{var _;try{if(!((_=E.value)!=null&&_.id))throw new Error("User must be logged in to add featured content");if(o.categoryState){const{error:b}=await w(l.id,l.type,{categories:o.categoryState.categories,subcategories:o.categoryState.subcategories});if(b)throw b}const{error:v}=await V.from("affirmly_content_shares").insert({content_id:l.id,content_type:l.type,share_type:"featured",shared_by:E.value.id,placement:o.placement||"home",display_order:o.displayOrder||0,expires_at:o.expiresAt||null,is_active:!0});if(v)throw v;return await f(),{error:null}}catch(v){return{error:v}}}}},Ae={class:"space-y-8"},Se={key:0,class:"text-center py-8"},Ve={key:1,class:"space-y-4"},Oe={class:"flex items-center justify-between"},Be={class:"font-medium"},je={class:"flex items-center gap-2"},Ee={key:0,class:"space-y-2"},Me={class:"flex items-center gap-2"},Le={class:"text-sm text-gray-600"},Ne={key:1,class:"space-y-4"},ze={class:"flex justify-end gap-2"},Te=I({__name:"CurrentlyFeatured",emits:["notification"],setup(V,{emit:E}){const{isLoading:g,featuredContent:$,loadFeaturedContent:f,updateFeaturedAttributes:p,updateContentAttributes:w,removeFeatured:O}=Y(),B=E,l=S(null),o=S({placement:"",displayOrder:0,featuredUntil:"",categoryState:{categories:[],subcategories:[]}});function _(t){var e;return((e=l.value)==null?void 0:e.share_id)===t.share_id}function v(t){var e,a,u,h;l.value=t,o.value={placement:t.placement||"home",displayOrder:t.display_order||0,featuredUntil:t.expires_at||"",categoryState:{categories:typeof((e=t.content)==null?void 0:e.category)=="string"?t.content.category.split(",").filter(
1Boolean):((a=t.content)==null?void 0:a.category)||[],subcategories:typeof((u=t.content)==null?void 0:u.subcategory)=="string"?t.content.subcategory.split(",").filter(Boolean):((h=t.content)==null?void 0:h.subcategory)||[]}}}function b(){l.value=null,o.value={placement:"",displayOrder:0,featuredUntil:"",categoryState:{categories:[],subcategories:[]}}}function m(t){o.value.categoryState=t}async function s(t,e){var a,u,h,r;if(t!=null&&t.share_id)try{const{error:U}=await p(t.share_id,{placement:e.placement,displayOrder:e.displayOrder,expiresAt:e.featuredUntil||null});if(U)throw U;if((u=(a=e.categoryState)==null?void 0:a.categories)!=null&&u.length||(r=(h=e.categoryState)==null?void 0:h.subcategories)!=null&&r.length){const{error:N}=await w(t.content_id,t.content_type,{categories:e.categoryState.categories,subcategories:e.categoryState.subcategories});if(N)throw N}await f(),B("notification","Success","Featured content updated","green"),b()}catch(U){B("notification","Error",U.message||"Failed to update featured content","red")}}async function C(t){try{const{error:e}=await O(t.share_id);if(e)throw e;await f(),B("notification","Success","Content removed from featured","green")}catch(e){B("notification","Error",e.message||"Failed to remove featured content","red")}}return K(()=>{f()}),(t,e)=>{var D;const a=P,u=ie,h=R,r=G,U=W,N=Q;return c(),x("div",Ae,[(D=k($))!=null&&D.length?(c(),x("div",Ve,[(c(!0),x(T,null,q(k($),y=>(c(),x("div",{key:y.share_id,class:"relative"},[i(N,null,{header:d(()=>{var z;return[n("div",Oe,[n("h4",Be,F((z=y.content)==null?void 0:z.title),1),n("div",je,[i(a,{color:"gray",variant:"ghost",size:"xs",icon:"i-heroicons-pencil-square",onClick:M=>v(y)},null,8,["onClick"]),i(a,{color:"red",variant:"ghost",size:"xs",icon:"i-heroicons-trash",onClick:M=>C(y)},null,8,["onClick"])])])]}),default:d(()=>{var z;return[_(y)?(c(),x("div",Ne,[i(r,{label:"Placement"},{default:d(()=>[i(h,{modelValue:o.value.placement,"onUpdate:modelValue":e[0]||(e[0]=M=>o.value.placement=M),options:[{label:"Home",value:"home"},{label:"Affirmation of the Day",value:"affirmation-of-the-day"}]},null,8,["modelValue"])]),_:1}),i(r,{label:"Display Order"},{default:d(()=>[i(U,{modelValue:o.value.displayOrder,"onUpdate:modelValue":e[1]||(e[1]=M=>o.value.displayOrder=M),modelModifiers:{number:!0},type:"number",min:"0"},null,8,["modelValue"])]),_:1}),i(r,{label:"Featured Until"},{default:d(()=>[i(U,{modelValue:o.value.featuredUntil,"onUpdate:modelValue":e[2]||(e[2]=M=>o.value.featuredUntil=M),type:"datetime-local"},null,8,["modelValue"])]),_:1}),i(r,{label:"Categories"},{default:d(()=>[i(X,{"model-value":o.value.categoryState,"onUpdate:modelValue":m},null,8,["model-value"])]),_:1}),n("div",ze,[i(a,{color:"gray",variant:"soft",size:"sm",onClick:b},{default:d(()=>e[5]||(e[5]=[A(" Cancel ")])),_:1}),i(a,{color:"primary",variant:"solid",size:"sm",loading:k(g),onClick:e[3]||(e[3]=M=>s(l.value,o.value))},{default:d(()=>e[6]||(e[6]=[A(" Save ")])),_:1},8,["loading"])])])):(c(),x("div",Ee,[n("div",Me,[i(u,{color:"primary"},{default:d(()=>[A(F(y.placement||"Home"),1)]),_:2},1024),y.display_order?(c(),j(u,{key:0,color:"gray"},{default:d(()=>[A(" Order: "+F(y.display_order),1)]),_:2},1024)):L("",!0)]),n("p",Le,F((z=y.content)==null?void 0:z.text),1)]))]}),_:2},1024)]))),128))])):(c(),x("div",Se,e[4]||(e[4]=[n("p",{class:"text-gray-500"},"No featured content yet",-1)])))])}}}),qe={class:"min-h-screen bg-gradient-to-b from-white to-primary-50 dark:from-gray-900 dark:to-gray-800"},De={key:0,class:"mb-8"},Ie={class:"flex justify-between items-center mb-4"},Pe={class:"overflow-x-auto pb-4"},Ge={class:"flex space-x-4"},He={class:"w-48 h-48 rounded-lg overflow-hidden relative group"},Je=["src","alt"],Ke={class:"absolute inset-0 bg-black bg-opacity-40 flex flex-col items-center justify-center p-4 space-y-2"},Re={class:"text-white text-sm text-center font-medium"},mt=I({__name:"featured-page",setup(V){const E=H(),{addToFeatured:g,featuredContent:$,loadFeaturedContent:f}=Y(),p=S(!1),w=S(!1),O=S([]),B=J(()=>O.value.some(e=>!v(e.id))),l=S({show:!1,title:"",description:"",color:"primary"}),o=S(!1),_=S(null);function v(e){return $.value.some(a=>a.content_id===e)}async function b(){try{const{data:e,error:a}=await E.from("affirmly_affirmations").select("*").is("deleted_at",null).order("created_at",{ascending:!1});if(a)throw a;O.value=e||[]}catch{t("Error","Failed to load affirmations","red")}}function m(e){_.value=e,o.value=!0}async function s(e,a){try{p.value=!0;const{error:u}=await g({id:e.id,type:"affirmation"},a);if(u)throw u;t("Success","Content added to featured","green"),o.value=!1,_.value=null}catch(u){t("Error",u.message||"Failed to add to featured","red")}finally{p.value=!1}}async function C(){try{w.value=!0;const a=O.value.filter(r=>!v(r.id)).map((r,U)=>g({id:r.id,type:"affirmation"},{placement:"home",displayOrder:$.value.length+U,expiresAt:null})),u=await Promise.all(a),h=u.filter(r=>r.error);h.length>0?t("Warning",`Added ${u.length-h.length} items. ${h.length} failed.`,"yellow"):t("Success",`Added ${u.length} items to featured`,"green")}catch(e){t("Error",e.message||"Failed to add all items","red")}finally{w.value=!1}}function t(e,a,u="primary"){l.value={show:!0,title:e,description:a,color:u}}return K(async()=>{await Promise.all([b(),f()])}),(e,a)=>{const u=P,h=Fe,r=Te,U=de,N=ne,D=re;return c(),j(D,null,{default:d(()=>[n("div",qe,[i(U,{class:"py-16"},{default:d(()=>[a[6]||(a[6]=n("div",{class:"text-center mb-16"},[n("h1",{class:"text-4xl font-bold mb-6 bg-gradient-to-r from-primary-600 to-primary-400 bg-clip-text text-transparent"}," Featured Content Management "),n("p",{class:"text-xl text-gray-600 dark:text-gray-300 mb-8"}," Manage featured content across the platform ")],-1)),p.value?L("",!0):(c(),x("div",De,[n("div",Ie,[a[3]||(a[3]=n("h3",{class:"text-lg font-semibold"},"All Affirmations",-1)),k(B)?(c(),j(u,{key:0,color:"primary",variant:"soft",icon:"i-heroicons-plus-circle",loading:w.value,onClick:C},{default:d(()=>a[2]||(a[2]=[A(" Add All to Featured ")])),_:1},8,["loading"])):L("",!0)]),n("div",Pe,[n("div",Ge,[(c(!0),x(T,null,q(O.value,y=>(c(),x("div",{key:y.id,class:"flex-none"},[n("div",He,[n("img",{src:y.thumbnail_url||"/default-thumbnail.jpg",alt:y.title,class:"w-full h-full object-cover"},null,8,Je),n("div",Ke,[n("p",Re,F(y.title),1),v(y.id)?(c(),j(u,{key:1,size:"xs",color:"gray",variant:"soft",disabled:""},{default:d(()=>a[5]||(a[5]=[A(" Already Featured ")])),_:1})):(c(),j(u,{key:0,size:"xs",color:"white",variant:"solid",onClick:z=>m(y)},{default:d(()=>a[4]||(a[4]=[A(" Add to Featured ")])),_:2},1032,["onClick"]))])])]))),128))])])])),_.value?(c(),j(h,{key:1,isOpen:o.value,"onUpdate:isOpen":a[0]||(a[0]=y=>o.value=y),affirmation:_.value,isLoading:p.value,onAdd:s},null,8,["isOpen","affirmation","isLoading"])):L("",!0),i(r,{onNotification:t})]),_:1}),i(N,{modelValue:l.value.show,"onUpdate:modelValue":a[1]||(a[1]=y=>
1l.value.show=y),title:l.value.title,description:l.value.description,color:l.value.color},null,8,["modelValue","title","description","color"])])]),_:1})}}});export{mt 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.