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.