PageSourceSearch

https://smartacc.ai/assets/AIIntegration-BBppYrng.js

js smartacc.ai collected 2026-10-05 13:53:24 UTC 27,361 bytes, 17 lines download raw bytes

1import{c as rs,l as Os,h as Ps,r as i,R as ze,j as e,b as qe,C,d as S,e as D,f as ee,a as _,B as c,n as He,t as a,s as se}from"./index-DxOFb5q5.js";import{utils as te,writeFile as Fs,read as Es}from"./xlsx-B6sNpj_1.js";import{A as Ls}from"./ApiExplorer-Cy1Qpt_z.js";import{u as Bs,M as $s}from"./MainLayout-DtU_Llqf.js";import{I as P}from"./input-CVbPUMku.js";import{L as d}from"./label-7GxXTAVW.js";import{T as Re}from"./textarea-Cmvr5DnJ.js";import{B as F}from"./badge-CVZMAyjp.js";import{C as Ve}from"./checkbox-B-q7ceh6.js";import{T as Ws,a as zs,b as E,c as L}from"./tabs-CzMufvm2.js";import{T as Je,a as Ke,b as ie,c as l,d as Ue,e as o}from"./table-ME1uwNKv.js";import{D as Ge,b as Qe,c as Xe,d as Ye,f as Ze,e as es}from"./dialog-DgwIDP3O.js";import{S as ue,a as je,b as ge,c as fe,d as v}from"./select-D5UGUo-D.js";import{A as ve,a as Ne,b as we,c as ye,d as be,e as ke,f as Ce,g as Se}from"./alert-dialog-j3DHAtp_.js";import{u as qs}from"./useCurrency-CHfOSI-0.js";import{S as Hs}from"./settings-HOD_H3QC.js";import{L as Rs}from"./list-qUlAru1O.js";import{K as ss}from"./key-D65IFvYq.js";import{S as ae}from"./sparkles-Dq7Hnh_d.js";import{S as Vs}from"./send-Cg1_2Arg.js";import{C as Js}from"./circle-check-big-Qz15irJg.js";import{C as Ks}from"./circle-alert-B2fp0-Vk.js";import{E as Us}from"./external-link-tmSrGh37.js";import{B as ts}from"./index-Cqq0Q2R_.js";import{C as is}from"./copy-dz7rAWaq.js";import{T as De}from"./trash-2-BoOxGfMY.js";import{U as Gs}from"./upload-C9UMjIMX.js";import{D as Qs}from"./download-11o5Rlif.js";import{P as _e}from"./plus-uyLhkU53.js";import{P as as}from"./pencil-wz2U88f-.js";import"./search-G0uOToOP.js";import"./chevron-down-CWi4njHw.js";import"./shield-CflKCyrC.js";import"./users-BVKd5H-E.js";import"./user-plus-CAB0aKvA.js";import"./user-minus-Dv2FDEEk.js";import"./refresh-cw-svEfoL48.js";import"./package-D2mOB_oX.js";import"./building-DSRidNLJ.js";import"./file-text-COWAn2T6.js";import"./receipt-BQ0dEskx.js";import"./store-CwRfK_Md.js";import"./wallet-DGGNcBKF.js";import"./chart-column-CLiCXUYS.js";import"./eye-Dlshx1uz.js";import"./message-square-DgTO1qZn.js";import"./mail-DsjaKHYV.js";import"./scroll-area-DnopRVtP.js";import"./index-BcIIhdSh.js";import"./index-BdQq_4o_.js";import"./command-BFn5ANfh.js";import"./index-Dcw69aED.js";import"./Combination-DCNPHtSM.js";import"./menu-QlHo9vH9.js";import"./chevron-right-D6QjocKi.js";import"./chevron-left-RCei6Rf9.js";import"./shield-check-1hkJMTyG.js";import"./database-bp7Ljsd-.js";import"./ruler-BrO1m_xd.js";import"./building-2-r7iwwscV.js";import"./landmark-C-TTWCoH.js";import"./file-spreadsheet-CNeCmKU4.js";import"./activity-CNN2ocS3.js";import"./trending-up-B0aavs3A.js";import"./history-nIzksNKw.js";import"./dropdown-menu-CjAirWC6.js";import"./check-DzIagfLA.js";import"./bell-CD0XGSIW.js";
1import"./separator-DEBCOVBC.js";import"./format-C8WnnBHU.js";import"./ar-CbFYuq6n.js";import"./useQuery-M3eWlJAa.js";import"./globe-DnaTgzo2.js";import"./shopping-cart-z_8fiYSq.js";import"./index-BdK6m1Wq.js";import"./zap-DG0OwecT.js";import"./AnnouncementCard-C0NUbBSm.js";import"./megaphone-D4JgWOFE.js";import"./index-CoAPzOtZ.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Xs=rs("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ys=rs("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]),ki=()=>{const{t:ns}=Bs(),{entries:cs,accounts:A,accountMappings:h,addAccountMapping:ls,updateAccountMapping:os,deleteAccountMapping:ds}=Os(),{tenant:re}=Ps(),N=re==null?void 0:re.id,hs=qs().symbol,[ne,ms]=i.useState(""),[Ae,Ie]=i.useState(!1),[Te,ce]=i.useState("idle"),B=i.useRef(null),[Me,Oe]=i.useState(!1),[m,I]=i.useState([]),[xs,le]=i.useState(!1),[ps,oe]=i.useState(!1),[w,$]=i.useState(!1),[W,us]=i.useState(""),[js,de]=i.useState(1),[z,gs]=i.useState(20),u=ze.useMemo(()=>{const s=W.trim().toLowerCase();return s?h.filter(t=>{var r,n,O;return((r=t.keyword)==null?void 0:r.toLowerCase().includes(s))||((n=t.account_code)==null?void 0:n.toLowerCase().includes(s))||((O=t.account_name)==null?void 0:O.toLowerCase().includes(s))||(t.description||"").toLowerCase().includes(s)}):h},[h,W]),T=z===-1?Math.max(u.length,1):z,q=Math.max(1,Math.ceil(u.length/T)),j=Math.min(js,q),H=u.slice((j-1)*T,j*T);ze.useEffect(()=>{de(1)},[W,z]);const[fs,M]=i.useState(!1),[vs,R]=i.useState(!1),[Ns,he]=i.useState(!1),[g,V]=i.useState(null),[y,J]=i.useState(""),[p,K]=i.useState(""),[U,G]=i.useState(""),Q=cs.filter(s=>s.source==="ai"),Pe=`${window.location.origin}/api/entries`,ws=async()=>{if(!ne){a({title:"خطأ",description:"يرجى إدخال رابط الـ Webhook",variant:"destructive"});return}Ie(!0),ce("idle");try{await fetch(ne,{method:"POST",headers:{"Content-Type":"application/json"},mode:"no-cors",body:JSON.stringify({test:!0,timestamp:new Date().toISOString(),source:"المحاسب الذكي"})}),ce("success"),a({title:"تم الإرسال",description:"تم إرسال طلب الاختبار بنجاح"})}catch{ce("error"),a({title:"خطأ",description:"فشل الاتصال بالـ Webhook",variant:"destructive"})}finally{Ie(!1)}},Fe=s=>{navigator.clipboard.writeText(s),a({title:"تم النسخ",description:"تم نسخ النص إلى الحافظة"})},Ee={description:"دفع فاتورة الكهرباء",date:"2024-01-15",lines:[{account_code:"523",debit:500,credit:0},{account_code:"1112",debit:0,credit:500}]},ys=()=>{const s=A.find(t=>t.code===p);if(!y.trim()||!p){a({title:"خطأ",description:"يرجى ملء جميع الحقول المطلوبة",variant:"destructive"});return}if(!s){a({title:"خطأ",description:"لم يتم العثور على الحساب المحدد",variant:"destructive"});return}ls({keyword:y.trim(),account_code:p,account_name:s.name,type:s.type,description:U.trim()||void 0,is_active:!0}),X(),M(!1)},bs=()=>{if(!g)return;const s=A.find(t=>t.code===p);if(!y.trim()||!p){a({title:"خطأ",description:"يرجى ملء جميع الحقول المطلوبة",variant:"destructive"});return}if(!s){a({title:"خطأ",description:"لم يتم العثور على الحساب المحدد",variant:"destructive"});return}os(g.id,{keyword:y.trim(),account_code:p,account_name:s.name,type:s.type,description:U.trim()||void 0}),X(),R(!1),V(null)},ks=()=>{g&&(ds(g.id),he(!1),V(null))},Cs=async()=>
11{if(!(m.length===0||!N)){$(!0);try{const{error:s}=await se.from("account_mappings").delete().in("id",m).eq("tenant_id",N);if(s)throw s;a({title:"تم الحذف",description:`تم حذف ${m.length} خريطة بنجاح`}),I([]),le(!1),window.location.reload()}catch(s){a({title:"خطأ في الحذف",description:s.message,variant:"destructive"})}finally{$(!1)}}},Ss=async()=>{if(N){$(!0);try{const{error:s}=await se.from("account_mappings").delete().eq("tenant_id",N);if(s)throw s;a({title:"تم الحذف",description:"تم حذف جميع خرائط الحسابات"}),I([]),oe(!1),window.location.reload()}catch(s){a({title:"خطأ في الحذف",description:s.message,variant:"destructive"})}finally{$(!1)}}},Ds=s=>{V(s),J(s.keyword),K(s.account_code),G(s.description||""),R(!0)},_s=s=>{V(s),he(!0)},X=()=>{J(""),K(""),G("")},As=s=>({asset:"أصول",liability:"خصوم",equity:"حقوق ملكية",revenue:"إيرادات",expense:"مصروفات"})[s],Is=()=>{if(h.length===0){a({title:"لا توجد بيانات",description:"لا توجد خرائط حسابات للتصدير",variant:"destructive"});return}const s=h.map(n=>({keyword:n.keyword,account_code:n.account_code,account_name:n.account_name,type:n.type,description:n.description||"",is_active:n.is_active})),t=te.json_to_sheet(s);t["!cols"]=[{wch:25},{wch:15},{wch:30},{wch:12},{wch:35},{wch:10}];const r=te.book_new();te.book_append_sheet(r,t,"AccountMappings"),Fs(r,`account-mappings-${new Date().toISOString().slice(0,10)}.xlsx`),a({title:"تم التصدير",description:`تم تصدير ${s.length} خريطة بنجاح`})},Ts=async s=>{var r;const t=(r=s.target.files)==null?void 0:r[0];if(t){if(!N){a({title:"خطأ",description:"لم يتم تحديد المنشأة",variant:"destructive"});return}Oe(!0);try{const n=await t.arrayBuffer(),O=Es(n,{type:"array"}),Ms=O.Sheets[O.SheetNames[0]],me=te.sheet_to_json(Ms,{defval:""});if(me.length===0){a({title:"ملف فارغ",description:"لا توجد بيانات في الملف",variant:"destructive"});return}let Le=0,Be=0,Y=0;const b=[];for(let k=0;k<me.length;k++){const f=me[k],xe=String(f.keyword||"").trim(),Z=String(f.account_code||"").trim();if(!xe||!Z){Y++;continue}const pe=A.find(x=>x.code===Z);if(!pe){b.push(`صف ${k+2}: الحساب ${Z} غير موجود`),Y++;continue}const $e={keyword:xe,account_code:Z,account_name:pe.name,type:pe.type,description:f.description?String(f.description).trim():null,is_active:!(f.is_active===!1||f.is_active==="false"||f.is_active===0),tenant_id:N},We=h.find(x=>x.keyword===xe);if(We){const{error:x}=await se.from("account_mappings").update($e).eq("id",We.id);x?b.push(`صف ${k+2}: ${x.message}`):Be++}else{const{error:x}=await se.from("account_mappings").insert($e);x?b.push(`صف ${k+2}: ${x.message}`):Le++}}a({title:"تم الاستيراد",description:`تمت إضافة ${Le} وتحديث ${Be}${Y?` وتخطي ${Y}`:""}`}),b.length&&(console.error("Import errors:",b),a({title:"بعض الصفوف بها أخطاء",description:b.slice(0,3).join(" | "),variant:"destructive"})),window.location.reload()}catch(n){a({title:"خطأ في الاستيراد",description:n.message,variant:"destructive"})}finally{Oe(!1),B.current&&(B.current.value="")}}};return e.jsxs($s,{title:ns("sidebar.aiIntegration"),children:[e.jsxs(Ws,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(zs,{className:"bg-muted/50 flex-wrap h-auto gap-1 p-1",children:[e.jsxs(E,{value:"settings",className:"gap-2",children:[e.jsx(Hs,{className:"w-4 h-4"}),"الإعدادات"]}),e.jsxs(E,{value:"api-list",className:"gap-2",children:[e.jsx(Rs,{className:"w-4 h-4"}),"قائمة APIs"]}),e.jsxs(E,{value:"api",className:"gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),"واجهة API"]}),e.jsxs(E,{value:"history",className:"gap-2",children:[e.jsx(qe,{className:"w-4 h-4"}),"سجل القيود"]}),e.jsxs(E,{value:"mappings",className:"gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"خرائط الحسابات"]})]}),e.jsx(L,{value:"api-list",children:e.jsxs(C,{children:[e.jsxs(S,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(Xs,{className:"w-5 h-5 text-primary"}),"واجهات برمجة التطبيقات (APIs)"]}),e.jsx(ee,{children:"استعرض جميع الـ APIs المتاحة للتكامل — ابحث بالاسم أو فلتر حسب النوع"})]}),e.jsx(_,{children:e.jsx(Ls,{})})]})}),e.jsx(L,{value:"settings",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(C,{children:[e.jsxs(S,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(Ys,{className:"w-5 h-5 text-primary"}),"تكامل N8N"]}),e.jsx(ee,{children:"قم بربط النظام مع N8N لإنشاء قيود تلقائية من خلال وكيل الذكاء الاصطناعي"})]}),e.jsxs(_,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"webhook-url",children:"رابط Webhook"}),e.jsx(P,{id:"webhook-url",value:ne,onChange:s=>ms(s.target.value),placeholder:"https://your-n8n.cloud/webhook/...",dir:"ltr"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(c,{variant:"outline",onClick:ws,disabled:Ae,children:[e.jsx(Vs,{className:"w-4 h-4 ml-2"}),Ae?"جاري الاختبار...":"اختبار الاتصال"]}),Te==="success"&&e.jsxs(F,{className:"bg-success/10 text-success border-success/30",children:[e.jsx(Js,{className:"w-3 h-3 ml-1"}),"متصل"]}),Te==="error"&&e.jsxs(F,{variant:"destructive",children:[e.jsx(Ks,{className:"w-3 h-3 ml-1"}),"فشل الاتصال"]})]}),e.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:[e.jsx("strong",{children:"ملاحظة:"})," قم بإنشاء Workflow في N8N يستقبل البيانات من وكيل AI ويرسلها إلى API النظام"]}),e.jsxs("a",{href:"https://n8n.io",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline flex items-center gap-1",children:["معرفة المزيد عن N8N",e.jsx(Us,{className:"w-3 h-3"})]})]})]})]}),e.jsxs(C,{children:[e.jsx(S,{children:e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(ts,{className:"w-5 h-5 text-accent"}),"حالة التكامل"]})}),e.jsxs(_,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg text-center",children:[e.jsx("p",{className:"text-3xl font-bold text-primary",children:Q.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"قيود من AI"})]}),e.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg text-center",children:[e.jsx("p",{className:"text-3xl font-bold text-success",children:Q.filter(s=>s.status==="approved").length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"معتمدة"})]})]}),e.jsxs("div",{className:"p-4 bg-accent/10 rounded-lg border border-accent/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ae,{className:"w-4 h-4 text-accent"}),e.jsx("span",{className:"font-medium",children:"كيف يعمل النظام؟"})]}),e.jsxs("ol",{className:"text-sm text-muted-foreground space-y-1 list-decimal list-inside",children:[e.jsx("li",{children:"وكيل AI يحلل المعاملة المالية"}),e.jsx("li",{children:"يحدد الحسابات المناسبة تلقائياً"}),e.jsx("li",{children:"ينشئ قيد محاسبي ويرسله للنظام"}),e.jsx("li",{children:"القيد ينتظر موافقة المدير"}),e.jsx("li",{children:"بعد الموافقة يتم ترحيله رسمياً"})]})]})]})]})]})}),e.jsx(L,{value:"api",children:e.jsxs(C,{children:[e.jsxs(S,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(ss,{className:"w-5 h-5 text-primary"}),"واجهة برمجة التطبيقات (API)"]}),e.jsx(ee,{children:"استخدم هذه الواجهة لإنشاء قيود محاسبية برمجياً من أي نظام خارجي"})]}),e.jsxs(_,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"نقطة النهاية (Endpoint)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{value:Pe,readOnly:!0,dir:"ltr"}),e.jsx(c,{variant:"outline",onClick:()=>Fe(Pe),children:e.jsx(is,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"مثال على الطلب (POST)"}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-sm",dir:"ltr",children:JSON.stringify(Ee,null,2)}),e.jsx(c,{variant:"ghost",size:"icon",className:"absolute top-2 left-2",onClick:()=>Fe(JSON.stringify(Ee,null,2)),children:e.jsx(is,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"الاستجابة المتوقعة"}),e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-sm",dir:"ltr",children:`{
12  "success": true,
13  "entry_id": "abc123",
14  "entry_number": "JE-2024-00003",
15  "status": "pending",
16  "message": "تم إنشاء القيد بنجاح وينتظر الموافقة"
17}`})]})]})]})}),e.jsx(L,{value:"history",children:e.jsxs(C,{children:[e.jsx(S,{children:e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"w-5 h-5 text-primary"}),"سجل قيود الذكاء الاصطناعي"]})}),e.jsxs(_,{children:[e.jsxs(Je,{children:[e.jsx(Ke,{children:e.jsxs(ie,{children:[e.jsx(l,{children:"رقم القيد"}),e.jsx(l,{children:"التاريخ"}),e.jsx(l,{children:"البيان"}),e.jsx(l,{children:"المبلغ"}),e.jsx(l,{children:"الحالة"})]})}),e.jsx(Ue,{children:Q.map(s=>e.jsxs(ie,{children:[e.jsx(o,{className:"font-mono text-primary",children:s.entry_number}),e.jsx(o,{children:new Date(s.date).toLocaleDateString("ar-SA")}),e.jsx(o,{children:s.description}),e.jsxs(o,{children:[new Intl.NumberFormat("ar-SA",{style:"decimal",minimumFractionDigits:2}).format(s.total_debit)," ",hs]}),e.jsx(o,{children:e.jsxs(F,{variant:"outline",className:He(s.status==="approved"&&"bg-success/10 text-success border-success/30",s.status==="pending"&&"bg-warning/10 text-warning-foreground border-warning/30",s.status==="rejected"&&"bg-destructive/10 text-destructive border-destructive/30"),children:[s.status==="approved"&&"معتمد",s.status==="pending"&&"قيد المراجعة",s.status==="rejected"&&"مرفوض"]})})]},s.id))})]}),Q.length===0&&e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ts,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"لا توجد قيود من الذكاء الاصطناعي حتى الآن"})]})]})]})}),e.jsx(L,{value:"mappings",children:e.jsxs(C,{children:[e.jsxs(S,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"w-5 h-5 text-secondary"}),"خرائط الحسابات الذكية"]}),e.jsx(ee,{children:"تساعد هذه الخرائط وكيل AI على التعرف على الحسابات المناسبة تلقائياً"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("input",{ref:B,type:"file",accept:".xlsx,.xls",className:"hidden",onChange:Ts}),m.length>0&&e.jsxs(c,{variant:"destructive",onClick:()=>le(!0),children:[e.jsx(De,{className:"w-4 h-4 ml-2"}),"حذف المحدد (",m.length,")"]}),h.length>0&&e.jsxs(c,{variant:"outline",onClick:()=>oe(!0),className:"text-destructive hover:text-destructive border-destructive/30",children:[e.jsx(De,{className:"w-4 h-4 ml-2"}),"حذف الكل"]}),e.jsxs(c,{variant:"outline",onClick:()=>{var s;return(s=B.current)==null?void 0:s.click()},disabled:Me,children:[e.jsx(Gs,{className:"w-4 h-4 ml-2"}),Me?"جاري الاستيراد...":"استيراد Excel"]}),e.jsxs(c,{variant:"outline",onClick:Is,children:[e.jsx(Qs,{className:"w-4 h-4 ml-2"}),"تصدير Excel"]}),e.jsxs(c,{onClick:()=>{X(),M(!0)},children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"إضافة خريطة"]})]})]}),e.jsxs(_,{children:[e.jsx("div",{className:"mb-4",children:e.jsx(P,{value:W,onChange:s=>us(s.target.value),placeholder:"بحث بالكلمة المفتاحية أو رقم الحساب أو اسم الحساب أو الوصف..."})}),e.jsxs(Je,{children:[e.jsx(Ke,{children:e.jsxs(ie,{children:[e.jsx(l,{className:"w-12",children:e.jsx(Ve,{checked:H.length>0&&H.every(s=>
17m.includes(s.id)),onCheckedChange:s=>{const t=H.map(r=>r.id);I(s?r=>Array.from(new Set([...r,...t])):r=>r.filter(n=>!t.includes(n)))}})}),e.jsx(l,{children:"الكلمة المفتاحية"}),e.jsx(l,{children:"رقم الحساب"}),e.jsx(l,{children:"اسم الحساب"}),e.jsx(l,{children:"النوع"}),e.jsx(l,{children:"الوصف"}),e.jsx(l,{className:"text-center",children:"الإجراءات"})]})}),e.jsx(Ue,{children:H.map(s=>e.jsxs(ie,{"data-state":m.includes(s.id)?"selected":void 0,children:[e.jsx(o,{children:e.jsx(Ve,{checked:m.includes(s.id),onCheckedChange:t=>{I(r=>t?[...r,s.id]:r.filter(n=>n!==s.id))}})}),e.jsx(o,{children:e.jsx(F,{variant:"secondary",children:s.keyword})}),e.jsx(o,{className:"font-mono",children:s.account_code}),e.jsx(o,{children:s.account_name}),e.jsx(o,{children:e.jsx(F,{variant:"outline",className:He(s.type==="asset"&&"bg-accent/10 text-accent",s.type==="expense"&&"bg-warning/10 text-warning-foreground",s.type==="revenue"&&"bg-success/10 text-success",s.type==="liability"&&"bg-destructive/10 text-destructive",s.type==="equity"&&"bg-primary/10 text-primary"),children:As(s.type)})}),e.jsx(o,{className:"text-muted-foreground text-sm",children:s.description||"-"}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>Ds(s),children:e.jsx(as,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>_s(s),className:"text-destructive hover:text-destructive",children:e.jsx(De,{className:"w-4 h-4"})})]})})]},s.id))})]}),u.length>0&&e.jsxs("div",{className:"flex items-center justify-between mt-4 flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["عرض ",(j-1)*T+1," - ",Math.min(j*T,u.length)," من ",u.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{className:"text-sm text-muted-foreground",children:"عدد السجلات:"}),e.jsxs(ue,{value:String(z),onValueChange:s=>gs(Number(s)),children:[e.jsx(je,{className:"h-9 w-24",children:e.jsx(ge,{})}),e.jsxs(fe,{children:[e.jsx(v,{value:"10",children:"10"}),e.jsx(v,{value:"20",children:"20"}),e.jsx(v,{value:"50",children:"50"}),e.jsx(v,{value:"100",children:"100"}),e.jsx(v,{value:"-1",children:"الكل"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{variant:"outline",size:"sm",onClick:()=>de(s=>Math.max(1,s-1)),disabled:j===1,children:"السابق"}),e.jsxs("span",{className:"text-sm",children:["صفحة ",j," من ",q]}),e.jsx(c,{variant:"outline",size:"sm",onClick:()=>de(s=>Math.min(q,s+1)),disabled:j===q,children:"التالي"})]})]}),h.length===0&&e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ae,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"لا توجد خرائط حسابات حتى الآن"}),e.jsxs(c,{variant:"outline",className:"mt-4",onClick:()=>{X(),M(!0)},children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"إضافة خريطة جديدة"]})]}),h.length>0&&u.length===0&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:e.jsx("p",{children:"لا توجد نتائج للبحث"})})]})]})})]}),e.jsx(Ge,{open:fs,onOpenChange:M,children:e.jsxs(Qe,{className:"max-w-md",children:[e.jsxs(Xe,{children:[e.jsx(Ye,{children:"إضافة خريطة حساب جديدة"}),e.jsx(Ze,{children:"أضف كلمة مفتاحية وربطها بحساب لتسهيل التعرف التلقائي"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"keyword",children:"الكلمة المفتاحية *"}),e.jsx(P,{id:"keyword",value:y,onChange:s=>J(s.target.value),placeholder:"مثال: كهرباء، إيجار، رواتب"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"account",children:"الحساب المرتبط *"}),e.jsxs(ue,{value:p,onValueChange:K,children:[e.jsx(je,{children:e.jsx(ge,{placeholder:"اختر الحساب"})}),e.jsx(fe,{className:"max-h-60",children:A.filter(s=>s.level>=2).map(s=>e.jsxs(v,{value:s.code,children:[s.code," - ",s.name]},s.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"description",children:"الوصف (اختياري)"}),e.jsx(Re,{id:"description",value:U,onChange:s=>G(s.target.value),placeholder:"وصف إضافي للمساعدة في التعرف",rows:2})]})]}),e.jsxs(es,{children:[e.jsx(c,{variant:"outline",onClick:()=>M(!1),children:"إلغاء"}),e.jsxs(c,{onClick:ys,children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"إضافة"]})]})]})}),e.jsx(Ge,{open:vs,onOpenChange:R,children:e.jsxs(Qe,{className:"max-w-md",children:[e.jsxs(Xe,{children:[e.jsx(Ye,{children:"تعديل خريطة الحساب"}),e.jsx(Ze,{children:"قم بتعديل الكلمة المفتاحية أو الحساب المرتبط"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"edit-keyword",children:"الكلمة المفتاحية *"}),e.jsx(P,{id:"edit-keyword",value:y,onChange:s=>J(s.target.value),placeholder:"مثال: كهرباء، إيجار، رواتب"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"edit-account",children:"الحساب المرتبط *"}),e.jsxs(ue,{value:p,onValueChange:K,children:[e.jsx(je,{children:e.jsx(ge,{placeholder:"اختر الحساب"})}),e.jsx(fe,{className:"max-h-60",children:A.filter(s=>s.level>=2).map(s=>e.jsxs(v,{value:s.code,children:[s.code," - ",s.name]},s.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"edit-description",children:"الوصف (اختياري)"}),e.jsx(Re,{id:"edit-description",value:U,onChange:s=>G(s.target.value),placeholder:"وصف إضافي للمساعدة في التعرف",rows:2})]})]}),e.jsxs(es,{children:[e.jsx(c,{variant:"outline",onClick:()=>R(!1),children:"إلغاء"}),e.jsxs(c,{onClick:bs,children:[e.jsx(as,{className:"w-4 h-4 ml-2"}),"حفظ التغييرات"]})]})]})}),e.jsx(ve,{open:Ns,onOpenChange:he,children:e.jsxs(Ne,{children:[e.jsxs(we,{children:[e.jsx(ye,{children:"هل أنت متأكد من الحذف؟"}),e.jsxs(be,{children:['سيتم حذف خريطة الحساب "',g==null?void 0:g.keyword,'" بشكل نهائي. هذا الإجراء لا يمكن التراجع عنه.']})]}),e.jsxs(ke,{children:[e.jsx(Ce,{children:"إلغاء"}),e.jsx(Se,{onClick:ks,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"حذف"})]})]})}),e.jsx(ve,{open:xs,onOpenChange:le,children:e.jsxs(Ne,{children:[e.jsxs(we,{children:[e.jsx(ye,{children:"حذف الخرائط المحددة؟"}),e.jsxs(be,{children:["سيتم حذف ",m.length," خريطة بشكل نهائي. هذا الإجراء لا يمكن التراجع عنه."]})]}),e.jsxs(ke,{children:[e.jsx(Ce,{disabled:w,children:"إلغاء"}),e.jsx(Se,{onClick:s=>{s.preventDefault(),Cs()},disabled:w,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:w?"جاري الحذف...":"حذف"})]})]})}),e.jsx(ve,{open:ps,onOpenChange:oe,children:e.jsxs(Ne,{children:[e.jsxs(we,{children:[e.jsx(ye,{children:"حذف جميع خرائط الحسابات؟"}),e.jsxs(be,{children:["سيتم حذف جميع الخرائط (",h.length,") بشكل نهائي. هذا الإجراء لا يمكن التراجع عنه."]})]}),e.jsxs(ke,{children:[e.jsx(Ce,{disabled:w,children:"إلغاء"}),e.jsx(Se,{onClick:s=>{s.preventDefault(),Ss()},disabled:w,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:w?"جاري الحذف...":"حذف الكل"})]})]})})]})};export{ki 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.