PageSourceSearch

https://unbserved.com/assets/AdminEngagementPage-Byjm8U77.js

js unbserved.com collected 2026-10-02 01:49:01 UTC 10,997 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-CmsjHIn-.js";import{a as v}from"./vendor-react-BIk3JZ8x.js";import{r as N,s as E,ao as S,az as R,Y as w,aM as U,R as x,E as z,U as u,q as $,b6 as J,aL as Q,T as V}from"./main-CVSb0ivP.js";import{C as M,b as O,c as T,d as K,a as B}from"./card-8AoRGwQB.js";import{a as H,u as F,b as I}from"./vendor-query-ByPjdCNj.js";import{A as G}from"./AdminPageShell-D7f2fyes.js";import{S as C}from"./StatUp-CC6WulQF.js";import{g as _}from"./Play-BlftWPWM.js";import"./index-Bgb3GKdq.js";import"./triangle-alert-C-X7xUKj.js";import"./zap-RXDA8toK.js";import"./sliders-horizontal-CLqEqMaF.js";import"./check-Cs5as3tE.js";import"./download-COZD-iZ9.js";import"./image-plus-CqfGgfUd.js";import"./lock-DbdsG4Q5.js";import"./plus-Ba1NuFOA.js";import"./search-CRUaHbAt.js";import"./upload-B4YuwLsS.js";import"./vendor-motion-pIdvkJtl.js";import"./BackIcon-M1vk_R5Y.js";function Y(){return H({queryKey:["engagement-settings"],staleTime:5*6e4,queryFn:async()=>{const{data:t,error:s}=await E.from("engagement_settings").select("*");if(s)throw s;const n={};return t?.forEach(i=>{n[i.key]=i.value}),{projects:n.projects_config,blog:n.blog_config,images:n.images_config,executionLog:n.execution_log}}})}function W(){const t=F();return I({mutationFn:async({key:s,value:n})=>{const{error:i}=await E.from("engagement_settings").update({value:n,updated_at:new Date().toISOString()}).eq("key",s);if(i)throw i},onSuccess:()=>{t.invalidateQueries({queryKey:["engagement-settings"]}),N.success("Settings saved!")},onError:s=>{N.error("Error saving: "+s.message)}})}function X(){const t=F();return I({mutationFn:async s=>{const{data:n,error:i}=await E.functions.invoke("inject-engagement",{body:{target:s}});if(i)throw i;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["engagement-settings"]}),N.success(`Engagement injected! Views: +${s?.summary?.totalViewsAdded||0}, Likes: +${s?.summary?.totalLikesAdded||0}`)},onError:s=>{N.error("Error executing: "+s.message)}})}const Z=[{maxAgeDays:1,multiplier:6},{maxAgeDays:3,multiplier:3.5},{maxAgeDays:7,multiplier:2},{maxAgeDays:14,multiplier:1},{maxAgeDays:30,multiplier:.6},{maxAgeDays:60,multiplier:.3},{maxAgeDays:90,multiplier:.1},{maxAgeDays:9999,multiplier:0}];function ee(t){if(!t||t.length===0)return null;const s=[...t].sort((c,o)=>c.maxAgeDays-o.maxAgeDays),n=s.find(c=>c.multiplier<=0);if(!n)return null;const i=s.indexOf(n)-1;return i>=0?s[i].maxAgeDays:0}function D({title:t,config:s,onChange:n,icon:i=C,color:c="text-primary"}){const o=(a,l)=>{const m=JSON.parse(JSON.stringify(s)),g=a.split(".");let p=m;for(let j=0;j<g.length-1;j++)p=p[g[j]];p[g[g.length-1]]=l,n(m)},r=s.decay.ageCurve??Z,y=a=>{const l=JSON.parse(JSON.stringify(s));l.decay={...l.decay,ageCurve:a},n(l)},d=(a,l,m)=>{const g=r.map((p,j)=>j===a?{...p,[l]:m}:p);y(g)},b=()=>{const l={maxAgeDays:(r[r.length-1]?.maxAgeDays??0)+30,multiplier:0};y([...r,l])},h=a=>{r.length<=2||y(r.filter((l,m)=>m!==a))},f=ee(r);return e.jsxs(M,{children:[e.jsx(O,{children:e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(i,{className:`h-5 w-5 ${c}`}),t]})}),e.jsxs(B,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(z,{className:"h-4 w-4"}),"Views per day"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Minimum"}),e.jsx(u,{type:"number",value:s.views.min,onChange:a=>o("views.min",Number(a.target.value))})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Maximum"}),e.jsx(u,{type:"number",value:s.views.max,onChange:a=>o("views.max",Number(a.target.value))})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx($,{className:"h-4 w-4"}),"Likes per day"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Minimum"}),e.jsx(u,{type:"number",value:s.likes.min,onChange:a=>
1o("likes.min",Number(a.target.value))})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Maximum"}),e.jsx(u,{type:"number",value:s.likes.max,onChange:a=>o("likes.max",Number(a.target.value))})]})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Probability (%)"}),e.jsx(u,{type:"number",min:0,max:100,value:Math.round(s.likes.probability*100),onChange:a=>o("likes.probability",Number(a.target.value)/100)})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(C,{className:"h-4 w-4"}),"Boost for recent"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Boost days"}),e.jsx(u,{type:"number",value:s.views.recencyBoostDays,onChange:a=>o("views.recencyBoostDays",Number(a.target.value))})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Multiplier"}),e.jsx(u,{type:"number",step:.1,value:s.views.recencyMultiplier,onChange:a=>o("views.recencyMultiplier",Number(a.target.value))})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(J,{className:"h-4 w-4"}),"Age decay curve"]}),e.jsxs(w,{type:"button",size:"sm",variant:"ghost",onClick:b,children:[e.jsx(Q,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Multiplier applied to base views/likes by content age. ",e.jsx("strong",{children:"0 = no injection"})," (only real engagement counts)."]}),e.jsx("div",{className:"space-y-2",children:r.map((a,l)=>e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx(x,{className:"text-[10px] uppercase tracking-wide",children:"Up to age (days)"}),e.jsx(u,{type:"number",min:0,value:a.maxAgeDays,onChange:m=>d(l,"maxAgeDays",Number(m.target.value))})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-[10px] uppercase tracking-wide",children:"Multiplier"}),e.jsx(u,{type:"number",min:0,step:.1,value:a.multiplier,onChange:m=>d(l,"multiplier",Number(m.target.value))})]}),e.jsx(w,{type:"button",size:"icon",variant:"ghost",onClick:()=>h(l),disabled:r.length<=2,"aria-label":"Remove curve point",children:e.jsx(V,{className:"h-4 w-4"})})]},l))}),f!==null&&e.jsxs("p",{className:"text-xs text-muted-foreground border-t border-border pt-2",children:["Items older than ",e.jsxs("strong",{children:[f," days"]})," get 0 injected views/likes — only real engagement."]})]})]})]})}function be(){const{data:t,isLoading:s}=Y(),n=W(),i=X(),[c,o]=v.useState(null),[r,y]=v.useState(null),[d,b]=v.useState(null),[h,f]=v.useState("all");v.useEffect(()=>{t?.projects&&!c&&o(t.projects),t?.blog&&!r&&y(t.blog),t?.images&&!d&&b(t.images)},[t,c,r,d]);const a=async()=>{const g=[["projects",c],["blog",r],["images",d]];for(const[p,j]of g){if(!j)continue;const q=j;for(const L of["views","likes"]){const k=q[L];if(!k)continue;const A=Number(k.min??0),P=Number(k.max??0);if(!Number.isFinite(A)||!Number.isFinite(P)||A<0||P<A){N.error(`${p} · ${L}: minimum must be ≥ 0 and ≤ maximum`);return}}}c&&await n.mutateAsync({key:"projects_config",value:c}),r&&await n.mutateAsync({key:"blog_config",value:r}),d&&await n.mutateAsync({key:"images_config",value:d})},l=()=>{i.mutate(h)},m=g=>g?new Date(g).toLocaleString("en-US"):"Never executed";return s?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(S,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(G,{title:"Engajamento",description:"Configure automatic views and likes injection",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8",children:[c&&e.jsx(D,{title:"Featured Projects",config:c,onChange:o,icon:C,color:"text-yellow-500"}),r&&e.jsx(D,{title:"Blog Posts",config:r,onChange:y,icon:C,color:"text-purple-500"}),d&&e.jsx(D,{title:"Images / Explore Feed",config:d,onChange:b,icon:R,color:"text-blue-500"})]}),e.jsx("div",{className:"flex justify-center mb-8",children:e.jsxs(w,{size:"lg",onClick:a,disabled:n.isPending,className:"gap-2",children:[n.isPending?e.jsx(S,{className:"h-4 w-4 animate-spin"}):e.jsx(U,{className:"h-4 w-4"}),"Save Settings"]})}),e.jsxs(M,{children:[e.jsxs(O,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-5 w-5 text-green-500"}),"Manual Execution"]}),e.jsx(K,{children:"Execute engagement injection manually"})]}),e.jsxs(B,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-6 flex-wrap",children:[e.jsx(x,{children:"Target:"}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"target",checked:h==="projects",onChange:()=>f("projects"),className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:"Projects Only"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"target",checked:h==="blog",onCh
1ange:()=>f("blog"),className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:"Blog Only"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"target",checked:h==="images",onChange:()=>f("images"),className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:"Images Only"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"target",checked:h==="all",onChange:()=>f("all"),className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:"Todos"})]})]})]}),e.jsxs(w,{onClick:l,disabled:i.isPending,className:"gap-2",children:[i.isPending?e.jsx(S,{className:"h-4 w-4 animate-spin"}):e.jsx(_,{className:"h-4 w-4"}),"Execute Now"]}),t?.executionLog&&e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Last execution:"})," ",m(t.executionLog.lastRun)]}),t.executionLog.lastStats&&e.jsxs("div",{className:"flex gap-6 mt-2 text-sm flex-wrap",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Projects:"})," +",t.executionLog.lastStats.projects?.views||0," views, +",t.executionLog.lastStats.projects?.likes||0," likes"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Blog:"})," +",t.executionLog.lastStats.blog?.views||0," views, +",t.executionLog.lastStats.blog?.likes||0," likes"]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Images:"})," +",t.executionLog.lastStats.images?.views||0," views, +",t.executionLog.lastStats.images?.likes||0," likes"]})]})]})]})]})]})}export{be 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.