1import{r,j as e,C as ue,Z as Le,ae as Te,z as h,d as k,a9 as Q,a1 as me,af as ne,Q as X,T as xe,ag as he,am as Fe,m as Oe,n as Ie,o as Ee,p as Me,aL as $e,B as R,aC as ze,ac as He,t as Ae,a as Ue,aI as Be,y as Re,P as Ge,K as Ve}from"./index-BH8Hq4fF.js";import{K as Ke}from"./KibbutzModuleGuard-BrSTzYkw.js";import{g as We,D as qe}from"./DigitalPageFormDialog-WPatTbMU.js";import{S as fe,a as ge,b as pe,c as be,d as Y}from"./select-D1fi8zWO.js";import{f as Ze,g as Qe,a as Xe,I as Ye,u as Je,b as et,c as tt,d as st,e as at,h as lt}from"./digitalPageUtils-HdRLL7zn.js";import{M as q}from"./ManagerDialog-iFzxbOnI.js";import{F as Z}from"./FormSection-8_EQ6Rzg.js";import{l as E,f as J,a as je}from"./formStyles-CzLsWpb8.js";import{S as ee}from"./save-B5tADMHo.js";import{F as rt}from"./file-code-EbflQUCw.js";import{C as it}from"./clipboard-paste-9hEC__C5.js";import{F as nt}from"./file-up-D9M_wud9.js";import{U as ot}from"./upload-DtbdHLAK.js";import{B as we}from"./badge-DStqKKop.js";import{u as ct}from"./useHtmlContent-Cd5aQ1Da.js";import{C as dt}from"./code-Dlxbz7jD.js";import{P as ut}from"./pencil-DlA_FTEn.js";import{C as ve}from"./copy-B_0EPT7Q.js";import{C as mt}from"./CategoryManagerDialog-D9Jh-c_S.js";import{S as Ne}from"./switch-Sj01sJJm.js";import{L as _e}from"./label-BHWfbzXI.js";import{o as xt,U as ht,p as ft,a as gt,m as oe}from"./digitalPageOrder-C4niF6hl.js";import{L as ce}from"./list-ordered-DxwjvuSC.js";import{A as pt}from"./arrow-down-VEWBquYE.js";import{G as bt}from"./grip-vertical-Bettc5f-.js";import{C as jt}from"./check-check-DLN-xcGC.js";import{P as wt}from"./PageTitleMenu-CMXtRh6s.js";import{F as vt}from"./file-pen-LjKIPwci.js";import"./refresh-cw-kjmzcQOe.js";import"./tabs-CKaP-HUz.js";import"./input-RnZK1Sdh.js";import"./textarea-C9Nd53i2.js";import"./index-9660Bi2z.js";import"./isEqual-JxrnfUIG.js";import"./pdfThumbnail--4I8gdgE.js";import"./RegField-Bs2WN6x6.js";import"./FormColumnCard-CRl3dGTi.js";import"./StepCards-BAMOaQ3M.js";import"./align-left-DTBFU8py.js";import"./index-CikwpBsl.js";import"./chevron-up-Nk0mcmku.js";import"./ConfirmDialog-5ehqONc0.js";import"./alert-dialog-CKlZlXSt.js";import"./utensils-crossed-Bi5st8bT.js";import"./heart-pulse-CrOlTjnS.js";import"./pill-CexHQAtm.js";import"./utensils-D_WButlT.js";import"./mic-UCuawlcW.js";import"./film-MuXUePXC.js";import"./party-popper-BB1LW77c.js";import"./pizza-DRRY-QvQ.js";import"./tree-pine-C5mfzpOE.js";import"./trophy-ouGVads6.js";import"./sparkles-DYMjDKmN.js";import"./leaf-DJuap4o0.js";import"./graduation-cap-DnGVwVvF.js";import"./baby-Cs7Gtrey.js";import"./dumbbell-B6wytY5J.js";import"./palette-CIgIe0F7.js";import"./music-DKTtf7a1.js";import"./reorder-BJ1u2xSy.js";import"./useActionVisibility-oACH4aDh.js";function Nt({kibbutzId:s,existingPages:m,categories:d,onClose:p,onSaved:i}){const[b,v]=r.useState(""),[N,x]=r.useState(""),[_,o]=r.useState(""),[j,c]=r.useState("paste"),[y,P]=r.useState(""),[a,u]=r.useState(null),[C,S]=r.useState(""),[I,L]=r.useState(!1),T=r.useRef(null),w=j==="file"?C:y,M=!!w.trim();function G(t){var O;const n=(O=t.target.files)==null?void 0:O[0];if(!n)return;const f=[".html",".htm",".txt"],g=n.name.slice(n.name.lastIndexOf(".")).toLowerCase();if(!f.includes(g)){h.error("× ××ª× ×××¢×× ×§×××¥ HTML ××××"),t.target.value="";return}const F=new FileReader;F.onload=A=>{S(A.target.result),u(n),h.success("××§×××¥ ×××× ×××¢×× ×")},F.onerror=()=>{h.error("ש×××× ×קר××ת ××§×××¥")},F.readAsText(n)}function $(){u(null),S(""),T.current&&(T.current.value="")}async function z(){if(!b.trim()){h.error("× × ××××× ××תרת ×¢×××");return}if(!M){h.error(j==="file"?"× × ×××¢×× ×§×××¥ HTML":"× × ××××××§ ×§×× HTML");return}L(!0);try{const t=Qe(b.trim()),n=await Xe(t,s,m),f=j==="file"?a.name:`${t||"page"}.html`,g=new Blob([w]).size,F=g>Ye;let O="",A="",V="",K="inline";if(F){h.loading("××¢×× ×§×××¥ HTML...",{id:"upload"});const{file_url:se}=await Je(k,w,f);O=se,K="file",V=et(w),h.dismiss("upload")}else A=tt(w),K="inline",V="";const te={kibbutz_id:s,title:b.trim(),slug:n,description:N.trim(),content:"",html_content:A,html_file_url:O,html_file_name:f,html_file_size:g,html_uploaded_at:new Date().toISOString(),html_preview_content:V,content_storage_type:K,content_type:"html",category_id:_||"",status:"draft",show_on_website:!0,show_on_app:!0,show_on_homepage:!1,is_private:!1,is_active:!0,allow_lead_form:!1,show_view_counter:!0,show_update_date:!0,show_share_buttons:!0,sort_order:0};await k.entities.DigitalPage.create(te),h.success("××¢××× × ×צר ××צ×××"),i(),p()}catch{h.dismiss("upload"),h.error("×צ×רת ××¢××× × ×ש××. × ×¡× ×©×× ×× ×שת××©× ××§×××¥ ×§×× ××תר.")}finally{L(!1)}}const H=[{key:"paste",label:"×××קת ×§×× HTML",icon:it},{key:"file",label:"××¢×× ×ª ×§×××¥ HTML",icon:nt}];return e.jsxs(q,{onClose:p,title:"צ×ר ×¢××× HTML ××ש",icon:rt,tone:"emerald",maxWidth:"max-w-[800px]",onSave:z,saving:I,saveLabel:"צ×ר ×¢×××",saveIcon:ee,saveDisabled:!b.trim()||!M,children:[e.jsx(Z,{title:"פר×× ××¢×××",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:E,
1children:["××תרת ××¢××× ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{value:b,onChange:t=>v(t.target.value),placeholder:"××××××: ××£ ×§××ת ×¤× ×× ×××ר",className:J,autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:E,children:"ת×××ר קצר"}),e.jsx("textarea",{value:N,onChange:t=>x(t.target.value),rows:2,placeholder:"ת×××ר קצר ש××פ××¢ ××ר××ס ××¢××× (××פצ××× ××)",className:je})]}),d&&d.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:E,children:"ס×× ×¢××× / ×§×××ר××"}),e.jsxs(fe,{value:_||"none",onValueChange:t=>o(t==="none"?"":t),children:[e.jsx(ge,{className:J,children:e.jsx(pe,{placeholder:"××ר ×§×××ר×× (××פצ××× ××)"})}),e.jsxs(be,{children:[e.jsx(Y,{value:"none",children:"××× ×§×××ר××"}),d.map(t=>e.jsx(Y,{value:t.id,children:t.title},t.id))]})]})]})]})}),e.jsxs(Z,{title:"ת××× HTML",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2 mb-3",children:H.map(t=>{const n=t.icon,f=j===t.key;return e.jsxs("button",{type:"button",onClick:()=>c(t.key),className:`h-11 rounded-xl border text-sm font-semibold inline-flex items-center justify-center gap-2 transition-all ${f?"bg-emerald-600 text-white border-emerald-600 shadow-sm":"bg-white border-slate-200 text-slate-600 hover:bg-slate-50"}`,children:[e.jsx(n,{className:"w-4 h-4"})," ",t.label]},t.key)})}),j==="paste"?e.jsxs("div",{children:[e.jsxs("label",{className:E,children:["×§×× HTML ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{value:y,onChange:t=>P(t.target.value),rows:12,dir:"ltr",className:"w-full font-mono text-sm rounded-xl border border-slate-200 bg-slate-50 p-3 focus:outline-none focus:ring-2 focus:ring-emerald-100 focus:border-emerald-300",placeholder:`<div> 2 <h1>××תרת ××¢×××</h1> 3 <p>ת××× ××¢×××...</p> 4</div>`})]}):e.jsxs("div",{children:[e.jsxs("label",{className:E,children:["×§×××¥ HTML ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"border-2 border-dashed border-slate-200 rounded-xl p-4 bg-white",children:[a?e.jsxs("div",{className:"flex items-center justify-between bg-emerald-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ue,{className:"w-5 h-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:a.name}),e.jsxs("p",{className:"text-xs text-emerald-600",children:[Ze(a.size)," · ××§×××¥ ×××× ×××¢×× ×"]})]})]}),e.jsx("button",{onClick:$,className:"p-1.5 rounded-lg hover:bg-white text-slate-400 hover:text-red-500",children:e.jsx(Le,{className:"w-4 h-4"})})]}):e.jsxs("div",{onClick:()=>{var t;return(t=T.current)==null?void 0:t.click()},className:"flex flex-col items-center justify-center py-6 cursor-pointer",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center mb-2",children:e.jsx(ot,{className:"w-6 h-6 text-slate-400"})}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"×××¦× ××××רת ×§×××¥ HTML"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"×§×צ×× × ×ª××××: .html, .htm, .txt"})]}),e.jsx("input",{ref:T,type:"file",accept:".html,.htm,.txt",onChange:G,className:"hidden"})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 flex items-center gap-1",children:[e.jsx(Te,{className:"w-3.5 h-3.5 flex-shrink-0"}),"סקר×פ××× ×××¡×¨× ×××××××ת ×××¢×× ×××××. ת××× ×××× ××ש×ר ×××××××ת ××§×××¥ ××××¦× ××¨× ×ת××ת ××§×××¥."]})]})]})}function _t({page:s,categoryName:m,publicUrl:d,onView:p,onCopy:i,onEdit:b,onSettings:v,onDelete:N}){const[x,_]=r.useState(!1),o=st(s.status),j=s.content_storage_type==="file"||s.html_file_url&&!s.html_content,c=s.html_content&&s.html_content.trim(),y=s.content&&s.content.trim(),{html:P,error:a}=ct(j?s.html_file_url:null),u=j?P:c?s.html_content:y?s.content:"",C=j?!a&&!!P:!!u,S=j||c?"×¢××× HTML":y?"××£ ××××¢":"××£ ××ש",I=j||c?dt:y?me:Q,L=s.updated_date?new Date(s.updated_date).toLocaleDateString("he-IL"):s.created_date?new Date(s.created_date).toLocaleDateString("he-IL"):"â";function T(w){w.stopPropagation(),x?N(s):(_(!0),setTimeout(()=>_(!1),3e3))}return e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm overflow-hidden flex flex-col hover:shadow-md hover:border-slate-300 transition-all h-full",children:[e.jsxs("div",{className:"relative h-[220px] bg-white overflow-hidden",style:{borderRadius:"18px 18px 0 0"},children:[C?e.jsx("iframe",{srcDoc:u,className:"border-0 pointer-events-none absolute top-0 right-0",style:{width:"222%",height:"222%",transform:"scale(0.45)",transformOrigin:"top right",pointerEvents:"none",background:"white"},title:`preview-${s.id}`,sandbox:"",loading:"lazy"}):e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center bg-slate-50",children:[e.jsx("div",{className:"w-14 h-14 roun
4ded-full bg-slate-100 flex items-center justify-center mb-2",children:e.jsx(Q,{className:"w-7 h-7 text-slate-300"})}),e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"תצ××× ××§×××× ×× ×××× ×"}),e.jsx("p",{className:"text-xs text-slate-300 mt-0.5",children:"×××¥ ×¢× ××¦× ×פת××ת ××¢×××"})]}),e.jsx("div",{className:"absolute top-2 right-2 flex gap-1.5 z-10",children:e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-white/90 backdrop-blur text-slate-600 border border-slate-200 flex items-center gap-1",children:[e.jsx(I,{className:"w-3 h-3"}),S]})}),e.jsx("div",{className:"absolute top-2 left-2 z-10",children:e.jsx(we,{className:o.cls,children:o.label})})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground line-clamp-1 leading-snug mb-1",children:s.title}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1 leading-snug mb-2",children:s.description}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mb-3",children:[e.jsx("span",{children:L}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-blue-50 text-blue-600 text-xs font-medium",children:[e.jsx(ne,{className:"w-3 h-3"}),s.view_count||0," צפ××ת"]})]}),m&&m!=="â"&&e.jsx("div",{className:"mb-3",children:e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs bg-purple-50 text-purple-600",children:m})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-auto pt-3 border-t border-slate-100",children:[e.jsx("button",{onClick:w=>{w.stopPropagation(),b(s)},className:"w-11 h-11 rounded-full bg-orange-50 flex items-center justify-center text-orange-500 hover:bg-orange-100 transition-colors",title:"ער×××",children:e.jsx(ut,{className:"w-5 h-5"})}),e.jsx("button",{onClick:w=>{w.stopPropagation(),v(s)},className:"w-11 h-11 rounded-full bg-slate-100 flex items-center justify-center text-slate-500 hover:bg-slate-200 transition-colors",title:"×××ר×ת",children:e.jsx(X,{className:"w-5 h-5"})}),e.jsx("button",{onClick:w=>{w.stopPropagation(),p(s)},className:"w-11 h-11 rounded-full bg-purple-50 flex items-center justify-center text-purple-500 hover:bg-purple-100 transition-colors",title:"×צ×",children:e.jsx(ne,{className:"w-5 h-5"})}),e.jsx("button",{onClick:w=>{w.stopPropagation(),i(s)},className:"w-11 h-11 rounded-full bg-blue-50 flex items-center justify-center text-blue-500 hover:bg-blue-100 transition-colors",title:"×עתק ×§×ש×ר",children:e.jsx(ve,{className:"w-5 h-5"})}),e.jsx("button",{onClick:T,className:`w-11 h-11 rounded-full flex items-center justify-center transition-colors ${x?"bg-red-100 text-red-600 ring-2 ring-red-300":"bg-red-50 text-red-400 hover:bg-red-100 hover:text-red-600"}`,title:x?"×××¦× ×©×× ×××ש×ר ××××§×":"××××§×",children:e.jsx(xe,{className:"w-5 h-5"})})]})]})]})}const de={show_search:!0,show_categories:!0,allow_lead_forms:!0};function ae({label:s,checked:m,onChange:d}){return e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsx(_e,{className:"text-sm font-medium cursor-pointer",children:s}),e.jsx(Ne,{checked:m,onCheckedChange:d})]})}function yt({kibbutzId:s,onClose:m}){const{t:d}=he(),[p,i]=r.useState(de),[b,v]=r.useState(!0),[N,x]=r.useState(!1);r.useEffect(()=>{_()},[s]);async function _(){v(!0);try{const c=await k.entities.DigitalPageSettings.filter({kibbutz_id:s});c[0]&&i({...de,...c[0]})}catch{}finally{v(!1)}}function o(c,y){i(P=>({...P,[c]:y}))}async function j(){x(!0);try{p.id?await k.entities.DigitalPageSettings.update(p.id,{...p,kibbutz_id:s}):await k.entities.DigitalPageSettings.create({...p,kibbutz_id:s}),h.success("××××ר×ת × ×©×ר×"),m()}catch{h.error("ש×××× ×ש××ר×")}finally{x(!1)}}return b?e.jsx(q,{onClose:m,title:"×××ר×ת ×¢××××× ×××××××××",icon:X,tone:"blue",maxWidth:"max-w-md",hideFooter:!0,children:e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})})}):e.jsxs(q,{onClose:m,title:"×××ר×ת ×¢××××× ×××××××××",icon:X,tone:"blue",maxWidth:"max-w-md",onSave:j,saving:N,saveLabel:"ש××ר×",saveIcon:ee,children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["×××ר×ת ×¢××× ××תר (ת××× ×, ××תרת, ת×××ר, תפר××××) ×× ××××ת ××¨× ×תר ",d("community_noun_definite")," â × ×××× ×¢×××××."]}),e.jsxs(Z,{children:[e.jsx(ae,{label:"××¦× ××פ×ש",checked:p.show_search,onChange:c=>o("show_search",c)}),e.jsx(ae,{label:"××¦× ×§×××ר××ת",checked:p.show_categories,onChange:c=>o("show_categories",c)}),e.jsx(ae,{label:"×פשר ××¤×¡× ×¤× ×××",checked:p.allow_lead_forms,onChange:c=>o("allow_lead_forms",c)})]})]})}function Ct({kibbutzId:s,pages:m,categories:d,onClose:p,onSaved:i}){var z,H;const b=r.useMemo(()=>xt(m,d),[m,d]),[v,N]=r.useState(((z=b[0])==null?void 0:z.key)||ht),[x,_]=r.useState(()=>{const t={};for(const n of b)t[n.key]=ft(m,n.key);return t}),[o,j]=r.useState(()=>new Set),[c,y]=r.useState(null),[P,a]=r.useState(!1),u=r.useRef(null),C=x[v]||[],S=C.findIndex(t=>t.id===c),I=r.useMemo(()=>{const t={};for(const[n,f]of Object.entries(x)){if(!o.has(n))continue;const g=gt(f);g.length&&(t[n]=g)}return t},[x,o]),L=Object.values(I).reduce((t,n)=>t+n.length,0);function T(t,n){const f=x[t]||[];n.length===f.length&&n.every((g,F)=>{var O;return g.id===((O=f[F])==null?void 0:O.id)})||(_(g=>({...g,[t]:n})),j(g=>g.has(t)?g:new Set(g).add(t)))}function w(t){S<0||T(v,oe(C,S,S+t))}r.useEffect(()=>{if(!c)return;const t=n=>{n.key!=="ArrowUp"&&n.key!=="ArrowDown"||(n.preventDefault(),w(n.key==="ArrowUp"?-1:1))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[c,v,x]);function M(t,n){t.preventDefault();const f=u.current;f===null||f===n||(T(v,oe(C,f,n)),u.current=n)}async function G(){if(!L){h("×ס×ר ×× ××©×ª× ×"),p();return}a(!0);try{const t=Object.values(I).flat();await Promise.all(t.map(n=>k.entities.DigitalPage.update(n.id,{sort_order:n.sort_order}))),h.success("ס×ר ××¢××××× × ×©×ר"),i==null||i(),p()}catch{h.error("ש×××× ×ש××רת ×ס×ר")}finally{a(!1)}}const $=b.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 roun
4ded-full bg-slate-100 flex items-center justify-center mx-auto mb-3",children:e.jsx(ce,{className:"w-7 h-7 text-slate-300"})}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"××× ×¢×××× ×¢××××× ×ס×××ר"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"×¦×¨× ×¢××××× ×ש×××× ×××ª× ××§×××ר××, ×××× ×ª×××× ××§×××¢ ×ת ס×ר ×צ××ª× ××תר."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"××¨×¨× ×¢××× ×××§×××, ×× ×¡×× × ×××ª× ×××××× ××צ×× (×× ×××§××ת). ×ס×ר ×©× ×§××¢ ××× ××× ×ס×ר ש×× ××¢××××× ××צ××× ×ת××©× ××§×××ר×× ××× ××תר ×××פ××קצ××. ×¢××× ××ש ש××××צר ××××ר ××תר ×ת××סף ×ס××£ ×רש×××."}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>w(-1),disabled:S<=0,className:"inline-flex items-center gap-1.5 h-9 px-3 rounded-lg border border-slate-200 bg-white text-sm font-medium text-slate-700 hover:bg-slate-50 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Fe,{className:"w-4 h-4"})," ××¢××"]}),e.jsxs("button",{type:"button",onClick:()=>w(1),disabled:S<0||S>=C.length-1,className:"inline-flex items-center gap-1.5 h-9 px-3 rounded-lg border border-slate-200 bg-white text-sm font-medium text-slate-700 hover:bg-slate-50 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(pt,{className:"w-4 h-4"})," ××ר×"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:S>=0?`× ××ר: ${((H=C[S])==null?void 0:H.title)||"××× ××תרת"} · ××§×× ${S+1} ×ת×× ${C.length}`:"×× × ××ר ×¢×××"})]}),e.jsx("div",{className:"space-y-2",children:C.map((t,n)=>{const f=t.id===c;return e.jsxs("div",{draggable:!0,onDragStart:()=>{u.current=n,y(t.id)},onDragOver:g=>M(g,n),onDrop:g=>{g.preventDefault(),u.current=null},onDragEnd:()=>{u.current=null},onClick:()=>y(f?null:t.id),className:`flex items-center gap-3 p-2.5 rounded-xl border bg-white cursor-grab active:cursor-grabbing transition-all ${f?"border-purple-300 ring-2 ring-purple-100":"border-slate-200 hover:border-slate-300"}`,children:[e.jsx(bt,{className:"w-5 h-5 text-slate-300 flex-shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"w-7 h-7 rounded-lg bg-slate-100 text-slate-600 text-xs font-extrabold grid place-items-center flex-shrink-0",children:n+1}),t.cover_image?e.jsx("img",{src:t.cover_image,alt:"",className:"w-12 h-9 rounded-md object-cover border border-slate-200 flex-shrink-0"}):e.jsx("span",{className:"w-12 h-9 rounded-md bg-slate-50 border border-slate-200 grid place-items-center flex-shrink-0",children:e.jsx(Q,{className:"w-4 h-4 text-slate-300"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-bold text-foreground truncate",children:t.title||"××× ××תרת"}),e.jsxs("p",{className:"text-[0.6875rem] text-muted-foreground truncate",children:[t.status==="published"?"×פ×רס×":"×××××",t.show_on_website===!1&&" · ×× ×××¦× ××תר"]})]})]},t.id)})})]});return e.jsx(q,{onClose:p,title:"ס×ר ×צ×ת ××¢×××××",subtitle:"××× ×§×××ר×× ×¡×ר ×ש××, ××¤× ×©×ת××©× ×¨××× ××ת×",icon:ce,tone:"purple",maxWidth:"max-w-2xl",align:"top",tabs:b.map(t=>({key:t.key,label:`${t.title} (${t.count})`})),activeTab:v,onTabChange:t=>{N(t),y(null)},onSave:b.length?G:void 0,hideFooter:!b.length,saving:P,saveDisabled:!L,saveLabel:L?`ש××רת ×ס×ר (${L})`:"ש××רת ×ס×ר",saveIcon:ee,children:$})}function St({kibbutzId:s,pages:m,onClose:d}){const[p,i]=r.useState([]),[b,v]=r.useState(!0),[N,x]=r.useState("all");r.useEffect(()=>{_()},[s]);async function _(){v(!0);try{const a=await k.entities.DigitalPageLead.filter({kibbutz_id:s},"-created_date",500);i(a)}catch{h.error("ש×××× ×××¢×× ×ª ×¤× ××ת")}finally{v(!1)}}const o=r.useMemo(()=>N==="all"?p:p.filter(a=>a.status===N),[p,N]),j=r.useMemo(()=>{const a={};return m.forEach(u=>{a[u.id]=u.title}),a},[m]);async function c(a,u){try{await k.entities.DigitalPageLead.update(a.id,{status:u}),h.success("×ס×××ס ×¢××××"),_()}catch{h.error("ש×××× ××¢××××")}
4}async function y(a){try{await k.entities.DigitalPageLead.delete(a.id);const u=m.find(C=>C.id===a.page_id);u&&u.lead_count>0&&await k.entities.DigitalPage.update(u.id,{lead_count:u.lead_count-1}),h.success("××¤× ××× × ×××§×"),_()}catch{h.error("ש×××× ×××××§×")}}function P(a){const u=`ש×: ${a.name} 5××פ××: ${a.phone||"â"} 6×××"×: ${a.email||"â"} 7××××¢×: ${a.message}`;navigator.clipboard.writeText(u),h.success("×פר××× ××עתק×")}return e.jsx(Oe,{open:!0,onOpenChange:a=>!a&&d(),children:e.jsxs(Ie,{className:"max-w-4xl max-h-[85vh] flex flex-col",dir:"rtl",children:[e.jsx(Ee,{children:e.jsx(Me,{children:"×¤× ××ת ש×תק××× â ×¢××××× ×××××××××"})}),e.jsx("div",{className:"flex items-center gap-2 mb-3",children:["all","new","read","handled"].map(a=>e.jsx("button",{onClick:()=>x(a),className:`px-3 py-1.5 rounded-full text-xs font-medium transition-all ${N===a?"bg-primary text-primary-foreground":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`,children:a==="all"?"×××":a==="new"?"××ש":a==="read"?"× ×§×¨×":"××פ×"},a))}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):o.length===0?e.jsxs("div",{className:"flex flex-col items-center py-12",children:[e.jsx($e,{className:"w-10 h-10 text-slate-300 mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"××× ×¤× ××ת ××צ××"})]}):e.jsx("div",{className:"space-y-2",children:o.map(a=>{const u=at(a.status);return e.jsxs("div",{className:"bg-white rounded-xl border border-border p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-bold",children:a.name}),e.jsx(we,{className:u.cls,children:u.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j[a.page_id]||"×¢××× ×× × ×צ×"})]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:a.created_date?new Date(a.created_date).toLocaleDateString("he-IL"):""})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs mb-2",children:[a.phone&&e.jsx("a",{href:`tel:${a.phone}`,className:"text-blue-600",dir:"ltr",style:{unicodeBidi:"plaintext"},children:a.phone}),a.email&&e.jsx("a",{href:`mailto:${a.email}`,className:"text-blue-600",dir:"ltr",style:{unicodeBidi:"plaintext"},children:a.email})]}),e.jsx("p",{className:"text-sm text-slate-600 bg-slate-50 rounded-lg p-2 mb-2",children:a.message}),e.jsxs("div",{className:"flex items-center gap-1",children:[a.status==="new"&&e.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>c(a,"read"),className:"gap-1.5 text-xs",children:[e.jsx(ze,{className:"w-3.5 h-3.5"})," ס×× ×× ×§×¨×"]}),a.status!=="handled"&&e.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>c(a,"handled"),className:"gap-1.5 text-xs",children:[e.jsx(jt,{className:"w-3.5 h-3.5"})," ס×× ×××פ×"]}),e.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>P(a),className:"gap-1.5 text-xs",children:[e.jsx(ve,{className:"w-3.5 h-3.5"})," ×עתק פר×××"]}),e.jsxs(R,{variant:"ghost",size:"sm",onClick:()=>y(a),className:"gap-1.5 text-xs text-red-600",children:[e.jsx(xe,{className:"w-3.5 h-3.5"})," ××××§×"]})]})]},a.id)})})}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx(R,{variant:"outline",onClick:d,children:"ס××ר×"})})]})})}function B({label:s,checked:m,onChange:d}){return e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-200/70 last:border-0",children:[e.jsx(_e,{className:"text-sm font-medium cursor-pointer",children:s}),e.jsx(Ne,{checked:m,onCheckedChange:d})]})}function kt({page:s,onClose:m,onSaved:d}){const{t:p}=he(),[i,b]=r.useState({}),[v,N]=r.useState(!1);r.useEffect(()=>{s&&b({...s})},[s]);function x(o,j){b(c=>({...c,[o]:j}))}async function _(){N(!0);
7try{await k.entities.DigitalPage.update(s.id,{title:i.title,description:i.description,status:i.status,is_private:i.is_private,show_on_website:i.show_on_website,show_on_app:i.show_on_app,show_on_homepage:i.show_on_homepage,allow_lead_form:i.allow_lead_form,show_view_counter:i.show_view_counter}),h.success("××××ר×ת × ×©×ר×"),d(),m()}catch{h.error("ש×××× ×ש××רת ×××ר×ת")}finally{N(!1)}}return e.jsxs(q,{onClose:m,title:`×××ר×ת ×¢××× - ${(s==null?void 0:s.title)||""}`,icon:X,tone:"blue",maxWidth:"max-w-lg",onSave:_,saving:v,saveLabel:"ש××ר×",saveIcon:ee,children:[e.jsx(Z,{title:"פר×× ××¢×××",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:E,children:"××תרת ××¢×××"}),e.jsx("input",{className:J,value:i.title||"",onChange:o=>x("title",o.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:E,children:"ת×××ר (SEO)"}),e.jsx("textarea",{className:je,value:i.description||"",onChange:o=>x("description",o.target.value),rows:2})]}),e.jsxs("div",{children:[e.jsx("label",{className:E,children:"ס×××ס"}),e.jsxs(fe,{value:i.status||"draft",onValueChange:o=>x("status",o),children:[e.jsx(ge,{className:J,children:e.jsx(pe,{})}),e.jsxs(be,{children:[e.jsx(Y,{value:"draft",children:"×××××"}),e.jsx(Y,{value:"published",children:"פע×× / ×פ×רס×"})]})]})]})]})}),e.jsxs(Z,{title:"× ×¨××ת ××רש××ת",children:[e.jsx(B,{label:"×¢××× ×¦××××¨× (פת×× ×××××)",checked:!i.is_private,onChange:o=>x("is_private",!o)}),e.jsx(B,{label:`××¦× ××תר ${p("community_noun_definite")}`,checked:i.show_on_website??!0,onChange:o=>x("show_on_website",o)}),e.jsx(B,{label:"××¦× ××פ××קצ××ת ×ת×ש×××",checked:i.show_on_app??!0,onChange:o=>x("show_on_app",o)}),e.jsx(B,{label:"××¦× ××¢××× ×××ת",checked:i.show_on_homepage??!1,onChange:o=>x("show_on_homepage",o)}),e.jsx(B,{label:"×פשר ××פס ×צ×רת קשר",checked:i.allow_lead_form??!1,onChange:o=>x("allow_lead_form",o)}),e.jsx(B,{label:"××¦× ××× × ×¦×¤××ת",checked:i.show_view_counter??!0,onChange:o=>x("show_view_counter",o)})]})]})}const Dt=["blue","emerald","amber","rose","purple","indigo","teal","slate"];function Pt(){const{id:s}=He(),m=Ae(),[d,p]=r.useState([]),[i,b]=r.useState([]),[v,N]=r.useState([]),[x,_]=r.useState(!0),[o,j]=r.useState(""),[c,y]=r.useState(null),[P,a]=r.useState(!1),[u,C]=r.useState(!1),[S,I]=r.useState(null),[L,T]=r.useState(!1),[w,M]=r.useState(!1),[G,$]=r.useState(!1),[z,H]=r.useState(!1),[t,n]=r.useState(null);r.useEffect(()=>{f()},[s]);async function f(){_(!0);try{const[l,D,U]=await Promise.all([k.entities.DigitalPage.filter({kibbutz_id:s},"-updated_date",500),k.entities.DigitalPageCategory.filter({kibbutz_id:s},"sort_order",100),k.entities.DigitalPageLead.filter({kibbutz_id:s},"-created_date",500)]);p(l),b(D),N(U)}catch{h.error("ש×××× ×××¢×× ×ª × ×ª×× ××")}finally{_(!1)}}const g=r.useMemo(()=>({total:d.length,active:d.filter(l=>l.status==="published").length,drafts:d.filter(l=>l.status==="draft").length,publicPages:d.filter(l=>!l.is_private).length,privatePages:d.filter(l=>l.is_private).length}),[d]),F=r.useMemo(()=>d.filter(l=>{var D,U,le,re,ie;if(c==="active"&&l.status!=="published"||c==="drafts"&&l.status!=="draft"||c==="public"&&l.is_private||c==="private"&&!l.is_private)return!1;if(o.trim()){const W=o.toLowerCase(),De=((D=i.find(Pe=>Pe.id===l.category_id))==null?void 0:D.title)||"";if(!((U=l.title)!=null&&U.toLowerCase().includes(W))&&!((le=l.description)!=null&&le.toLowerCase().includes(W))&&!((re=l.slug)!=null&&re.toLowerCase().includes(W))&&!((ie=l.content)!=null&&ie.toLowerCase().includes(W))&&!De.toLowerCase().includes(W))return!1}return!0}),[d,i,o,c]);function O(l){return Ve(s,`/kibbutz-site/${s}/digital-pages/${l.slug}`,window.location.origin)}function A(l){navigator.clipboard.writeText(O(l)),h.success("××§×ש×ר ××עתק")}function V(l){window.open(`/digital-page-view/${l.id}`,"_blank")}function K(l){const D=l.content_type==="html"||l.content_storage_type==="file"||l.html_file_url&&!l.html_content||l.html_content&&l.html_content.trim();m(`/kibbutz/${s}/digital-pages/${l.id}/${D?"visual":"edit"}`)}function te(l){n(l)}async function se(l){try{await k.entities.DigitalPage.delete(l.id),h.success("××¢××× × ×××§"),f()}catch{h.error("ש×××× ×××××§×")}}function ye(){a(!0)}function Ce(){lt(F,i),h.success("×××צ×× ××ש××")}const Se=l=>{var D;return((D=i.find(U=>U.id===l))==null?void 0:D.title)||"â"},ke=[{key:"active",label:"×¢××××× ×¤×¢××××",desc:"×¢××××× ×©×פ×רס××× ×פע××××",value:g.active,icon:ue,color:"text-emerald-600",bg:"bg-emerald-50"},{key:"drafts",label:"×¢××××× ×××××",desc:"×¢××××× ×©×¢×××× ×× ×¤×רס××",value:g.drafts,icon:vt,color:"text-amber-600",bg:"bg-amber-50"},{key:"public",label:"×¢××××× ×¦×××ר×××",desc:"×¢××××× ×¤×ª×××× ×צ×××ר",value:g.publicPages,icon:me,color:"text-blue-600",bg:"bg-blue-50"},{key:"private",label:"×¢××××× ×¤×¨××××",desc:"×¢××××× ×©××רש×× ×××©× / ×ת××ר×ת",value:g.privatePages,icon:Ue,color:"text-rose-600",bg:"bg-rose-50"},{key:null,label:'ס×"× ×¢×××××',desc:"×× ××¢××××× ××××××××××",value:g.total,icon:Be,color:"text-purple-600",bg:"bg-purple-50"}];return x?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):e.jsxs("div",{dir:"rtl",children:[e.jsx("div",{className:"flex mb-6",children:e.jsx(wt,{title:"×¢××××× ×××××××××",items:We(s,m,{onCreateHtml:ye,onOrder:()=>$(!0),onSettings:()=>M(!0),onExport:Ce})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 ga
7p-3 mb-6",children:ke.map(l=>{const D=c===l.key;return e.jsxs("button",{onClick:()=>y(D?null:l.key),className:`text-right bg-white rounded-2xl border shadow-sm p-4 transition-all hover:shadow-md ${D?"border-purple-300 ring-2 ring-purple-100":"border-border"}`,children:[e.jsx("div",{className:`w-9 h-9 rounded-lg ${l.bg} flex items-center justify-center mb-2`,children:e.jsx(l.icon,{className:`w-5 h-5 ${l.color}`})}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:l.value}),e.jsx("p",{className:"text-xs font-medium text-foreground mt-0.5",children:l.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.desc})]},l.label)})}),e.jsx("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-3 mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(Re,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx("input",{type:"text",value:o,onChange:l=>j(l.target.value),placeholder:"××פ×ש ×¢×××...",className:"w-full h-10 rounded-full border border-slate-200 bg-slate-50 pr-10 pl-4 text-sm focus:outline-none focus:ring-2 focus:ring-purple-100 focus:border-purple-300 focus:bg-white transition-all"})]})}),F.length===0?e.jsx("div",{className:"bg-white rounded-2xl border border-border shadow-sm",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-purple-50 flex items-center justify-center mb-4",children:e.jsx(Q,{className:"w-8 h-8 text-purple-300"})}),e.jsx("p",{className:"text-sm font-medium text-foreground mb-1",children:"××× ×¢××××× ××××××××× ××צ××"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"צ×ר ×¢××× ××ש ×× ××¢× ×§×××¥ HTML ××× ××ת×××"}),e.jsxs(R,{variant:"outline",className:"gap-2",onClick:()=>m(`/kibbutz/${s}/digital-pages/new`),children:[e.jsx(Ge,{className:"w-4 h-4"})," צ×ר ×¢××× ××ש"]})]})}):e.jsx("div",{className:"grid grid-cols-1 min-[600px]:grid-cols-2 min-[900px]:grid-cols-3 min-[1200px]:grid-cols-4 gap-4",children:F.map(l=>e.jsx(_t,{page:l,categoryName:Se(l.category_id),publicUrl:O(l),onView:V,onCopy:A,onEdit:K,onSettings:te,onDelete:se},l.id))}),P&&e.jsx(Nt,{kibbutzId:s,existingPages:d,categories:i,onClose:()=>a(!1),onSaved:()=>{f()}}),u&&e.jsx(qe,{kibbutzId:s,page:S,categories:i,onClose:()=>{C(!1),I(null)},onSaved:()=>{f()}}),L&&e.jsx(mt,{title:"× ×××× ×§×××ר××ת â ×¢××××× ×××××××××",entityName:"DigitalPageCategory",kibbutzId:s,categories:i,colorOptions:Dt,accentColor:"indigo",onUpdate:f,onClose:()=>T(!1)}),w&&e.jsx(yt,{kibbutzId:s,onClose:()=>M(!1)}),G&&e.jsx(Ct,{kibbutzId:s,pages:d,categories:i,onClose:()=>$(!1),onSaved:f}),z&&e.jsx(St,{kibbutzId:s,pages:d,onClose:()=>{H(!1),f()}}),t&&e.jsx(kt,{page:t,onClose:()=>n(null),onSaved:()=>f()})]})}function zs(){return e.jsx(Ke,{moduleKey:"digital_pages",children:e.jsx(Pt,{})})}
7export{zs 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.