PageSourceSearch

https://koydengelsin.com/_next/static/chunks/pages/dashboard/Ambar-9765053c499159c3.js

js koydengelsin.com collected 2026-10-07 13:03:29 UTC 40,944 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3320],{17595:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/Ambar",function(){return a(57648)}])},57648:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>et});var n=a(6029),r=a(55729),s=a(27436),l=a(65572),i=a(19865),o=a(59079),c=a(36367),d=a(4191),u=a(52905),h=a(81954),m=a(13313),x=a(64130),p=a(1242),j=a(17691),A=a(11788),y=a(73014),b=a(61476),g=a(15107),w=a(75798),C=a(53744),f=a(78654);let{Column:N,HeaderCell:k,Cell:S}=g.A;function I({data:e,onEdit:t,onDelete:a,onRowClick:r}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{children:(0,n.jsx)("h4",{children:"Depolar"})}),(0,n.jsx)("div",{className:"table-scroll",children:(0,n.jsxs)(g.A,{data:e,bordered:!0,cellBordered:!0,height:280,rowHeight:56,className:"rounded-xl dotted-table",onRowClick:r,rowClassName:()=>"clickable-row",children:[(0,n.jsxs)(N,{flexGrow:2,children:[(0,n.jsx)(k,{children:"Ad"}),(0,n.jsx)(S,{dataKey:"name"})]}),(0,n.jsxs)(N,{flexGrow:1,children:[(0,n.jsx)(k,{children:"Kod"}),(0,n.jsx)(S,{dataKey:"code"})]}),(0,n.jsxs)(N,{flexGrow:1,children:[(0,n.jsx)(k,{children:"Aktif"}),(0,n.jsx)(S,{children:e=>e.isActive?"Evet":"Hayır"})]}),(0,n.jsxs)(N,{flexGrow:1,children:[(0,n.jsx)(k,{children:"İşlem"}),(0,n.jsx)(S,{children:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(w.A,{size:"sm",appearance:"subtle",icon:(0,n.jsx)(C.A,{}),onClick:a=>{a?.stopPropagation(),t(e)}}),(0,n.jsx)(w.A,{size:"sm",appearance:"subtle",icon:(0,n.jsx)(f.A,{}),onClick:t=>
1{t?.stopPropagation(),a(e)}})]})})]})]})})]})}var D=a(52375);let{Column:v,HeaderCell:T,Cell:q}=g.A;function G({rows:e,loading:t,numFmt:a,onRowClick:s}){let[l,i]=(0,r.useState)(""),o=(0,r.useMemo)(()=>{let t=l.trim().toLowerCase();return t?(e||[]).filter(e=>String(e.itemName||"").toLowerCase().includes(t)):e||[]},[e,l]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{children:(0,n.jsxs)(m.Ay,{justifyContent:"space-between",alignItems:"center",children:[(0,n.jsx)("h4",{children:"\xdcr\xfcnler"}),(0,n.jsx)(D.A,{placeholder:"\xdcr\xfcn ara",value:l,onChange:i,style:{width:240}})]})}),(0,n.jsx)("div",{className:"table-scroll",children:(0,n.jsxs)(g.A,{data:o,loading:t,bordered:!0,cellBordered:!0,height:360,rowHeight:56,className:"rounded-xl dotted-table",onRowClick:s,rowClassName:()=>"clickable-row",children:[(0,n.jsxs)(v,{flexGrow:2,children:[(0,n.jsx)(T,{children:"\xdcr\xfcn / Hammadde"}),(0,n.jsx)(q,{dataKey:"itemName"})]}),(0,n.jsxs)(v,{flexGrow:1,children:[(0,n.jsx)(T,{children:"Birim"}),(0,n.jsx)(q,{dataKey:"unit"})]}),(0,n.jsxs)(v,{flexGrow:1,children:[(0,n.jsx)(T,{children:"Toplam Miktar"}),(0,n.jsx)(q,{children:e=>a(e.quantity)})]})]})})]})}var L=a(93307),_=a(17342),R=a(78717),M=a(51811),H=a(6472),B=a(60215),K=a(24989),F=a(57728);if(A?.Chart&&"function"==typeof A.Chart.register){let{CategoryScale:e,LinearScale:t,PointElement:a,LineElement:n,BarElement:r,Tooltip:s,Legend:l,Filler:i}=A,o=[e,t,a,n,r,s,l,i].filter(Boolean);o.length&&A.Chart.register&&A.Chart.register(...o)}function z(e,t,a){let n=e=>{if(null==e)return"";let t=String(e);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t};return[a.map(n).join(","),...(e||[]).map(e=>t.map(t=>n(e?.[t])).join(","))].join("\n")}function $(e,t){let a=new Blob([t],{type:"text/csv;charset=utf-8"}),n=URL.createObjectURL(a),r=document.createElement("a");r.href=n,r.download=e,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}function P({open:e,onClose:t,editing:a,formValue:r,onChange:s,onSave:i,onDelete:o}){return(0,n.jsxs)(L.A,{open:e,onClose:t,size:"md",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsx)(L.A.Title,{children:a?"Depo D\xfczenle":"Yeni Depo"})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsxs)(_.A,{fluid:!0,formValue:r,onChange:s,layout:"vertical",children:[(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Ad"}),(0,n.jsx)(_.A.Control,{name:"name",accepter:D.A})]}),(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Kod"}),(0,n.jsx)(_.A.Control,{name:"code",accepter:D.A})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Aktif"}),(0,n.jsx)(_.A.Control,{name:"isActive",accepter:R.A})]})})]}),(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Adres"}),(0,n.jsx)(_.A.Control,{name:"address",accepter:D.A,componentClass:"textarea",rows:2})]}),(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Notlar"}),(0,n.jsx)(_.A.Control,{name:"notes",accepter:D.A,componentClass:"textarea",rows:2})]})]})}),(0,n.jsxs)(L.A.Footer,{children:[a&&(0,n.jsx)(l.A,{appearance:"subtle",color:"red",onClick:()=>o(a),children:"Sil"}),(0,n.jsx)(l.A,{appearance:"primary",onClick:i,children:"Kaydet"}),(0,n.jsx)(l.A,{appearance:"subtle",onClick:t,children:"Kapat"})]})]})}function E({open:e,onClose:t,editing:a,formValue:r,onChange:s,onSave:i,onDelete:o}){return(0,n.jsxs)(L.A,{open:e,onClose:t,size:"md",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsx)(L.A.Title,{children:a?"\xdcr\xfcn/Hammadde D\xfczenle":"Yeni \xdcr\xfcn/Hammadde"})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsxs)(_.A,{fluid:!0,formValue:r,onChange:s,layout:"vertical",children:[(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Ad"}),(0,n.jsx)(_.A.Control,{name:"name",accepter:D.A})]}),(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"SKU"}),(0,n.jsx)(_.A.Control,{name:"sku",accepter:D.A})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"T\xfcr"}),(0,n.jsx)(_.A.Control,{name:"type",accepter:M.A,data:[{label:"Hammadde",value:"raw"},{label:"\xdcr\xfcn",value:"product"}],cleanable:!1,style:{width:"100%"}})]})})]}),(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Birim"}),(0,n.jsx)(_.A.Control,{name:"unit",accepter:D.A})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Min. Stok"}),(0,n.jsx)(_.A.Control,{name:"minStock",accepter:H.A,min:0})]})})]}),(0,n.jsx)(h.A,{gutter:16,children:(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Aktif"}),(0,n.jsx)(_.A.Control,{name:"isActive",accepter:R.A})]})})}),(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Notlar"}),(0,n.jsx)(_.A.Control,{name:"notes",accepter:D.A,componentClass:"textarea",rows:2})]})]})}),(0,n.jsxs)(L.A.Footer,{children:[a&&(0,n.jsx)(l.A,{appearance:"subtle",color:"red",onClick:()=>o(a),children:"Sil"}),(0,n.jsx)(l.A,{appearance:"primary",onClick:i,children:"Kaydet"}),(0,n.jsx)(l.A,{appearance:"subtle",onClick:t,children:"Kapat"})]})]})}function V({open:e,onClose:t,formValue:a,onChange:r,onSave:s,whOptions:i,itemOptions:o,supplierOptions:c}){return(0,n.jsxs)(L.A,{open:e,onClose:t,size:"md",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsx)(L.A.Title,{children:a?.type==="in"?"Giriş Hareketi":"\xc7ıkış Hareketi"})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsxs)(_.A,{fluid:!0,formValue:a,onChange:r,layout:"vertical",children:[(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Depo"}),(0,n.jsx)(_.A.Control,{name:"warehouse",accepter:M.A,data:i,cleanable:!1,style:{width:"100%"}})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"\xdcr\xfcn/Hammadde"}),(0,n.jsx)(_.A.Control,{name:"item",accepter:M.A,data:o,cleanable:!1,style:{width:"100%"}})]})})]}),(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"T\xfcr"}),(0,n.jsx)(_.A.Control,{name:"type",accepter:M.A,data:[{label:"Giriş",value:"in"},{label:"\xc7ıkış",value:"out"}],cleanable:!1,style:{width:"100%"}})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Miktar"}),(0,n.jsx)(_.A.Control,{name:"quantity",accepter:H.A,min:0})]})})]}),(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Birim Fiyat (TL)"}),(0,n.jsx)(_.A.Control,{name:"unitPrice",accepter:H.A,min:0})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Tarih"}),(0,n.jsx)(_.A.Control,{name:"date",accepter:B.A,oneTap:!0})]})})]}),(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Belge / İrsaliye No (ops.)"}),(0,n.jsx)(_.A.Control,{name:"docNo",accepter:D.A})]}),(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Tedarik\xe7i (ops.)"}),(0,n.jsx)(_.A.Control,{name:"supplier",accepter:M.A,data:c,placeholder:"Tedarik\xe7i se\xe7iniz",style:{width:"100%"},block:!0,cleanable:!0})]}),(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Not"}),(0,n.jsx)(_.A.Control,{name:"notes",accepter:D.A,componentClass:"textarea",rows:2})]})]})}),(0,n.jsxs)(L.A.Footer,{children:[(0,n.jsx)(l.A,{appearance:"primary",onClick:s,children:"Kaydet"}),(0,n.jsx)(l.A,{appearance:"subtle",onClick:t,children:"Kapat"})]})]})}function O({open:e,onClose:t,formValue:a,onChange:r,onSave:s,whOptions:i,itemOptions:o}){let c=(Number(a?.quantity)||0)*(Number(a?.unitCost)||0);return(0,n.jsxs)(L.A,{open:e,onClose:t,size:"md",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsx)(L.A.Title,{children:"Aylık Sayım"})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsxs)(_.A,{fluid:!0,formValue:a,onChange:r,layout:"vertical",children:[(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Depo"}),(0,n.jsx)(_.A.Control,{name:"warehouse",accepter:M.A,data:i,cleanable:!1,style:{width:"100%"}})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"\xdcr\xfcn/Hammadde"}),(0,n.jsx)(_.A.Control,{name:"item",accepter:M.A,data:o,cleanable:!1,style:{width:"100%"}})]})})]}),(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"D\xf6nem"}),(0,n.jsx)(_.A.Control,{name:"periodKey",accepter:D.A,placeholder:"YYYY-MM"})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Sayım Tarihi"}),(0,n.jsx)(_.A.Control,{name:"date",accepter:B.A,oneTap:!0})]})})]}),(0,n.jsxs)(h.A,{gutter:16,children:[(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Miktar"}),(0,n.jsx)(_.A.Control,{name:"quantity",accepter:H.A,min:0})]})}),(0,n.jsx)(h.A.Item,{colspan:12,children:(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Birim Alış (TL)"}),(0,n.jsx)(_.A.Control,{name:"unitCost",accepter:H.A,min:0})]})})]}),(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Toplam Değer"}
1),(0,n.jsx)(D.A,{value:isFinite(c)?c.toLocaleString("tr-TR",{maximumFractionDigits:2}):"",readOnly:!0})]}),(0,n.jsxs)(_.A.Group,{children:[(0,n.jsx)(_.A.ControlLabel,{children:"Not"}),(0,n.jsx)(_.A.Control,{name:"notes",accepter:D.A,componentClass:"textarea",rows:2})]})]})}),(0,n.jsxs)(L.A.Footer,{children:[(0,n.jsx)(l.A,{appearance:"primary",onClick:s,children:"Kaydet"}),(0,n.jsx)(l.A,{appearance:"subtle",onClick:t,children:"Kapat"})]})]})}let{Column:Y,HeaderCell:W,Cell:U}=g.A;function Z({open:e,onClose:t,warehouse:a,rows:s,loading:i,onItemClick:o,onEditItem:c,onDeleteItem:d,numFmt:u}){let h=a?`${a.name||"Depo"} — \xdcr\xfcnler`:"Depo — \xdcr\xfcnler",x=(s||[]).map(e=>({itemName:e.itemName,unit:e.unit,quantity:e.quantity})),p=(0,r.useMemo)(()=>({labels:(s||[]).map(e=>e.itemName||"—"),datasets:[{label:"Miktar",data:(s||[]).map(e=>Number(e.quantity)||0),borderColor:"#06402c",backgroundColor:"rgba(6, 64, 44, 0.55)",fill:!0,pointRadius:2,pointHoverRadius:4}]}),[s]);return(0,n.jsxs)(L.A,{open:e,onClose:t,size:"lg",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsxs)(m.Ay,{justifyContent:"space-between",alignItems:"center",children:[(0,n.jsx)(L.A.Title,{children:h}),(0,n.jsx)(w.A,{size:"sm",appearance:"subtle",icon:(0,n.jsx)(F.A,{}),disabled:!x.length,onClick:()=>{let e=z(x,["itemName","unit","quantity"],["\xdcr\xfcn / Hammadde","Birim","Miktar"]);$(`depo-urunler-${a?.name||"depo"}.csv`,e)},children:"CSV"})]})}),(0,n.jsxs)(L.A.Body,{children:[(0,n.jsx)("div",{className:"mb-3",style:{height:240},children:(0,n.jsx)(j.Bar,{data:p,options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:"#e6efe9"}}},scales:{x:{ticks:{autoSkip:!0,maxRotation:0,minRotation:0,color:"#cfe7d9"},grid:{color:"#1f3a2d"}},y:{beginAtZero:!0,ticks:{color:"#cfe7d9"},grid:{color:"#1f3a2d"}}}}})}),(0,n.jsx)("div",{className:"table-scroll",children:(0,n.jsxs)(g.A,{data:s||[],loading:i,bordered:!0,cellBordered:!0,height:360,rowHeight:56,className:"rounded-xl dotted-table rounded-table",onRowClick:o,rowClassName:()=>"clickable-row",children:[(0,n.jsxs)(Y,{flexGrow:3,children:[(0,n.jsx)(W,{children:"\xdcr\xfcn / Hammadde"}),(0,n.jsx)(U,{dataKey:"itemName"})]}),(0,n.jsxs)(Y,{flexGrow:1,children:[(0,n.jsx)(W,{children:"Birim"}),(0,n.jsx)(U,{dataKey:"unit"})]}),(0,n.jsxs)(Y,{flexGrow:1,minWidth:140,children:[(0,n.jsx)(W,{children:"Miktar"}),(0,n.jsx)(U,{children:e=>u(e.quantity)})]}),(c||d)&&(0,n.jsxs)(Y,{flexGrow:1,children:[(0,n.jsx)(W,{children:"İşlem"}),(0,n.jsx)(U,{children:e=>(0,n.jsxs)(n.Fragment,{children:[c&&(0,n.jsx)(w.A,{size:"sm",appearance:"subtle",icon:(0,n.jsx)(C.A,{}),onClick:t=>
1{t?.stopPropagation(),c(e)}}),d&&(0,n.jsx)(w.A,{size:"sm",appearance:"subtle",icon:(0,n.jsx)(f.A,{}),onClick:t=>{t?.stopPropagation(),d(e)}})]})})]})]})})]}),(0,n.jsx)(L.A.Footer,{children:(0,n.jsx)(l.A,{appearance:"subtle",onClick:t,children:"Kapat"})})]})}function X({open:e,onClose:t,warehouse:a,item:s,rows:i,loading:o,numFmt:c}){let d=`${a?.name||"Depo"} — ${s?.itemName||s?.name||"\xdcr\xfcn"}`,u=e=>"in"===e?(0,n.jsx)(K.A,{color:"green",children:"Giriş"}):"out"===e?(0,n.jsx)(K.A,{color:"red",children:"\xc7ıkış"}):(0,n.jsx)(K.A,{color:"orange",children:"Sayım"}),[x,p]=(0,r.useState)(null),[j,A]=(0,r.useState)(null),y=(i||[]).map(e=>({date:new Date(e.date).toISOString().slice(0,10),type:"in"===e.type?"Giriş":"out"===e.type?"\xc7ıkış":"Sayım",warehouse:e.warehouse,unitPrice:e.unitPrice,quantity:e.quantity,docNo:e.docNo,notes:e.notes}));return(0,n.jsxs)(L.A,{open:e,onClose:t,size:"lg",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsxs)(m.Ay,{justifyContent:"space-between",alignItems:"center",children:[(0,n.jsxs)(L.A.Title,{children:[d," — Hareketler"]}),(0,n.jsx)(w.A,{size:"sm",appearance:"subtle",icon:(0,n.jsx)(F.A,{}),disabled:!y.length,onClick:()=>{let e=z(y,["date","type","warehouse","unitPrice","quantity","docNo","notes"],["Tarih","T\xfcr","Depo","Birim Fiyat","Miktar","Belge / D\xf6nem","Not"]);$(`depo-hareketler-${a?.name||"depo"}.csv`,e)},children:"CSV"})]})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsx)("div",{className:"table-scroll",children:(0,n.jsxs)(g.A,{data:i||[],loading:o,bordered:!0,cellBordered:!0,height:420,rowHeight:64,className:"rounded-xl dotted-table rounded-table",onRowClick:e=>{e?.type==="count"?p(e):A(e)},rowClassName:()=>"clickable-row",children:[(0,n.jsxs)(Y,{flexGrow:1,minWidth:140,children:[(0,n.jsx)(W,{children:"Tarih"}),(0,n.jsx)(U,{children:e=>new Date(e.date).toLocaleDateString("tr-TR")})]}),(0,n.jsxs)(Y,{flexGrow:1,children:[(0,n.jsx)(W,{children:"T\xfcr"}),(0,n.jsx)(U,{children:e=>u(e.type)})]}),(0,n.jsxs)(Y,{flexGrow:1,minWidth:160,children:[(0,n.jsx)(W,{children:"Depo"}),(0,n.jsx)(U,{dataKey:"warehouse"})]}),(0,n.jsxs)(Y,{flexGrow:1,children:[(0,n.jsx)(W,{children:"Birim Fiyat"}),(0,n.jsx)(U,{children:e=>c(e.unitPrice)})]}),(0,n.jsxs)(Y,{flexGrow:1,minWidth:120,children:[(0,n.jsx)(W,{children:"Miktar"}),(0,n.jsx)(U,{children:e=>c(e.quantity)})]}),(0,n.jsxs)(Y,{flexGrow:2,children:[(0,n.jsx)(W,{children:"Belge / D\xf6nem"}),(0,n.jsx)(U,{dataKey:"docNo"})]}),(0,n.jsxs)(Y,{flexGrow:3,children:[(0,n.jsx)(W,{children:"Not"}),(0,n.jsx)(U,{dataKey:"notes"})]})]})})}),(0,n.jsx)(L.A.Footer,{children:(0,n.jsx)(l.A,{appearance:"subtle",onClick:t,children:"Kapat"})}),(0,n.jsxs)(L.A,{open:!!x,onClose:()=>p(null),size:"sm",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsx)(L.A.Title,{children:"Sayım Detayı"})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsxs)(h.A,{gutter:12,children:[(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Tarih:"})," ",x?.date?new Date(x.date).toLocaleDateString("tr-TR"):"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Depo:"})," ",x?.warehouse||"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Belge / D\xf6nem:"})," ",x?.docNo||"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Miktar:"})," ",c(x?.quantity)]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Birim Alış:"})," ",c(x?.unitCost??x?.unitPrice)]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Toplam Değer:"})," ",c(x?.totalValue)]}),(0,n.jsxs)(h.A.Item,{colspan:24,children:[(0,n.jsx)("strong",{children:"Not:"}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",marginTop:6},children:x?.notes||"—"})]})]})}),(0,n.jsx)(L.A.Footer,{children:(0,n.jsx)(l.A,{appearance:"subtle",onClick:()=>p(null),children:"Kapat"})})]}),(0,n.jsxs)(L.A,{open:!!j,onClose:()=>A(null),size:"sm",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsx)(L.A.Title,{children:"Hareket Detayı"})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsxs)(h.A,{gutter:12,children:[(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Tarih:"})," ",j?.date?new Date(j.date).toLocaleDateString("tr-TR"):"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"T\xfcr:"})," ",j?.type==="in"?"Giriş":j?.type==="out"?"\xc7ıkış":"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Depo:"})," ",j?.warehouse||"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Miktar:"})," ",c(j?.quantity)]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Birim Fiyat:"})," ",c(j?.unitPrice)]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Belge / D\xf6nem:"})," ",j?.docNo||"—"]}
1),(0,n.jsxs)(h.A.Item,{colspan:24,children:[(0,n.jsx)("strong",{children:"Not:"}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",marginTop:6},children:j?.notes||"—"})]})]})}),(0,n.jsx)(L.A.Footer,{children:(0,n.jsx)(l.A,{appearance:"subtle",onClick:()=>A(null),children:"Kapat"})})]})]})}function J({open:e,onClose:t,item:a,rows:s,loading:i}){let o=a?.itemName||a?.name||"\xdcr\xfcn",c=e=>(Number(e)||0).toLocaleString("tr-TR",{maximumFractionDigits:3}),d=e=>"in"===e?(0,n.jsx)(K.A,{color:"green",children:"Giriş"}):"out"===e?(0,n.jsx)(K.A,{color:"red",children:"\xc7ıkış"}):(0,n.jsx)(K.A,{color:"orange",children:"Sayım"}),u=(0,r.useMemo)(()=>({labels:(s||[]).map(e=>new Date(e.date).toLocaleDateString("tr-TR")),datasets:[{label:"Stok",data:(s||[]).map(e=>Number(e.balance)||0),borderColor:"#0a5a41",backgroundColor:"rgba(10, 90, 65, 0.35)",fill:!0,pointRadius:3,pointHoverRadius:5}]}),[s]),[x,p]=(0,r.useState)(null),[A,y]=(0,r.useState)(null),b=(s||[]).map(e=>({date:new Date(e.date).toISOString().slice(0,10),type:"in"===e.type?"Giriş":"out"===e.type?"\xc7ıkış":"Sayım",warehouse:e.warehouse,quantity:e.quantity,docNo:e.docNo,notes:e.notes}));return(0,n.jsxs)(L.A,{open:e,onClose:t,size:"lg",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsxs)(m.Ay,{justifyContent:"space-between",alignItems:"center",children:[(0,n.jsxs)(L.A.Title,{children:[o," — T\xfcm Depolar Hareketler"]}),(0,n.jsx)(w.A,{size:"sm",appearance:"subtle",icon:(0,n.jsx)(F.A,{}),disabled:!b.length,onClick:()=>{let e=z(b,["date","type","warehouse","quantity","docNo","notes"],["Tarih","T\xfcr","Depo","Miktar","Belge / D\xf6nem","Not"]);$(`urun-hareketler-${a?.itemName||"urun"}.csv`,e)},children:"CSV"})]})}),(0,n.jsxs)(L.A.Body,{children:[(0,n.jsx)("div",{className:"mb-3",style:{height:240},children:(0,n.jsx)(j.Line,{data:u,options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:"#e6efe9"}}},scales:{x:{ticks:{autoSkip:!0,maxRotation:0,minRotation:0,color:"#cfe7d9"},grid:{color:"#1f3a2d"}},y:{beginAtZero:!0,ticks:{color:"#cfe7d9"},grid:{color:"#1f3a2d"}}}}})}),(0,n.jsx)("div",{className:"table-scroll",children:(0,n.jsxs)(g.A,{data:s||[],loading:i,bordered:!0,cellBordered:!0,height:360,rowHeight:64,className:"rounded-xl dotted-table rounded-table",onRowClick:e=>{e?.type==="count"?p(e):y(e)},rowClassName:()=>"clickable-row",children:[(0,n.jsxs)(Y,{flexGrow:2,children:[(0,n.jsx)(W,{children:"Tarih"}),(0,n.jsx)(U,{children:e=>new Date(e.date).toLocaleDateString("tr-TR")})]}),(0,n.jsxs)(Y,{flexGrow:1,children:[(0,n.jsx)(W,{children:"T\xfcr"}),(0,n.jsx)(U,{children:e=>d(e.type)})]}),(0,n.jsxs)(Y,{flexGrow:2,children:[(0,n.jsx)(W,{children:"Depo"}),(0,n.jsx)(U,{dataKey:"warehouse"})]}),(0,n.jsxs)(Y,{flexGrow:1,children:[(0,n.jsx)(W,{children:"Miktar"}),(0,n.jsx)(U,{dataKey:"quantity"})]})]})})]}),(0,n.jsx)(L.A.Footer,{children:(0,n.jsx)(l.A,{appearance:"subtle",onClick:t,children:"Kapat"})}),(0,n.jsxs)(L.A,{open:!!x,onClose:()=>p(null),size:"sm",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsx)(L.A.Title,{children:"Sayım Detayı"})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsxs)(h.A,{gutter:12,children:[(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Tarih:"})," ",x?.date?new Date(x.date).toLocaleDateString("tr-TR"):"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Depo:"})," ",x?.warehouse||"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Belge / D\xf6nem:"})," ",x?.docNo||"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Miktar:"})," ",c(x?.quantity)]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Birim Alış:"})," ",x?.unitCost!=null?c(x?.unitCost):"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Toplam Değer:"})," ",x?.totalValue!=null?c(x?.totalValue):"—"]}),(0,n.jsxs)(h.A.Item,{colspan:24,children:[(0,n.jsx)("strong",{children:"Not:"}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",marginTop:6},children:x?.notes||"—"})]})]})}),(0,n.jsx)(L.A.Footer,{children:(0,n.jsx)(l.A,{appearance:"subtle",onClick:()=>p(null),children:"Kapat"})})]}),(0,n.jsxs)(L.A,{open:!!A,onClose:()=>y(null),size:"sm",children:[(0,n.jsx)(L.A.Header,{children:(0,n.jsx)(L.A.Title,{children:"Hareket Detayı"})}),(0,n.jsx)(L.A.Body,{children:(0,n.jsxs)(h.A,{gutter:12,children:[(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Tarih:"})," ",A?.date?new Date(A.date).toLocaleDateString("tr-TR"):"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"T\xfcr:"})," ",A?.type==="in"?"Giriş":A?.type==="out"?"\xc7ıkış":"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Depo:"})," ",A?.warehouse||"—"]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Miktar:"})," ",c(A?.quantity)]}),(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("strong",{children:"Belge / D\xf6nem:"})," ",A?.docNo||"—"]}
1),(0,n.jsxs)(h.A.Item,{colspan:24,children:[(0,n.jsx)("strong",{children:"Not:"}),(0,n.jsx)("div",{style:{whiteSpace:"pre-wrap",marginTop:6},children:A?.notes||"—"})]})]})}),(0,n.jsx)(L.A.Footer,{children:(0,n.jsx)(l.A,{appearance:"subtle",onClick:()=>y(null),children:"Kapat"})})]})]})}let Q=e=>"number"==typeof e?e.toLocaleString("tr-TR",{maximumFractionDigits:3}):"";function ee({data:e,value:t,onChange:a,block:r,className:i}){return(0,n.jsx)(s.A,{className:i,block:r,children:(e||[]).map(e=>(0,n.jsx)(l.A,{appearance:"subtle",className:t===e.value?"segment-btn is-active":"segment-btn",onClick:()=>a&&a(e.value),children:e.label},e.value))})}if(A?.Chart&&"function"==typeof A.Chart.register){let{CategoryScale:e,LinearScale:t,BarElement:a,LineElement:n,PointElement:r,Tooltip:s,Legend:l}=A,i=[e,t,a,n,r,s,l].filter(Boolean);i.length&&A.Chart.register&&A.Chart.register(...i)}function et(){let[e,t]=(0,r.useState)(!1),[a,s]=(0,r.useState)([]),[A,g]=(0,r.useState)(!1),[w,C]=(0,r.useState)(null),[f,N]=(0,r.useState)({name:"",code:"",address:"",isActive:!0,notes:""}),[k,S]=(0,r.useState)([]),[D,v]=(0,r.useState)(!1),[T,q]=(0,r.useState)(null),[L,_]=(0,r.useState)({name:"",sku:"",type:"raw",unit:"adet",minStock:0,isActive:!0,notes:""}),[R,M]=(0,r.useState)(!1),[H,B]=(0,r.useState)(null),[K,F]=(0,r.useState)({warehouse:null,item:null,supplier:null,type:"in",quantity:0,unitPrice:0,date:new Date,docNo:"",notes:""}),[z,$]=(0,r.useState)(!1),[Y,W]=(0,r.useState)(!1),[U,et]=(0,r.useState)(null),[ea,en]=(0,r.useState)([]),[er,es]=(0,r.useState)(!1),[el,ei]=(0,r.useState)(!1),[eo,ec]=(0,r.useState)(null),[ed,eu]=(0,r.useState)([]),[eh,em]=(0,r.useState)(!1),[ex,ep]=(0,r.useState)([]),[ej,eA]=(0,r.useState)(!1),[ey,eb]=(0,r.useState)(!1),[eg,ew]=(0,r.useState)(null),[eC,ef]=(0,r.useState)([]),[eN,ek]=(0,r.useState)("warehouses"),[eS,eI]=(0,r.useState)(!1),[eD,ev]=(0,r.useState)({warehouse:null,item:null,periodKey:"",date:new Date,quantity:0,unitCost:0,notes:""}),[eT,eq]=(0,r.useState)([]),[eG,eL]=(0,r.useState)([]);async function e_(){t(!0);try{let[e,t,a]=await Promise.all([(0,y.LH0)(),(0,y.Dwy)(),(0,y.qv9)()]);s(e||[]),S(t||[]),eL((a||[]).map(e=>({label:e.name,value:e._id}))),await eM(),await eR()}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e.message}))}finally{t(!1)}}async function eR(){eq(await (0,y.$bt)({})||[])}async function eM(){em(!0);try{let e=await (0,y.TwK)({}),t=Array.isArray(e)?e:Array.isArray(e?.rows)?e.rows:[];ep(t)}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e?.message||"Stok listesi alınamadı"})),ep([])}finally{em(!1)}}async function eH(){try{w?._id?await (0,y.$O3)(w._id,f):await (0,y.aot)(f),g(!1),C(null),s(await (0,y.LH0)()),await eM(),i.A.push((0,n.jsx)(o.A,{type:"success",closable:!0,children:"Kayıt başarılı"}))}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e.message}))}}async function eB(e){if(window.confirm("Depo silinsin mi?"))try{await (0,y.k$m)(e._id),s(await (0,y.LH0)()),i.A.push((0,n.jsx)(o.A,{type:"success",closable:!0,children:"Silindi"}))}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e.message}))}}async function eK(){try{T?._id?await (0,y.fkv)(T._id,L):await (0,y.wEy)(L),v(!1),S(await (0,y.Dwy)({})),await eM(),z&&U?._id&&await e0(U),i.A.push((0,n.jsx)(o.A,{type:"success",closable:!0,children:"Kayıt başarılı"}))}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e.message}))}}async function eF(e){if(window.confirm("\xdcr\xfcn silinsin mi?"))try{await (0,y.Aiq)(e._id),S(await (0,y.Dwy)({})),await eM(),z&&U?._id&&await e0(U),i.A.push((0,n.jsx)(o.A,{type:"success",closable:!0,children:"Silindi"}))}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e.message}))}}function ez(e="in"){B(null),F({warehouse:null,item:null,supplier:null,type:e,quantity:0,unitPrice:0,date:new Date,docNo:"",notes:""}),M(!0)}async function e$(){try{let e={...K,date:K.date||new Date};H?await (0,y.au$)(H,e):await (0,y.NSE)(e),M(!1),B(null),await eM(),er&&eo?.itemId&&U?._id&&await e1(eo),ej&&eg?.itemId&&await e2(eg),i.A.push((0,n.jsx)(o.A,{type:"success",closable:!0,children:"Hareket kaydedildi"}))}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e.message}))}}async function eP(){try{await (0,y.$sf)({...eD,date:eD.date||new Date}),eI(!1),await eR(),await eM(),er&&eo?.itemId&&U?._id&&await e1(eo),ej&&eg?.itemId&&await e2(eg),i.A.push((0,n.jsx)(o.A,{type:"success",closable:!0,children:"Sayım kaydedildi"}))}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e.message}))}}(0,r.useEffect)(()=>{(0,b.Sp)(),e_()},[]);let eE=(a||[]).map(e=>({label:e.name,value:e._id})),eV=(k||[]).map(e=>({label:`${e.name} (${e.unit})`,value:e._id})),eO=(0,r.useMemo)(()=>{let e=new Map((k||[]).map(e=>[String(e._id),{name:e.name||"—",unit:e.unit||""}])),t=new Map,a=new Map;
1(eT||[]).forEach(e=>{let n=String(e?.item?._id||e?.item||""),r=String(e?.warehouse?._id||e?.warehouse||"");if(!n||!r)return;t.has(n)||t.set(n,{name:e?.item?.name||"—",unit:e?.item?.unit||""});let s=`${r}|${n}`,l=new Date(e.date),i=a.get(s);(!i||l>i.date)&&a.set(s,{date:l,quantity:Number(e.quantity)||0})});let n=new Map((ex||[]).map(e=>[`${e.warehouseId}|${e.itemId}`,e])),r=new Set([...n.keys(),...a.keys()]),s=new Map;return r.forEach(r=>{let[l,i]=String(r).split("|"),o=n.get(r),c=a.get(r),d=o?Number(o.quantity)||0:Number(c?.quantity)||0,u=e.get(i)||t.get(i)||{name:"—",unit:""},h=s.get(i)||{itemId:i,itemName:u.name,unit:u.unit,quantity:0};h.quantity+=d,s.set(i,h)}),[...s.values()].sort((e,t)=>String(e.itemName).localeCompare(String(t.itemName)))},[k,eT,ex]),eY=(0,r.useMemo)(()=>{let e=new Map;return(eT||[]).forEach(t=>{let a=new Date(t.date);if(isNaN(a))return;let n=a.toISOString().slice(0,10),r=(Number(t.quantity)||0)*(Number(t.unitCost)||0);e.set(n,(e.get(n)||0)+r)}),[...e.entries()].sort((e,t)=>new Date(e[0])-new Date(t[0])).map(([e,t])=>({date:e,value:t}))},[eT]),eW=eY.length?eY[eY.length-1].value:0,eU=(0,r.useMemo)(()=>({warehouseCount:(a||[]).length,productCount:(k||[]).length,totalValue:eW}),[a,k,eW]),eZ=(0,r.useMemo)(()=>({labels:eY.map(e=>new Date(e.date).toLocaleDateString("tr-TR")),datasets:[{label:"Toplam Değer (TL)",data:eY.map(e=>Math.round(Number(e.value)||0)),borderColor:"#0b6e4f",backgroundColor:"rgba(11, 110, 79, 0.2)",fill:!0,pointRadius:3,pointHoverRadius:5}]}),[eY]),eX=(0,r.useMemo)(()=>({labels:(eO||[]).map(e=>e.itemName||"—"),datasets:[{label:"Toplam Miktar",data:(eO||[]).map(e=>Number(e.quantity)||0),backgroundColor:"rgba(11, 110, 79, 0.85)",borderColor:"#0b6e4f",borderWidth:1}]}),[eO]),eJ=(0,r.useMemo)(()=>{let e=new Map;(eT||[]).forEach(t=>{let a=String(t?.item?._id||t?.item||""),n=String(t?.warehouse?._id||t?.warehouse||"");if(!a||!n)return;let r=`${n}|${a}`,s=new Date(t.date),l=e.get(r);(!l||s>l.date)&&e.set(r,{date:s,quantity:Number(t.quantity)||0})});let t=new Map((ex||[]).map(e=>[`${e.warehouseId}|${e.itemId}`,e])),n=new Set([...t.keys(),...e.keys()]),r=new Map;return n.forEach(a=>{let[n]=String(a).split("|"),s=t.get(a),l=e.get(a),i=s?Number(s.quantity)||0:Number(l?.quantity)||0;r.set(n,(r.get(n)||0)+i)}),(a||[]).map(e=>({warehouseId:e._id,warehouseName:e.name||"—",total:Number(r.get(String(e._id)))||0}))},[eT,ex,a]),eQ=(0,r.useMemo)(()=>({labels:(eJ||[]).map(e=>e.warehouseName||"—"),datasets:[{label:"Toplam Adet",data:(eJ||[]).map(e=>Number(e.total)||0),backgroundColor:"rgba(11, 110, 79, 0.85)",borderColor:"#0b6e4f",borderWidth:1}]}),[eJ]);async function e0(e){et(e),$(!0),W(!0);try{let t=await (0,y.TwK)({warehouseId:e._id}),a=Array.isArray(t)?t:Array.isArray(t?.rows)?t.rows:[],n=e=>{if(!e)return null;let t=new Date(e);return isNaN(t)?null:t.toISOString().slice(0,10)},r=new Map;(eT||[]).filter(t=>String(t?.warehouse?._id||t?.warehouse)===String(e._id)).forEach(e=>{let t=String(e?.item?._id||e?.item||"");if(!t)return;let a=r.get(t),n=new Date(e.date);(!a||n>a.date)&&r.set(t,{date:n,quantity:Number(e.quantity)||0})});let s=new Map((a||[]).map(e=>[String(e.itemId),e])),l=new Set([...s.keys(),...r.keys()]),i=await Promise.all([...l].map(async t=>{let a=s.get(String(t)),l=r.get(String(t)),i=(k||[]).find(e=>String(e._id)===String(t)),o=Number(a?.quantity)||0;if(l?.date){let a=n(l.date);try{let n=await (0,y.zxT)(t,{warehouseId:e._id,since:a}),r=(Array.isArray(n?.rows)?n.rows:[]).reduce((e,t)=>"in"===t.type?e+(Number(t.quantity)||0):"out"===t.type?e-(Number(t.quantity)||0):e,0);o=(Number(l.quantity)||0)+r}catch(e){o=Number(l.quantity)||o}}return{warehouseId:e._id,warehouseName:e.name||a?.warehouseName||"—",itemId:t,itemName:i?.name||a?.itemName||"—",unit:i?.unit||a?.unit||"",quantity:Number(o)||0}})),o=(a||[]).filter(e=>!k?.some(t=>String(t._id)===String(e.itemId))).map(t=>({warehouseId:e._id,warehouseName:t.warehouseName||e.name||"—",itemId:t.itemId,itemName:t.itemName||"—",unit:t.unit||"",quantity:Number(t.quantity)||0}));en([...i,...o])}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e?.message||"Depo \xfcr\xfcnleri alınamadı"})),en([])}finally{W(!1)}}async function e1(e){let t=e?.warehouseId||U?._id;if(e?.itemId&&t){ec(e),es(!0),ei(!0);try{let a=await (0,y.zxT)(e.itemId,{warehouseId:t}),n=(a?.rows||[]).map(e=>({...e,unitPrice:Number(e.unitPrice)||0,quantity:Number(e.quantity)||0,warehouse:e.warehouse||U?.name||"—"})),r=(eT||[]).filter(e=>String(e?.warehouse?._id||e?.warehouse)===String(t)).filter(t=>String(t?.item?._id||t?.item)===String(e.itemId)).map(e=>({_id:`count-${e._id}`,date:e.date,type:"count",warehouse:e?.warehouse?.name||U?.name||"—",unitCost:Number(e.unitCost)||0,unitPrice:Number(e.unitCost)||0,quantity:Number(e.quantity)||0,totalValue:(Number(e.unitCost)||0)*(Number(e.quantity)||0),docNo:e.periodKey||"",notes:e.notes||""})),s=[...n,...r].sort((e,t)=>
1new Date(t.date)-new Date(e.date));eu(s)}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e?.message||"Hareketler alınamadı"})),eu([])}finally{ei(!1)}}}async function e2(e){if(e?.itemId){ew(e),eA(!0),eb(!0);try{let t=await (0,y.zxT)(e.itemId,{}),a=(t?.rows||[]).map(e=>({_id:e._id,date:e.date,type:e.type,warehouse:e.warehouse||"—",quantity:Number(e.quantity)||0,docNo:e.docNo||"",notes:e.notes||""})),n=(eT||[]).filter(t=>String(t?.item?._id||t?.item)===String(e.itemId)).map(e=>({_id:`count-${e._id}`,date:e.date,type:"count",warehouse:e?.warehouse?.name||"—",quantity:Number(e.quantity)||0,unitCost:Number(e.unitCost)||0,totalValue:(Number(e.unitCost)||0)*(Number(e.quantity)||0),docNo:e.periodKey||"",notes:e.notes||""})),r=e=>"count"===e?2:+("out"===e),s=[...a,...n].sort((e,t)=>{let a=new Date(e.date),n=new Date(t.date);return a.getTime()!==n.getTime()?a-n:r(e.type)-r(t.type)}),l=new Map,i=s.map(e=>{let t=e.warehouse||"—",a=Number(l.get(t))||0,n=a;"count"===e.type?n=Number(e.quantity)||0:"in"===e.type?n=a+(Number(e.quantity)||0):"out"===e.type&&(n=a-(Number(e.quantity)||0)),l.set(t,n);let r=[...l.values()].reduce((e,t)=>e+(Number(t)||0),0);return{...e,balance:r}});ef(i)}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e?.message||"Hareketler alınamadı"})),ef([])}finally{eb(!1)}}}async function e6(e){if(window.confirm("\xdcr\xfcn silinsin mi?"))try{await (0,y.Aiq)(e.itemId),i.A.push((0,n.jsx)(o.A,{type:"success",closable:!0,children:"\xdcr\xfcn silindi"})),S(await (0,y.Dwy)({})),z&&U?._id&&await e0(U)}catch(e){i.A.push((0,n.jsx)(o.A,{type:"error",closable:!0,children:e?.message||"Silinemedi. \xdcr\xfcn\xfcn hareketleri olabilir; istersen pasif yap."}))}}return(0,n.jsxs)("div",{className:"admin-page",children:[(0,n.jsx)(c.A,{bordered:!0,className:"rounded-xl table-panel mb-3",children:(0,n.jsxs)(d.A,{children:[(0,n.jsx)(u.A,{label:"Toplam Depo",value:eU.warehouseCount}),(0,n.jsx)(u.A,{label:"Toplam \xdcr\xfcn",value:eU.productCount}),(0,n.jsx)(u.A,{label:"Toplam Değer (TL)",value:Math.round(eU.totalValue).toLocaleString("tr-TR")})]})}),(0,n.jsxs)(h.A,{justify:"space-between",align:"middle",className:"mb-3",children:[(0,n.jsxs)(h.A.Item,{colspan:12,children:[(0,n.jsx)("h3",{className:"m-0",children:"Ambar / Stok Y\xf6netimi"}),(0,n.jsx)("p",{className:"text-gray-600",children:"Depo, \xfcr\xfcn/hammadde, giriş-\xe7ıkış ve aylık sayımlar."})]}),(0,n.jsx)(h.A.Item,{colspan:12,className:"text-right",children:(0,n.jsxs)(m.Ay,{spacing:8,alignItems:"center",justifyContent:"flex-end",className:"stack-responsive ambar-top-actions",children:[(0,n.jsx)(l.A,{appearance:"subtle",className:"ambar-btn",startIcon:(0,n.jsx)(x.A,{}),onClick:function(){C(null),N({name:"",code:"",address:"",isActive:!0,notes:""}),g(!0)},children:"Depo"}),(0,n.jsx)(l.A,{appearance:"subtle",className:"ambar-btn",startIcon:(0,n.jsx)(x.A,{}),onClick:function(){q(null),_({name:"",sku:"",type:"raw",unit:"adet",minStock:0,isActive:!0,notes:""}),v(!0)},children:"\xdcr\xfcn/Hammadde"}),(0,n.jsx)(l.A,{appearance:"primary",className:"ambar-btn ambar-btn-primary",startIcon:(0,n.jsx)(p.A,{}),onClick:()=>ez("in"),children:"Giriş"}),(0,n.jsx)(l.A,{appearance:"ghost",className:"ambar-btn",startIcon:(0,n.jsx)(p.A,{}),onClick:()=>ez("out"),children:"\xc7ıkış"}),(0,n.jsx)(l.A,{appearance:"subtle",className:"ambar-btn",startIcon:(0,n.jsx)(x.A,{}),onClick:function(){ev({warehouse:null,item:null,periodKey:"",date:new Date,quantity:0,unitCost:0,notes:""}),eI(!0)},children:"Aylık Sayım"})]})})]}),(0,n.jsxs)(c.A,{bordered:!0,className:"rounded-xl table-panel mb-3",children:[(0,n.jsx)("div",{className:"affix-bar",children:(0,n.jsxs)("span",{className:"chart-title-link",role:"button",tabIndex:0,children:["Toplam Stok Değeri (TL) — ",Math.round(eW).toLocaleString("tr-TR")]})}),(0,n.jsx)("div",{style:{height:320,marginTop:12},children:(0,n.jsx)(j.Line,{data:eZ,options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:"#0f172a"}}},scales:{x:{ticks:{autoSkip:!0,maxRotation:0,minRotation:0,color:"#475569"},grid:{color:"#e5e7eb"}},y:{beginAtZero:!0,ticks:{color:"#475569",callback:e=>
1Number(e).toLocaleString("tr-TR")},grid:{color:"#e5e7eb"}}}}})})]}),(0,n.jsxs)("div",{className:"charts-row mb-3",children:[(0,n.jsxs)(c.A,{bordered:!0,className:"rounded-xl table-panel chart-panel-main",children:[(0,n.jsx)("div",{className:"affix-bar",children:(0,n.jsx)("span",{className:"chart-title-link",role:"button",tabIndex:0,children:"T\xfcm Ambarlarda Toplam \xdcr\xfcn Miktarı"})}),(0,n.jsx)("div",{style:{marginTop:12},children:(0,n.jsx)(j.Bar,{height:460,data:eX,options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:"#e6efe9"}}},scales:{x:{ticks:{autoSkip:!0,maxRotation:0,minRotation:0,color:"#cfe7d9"},grid:{color:"#1f3a2d"}},y:{beginAtZero:!0,ticks:{color:"#cfe7d9"},grid:{color:"#1f3a2d"}}}}})})]}),(0,n.jsxs)(c.A,{bordered:!0,className:"rounded-xl table-panel chart-panel-secondary",children:[(0,n.jsx)("div",{className:"affix-bar",children:(0,n.jsx)("span",{className:"chart-title-link",role:"button",tabIndex:0,children:"Ambar Doluluk (Toplam Adet)"})}),(0,n.jsx)("div",{style:{marginTop:12},children:(0,n.jsx)(j.Bar,{height:460,data:eQ,options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:"#e6efe9"}}},scales:{x:{ticks:{autoSkip:!0,maxRotation:0,minRotation:0,color:"#cfe7d9"},grid:{color:"#1f3a2d"}},y:{beginAtZero:!0,ticks:{color:"#cfe7d9"},grid:{color:"#1f3a2d"}}}}})})]})]}),(0,n.jsx)("div",{className:"segment-wrap",children:(0,n.jsx)(m.Ay,{justifyContent:"center",children:(0,n.jsx)(ee,{className:"segment-control",data:[{label:"Depolar",value:"warehouses"},{label:"\xdcr\xfcnler",value:"products"}],value:eN,onChange:ek,block:!0})})}),"warehouses"===eN&&(0,n.jsx)(c.A,{bordered:!0,className:"rounded-xl table-panel",children:(0,n.jsx)(I,{data:a,onEdit:function(e){C(e),N({name:e.name||"",code:e.code||"",address:e.address||"",isActive:!!e.isActive,notes:e.notes||""}),g(!0)},onDelete:eB,onRowClick:e0})}),"products"===eN&&(0,n.jsx)(c.A,{bordered:!0,className:"rounded-xl table-panel",children:(0,n.jsx)(G,{rows:eO,loading:eh,numFmt:Q,onRowClick:e2})}),(0,n.jsx)(P,{open:A,onClose:()=>g(!1),editing:w,formValue:f,onChange:N,onSave:eH,onDelete:eB}),(0,n.jsx)(E,{open:D,onClose:()=>v(!1),editing:T,formValue:L,onChange:_,onSave:eK,onDelete:eF}),(0,n.jsx)(V,{open:R,onClose:()=>{M(!1),B(null)},formValue:K,onChange:F,onSave:e$,whOptions:eE,itemOptions:eV,supplierOptions:eG}),(0,n.jsx)(O,{open:eS,onClose:()=>eI(!1),formValue:eD,onChange:ev,onSave:eP,whOptions:eE,itemOptions:eV}),(0,n.jsx)(Z,{open:z,onClose:function(){$(!1),et(null),en([]),es(!1),ec(null),eu([])},warehouse:U,rows:ea,loading:Y,onItemClick:e1,onEditItem:function(e){let t=(k||[]).find(t=>String(t._id)===String(e.itemId));if(!t)return void i.A.push((0,n.jsx)(o.A,{type:"warning",closable:!0,children:"\xdcr\xfcn bulunamadı"}));q(t),_({name:t.name||"",sku:t.sku||"",type:t.type||"raw",unit:t.unit||"adet",minStock:t.minStock||0,isActive:!!t.isActive,notes:t.notes||""}),v(!0)},onDeleteItem:e6,numFmt:Q}),(0,n.jsx)(X,{open:er,onClose:()=>es(!1),warehouse:U,item:eo,rows:ed,loading:el,numFmt:Q}),(0,n.jsx)(J,{open:ej,onClose:()=>eA(!1),item:eg,rows:eC,loading:ey})]})}}},e=>{var t=t=>e(e.s=t);e.O(0,[4221,4284,8093,2666,4550,8607,6367,1802,301,9578,5107,2029,7342,566,254,7691,2896,636,6593,8792],()=>t(17595)),_N_E=e.O()}]);

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.