module.exports=[94195,a=>{"use strict";var b=a.i(63672);function c(){return"https://api.banglayon.com/api".replace(/\/+$/,"")}function d(){let a=c();if(!a)throw{status:0,message:"API Base URL সেট করা নেই। `nextjsadmin/.env.local` এ NEXT_PUBLIC_API_BASE_URL দিন (example দেখুন), তারপর dev server restart করুন।"};return a}function e(a){let c=(0,b.getAdminApiKey)(),d=new Headers(a?.headers);return c&&d.set("x-admin-key",c),{...a,headers:d}}async function f(a){return await a.json().catch(()=>null)}async function g(a){let b=await f(a),c=(()=>{if(b&&"object"==typeof b&&"message"in b){let a=b.message;if(null!=a)return String(a)}return`Request failed (${a.status})`})();return{status:a.status,message:c}}async function h(a,b){let c=new URL(`${d()}${a}`);b&&Object.entries(b).forEach(([a,b])=>c.searchParams.set(a,b));let h=await fetch(c.toString(),e({method:"GET"}));if(!h.ok)throw await g(h);let i=await f(h);return i?.data??i}async function i(a,b){let c=await fetch(`${d()}${a}`,e({method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(b)}));if(!c.ok)throw await g(c);let h=await f(c);return h?.data??h}async function j(a,b){let c=await fetch(`${d()}${a}`,e({method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)}));if(!c.ok)throw await g(c);let h=await f(c);return h?.data??h}async function k(a){let b=await fetch(`${d()}${a}`,e({method:"DELETE"}));if(!b.ok)throw await g(b);return!0}async function l(a){let b=`${d()}/admin/books`,c=new Headers;c.set("x-admin-key",a.trim());let e=await fetch(b,{method:"GET",headers:c});if(401===e.status)throw{status:401,message:"ভুল Admin API Key। সঠিক key দিন।"};if(!e.ok)throw await g(e)}async function m(a,b,c){let h=new FormData;for(let[a,b]of Object.entries(c))h.set(a,b);h.set("file",b,b.name);let i=await fetch(`${d()}${a}`,e({method:"POST",body:h}));if(!i.ok)throw await g(i);let j=await f(i);return j?.data??j}async function n(a,b,c=!1){let h=new FormData;h.set("file",b,b.name);let i=await fetch(`${d()}/admin/contents/${a}/file${c?"?keepName=true":""}`,e({method:"PUT",body:h}));if(!i.ok)throw await g(i);let j=await f(i);return j?.data??j}a.s(["apiDelete",0,k,"apiGet",0,h,"apiPost",0,j,"apiPut",0,i,"apiReplacePdf",0,n,"apiUploadPdf",0,m,"getApiBaseUrl",0,c,"validateAdminKey",0,l])},98352,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(94195);function e({book:a,existing:f,onClose:g,onSaved:h}){let i=String(a.bookId),j=String(a?.title?.bn??i),[k,l]=(0,c.useState)(()=>{let a=f?.delta?.bn;return Array.isArray(a)?a.map(a=>"string"==typeof a?.insert?a.insert:"").join(""):""}),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)(null);function q(a){return[{insert:a.endsWith("\n")?a:`${a}
`}]}async function r(){p(null),n(!0);try{await (0,d.apiPut)(`/admin/guides/${i}`,{title:{bn:`${j} — গাইড`,en:`${String(a?.title?.en??j)} — Guide`,ar:`${String(a?.title?.ar??j)} — دليل`},delta:{bn:q(k),en:q(k),ar:q(k)},isPublished:!0}),await h()}catch(a){p(a?.message??String(a)),n(!1)}}return(0,b.jsx)("div",{className:"fixed inset-0 z-50 bg-black/70 flex items-center justify-center p-4",children:(0,b.jsxs)("div",{className:"w-full max-w-[760px] rounded-3xl border border-zinc-800 bg-zinc-950 shadow-2xl",children:[(0,b.jsxs)("div",{className:"px-6 py-4 border-b border-zinc-800 flex items-center gap-3",children:[(0,b.jsxs)("div",{className:"text-base font-semibold",children:[j," — গাইড"]}),(0,b.jsx)("div",{className:"flex-1"}),(0,b.jsx)("button",{onClick:g,className:"px-3 py-2 rounded-lg border border-zinc-800 hover:border-zinc-700 text-sm",children:"Close"})]}),(0,b.jsxs)("div",{className:"p-6 space-y-3",children:[(0,b.jsx)("div",{className:"text-xs text-zinc-300",children:"Guide text (BN) — simple editor"}),(0,b.jsx)("textarea",{value:k,onChange:a=>l(a.target.value),className:"w-full rounded-xl bg-black/40 border border-zinc-800 px-4 py-3 outline-none focus:border-[#D4AF37]/60 min-h-[360px]"}),o?(0,b.jsx)("div",{className:"text-sm text-red-300",children:o}):null,(0,b.jsx)("div",{className:"flex gap-2 pt-2",children:(0,b.jsx)("button",{type:"button",onClick:()=>void r(),disabled:m,className:"px-4 py-2 rounded-xl bg-[#D4AF37] text-zinc-950 font-semibold text-sm disabled:opacity-40",children:m?"Saving…":"Save Guide"})})]})]})})}a.s(["default",0,function(){let[a,f]=(0,c.useState)([]),[g,h]=(0,c.useState)([]),[i,j]=(0,c.useState)([]),[k,l]=(0,c.useState)("all"),[m,n]=(0,c.useState)(!0),[o,p]=(0,c.useState)(null),[q,r]=(0,c.useState)(null);async function s(){n(!0),p(null);try{let[a,b,c]=await Promise.all([(0,d.apiGet)("/admin/books"),(0,d.apiGet)("/admin/categories"),(0,d.apiGet)("/admin/guides")]),e=(a??[]).filter(a=>a?.showOnHome!==!1&&a?.hasGuide!==!1).sort((a,b)=>Number(a?.sortOrder??a?.number??0)-Number(b?.sortOrder??b?.number??0));f(e),h(b??[]),j(c??[])}catch(a){p(a?.message??String(a))}finally{n(!1)}}(0,c.useEffect)(()=>{s()},[]);let t=(0,c.useMemo)(()=>[{id:"all",label:"সকল কিতাব"},...g.map(a=>({id:String(a.categoryId),label:String(a?.title?.bn??a.categoryId)}))],[g]),u=(0,c.useMemo)(()=>"all"===k?a:a.filter(a=>String(a?.category??"")===k),[a,k]);return(0,b.jsxs)("div",{className:"space-y-5",children:[(0,b.jsxs)("div",{className:"flex items-start gap-4",children:[(0,b.jsxs)("div",{className:"flex-1",children:[(0,b.jsx)("div",{className:"text-xl font-semibold",children:"Teaching Guides"}),(0,b.jsx)("div",{className:"text-sm text-zinc-400",children:"প্রতিটি book card এর জন্য আলাদা গাইড"})]}),(0,b.jsx)("button",{onClick:()=>void s(),className:"px-3 py-2 rounded-lg border border-zinc-800 hover:border-zinc-700 text-sm",children:"Refresh"})]}),m?null:(0,b.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-1",children:t.map(c=>{let d=k===c.id,e="all"===c.id?a.length:a.filter(a=>String(a?.category??"")===c.id).length;return(0,b.jsxs)("button",{onClick:()=>l(c.id),className:["shrink-0 rounded-full border px-4 py-2 text-sm flex items-center gap-2",d?"bg-[#D4AF37] text-zinc-950 border-[#D4AF37]":"border-zinc-800 text-zinc-200 hover:bg-zinc-900/50"].join(" "),children:[(0,b.jsx)("span",{className:"truncate max-w-[200px]",children:c.label}),(0,b.jsx)("span",{className:["text-xs rounded-full px-2 py-0.5 font-medium",d?"count-badge-selected":"count-badge"].join(" "),children:e})]},c.id)})}),m?(0,b.jsx)("div",{className:"py-10 text-center text-zinc-300 text-sm",children:"Loading…"}):0===u.length?(0,b.jsx)("div",{className:"py-10 text-center text-zinc-300 text-sm",children:"No guide-enabled books"}):(0,b.jsx)("div",{className:"space-y-2",children:u.map(a=>{let c=String(a.bookId),e=i.find(a=>String(a.bookId)===c)??null,f=String(a?.title?.bn??c);return(0,b.jsxs)("div",{className:"rounded-2xl border border-zinc-800 bg-black/40 p-4 flex items-start gap-4",children:[(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("div",{className:"font-semibold truncate",children:f}),(0,b.jsx)("div",{className:"text-sm text-zinc-400 truncate",children:e?"Guide saved":"Not set"})]}),(0,b.jsx)("button",{className:"px-3 py-2 rounded-lg border border-zinc-800 hover:border-zinc-700 text-sm",onClick:()=>r({book:a,guide:e}),children:"Edit"}),e?(0,b.jsx)("button",{className:"px-3 py-2 rounded-lg border border-red-900/60 text-red-200 hover:border-red-800 text-sm",onClick:async()=>{if(confirm("Delete guide?"))try{await (0,d.apiDelete)(`/admin/guides/${c}`),await s()}catch(a){p(a?.message??String(a))}},children:"Delete"}):null]},c)})}),o?(0,b.jsx)("div",{className:"text-sm text-red-300",children:o}):null,q?(0,b.jsx)(e,{book:q.book,existing:q.guide,onClose:()=>r(null),onSaved:async()=>{r(null),await s()}}):null]})}])}];

//# sourceMappingURL=src_1awgk5j._.js.map