PageSourceSearch

https://tsofit.org.il/assets/CommunitySitesAdmin-akHptiWH.js

js tsofit.org.il collected 2026-09-25 02:12:25 UTC 42,757 bytes, 4 lines download raw bytes

1import{r as n,j as e,a7 as q,_ as H,aM as se,d as N,z as h,b as A,B as L,l as Q,w as Z,P as ae,T as W,y as pe}from"./index-BuF13C9R.js";import{P as ge}from"./PageHeader-BJWwaOi_.js";import{A as E}from"./AdminSection-DFy117-w.js";import{I as S}from"./input-B1pb-EbS.js";import{L as m}from"./label-CZGaFvV8.js";import{T as le}from"./textarea-xKivmc1W.js";import{S as K}from"./switch-9kzbE2Dl.js";import{S as O,a as z,b as R,c as V,d as F}from"./select-J0viKo_P.js";import{I as ie}from"./ImageUpload-Bg2e0VMr.js";import{R as je}from"./index-BPksF9KU.js";/* empty css                   */import{g as ne,I as ye,A as ce}from"./kibbutzSiteUtils-DG6eIbUJ.js";import{D as be}from"./defaultSitePages-Ba0xpG5U.js";import{V as ve}from"./contentVisibility-BQn1qULy.js";import{I as Y}from"./image-BzvPncEw.js";import{R as J}from"./refresh-cw-DvPS6Mu1.js";import{S as ee}from"./save-C6cWy1UE.js";import"./index-BGaOrCq_.js";import"./chevron-up-CCjitxk2.js";import"./upload-DeFZlL4S.js";import"./link-vExjJmvA.js";import"./isEqual-Bszk2vQ5.js";import"./info-BIFqAg3-.js";import"./folder-open-BSPTKQzn.js";import"./graduation-cap-D9zn9IjR.js";import"./file-check-D2O-2b5u.js";import"./log-in-8daxVYSJ.js";import"./files-Lfv8I8Qy.js";const te=be.filter(a=>a.module_key&&a.key!=="home").map(a=>({value:a.module_key,label:a.title})),U=[{value:"module",label:"מודול"},{value:"auth_action",label:"פעולה"},{value:"external_link",label:"קישור חיצוני"}],fe=[{token:"{{community_name}}",label:"שם הקהילה"},{token:"{{community_address}}",label:"כתובת הקהילה"},{token:"{{community_website}}",label:"כתובת האתר"},{token:"{{community_email}}",label:"אימייל"},{token:"{{community_phone}}",label:"טלפון"}],_e={legal:"עמוד משפטי",content:"עמוד תוכן"},Ne=[{key:"pages",label:"ניהול עמודים",icon:q,enabled:!0},{key:"buttons",label:"כפתורי שירות",icon:H,enabled:!0},{key:"slides",label:"סליידר",icon:Y,enabled:!0},{key:"marketing",label:"חלק שיווקי",icon:se,enabled:!0}];function lt(){const[a,g]=n.useState("pages");return e.jsxs("div",{dir:"rtl",children:[e.jsx(ge,{title:"ניהול אתר קהילות",description:"ניהול תבניות ברירת המחדל שכל קהילה חדשה מקבלת — עמודים, כפתורים, סליידר וחלק שיווקי."}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-6",children:Ne.map(j=>{const C=j.icon,p=a===j.key;return e.jsxs("button",{type:"button",disabled:!j.enabled,onClick:()=>j.enabled&&g(j.key),className:`inline-flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-semibold border transition-colors
2                ${p?"bg-primary text-white border-primary shadow-sm":j.enabled?"bg-white text-slate-600 border-slate-200 hover:bg-slate-50":"bg-slate-50 text-slate-300 border-slate-100 cursor-not-allowed"}`,children:[e.jsx(C,{className:"w-4 h-4"})," ",j.label,!j.enabled&&e.jsx("span",{className:"text-[10px] font-normal",children:"(בקרוב)"})]},j.key)})}),a==="pages"&&e.jsx(Se,{}),a==="buttons"&&e.jsx(ke,{}),a==="slides"&&e.jsx(we,{}),a==="marketing"&&e.jsx(Ie,{})]})}function X({type:a,target:g,external:j,onTarget:C,onExternal:p}){if(a==="external_link")return e.jsx(S,{value:j||"",onChange:s=>p(s.target.value),placeholder:"#services / https://...",dir:"ltr",className:"text-left"});const b=a==="auth_action"?ce:te;return e.jsxs(O,{value:g||"",onValueChange:C,children:[e.jsx(z,{children:e.jsx(R,{placeholder:"בחרו יעד"})}),e.jsx(V,{dir:"rtl",children:b.map(s=>e.jsx(F,{value:s.value,children:s.label},s.value))})]})}function we(){const[a,g]=n.useState([]),[j,C]=n.useState(!0),[p,b]=n.useState(null),[s,v]=n.useState(null),[k,w]=n.useState(!1),[c,f]=n.useState([]);n.useEffect(()=>{let t=!0;return(async()=>{try{const[i,x]=await Promise.all([N.entities.SiteSlideDefault.list(),N.entities.Kibbutz.list().catch(()=>[])]);if(!t)return;const u=(i||[]).slice().sort((_,M)=>(_.order??0)-(M.order??0));g(u),f((x||[]).filter(_=>!_.is_deleted)),u.length&&b(u[0].id)}catch{h.error("שגיאה בטעינת תבניות הסליידר")}finally{t&&C(!1)}})(),()=>{t=!1}},[]),n.useEffect(()=>{const t=a.find(i=>i.id===p);v(t?{...t}:null)},[p,a]);const o=(t,i)=>v(x=>({...x,[t]:i})),y=async()=>{try{const t=a.length?Math.max(...a.map(x=>x.order??0))+1:1,i=await N.entities.SiteSlideDefault.create({slide_key:`custom_${Date.now()}`,title:"שקופית חדשה",subtitle:"",primary_button_type:"external_link",secondary_button_type:"external_link",order:t,is_active:!0});g(x=>[...x,i].sort((u,_)=>(u.order??0)-(_.order??0))),b(i.id),h.success("שקופית נוספה")}catch{h.error("שגיאה בהוספת שקופית")}},D=async()=>{var t;if(s){if(!((t=s.title)!=null&&t.trim())){h.error("נדרשת כותרת");return}w(!0);try{const i={title:s.title,subtitle:s.subtitle||"",badge_label:s.badge_label||"",background_image:s.background_image||null,primary_button_text:s.primary_button_text||null,primary_button_type:s.primary_button_type||"external_link",primary_button_target:s.primary_button_target||null,secondary_button_text:s.secondary_button_text||null,secondary_button_type:s.secondary_button_type||"external_link",secondary_button_target:s.secondary_button_target||null,order:Number(s.order)||0,is_active:s.is_active!==!1};await N.entities.SiteSlideDefault.update(s.id,i),g(x=>x.map(u=>u.id===s.id?{...u,...i}:u).sort((u,_)=>(u.order??0)-(_.order??0))),h.success("השקופית נשמרה")}catch{h.error("שגיאה בשמירת השקופית")}finally{w(!1)}}},l=async t=>{if(window.confirm("למחוק את תבנית השקופית?"))try{await N.entities.SiteSlideDefault.delete(t),g(i=>{var u;const x=i.filter(_=>_.id!==t);return p===t&&b(((u=x[0])==null?void 0:u.id)||null),x}),h.success("השקופית נמחקה")}catch{h.error("שגיאה במחיקה")}};return j?e.jsx("div",{className:"flex items-center justify-center h-48",children:e.jsx(A,{className:"w-6 h-6 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{icon:J,iconBg:"bg-emerald-50",iconColor:"text-emerald-600",title:"החלה על קהילות",
2subtitle:"החלת שקופיות ברירת המחדל על קהילה מסוימת",children:e.jsx(de,{part:"slides",communities:c})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[300px_1fr] gap-6",children:[e.jsx(E,{icon:Y,iconBg:"bg-blue-50",iconColor:"text-blue-600",title:"שקופיות ברירת מחדל",className:"h-fit",action:e.jsxs(L,{size:"sm",variant:"secondary",className:"gap-1.5",onClick:y,children:[e.jsx(ae,{className:"w-4 h-4"})," הוסף"]}),children:e.jsx("div",{className:"space-y-1.5",children:a.map(t=>{const i=t.id===p;return e.jsx("button",{type:"button",onClick:()=>b(t.id),className:`w-full text-right rounded-xl border overflow-hidden transition-colors ${i?"border-primary/40 ring-1 ring-primary/20":"border-slate-100 hover:bg-slate-50"}`,children:e.jsxs("div",{className:"h-16 bg-slate-100 bg-cover bg-center relative",style:t.background_image?{backgroundImage:`url(${t.background_image})`}:void 0,children:[e.jsx("div",{className:"absolute inset-0 bg-black/30"}),e.jsx("div",{className:"absolute inset-0 p-2 flex flex-col justify-end",children:e.jsx("span",{className:"text-white text-xs font-bold truncate drop-shadow",children:t.title})}),!t.is_active&&e.jsx("span",{className:"absolute top-1 left-1 text-[10px] bg-black/50 text-white px-1.5 rounded",children:"כבוי"})]})},t.id)})})}),s?e.jsx(E,{icon:Y,title:`עריכת שקופית: ${s.title||""}`,action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>l(s.id),className:"text-red-500 hover:text-red-700 p-1.5",title:"מחיקה",type:"button",children:e.jsx(W,{className:"w-4 h-4"})}),e.jsxs(L,{onClick:D,disabled:k,size:"sm",className:"gap-2",children:[k?e.jsx(A,{className:"w-4 h-4 animate-spin"}):e.jsx(ee,{className:"w-4 h-4"})," שמירה"]})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"כותרת"}),e.jsx(S,{value:s.title||"",onChange:t=>o("title",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"תגית (badge)"}),e.jsx(S,{value:s.badge_label||"",onChange:t=>o("badge_label",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"כותרת משנה"}),e.jsx(le,{value:s.subtitle||"",onChange:t=>o("subtitle",t.target.value),rows:2})]}),e.jsx(ie,{label:"תמונת רקע",value:s.background_image||"",onChange:t=>o("background_image",t)}),e.jsxs("div",{className:"rounded-xl border border-slate-100 p-4 space-y-3",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-700",children:"כפתור ראשי"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"טקסט"}),e.jsx(S,{value:s.primary_button_text||"",onChange:t=>o("primary_button_text",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סוג"}),e.jsxs(O,{value:s.primary_button_type||"external_link",onValueChange:t=>o("primary_button_type",t),children:[e.jsx(z,{children:e.jsx(R,{})}),e.jsx(V,{dir:"rtl",children:U.map(t=>e.jsx(F,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"יעד"}),e.jsx(X,{type:s.primary_button_type||"external_link",target:s.primary_button_target,external:s.primary_button_target,onTarget:t=>o("primary_button_target",t),onExternal:t=>o("primary_button_target",t)})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-100 p-4 space-y-3",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-700",children:"כפתור משני"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"טקסט"}),e.jsx(S,{value:s.secondary_button_text||"",onChange:t=>o("secondary_button_text",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סוג"}),e.jsxs(O,{value:s.secondary_button_type||"external_link",onValueChange:t=>o("secondary_button_type",t),children:[e.jsx(z,{children:e.jsx(R,{})}),e.jsx(V,{dir:"rtl",children:U.map(t=>e.jsx(F,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"יעד"}),e.jsx(X,{type:s.secondary_button_type||"external_link",target:s.secondary_button_target,external:s.secondary_button_target,onTarget:t=>o("secondary_button_target",t),onExternal:t=>o("secondary_button_target",t)})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סדר"}),e.jsx(S,{type:"number",value:s.order??0,onChange:t=>o("order",t.target.value),className:"w-24"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סטטוס"}),e.jsxs("label",{className:"flex items-center gap-2 h-9",children:[e.jsx(K,{checked:s.is_active!==!1,onCheckedChange:t=>o("is_active",t)}),e.jsx("span",{className:"text-sm text-slate-600",children:s.is_active!==!1?"פעיל":"כבוי"})]})]})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-slate-400 border-t border-slate-100 pt-4",children:[e.jsx(Z,{className:"w-4 h-4 flex-none mt-0.5 text-slate-300"}),e.jsxs("span",{children:["המחוון ","{{","community_name","}}"," בכותרת יוחלף בשם הקהילה בעת ההחלה. שקופיות שקהילה ערכה בעצמה לא נדרסות."]})]})]})}):e.jsx(E,{icon:Y,title:"בחרו שקופית לעריכה",children:e.jsx("p",{className:"text-sm text-slate-400",children:'אין תבניות שקופיות. לחצו "הוסף".'})})]})]})}function oe({communities:a,value:g,onChange:j,className:C="w-56"}){const[p,b]=n.useState(!1),[s,v]=n.useState(""),k=n.useRef(null),w=a.find(y=>y.id===g);n.useEffect(()=>{const y=D=>{k.current&&!k.current.contains(D.target)&&b(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const c=s.trim().toLowerCase(),f=c?a.filter(y=>(y.name||"").toLowerCase().includes(c)):a,o=y=>{j(y.id),v(""),b(!1)};return e.jsxs("div",{ref:k,className:`relative ${C}`,children:[e.jsxs("div",{className:"relative",children:[e.jsx(pe,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"}),e.jsx(S,{value:p?s:(w==null?void 0:w.name)||"",onChange:y=>{v(y.target.value),p||b(!0)},onFocus:()=>{b(!0),v("")},placeholder:w?w.name:"חיפוש קהילה…",className:"pr-9 text-right",dir:"rtl"})]}),p&&e.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto rounded-xl border border-slate-200 bg-white shadow-lg",dir:"rtl",children:f.length===0?e.jsx("div",{className:"px-3 py-2.5 text-sm text-slate-400",children:"לא נמצאו קהילות"}):f.map(y=>e.jsx("button",{type:"button",onClick:()=>o(y),className:`w-full text-right px-3 py-2 text-sm transition-colors hover:bg-blue-50 ${y.id===g?"bg-blue-50 font-bold text-blue-700":"text-slate-700"}`,children:y.name},y.id))})]})}function de({part:a,communities:g}){const[j,C]=n.useState(""),[p,b]=n.useState(!1),[s,v]=n.useState(!1),k=async()=>{var w;if(!j){h.error("בחרו קהילה");return}v(!0);try{const c=await N.functions.invoke("communitySiteDefaults",{action:"applyToCommunity",community_id:j,parts:[a],over
2write:p}),f=((w=c==null?void 0:c.data)==null?void 0:w[a])||{};h.success(`הוחל על הקהילה — נוצרו ${f.created||0}, עודכנו ${f.updated||0}, דולגו ${f.skipped||0}`)}catch(c){h.error(`שגיאה בהחלה על הקהילה${c!=null&&c.message?`: ${c.message}`:""}`)}finally{v(!1)}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{children:"החלה על קהילה מסוימת"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(oe,{communities:g,value:j,onChange:C}),e.jsxs(L,{onClick:k,disabled:s,className:"gap-2",children:[s?e.jsx(A,{className:"w-4 h-4 animate-spin"}):e.jsx(Q,{className:"w-4 h-4"}),"החל"]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600",children:[e.jsx(K,{checked:p,onCheckedChange:b}),"דרוס גם פריטים קיימים (שלא הותאמו ידנית)"]}),e.jsx("p",{className:"text-xs text-slate-400",children:"ללא דריסה — נוצרים רק פריטים חסרים; פריטים שהקהילה ערכה נשמרים תמיד."})]})}function ke(){const[a,g]=n.useState([]),[j,C]=n.useState(!0),[p,b]=n.useState(null),[s,v]=n.useState(null),[k,w]=n.useState(!1),[c,f]=n.useState([]);n.useEffect(()=>{let t=!0;return(async()=>{try{const[i,x]=await Promise.all([N.entities.SiteButtonDefault.list(),N.entities.Kibbutz.list().catch(()=>[])]);if(!t)return;const u=(i||[]).slice().sort((_,M)=>(_.order??0)-(M.order??0));g(u),f((x||[]).filter(_=>!_.is_deleted)),u.length&&b(u[0].id)}catch{h.error("שגיאה בטעינת תבניות הכפתורים")}finally{t&&C(!1)}})(),()=>{t=!1}},[]),n.useEffect(()=>{const t=a.find(i=>i.id===p);v(t?{...t}:null)},[p,a]);const o=(t,i)=>v(x=>({...x,[t]:i})),y=async()=>{var t;try{const i=a.length?Math.max(...a.map(u=>u.order??0))+1:1,x=await N.entities.SiteButtonDefault.create({button_key:`custom_${Date.now()}`,label:"כפתור חדש",icon:"LayoutGrid",link_type:"module",link_target:((t=te[0])==null?void 0:t.value)||"",visibility:"public",color:"#2563eb",order:i,is_active:!0});g(u=>[...u,x].sort((_,M)=>(_.order??0)-(M.order??0))),b(x.id),h.success("כפתור נוסף")}catch{h.error("שגיאה בהוספת כפתור")}},D=async()=>{var t;if(s){if(!((t=s.label)!=null&&t.trim())){h.error("נדרשת כותרת");return}w(!0);try{const i={label:s.label,icon:s.icon||"LayoutGrid",color:s.color||null,link_type:s.link_type||"module",link_target:s.link_type==="external_link"?null:s.link_target||null,external_url:s.link_type==="external_link"&&s.external_url||null,visibility:s.visibility||"public",order:Number(s.order)||0,is_active:s.is_active!==!1};await N.entities.SiteButtonDefault.update(s.id,i),g(x=>x.map(u=>u.id===s.id?{...u,...i}:u).sort((u,_)=>(u.order??0)-(_.order??0))),h.success("הכפתור נשמר")}catch{h.error("שגיאה בשמירת הכפתור")}finally{w(!1)}}},l=async t=>{if(window.confirm("למחוק את תבנית הכפתור?"))try{await N.entities.SiteButtonDefault.delete(t),g(i=>{var u;const x=i.filter(_=>_.id!==t);return p===t&&b(((u=x[0])==null?void 0:u.id)||null),x}),h.success("הכפתור נמחק")}catch{h.error("שגיאה במחיקה")}};return j?e.jsx("div",{className:"flex items-center justify-center h-48",children:e.jsx(A,{className:"w-6 h-6 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{icon:J,iconBg:"bg-emerald-50",iconColor:"text-emerald-600",title:"החלה על קהילות",subtitle:"החלת כפתורי ברירת המחדל על קהילה מסוימת",children:e.jsx(de,{part:"buttons",communities:c})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[300px_1fr] gap-6",children:[e.jsx(E,{icon:H,iconBg:"bg-blue-50",iconColor:"text-blue-600",title:"כפתורי ברירת מחדל",className:"h-fit",action:e.jsxs(L,{size:"sm",variant:"secondary",className:"gap-1.5",onClick:y,children:[e.jsx(ae,{className:"w-4 h-4"})," הוסף"]}),children:e.jsx("div",{className:"space-y-1.5",children:a.map(t=>{const i=ne(t.icon),x=t.id===p;return e.jsxs("button",{type:"button",onClick:()=>b(t.id),className:`w-full text-right px-3 py-2.5 rounded-xl border transition-colors flex items-center gap-2.5
3                    ${x?"bg-primary/10 border-primary/40":"bg-white border-slate-100 hover:bg-slate-50"}`,children:[e.jsx("span",{className:"w-7 h-7 rounded-lg grid place-items-center flex-none",style:{backgroundColor:(t.color||"#2563eb")+"18"},children:i&&e.jsx(i,{className:"w-4 h-4",style:{color:t.color||"#2563eb"}})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-semibold text-sm text-slate-800 truncate",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-400 truncate",children:t.link_target||t.external_url||"—"})]}),!t.is_active&&e.jsx("span",{className:"text-[10px] text-slate-300",children:"כבוי"})]},t.id)})})}),s?e.jsx(E,{icon:H,title:`עריכת כפתור: ${s.label||""}`,action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>l(s.id),className:"text-red-500 hover:text-red-700 p-1.5",title:"מחיקה",type:"button",children:e.jsx(W,{className:"w-4 h-4"})}),e.jsxs(L,{onClick:D,disabled:k,size:"sm",className:"gap-2",children:[k?e.jsx(A,{className:"w-4 h-4 animate-spin"}):e.jsx(ee,{className:"w-4 h-4"}),"שמירה"]})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"כותרת הכפתור"}),e.jsx(S,{value:s.label||"",onChange:t=>o("label",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"צבע"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:s.color||"#2563eb",onChange:t=>o("color",t.target.value),className:"w-10 h-9 rounded-md border border-slate-200 cursor-pointer"}),e.jsx(S,{value:s.color||"",onChange:t=>o("color",t.target.value),dir:"ltr",className:"text-left"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"אייקון"}),e.jsx("div",{className:"grid grid-cols-6 md:grid-cols-10 gap-2 max-h-40 overflow-y-auto border border-slate-100 rounded-xl p-2 bg-white",children:ye.map(t=>{const i=ne(t.icon),x=s.icon===t.icon;return e.jsxs("button",{type:"button",title:t.label,onClick:()=>o("icon",t.icon),className:`flex flex-col items-center gap-0.5 p-1.5 rounded-lg transition-colors ${x?"bg-emerald-50 ring-2 ring-emerald-400":"hover:bg-slate-50"}`,children:[e.jsx(i,{className:`w-5 h-5 ${x?"text-emerald-600":"text-slate-600"}`}),e.jsx("span",{className:"text-[9px] text-slate-400 truncate w-full text-center",children:t.label})]},t.icon)})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סוג קישור"}),e.jsxs(O,{value:s.link_type||"module",onValueChange:t=>o("link_type",t),children:[e.jsx(z,{children:e.jsx(R,{})}),e.jsx(V,{dir:"rtl",children:U.map(t=>e.jsx(F,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"יעד"}),s.link_type==="external_link"?e.jsx(S,{value:s.external_url||"",onChange:t=>o("external_url",t.target.value),placeholder:"https://example.com",dir:"ltr",className:"text-left"}):e.jsxs(O,{value:s.link_target||"",onValueChange:t=>o("link_target",t),children:[e.jsx(z,{children:e.jsx(R,{placeholder:"בחרו יעד"})}),e.jsx(V,{dir:"rtl",children:(s.link_type==="auth_action"?ce:te).map(t=>e.jsx(F,{value:t.value,children:t.label},t.value))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"גישה"}),e.jsxs(O,{value:s.visibility||"public",onValueChange:t=>o("visibility",t),children:[e.jsx(z,{children:e.jsx(R,{})}),e.jsx(V,{dir:"rtl",children:Object.entries(ve).map(([t,i])=>e.jsx(F,{value:t,children:i},t))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סדר"}),e.jsx(S,{type:"number",value:s.order??0,onChange:t=>o("order",t.target.value),className:"w-24"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סטטוס"}),e.jsxs("label",{className:"flex items-center gap-2 h-9",children:[e.jsx(K,{checked:s.is_active!==!1,onCheckedChange:t=>o("is_active",t)}),e.jsx("span",{className:"text-sm text-slate-600",children:s.is_active!==!1?"פעיל":"כבוי"})]})]})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-slate-400 border-t border-slate-100 pt-4",children:[e.jsx(Z,{className:"w-4 h-4 flex-none mt-0.5 text-slate-300"}),e.jsx("span",{children:'שינויים כאן משפיעים על קהילות חדשות מכאן והלאה, ועל קהילות קיימות רק בעת "החל על קהילה". כפתורים שקהילה ערכה בעצמה לא נדרסים.'})]})]})}):e.jsx(E,{icon:H,title:"בחרו כפתור לעריכה",children:e.jsx("p",{className:"text-sm text-slate-400",children:'אין תבניות כפתורים. לחצו "הוסף".'})})]})]})}function Se(){const[a,g]=n.useState([]),[j,C]=n.useState(!0),[p,b]=n.useState(null),[s,v]=n.useState(null),[k,w]=n.useState(!1),[c,f]=n.useState([]),[o,y]=n.useState(""),[D,l]=n.useState(!1),[t,i]=n.useState(!1),[x,u]=n.useState(!1),[_,M]=n.useState(null),re=n.useRef(null);n.useEffect(()=>{let r=!0;return(async()=>{try{const[d,I]=await Promise.all([N.entities.SitePageDefault.list(),N.entities.Kibbutz.list().catch(()=>[])]);if(!r)return;const T=(d||[]).slice().sort((B,$)=>(B.order??0)-($.order??0));
3g(T),f((I||[]).filter(B=>!B.is_deleted)),T.length&&b(T[0].id)}catch{h.error("שגיאה בטעינת תבניות העמודים")}finally{r&&C(!1)}})(),()=>{r=!1}},[]),n.useEffect(()=>{const r=a.find(d=>d.id===p);v(r?{...r}:null)},[p,a]);const P=(r,d)=>v(I=>({...I,[r]:d})),me=r=>{var B,$;const d=($=(B=re.current)==null?void 0:B.getEditor)==null?void 0:$.call(B);if(!d){P("content",`${(s==null?void 0:s.content)||""} ${r}`);return}const I=d.getSelection(!0),T=I?I.index:d.getLength();d.insertText(T,r,"user"),d.setSelection(T+r.length,0),P("content",d.root.innerHTML)},xe=async()=>{var r;if(s){if(!((r=s.title)!=null&&r.trim())){h.error("נדרשת כותרת");return}w(!0);try{const d={title:s.title,content:s.content||"",homepage_image_url:s.homepage_image_url||null,hero_image_url:s.hero_image_url||null,show_in_footer:!!s.show_in_footer,footer_order:Number(s.footer_order)||0,seo_title:s.seo_title||"",seo_description:s.seo_description||"",is_active:s.is_active!==!1};await N.entities.SitePageDefault.update(s.id,d),g(I=>I.map(T=>T.id===s.id?{...T,...d}:T)),h.success("התבנית נשמרה")}catch{h.error("שגיאה בשמירת התבנית")}finally{w(!1)}}},ue=async()=>{var r;if(!o){h.error("בחרו קהילה");return}i(!0);try{const d=await N.functions.invoke("communitySiteDefaults",{action:"applyToCommunity",community_id:o,parts:["pages"],overwrite:D}),I=((r=d==null?void 0:d.data)==null?void 0:r.pages)||{};h.success(`הוחל על הקהילה — נוצרו ${I.created||0}, עודכנו ${I.updated||0}, דולגו ${I.skipped||0}`)}catch(d){h.error(`שגיאה בהחלה על הקהילה${d!=null&&d.message?`: ${d.message}`:""}`)}finally{i(!1)}},he=async()=>{if(window.confirm("לעדכן את עמודי ברירת המחדל בכל הקהילות? עמודים שקהילה ערכה ידנית לא ישונו.")){u(!0),M(null);try{let r=0;const d={communities:0,created:0,updated:0,skipped:0,deleted:0};for(let T=0;T<1e5;T+=1){const B=await N.functions.invoke("communitySiteDefaults",{action:"applyToAll",offset:r}),$=(B==null?void 0:B.data)||{};if(d.communities+=$.communities||0,d.created+=$.created||0,d.updated+=$.updated||0,d.skipped+=$.skipped||0,d.deleted+=$.deleted||0,$.total&&M({processed:$.processed||0,total:$.total}),$.nextOffset===null||$.nextOffset===void 0)break;r=$.nextOffset}const I=d.deleted?`, הוסרו כפילויות ${d.deleted}`:"";h.success(`עודכנו ${d.communities} קהילות — נוצרו ${d.created}, עודכנו ${d.updated}, דולגו ${d.skipped}${I}`)}catch(r){h.error(`שגיאה בעדכון הקהילות${r!=null&&r.message?`: ${r.message}`:""}`)}finally{u(!1),M(null)}}};return j?e.jsx("div",{className:"flex items-center justify-center h-48",children:e.jsx(A,{className:"w-6 h-6 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{icon:J,iconBg:"bg-emerald-50",iconColor:"text-emerald-600",title:"החלה על קהילות",subtitle:"החלת תבניות העמודים על קהילה מסוימת, או עדכון כל הקהילות בבת אחת",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{children:"החלה על קהילה מסוימת"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(oe,{communities:c,value:o,onChange:y}),e.jsxs(L,{onClick:ue,disabled:t,className:"gap-2",children:[t?e.jsx(A,{className:"w-4 h-4 animate-spin"}):e.jsx(Q,{className:"w-4 h-4"}),"החל"]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600",children:[e.jsx(K,{checked:D,onCheckedChange:l}),"דרוס גם עמודים קיימים (שלא הותאמו ידנית)"]}),e.jsx("p",{className:"text-xs text-slate-400",children:"ללא דריסה — נוצרים רק עמודים חסרים; עמודים שהקהילה ערכה נשמרים תמיד."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{children:"עדכון כל הקהילות (עמודים בלבד)"}),e.jsxs(L,{onClick:he,disabled:x,variant:"secondary",className:"gap-2",children:[x?e.jsx(A,{className:"w-4 h-4 animate-spin"}):e.jsx(J,{className:"w-4 h-4"}),x&&_?`מעדכן… ${_.processed}/${_.total}`:"עדכן בכל הקהילות"]}),e.jsx("p",{className:"text-xs text-slate-400",children:"מרענן את עמודי ברירת המחדל בכל הקהילות. עמודים שקהילה ערכה ידנית לא ישונו — ההתאמה המקומית תמיד גוברת."})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[280px_1fr] gap-6",children:[e.jsx(E,{icon:q,iconBg:"bg-blue-50",iconColor:"text-blue-600",title:"עמודי ברירת מחדל",className:"h-fit",children:e.jsx("div",{className:"space-y-1.5",children:a.map(r=>{const d=r.id===p;return e.jsxs("button",{type:"button",onClick:()=>b(r.id),className:`w-full text-right px-3 py-2.5 rounded-xl border transition-colors
4                    ${d?"bg-primary/10 border-primary/40":"bg-white border-slate-100 hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-semibold text-sm text-slate-800 truncate",children:r.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:_e[r.page_type]||"עמוד"}),r.show_in_footer&&e.jsx("span",{className:"text-[11px] text-emerald-600",children:"בפוטר"})]})]},r.id)})})}),s?e.jsx(E,{icon:q,title:`עריכת תבנית: ${s.title||""}`,subtitle:`slug: ${s.slug}`,action:e.jsxs(L,{onClick:xe,disabled:k,size:"sm",className:"gap-2",children:[k?e.jsx(A,{className:"w-4 h-4 animate-spin"}):e.jsx(ee,{className:"w-4 h-4"}),"שמירה"]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"כותרת העמוד"}),e.jsx(S,{value:s.title||"",onChange:r=>P("title",r.target.value)})]}),e.jsxs("div",{className:"rounded-xl bg-slate-50 border border-slate-100 p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-500 mb-2",children:"מחוונים להחלפה אוטומטית לכל קהילה — לחצו כדי להוסיף לתוכן:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:fe.map(r=>e.jsxs("button",{type:"button",onClick:()=>me(r.token),className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-white border border-slate-200 text-xs text-slate-600 hover:bg-primary/10 hover:border-primary/30 transition-colors",title:r.token,children:[e.jsx(se,{className:"w-3 h-3"})," ",r.label]},r.token))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"תוכן העמוד"}),e.jsx(je,{ref:re,theme:"snow",value:s.content||"",onChange:r=>P("content",r),className:"bg-white [&_.ql-editor]:min-h-[220px]"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx("div",{children:e.jsx(ie,{label:"תמונה ראשית לעמוד",value:s.hero_image_url||s.homepage_image_url||"",onChange:r=>v(d=>({...d,hero_image_url:r||null,homepage_image_url:r||null}))})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(m,{className:"mb-0",children:"הצגה בפוטר"}),e.jsx(K,{checked:!!s.show_in_footer,onCheckedChange:r=>P("show_in_footer",r)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סדר בפוטר"}),e.jsx(S,{type:"number",value:s.footer_order??0,onChange:r=>P("footer_order",r.target.value),className:"w-28"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"כותרת SEO"}),e.jsx(S,{value:s.seo_title||"",onChange:r=>P("seo_title",r.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"תיאור SEO"}),e.jsx(le,{value:s.seo_description||"",onChange:r=>P("seo_description",r.target.value),rows:2})]})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-slate-400 border-t border-slate-100 pt-4",children:[e.jsx(Z,{className:"w-4 h-4 flex-none mt-0.5 text-slate-300"}),e.jsx("span",{children:'שינויים כאן משפיעים על קהילות חדשות מכאן והלאה, ועל קהילות קיימות רק בעת "עדכן בכל הקהילות" / "החל על קהילה". עמודים שקהילה ערכה בעצמה לא נדרסים.'})]})]})}):e.jsx(E,{icon:q,title:"בחרו עמוד לעריכה",children:e.jsx("p",{className:"text-sm text-slate-400",children:"אין תבניות עמודים."})})]})]})}const G="default";function Ce(){const[a,g]=n.useState(null),[j,C]=n.useState(!0),[p,b]=n.useState(!1);n.useEffect(()=>{let l=!0;return(async()=>{try{let t=await N.entities.SiteMarketingSection.get(G).catch(()=>null);if(t||(t=(await N.entities.SiteMarketingSection.list().catch(()=>[]))[0]||null),!l)return;g(t?{...t}:{id:G,is_active:!0,title:"",subtitle:"",bullets:[],primary_button_type:"auth_action",secondary_button_type:"external_link",media_type:"images",images:[]})}catch{h.error("שגיאה בטעינת התוכן השיווקי")}finally{l&&C(!1)}})(),()=>{l=!1}},[]);const s=(l,t)=>g(i=>({...i,[l]:t})),v=Array.isArray(a==null?void 0:a.bullets)?a.bullets:[],k=Array.isArray(a==null?void 0:a.images)?a.images:[],w=(l,t)=>s("bullets",v.map((i,x)=>x===l?t:i)),c=()=>s("bullets",[...v,""]),f=l=>s("bullets",v.filter((t,i)=>i!==l)),o=l=>{l&&s("images",[...k,l])},y=l=>s("images",k.filter((t,i)=>i!==l)),D=async()=>
4{if(a){b(!0);try{const l={is_active:a.is_active!==!1,title:a.title||"",subtitle:a.subtitle||"",bullets:v.filter(i=>i&&i.trim()),primary_button_text:a.primary_button_text||null,primary_button_type:a.primary_button_type||"auth_action",primary_button_target:a.primary_button_target||null,secondary_button_text:a.secondary_button_text||null,secondary_button_type:a.secondary_button_type||"external_link",secondary_button_target:a.secondary_button_target||null,media_type:a.media_type||"images",youtube_url:a.media_type==="youtube"&&a.youtube_url||null,images:a.media_type==="images"?k.filter(Boolean):[]};await N.entities.SiteMarketingSection.get(G).catch(()=>null)?await N.entities.SiteMarketingSection.update(G,l):await N.entities.SiteMarketingSection.create({id:G,...l}),h.success("התוכן השיווקי נשמר")}catch{h.error("שגיאה בשמירה")}finally{b(!1)}}};return j?e.jsx("div",{className:"flex items-center justify-center h-40",children:e.jsx(A,{className:"w-6 h-6 animate-spin text-primary"})}):a?e.jsx(E,{icon:se,iconBg:"bg-violet-50",iconColor:"text-violet-600",title:"תוכן החלק השיווקי",subtitle:"מוצג בתחתית עמוד הבית של כל קהילה. תוכן מרכזי — מותאם אוטומטית לשם הקהילה.",action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx(K,{checked:a.is_active!==!1,onCheckedChange:l=>s("is_active",l)}),e.jsx("span",{className:"text-sm text-slate-600",children:a.is_active!==!1?"פעיל":"כבוי"})]}),e.jsxs(L,{onClick:D,disabled:p,size:"sm",className:"gap-2",children:[p?e.jsx(A,{className:"w-4 h-4 animate-spin"}):e.jsx(ee,{className:"w-4 h-4"})," שמירה"]})]}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"כותרת"}),e.jsx(S,{value:a.title||"",onChange:l=>s("title",l.target.value),placeholder:"תושבי {{community_name}} — הצטרפו לקהילה הדיגיטלית"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"טקסט פתיחה"}),e.jsx(le,{value:a.subtitle||"",onChange:l=>s("subtitle",l.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(m,{children:"נקודות חוזק"}),e.jsxs(L,{size:"sm",variant:"secondary",className:"gap-1.5",onClick:c,children:[e.jsx(ae,{className:"w-4 h-4"})," נקודה"]})]}),e.jsxs("div",{className:"space-y-2",children:[v.map((l,t)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{value:l,onChange:i=>w(t,i.target.value),placeholder:`נקודה ${t+1}`}),e.jsx("button",{type:"button",onClick:()=>f(t),className:"text-red-500 hover:text-red-700 p-1.5",children:e.jsx(W,{className:"w-4 h-4"})})]},t)),v.length===0&&e.jsx("p",{className:"text-xs text-slate-400",children:'אין נקודות. לחצו "נקודה" להוספה.'})]})]})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"מדיה (צד שני במסך)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>s("media_type","images"),className:`flex-1 h-9 rounded-lg text-sm font-medium border transition-colors ${a.media_type!=="youtube"?"border-primary/40 bg-primary/5 text-primary":"border-slate-200 text-slate-500"}`,children:"תמונות מתחלפות"}),e.jsx("button",{type:"button",onClick:()=>s("media_type","youtube"),className:`flex-1 h-9 rounded-lg text-sm font-medium border transition-colors ${a.media_type==="youtube"?"border-primary/40 bg-primary/5 text-primary":"border-slate-200 text-slate-500"}`,children:"סרטון יוטיוב"})]})]}),a.media_type==="youtube"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"קישור יוטיוב"}),e.jsx(S,{value:a.youtube_url||"",onChange:l=>s("youtube_url",l.target.value),placeholder:"https://youtube.com/watch?v=...",dir:"ltr",className:"text-left"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{children:"תמונות מתחלפות"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:k.map((l,t)=>e.jsxs("div",{className:"relative aspect-video rounded-lg overflow-hidden border border-slate-100 group",children:[e.jsx("img",{src:l,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>y(t),className:"absolute top-1 left-1 bg-black/60 text-white rounded p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(W,{className:"w-3.5 h-3.5"})})]},l+t))}),e.jsx(ie,{label:"הוספת תמונה",value:"",onChange:o})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"rounded-xl border border-slate-100 p-4 space-y-3",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-700",children:"כפתור ראשי"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"טקסט"}),e.jsx(S,{value:a.primary_button_text||"",onChange:l=>s("primary_button_text",l.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סוג"}),e.jsxs(O,{value:a.primary_button_type||"auth_action",onValueChange:l=>s("primary_button_type",l),children:[e.jsx(z,{children:e.jsx(R,{})}),e.jsx(V,{dir:"rtl",children:U.map(l=>e.jsx(F,{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"יעד"}),e.jsx(X,{type:a.primary_button_type||"auth_action",target:a.primary_button_target,external:a.primary_button_target,onTarget:l=>s("primary_button_target",l),onExternal:l=>s("primary_button_target",l)})]})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-100 p-4 space-y-3",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-700",children:"כפתור משני (הורדת אפליקציה)"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"טקסט"}),e.jsx(S,{value:a.secondary_button_text||"",onChange:l=>s("secondary_button_text",l.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"סוג"}),e.jsxs(O,{value:a.secondary_button_type||"external_link",onValueChange:l=>s("secondary_button_type",l),children:[e.jsx(z,{children:e.jsx(R,{})}),e.jsx(V,{dir:"rtl",children:U.map(l=>e.jsx(F,{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"יעד"}),e.jsx(X,{type:a.secondary_button_type||"external_link",target:a.secondary_button_target,external:a.secondary_button_target,onTarget:l=>s("secondary_button_target",l),onExternal:l=>s("secondary_button_target",l)})]})]})]})]})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-slate-400 border-t border-slate-100 pt-4",children:[e.jsx(Z,{className:"w-4 h-4 flex-none mt-0.5 text-slate-300"}),e.jsxs("span",{children:["המחוון ","{{","community_name","}}"," בכותרת/בטקסט יוחלף בשם הקהילה בכל אתר. מנהלי הקהילות אינם רואים או עורכים חלק זה."]})]})]})}):null}function $e(){const[a,g]=n.useState([]),[j,C]=n.useState(!0),[p,b]=n.useState(""),[s,v]=n.useState(null);n.useEffect(()=>{let c=!0;return(async()=>{try{const f=await N.entities.Kibbutz.list("-created_date",300).catch(()=>[]);if(!c)return;g((f||[]).filter(o=>!o.is_deleted))}catch{h.error("שגיאה בטעינת הקהילות")}finally{c&&C(!1)}})(),()=>{c=!1}},[]);const k=async(c,f)=>{v(c.id);try{await N.entities.Kibbutz.update(c.id,{show_marketing_section:f}),g(o=>o.map(y=>y.id===c.id?{...y,show_marketing_section:f}:y))}catch{h.error("שגיאה בעדכון הקהילה")}finally{v(null)}},w=a.filter(c=>{var f,o;return!p||((f=c.name)==null?void 0:f.includes(p))||((o=c.slug)==null?void 0:o.includes(p))});return e.jsx(E,{icon:Q,iconBg:"bg-blue-50",iconColor:"text-blue-600",title:"הצגה לפי קהילה",subtitle:"בחרו לאילו קהילות יוצג החלק השיווקי באתר הציבורי. ברירת המחדל: מוצג.",action:e.jsx("div",{className:"relative",children:e.jsx(S,{value:p,onChange:c=>b(c.target.value),placeholder:"חיפוש קהילה…",className:"w-56"})}),children:j?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(A,{className:"w-6 h-6 animate-spin text-primary"})}):e.jsxs("div",{className:"divide-y divide-slate-100",children:[w.map(c=>{const f=c.show_marketing_section!==!1;return e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[c.logo?e.jsx("img",{src:c.logo,alt:"",className:"w-9 h-9 rounded-lg object-contain bg-slate-50 border border-slate-100 flex-none"}):e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-none",children:e.jsx(Q,{className:"w-4 h-4 text-slate-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-slate-800 truncate",children:c.name}),e.jsx("div",{className:"text-xs text-slate-400 truncate",children:c.slug})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-none",children:[s===c.id&&e.jsx(A,{className:"w-4 h-4 animate-spin text-slate-300"}),e.jsx("span",{className:`text-xs ${f?"text-emerald-600":"text-slate-400"}`,children:f?"מוצג":"מוסתר"}),e.jsx(K,{checked:f,disabled:s===c.id,onCheckedChange:o=>k(c,o)})]})]},c.id)}),w.length===0&&e.jsx("p",{className:"text-sm text-slate-400 py-6 text-center",children:"לא נמצאו קהילות."})]})})}function Ie(){return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ce,{}),e.jsx($e,{})]})}
4export{lt 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.