hanoman 0.9.26 → 0.9.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +3 -3
- package/dist/server.js +10 -5
- package/package.json +1 -1
- package/web/assets/{DalangHanomanScreen-BMQjWbwC.js → DalangHanomanScreen-wJskhX1_.js} +1 -1
- package/web/assets/{DocPreviewModal-Vysb114M.js → DocPreviewModal-ClHbRVmQ.js} +1 -1
- package/web/assets/{DocsWorkspace-Bo2dJRqt.js → DocsWorkspace-Db_g219X.js} +1 -1
- package/web/assets/{IdeScreen-1V2L_82g.js → IdeScreen-CfX1HEtj.js} +1 -1
- package/web/assets/{LeadScreen-D7njTsNH.js → LeadScreen-BIpisTdG.js} +1 -1
- package/web/assets/{ReviewScreen-BytyE-o3.js → ReviewScreen-DMGTLCki.js} +1 -1
- package/web/assets/{SchedulerScreen-b4hvb1Sy.js → SchedulerScreen-CSaFiXc9.js} +1 -1
- package/web/assets/{SettingsScreen-C9YeMz1R.js → SettingsScreen-C4chALvS.js} +1 -1
- package/web/assets/{TeamScreen-WvQNIYf0.js → TeamScreen-CS9osC8I.js} +1 -1
- package/web/assets/TerminalScreen-C0fHHsUa.js +2 -0
- package/web/assets/{TriageScreen-CfzqvbI2.js → TriageScreen-Eh8BoPTm.js} +1 -1
- package/web/assets/{VpsScreen-XWHjdq4i.js → VpsScreen-CweCi934.js} +1 -1
- package/web/assets/{index-BvFCEJud.js → index-Av-RfHXX.js} +2 -2
- package/web/assets/{live-B2RFSX3l.js → live-Bfx0Oehi.js} +1 -1
- package/web/assets/{sched-lead-shared-0mpQqjza.js → sched-lead-shared-DJn2D3VE.js} +1 -1
- package/web/assets/{settings-rebase-BVFljdPX.js → settings-rebase-Bbz53ceL.js} +1 -1
- package/web/index.html +1 -1
- package/web/assets/TerminalScreen-BYx1OK27.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DalangHanomanScreen-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DalangHanomanScreen-wJskhX1_.js","assets/react-DfGhg7ZW.js","assets/markdown-CWEY34jk.js","assets/xterm-3VOAfa_q.js","assets/DalangHanomanScreen-DhDPV6e8.css","assets/TeamScreen-CS9osC8I.js","assets/live-Bfx0Oehi.js","assets/TeamScreen-Bw8bIycZ.css","assets/TriageScreen-Eh8BoPTm.js","assets/TriageScreen-B6_KrS6l.css","assets/TerminalScreen-C0fHHsUa.js","assets/TerminalScreen-D0NdFmR-.css","assets/IdeScreen-CfX1HEtj.js","assets/highlight-HK3IjCTX.js","assets/DocPreviewModal-ClHbRVmQ.js","assets/IdeScreen-CppUucs0.css","assets/VpsScreen-CweCi934.js","assets/VpsScreen-BzXpc3le.css","assets/SchedulerScreen-CSaFiXc9.js","assets/sched-lead-shared-DJn2D3VE.js","assets/scheduler-CQt-VP9-.css","assets/settings-rebase-Bbz53ceL.js","assets/LeadScreen-BIpisTdG.js","assets/LeadScreen-CN53yR_e.css","assets/DocsWorkspace-Db_g219X.js","assets/DocsWorkspace-CSak7xFX.css","assets/ReviewScreen-DMGTLCki.js","assets/SettingsScreen-C4chALvS.js","assets/SettingsScreen-DQZ3K43g.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var Ef=Object.defineProperty;var Tf=(e,a,n)=>a in e?Ef(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n;var bu=(e,a,n)=>Tf(e,typeof a!="symbol"?a+"":a,n);import{r as qt,a as Cf,R as d,B as Pf,u as Mf,b as If}from"./react-DfGhg7ZW.js";import{m as Nf,p as Rf}from"./markdown-CWEY34jk.js";import{D as Lf,o as Bf}from"./xterm-3VOAfa_q.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();var bp={exports:{}},Uo={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.min.js
|
|
@@ -1007,6 +1007,6 @@ Klik Masuk`,"aria-label":`Langkah pengujian ${e.code}`,...m("steps")})}),t.jsx(o
|
|
|
1007
1007
|
Isi akun yang benar
|
|
1008
1008
|
Klik Masuk`,value:o.steps,onChange:N("steps")})}),t.jsx(oe,{label:"Hasil yang diharapkan",children:t.jsx(Ia,{rows:3,placeholder:"mis. Halaman beranda terbuka.",value:o.expected,onChange:N("expected")})}),t.jsx(oe,{label:"Hasil yang terjadi",children:t.jsx(Ia,{rows:3,placeholder:"mis. Tombol diam, tak ada pesan galat.",value:o.actual,onChange:N("actual")})}),o.id&&t.jsx(oe,{label:"Status",children:t.jsx($e,{value:o.status,onChange:N("status"),options:[{value:"open",label:ro.open},{value:"wontfix",label:ro.wontfix}]})}),c&&t.jsx("p",{role:"alert",className:"hn-qa-error",children:c})]})}),i]})}function tI({f:e,p:a}){return t.jsxs("div",{className:"hn-qa-detail-stack",children:[t.jsxs("span",{className:"hn-qa-row-line",children:[t.jsx(oa,{tone:rf[e.severity],size:"sm",children:hs[e.severity]}),t.jsx(oa,{tone:of[e.status],variant:"dot",size:"sm",children:ro[e.status]}),t.jsxs("span",{children:["Prioritas ",e.priority]}),e.area&&t.jsx("span",{children:e.area}),e.caseCode&&t.jsx("span",{children:e.caseCode})]}),e.steps.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"hn-qa-label",children:"Cara memunculkan masalah"}),t.jsx("ol",{className:"hn-qa-steps",children:e.steps.map((n,i)=>t.jsx("li",{children:n},i))})]}),t.jsxs("div",{className:"hn-qa-detail-grid",children:[t.jsxs("div",{children:[t.jsx("div",{className:"hn-qa-label",children:"Hasil yang diharapkan"}),t.jsx("div",{className:"hn-qa-pre",children:e.expected||"—"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"hn-qa-label",children:"Hasil yang terjadi"}),t.jsx("div",{className:"hn-qa-pre",children:e.actual||"—"})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"hn-qa-label",children:"Lampiran temuan"}),t.jsx(uu,{...a,ownerType:"finding",ownerId:e.id,compact:!0})]})]})}function nI({detail:e,projectId:a}){const n=At(),i=Object.fromEntries(e.attachments.map(r=>[r.id,n.qaAttachmentUrl(a,e.id,r.id)]));return t.jsx("div",{className:"hn-qa-preview",children:t.jsx(ws,{text:Dx(e,i,{preview:!0}),name:`${e.code}.md`})})}const ac=[{key:"os",label:"Sistem operasi",example:"Windows 11 atau macOS 15"},{key:"browser",label:"Browser",example:"Chrome 130"},{key:"device",label:"Perangkat",example:"Laptop atau iPhone 15"},{key:"url",label:"Alamat aplikasi",example:"https://staging.example.com"},{key:"branch",label:"Branch (opsional)",example:"main"}],Kh=e=>({title:e.title,buildVersion:e.buildVersion,tester:e.tester,scope:e.scope,summary:e.summary,verdict:e.verdict??"",env:FM(Object.fromEntries(Object.entries(e.environment).filter(([a])=>!ac.some(n=>n.key===a)))),os:e.environment.os??"",browser:e.environment.browser??"",device:e.environment.device??"",url:e.environment.url??"",branch:e.environment.branch??""});function iI({detail:e,projectId:a,onChange:n,onBack:i,onDeleted:r,onToast:s,onOpenSession:o,startOpen:l=!1}){const c=At(),{confirm:u,dialog:m}=lt(),h=e.status==="closed",p=Object.prototype.hasOwnProperty.call(Md,e.status),[g,f]=d.useState("cases"),[b,v]=d.useState(()=>Kh(e)),[x,y]=d.useState(()=>Kh(e)),[T,S]=d.useState(l),[E,w]=d.useState(!1),[N,R]=d.useState(!1),[L,I]=d.useState(!1),[B,A]=d.useState(""),[M,K]=d.useState(""),[O,J]=d.useState(""),Z=JSON.stringify(b)!==JSON.stringify(x),H=e.status==="submitted"?"closed":"submitted",te=b.title.trim().length>0,ae=e.findings.filter(we=>we.status==="open").length,F=e.attachments.filter(we=>we.ownerType==="report").length,fe=()=>({title:b.title,buildVersion:b.buildVersion,tester:b.tester,scope:b.scope,summary:b.summary,verdict:b.verdict||null,environment:{...GM(b.env),...Object.fromEntries(ac.filter(({key:we})=>b[we].trim()).map(({key:we})=>[we,b[we].trim()]))}}),_e=async(we,Je)=>{const U=b;I(!0);try{const Be=await c.patchQaReport(a,e.id,{...h?{}:fe(),...we?{status:we}:{}});return y(U),A(""),K(""),n(Be),null}catch(Be){return Oo(Je,Be)}finally{I(!1)}},ee=async()=>{if(!te){A("Isi judul laporan sebelum menyimpan."),S(!0);return}const we=await _e(void 0,"menyimpan laporan");we&&K(we)},X=async()=>{const we=await _e("draft","membuka kembali laporan");we&&K(we)},ce=()=>{J(""),w(!0)},se=async()=>{J("");const we=await _e(H,H==="closed"?"menyelesaikan laporan":"mengajukan laporan");we?J(we):w(!1)},Ce=async()=>{if(await u({title:`Hapus ${e.code}?`,message:`"${e.title}"`,impact:["Test case, temuan, dan lampirannya ikut terhapus."],tone:"danger",confirmLabel:"Hapus"}))try{await c.deleteQaReport(a,e.id),r()}catch(we){s==null||s(St(we))}},Te=async()=>{Z&&!await u({title:"Buang perubahan yang belum disimpan?",message:"Perubahan pada informasi laporan belum disimpan dan akan hilang.",impact:["Judul, versi, penguji, lingkungan, ringkasan, dan keputusan kembali ke nilai yang tersimpan."],tone:"danger",confirmLabel:"Buang perubahan"})||i()},le=we=>Je=>v(U=>({...U,[we]:Je.target.value})),ya=b.verdict&&b.verdict in tr?tr[b.verdict]:"Belum dipilih",Ze=[b.os,b.browser,b.device].map(we=>we.trim()).filter(Boolean),He=M||(h?"Laporan terkunci. Buka kembali untuk mengubah isinya.":Z?"Ada perubahan belum disimpan.":"Semua perubahan tersimpan."),Ke=H==="closed"?"Selesaikan dan kunci":"Ajukan",ga=H==="closed"?"Selesaikan dan kunci":"Ajukan laporan",Ge=h?t.jsx(q,{disabled:L,loading:L,onClick:()=>void X(),children:"Buka kembali"}):Z?t.jsxs(t.Fragment,{children:[t.jsx(q,{disabled:L,loading:L,onClick:()=>void ee(),children:"Simpan"}),t.jsx(q,{variant:"secondary",disabled:L,onClick:ce,children:Ke})]}):t.jsx(q,{disabled:L,onClick:ce,children:Ke}),ba=[{key:"preview",label:"Pratinjau laporan",icon:"eye",onSelect:()=>R(!0)},...h?[]:[{key:"delete",label:"Hapus laporan",icon:"trash-2",tone:"danger",onSelect:()=>void Ce()}]],Ta=te&&b.verdict!=="",va={detail:e,projectId:a,locked:h,onChange:n,onToast:s,onOpenSession:o};return t.jsxs("div",{className:"hn-qa-editor",children:[t.jsxs("div",{className:"hn-qa-bar",children:[t.jsxs("div",{className:"hn-qa-bar-title",children:[t.jsx(q,{variant:"ghost",size:"sm",leftIcon:"arrow-left",onClick:()=>void Te(),children:"Kembali"}),t.jsx(oa,{tone:"brass",variant:"outline",size:"sm",children:e.code}),p&&t.jsx(oa,{tone:lf[e.status],size:"sm",children:Md[e.status]}),t.jsx("h3",{className:"hn-qa-bar-name",children:b.title.trim()||"Tanpa judul"})]}),t.jsxs("div",{className:"hn-qa-bar-actions",children:[t.jsx("span",{role:M?"alert":"status",className:`hn-qa-bar-save${M?" is-error":""}`,children:He}),Ge,t.jsx(rn,{label:"Menu laporan",title:"Ekspor dan tindakan lain",items:ba,children:t.jsx("div",{className:"hn-qa-export",children:zM.map(we=>t.jsx(q,{size:"sm",variant:we.format==="zip"?"secondary":"ghost",leftIcon:"download",as:"a",href:c.qaExportUrl(a,e.id,we.format),children:we.label},we.format))})})]})]}),t.jsxs("section",{className:"hn-qa-info","aria-labelledby":`${e.id}-info`,children:[t.jsxs("div",{className:"hn-qa-info-head",children:[t.jsx("h3",{id:`${e.id}-info`,className:"hn-qa-info-title",children:"Info laporan"}),Z&&t.jsx(oa,{tone:"warn",size:"sm",children:"Belum disimpan"}),t.jsx(q,{variant:"secondary",size:"sm",leftIcon:"pencil",onClick:()=>S(!0),children:h?"Lihat info":"Ubah info"})]}),t.jsxs("dl",{className:"hn-qa-facts",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Versi aplikasi"}),t.jsx("dd",{children:b.buildVersion.trim()||"Belum diisi"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Penguji"}),t.jsx("dd",{children:b.tester.trim()||"Belum diisi"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Keputusan"}),t.jsx("dd",{children:ya})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Perangkat dan lingkungan"}),t.jsx("dd",{children:Ze.length?Ze.join(" · "):"Belum diisi"})]})]})]}),t.jsx(_t,{value:g,onChange:f,tabs:[{value:"cases",label:"Langkah uji",count:e.cases.length},{value:"findings",label:"Temuan",count:e.findings.length},{value:"attachments",label:"Lampiran",count:F}]}),g==="cases"&&t.jsx(QM,{...va}),g==="findings"&&t.jsx(aI,{...va}),g==="attachments"&&t.jsx(uu,{...va,ownerType:"report",ownerId:e.id}),t.jsx(da,{open:T,title:"Info laporan",eyebrow:e.code,width:640,onClose:()=>S(!1),footer:t.jsx(q,{onClick:()=>S(!1),children:"Selesai"}),children:t.jsxs("div",{className:"hn-qa-form",children:[t.jsx(oe,{label:"Judul laporan (wajib)",error:B||void 0,children:t.jsx(Oe,{placeholder:"Contoh: Pengujian fitur login versi 1.0",value:b.title,disabled:h,onChange:le("title")})}),t.jsxs("div",{className:"hn-qa-grid",children:[t.jsx(oe,{label:"Versi aplikasi",children:t.jsx(Oe,{placeholder:"Contoh: 1.0.0",value:b.buildVersion,disabled:h,onChange:le("buildVersion")})}),t.jsx(oe,{label:"Nama penguji",children:t.jsx(Oe,{placeholder:"Contoh: Rina Pratama",value:b.tester,disabled:h,onChange:le("tester")})})]}),t.jsx(oe,{label:"Apa yang diuji?",hint:"Sebutkan fitur yang diperiksa dan batasan pengujiannya.",children:t.jsx(Ia,{rows:3,placeholder:"Contoh: Login dengan email dan kata sandi. Login Google belum diuji.",value:b.scope,disabled:h,onChange:le("scope")})}),t.jsxs("fieldset",{className:"hn-qa-fieldset",children:[t.jsx("legend",{className:"hn-qa-legend",children:"Perangkat dan lingkungan pengujian"}),t.jsx("div",{className:"hn-qa-grid",children:ac.map(({key:we,label:Je,example:U})=>t.jsx(oe,{label:Je,children:t.jsx(Oe,{value:b[we],placeholder:U,disabled:h,onChange:le(we)})},we))}),t.jsxs("details",{className:"hn-qa-more",children:[t.jsx("summary",{children:"Informasi lingkungan tambahan (opsional)"}),t.jsx(oe,{label:"Lingkungan tambahan",hint:"Satu per baris, misalnya jaringan=Wi-Fi",children:t.jsx(Ia,{rows:3,placeholder:"mis. jaringan=Wi-Fi",value:b.env,disabled:h,onChange:le("env")})})]})]}),t.jsx(oe,{label:"Ringkasan hasil",hint:"Boleh diisi setelah langkah uji dan temuan selesai dicatat.",children:t.jsx(Ia,{rows:3,placeholder:"Contoh: Login berhasil di Chrome, tetapi tombol Masuk tidak bereaksi di Safari.",value:b.summary,disabled:h,onChange:le("summary")})}),t.jsx(oe,{label:"Keputusan",hint:"Wajib saat mengajukan laporan. Pilih berdasarkan hasil pengujian.",children:t.jsx($e,{value:b.verdict,disabled:h,onChange:le("verdict"),options:[{value:"",label:"Pilih setelah pengujian selesai"},...wo.map(we=>({value:we,label:tr[we]}))]})})]})}),t.jsxs(da,{open:E,title:H==="closed"?"Tinjau dan selesaikan":"Tinjau dan ajukan",eyebrow:e.code,width:560,dismissible:!L,onClose:()=>w(!1),footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",disabled:L,onClick:()=>w(!1),children:"Batal"}),t.jsx(q,{disabled:!Ta||L,loading:L,onClick:()=>void se(),children:ga})]}),children:[t.jsxs("ul",{className:"hn-qa-check","aria-label":"Syarat pengajuan",children:[t.jsxs("li",{children:[t.jsx(ad,{ok:te}),t.jsxs("div",{className:"hn-qa-check-body",children:[t.jsx("div",{className:"hn-qa-check-name",children:"Judul laporan"}),t.jsx("div",{className:"hn-qa-check-note",children:te?"Sudah diisi.":"Belum diisi. Isi judul di Info laporan, lalu tinjau lagi."})]})]}),t.jsxs("li",{children:[t.jsx(ad,{ok:b.verdict!==""}),t.jsxs("div",{className:"hn-qa-check-body",children:[t.jsx("div",{className:"hn-qa-check-name",children:"Keputusan hasil pengujian"}),t.jsx("div",{className:"hn-qa-check-note",children:b.verdict!==""?`Dipilih: ${ya}.`:"Pilih satu keputusan. Wajib sebelum laporan diajukan."}),t.jsx(vr,{"aria-label":"Keputusan hasil pengujian",value:b.verdict,onChange:we=>v(Je=>({...Je,verdict:we})),children:wo.map(we=>t.jsx(Mi,{value:we,label:tr[we]},we))})]})]}),t.jsxs("li",{children:[t.jsx(ad,{ok:ae===0,warn:!0}),t.jsxs("div",{className:"hn-qa-check-body",children:[t.jsx("div",{className:"hn-qa-check-name",children:"Temuan belum ditangani"}),t.jsx("div",{className:"hn-qa-check-note",children:ae===0?"Tidak ada temuan terbuka.":`${ae} temuan belum ditangani. Ini tidak menghalangi pengajuan.`})]})]})]}),O&&t.jsx("p",{role:"alert",className:"hn-qa-error",children:O})]}),t.jsx(da,{open:N,title:`Pratinjau ${e.code}`,width:880,onClose:()=>R(!1),footer:t.jsx(q,{variant:"ghost",onClick:()=>R(!1),children:"Tutup"}),children:t.jsx(nI,{detail:e,projectId:a})}),m]})}function ad({ok:e,warn:a=!1}){const n=e?"is-ok":a?"is-warn":"is-miss";return t.jsx("span",{className:`hn-qa-check-icon ${n}`,children:t.jsx(Re,{name:e?"circle-check":a?"triangle-alert":"circle-x",size:16})})}function sI({projectId:e,reports:a,onOpen:n}){const i=At();if(a.length===0)return t.jsx(he,{kind:"empty",title:"Belum ada laporan QA",hint:"Buat laporan baru, atau impor dari template Excel."});const r=Date.now();return t.jsx(Xt,{label:"Daftar laporan QA",children:a.map(s=>t.jsx(an,{onClick:()=>n(s.id),actions:t.jsx(q,{as:"a",size:"sm",variant:"ghost",leftIcon:"download",href:i.qaExportUrl(e,s.id),"aria-label":`Unduh ZIP ${s.code}`,children:"Unduh ZIP"}),children:t.jsxs("span",{className:"hn-qa-row-body",children:[t.jsxs("span",{className:"hn-qa-row-head",children:[t.jsx("span",{className:"hn-qa-code",children:s.code}),t.jsx(oa,{tone:lf[s.status],variant:"dot",size:"sm",children:Md[s.status]})]}),t.jsx("span",{className:"hn-qa-row-title",children:s.title}),t.jsxs("span",{className:"hn-qa-row-line",children:[t.jsx("span",{children:[s.buildVersion&&`Versi ${s.buildVersion}`,s.tester].filter(Boolean).join(" · ")||"Belum ada versi atau penguji"}),t.jsxs("span",{className:"hn-qa-row-stat",children:[s.stats.cases.pass,"/",s.stats.cases.total," lulus (",UM(s.stats.passRate),") · ",s.stats.findings.total," temuan (",s.stats.findings.open," belum ditangani)"]}),s.verdict&&t.jsxs("span",{children:["Keputusan: ",tr[s.verdict]]}),t.jsxs("span",{children:["Diubah ",vt(s.updatedAt,r)||"—"]})]})]})},s.id))})}function rI({projects:e,projectId:a,onSelectProject:n,onToast:i,onOpenSession:r}){const s=At(),[o,l]=d.useState(!1),[c,u]=d.useState(null),[m,h]=d.useState(!1),[p,g]=d.useState(null),[f,b]=d.useState(null),[v,x]=d.useState(!1),[y,T]=d.useState(""),[S,E]=d.useState(!1),[w,N]=d.useState(),[R,L]=d.useState([]),[I,B]=d.useState(!1),[A,M]=d.useState(""),[K,O]=d.useState([]),J=d.useCallback(async()=>{if(a){h(!1);try{u((await s.qaReports(a)).items)}catch{h(!0)}}},[s,a]);if(d.useEffect(()=>{g(null),b(null),u(null),O([]),E(!1),N(void 0),L([]),J()},[J]),!a)return t.jsx(he,{kind:"empty",title:"Belum ada project",hint:"Buat atau muat project di halaman Projects, lalu buka QA lagi."});const Z=async F=>{try{g(await s.qaReport(a,F))}catch(fe){i==null||i(St(fe))}},H=async()=>{if(!o){l(!0);try{const F=await s.syncNow();if(!F.ok){i==null||i(F.reason==="not-configured"?"Sinkronisasi belum dikonfigurasi. Hubungkan server dan device token di Settings.":F.reason??"Sinkronisasi gagal");return}await J(),p&&g(await s.qaReport(a,p.id)),i==null||i("QA disinkronkan. Lampiran dipindahkan bertahap pada siklus sinkronisasi.")}catch(F){i==null||i(St(F))}finally{l(!1)}}},te=async()=>{const F=y.trim();if(F)try{const fe=await s.createQaReport(a,{title:F});x(!1),T(""),b(fe.id),g(fe),J()}catch(fe){i==null||i(St(fe))}},ae=async()=>{if(!(!w||I)){B(!0),M(""),O([]);try{const F=await s.importQaReport(a,w,R),fe=F.attachments.rejected.length?`, ${F.attachments.rejected.length} lampiran ditolak`:"";i==null||i(`${F.created?"Diimpor":"Diperbarui"}: ${F.cases} test case, ${F.findings} temuan, ${F.attachments.saved} lampiran${fe}`),O(F.attachments.rejected.map(_e=>`${_e.filename}: ${_e.reason==="missing"?"Berkas belum disertakan. Lampirkan dari laporan yang diimpor.":_e.reason==="type"?"Tipe berkas tidak didukung.":_e.reason}`)),E(!1),N(void 0),L([]),await J(),await Z(F.reportId)}catch(F){M(St(F))}finally{B(!1)}}};return t.jsxs("div",{className:"hn-qa-stack",children:[t.jsxs("div",{className:"hn-qa-toolbar",children:[t.jsx($e,{"aria-label":"Project",className:"hn-qa-toolbar-project",value:a,onChange:F=>n(F.target.value),options:e.map(F=>({value:F.id,label:F.name}))}),t.jsx(q,{variant:"secondary",disabled:o,loading:o,onClick:()=>void H(),children:"Sinkronkan QA"}),!p&&t.jsxs(t.Fragment,{children:[t.jsx(q,{leftIcon:"plus",onClick:()=>x(!0),children:"Laporan baru"}),t.jsx(q,{variant:"secondary",leftIcon:"upload",onClick:()=>{M(""),E(!0)},children:"Impor Excel, ZIP, atau .md"}),t.jsx(q,{variant:"ghost",leftIcon:"download",as:"a",href:s.qaTemplateUrl(),download:"qa-template.xlsx",children:"Unduh template Excel"})]})]}),!p&&t.jsx("p",{className:"hn-qa-intro",children:"Catat hasil pengujian aplikasi dalam satu laporan. Mulai dengan laporan baru, atau unduh template Excel lalu isi dan impor kembali bersama lampirannya."}),K.length>0&&t.jsx("div",{role:"status",children:t.jsx(bt,{tone:"warn",title:"Laporan berhasil diimpor. Beberapa lampiran perlu ditambahkan.",action:t.jsx(q,{size:"sm",variant:"ghost",onClick:()=>O([]),children:"Tutup"}),children:t.jsx("ul",{className:"hn-qa-note-list",children:K.map((F,fe)=>t.jsx("li",{children:F},fe))})})}),p?t.jsx(iI,{detail:p,projectId:a,onChange:g,onToast:i,onOpenSession:r,startOpen:p.id===f,onBack:()=>{g(null),b(null),J()},onDeleted:()=>{g(null),J()}},p.id):m?t.jsx(he,{kind:"error",title:"Gagal memuat laporan QA",action:()=>void J(),actionLabel:"Coba lagi"}):c===null?t.jsx(bk,{rows:3,label:"Memuat laporan QA…",rowHeight:64}):t.jsx(sI,{projectId:a,reports:c,onOpen:F=>void Z(F)}),t.jsx(da,{open:S,title:"Impor laporan QA",width:620,onClose:()=>{I||E(!1)},footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",disabled:I,onClick:()=>E(!1),children:"Batal"}),t.jsx(q,{disabled:!w||I,loading:I,onClick:()=>void ae(),children:"Impor laporan"})]}),children:t.jsxs("div",{className:"hn-qa-modal-stack",children:[t.jsx("p",{className:"hn-qa-note",children:"Isi template Excel, lalu pilih berkasnya di bawah. Laporan hasil ekspor juga dapat diimpor kembali."}),t.jsx(oe,{label:"Berkas laporan (wajib)",hint:"Excel (.xlsx), ZIP dengan Excel dan lampiran, atau Markdown (.md).",children:t.jsx("input",{type:"file",className:"hn-qa-file","aria-label":"Berkas laporan (wajib)",accept:".xlsx,.zip,.md",disabled:I,onChange:F=>{var fe;return N((fe=F.target.files)==null?void 0:fe[0])}})}),t.jsx(oe,{label:"Berkas lampiran (opsional)",hint:"Pilih semua screenshot atau log yang disebut pada sheet Lampiran. Nama berkas harus sama dengan kolom Berkas; kolom Pemilik diisi Laporan, TC-01, atau F-01.",children:t.jsx("input",{type:"file",multiple:!0,className:"hn-qa-file","aria-label":"Berkas lampiran (opsional)",accept:".png,.jpg,.jpeg,.webp,.pdf,.md,.txt,.log,.json,.csv",disabled:I,onChange:F=>L(Array.from(F.target.files??[]))})}),t.jsx("p",{className:"hn-qa-note",children:"Maksimal 10 MB per lampiran, 30 lampiran dan 100 MB per laporan. Untuk ZIP, sertakan report.xlsx dan folder attachments/. Gambar yang ditempel di sel Excel perlu disertakan sebagai berkas terpisah."}),A&&t.jsx("p",{role:"alert",className:"hn-qa-error",children:A})]})}),t.jsx(da,{open:v,title:"Laporan QA baru",onClose:()=>x(!1),footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",onClick:()=>x(!1),children:"Batal"}),t.jsx(q,{onClick:()=>void te(),disabled:!y.trim(),children:"Buat"})]}),children:t.jsx(oe,{label:"Judul",hint:"Contoh: Pengujian fitur login versi 1.0",children:t.jsx(Oe,{value:y,autoFocus:!0,placeholder:"mis. Regresi rilis 1.1",onChange:F=>T(F.target.value),onKeyDown:F=>{F.key==="Enter"&&te()}})})})]})}const oI=[{value:"all",label:Cd.all},{value:"worktree",label:Cd.worktree}],lI=e=>!!e.baseSha;function dI(e,a){return a==="all"?e:e.filter(lI)}const cI=[{value:"all",label:Pd.all},{value:"review",label:Pd.review}],uI=new Set;function mI(e,a=[]){const n=new Set;for(const i of e)i.specId&&Ar(i,uI)==="waiting"&&n.add(i.specId);for(const i of a)i.stage==="done"&&i.baseSha&&!i.reviewedAt&&n.add(i.id);return n}function hI(e,a,n){return a==="all"?e:e.filter(i=>n.has(i.id))}function pI({projectId:e,ownBranch:a,eyebrow:n,onClose:i,onIntegrate:r}){const[s,o]=d.useState({local:[],origin:[]}),[l,c]=d.useState(""),u=a;d.useEffect(()=>{let p=!0;return ne.listBranches(e).then(g=>{p&&o({local:g.branches.filter(f=>f!==u),origin:g.remotes.filter(f=>f!==u)})}).catch(()=>{p&&o({local:[],origin:[]})}),()=>{p=!1}},[e,u]);const m=[{value:"",label:"Pilih target…"},...s.local.map(p=>({value:`local:${p}`,label:`${p} (lokal)`})),...s.origin.map(p=>({value:`origin:${p}`,label:`origin/${p}`}))],h=p=>{l&&r(p,l)};return t.jsxs(da,{open:!0,title:"Rebase / Merge",eyebrow:`${n} · ${u}`,icon:"git-merge",onClose:i,children:[t.jsxs("div",{style:{fontSize:13,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:["Rebase menata ulang branch di atas target (force-push balik ke branch itu). Merge menggabungkan branch ke target. Bila ada konflik, sesi agen membereskannya di Terminal — agen, model & effort-nya diatur di ",t.jsx("b",{children:"Settings → Model sesi → Konflik rebase & merge"})," ","— selama kartu itu dinonaktifkan, ia mengikuti default global."]}),t.jsxs("div",{style:{marginBottom:16},children:[t.jsx("div",{className:"hn-eyebrow",style:{marginBottom:4},children:"Target"}),t.jsx($e,{size:"sm","aria-label":"Target",value:l,disabled:m.length===1,onChange:p=>c(p.target.value),options:m})]}),t.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"git-branch",disabled:!l,onClick:()=>h("rebase"),children:"Rebase"}),t.jsx(q,{size:"sm",variant:"primary",leftIcon:"git-merge",disabled:!l,onClick:()=>h("merge"),children:"Merge"})]})]})}function gI(e){return new Date(e.localUpdatedAt)>=new Date(e.serverUpdatedAt)?"local":"server"}function eo(e){if(e===void 0)return"(kosong)";const a=typeof e=="string"?`"${e}"`:JSON.stringify(e)??String(e);return a.length>80?`${a.slice(0,77)}…`:a}function Wh(e){const a=e.localData??{},n=e.serverData??{};return[...new Set([...Object.keys(a),...Object.keys(n)])].filter(r=>JSON.stringify(a[r])!==JSON.stringify(n[r]))}const kI={project:"Project",spec:"Item backlog",vps:"VPS",sessionResult:"Hasil sesi",ticket:"Tiket",ticketAttachment:"Lampiran tiket",customAgent:"Agen kustom",githubIssue:"Issue GitHub",member:"Anggota tim",task:"Tugas",qaReport:"Laporan QA",qaCase:"Kasus QA",qaFinding:"Temuan QA",qaAttachment:"Lampiran QA"},td=e=>kI[e]??"Data",bI={"still-conflict":"Server pusat bergeser lagi sebelum keputusan ini masuk. Coba lagi — datanya sudah disegarkan.","not-found":"Konflik ini sudah tidak ada di server pusat (mungkin sudah diselesaikan dari perangkat lain)."},fI="Server pusat menolak keputusan ini. Muat ulang daftar, lalu coba lagi.";function yI({open:e,onClose:a,onResolved:n}){const[i,r]=d.useState([]),[s,o]=d.useState(!1),[l,c]=d.useState(null),[u,m]=d.useState(null),[h,p]=d.useState(null),{confirm:g,dialog:f}=lt(),b=Date.now(),v=d.useCallback(async()=>{o(!0),c(null);try{r((await ne.listConflicts()).conflicts)}catch(S){r([]),c(ka("memuat daftar konflik",S))}finally{o(!1)}},[]);d.useEffect(()=>{e&&v()},[e,v]);async function x(S,E){const w=`${S.entity}:${S.recordId}`;m(w),p(null);try{const N=await ne.resolveConflict(S.entity,S.recordId,E);N.ok||p(bI[N.reason??""]??fI),await v(),N.ok&&n()}catch(N){p(ka("menghubungi server",N))}finally{m(null)}}function y(S,E){const w=E==="local"?"Lokal":"Server",N=E==="local"?"Server":"Lokal",R=(E==="local"?S.localData:S.serverData)??{},L=(E==="local"?S.serverData:S.localData)??{},I=Wh(S),B=I.length===0?["Tidak ada field yang berbeda antara kedua sisi."]:I.map(A=>`${A}: ${eo(L[A])} → ${eo(R[A])}`);g({title:`Pakai data ${w}?`,message:`Sisi ${N} di server pusat akan diganti dengan data ${w} untuk ${td(S.entity).toLowerCase()} ${S.recordId}.`,impact:B,eyebrow:"konflik sinkron",confirmLabel:`Pakai data ${w}`,tone:"danger",run:()=>x(S,E)}).catch(A=>p(ka("menyelesaikan konflik",A)))}const T=!s&&!l&&i.length===0;return t.jsxs(t.Fragment,{children:[t.jsxs(da,{open:e,title:"Konflik sinkron",eyebrow:"sinkronisasi",icon:"git-merge",width:720,onClose:()=>{u===null&&a()},children:[h&&t.jsx("div",{"data-testid":"resolve-error",role:"alert",className:"hn-reconcile-error",children:h}),s&&i.length===0&&t.jsx(he,{kind:"loading",compact:!0,title:"Memuat konflik…"}),l&&t.jsx(he,{kind:"error",compact:!0,title:"Daftar konflik gagal dimuat",hint:l,action:()=>{v()},actionLabel:"Coba lagi"}),T&&t.jsx(he,{kind:"empty",compact:!0,icon:"git-merge",title:"Tidak ada konflik",hint:"Data lokal dan server sudah sinkron."}),i.map(S=>{const E=gI(S),w=`${S.entity}:${S.recordId}`,N=Wh(S),R=S.localData??{},L=S.serverData??{};return t.jsxs("section",{className:"hn-reconcile-card","aria-label":`${td(S.entity)} ${S.recordId}`,children:[t.jsxs("div",{className:"hn-reconcile-head",children:[t.jsx("strong",{children:td(S.entity)}),t.jsx("span",{className:"hn-reconcile-id",children:S.recordId}),t.jsxs("span",{"data-testid":"default-side",className:"hn-reconcile-hint",children:["disarankan: ",E==="local"?"Lokal":"Server"," (diubah terakhir)"]})]}),t.jsxs("div",{className:"hn-reconcile-meta",children:[t.jsxs("span",{children:["Lokal v",S.localVersion," · ",vt(S.localUpdatedAt,b)||"—"]}),t.jsxs("span",{children:["Server v",S.serverVersion," · ",vt(S.serverUpdatedAt,b)||"—"]})]}),N.length===0?t.jsx("p",{className:"hn-reconcile-same",children:"Kedua sisi berisi data yang sama."}):t.jsxs("dl",{className:"hn-reconcile-fields","aria-label":"Field yang berbeda",children:[t.jsxs("div",{className:"hn-reconcile-field hn-reconcile-field-head","aria-hidden":"true",children:[t.jsx("dt",{children:"Field"}),t.jsx("dd",{children:"Lokal"}),t.jsx("dd",{children:"Server"})]}),N.map(I=>t.jsxs("div",{className:"hn-reconcile-field",children:[t.jsx("dt",{children:I}),t.jsxs("dd",{children:[t.jsx("span",{className:"hn-reconcile-side",children:"Lokal"}),t.jsx("code",{children:eo(R[I])})]}),t.jsxs("dd",{children:[t.jsx("span",{className:"hn-reconcile-side",children:"Server"}),t.jsx("code",{children:eo(L[I])})]})]},I))]}),t.jsxs("div",{className:"hn-reconcile-actions",children:[t.jsx(q,{size:"sm",variant:E==="local"?"primary":"secondary",disabled:u!==null,loading:u===w,onClick:()=>y(S,"local"),children:"Pakai Lokal"}),t.jsx(q,{size:"sm",variant:E==="server"?"primary":"secondary",disabled:u!==null,onClick:()=>y(S,"server"),children:"Pakai Server"})]})]},w)})]}),f]})}let nd=null;function vI(){const[e,a]=d.useState(!1);return d.useEffect(()=>{nd||(nd=(async()=>{var i;try{return((i=(await ne.getConfig()).sync)==null?void 0:i.running)??!1}catch{return!1}})());let n=!0;return nd.then(i=>{n&&a(i)}),()=>{n=!1}},[]),e}function xI({onDone:e,onToast:a}){const n=vI(),[i,r]=d.useState(""),[s,o]=d.useState(!1),[l,c]=d.useState(0),u=d.useCallback(()=>{ne.getSyncPending().then(h=>c(h.total)).catch(()=>c(0))},[]);if(d.useEffect(()=>{n&&u()},[n,u]),!n)return null;async function m(h){r(h?"full":"once");try{const p=h?await ne.syncNow({full:!0}):await ne.syncNow();p.ok?a(`Sinkron: ↓${p.pulled??0} ↑${p.pushed??0}`+(p.deleted?` ⨯${p.deleted}`:"")+(p.conflicts?` · ${p.conflicts} konflik`:""),p.conflicts?"warn":"ok",p.conflicts?"triangle-alert":"check"):a("Instance ini hub — tak ada sync manual","info","info"),p.ok&&p.conflicts&&o(!0),e(),u()}catch{a("Gagal sync","err","x-circle")}finally{r("")}}return t.jsxs(t.Fragment,{children:[t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"rotate-ccw",onClick:()=>m(!1),disabled:i!=="",children:i==="once"?"Menyinkron…":"Sync"}),t.jsx(q,{size:"sm",variant:"ghost",leftIcon:"history",onClick:()=>m(!0),disabled:i!=="",title:"Tarik ulang seluruh feed dari awal — untuk data lama yang tak ikut tersinkron",children:i==="full"?"Menarik ulang…":"Tarik ulang"}),l>0&&t.jsxs("span",{className:"hn-muted",style:{fontSize:12},title:"Penghapusan sudah tercatat di mesin ini dan akan menyeberang ke hub pada sync berikutnya",children:[l," hapus menunggu"]}),t.jsx(yI,{open:s,onClose:()=>o(!1),onResolved:e})]})}const Vh={qa:{label:zi.qa,icon:"bug",tone:"err",color:"var(--clay-500)"},audit:{label:zi.audit,icon:"search",tone:"info",color:"var(--wind-600)"},brief:{label:zi.brief,icon:"lightbulb",tone:"brass",color:"var(--brass-500)"},goal:{label:zi.goal,icon:"target",tone:"brass",color:"var(--brass-700)"},help:{label:zi.help,icon:"life-buoy",tone:"info",color:"var(--wind-500)"},no_effort:{label:zi.no_effort,icon:"zap",tone:"brass",color:"var(--brass-400)"}},ai=e=>Vh[e]??Vh.brief,jI=br.options.map(e=>({value:e,label:ai(e).label})),wI=[["context","Konteks","mis. operator harus membuka tiga layar untuk tahu sesi mana yang menunggu"],["outcome","Outcome","mis. satu badge di Overview menunjukkan jumlah sesi yang menunggu"],["constraints","Batasan","mis. reuse queue yang ada"]],SI=[["goal","Goal","mis. p95 GET /api/specs di bawah 200 ms"],["done","Selesai bila","mis. output benchmark menunjukkan < 200 ms"],["constraints","Batasan","mis. tanpa cache eksternal"]],_I=[["severity","Severity",""],["steps","Langkah reproduksi",`1. Buka …
|
|
1009
1009
|
2. Lakukan …
|
|
1010
|
-
3. Amati …`],["expected","Diharapkan","mis. total funnel sama dengan jumlah baris laporan harian"],["actual","Aktual","mis. total funnel dua kali lipat untuk sesi yang melewati tengah malam"],["env","Environment","prod · web · v0.9.2"],["constraints","Batasan","mis. jangan ubah kontrak API"]],tc={brief:wI,qa:_I,goal:SI},nc=[{value:"tinggi",label:ms.tinggi},{value:"sedang",label:ms.sedang},{value:"rendah",label:ms.rendah}],df=[{value:"critical",label:Tl.critical},{value:"major",label:Tl.major},{value:"minor",label:Tl.minor}];function AI({spec:e,onClose:a,onSubmit:n}){var E;const i=e.stage!=="brainstorming"||e.baseSha!=null,r=jI.filter(w=>w.value!==e.source),[s,o]=d.useState(((E=r[0])==null?void 0:E.value)??""),l=i&&ur(s)!==ur(e.source),c=i&&!l,u=d.useMemo(()=>wy(s,e.payload),[s,e.payload]),[m,h]=d.useState(()=>u.payload),[p,g]=d.useState(null),[f,b]=d.useState(!1);d.useEffect(()=>{h(u.payload),g(null)},[s]);const v=w=>N=>h(R=>({...R,[w]:N.target.value})),x=Ti(s),y=tc[x]??[],T=w=>{var N;return((N=(tc[dc(e.payload)]??[]).find(([R])=>R===w))==null?void 0:N[1])??w};async function S(w){if(!f){b(!0);try{const N=await n(s,c?void 0:{...m},w);N&&N.pending?g(N):a()}finally{b(!1)}}}return p?t.jsxs(da,{open:!0,title:"Item ini akan dikembalikan ke Brainstorming",icon:"rotate-ccw",eyebrow:`${e.id} · ${ai(e.source).label} → ${ai(s).label}`,onClose:f?void 0:a,children:[t.jsxs("div",{className:"hn-dia-lead hn-dia-lead-sm",children:["Alur kerja ",ai(s).label," berbeda dari yang sudah dikerjakan, jadi item ini mulai lagi dari awal. Kode yang sudah ter-commit di branch lain tak disentuh."]}),t.jsxs("ul",{"data-testid":"source-reset-impact",className:"hn-dia-impact",children:[p.wouldDelete.map(w=>t.jsx("li",{children:w},w)),p.worktree&&t.jsx("li",{children:p.worktree}),p.branch&&t.jsx("li",{children:p.branch}),!p.wouldDelete.length&&!p.worktree&&!p.branch&&t.jsx("li",{children:"tak ada berkas yang perlu dibuang — hanya tahapnya yang mundur"})]}),t.jsxs("div",{className:"hn-dia-foot",children:[t.jsx(q,{size:"sm",variant:"secondary",disabled:f,onClick:a,children:"Batal"}),t.jsx(q,{size:"sm",variant:"danger",leftIcon:"rotate-ccw",loading:f,onClick:()=>S(!0),children:"Reset & ubah type"})]})]}):t.jsxs(da,{open:!0,title:"Ubah type backlog item",icon:"shuffle",eyebrow:`${e.id} · ${ai(e.source).label}`,onClose:a,children:[t.jsx(oe,{label:"Type tujuan",children:t.jsx($e,{"aria-label":"Type tujuan",value:s,onChange:w=>o(w.target.value),options:r,className:"hn-dia-full"})}),!r.length&&t.jsx("div",{className:"hn-dia-note",children:"Tak ada type lain yang bisa dituju. Dialog tetap terbuka dan mengatakannya — menolak dengan diam adalah bug yang melahirkan ADR-0149."}),c?t.jsxs("div",{className:"hn-dia-note",children:["Item ini sudah pernah dikerjakan sesi, dan type tujuannya memakai alur kerja yang sama — yang berpindah hanya ",t.jsx("strong",{children:"labelnya"}),". Isi, worktree, dan berkas fase tak disentuh."]}):t.jsxs(t.Fragment,{children:[l&&t.jsxs("div",{"data-testid":"source-reset-warning",className:"hn-dia-box",children:[t.jsx(oa,{tone:"warn",size:"sm",children:"alur kerja berbeda"})," ","Item ini akan kembali ke tahap ",t.jsx("strong",{children:"Brainstorming"}),"; dokumen fase, worktree, dan branch sesi lamanya dihapus. Daftar persisnya ditampilkan sebelum kamu menyetujui."]}),u.dropped.length>0&&t.jsxs("div",{"data-testid":"source-dropped",className:"hn-dia-box hn-dia-box-muted",children:[t.jsx(oa,{tone:"warn",size:"sm",children:"tak punya padanan"})," ",u.dropped.map(T).join(", ")," tidak ada di bentuk"," ",ai(s).label,". Teks lamanya tetap tersimpan di"," ",t.jsx("strong",{children:"jejak konversi"})," item ini."]}),x!=="qa"&&t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{"aria-label":"Prioritas",value:m.priority??"sedang",onChange:v("priority"),options:nc,className:"hn-dia-full"})}),y.map(([w,N,R])=>t.jsx(oe,{label:N,children:w==="severity"?t.jsx($e,{"aria-label":N,value:m[w]??"minor",onChange:v(w),options:df,className:"hn-dia-full"}):t.jsx(Ia,{"aria-label":N,value:m[w]??"",onChange:v(w),rows:2,placeholder:R})},w))]}),t.jsxs("div",{className:"hn-dia-foot hn-dia-foot-tight",children:[t.jsx(q,{size:"sm",variant:"secondary",onClick:a,children:"Batal"}),t.jsx(q,{size:"sm",variant:"primary",leftIcon:"shuffle",loading:f,disabled:!r.length,onClick:()=>S(),children:"Ubah type"})]})]})}const Yh=280;function cf({spec:e,onClose:a,onSubmit:n}){const[i,r]=d.useState(""),[s,o]=d.useState(null),[l,c]=d.useState(!1),u=d.useRef(!1);async function m(){if(!u.current){u.current=!0,c(!0);try{const h=await n(e,i.trim(),s!==null);if(h&&"needConfirm"in h){o(h.sessionId??"");return}h&&a()}finally{u.current=!1,c(!1)}}}return t.jsxs(da,{open:!0,title:"Tandai selesai",icon:"circle-check",eyebrow:e.id+" · "+e.projectId,onClose:l?void 0:a,children:[t.jsx("div",{style:{fontSize:13,color:"var(--text-muted)",lineHeight:1.55,marginBottom:14},children:"Item keluar dari daftar siap-kerja dan berstatus selesai — sama seperti item yang selesai lewat sesi. Kode, commit, dan dokumen tidak disentuh, dan status ini masih bisa dikembalikan lewat “Ubah status”."}),s!==null&&t.jsxs("div",{"data-testid":"mark-done-live",style:{border:"1px solid var(--border-hair)",borderRadius:"var(--radius-sm)",background:"var(--bone-100)",padding:10,marginBottom:14,fontSize:12.5,color:"var(--text-strong)",lineHeight:1.5},children:["Masih ada sesi yang berjalan untuk item ini",s?` (${s})`:"",". Menandainya selesai tidak menghentikan sesi itu — tutup sesinya dari Terminal bila memang sudah tak dibutuhkan."]}),t.jsx(oe,{label:"Alasan singkat (opsional)",hint:`${i.trim().length}/${Yh} — mis. “sudah ter-merge lewat PR #12”`,children:t.jsx(Ia,{"aria-label":"Alasan singkat (opsional)",rows:2,value:i,maxLength:Yh,disabled:l,onChange:h=>r(h.target.value),placeholder:"sudah dikerjakan langsung di checkout"})}),t.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[t.jsx(q,{size:"sm",variant:"secondary",disabled:l,onClick:a,children:"Batal"}),t.jsx(q,{size:"sm",variant:"primary",leftIcon:"circle-check",loading:l,onClick:m,children:s!==null?"Tandai selesai — sesi tetap berjalan":"Tandai selesai"})]})]})}const kn=[{key:"brainstorming",label:"Brainstorm"},{key:"objective",label:"Objective"},{key:"spec-ready",label:"Spec"},{key:"planned",label:"Plan"},{key:"executing",label:"Execute"},{key:"done",label:"Done"}],uf=e=>kn.findIndex(a=>a.key===e),mf={brainstorming:"Brainstorm: ide digali bersama agen sebelum tujuan dikunci",objective:"Objective: tujuan terukur dikunci sebelum spec ditulis","spec-ready":"Spec: dokumen spesifikasi ditulis",planned:"Plan: rencana langkah disusun",executing:"Execute: kode dikerjakan di worktree sesi",done:"Done: item selesai"},lr=[{key:"all",label:"Semua",stages:kn.map(e=>e.key)},{key:"brainstorm",label:"Brainstorm",stages:["brainstorming","objective"]},{key:"spec",label:"Spec",stages:["spec-ready","planned"]},{key:"doing",label:"Dikerjakan",stages:["executing"]},{key:"done",label:"Selesai",stages:["done"]}],Jh=(e,a)=>{var n;return a==="all"||(((n=lr.find(i=>i.key===a))==null?void 0:n.stages.includes(e))??!1)},hf=e=>{var a;return((a=lr.find(n=>n.key!=="all"&&n.stages.includes(e)))==null?void 0:a.label)??e},pf={brainstorming:"idle",objective:"idle","spec-ready":"queued",planned:"queued",executing:"running",done:"done"},EI=e=>e==="brainstorming"?"Mulai":"Lanjutkan",Qh={tinggi:{tone:"brass",label:ms.tinggi,level:"high"},sedang:{tone:"neutral",label:ms.sedang,level:"mid"},rendah:{tone:"neutral",label:ms.rendah,level:"low"}},Ho=e=>Qh[e]??Qh.sedang,Zh=[{value:"all",label:"Semua sumber"},{value:"brief",label:"Dari brief"},{value:"qa",label:"Dari QA"},{value:"audit",label:"Audit"},{value:"goal",label:"Goal"},{value:"help",label:"Help Center"},{value:"no_effort",label:"Tanpa effort"}],TI=[{value:"all",label:"Semua prioritas"},{value:"tinggi",label:"Tinggi"},{value:"sedang",label:"Sedang"},{value:"rendah",label:"Rendah"}],Xh={audit:"Audit: hasil pemeriksaan project. Dari sini bisa dinaikkan jadi Finding QA, feature brief, atau PRD.",goal:"Goal: item dengan tujuan terukur. Dikerjakan dua fase (Goal lalu Verifikasi) tanpa tahap perencanaan.",no_effort:"Tanpa effort: tugas remeh yang dikerjakan satu fase, tanpa perencanaan maupun verifikasi."},gf=e=>e==="missing"?"tak ditemukan":e==="unmerged"?"belum ter-merge":"belum selesai";function mu({spec:e}){const a=e.blockedBy??[];return a.length?t.jsx(oa,{tone:"warn",size:"sm",icon:"lock",title:a.map(n=>`${n.id} — ${gf(n.reason)}`).join(" · "),children:"Terblokir"}):null}function hu({priority:e,stage:a}){const n=Ho(e),i=a?pf[a]??"idle":void 0,r=a?hf(a):null;return t.jsx("span",{className:`hn-bl-prio hn-bl-prio-${n.level}`,"data-status":i,title:r?`Prioritas ${n.label} · Status ${r}`:`Prioritas ${n.label}`,children:t.jsxs("span",{className:"hn-sr-only",children:["Prioritas ",n.label,r?`, status ${r}`:""]})})}function kf({source:e}){const a=ai(e);return t.jsxs("span",{className:"hn-bl-source",children:[t.jsx(Re,{name:a.icon,size:12,color:a.color}),a.label]})}function bf({stage:e}){return t.jsx(ht,{status:pf[e]??"idle",size:"sm",variant:"dot",className:"hn-bl-stage-pill",title:mf[e],children:hf(e)})}function CI({stage:e}){var i;const a=uf(e),n=((i=kn[a])==null?void 0:i.label)??e;return t.jsx("div",{role:"progressbar","aria-label":`Status ${n}`,"aria-valuemin":0,"aria-valuemax":kn.length-1,"aria-valuenow":Math.max(a,0),"aria-valuetext":n,className:"hn-bl-stagebar",children:kn.map((r,s)=>{const o=s<a||e==="done",l=s===a&&e!=="done",c=o?"done":l?"active":"todo";return t.jsxs("span",{className:"hn-bl-stage","data-state":c,title:mf[r.key],children:[t.jsx("span",{className:"hn-bl-stage-dot","aria-hidden":"true"}),l&&t.jsx("span",{className:"hn-bl-stage-label",children:r.label})]},r.key)})})}function ep({label:e,value:a}){return t.jsxs("div",{className:"hn-bl-field",children:[t.jsx("div",{className:"hn-eyebrow",children:e}),t.jsx("div",{className:"hn-bl-field-value",children:a||"—"})]})}const PI={qa:"Finding QA — ada yang perlu diperbaiki.",brief:"Feature brief — kebutuhan yang bentuknya sudah jelas.",prd:"PRD — kebutuhan produk yang perlu didefinisikan dulu."},id=(e,a)=>e&&e.target===a?"primary":"secondary",ap=e=>e==="audit";function MI({spec:e,onClose:a,onEditBranch:n,onRevertStage:i,onMarkDone:r,onOpenReview:s,onStart:o,onIntegrate:l,onEditSpec:c,onPromoteToQa:u,onPromoteToBrief:m,onPromoteToPrd:h,onEditDeps:p,onEditAutoMerge:g,onChangeSource:f,onRequestDelete:b,onUndoable:v,projectPolicy:x,allSpecs:y,onAttachmentToast:T,running:S,onOpenRun:E,projectName:w,presenceOn:N}){var dt,qa,Xe;const[R,L]=d.useState([]),[I,B]=d.useState(new Set),[A,M]=d.useState(null),[K,O]=d.useState(""),[J,Z]=d.useState(!1),[H,te]=d.useState(!1),ae=d.useRef(!1),[F,fe]=d.useState(!1),[_e,ee]=d.useState(!1),[X,ce]=d.useState(!1),[se,Ce]=d.useState(!1),[Te,le]=d.useState({}),ya=(e==null?void 0:e.stage)==="brainstorming"&&(e==null?void 0:e.baseSha)==null&&!!c&&e.payload!==void 0,Ze=()=>{if(!e)return;const ge=e.payload||{};le({title:e.title,priority:e.priority,...ge}),Ce(!0)},He=ge=>be=>le(ua=>({...ua,[ge]:be.target.value})),[Ke,ga]=d.useState(null),Ge=e&&ap(e.source)?e.id:null;d.useEffect(()=>{var be;if(ga(null),!Ge)return;let ge=!0;return(be=ne.getEscalation)==null||be.call(ne,Ge).then(ua=>{ge&&ga(ua.escalation)}).catch(()=>{ge&&ga(null)}),()=>{ge=!1}},[Ge]);const ba=()=>{if(!e||!c)return;const ge=e.source==="qa"?{title:Te.title,payload:{severity:Te.severity,steps:Te.steps,expected:Te.expected,actual:Te.actual,env:Te.env,constraints:Te.constraints??""}}:Ti(e.source)==="goal"?{title:Te.title,priority:Te.priority,payload:{goal:Te.goal,done:Te.done??"",constraints:Te.constraints??"",priority:Te.priority}}:{title:Te.title,priority:Te.priority,payload:{context:Te.context,outcome:Te.outcome,constraints:Te.constraints,priority:Te.priority}};c(e,ge),Ce(!1)},Ta=ge=>{if(!e||!c||ge===e.priority)return;const be=e.priority;c(e,{priority:ge}),v==null||v(`Prioritas ${e.id} diubah ke ${Ho(ge).label}`,()=>c(e,{priority:be}))},va=e==null?void 0:e.projectId;d.useEffect(()=>{if(!va){L([]),B(new Set);return}let ge=!0;return ne.listBranches(va).then(be=>{if(ge){const ua=[...new Set([...be.branches,...be.remotes])].sort();L(ua),B(new Set(be.remotes.filter(Da=>!be.branches.includes(Da))))}}).catch(()=>{ge&&(L([]),B(new Set))}),()=>{ge=!1}},[va]),d.useEffect(()=>{K&&O(""),A&&M(null)},[e==null?void 0:e.id,e==null?void 0:e.stage]);async function we(ge){if(!ae.current){ae.current=!0,te(!0);try{return await ge()}finally{ae.current=!1,te(!1)}}}async function Je(){if(!e||!i||!K)return;const ge=await we(()=>i(e,K));ge&&ge.pending?M({target:K,files:ge.wouldDelete}):ge&&O("")}async function U(){if(!e||!i||!A)return;await we(()=>i(e,A.target,!0))&&(M(null),O(""))}function Be(){A||ae.current||(Ce(!1),a())}if(!e)return null;const ue=kn.slice(0,uf(e.stage)),We=((dt=kn.find(ge=>ge.key===e.stage))==null?void 0:dt.label)??e.stage,sa=((qa=kn.find(ge=>ge.key===K))==null?void 0:qa.label)??K,ye=e.source==="qa",la=Ti(e.source),Se=e.payload||{},xe=(y??[]).filter(ge=>ge.projectId===e.projectId&&ge.id!==e.id),aa=tc[la],Ea=ai(e.source);return t.jsxs(da,{open:!0,title:e.title,eyebrow:e.id,icon:Ea.icon,onClose:Be,width:600,children:[t.jsxs("div",{className:"hn-bl-detail",children:[t.jsxs("section",{className:"hn-bl-section","aria-labelledby":"bl-sec-ringkasan",children:[t.jsx("h3",{id:"bl-sec-ringkasan",className:"hn-bl-section-title",children:"Ringkasan"}),t.jsxs("div",{className:"hn-bl-summary-meta",children:[t.jsx(bf,{stage:e.stage}),t.jsxs("span",{className:"hn-bl-prio-text",children:[t.jsx(hu,{priority:e.priority}),Ho(e.priority).label]}),t.jsx(mu,{spec:e}),t.jsx(dl,{names:N})]}),t.jsx(CI,{stage:e.stage}),se?t.jsx(oe,{label:"Judul",children:t.jsx(Oe,{value:Te.title??"",onChange:He("title"),placeholder:"mis. Jadwal invoice berulang",className:"hn-bl-full"})}):t.jsx(ep,{label:"Tujuan",value:e.objective}),t.jsxs("dl",{className:"hn-bl-facts",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Project"}),t.jsx("dd",{children:w??e.projectId})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Penulis"}),t.jsx("dd",{children:e.author||"—"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Dibuat"}),t.jsx("dd",{children:II(e.createdAt)||"—"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Branch asal"}),t.jsx("dd",{children:e.branchFrom||"—"})]})]}),ya&&!se&&t.jsxs("div",{className:"hn-bl-inline-row",children:[t.jsx($e,{size:"sm","aria-label":"Prioritas item ini",value:e.priority,onChange:ge=>Ta(ge.target.value),options:nc}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"pencil",onClick:Ze,children:"Edit"})]}),se?t.jsxs(t.Fragment,{children:[!ye&&t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{value:Te.priority??"sedang",onChange:He("priority"),options:nc,className:"hn-bl-full"})}),aa.map(([ge,be,ua])=>t.jsx(oe,{label:be,children:ge==="severity"?t.jsx($e,{value:Te[ge]??"major",onChange:He(ge),options:df,className:"hn-bl-full"}):t.jsx(Ia,{value:Te[ge]??"",onChange:He(ge),rows:2,placeholder:ua})},ge)),t.jsxs("div",{className:"hn-bl-inline-row hn-bl-end",children:[t.jsx(q,{size:"sm",variant:"secondary",onClick:()=>Ce(!1),children:"Batal"}),t.jsx(q,{size:"sm",variant:"primary",leftIcon:"check",onClick:ba,children:"Simpan"})]})]}):aa.map(([ge,be])=>t.jsx(ep,{label:be,value:Se[ge]??""},ge)),e.manualDone&&t.jsxs("div",{className:"hn-bl-field","data-testid":"manual-done-trail",children:[t.jsx("div",{className:"hn-eyebrow",children:"Ditandai selesai manual"}),t.jsxs("div",{className:"hn-bl-field-value hn-bl-muted",children:[e.manualDone.by," · ",new Date(e.manualDone.at).toLocaleString("id-ID"),e.manualDone.reason?t.jsx("div",{className:"hn-bl-gap-top",children:e.manualDone.reason}):null]})]})]}),t.jsxs("div",{className:"hn-bl-cta",children:[S&&E&&t.jsx(q,{variant:"primary",leftIcon:"terminal",onClick:()=>E(e),children:"Buka sesi"}),!S&&o&&t.jsx(q,{variant:"primary",leftIcon:"play",onClick:()=>o(e),children:"Jalankan"}),e.stage==="done"&&t.jsx("span",{className:"hn-bl-hint",children:"Sesi baru melanjutkan sisa kerja item ini."})]}),t.jsxs("section",{className:"hn-bl-section","aria-labelledby":"bl-sec-review",children:[t.jsx("h3",{id:"bl-sec-review",className:"hn-bl-section-title",children:"Review, dokumen, dan lampiran"}),t.jsxs("div",{className:"hn-bl-inline-row",children:[s&&t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"git-compare",onClick:()=>{s(e),a()},children:"Review perubahan"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"file-text",onClick:()=>ee(!0),children:"Lihat dokumen"})]}),ap(e.source)&&(u||m||h)&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Tindak lanjut"}),Ke&&t.jsxs("div",{className:"hn-bl-hint",children:[Ke.target==="none"?t.jsxs("span",{children:["Audit menilai ",t.jsx("strong",{children:"cukup jawaban"})," — tak perlu perbaikan."]}):t.jsxs("span",{children:[t.jsx(oa,{tone:"brass",size:"sm",children:"direkomendasikan hanoman"})," ",PI[Ke.target]]}),Ke.reason?t.jsx("div",{className:"hn-bl-gap-top",children:Ke.reason}):null]}),t.jsxs("div",{className:"hn-bl-inline-row",children:[u&&t.jsx(q,{size:"sm",variant:id(Ke,"qa"),leftIcon:"bug",onClick:()=>u(e,Ke),children:"Jadikan Finding QA"}),m&&t.jsx(q,{size:"sm",variant:id(Ke,"brief"),leftIcon:"lightbulb",onClick:()=>m(e,Ke),children:"Jadikan Feature brief"}),h&&t.jsx(q,{size:"sm",variant:id(Ke,"prd"),leftIcon:"scroll-text",onClick:()=>h(e,Ke),children:"Jadikan PRD"})]})]}),t.jsx(iT,{specId:e.id,onToast:T??(()=>{})})]}),t.jsxs("details",{className:"hn-bl-advanced","data-testid":"spec-advanced",children:[t.jsx("summary",{children:"Lanjutan"}),t.jsxs("div",{className:"hn-bl-advanced-body",children:[t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Branch worktree"}),t.jsx($e,{size:"sm",value:e.branchFrom??"",disabled:!R.length,onChange:ge=>n&&n(e,ge.target.value||null),options:cb(R,I)})]}),t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Bergantung pada"}),(e.dependsOn??[]).length===0?t.jsx("div",{className:"hn-bl-hint",children:"— berdiri sendiri"}):t.jsx("div",{className:"hn-bl-stack-list",children:(e.dependsOn??[]).map(ge=>{const be=(e.blockedBy??[]).find(ua=>ua.id===ge);return t.jsxs("div",{className:"hn-bl-dep",children:[t.jsx("span",{className:"hn-bl-id",children:ge}),be?t.jsx(oa,{tone:"warn",size:"sm",children:gf(be.reason)}):t.jsx(oa,{tone:"ok",size:"sm",icon:"check",children:"selesai & ter-merge"})]},ge)})}),p&&xe.length>0&&t.jsx("div",{className:"hn-bl-checklist",children:xe.map(ge=>{const be=(e.dependsOn??[]).includes(ge.id);return t.jsx(vs,{"aria-label":`Bergantung pada ${ge.id}`,checked:be,label:`${ge.id} · ${ge.title}`,onChange:()=>p(e,be?(e.dependsOn??[]).filter(ua=>ua!==ge.id):[...e.dependsOn??[],ge.id])},ge.id)})})]}),g&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Auto-merge saat selesai"}),t.jsx($e,{size:"sm","aria-label":"Auto-merge item ini",value:e.autoMerge?e.autoMerge.mode:"inherit",onChange:ge=>{var ua;const be=ge.target.value;if(be==="inherit")return g(e,null);if(be==="off")return g(e,{...ls});g(e,{...e.autoMerge??ls,mode:be,branch:be==="branch"?((ua=e.autoMerge)==null?void 0:ua.branch)??R[0]??null:null})},options:[{value:"inherit",label:`Ikut project (${Ip(Ny(x,null))})`},{value:"off",label:"Tanpa auto-merge untuk item ini"},{value:"default-branch",label:"Auto-merge ke default branch repo"},{value:"branch",label:"Auto-merge ke branch tujuan…"}]}),((Xe=e.autoMerge)==null?void 0:Xe.mode)==="branch"&&t.jsx("div",{className:"hn-bl-gap-top",children:t.jsx($e,{size:"sm","aria-label":"Branch tujuan item ini",value:e.autoMerge.branch??"",onChange:ge=>g(e,{...e.autoMerge,branch:ge.target.value||null}),options:[{value:"",label:"Pilih branch…"},...R.map(ge=>({value:ge,label:ge}))]})})]}),(i||r)&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Ubah status"}),t.jsx("div",{className:"hn-bl-status-now",children:`Status saat ini: ${We}`}),e.stage!=="done"&&r&&t.jsx("div",{className:"hn-bl-gap-bottom",children:t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"circle-check",onClick:()=>Z(!0),children:"Tandai selesai"})}),i?ue.length>0?t.jsxs(t.Fragment,{children:[t.jsx($e,{size:"sm","aria-label":"Kembalikan stage",value:K,onChange:ge=>O(ge.target.value),disabled:H,placeholder:"Pilih status lebih awal…",options:ue.map(ge=>({value:ge.key,label:"← "+ge.label}))}),t.jsx("div",{className:"hn-bl-hint hn-bl-gap-top",children:"Status saat ini dan status berikutnya tidak dapat dipilih. Kemajuan hanya berasal dari fase sesi."}),K&&t.jsxs("div",{className:"hn-bl-callout",children:[t.jsxs("div",{className:"hn-bl-callout-title",children:[We," → ",sa]}),"Fase sesi yang sudah berjalan tidak dibatalkan. Dokumen Spec/Plan di atas target mungkin perlu dihapus setelah konfirmasi; kode dan commit tidak disentuh."]}),t.jsx("div",{className:"hn-bl-gap-top",children:t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"rotate-ccw",disabled:!K,loading:H,onClick:Je,children:"Simpan status"})})]}):t.jsxs("div",{className:"hn-bl-hint",children:[We," adalah status paling awal. Kemajuan hanya berasal dari fase sesi."]}):null]}),e.stage==="done"&&l&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Integrasi"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"git-merge",onClick:()=>fe(!0),children:"Rebase / Merge"})]}),f&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Type"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"shuffle",onClick:()=>ce(!0),children:"Ubah type"})]}),(e.sourceHistory??[]).length>0&&t.jsxs("div",{className:"hn-bl-subsection","data-testid":"source-trail",children:[t.jsx("div",{className:"hn-eyebrow",children:"Jejak konversi type"}),t.jsx("div",{className:"hn-bl-stack-list",children:(e.sourceHistory??[]).map((ge,be)=>t.jsxs("div",{className:"hn-bl-trail",children:[t.jsxs("span",{className:"hn-bl-id",children:[ge.from," → ",ge.to]})," · ",new Date(ge.at).toLocaleString("id-ID")," · ",ge.by]},`${ge.at}-${be}`))})]})]})]}),b&&t.jsxs("section",{className:"hn-bl-danger","aria-labelledby":"bl-sec-bahaya",children:[t.jsx("h3",{id:"bl-sec-bahaya",className:"hn-bl-section-title",children:"Zona berbahaya"}),t.jsx("div",{className:"hn-bl-hint",children:"Menghapus item tak bisa dibatalkan. Kode dan commit di repo tidak disentuh."}),t.jsx("div",{className:"hn-bl-gap-top",children:t.jsx(q,{size:"sm",variant:"danger",leftIcon:"trash-2",onClick:()=>b(e),children:"Hapus spec"})})]})]}),A&&t.jsxs(da,{open:!0,title:"Kembalikan status & hapus dokumen fase",icon:"rotate-ccw",eyebrow:e.id+" → "+A.target,onClose:H?void 0:()=>M(null),children:[t.jsxs("div",{className:"hn-bl-confirm-lead",children:[A.files.length," berkas docs akan dihapus dari disk (kode & commit tak disentuh):"]}),t.jsx("ul",{className:"hn-bl-file-list",children:A.files.map(ge=>t.jsx("li",{children:ge},ge))}),t.jsxs("div",{className:"hn-bl-inline-row hn-bl-end",children:[t.jsx(q,{size:"sm",variant:"secondary",disabled:H,onClick:()=>M(null),children:"Batal"}),t.jsx(q,{size:"sm",variant:"danger",leftIcon:"trash-2",loading:H,onClick:U,children:"Hapus & kembalikan"})]})]}),F&&l&&t.jsx(pI,{projectId:e.projectId,ownBranch:`hanoman/${e.id.toLowerCase().replace(/[^a-z0-9_-]/g,"_")}`,eyebrow:e.id,onClose:()=>fe(!1),onIntegrate:(ge,be)=>{fe(!1),l(e,ge,be)}}),J&&r&&t.jsx(cf,{spec:e,onClose:()=>Z(!1),onSubmit:r}),_e&&t.jsx(ou,{specId:e.id,onClose:()=>ee(!1)}),X&&f&&e.payload!==void 0&&t.jsx(AI,{spec:e,onClose:()=>ce(!1),onSubmit:(ge,be,ua)=>Promise.resolve(f(e,ge,be,ua)??null)})]})}function ff({spec:e,onStart:a,onDelete:n,onOpenRun:i,onOpenReview:r,onMarkDone:s,onMarkReviewed:o,running:l}){const[c,u]=d.useState(!1),[m,h]=d.useState(!1),p=e.stage!=="done",g=l?i?{label:"Buka sesi",icon:"terminal",run:()=>i(e)}:null:p?a?{label:EI(e.stage),icon:"play",run:()=>a(e)}:null:r?{label:"Review perubahan",icon:"git-compare",run:()=>r(e)}:null,b=[...!!r&&(g==null?void 0:g.label)!=="Review perubahan"&&r?[{key:"review",label:"Review perubahan",icon:"git-compare",onSelect:()=>r(e)}]:[],{key:"docs",label:"Lihat dokumen",icon:"file-text",onSelect:()=>u(!0)},...!p&&a?[{key:"rerun",label:"Jalankan lagi",icon:"play",onSelect:()=>a(e)}]:[],...p&&s?[{key:"done",label:"Tandai selesai",icon:"circle-check",onSelect:()=>h(!0)}]:[],...!p&&o?[{key:"reviewed",label:e.reviewedAt?"Batalkan tanda ditinjau":"Tandai ditinjau",icon:e.reviewedAt?"rotate-ccw":"circle-check",onSelect:()=>void o(e,!e.reviewedAt)}]:[],...n?[{key:"delete",label:"Hapus spec",icon:"trash-2",tone:"danger",onSelect:()=>n(e)}]:[]];return t.jsxs("div",{className:"hn-bl-actions",children:[g&&t.jsx(q,{size:"sm",variant:g.label==="Review perubahan"?"secondary":"primary",leftIcon:g.icon,onClick:g.run,children:g.label}),t.jsx(rn,{label:`Aksi lain ${e.id}`,items:b}),m&&s&&t.jsx(cf,{spec:e,onClose:()=>h(!1),onSubmit:s}),c&&t.jsx(ou,{specId:e.id,onClose:()=>u(!1)})]})}const II=e=>{const a=e?new Date(e):null;return a&&!Number.isNaN(a.getTime())?a.toLocaleDateString("id-ID",{day:"numeric",month:"short",year:"numeric"}):""};function NI({spec:e,onOpenDetail:a,className:n="hn-bl-title"}){return t.jsx("button",{type:"button",className:n,onClick:()=>a&&a(e),children:e.title})}function RI({spec:e,presenceOn:a,onOpenDetail:n,projectName:i,...r}){return t.jsxs(an,{onClick:n?()=>n(e):void 0,actions:t.jsx(ff,{spec:e,...r}),children:[t.jsx(hu,{priority:e.priority,stage:e.stage}),t.jsxs("span",{className:"hn-bl-row-body",children:[t.jsx("span",{className:"hn-bl-row-title",children:e.title}),t.jsxs("span",{className:"hn-bl-row-meta",children:[t.jsx("span",{className:"hn-bl-id",children:e.id}),i&&t.jsx("span",{className:"hn-bl-proj",title:`Project: ${i}`,children:i}),t.jsx(kf,{source:e.source}),t.jsx(bf,{stage:e.stage}),t.jsx(mu,{spec:e}),t.jsx(dl,{names:a})]})]})]})}const cl="backlog",yf="success",LI=kn[0].key,tp=[{key:cl,label:"Backlog",icon:"inbox"},...kn.slice(0,5).map(e=>({key:e.key,label:e.label})),{key:yf,label:"Success",icon:"check-circle-2"}];function BI(e,a){return e.stage==="done"?yf:!a&&e.stage==="brainstorming"?cl:e.stage}const np=(e,a)=>e===cl&&a===LI;function $I({spec:e,col:a,onOpenDetail:n,presenceOn:i,projectName:r,onDragStart:s,onDragEnd:o,dragging:l,...c}){const u=a===cl;return t.jsxs("div",{draggable:u,className:"hn-bl-card","data-dragging":l||void 0,onDragStart:m=>{m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",e.id),s()},onDragEnd:o,title:u?"Seret ke Brainstorm untuk memulai sesi":"Stage mengikuti fase yang dilaporkan agen — kartu tak bisa dipindah","data-draggable":u||void 0,children:[t.jsxs("div",{className:"hn-bl-card-head",children:[t.jsx(hu,{priority:e.priority,stage:e.stage}),t.jsx("span",{className:"hn-bl-id",children:e.id}),t.jsx(kf,{source:e.source})]}),t.jsx(NI,{spec:e,onOpenDetail:n}),r&&t.jsx("span",{className:"hn-bl-proj",title:`Project: ${r}`,children:r}),(e.blockedBy??[]).length>0||i!=null&&i.length?t.jsxs("div",{className:"hn-bl-card-badges",children:[t.jsx(mu,{spec:e}),t.jsx(dl,{names:i})]}):null,t.jsx("div",{className:"hn-bl-card-foot",children:t.jsx(ff,{spec:e,...c})})]})}function DI({specs:e,activeSpecs:a,presenceBySpec:n,onOpenDetail:i,projectNameOf:r,...s}){const[o,l]=d.useState(null),[c,u]=d.useState(null),m=d.useMemo(()=>{var g;const p=new Map(tp.map(f=>[f.key,[]]));for(const f of e)(g=p.get(BI(f,a==null?void 0:a.has(f.id))))==null||g.push(f);return p},[e,a]),h=p=>{o&&np(o.from,p)&&s.onStart&&s.onStart(o.spec),l(null),u(null)};return t.jsx("div",{"data-testid":"backlog-board",className:"hn-board-local-overflow hn-bl-board",children:tp.map(p=>{const g=m.get(p.key),f=!!o&&np(o.from,p.key),b=f&&c===p.key;return t.jsxs("div",{className:"hn-bl-col","data-active":f||void 0,"data-hot":b||void 0,"data-dimmed":o&&!f||void 0,onDragOver:v=>{f&&(v.preventDefault(),v.dataTransfer.dropEffect="move",u(p.key))},onDragLeave:()=>u(v=>v===p.key?null:v),onDrop:v=>{v.preventDefault(),h(p.key)},children:[t.jsxs("div",{className:"hn-bl-col-head",children:[p.icon&&t.jsx(Re,{name:p.icon,size:13,color:"var(--text-muted)"}),t.jsx("span",{className:"hn-eyebrow",children:p.label}),t.jsx("span",{className:"hn-bl-col-count",children:g.length})]}),t.jsx("div",{className:"hn-bl-col-body",children:g.map(v=>t.jsx($I,{spec:v,col:p.key,onOpenDetail:i,projectName:r==null?void 0:r(v.projectId),presenceOn:n==null?void 0:n.get(v.id),...s,dragging:(o==null?void 0:o.spec.id)===v.id,running:a==null?void 0:a.has(v.id),onDragStart:()=>l({spec:v,from:p.key}),onDragEnd:()=>{l(null),u(null)}},v.id))})]},p.key)})})}const OI=[{value:"list",label:"Daftar",icon:"list"},{value:"board",label:"Papan",icon:"kanban"}];function HI({value:e,onChange:a}){return t.jsx("div",{className:"hn-bl-view-toggle",role:"group","aria-label":"Mode tampilan",children:OI.map(n=>t.jsx("button",{type:"button",className:"hn-bl-view-btn hn-touch-target","aria-pressed":e===n.value,"aria-label":n.label,title:n.label,onClick:()=>a(n.value),children:t.jsx(Re,{name:n.icon,size:15})},n.value))})}const qI=5,UI=new Set;function zI({backlog:e,projects:a,pageSize:n=20,onStart:i,activeSpecs:r,presenceBySpec:s,reviewSpecIds:o=UI,onDelete:l,onOpenRun:c,onOpenReview:u,onNew:m,onEditBranch:h,onRevertStage:p,onMarkDone:g,onMarkReviewed:f,onIntegrate:b,onEditSpec:v,onEditDeps:x,onEditAutoMerge:y,onChangeSource:T,onPromoteToQa:S,onPromoteToBrief:E,onPromoteToPrd:w,projectFilter:N,onProjectFilter:R,dataVersion:L,onToast:I,initialDetailId:B}){var Gt,ln,jt,wn,Kt;const[A,M]=Ba("backlog","tab","all",Dn),[K,O]=d.useState(0),[J,Z]=Ba("backlog","view","list",bi("list","board")),[H,te]=Ba("backlog","stageGroup","all",bi("all","brainstorm","spec","doing","done")),[ae,F]=Ba("backlog","q","",Dn),[fe,_e]=Ba("backlog","prio","all",Dn),[ee,X]=Ba("backlog","worktree","all",bi("all","worktree")),[ce,se]=Ba("backlog","review","all",bi("all","review")),[Ce,Te]=Ba("backlog","dateField","created",bi("created","started")),[le,ya]=Ba("backlog","from","",Dn),[Ze,He]=Ba("backlog","to","",Dn),Ke=N,ga=R,[Ge,ba]=Ba("backlog","detailId",null,Nk);d.useEffect(()=>{B&&ba(B)},[B]);const Ta=d.useCallback(me=>{var ia;return(ia=(a??[]).find(Fa=>Fa.id===me))==null?void 0:ia.name},[a]),va=a||[...new Set(e.map(me=>me.projectId))].map(me=>({id:me,name:me})),[we,Je]=d.useState(()=>e.map(me=>({objective:"",...me}))),[U,Be]=Ba("backlog","page",1,Wc),[ue,We]=d.useState(()=>ae.trim()),[sa,ye]=d.useState(!1),[la,Se]=d.useState(!1),[xe,aa]=d.useState(!1),Ea=d.useRef(!1),[dt,qa]=mk(),Xe=d.useCallback((me,ia)=>{qa(me,"ok",void 0,{action:{label:"Urungkan",onAction:ia}})},[qa]),ge=[A!=="all",Ke!=="all",ae.trim()!=="",H!=="all",fe!=="all",le!=="",Ze!=="",ee!=="all",ce!=="all"].filter(Boolean).length,be=Vc("backlog","scroll",we.length>0);d.useEffect(()=>{const me=setTimeout(()=>We(ae.trim()),250);return()=>clearTimeout(me)},[ae]),Lk(JSON.stringify([A,Ke,H,fe,ue,Ce,le,Ze,ee,ce]),()=>Be(1)),d.useEffect(()=>{var Fa;let me=!0;const ia=(Fa=ne.listSpecs)==null?void 0:Fa.call(ne,{project:Ke==="all"?void 0:Ke,source:A==="all"?void 0:A,q:ue||void 0,priority:fe==="all"?void 0:fe,dateField:le||Ze?Ce:void 0,from:le||void 0,to:Ze||void 0});return Se(!!ia),ia==null||ia.then(Ya=>{me&&(Je(Ya.items),aa(!0),Ea.current=!1,ye(!1),Se(!1))}).catch(()=>{me&&(Ea.current||(Ea.current=!0,I==null||I("Gagal menyegarkan backlog — data di layar mungkin usang","warn")),ye(!0),Se(!1))}),()=>{me=!1}},[A,Ke,fe,ue,Ce,le,Ze,L,K]);const ua=d.useMemo(()=>new Map(e.map(me=>[me.id,me])),[e]),Da=d.useMemo(()=>we.map(me=>Jl(me,ua.get(me.id))),[we,ua]),it=d.useMemo(()=>hI(dI(Da,ee),ce,o),[Da,ee,ce,o]),It=d.useMemo(()=>{const me={};for(const ia of lr)me[ia.key]=it.filter(Fa=>Jh(Fa.stage,ia.key)).length;return me},[it]),pt=d.useMemo(()=>it.filter(me=>Jh(me.stage,H)),[it,H]),_a=xr(pt.length,U,n),Nt=pt.slice((_a.page-1)*n,_a.page*n),[Rt,st]=d.useState(null);d.useEffect(()=>{if(!Ge||!ne.getSpec){st(null);return}let me=!0;return ne.getSpec(Ge).then(ia=>{me&&st(ia)}).catch(ia=>{!me||!(ia instanceof ha)||ia.status!==404||(ba(null),I==null||I(`${Ge} sudah tidak ada`,"warn"))}),()=>{me=!1}},[Ge,L]);const Ua=d.useMemo(()=>{if(!Ge)return null;const me=ua.get(Ge);if((Rt==null?void 0:Rt.id)===Ge)return Jl(Rt,me);const ia=we.find(Fa=>Fa.id===Ge);return ia?Jl(ia,me):me?{objective:"",...me}:null},[Ge,Rt,we,ua]),{confirm:Ja,dialog:Et}=lt(),Tt=l?me=>{var Fa;const ia=((Fa=a.find(Ya=>Ya.id===me.projectId))==null?void 0:Fa.name)??me.projectId;Ja({title:`Hapus ${me.id}?`,message:`"${me.title}" dihapus dari backlog ${ia}.`,impact:["Tindakan ini tidak bisa dibatalkan.","Lampiran item ini ikut dihapus dari disk.","Sesi yang masih berjalan untuk item ini tidak ikut dihentikan.","Item lain yang menunggu item ini tidak lagi bergantung padanya.","Kode dan commit di repo tidak disentuh."],confirmLabel:"Hapus spec",tone:"danger",icon:"trash-2",run:async()=>{await l(me),Ge===me.id&&ba(null)}}).catch(Ya=>I==null?void 0:I(ka(`menghapus ${me.id}`,Ya),"err","x-circle"))}:void 0,Ct=()=>{M("all"),ga("all"),F(""),te("all"),_e("all"),Te("created"),ya(""),He(""),X("all"),se("all"),Be(1)},jn=[...A!=="all"?[{key:"tab",label:`Sumber: ${((Gt=Zh.find(me=>me.value===A))==null?void 0:Gt.label)??A}`,onRemove:()=>M("all")}]:[],...Ke!=="all"?[{key:"proj",label:`Project: ${((ln=va.find(me=>me.id===Ke))==null?void 0:ln.name)??Ke}`,onRemove:()=>ga("all")}]:[],...fe!=="all"?[{key:"prio",label:`Prioritas: ${Ho(fe).label}`,onRemove:()=>_e("all")}]:[],...le||Ze?[{key:"date",label:`Tanggal ${Ce==="created"?"dibuat":"dikerjakan"}: ${le||"…"} – ${Ze||"…"}`,onRemove:()=>{ya(""),He("")}}]:[],...ee!=="all"?[{key:"wt",label:Cd.worktree,onRemove:()=>X("all")}]:[],...ce!=="all"?[{key:"review",label:Pd.review,onRemove:()=>se("all")}]:[]],Pt=t.jsxs(S2,{gap:3,children:[t.jsx(oe,{label:"Sumber",children:t.jsx($e,{size:"sm","aria-label":"Filter sumber",value:A,onChange:me=>M(me.target.value),options:Zh})}),t.jsx(oe,{label:"Project",children:t.jsx($e,{size:"sm","aria-label":"Filter project",value:Ke,onChange:me=>ga(me.target.value),options:[{value:"all",label:"Semua project"}].concat(va.map(me=>({value:me.id,label:me.name})))})}),t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{size:"sm","aria-label":"Filter prioritas",value:fe,onChange:me=>_e(me.target.value),options:TI})}),t.jsx(oe,{label:"Worktree",hint:"Hanya item yang pernah dibuatkan worktree oleh hanoman. Pekerjaan di luar hanoman tidak terhitung.",children:t.jsx($e,{size:"sm","aria-label":"Filter worktree",value:ee,onChange:me=>X(me.target.value),options:oI.map(me=>({value:me.value,label:me.label}))})}),t.jsx(oe,{label:"Tinjauan",hint:"Item yang sesinya menunggu jawabanmu, dan item selesai yang belum kamu tandai sudah ditinjau. Tandai lewat menu item atau di Review perubahan.",children:t.jsx($e,{size:"sm","aria-label":"Filter perlu ditinjau",value:ce,onChange:me=>se(me.target.value),options:cI.map(me=>({value:me.value,label:me.label}))})}),t.jsx(oe,{label:"Tanggal",children:t.jsxs("div",{className:"hn-bl-date-row",children:[t.jsx($e,{size:"sm","aria-label":"Filter tanggal berdasarkan",value:Ce,onChange:me=>Te(me.target.value),options:[{value:"created",label:"Dibuat"},{value:"started",label:"Dikerjakan"}]}),t.jsx(Oe,{size:"sm",type:"date","aria-label":"Tanggal dari",value:le,onChange:me=>ya(me.target.value)}),t.jsx("span",{className:"hn-eyebrow","aria-hidden":"true",children:"→"}),t.jsx(Oe,{size:"sm",type:"date","aria-label":"Tanggal sampai",value:Ze,onChange:me=>He(me.target.value)})]})})]}),xt=!xe&&Da.length===0&&la,za={onStart:i,onDelete:Tt,onOpenRun:c,onOpenReview:u,onMarkDone:g,onMarkReviewed:f},on=me=>ba(me.id),xa=((jt=lr.find(me=>me.key===H))==null?void 0:jt.label)??"";return t.jsxs("div",{className:"hn-bl-screen",children:[t.jsxs("section",{className:"hn-bl-toolbar",role:"region","aria-label":"Kontrol backlog",children:[t.jsx(w2,{label:"Penyaring backlog",search:{value:ae,onChange:F,label:"Cari backlog",placeholder:"mis. invoice atau SPEC-412"},chips:jn,filters:Pt,filtersLabel:"Filter",onReset:ge>0?Ct:void 0,resetLabel:"Reset filter",actions:t.jsxs(t.Fragment,{children:[t.jsx(HI,{value:J,onChange:Z}),t.jsx(xI,{onDone:()=>O(me=>me+1),onToast:I??(()=>{})})]})}),t.jsx(_t,{variant:"pill","aria-label":"Tahap backlog",value:H,onChange:me=>te(me),className:"hn-bl-stage-tabs",tabs:lr.map(me=>({value:me.key,label:me.label,count:It[me.key]}))}),Xh[A]&&t.jsx("p",{className:"hn-bl-hint","data-testid":"backlog-tab-hint",children:Xh[A]}),t.jsxs("div",{className:"hn-bl-status-line",children:[sa&&t.jsx("span",{role:"status",className:"hn-bl-stale",title:"Server tak menjawab saat menyegarkan — angka ini dari muatan terakhir yang berhasil",children:"Data mungkin usang: server tak menjawab saat menyegarkan."}),la&&t.jsx("span",{"data-testid":"backlog-refreshing",className:"hn-bl-muted",children:"Memuat…"})]})]}),xt?t.jsx(bk,{rows:qI,label:"Memuat backlog"}):it.length===0?e.length===0?t.jsx(he,{kind:"empty",illustration:"PST-002",title:"Backlog masih kosong",hint:"Ajukan feature brief atau Finding QA — hanoman menjalankannya dari brainstorm sampai execute.",action:m,actionLabel:"Tambah spec"}):t.jsx(he,{kind:"empty",icon:"filter",title:"Tidak ada spec untuk filter ini",hint:`${e.length} spec ada di backlog, tapi tak ada yang cocok dengan filter aktif.`,action:Ct,actionLabel:"Reset filter",actionIcon:"rotate-ccw"}):pt.length===0?t.jsx(he,{kind:"empty",compact:!0,icon:"filter",title:`Tidak ada spec di tahap ${xa}`,hint:"Tahap lain tetap memuat item yang sama.",action:()=>te("all"),actionLabel:"Tampilkan semua",actionIcon:"x"}):J==="board"?t.jsxs("div",{className:"hn-bl-body",children:[t.jsx("p",{"data-testid":"board-drag-hint",className:"hn-bl-hint",children:"Seret kartu dari kolom Backlog ke Brainstorm untuk memulai sesi. Tombol di kartu melakukan hal yang sama."}),t.jsx(DI,{specs:pt,activeSpecs:r,presenceBySpec:s,projectNameOf:Ta,onOpenDetail:on,...za})]}):t.jsxs("div",{className:"hn-bl-body",children:[t.jsx("div",{ref:be,"data-testid":"backlog-scroll","aria-busy":la||void 0,className:"hn-bl-list-scroll",children:t.jsx(Xt,{label:"Daftar backlog",children:Nt.map(me=>t.jsx(RI,{spec:me,presenceOn:s==null?void 0:s.get(me.id),projectName:Ta(me.projectId),running:r==null?void 0:r.has(me.id),onOpenDetail:on,...za},me.id))})}),t.jsx("div",{className:"hn-bl-pager",children:t.jsx(jr,{page:_a.page,pageCount:_a.pageCount,total:pt.length,from:_a.from,to:_a.to,onPage:Be,unit:"spec"})})]}),t.jsx(MI,{spec:Ua,onClose:()=>ba(null),running:!!Ge&&!!(r!=null&&r.has(Ge)),onOpenRun:c,presenceOn:Ge?s==null?void 0:s.get(Ge):void 0,onEditBranch:h,onRevertStage:p,onMarkDone:g,onOpenReview:u,onStart:i,onIntegrate:b,onEditSpec:v,onPromoteToQa:S,onPromoteToBrief:E,onPromoteToPrd:w,onEditDeps:x,onEditAutoMerge:y,onChangeSource:T,onRequestDelete:Tt,onUndoable:Xe,projectPolicy:(wn=a.find(me=>{var ia;return me.id===((ia=e.find(Fa=>Fa.id===Ge))==null?void 0:ia.projectId)}))==null?void 0:wn.autoMerge,projectName:(Kt=a.find(me=>me.id===(Ua==null?void 0:Ua.projectId)))==null?void 0:Kt.name,allSpecs:e,onAttachmentToast:(me,ia)=>I==null?void 0:I(me,ia??"ok","paperclip")}),t.jsx(Hc,{toast:dt}),Et]})}const ip=20,sp=Rj,sd=e=>e?new Date(e).toLocaleDateString("id-ID",{day:"numeric",month:"short",year:"numeric"}):"—";function FI({projectId:e}){const[a,n]=d.useState(null),[i,r]=d.useState(0),[s,o]=d.useState(null),[l,c]=d.useState(1),[u,m]=d.useState(null),[h,p]=d.useState(""),[g,f]=d.useState(null),b=d.useCallback(()=>{El.listSessions(e,{page:l,limit:ip}).then(T=>{n(T.items),r(T.total),o(T.kuota)}).catch(()=>{n([]),r(0),o(null)})},[e,l]);d.useEffect(()=>{m(null),b()},[b]),d.useEffect(()=>{c(1)},[e]);const v=T=>{f(null),p(""),El.getSession(T).then(m).catch(()=>m(null))},x=async()=>{if(!(!u||!h.trim()))try{const T=await El.materializePrd(u.id,h.trim());f(`PRD tersimpan di ${T.path}. Ia BELUM jadi backlog — eskalasi tetap keputusan Anda.`),b()}catch(T){f(T instanceof Error?T.message:"gagal menulis PRD")}};if(a===null)return t.jsx(he,{kind:"loading",title:"Memuat obrolan…"});const y=xr(i,l,ip);return t.jsxs("div",{className:"hn-pc",children:[s&&t.jsxs("div",{"data-testid":"portal-chat-kuota",className:"hn-pc-kuota",children:["Jatah bulan ini — Brainstorming ",t.jsxs("b",{children:[s.brainstorm.terpakai," / ",s.brainstorm.jatah]})," · ","Bertanya ",t.jsxs("b",{children:[s.tanya.terpakai," / ",s.tanya.jatah]})," · ","reset ",sd(s.resetPada),!s.enabled&&" · obrolan portal sedang MATI di Settings"]}),a.length===0?t.jsx(he,{kind:"empty",icon:"messages-square",title:"Belum ada obrolan",hint:"Begitu klien memulai obrolan di portal, sesinya muncul di sini."}):t.jsxs(t.Fragment,{children:[t.jsx(Sa,{padding:0,children:a.map(T=>t.jsxs("button",{type:"button","data-testid":`portal-chat-row-${T.id}`,onClick:()=>v(T.id),className:"hn-pc-row",children:[t.jsx("span",{className:"hn-pc-type",children:sp[T.type]??T.type}),t.jsx("span",{className:"hn-pc-summary",children:T.summary||"Belum ada ringkasan"}),T.prdSiap&&t.jsx(ht,{status:T.prdDocPath?"ok":"warn",size:"sm",children:T.prdDocPath?"PRD dokumen":"PRD draft"}),t.jsx("span",{className:"hn-pc-meta",children:T.clientEmail}),t.jsx("span",{className:"hn-pc-meta",children:sd(T.createdAt)})]},T.id))}),t.jsx(jr,{page:y.page,pageCount:y.pageCount,total:i,from:y.from,to:y.to,onPage:c,unit:"obrolan"})]}),u&&t.jsxs(Sa,{eyebrow:`${sp[u.type]??u.type} · ${u.clientEmail}`,title:u.summary||"Obrolan",children:[t.jsx("div",{"data-testid":"portal-chat-transkrip",className:"hn-pc-transcript",children:u.messages.map(T=>t.jsxs("div",{className:"hn-pc-msg","data-role":T.role,"data-blocked":T.blocked?"true":"false",children:[t.jsxs("div",{className:"hn-pc-msg-meta",children:[T.role==="klien"?"Klien":"hanoman"," · ",sd(T.createdAt)]}),t.jsx("div",{className:"hn-pc-msg-text",children:T.text}),T.blocked&&t.jsxs("div",{className:"hn-pc-blocked",children:[t.jsx("b",{children:"Diblokir"})," (",(T.blockReasons??[]).join(", "),") — teks asli agen:",t.jsx("div",{className:"hn-pc-raw",children:T.rawText})]})]},T.id))}),u.prdMarkdown&&t.jsxs(t.Fragment,{children:[t.jsx("div",{"data-testid":"portal-chat-prd",className:"hn-pc-prd",children:t.jsx(ws,{text:u.prdMarkdown,name:"prd-draft.md"})}),t.jsxs("div",{className:"hn-pc-prd-actions",children:[t.jsx(Oe,{"data-testid":"portal-chat-slug","aria-label":"Slug dokumen PRD",placeholder:"nama-dokumen",value:h,className:"hn-pc-slug",onChange:T=>p(T.target.value)}),t.jsx(q,{"data-testid":"portal-chat-jadikan-prd",disabled:!h.trim(),onClick:()=>void x(),children:"Jadikan dokumen PRD"}),t.jsxs("span",{className:"hn-pc-meta",children:["Menyimpan ke ",t.jsx("code",{children:"docs/prd/"}),". Tidak membuat backlog."]})]})]}),g&&t.jsx("p",{className:"hn-pc-note",children:g})]})]})}function vf({projects:e,defaultProject:a,onClose:n,onCreate:i,prefill:r,lockProject:s}){var f;const[o,l]=d.useState(a||((f=e[0])==null?void 0:f.id)||""),[c,u]=d.useState({title:(r==null?void 0:r.title)??"",context:(r==null?void 0:r.context)??"",outcome:(r==null?void 0:r.outcome)??"",constraints:(r==null?void 0:r.constraints)??""}),m=b=>v=>u(x=>({...x,[b]:v.target.value})),h=!!c.title.trim()&&!!o,p=()=>{h&&i(o,{title:c.title.trim(),context:c.context,outcome:c.outcome,constraints:c.constraints||void 0})},g=t.jsx("span",{"aria-hidden":"true",className:"hn-prj-required",children:"*"});return t.jsxs(da,{open:!0,onClose:n,icon:"scroll-text",eyebrow:"PM → hanoman",title:"PRD baru",footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:n,children:"Batal"}),t.jsx(q,{size:"sm",leftIcon:"messages-square",onClick:p,disabled:!h,children:"Buat brief → brainstorm PRD"})]}),children:[t.jsxs("p",{className:"hn-prj-note",children:["hanoman membuka sesi brainstorm interaktif di terminal, lalu menulis dokumen PRD ke ",t.jsx("code",{children:"docs/prd/"}),"."]}),t.jsxs("p",{className:"hn-prj-note",children:[t.jsx("span",{"aria-hidden":"true",className:"hn-prj-required",children:"*"})," wajib diisi"]}),t.jsx(oe,{label:t.jsxs(t.Fragment,{children:["Project",g]}),hint:"Tujuan penulisan docs/prd/ — pilih di sini, tak perlu memfilter daftar dulu",children:t.jsx($e,{"aria-label":"Project untuk PRD baru",value:o,disabled:s,onChange:b=>l(b.target.value),className:"hn-prj-full",options:e.map(b=>({value:b.id,label:b.name}))})}),t.jsx(oe,{label:t.jsxs(t.Fragment,{children:["Judul",g]}),hint:c.title.trim()?void 0:"Wajib diisi — tanpa judul, brief tak bisa dibuat.",children:t.jsx(Oe,{value:c.title,onChange:m("title"),placeholder:"mis. Jadwal Invoice Berulang",className:"hn-prj-full"})}),t.jsx(oe,{label:"Konteks",hint:"Latar belakang & alasan fitur ini dibutuhkan",children:t.jsx(Ia,{value:c.context,onChange:m("context"),rows:3,placeholder:"mis. operator harus membuka tiga layar untuk tahu sesi mana yang menunggu"})}),t.jsx(oe,{label:"Hasil yang diharapkan",children:t.jsx(Ia,{value:c.outcome,onChange:m("outcome"),rows:2,placeholder:"mis. satu badge di Overview menunjukkan jumlah sesi yang menunggu"})}),t.jsx(oe,{label:"Batasan",hint:"opsional",children:t.jsx(Oe,{value:c.constraints,onChange:m("constraints"),placeholder:"mis. reuse queue yang ada",className:"hn-prj-full"})})]})}const GI={draft:"neutral",dieskalasi:"info",terwujud:"ok"};function KI({prd:e}){const a=Id[e.status]??e.status;return t.jsx(oa,{tone:GI[e.status],size:"sm",children:e.specCount>0?`${a} ${e.doneCount}/${e.specCount}`:a})}function WI({open:e,onClose:a,prd:n,takeBase:i,items:r,include:s,setInclude:o,busy:l,onTake:c,onStartBreakdown:u,onMaterialize:m,projectId:h}){const p=r.filter((g,f)=>s[f]).length;return t.jsxs(da,{open:e,onClose:a,icon:"list-checks",width:600,eyebrow:"PRD → backlog",title:"Jadikan backlog",footer:t.jsx(q,{variant:"ghost",size:"sm",onClick:a,children:"Batal"}),children:[t.jsxs("p",{className:"hn-prj-note",children:["Pilih bentuk backlog untuk ",t.jsx("b",{children:n.title}),". Manusia yang memutuskan."]}),t.jsxs("div",{className:"hn-prj-sheet-options",children:[t.jsxs("div",{className:"hn-prj-sheet-option",children:[t.jsx(q,{leftIcon:"lightbulb",onClick:()=>{a(),c({...i,kind:"brief",context:`Dari PRD: ${n.path}`,outcome:""})},children:"Sebagai feature brief"}),t.jsx("p",{className:"hn-prj-hint",children:"Sesi menjalankan pipeline penuh: brainstorm → objective → spec → plan → execute."})]}),t.jsxs("div",{className:"hn-prj-sheet-option",children:[t.jsx(q,{leftIcon:"target",variant:"secondary",onClick:()=>{a(),c({...i,kind:"goal",context:"",outcome:"",goal:`Wujudkan PRD ${n.path}`})},children:"Sebagai goal"}),t.jsx("p",{className:"hn-prj-hint",children:"Sesi dua fase (Goal → Verifikasi) yang langsung mengejar goal-nya, tanpa brainstorm, spec, maupun plan. Mode goal selalu aktif."})]}),t.jsx("div",{className:"hn-prj-sheet-option",children:r.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hn-prj-sheet-head",children:[t.jsxs("span",{className:"hn-prj-sheet-title",children:["Breakdown · ",r.length," item"]}),t.jsxs("span",{className:"hn-prj-hint",children:[p,"/",r.length," dipilih"]})]}),t.jsx("ul",{className:"hn-prj-checklist",children:r.map((g,f)=>t.jsx("li",{children:t.jsxs("label",{className:"hn-prj-check",children:[t.jsx("input",{type:"checkbox",checked:s[f]??!1,className:"hn-prj-check-input",onChange:b=>o(v=>v.map((x,y)=>y===f?b.target.checked:x))}),t.jsxs("span",{className:"hn-prj-check-text",children:[t.jsxs("span",{className:"hn-prj-check-title",children:[g.title," ",t.jsx(oa,{tone:"brass",size:"sm",children:g.priority})]}),g.outcome&&t.jsx("span",{className:"hn-prj-hint",children:g.outcome})]})]})},f))}),t.jsx(q,{size:"sm",leftIcon:"plus",disabled:!p||l,onClick:m,children:l?"Membuat…":`Buat ${p} backlog`})]}):t.jsxs(t.Fragment,{children:[t.jsx(q,{leftIcon:"split",variant:"secondary",onClick:()=>{a(),u(h,n.path)},children:"Breakdown ke backlog"}),t.jsx("p",{className:"hn-prj-hint",children:"Mulai sesi breakdown yang menulis usulan backlog paralel dari PRD ini."})]})})]})]})}function VI({prd:e,projectId:a,dataVersion:n,onTake:i,onStartBreakdown:r,onMaterialize:s}){const[o,l]=d.useState(null),[c,u]=d.useState(""),[m,h]=d.useState(0),[p,g]=d.useState([]),[f,b]=d.useState([]),[v,x]=d.useState(""),[y,T]=d.useState(0),[S,E]=d.useState(!1),[w,N]=d.useState(!1);d.useEffect(()=>{let B=!0;return l(null),u(""),ne.getPrd(a,e.path).then(A=>{B&&l(A.content)}).catch(A=>{B&&u(xs(A,"tidak diketahui"))}),()=>{B=!1}},[a,e.path,m]),d.useEffect(()=>{let B=!0;return ne.getBreakdown(a,e.path).then(A=>{B&&(g(A.items),b(A.items.map(()=>!0)),x(""))}).catch(A=>{if(B){if((A==null?void 0:A.status)===404){g([]),b([]),x("");return}x(xs(A,"tidak diketahui"))}}),()=>{B=!1}},[a,e.path,n,y]);const R={project:a,title:e.title,prdPath:e.path,branchFrom:AT(e.path)},L=p.filter((B,A)=>f[A]),I=async()=>{if(L.length){E(!0);try{await s(a,e.path,L),N(!1)}finally{E(!1)}}};return t.jsxs("div",{className:"hn-prd-pane",children:[t.jsxs("div",{className:"hn-prd-actionbar",role:"toolbar","aria-label":"Aksi PRD",children:[t.jsx("span",{className:"hn-prd-actionbar-title",children:e.title}),t.jsx(q,{size:"sm",leftIcon:"list-checks",onClick:()=>N(!0),children:"Jadikan backlog"}),t.jsx(rn,{label:"Aksi lain PRD",icon:"ellipsis",items:[],children:t.jsx(Kk,{href:B=>ne.prdDownloadUrl(a,e.path,B),disabled:o===null})})]}),t.jsxs("div",{className:"hn-prd-read",children:[t.jsxs("header",{className:"hn-prd-head",children:[t.jsx("div",{className:"hn-prj-mono hn-prd-path",children:e.path}),t.jsxs("div",{className:"hn-prd-head-row",children:[t.jsx("h2",{className:"hn-prd-title",children:e.title}),t.jsx(KI,{prd:e})]})]}),v&&t.jsxs("div",{role:"alert",className:"hn-prj-stale",children:[t.jsxs("span",{className:"hn-prj-stale-text",children:["Usulan breakdown gagal dimuat: ",v]}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"rotate-ccw",onClick:()=>T(B=>B+1),children:"Coba lagi"})]}),p.length>0&&t.jsxs("details",{className:"hn-prd-breakdown",children:[t.jsxs("summary",{className:"hn-prd-breakdown-summary",children:["Usulan breakdown · ",p.length," item"]}),t.jsx("ul",{className:"hn-prd-breakdown-list",children:p.map((B,A)=>t.jsxs("li",{children:[t.jsx("span",{className:"hn-prd-breakdown-item",children:B.title}),t.jsx(oa,{tone:"brass",size:"sm",children:B.priority})]},A))}),t.jsx("p",{className:"hn-prj-hint",children:"Pilih item yang dibuat lewat “Jadikan backlog”."})]}),c?t.jsx(he,{kind:"error",title:"Gagal memuat isi PRD",hint:c,action:()=>h(B=>B+1)}):o===null?t.jsx(he,{kind:"loading",title:"Memuat PRD…"}):t.jsx("div",{className:"hn-prd-doc",children:t.jsx(ws,{text:o,name:e.name})})]}),t.jsx(WI,{open:w,onClose:()=>N(!1),prd:e,takeBase:R,items:p,include:f,setInclude:b,busy:S,onTake:i,onStartBreakdown:r,onMaterialize:()=>{I()},projectId:a})]})}function YI(e){const a=[],n=new Map;for(const i of e){let r=n.get(i.projectId);r||(r={projectId:i.projectId,projectName:i.projectName,items:[]},n.set(i.projectId,r),a.push(i.projectId)),r.items.push(i)}return a.map(i=>n.get(i))}function JI({prd:e,active:a,showProject:n,onSelect:i}){return t.jsxs("button",{type:"button",onClick:i,"aria-current":a?"true":void 0,className:`hn-prd-item${a?" is-active":""}`,children:[t.jsxs("span",{className:"hn-prd-item-head",children:[t.jsx(Re,{name:"scroll-text",size:13,color:a?"var(--brass-700)":"var(--brass-500)"}),t.jsx("span",{className:"hn-prd-item-title",children:e.title}),e.live&&t.jsx(oa,{tone:"brass",size:"sm",children:"sesi hidup"})]}),t.jsxs("span",{className:"hn-prd-item-meta",children:[n&&t.jsxs("span",{children:[e.projectName," · "]}),e.specCount>0&&t.jsxs("span",{children:[e.doneCount,"/",e.specCount," item selesai · "]}),t.jsx("span",{className:"hn-prj-mono",children:e.path})]})]})}function QI({projects:e,projectFilter:a,onProjectFilter:n,onNewPrd:i,onTakeToBacklog:r,onStartBreakdown:s,onMaterialize:o,dataVersion:l}){const[c,u]=d.useState([]),[m,h]=d.useState("loading"),[p,g]=d.useState(""),[f,b]=d.useState(0),[v,x]=Ba("prd","sel",null,Nk),[y,T]=d.useState("list"),S=d.useMemo(()=>c.find(H=>H.slug===v)??null,[c,v]),E=d.useCallback(H=>x(H?H.slug:null),[x]),[w,N]=d.useState(!1),R=a==="all",L=R?"":a,I=d.useRef(null);d.useEffect(()=>{I.current!==null&&I.current!==a&&E(null),I.current=a},[a,E]),d.useEffect(()=>{let H=!0;return(R?ne.listAllPrds():L?ne.listPrds(L):Promise.resolve({items:[]})).then(ae=>{H&&(u(ae.items),h("ready"),g(""))}).catch(ae=>{H&&(h("error"),g(xs(ae,"tidak diketahui")))}),()=>{H=!1}},[a,l,f]);const[B,A]=d.useState(!1),M=S?S.projectId||L:"",K=[{value:"all",label:"Semua project"}].concat(e.map(H=>({value:H.id,label:H.name}))),O=[...yd],J=[...yd.map(H=>({status:H,label:Kn(Id,H),items:c.filter(te=>te.status===H)})),...Array.from(new Set(c.map(H=>H.status).filter(H=>!O.includes(H)))).map(H=>({status:H,label:Kn(Id,H),items:c.filter(te=>te.status===H)}))],Z=m==="loading"&&c.length===0?t.jsx(he,{kind:"loading",compact:!0,title:"Memuat daftar PRD…"}):m==="error"&&c.length===0?t.jsx(he,{kind:"error",compact:!0,title:"Gagal memuat daftar PRD",hint:p,action:()=>b(H=>H+1)}):c.length===0?t.jsx(he,{kind:"empty",icon:"scroll-text",title:"Belum ada PRD",hint:"Buat PRD dari brief + brainstorm; hanoman menulisnya ke docs/prd/ lalu bisa di-take jadi backlog.",action:()=>N(!0),actionLabel:"PRD baru"}):t.jsxs(t.Fragment,{children:[m==="error"&&t.jsxs("div",{role:"alert",className:"hn-prj-stale hn-prd-stale",children:[t.jsx("span",{className:"hn-prj-stale-text",children:"Gagal memuat ulang — daftar dari muatan terakhir."}),t.jsx(q,{size:"sm",variant:"secondary",onClick:()=>b(H=>H+1),children:"Coba lagi"})]}),J.filter(H=>H.items.length>0).map(H=>t.jsxs("details",{open:!0,className:"hn-prd-group",children:[t.jsxs("summary",{className:"hn-prd-group-summary",children:[H.label,t.jsx("span",{className:"hn-prj-chip-count",children:H.items.length})]}),YI(H.items).map(te=>t.jsxs("div",{className:"hn-prd-group-body",children:[R&&t.jsx("div",{className:"hn-eyebrow hn-prd-project-label",children:te.projectName}),te.items.map(ae=>t.jsx(JI,{prd:ae,showProject:!1,active:(S==null?void 0:S.path)===ae.path&&(S==null?void 0:S.projectId)===ae.projectId,onSelect:()=>{E(ae),T("detail")}},`${ae.projectId}:${ae.path}`))]},te.projectId))]},H.status))]});return t.jsxs("div",{style:pk,children:[t.jsxs("div",{style:Ao,className:"hn-prd-toolbar",children:[t.jsx($e,{size:"sm",value:a,"aria-label":"Project",onChange:H=>n(H.target.value),options:K}),t.jsx(zE,{screen:"prd",active:R?0:1}),t.jsx("span",{className:"hn-prd-toolbar-spacer"}),!R&&t.jsx(q,{size:"sm",variant:B?"primary":"ghost",leftIcon:"messages-square","aria-expanded":B,onClick:()=>A(H=>!H),children:"Draft dari portal klien"}),t.jsx(q,{size:"sm",leftIcon:"plus",onClick:()=>N(!0),children:"PRD baru"})]}),B&&!R&&t.jsx("div",{style:Ao,className:"hn-prd-portal",children:t.jsx(FI,{projectId:a})}),t.jsx(tl,{ariaLabel:"Panel PRD",active:y,onActiveChange:H=>T(H),masterWidth:288,panels:[{id:"list",label:"Indeks",className:"hn-panel-flex",content:t.jsx("aside",{"aria-label":"Indeks PRD",className:"hn-prd-index",children:Z})},{id:"detail",label:"Isi",className:"hn-panel-flex",content:t.jsx("section",{"aria-label":"Isi PRD",className:"hn-prd-detail",children:S?t.jsx(VI,{prd:S,projectId:M,dataVersion:l,onTake:H=>r(H),onStartBreakdown:s,onMaterialize:o}):t.jsx(he,{kind:"empty",icon:"scroll-text",title:"Pilih PRD",hint:"Klik dokumen di indeks kiri untuk membacanya, lalu jadikan backlog."})})}]}),w&&t.jsx(vf,{projects:e,defaultProject:L,onClose:()=>N(!1),onCreate:(H,te)=>{N(!1),i(H,te)}})]})}const rp=5e3,ZI=12e3,XI=5*6e4,eN=new Set(["shipped","docs-updated","waiting","offline"]),aN={shipped:"selesai","docs-updated":"dokumen terbit",waiting:"butuh jawabanmu"},tN={shipped:"kabar","docs-updated":"dokumen",waiting:"sesi"},xf=(e,a)=>e.kind==="waiting"&&e.since!==null&&a-e.since>=Ud;function nN(e){const a=Math.floor(e/6e4);if(a<1)return`${Math.max(0,Math.floor(e/1e3))} detik`;if(a<60)return`${a} menit`;const n=Math.floor(a/60),i=a%60;return i>0?`${n} jam ${i} menit`:`${n} jam`}function iN(e,a){if(!eN.has(e.kind))return null;if(e.kind==="offline")return{kind:"pose",text:"Aku kehilangan sambungan",ttl:rp};let n=`${e.subject??"Backlog"} ${aN[e.kind]}`;return e.count>1&&(n+=` · ${e.count} ${tN[e.kind]}`),xf(e,a)&&(n+=` — ${nN(a-e.since)}`),{kind:"pose",text:n,ttl:rp}}function jf(e){const a=rl(e.backlog),n={};for(const i of e.sessions){const r=Ar(i,a);r&&(n[i.id]=r)}return{at:e.now,sessions:n,notifiedAt:Xk(e.notifications)}}function sN(e,a){const n=jf(a),i=c=>Object.entries(n.sessions).filter(([u,m])=>m===c&&e.sessions[u]!==c).length,r=a.notifications.filter(c=>Qk.has(c.type)&&c.createdAt>e.notifiedAt).length,s=i("waiting"),o=i("failed"),l=[r>0?`${r} selesai`:"",s>0?`${s} menunggu`:"",o>0?`${o} gagal`:""].filter(Boolean);return l.length>0?{kind:"recap",text:l.join(" · "),ttl:ZI}:null}const rN="PET-001",oN=2,lN={w:192,h:208},dN=8,cN={x:.62,baseline:202},uN={h:168},mN=[{key:"idle",fps:6,loop:!0},{key:"walk-right",fps:10,loop:!0,dir:"right"},{key:"walk-left",fps:10,loop:!0,dir:"left"},{key:"working",fps:8,loop:!0},{key:"waiting",fps:6,loop:!0},{key:"blocked",fps:4,loop:!0},{key:"review",fps:6,loop:!0},{key:"shipped",fps:10,loop:!1,then:"idle"},{key:"docs-updated",fps:6,loop:!0},{key:"wave",fps:10,loop:!1,then:"idle"},{key:"deciding",fps:6,loop:!0},{key:"sleep",fps:4,loop:!0},{key:"thanks",fps:10,loop:!1,then:"idle"},{key:"held",fps:8,loop:!0},{key:"falling",fps:8,loop:!0},{key:"dizzy",fps:8,loop:!1,then:"idle"}],hN={idle:"4a0f06cacdad0fa8e0b0a369628e383fc2cb54cbdd5297285c88d1a33bd686ac","walk-right":"7bdfb2786b2b1c899fb7b170ce2cf5d1e3a922e251cbaca9600c210262629a52","walk-left":"c53c6f7b980d4179b45d55160145df73eb629ccbb809ce2b19946045e388ce60",working:"2ec0d0d4565eced3c55c32603c2b1c6fe9ff93f13f2a1061bc7d2e8d8864aa6f",waiting:"8bb1595bf280040e101949392c1048330c19142d7b5a1d6b74918734f72287e3",blocked:"134f48c60fa6fef038da266be7fb2a69755ecb9123d23dc4e270b14d7d077da6",review:"77c865ff6d49a8bbf3db4e0d7b91ce4663a1e3acef5d072ddd65eac9479b232c",shipped:"d32653efa6a64eb4d00fb63a6e8c0a7dc24de63ecd5a6cfda36f32b584de00b8","docs-updated":"2b3a01ddd640efd6e65d61c6ad4980da3a9fbceff251f1b42ce13389c02bb19c",wave:"4153420063211e6d196219b89c572f43f96ec32f28c63a1159e6d98630e0ed73",deciding:"6309ab706c8430cf97b187f353fd2d447ba729f6e0764efef1b75a3c96168984",sleep:"40f1fd6e27ddddb13a5702c05a03f5e015e44e7e77e96c4e1ed52a5d7741f2ec",thanks:"0f59f2c042b25ff47a7022d4452bf0dc433dcea796d90bf47d95a5c8ca359d8d",held:"8de04ba258b30acb105a27a81ed400b66f3b68953042957a75e63ebe8efe7c89",falling:"8bc3429c44ef4ba257da895080fa6458c3a66e51cebe103e09cd8bac25be5363",dizzy:"3e8c2072e2aa652e204e3c6b041cb6c9487d8dca1649b52f9695600880a94e49"},pN={id:rN,version:oN,cell:lN,columns:dN,anchor:cN,character:uN,rows:mN,sources:hN},gN="/assets/hnm-pet-anoman-atlas-v02-ClJhW17L.webp",ir=["idle","walk-right","walk-left","working","waiting","blocked","review","shipped","docs-updated","wave","deciding","sleep","thanks","held","falling","dizzy"],kN=e=>typeof e=="string"&&ir.includes(e),gi=e=>typeof e=="number"&&Number.isInteger(e)&&e>0,Zi=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function bN(e){const a=h=>{throw new Error(`pet.json tidak sah: ${h}`)};if(!Zi(e))return a("bukan objek");const{id:n,version:i,cell:r,columns:s,anchor:o,character:l,rows:c,sources:u}=e;if(typeof n!="string"||!n)return a("id");if(!gi(i))return a("version");if(!Zi(r)||!gi(r.w)||!gi(r.h))return a("cell");if(!gi(s))return a("columns");if(!Zi(o)||typeof o.x!="number"||!(o.x>0&&o.x<1)||!gi(o.baseline)||o.baseline>r.h)return a("anchor");if(!Zi(l)||!gi(l.h)||l.h>r.h)return a("character");if(!Array.isArray(c)||c.length!==ir.length)return a(`rows: butuh ${ir.length} baris`);const m=c.map((h,p)=>{const g=ir[p];if(!Zi(h)||h.key!==g)return a(`rows[${p}]: harus "${g}"`);if(!gi(h.fps))return a(`rows[${p}].fps`);if(typeof h.loop!="boolean")return a(`rows[${p}].loop`);const f={key:g,fps:h.fps,loop:h.loop};if(h.then!==void 0){if(!kN(h.then)||h.loop)return a(`rows[${p}].then hanya untuk baris loop:false`);f.then=h.then}else if(!h.loop)return a(`rows[${p}] loop:false tanpa then`);if(h.dir!==void 0){if(h.dir!=="right"&&h.dir!=="left")return a(`rows[${p}].dir`);f.dir=h.dir}return f});return!Zi(u)||ir.some(h=>typeof u[h]!="string")?a("sources"):{id:n,version:i,cell:{w:r.w,h:r.h},columns:s,anchor:{x:o.x,baseline:o.baseline},character:{h:l.h},rows:m,sources:u}}const Er=bN(pN),fN=gN,qo={ready:"idle",sleeping:"sleep",offline:"idle",working:"working",deciding:"deciding",waiting:"waiting",blocked:"blocked",review:"review",shipped:"shipped","docs-updated":"docs-updated"};function pu(e,a=Er){const n=a.rows.find(i=>i.key===e);if(!n)throw new Error(`baris ${e} tak ada di manifest`);return n}const yN=(e,a=Er)=>a.rows.findIndex(n=>n.key===e),wf=(e,a=Er)=>Math.round(a.columns/pu(e,a).fps*1e3),vN=(e,a=Er)=>pu(e,a).then??null,op=40,dr=[1200,4500],xN=[5e3,14e3],ic=16,lp=24,jN=240,wN=220,SN=new Set(["waiting","blocked"]),_N=new Set(["offline","sleeping"]),ao=(e,[a,n])=>a+e()*(n-a),rd=e=>e==="right"?"walk-right":"walk-left",gu=(e,a)=>Math.max(ic,e-a-ic),ti=(e,a,n)=>Math.min(Math.max(e,ic),gu(a,n)),Sf=(e,a,n)=>Math.min(Math.max(e,0),Math.max(0,a-n)),dp=e=>e==="held"||e==="falling"||e==="dizzy",AN=e=>!e.roam||e.reduced||e.tier==="mobile";function cp(e,a,n){return{x:gu(e,a),y:0,facing:"right",mode:"stand",until:n+dr[0],parkedX:null}}function EN(e,a){const{now:n,laneWidth:i,petWidth:r,pose:s}=a,o=ti(a.currentX,i,r);return{state:{x:o,y:0,facing:e.facing,mode:"stand",until:n+dr[0],parkedX:e.parkedX===null?null:ti(e.parkedX,i,r)},row:qo[s],move:{x:o,y:0,durationMs:0,ease:"linear"}}}const TN=(e,a,n,i,r)=>({...e,x:ti(e.x,a,i),y:Sf(e.y,n,r)});function CN(e,a,n){const{now:i,laneWidth:r,laneHeight:s,petWidth:o,petHeight:l,pose:c}=a,u=gu(r,o),m=qo[c],h=ti(a.currentX,r,o),p=e.mode==="walk"||e.mode==="home",g=e.mode==="dizzy",f=(E,w,N=e.facing)=>({x:E,y:0,facing:N,mode:"stand",until:w,parkedX:e.parkedX}),b=E=>p||Math.abs(h-E)>.5?{x:E,y:0,durationMs:0,ease:"linear"}:null,v=(E,w)=>{const N=Math.round(Math.abs(E-h)/op*1e3),R=E>=h?"right":"left";return{state:{x:E,y:0,facing:R,mode:w,until:i+N,parkedX:e.parkedX},row:rd(R),move:{x:E,y:0,durationMs:N,ease:"linear"}}},x=E=>{const w={x:E,y:0,durationMs:0,ease:"linear"};return a.reduced?{state:{...f(E,1/0),parkedX:E},row:m,move:w}:{state:{x:E,y:0,facing:e.facing,mode:"dizzy",until:i+wf("dizzy"),parkedX:E},row:"dizzy",move:w}};if(a.dragging){const E=ti(a.pointerX,r,o),w=Sf(a.pointerY,s,l);return{state:{x:E,y:w,facing:e.facing,mode:"held",until:1/0,parkedX:e.parkedX},row:"held",move:{x:E,y:w,durationMs:0,ease:"linear"}}}if(e.mode==="held"){if(a.reduced||e.y===0)return x(e.x);const E=Math.max(wN,Math.round(e.y/jN*1e3));return{state:{x:e.x,y:0,facing:e.facing,mode:"falling",until:i+E,parkedX:e.x},row:"falling",move:{x:e.x,y:0,durationMs:E,ease:"fall"}}}if(e.mode==="falling")return i<e.until?{state:e,row:"falling",move:null}:x(e.x);if(e.mode==="dizzy"&&i<e.until)return{state:e,row:"dizzy",move:null};if(AN(a)){const E=ti(e.parkedX??u,r,o);return{state:f(E,1/0,"right"),row:m,move:b(E)}}if(a.hovered||a.panelOpen||a.documentHidden)return{state:f(h,1/0),row:m,move:b(h)};if(_N.has(c))return{state:f(h,1/0),row:m,move:b(h)};if(SN.has(c))return Math.abs(h-u)>1?e.mode==="home"&&i<e.until?{state:e,row:rd(e.facing),move:null}:v(u,"home"):{state:f(u,1/0,"right"),row:m,move:b(u)};if(c==="shipped")return{state:f(h,1/0),row:m,move:b(h)};if(p)return i<e.until?{state:e,row:rd(e.facing),move:null}:{state:f(e.x,i+ao(n,dr)),row:m,move:null};if(g||e.until===1/0)return{state:f(h,i+ao(n,dr)),row:m,move:null};if(i<e.until)return{state:e,row:m,move:null};const y=ao(n,xN)*op/1e3;let T=n()<.5?-1:1,S=ti(h+T*y,r,o);return Math.abs(S-h)<lp&&(T=-T,S=ti(h+T*y,r,o)),Math.abs(S-h)<lp?{state:f(h,i+ao(n,dr)),row:m,move:null}:v(S,"walk")}const Ln={loading:"Membaca layar sesi…",none:"Pertanyaannya tak terbaca dari sini — buka Terminal untuk menjawabnya.",stale:"Layarnya sudah berubah — pertanyaannya dimuat ulang.",deciding:"hanoman-lead sedang menyusun keputusan untuk sesi ini.",failed:"Jawaban tak terkirim. Buka Terminal untuk menjawabnya.",answering:"hanoman-lead sudah mengirim jawabannya ke pane — terlambat mengambil alih.",taken:"Kamu mengambil alih sesi ini. hanoman-lead berhenti menjawabnya.",preparing:"Kotak jawabnya sedang disiapkan — dialognya belum tergambar di pane."},PN={queued:"hanoman-lead mengantre untuk sesi ini",deciding:"hanoman-lead sedang menyusun keputusan",answered:"hanoman-lead sudah menjawab","taken-over":"Kamu yang menjawab sesi ini",failed:"hanoman-lead tak sanggup menjawab sesi ini"},up=e=>{var a;return e instanceof ha?(a=e.detail)==null?void 0:a.reason:void 0};function mp({sessionId:e,label:a,reduced:n,ask:i}){const[r,s]=d.useState(void 0),[o,l]=d.useState([]),[c,u]=d.useState(""),[m,h]=d.useState(!1),[p,g]=d.useState(!1),[f,b]=d.useState(null),[v,x]=d.useState(0);d.useEffect(()=>{let I=!0;return s(void 0),ne.sessionDialog(e).then(B=>{I&&(s(B),l(B?B.dialog.options.filter(A=>A.checked).map(A=>A.n):[]))}).catch(()=>{I&&s(null)}),()=>{I=!1}},[e,v]);async function y(){if(!m){h(!0),b(null);try{await ne.takeoverSessionDialog(e),b(Ln.taken),x(I=>I+1)}catch(I){b(up(I)==="answering"?Ln.answering:Ln.failed)}finally{h(!1)}}}async function T(I){if(!(!r||m)){h(!0),b(null);try{await ne.answerSessionDialog(e,{screenHash:r.screenHash,...I}),g(!0)}catch(B){const A=up(B);A==="stale"?(b(Ln.stale),x(M=>M+1)):b(A==="deciding"?Ln.deciding:Ln.failed)}finally{h(!1)}}}const S=n?{transition:"none",transform:"none"}:void 0,E=I=>t.jsx("div",{"data-testid":"pet-answer-note",className:"hn-pet-note",children:I});if(p)return t.jsx("div",{className:"hn-pet-box",children:t.jsxs("div",{"data-testid":"pet-answer-sent",className:"hn-pet-sent",children:["Terkirim — menunggu ",a," bergerak"]})});const w=i==null?void 0:i.questions[Math.min(i.at,Math.max(0,i.questions.length-1))],N=i?t.jsxs("div",{className:"hn-pet-head",children:[t.jsx("div",{"data-testid":"pet-answer-lead-state",className:"hn-eyebrow",children:PN[i.state]}),i.total>1&&t.jsxs("div",{className:"hn-eyebrow hn-pet-eyebrow-top",children:["Pertanyaan ",Math.min(i.at+1,i.total)," dari ",i.total]}),i.source==="turn-end"&&t.jsx("div",{"data-testid":"pet-answer-source",className:"hn-eyebrow hn-pet-eyebrow-top",children:"Giliran terakhir sesi"}),((w==null?void 0:w.question)||i.message)&&t.jsx("div",{className:"hn-pet-question",children:(w==null?void 0:w.question)||i.message}),i.state!=="taken-over"&&t.jsx("div",{className:"hn-pet-mt-6",children:t.jsx(q,{"data-testid":"pet-answer-takeover",size:"sm",variant:"ghost",disabled:m,style:S,onClick:()=>{y()},children:"Ambil alih"})})]}):null;if(r===void 0)return t.jsxs("div",{className:"hn-pet-box",children:[N,E(Ln.loading)]});if(r===null)return t.jsxs("div",{className:"hn-pet-box",children:[N,E(f??(i?Ln.preparing:Ln.none))]});const{dialog:R}=r,L=R.tabs.filter(I=>I.answered).length;return t.jsxs("div",{"data-testid":"pet-answer","data-session":e,className:"hn-pet-box",children:[N,!i&&R.tabs.length>1&&t.jsxs("div",{className:"hn-eyebrow hn-pet-eyebrow-bottom",children:["Pertanyaan ",Math.min(L+1,R.tabs.length)," dari ",R.tabs.length]}),!i&&R.title&&t.jsx("div",{className:"hn-pet-title",children:R.title}),R.multi?t.jsx("div",{className:"hn-pet-stack",children:R.options.map(I=>t.jsx(vs,{label:I.label,checked:o.includes(I.n),disabled:m,onChange:B=>l(A=>(B?[...A,I.n]:A.filter(M=>M!==I.n)).sort((M,K)=>M-K))},I.n))}):t.jsx("div",{className:"hn-pet-wrap",children:R.options.map(I=>t.jsx(q,{"data-testid":"pet-answer-option",size:"sm",variant:"ghost",disabled:m,style:S,onClick:()=>{T({choice:I.n})},children:I.label},I.n))}),(R.freeIndex!==null||R.notes)&&t.jsxs("div",{className:"hn-pet-free",children:[t.jsx(Oe,{"data-testid":"pet-answer-text",size:"sm",value:c,disabled:m,placeholder:"Jawab dengan kalimatmu sendiri",className:"hn-grow-min",onChange:I=>u(I.target.value)}),!R.multi&&t.jsx(q,{size:"sm",variant:"ghost",disabled:m||!c.trim(),style:S,onClick:()=>{T({text:c.trim()})},children:"Kirim"})]}),R.multi&&t.jsx("div",{className:"hn-pet-mt-8",children:t.jsx(q,{"data-testid":"pet-answer-submit",size:"sm",variant:"primary",disabled:m,style:S,onClick:()=>{T({choices:o,...c.trim()?{text:c.trim()}:{}})},children:"Submit"})}),f&&t.jsx("div",{className:"hn-pet-mt-6",children:E(f)})]})}const MN={mobile:96,tablet:112,desktop:112},ts=44,_f=22,IN=_f+ts,NN=56,RN=6,od=268,LN=10,to=12,no=200,ld=8,BN=5e3,$N=1.5,DN=2e3,ON=3,HN=6,qN={linear:"linear",fall:"var(--ease-fall)"};function UN(){const e="(prefers-reduced-motion: reduce)",[a,n]=d.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return d.useEffect(()=>{var s;if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=window.matchMedia(e),r=()=>n(i.matches);return(s=i.addEventListener)==null||s.call(i,"change",r),()=>{var o;return(o=i.removeEventListener)==null?void 0:o.call(i,"change",r)}},[]),a}function zN(){const[e,a]=d.useState(()=>typeof document<"u"&&document.hidden);return d.useEffect(()=>{const n=()=>a(document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),e}function FN(e,a,n){const i=d.useCallback(()=>{var o;return Math.round(((o=e.current)==null?void 0:o.getBoundingClientRect().width)??0)},[e]),[r,s]=d.useState(0);return d.useLayoutEffect(()=>{n&&s(i())},[i,a,n]),d.useEffect(()=>{const o=e.current;if(!n||!o)return;if(typeof ResizeObserver<"u"){const u=new ResizeObserver(()=>s(i()));return u.observe(o),()=>u.disconnect()}let l;const c=()=>{clearTimeout(l),l=setTimeout(()=>s(i()),150)};return window.addEventListener("resize",c),()=>{clearTimeout(l),window.removeEventListener("resize",c)}},[i,n,e]),r}const GN="(min-width: 1200px) and (max-height: 760px)";function KN(e){const a=d.useCallback(i=>{var s;if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const r=window.matchMedia(e);return(s=r.addEventListener)==null||s.call(r,"change",i),()=>{var o;return(o=r.removeEventListener)==null?void 0:o.call(r,"change",i)}},[e]),n=d.useCallback(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches,[e]);return d.useSyncExternalStore(a,n,()=>!1)}function WN({sessions:e,backlog:a,asks:n=[],onOpen:i}){const{items:r}=Dc(),[s,o]=d.useState(OE),[l,c]=d.useState(qE),[u,m]=d.useState(!1),[h,p]=d.useState(!1),[g,f]=d.useState(to),[b,v]=d.useState(!1),[x,y]=d.useState(!1),[T,S]=d.useState(0),[E,w]=d.useState(null),N=UN(),[R,L]=d.useState(!1);d.useEffect(()=>{const ie=window;if(ie.requestIdleCallback){const qe=ie.requestIdleCallback(()=>L(!0),{timeout:1500});return()=>{var ra;return(ra=ie.cancelIdleCallback)==null?void 0:ra.call(ie,qe)}}const De=window.setTimeout(()=>L(!0),1);return()=>window.clearTimeout(De)},[]);const I=al(),B=zN(),A=KN(GN)&&I==="desktop",M=I!=="desktop",[K,O]=d.useState(!1),J=d.useRef(null),Z=d.useRef(null),H=d.useRef(null),te=FN(J,I,R),[,ae]=tb(),F=c2(),fe=RE(e,r),[_e,ee]=d.useState(fe),[X,ce]=d.useState(()=>Date.now());_e!==fe&&(ee(fe),ce(Date.now()));const se=d.useMemo(()=>DE({sessions:e,backlog:a,notifications:r,now:Date.now(),connection:F,quietSince:X}),[e,a,r,F,X,T]),Ce=d.useMemo(()=>eb(e,a),[e,a]),Te=d.useMemo(()=>LE(e,a),[e,a]);d.useEffect(()=>{if(se.recheckAt===null)return;const ie=setTimeout(()=>S(De=>De+1),Math.max(0,se.recheckAt-Date.now()));return()=>clearTimeout(ie)},[se.recheckAt]),d.useEffect(()=>{if(!E)return;const ie=setTimeout(()=>w(null),E.ttl);return()=>clearTimeout(ie)},[E]);const le=d.useRef(null),ya=d.useRef(null);d.useEffect(()=>{const ie={sessions:e,backlog:a,notifications:r,now:Date.now()};if(B){le.current||(le.current=jf(ie)),ya.current=null;return}const De=le.current;if(!De)return;if(ya.current===null&&(ya.current=ie.now),ie.now-De.at<XI){le.current=null;return}const qe=sN(De,ie);if(qe){le.current=null,w({...qe,id:ie.now});return}ie.now-ya.current>BN&&(le.current=null)},[B,e,a,r]);const Ze=iN(se,Date.now()),[He,Ke]=d.useState((Ze==null?void 0:Ze.text)??null);((Ze==null?void 0:Ze.text)??null)!==He&&(Ke((Ze==null?void 0:Ze.text)??null),Ze&&w({...Ze,id:Date.now()}));const{cell:ga,columns:Ge,anchor:ba,character:Ta,rows:va}=Er,we=MN[I]/Ta.h,Je=Math.round(ga.w*we),U=Math.round(ga.h*we),Be=d.useRef(cp(te,Je,Date.now())),[ue,We]=d.useState(Be.current),[sa,ye]=d.useState(qo[se.pose]),[la,Se]=d.useState({x:Be.current.x,y:0,durationMs:0,ease:"linear"}),[xe,aa]=d.useState(null),Ea=d.useRef(null),dt=d.useRef(!1),qa=d.useCallback(()=>{var qe,ra;const ie=(qe=Z.current)==null?void 0:qe.getBoundingClientRect(),De=(ra=J.current)==null?void 0:ra.getBoundingClientRect();return ie&&De&&ie.width>0?ie.left-De.left:Be.current.x},[]),Xe=d.useCallback(()=>typeof window<"u"?window.innerHeight:U,[U]),ge=d.useMemo(()=>{const ie=la.x+ba.x*Je-no/2,De=Math.min(Math.max(ie,ld),Math.max(ld,te-no-ld));return Math.round(ba.x*Je-no/2+(De-ie))},[la.x,Je,ba.x,te]);d.useEffect(()=>{if(!E||u)return;const ie=qe=>{J.current&&!J.current.contains(qe.target)&&w(null)},De=qe=>{qe.key==="Escape"&&w(null)};return document.addEventListener("mousedown",ie),document.addEventListener("keydown",De),()=>{document.removeEventListener("mousedown",ie),document.removeEventListener("keydown",De)}},[E,u]);const be=d.useRef(0),ua=d.useCallback(()=>{if(te<=0)return;const ie=Date.now();if(be.current===0){be.current=te;const Ga=cp(te,Je,ie);Be.current=Ga,We(Ga),ye(qo[se.pose]),Se({x:Ga.x,y:0,durationMs:0,ease:"linear"});return}const De=be.current!==te;be.current=te;const qe=qa(),ra=De&&xe===null&&!dp(Be.current.mode)?EN(Be.current,{now:ie,currentX:qe,laneWidth:te,petWidth:Je,pose:se.pose}):CN(Be.current,{now:ie,currentX:qe,laneWidth:te,laneHeight:Xe(),petWidth:Je,petHeight:U,pose:se.pose,hovered:x,panelOpen:u,documentHidden:B,roam:l,reduced:N,tier:I,dragging:xe!==null,pointerX:(xe==null?void 0:xe.x)??0,pointerY:(xe==null?void 0:xe.y)??0},Math.random);Be.current=ra.state,We(ra.state),ye(ra.row),ra.move&&Se(ra.move)},[qa,Xe,te,Je,U,se.pose,x,u,B,l,N,I,xe]);d.useEffect(()=>{ua()},[ua]),d.useEffect(()=>{if(!Number.isFinite(ue.until))return;const ie=setTimeout(ua,Math.max(0,ue.until-Date.now()));return()=>clearTimeout(ie)},[ue.until,ua]);const[Da,it]=d.useState(null),It=d.useRef(0),pt=d.useRef([]),[_a,Nt]=d.useState(0),[Rt,st]=d.useState(!1);d.useEffect(()=>{st(!1)},[se.pose]);const Ua=sa==="shipped"&&Rt?vN("shipped")??"idle":sa,Ja=(Da==null?void 0:Da.row)??Ua,Et=pu(Ja),Tt=d.useCallback(()=>!N&&se.pose!=="offline"&&se.pose!=="sleeping"&&xe===null&&!dp(Be.current.mode),[N,se.pose,xe]),Ct=d.useCallback(()=>{Tt()&&it(ie=>ie??{row:"wave",id:++It.current})},[Tt]),jn=d.useCallback(()=>{N||(it({row:"thanks",id:++It.current}),Nt(ie=>ie+1))},[N]);d.useEffect(()=>{if(!u)return;const ie=qe=>{J.current&&!J.current.contains(qe.target)&&xt()},De=qe=>{qe.key==="Escape"&&xt()};return document.addEventListener("mousedown",ie),document.addEventListener("keydown",De),()=>{document.removeEventListener("mousedown",ie),document.removeEventListener("keydown",De)}},[u,N]),d.useEffect(()=>{N&&(v(!1),it(null),u||p(!1))},[N,u]),d.useEffect(()=>{var ie;(ie=H.current)==null||ie.toggleAttribute("inert",!u)},[u,h]);function Pt(){var dn,Lt;const ie=typeof window<"u"?window.innerWidth:te,De=(dn=Z.current)==null?void 0:dn.getBoundingClientRect(),qe=((Lt=J.current)==null?void 0:Lt.getBoundingClientRect().left)??0,Ga=(De&&De.width>0?De.left:qe+Be.current.x)+ba.x*Je,Sn=Math.min(Math.max(Ga-od/2,to),Math.max(to,ie-od-to));f(Math.round(Sn-qe)),p(!0),m(!0)}function xt(){m(!1),N&&p(!1)}function za(){u?xt():Pt()}function on(){const ie=Date.now(),De=[...pt.current.filter(qe=>ie-qe<DN),ie];if(De.length>=ON){pt.current=[],jn();return}pt.current=De,N||v(!0),Ct(),za()}function xa(ie){var De,qe;(qe=(De=ie.currentTarget).setPointerCapture)==null||qe.call(De,ie.pointerId),Ea.current={id:ie.pointerId,dx:ie.clientX-qa(),dy:ie.clientY+Be.current.y,x0:ie.clientX,y0:ie.clientY,moved:!1}}function Gt(ie){const De=Ea.current;if(!(!De||De.id!==ie.pointerId)){if(!De.moved){if(Math.hypot(ie.clientX-De.x0,ie.clientY-De.y0)<=HN)return;De.moved=!0,u&&xt(),it(null)}aa({x:ie.clientX-De.dx,y:De.dy-ie.clientY})}}function ln(ie){var qe,ra;const De=Ea.current;!De||De.id!==ie.pointerId||(Ea.current=null,(ra=(qe=ie.currentTarget).releasePointerCapture)==null||ra.call(qe,ie.pointerId),De.moved&&(dt.current=!0,aa(null)))}function jt(ie){o(ie),HE(ie),ie&&(m(!1),p(!1))}function wn(){if(I==="desktop"&&A){m(!1),p(!1),O(!1);return}I==="desktop"?jt(!0):(m(!1),p(!1),ae(!1))}function Kt(ie){c(ie),UE(ie)}const me=ue.mode==="held"||ue.mode==="falling",ia=s||(A||M)&&!K,Fa=M?NN:ia?IN:U,Ya=TN(la,te,Xe(),Je,U);d.useEffect(()=>{ia&&u&&(m(!1),p(!1))},[ia,u]),d.useEffect(()=>{if(!M||!K)return;const ie=qe=>{J.current&&!J.current.contains(qe.target)&&O(!1)},De=qe=>{qe.key==="Escape"&&!u&&O(!1)};return document.addEventListener("mousedown",ie),document.addEventListener("keydown",De),()=>{document.removeEventListener("mousedown",ie),document.removeEventListener("keydown",De)}},[M,K,u]);const ri={position:"relative",width:"100%",height:Fa,zIndex:80,pointerEvents:"none"},Vn=R?Fa:0;if(d.useLayoutEffect(()=>{const ie=document.documentElement;return ie.style.setProperty("--pet-h",`${Vn}px`),()=>{ie.style.removeProperty("--pet-h")}},[Vn]),!R)return null;if(ia)return t.jsx("div",{"data-testid":"pet-root",ref:J,style:ri,children:t.jsx("button",{"aria-label":"Tampilkan pet Hanoman",onClick:()=>{s&&jt(!1),O(!0)},style:{pointerEvents:"auto",position:"absolute",width:ts,height:ts,padding:0,right:M?"max(var(--page-gutter-x), var(--safe-right))":"max(22px, var(--safe-right))",bottom:M?RN:_f,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",border:"1px solid var(--text-muted)",borderRadius:"var(--radius-pill)",background:"var(--surface-card)",color:"var(--text-strong)",boxShadow:"var(--shadow-sm)"},children:t.jsx(qc,{id:"buntut",size:15})})});const oi=se.pose==="offline",Ni=`Hanoman ${qm[se.pose]} · ${se.headline}`+(se.count>1?` · ${se.count} ${Il[se.kind]}`:""),_s=Ja==="waiting"&&xf(se,Date.now()),ta=Math.round(wf(Ja)/(_s?$N:1)),Ri=N?"none":`hn-pet-frames ${ta}ms steps(${Ge}, end) ${Et.loop?"infinite":"1 forwards"}`;return t.jsxs("div",{"data-testid":"pet-root",ref:J,style:ri,children:[h&&t.jsxs("div",{ref:H,"data-testid":"pet-panel","aria-hidden":!u||void 0,onAnimationEnd:ie=>{ie.animationName==="hn-pet-panel-out"&&!u&&p(!1)},style:{pointerEvents:u?"auto":"none",position:"absolute",left:g,bottom:U+LN,width:od,maxWidth:"calc(100vw - var(--safe-left) - var(--safe-right) - 24px)",maxHeight:"calc(100dvh - var(--safe-top) - var(--safe-bottom) - 120px)",overflowY:"auto",boxSizing:"border-box",padding:14,background:"var(--surface-card)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-lg)",transformOrigin:"center bottom",animation:N?"none":`${u?"hn-pet-panel-in":"hn-pet-panel-out"} var(--dur-slow) var(--ease-out) both`},children:[t.jsx("div",{className:"hn-eyebrow",style:{marginBottom:8},children:qm[se.pose]}),t.jsx("ul",{"data-testid":"pet-conditions",style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:10},children:se.conditions.map((ie,De)=>t.jsxs("li",{"data-testid":"pet-condition","data-kind":ie.kind,style:De>0?{borderTop:"1px solid var(--border-hair)",paddingTop:10}:void 0,children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[t.jsx("span",{style:De===0?{fontFamily:"var(--font-display)",fontSize:15,fontWeight:600,color:"var(--text-strong)",lineHeight:1.25}:{fontFamily:"var(--font-ui)",fontSize:13,fontWeight:600,color:"var(--text-strong)",lineHeight:1.3},children:ie.headline}),ie.count>1&&t.jsx("span",{"data-testid":"pet-condition-count",title:`${ie.count} ${Il[ie.kind]}`,style:{flex:"0 0 auto",padding:"2px 6px",fontFamily:"var(--font-ui)",fontSize:11,fontWeight:700,lineHeight:1,color:"var(--action-on)",background:"var(--action-bg)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-pill)"},children:ie.count})]}),t.jsx("div",{style:{marginTop:3,fontFamily:"var(--font-ui)",fontSize:12.5,color:"var(--text-muted)",lineHeight:1.45},children:ie.detail}),ie.target&&t.jsx("div",{style:{marginTop:7},children:t.jsx(q,{size:"sm",variant:De===0?"primary":"ghost",leftIcon:ie.target.section==="terminal"?"terminal":"list-checks",style:N?{transition:"none",transform:"none"}:void 0,onClick:()=>{const qe=ie.target;xt(),i(qe)},children:ie.target.section==="terminal"?"Buka Terminal":"Buka Backlog"})}),ie.kind==="waiting"&&u&&Ce.map(qe=>t.jsx(mp,{sessionId:qe.id,label:qe.specId??qe.id,reduced:N,ask:n.find(ra=>ra.sessionId===qe.id)},qe.id)),ie.kind==="deciding"&&u&&Te.map(qe=>{const ra=n.find(Ga=>Ga.sessionId===qe.id);return ra?t.jsx(mp,{sessionId:qe.id,label:qe.specId??qe.id,reduced:N,ask:ra},qe.id):null})]},`${ie.kind}:${De}`))}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:12,borderTop:"1px solid var(--border-hair)",paddingTop:10},children:[I!=="mobile"&&t.jsx(q,{size:"sm",variant:"ghost",style:N?{transition:"none",transform:"none"}:void 0,onClick:()=>Kt(!l),children:l?ue.parkedX===null?"Diam di pojok":"Diam di sini":"Berkeliaran"}),t.jsx(q,{size:"sm",variant:"ghost",style:N?{transition:"none",transform:"none"}:void 0,onClick:wn,children:"Sembunyikan"})]})]}),te>0&&t.jsxs("div",{"data-testid":"pet-actor",ref:Z,"data-facing":ue.facing,"data-mode":ue.mode,onTransitionEnd:ie=>{ie.propertyName==="transform"&&ua()},style:{position:"absolute",left:0,bottom:0,width:Je,height:U,transform:`translate(${Ya.x}px, ${-Ya.y}px)`,transition:N||la.durationMs===0?"none":`transform ${la.durationMs}ms ${qN[la.ease]}`,willChange:!N&&la.durationMs>0?"transform":void 0},children:[E&&!u&&t.jsxs("div",{"data-testid":"pet-bubble","data-kind":E.kind,"aria-hidden":E.kind==="pose"&&se.kind!=="waiting"?"true":void 0,style:{pointerEvents:"none",position:"absolute",left:ge,bottom:U-6,width:"max-content",maxWidth:no,boxSizing:"border-box",padding:"6px 10px",fontFamily:"var(--font-ui)",fontSize:12.5,lineHeight:1.35,color:"var(--text-strong)",background:"var(--surface-card)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-sm)",animation:N?"none":"hn-pet-bubble-in var(--dur-base) var(--ease-out) both"},children:[t.jsx("span",{"data-testid":"pet-bubble-text","aria-hidden":E.kind==="pose"?"true":void 0,children:E.text}),(E.kind==="recap"||se.kind==="waiting")&&t.jsx("div",{style:{marginTop:6,pointerEvents:"auto"},children:t.jsx(q,{size:"sm",variant:"ghost",leftIcon:E.kind==="recap"?"list-checks":"terminal","aria-label":E.kind==="recap"?`${E.text} — buka ringkasan pet`:`${E.text} — jawab di sini`,style:N?{transition:"none",transform:"none"}:void 0,onClick:()=>{w(null),Pt()},children:E.kind==="recap"?"Lihat":"Jawab di sini"})})]}),t.jsxs("div",{"data-testid":"pet-stage",className:"hn-pet-stage","data-reduced-motion":N?"true":void 0,style:{position:"relative",width:Je,height:U,animation:N?"none":"hn-pet-reveal var(--dur-slow) var(--ease-out) both"},children:[t.jsx("span",{className:"hn-sr-only",role:"status","aria-live":"polite","data-testid":"pet-status",children:Ni}),se.count>1&&t.jsx("span",{"data-testid":"pet-badge","aria-hidden":"true",title:`${se.count} ${Il[se.kind]}`,style:{pointerEvents:"none",position:"absolute",top:4,right:8,zIndex:2,minWidth:18,height:18,padding:"0 5px",boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",fontFamily:"var(--font-ui)",fontSize:11,fontWeight:700,lineHeight:1,color:"var(--action-on)",background:"var(--action-bg)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-pill)",boxShadow:"var(--shadow-sm)"},children:se.count}),_a>0&&!N&&t.jsx("span",{"data-testid":"pet-hearts","aria-hidden":"true",style:{pointerEvents:"none",position:"absolute",zIndex:2,left:Math.round(ba.x*Je),bottom:Math.round(U*.55)},onAnimationEnd:ie=>{ie.target.dataset.last==="1"&&Nt(0)},children:[0,1,2].map(ie=>t.jsx("span",{"data-last":ie===2?"1":void 0,style:{position:"absolute",left:ie*9-9,fontFamily:"var(--font-ui)",fontSize:12,color:"var(--accent)",animation:`hn-pet-heart 900ms var(--ease-out) ${ie*120}ms both`},children:"♥"},ie))},_a),t.jsx("div",{"data-testid":"pet-reactor",className:"hn-pet-reactor",style:{position:"relative",width:"100%",height:"100%",transition:N?"none":"transform var(--dur-base) var(--ease-out)",animation:N||!b?"none":"hn-pet-click var(--dur-slow) var(--ease-out) both"},onAnimationEnd:ie=>{ie.animationName==="hn-pet-click"&&v(!1)},children:t.jsx("div",{"data-testid":"pet-viewport","data-offline":oi?"true":void 0,style:{position:"relative",overflow:"hidden",width:Je,height:U,opacity:oi?.45:1,transition:N?"none":"opacity var(--dur-slow) var(--ease-out)"},children:t.jsx("div",{"data-testid":"pet-rowshift",className:"hn-pet-rowshift","data-row":Ja,style:{width:Je,height:U,"--row":yN(Ja)},children:t.jsx("img",{"data-testid":"pet-atlas",src:fN,alt:"","aria-hidden":"true",draggable:!1,decoding:"async",onAnimationEnd:ie=>{if(ie.animationName==="hn-pet-frames"){if(Da){Da.row==="wave"&&x&&Tt()?it({row:"wave",id:++It.current}):it(null);return}Ja==="shipped"&&st(!0)}},style:{display:"block",width:Je*Ge,height:U*va.length,animation:Ri}},`${Ja}:${(Da==null?void 0:Da.id)??0}`)})})}),t.jsx("button",{"data-testid":"pet-hit",className:"hn-pet-hit","aria-label":"Ringkasan status Hanoman",title:`${se.headline} — ${se.detail}`,onClick:()=>{if(dt.current){dt.current=!1;return}on()},onPointerDown:xa,onPointerMove:Gt,onPointerUp:ln,onPointerCancel:ln,onPointerEnter:()=>{y(!0),Ct()},onPointerLeave:()=>y(!1),onFocus:()=>y(!0),onBlur:()=>y(!1),style:{pointerEvents:"auto",position:"absolute",zIndex:3,left:Math.round(ba.x*Je-ts/2),bottom:0,width:ts,height:ts,padding:0,border:"none",background:"transparent",cursor:me?"grabbing":"grab"}})]})]})]})}const VN=d.lazy(()=>nn(()=>import("./DalangHanomanScreen-BMQjWbwC.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.DalangHanomanScreen}))),YN=d.lazy(()=>nn(()=>import("./TeamScreen-WvQNIYf0.js"),__vite__mapDeps([5,1,6,2,3,7])).then(e=>({default:e.TeamScreen}))),JN=d.lazy(()=>nn(()=>import("./TriageScreen-CfzqvbI2.js"),__vite__mapDeps([8,1,6,2,3,9])).then(e=>({default:e.TriageScreen}))),QN=d.lazy(()=>nn(()=>import("./TerminalScreen-BYx1OK27.js"),__vite__mapDeps([10,1,2,3,11])).then(e=>({default:e.TerminalScreen}))),ZN=d.lazy(()=>nn(()=>import("./IdeScreen-1V2L_82g.js"),__vite__mapDeps([12,1,13,14,6,2,3,15])).then(e=>({default:e.IdeScreen}))),XN=d.lazy(()=>nn(()=>import("./VpsScreen-XWHjdq4i.js"),__vite__mapDeps([16,1,2,3,17])).then(e=>({default:e.VpsScreen}))),eR=d.lazy(()=>nn(()=>import("./SchedulerScreen-b4hvb1Sy.js"),__vite__mapDeps([18,1,6,2,19,20,21,3])).then(e=>({default:e.SchedulerScreen}))),aR=d.lazy(()=>nn(()=>import("./LeadScreen-D7njTsNH.js"),__vite__mapDeps([22,1,6,2,19,20,3,23])).then(e=>({default:e.LeadScreen}))),tR=d.lazy(()=>nn(()=>import("./DocsWorkspace-Bo2dJRqt.js"),__vite__mapDeps([24,1,2,3,25])).then(e=>({default:e.DocsWorkspace}))),nR=d.lazy(()=>nn(()=>import("./ReviewScreen-BytyE-o3.js"),__vite__mapDeps([26,1,14,2,3])).then(e=>({default:e.ReviewScreen}))),iR=d.lazy(()=>nn(()=>import("./SettingsScreen-C9YeMz1R.js"),__vite__mapDeps([27,1,2,21,20,14,3,28])).then(e=>({default:e.SettingsScreen}))),sR=[{value:"critical",label:"Critical"},{value:"major",label:"Major"},{value:"minor",label:"Minor"}],hp=[{value:"tinggi",label:"Tinggi"},{value:"sedang",label:"Sedang"},{value:"rendah",label:"Rendah"}];function rR(e){switch(e){case"offline":return"offline";case"control-off":return"kendali jarak jauh mati";case"protocol-mismatch":return"versi tak cocok";case"no-spawn":return"tanpa izin mulai sesi";case"capacity-full":return"kapasitas penuh";default:return"tak tersedia"}}function oR({open:e,spec:a,onClose:n,onStarted:i,onError:r}){var Je,U,Be;const[s,o]=d.useState("sonnet"),[l,c]=d.useState("medium"),[u,m]=d.useState("claude"),[h,p]=d.useState({claude:{model:"sonnet",effort:"medium"},codex:{...bd}}),[g,f]=d.useState({}),[b,v]=d.useState(!1),[x,y]=d.useState(""),[T,S]=d.useState("changed"),[E,w]=d.useState(Mu().id),[N,R]=d.useState(!1),[L,I]=d.useState(null);d.useEffect(()=>{I(null)},[e,a==null?void 0:a.id]);const[B,A]=d.useState([{deviceId:mn,name:"hub ini",eligible:!0}]),[M,K]=d.useState(mn),[O,J]=d.useState(null),[Z,H]=d.useState(null),[te,ae]=d.useState(void 0),[F,fe]=d.useState(!1),[_e,ee]=d.useState(!1),[X,ce]=d.useState(!1),[se,Ce]=d.useState(null);d.useEffect(()=>{e&&(fe(!1),ee(!1),ce(!1),f({}),ne.getSettings().then(ue=>{const We={claude:{model:ue.model,effort:ue.effort},codex:{...bd,...ue.codex??{}}},sa=ue.agent==="codex"?"codex":"claude";p(We),m(sa),o(We[sa].model),c(We[sa].effort);const ye=!!a&&Gu(ur(a.source));v(ye||ue.goal.enabled),y(ye?"":ue.goal.condition),S(ue.verifyScope??"changed"),w(Mu(ue.method).id),ae(ue.orchestration),fe(!0)}).catch(()=>{ee(!0),fe(!0)}),ne.getCodexVersion().then(ue=>{H(ue.version),ce(!0)}).catch(()=>{ce(!0)}),ne.getMethodStatus().then(ue=>Ce(ue.methods)).catch(()=>Ce(null)))},[e,a]),d.useEffect(()=>{if(!e||!a)return;let ue=!1;return(async()=>{try{const[We,sa]=await Promise.all([typeof ne.presence=="function"?ne.presence():Promise.resolve({enabled:!1,devices:[],hubVersion:""}),typeof ne.getProject=="function"?ne.getProject(a.projectId).then(Se=>Se.handledBy??[]).catch(()=>[]):Promise.resolve([])]);if(ue)return;const ye=JE(We,sa);A(ye);const la=ye.find(Se=>Se.deviceId!==mn&&Se.eligible);K((la==null?void 0:la.deviceId)??mn)}catch{if(ue)return;A([{deviceId:mn,name:"hub ini",eligible:!0}]),K(mn)}})(),()=>{ue=!0}},[e,a==null?void 0:a.id]);const Te=M!==mn,le=d.useMemo(()=>Te?Nc({base:`/api/devices/${M}/relay`}):ne,[Te,M]),ya=ue=>{m(ue),f({});const We=eT(h,ue);o(We.model),c(We.effort)},Ze=ue=>{o(ue),c(We=>u==="codex"?Jo(ue,We):Vo(ue,We))},He=nb(u,s);if(!a)return null;const Ke=a,ga=ur(Ke.source),Ge=Gu(ga),ba=Ke.blockedBy??[],Ta=ba.length>0,va=(se==null?void 0:se.find(ue=>ue.method===E&&ue.agent===u))??null;async function we(ue=!1,We=!1){R(!0),I(null),J(null);try{const{id:sa,resumed:ye}=await le.startSession({spec:Ke.id,flow:ga,model:s,effort:l,agent:u,...Object.keys(g).length?{phaseOverrides:g}:{},goal:b,goalCondition:b&&x.trim()?x.trim():void 0,verifyScope:T,method:E,...Ta||ue?{force:!0}:{},...We?{confirmRemote:!0}:{}});i(sa,ye),n()}catch(sa){if(sa instanceof ha&&sa.status===409&&sa.detail&&typeof sa.detail=="object"&&(sa.detail.error==="remote-session"||sa.detail.error==="confirm-required")){J(sa.detail);return}const ye=sa instanceof ha&&sa.status===409?vg.safeParse(sa.detail):null;ye!=null&&ye.success?I(ye.data):r==null||r(sa)}finally{R(!1)}}return t.jsxs(da,{open:e,onClose:n,icon:"play",eyebrow:`${Ke.id} · ${ga}`,title:"Mulai sesi",footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",onClick:n,children:"Batal"}),t.jsx(q,{leftIcon:Ta?"lock":"play",variant:Ta?"danger":"primary",disabled:N,onClick:()=>void we(),children:Ta?"Mulai tetap":L?"Coba lagi":"Mulai"}),L&&!Ta&&!Te&&t.jsx(q,{leftIcon:"lock",variant:"danger",disabled:N,onClick:()=>void we(!0),children:"Mulai tetap"})]}),children:[t.jsxs("div",{className:"hn-sheet-lead",children:["Agen, model & effort ",t.jsx("b",{children:"orchestrator"})," sesi ini. Default dari setelan global; ubah bila perlu. Bila orkestrasi flow ini aktif, tiap fase dikerjakan subagent dengan model & effort di bawah (Settings › Orkestrasi). Override di bawah hanya berlaku untuk sesi ini dan tidak mengubah Settings."]}),L&&t.jsxs("div",{role:"alert",className:"hn-sheet-alert",children:[t.jsx("b",{children:L.error}),t.jsxs("div",{children:[L.admission.liveCount," sesi hidup · ",L.admission.liveAgentCount," agen terstruktur · cap ",L.admission.maxConcurrent]}),t.jsxs("div",{children:["Load per core: ",L.admission.loadStatus==="available"&&L.admission.loadPerCore!==null?L.admission.loadPerCore.toFixed(2):"tidak tersedia",L.admission.loadStatus==="unsupported"?" (tidak didukung platform)":""," · ambang ",L.admission.maxLoadPerCore]}),t.jsx("div",{children:"Coba lagi setelah beban turun, atau pilih Mulai tetap untuk melewati cap dan pemeriksaan beban host."})]}),Ta&&t.jsxs("div",{"data-testid":"dep-blocked-note",className:"hn-sheet-alert",children:["Backlog ini menunggu"," ",t.jsx("b",{children:ba.map(ue=>`${ue.id} (${ue.reason==="missing"?"tak ditemukan":ue.reason==="unmerged"?"belum ter-merge":"belum selesai"})`).join(", ")}),". Sesi tetap bisa dimulai, tapi worktree-nya lahir dari basis yang belum memuat pekerjaan itu."," ","Mulai tetap juga melewati cap sesi dan pemeriksaan beban host."]}),t.jsx(oe,{label:"Target",hint:"Mesin yang menjalankan sesi ini. Tak terpilih tetap tampil beserta alasannya.",children:t.jsx($e,{"aria-label":"target",value:M,className:"hn-w-full",options:B.map(ue=>({value:ue.deviceId,label:ue.eligible?ue.name:`${ue.name} — ${rR(ue.reason)}`,disabled:!ue.eligible})),onChange:ue=>{K(ue.target.value),J(null)}})}),(O==null?void 0:O.error)==="remote-session"&&O.remoteSession&&t.jsxs("div",{role:"alert",className:"hn-sheet-notice",children:["Sesi ini sudah berjalan di ",t.jsx("b",{children:O.remoteSession.name}),"."]}),(O==null?void 0:O.error)==="confirm-required"&&t.jsxs("div",{role:"alert",className:"hn-sheet-notice",children:[t.jsx("div",{children:"Device terakhir yang mengerjakan ini sudah offline."}),t.jsx(q,{variant:"danger",disabled:N,onClick:()=>void we(!1,!0),children:"Tetap mulai"})]}),t.jsx(oe,{label:"Agen",hint:"Mesin yang menjalankan sesi ini. Perilaku sesi sama; hanya CLI-nya berbeda.",children:t.jsx($e,{"aria-label":"Agen",value:u,className:"hn-w-full",options:[{value:"claude",label:"Claude Code"},{value:"codex",label:"Codex CLI"}],onChange:ue=>ya(ue.target.value)})}),t.jsx(oe,{label:"Model",children:t.jsx($e,{"aria-label":"Model",value:s,className:"hn-w-full",options:XE(u,s),onChange:ue=>Ze(ue.target.value)})}),t.jsx(oe,{label:"Effort",children:t.jsx($e,{"aria-label":"Effort",value:l,className:"hn-w-full",options:He.map(ue=>({value:ue,label:ue})),onChange:ue=>c(ue.target.value)})}),u==="codex"&&jv(s,Z)&&t.jsxs("div",{"data-testid":"codex-version-note",className:"hn-sheet-note",children:["Codex CLI terpasang ",t.jsx("b",{children:Z}),", sedangkan ",t.jsx("b",{children:s})," butuh ",t.jsx("b",{children:(Je=Yo(s))==null?void 0:Je.minClient}),". Sesi tetap boleh dijalankan, tapi modelnya belum tentu dikenali CLI ini."]}),t.jsx(oT,{flow:ga,agent:u,model:s,effort:l,orchestration:te,codexVersion:Z,phaseOverrides:g,onPhaseOverridesChange:f,loadError:_e,remoteTarget:Te?((U=B.find(ue=>ue.deviceId===M))==null?void 0:U.name)??M:null,loading:!F||u==="codex"&&!X}),t.jsxs(oe,{label:"Mode goal",hint:Ge?"Backlog goal selalu berjalan dalam mode goal — sesi menolak berhenti sampai goal item ini terbukti tercapai. Kosongkan kondisi untuk memakai goal item apa adanya.":"Sesi menolak berhenti sampai kondisinya terbukti. Kosongkan kondisi untuk memakai bawaan hanoman: semua fase tercatat, plan tak menyisakan task, push sukses.",children:[t.jsxs("div",{className:b?"hn-goal-row hn-goal-row--on":"hn-goal-row",children:[t.jsx(el,{"aria-label":"Mode goal",checked:b,disabled:Ge,onChange:ue=>{Ge||v(ue)}}),t.jsx("span",{className:"hn-sheet-meta",children:Ge?"aktif · terkunci":b?"aktif":"nonaktif"})]}),b&&t.jsx(Ia,{value:x,rows:4,mono:!0,placeholder:Ge?"Kosong = goal backlog item ini · mis. semua fase tercatat & plan tanpa - [ ]":"Kosong = kondisi bawaan hanoman · mis. semua fase tercatat & plan tanpa - [ ]",onChange:ue=>y(ue.target.value)})]}),t.jsx(oe,{label:"Scope verifikasi",hint:"Hanya yang berubah = test/typecheck/lint hanya menyentuh berkas yang disentuh sesi ini. Suite penuh tetap dijalankan manusia sebelum merge.",children:t.jsx($e,{"aria-label":"Scope verifikasi",value:T,className:"hn-w-full",options:[{value:"changed",label:"Hanya yang berubah — hemat RAM & CPU"},{value:"full",label:"Seluruh project"}],onChange:ue=>S(ue.target.value)})}),t.jsxs(oe,{label:"Metode",hint:"Metodologi kerja sesi ini: skill per fase + direktori plan/spec. Fase-fasenya sendiri tak berubah. Item yang sudah pernah dijalankan memakai metode tercatatnya saat dilanjutkan.",children:[t.jsx($e,{"aria-label":"Metode",value:E,className:"hn-w-full",options:cc.map(ue=>({value:ue,label:Ci[ue].label})),onChange:ue=>w(ue.target.value)}),t.jsxs("div",{"data-testid":"method-requires",className:"hn-sheet-foot",children:["Butuh terpasang: ",((Be=Ci[E])==null?void 0:Be.requires.join(" · "))??"—"]}),va&&!va.ready&&t.jsxs("div",{"data-testid":"method-status-note",className:"hn-sheet-status",children:[t.jsx("b",{children:va.label})," belum siap untuk ",t.jsx("b",{children:u==="codex"?"Codex CLI":"Claude Code"})," di mesin ini",va.missingPackages.length>0&&t.jsxs(t.Fragment,{children:[" · paket kurang: ",t.jsx("code",{children:va.missingPackages.join(" · ")})]}),va.missingSkills.length>0&&t.jsxs(t.Fragment,{children:[" · skill kurang: ",t.jsx("code",{children:va.missingSkills.join(" · ")})]}),"."," ","Sesi tetap boleh dijalankan, tapi gerbang yang disebut prompt tak akan ada. Pasang dari Settings → Sesi."]})]})]})}function lR({open:e,onClose:a,projects:n,defaultProject:i,onCreate:r,prefill:s,specs:o}){const l={kind:(s==null?void 0:s.kind)??"brief",project:(s==null?void 0:s.project)||i,title:(s==null?void 0:s.title)??"",context:(s==null?void 0:s.context)??"",outcome:(s==null?void 0:s.outcome)??"",constraints:(s==null?void 0:s.constraints)??"",priority:"sedang",severity:(s==null?void 0:s.severity)??"major",steps:(s==null?void 0:s.steps)??"",expected:"",actual:(s==null?void 0:s.actual)??"",env:"",branchFrom:(s==null?void 0:s.branchFrom)??"",fromAudit:(s==null?void 0:s.fromAudit)??"",goal:(s==null?void 0:s.goal)??"",done:(s==null?void 0:s.done)??"",dependsOn:[],attachments:[]},[c,u]=d.useState(l);d.useEffect(()=>{e&&u({...l,project:(s==null?void 0:s.project)||i})},[e,i,s]);const[m,h]=d.useState([]),[p,g]=d.useState(new Set);d.useEffect(()=>{if(!e||!c.project){h([]),g(new Set);return}let N=!0;return ne.listBranches(c.project).then(R=>{if(!N)return;const L=[...new Set([...R.branches,...R.remotes])].sort();h(L),g(new Set(R.remotes.filter(I=>!R.branches.includes(I)))),u(I=>I.branchFrom&&!L.includes(I.branchFrom)?{...I,branchFrom:""}:I)}).catch(()=>{N&&(h([]),g(new Set))}),()=>{N=!1}},[e,c.project]);const f=N=>R=>u(L=>({...L,[N]:R.target.value})),b=c.kind==="qa",v=c.kind==="audit",x=c.kind==="goal",y=c.kind==="no_effort",T=Ti(c.kind)==="goal",S=(o??[]).filter(N=>N.projectId===c.project),E=N=>u(R=>({...R,dependsOn:R.dependsOn.includes(N)?R.dependsOn.filter(L=>L!==N):[...R.dependsOn,N]})),w=()=>{!c.title.trim()||T&&!c.goal.trim()||r(c)};return t.jsxs(da,{open:e,onClose:a,icon:b?"bug":v?"search":y?"zap":x?"target":"lightbulb",eyebrow:"human → hanoman",title:b?"QA finding baru":v?"Audit baru":y?"Task remeh baru":x?"Goal baru":"Feature brief baru",footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:a,children:"Batal"}),t.jsx(q,{size:"sm",leftIcon:b?"radar":v?"search":y?"zap":x?"target":"messages-square",onClick:w,children:b?"Filekan finding → audit":v?"Buat audit → investigasi":y?"Buat task → sesi satu fase":x?"Buat goal → sesi goal":"Buat brief → brainstorm"})]}),children:[t.jsxs("div",{className:"hn-sheet-block",children:[t.jsx(_t,{variant:"pill",className:"hn-sheet-kinds",value:c.kind,onChange:N=>u(R=>({...R,kind:N})),tabs:[{value:"brief",label:"Feature brief",icon:"lightbulb"},{value:"qa",label:"QA finding",icon:"bug"},{value:"audit",label:"Audit",icon:"search"},{value:"goal",label:"Goal",icon:"target"},{value:"no_effort",label:"Tanpa effort",icon:"zap"}]}),t.jsx("div",{className:"hn-sheet-hint",children:y?"Sesi satu fase (Kerjakan): langsung mengerjakan lalu berhenti — tanpa brainstorm, spec, plan, maupun fase pembuktian terpisah. Untuk ganti copy, bump konstanta, perbaiki typo docs, tambah satu baris allowlist.":x?"Sesi goal langsung mengejar goal-nya — tanpa brainstorm, spec, atau plan (fase: Goal → Verifikasi). Sesi lahir dengan mode goal aktif dan menolak berhenti sampai buktinya ada di transkrip.":b?"Finding masuk lewat alur audit → spec → plan → execute. hanoman menelusuri akar masalah dulu.":v?"Audit HANYA menghasilkan dokumen (audit → laporan) — tanpa perbaikan kode. Bisa dinaikkan jadi Finding QA bila perlu diperbaiki.":"Brief masuk lewat alur brainstorm → objective → spec → plan → execute."})]}),t.jsx(oe,{label:"Project",children:t.jsx($e,{value:c.project,onChange:f("project"),className:"hn-w-full",options:n.map(N=>({value:N.id,label:N.name}))})}),t.jsx(oe,{label:"Branch",hint:"branch yang disalin ke worktree (salinan kerja terpisah untuk sesi ini) saat sesi dimulai",children:t.jsx($e,{value:c.branchFrom,onChange:f("branchFrom"),disabled:!m.length,className:"hn-w-full",options:cb(m,p)})}),t.jsx(oe,{label:"Bergantung pada",hint:"Backlog yang harus selesai & ter-merge lebih dulu. Kosongkan bila item ini berdiri sendiri.",children:S.length===0?t.jsx("div",{className:"hn-sheet-empty",children:"Belum ada backlog lain di project ini."}):t.jsx("div",{className:"hn-dep-list",children:S.map(N=>t.jsx(vs,{"aria-label":`Bergantung pada ${N.id}`,checked:c.dependsOn.includes(N.id),onChange:()=>E(N.id),label:`${N.id} · ${N.title}`},N.id))})}),t.jsx(oe,{label:"Judul",children:t.jsx(Oe,{"aria-label":"Judul",value:c.title,onChange:f("title"),placeholder:b?"mis. Funnel double-count sesi lintas tengah malam":y?"mis. Label tombol Simpan di form backlog":x?"mis. Latensi daftar backlog":"mis. Jadwal invoice berulang",className:"hn-w-full"})}),T?t.jsxs(t.Fragment,{children:[t.jsx(oe,{label:"Goal",hint:"Keadaan yang harus tercapai — inilah yang dikejar sesi sampai terbukti",children:t.jsx(Ia,{"aria-label":"Goal",value:c.goal,onChange:f("goal"),rows:3,placeholder:"mis. p95 GET /api/specs di bawah 200 ms"})}),t.jsx(oe,{label:"Selesai bila",hint:"Bukti yang harus muncul di transkrip; kosongkan bila goal-nya sudah jadi buktinya sendiri",children:t.jsx(Ia,{"aria-label":"Selesai bila",value:c.done,onChange:f("done"),rows:2,placeholder:"mis. output benchmark menunjukkan < 200 ms"})}),t.jsxs("div",{className:"hn-grid-mobile hn-grid-split",children:[t.jsx(oe,{label:"Batasan",hint:"opsional",children:t.jsx(Oe,{"aria-label":"Batasan",value:c.constraints,onChange:f("constraints"),placeholder:"mis. tanpa cache eksternal",className:"hn-w-full"})}),t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{"aria-label":"Prioritas",value:c.priority,onChange:f("priority"),className:"hn-w-full",options:hp})})]})]}):b?t.jsxs(t.Fragment,{children:[t.jsx(oe,{label:"Severity",children:t.jsx($e,{value:c.severity,onChange:f("severity"),className:"hn-w-full",options:sR})}),t.jsx(oe,{label:"Langkah reproduksi",children:t.jsx(Ia,{value:c.steps,onChange:f("steps"),rows:3,mono:!0,placeholder:`1. Buka …
|
|
1010
|
+
3. Amati …`],["expected","Diharapkan","mis. total funnel sama dengan jumlah baris laporan harian"],["actual","Aktual","mis. total funnel dua kali lipat untuk sesi yang melewati tengah malam"],["env","Environment","prod · web · v0.9.2"],["constraints","Batasan","mis. jangan ubah kontrak API"]],tc={brief:wI,qa:_I,goal:SI},nc=[{value:"tinggi",label:ms.tinggi},{value:"sedang",label:ms.sedang},{value:"rendah",label:ms.rendah}],df=[{value:"critical",label:Tl.critical},{value:"major",label:Tl.major},{value:"minor",label:Tl.minor}];function AI({spec:e,onClose:a,onSubmit:n}){var E;const i=e.stage!=="brainstorming"||e.baseSha!=null,r=jI.filter(w=>w.value!==e.source),[s,o]=d.useState(((E=r[0])==null?void 0:E.value)??""),l=i&&ur(s)!==ur(e.source),c=i&&!l,u=d.useMemo(()=>wy(s,e.payload),[s,e.payload]),[m,h]=d.useState(()=>u.payload),[p,g]=d.useState(null),[f,b]=d.useState(!1);d.useEffect(()=>{h(u.payload),g(null)},[s]);const v=w=>N=>h(R=>({...R,[w]:N.target.value})),x=Ti(s),y=tc[x]??[],T=w=>{var N;return((N=(tc[dc(e.payload)]??[]).find(([R])=>R===w))==null?void 0:N[1])??w};async function S(w){if(!f){b(!0);try{const N=await n(s,c?void 0:{...m},w);N&&N.pending?g(N):a()}finally{b(!1)}}}return p?t.jsxs(da,{open:!0,title:"Item ini akan dikembalikan ke Brainstorming",icon:"rotate-ccw",eyebrow:`${e.id} · ${ai(e.source).label} → ${ai(s).label}`,onClose:f?void 0:a,children:[t.jsxs("div",{className:"hn-dia-lead hn-dia-lead-sm",children:["Alur kerja ",ai(s).label," berbeda dari yang sudah dikerjakan, jadi item ini mulai lagi dari awal. Kode yang sudah ter-commit di branch lain tak disentuh."]}),t.jsxs("ul",{"data-testid":"source-reset-impact",className:"hn-dia-impact",children:[p.wouldDelete.map(w=>t.jsx("li",{children:w},w)),p.worktree&&t.jsx("li",{children:p.worktree}),p.branch&&t.jsx("li",{children:p.branch}),!p.wouldDelete.length&&!p.worktree&&!p.branch&&t.jsx("li",{children:"tak ada berkas yang perlu dibuang — hanya tahapnya yang mundur"})]}),t.jsxs("div",{className:"hn-dia-foot",children:[t.jsx(q,{size:"sm",variant:"secondary",disabled:f,onClick:a,children:"Batal"}),t.jsx(q,{size:"sm",variant:"danger",leftIcon:"rotate-ccw",loading:f,onClick:()=>S(!0),children:"Reset & ubah type"})]})]}):t.jsxs(da,{open:!0,title:"Ubah type backlog item",icon:"shuffle",eyebrow:`${e.id} · ${ai(e.source).label}`,onClose:a,children:[t.jsx(oe,{label:"Type tujuan",children:t.jsx($e,{"aria-label":"Type tujuan",value:s,onChange:w=>o(w.target.value),options:r,className:"hn-dia-full"})}),!r.length&&t.jsx("div",{className:"hn-dia-note",children:"Tak ada type lain yang bisa dituju. Dialog tetap terbuka dan mengatakannya — menolak dengan diam adalah bug yang melahirkan ADR-0149."}),c?t.jsxs("div",{className:"hn-dia-note",children:["Item ini sudah pernah dikerjakan sesi, dan type tujuannya memakai alur kerja yang sama — yang berpindah hanya ",t.jsx("strong",{children:"labelnya"}),". Isi, worktree, dan berkas fase tak disentuh."]}):t.jsxs(t.Fragment,{children:[l&&t.jsxs("div",{"data-testid":"source-reset-warning",className:"hn-dia-box",children:[t.jsx(oa,{tone:"warn",size:"sm",children:"alur kerja berbeda"})," ","Item ini akan kembali ke tahap ",t.jsx("strong",{children:"Brainstorming"}),"; dokumen fase, worktree, dan branch sesi lamanya dihapus. Daftar persisnya ditampilkan sebelum kamu menyetujui."]}),u.dropped.length>0&&t.jsxs("div",{"data-testid":"source-dropped",className:"hn-dia-box hn-dia-box-muted",children:[t.jsx(oa,{tone:"warn",size:"sm",children:"tak punya padanan"})," ",u.dropped.map(T).join(", ")," tidak ada di bentuk"," ",ai(s).label,". Teks lamanya tetap tersimpan di"," ",t.jsx("strong",{children:"jejak konversi"})," item ini."]}),x!=="qa"&&t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{"aria-label":"Prioritas",value:m.priority??"sedang",onChange:v("priority"),options:nc,className:"hn-dia-full"})}),y.map(([w,N,R])=>t.jsx(oe,{label:N,children:w==="severity"?t.jsx($e,{"aria-label":N,value:m[w]??"minor",onChange:v(w),options:df,className:"hn-dia-full"}):t.jsx(Ia,{"aria-label":N,value:m[w]??"",onChange:v(w),rows:2,placeholder:R})},w))]}),t.jsxs("div",{className:"hn-dia-foot hn-dia-foot-tight",children:[t.jsx(q,{size:"sm",variant:"secondary",onClick:a,children:"Batal"}),t.jsx(q,{size:"sm",variant:"primary",leftIcon:"shuffle",loading:f,disabled:!r.length,onClick:()=>S(),children:"Ubah type"})]})]})}const Yh=280;function cf({spec:e,onClose:a,onSubmit:n}){const[i,r]=d.useState(""),[s,o]=d.useState(null),[l,c]=d.useState(!1),u=d.useRef(!1);async function m(){if(!u.current){u.current=!0,c(!0);try{const h=await n(e,i.trim(),s!==null);if(h&&"needConfirm"in h){o(h.sessionId??"");return}h&&a()}finally{u.current=!1,c(!1)}}}return t.jsxs(da,{open:!0,title:"Tandai selesai",icon:"circle-check",eyebrow:e.id+" · "+e.projectId,onClose:l?void 0:a,children:[t.jsx("div",{style:{fontSize:13,color:"var(--text-muted)",lineHeight:1.55,marginBottom:14},children:"Item keluar dari daftar siap-kerja dan berstatus selesai — sama seperti item yang selesai lewat sesi. Kode, commit, dan dokumen tidak disentuh, dan status ini masih bisa dikembalikan lewat “Ubah status”."}),s!==null&&t.jsxs("div",{"data-testid":"mark-done-live",style:{border:"1px solid var(--border-hair)",borderRadius:"var(--radius-sm)",background:"var(--bone-100)",padding:10,marginBottom:14,fontSize:12.5,color:"var(--text-strong)",lineHeight:1.5},children:["Masih ada sesi yang berjalan untuk item ini",s?` (${s})`:"",". Menandainya selesai tidak menghentikan sesi itu — tutup sesinya dari Terminal bila memang sudah tak dibutuhkan."]}),t.jsx(oe,{label:"Alasan singkat (opsional)",hint:`${i.trim().length}/${Yh} — mis. “sudah ter-merge lewat PR #12”`,children:t.jsx(Ia,{"aria-label":"Alasan singkat (opsional)",rows:2,value:i,maxLength:Yh,disabled:l,onChange:h=>r(h.target.value),placeholder:"sudah dikerjakan langsung di checkout"})}),t.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[t.jsx(q,{size:"sm",variant:"secondary",disabled:l,onClick:a,children:"Batal"}),t.jsx(q,{size:"sm",variant:"primary",leftIcon:"circle-check",loading:l,onClick:m,children:s!==null?"Tandai selesai — sesi tetap berjalan":"Tandai selesai"})]})]})}const kn=[{key:"brainstorming",label:"Brainstorm"},{key:"objective",label:"Objective"},{key:"spec-ready",label:"Spec"},{key:"planned",label:"Plan"},{key:"executing",label:"Execute"},{key:"done",label:"Done"}],uf=e=>kn.findIndex(a=>a.key===e),mf={brainstorming:"Brainstorm: ide digali bersama agen sebelum tujuan dikunci",objective:"Objective: tujuan terukur dikunci sebelum spec ditulis","spec-ready":"Spec: dokumen spesifikasi ditulis",planned:"Plan: rencana langkah disusun",executing:"Execute: kode dikerjakan di worktree sesi",done:"Done: item selesai"},lr=[{key:"all",label:"Semua",stages:kn.map(e=>e.key)},{key:"brainstorm",label:"Brainstorm",stages:["brainstorming","objective"]},{key:"spec",label:"Spec",stages:["spec-ready","planned"]},{key:"doing",label:"Dikerjakan",stages:["executing"]},{key:"done",label:"Selesai",stages:["done"]}],Jh=(e,a)=>{var n;return a==="all"||(((n=lr.find(i=>i.key===a))==null?void 0:n.stages.includes(e))??!1)},hf=e=>{var a;return((a=lr.find(n=>n.key!=="all"&&n.stages.includes(e)))==null?void 0:a.label)??e},pf={brainstorming:"idle",objective:"idle","spec-ready":"queued",planned:"queued",executing:"running",done:"done"},EI=e=>e==="brainstorming"?"Mulai":"Lanjutkan",Qh={tinggi:{tone:"brass",label:ms.tinggi,level:"high"},sedang:{tone:"neutral",label:ms.sedang,level:"mid"},rendah:{tone:"neutral",label:ms.rendah,level:"low"}},Ho=e=>Qh[e]??Qh.sedang,Zh=[{value:"all",label:"Semua sumber"},{value:"brief",label:"Dari brief"},{value:"qa",label:"Dari QA"},{value:"audit",label:"Audit"},{value:"goal",label:"Goal"},{value:"help",label:"Help Center"},{value:"no_effort",label:"Tanpa effort"}],TI=[{value:"all",label:"Semua prioritas"},{value:"tinggi",label:"Tinggi"},{value:"sedang",label:"Sedang"},{value:"rendah",label:"Rendah"}],Xh={audit:"Audit: hasil pemeriksaan project. Dari sini bisa dinaikkan jadi Finding QA, feature brief, atau PRD.",goal:"Goal: item dengan tujuan terukur. Dikerjakan dua fase (Goal lalu Verifikasi) tanpa tahap perencanaan.",no_effort:"Tanpa effort: tugas remeh yang dikerjakan satu fase, tanpa perencanaan maupun verifikasi."},gf=e=>e==="missing"?"tak ditemukan":e==="unmerged"?"belum ter-merge":"belum selesai";function mu({spec:e}){const a=e.blockedBy??[];return a.length?t.jsx(oa,{tone:"warn",size:"sm",icon:"lock",title:a.map(n=>`${n.id} — ${gf(n.reason)}`).join(" · "),children:"Terblokir"}):null}function hu({priority:e,stage:a}){const n=Ho(e),i=a?pf[a]??"idle":void 0,r=a?hf(a):null;return t.jsx("span",{className:`hn-bl-prio hn-bl-prio-${n.level}`,"data-status":i,title:r?`Prioritas ${n.label} · Status ${r}`:`Prioritas ${n.label}`,children:t.jsxs("span",{className:"hn-sr-only",children:["Prioritas ",n.label,r?`, status ${r}`:""]})})}function kf({source:e}){const a=ai(e);return t.jsxs("span",{className:"hn-bl-source",children:[t.jsx(Re,{name:a.icon,size:12,color:a.color}),a.label]})}function bf({stage:e}){return t.jsx(ht,{status:pf[e]??"idle",size:"sm",variant:"dot",className:"hn-bl-stage-pill",title:mf[e],children:hf(e)})}function CI({stage:e}){var i;const a=uf(e),n=((i=kn[a])==null?void 0:i.label)??e;return t.jsx("div",{role:"progressbar","aria-label":`Status ${n}`,"aria-valuemin":0,"aria-valuemax":kn.length-1,"aria-valuenow":Math.max(a,0),"aria-valuetext":n,className:"hn-bl-stagebar",children:kn.map((r,s)=>{const o=s<a||e==="done",l=s===a&&e!=="done",c=o?"done":l?"active":"todo";return t.jsxs("span",{className:"hn-bl-stage","data-state":c,title:mf[r.key],children:[t.jsx("span",{className:"hn-bl-stage-dot","aria-hidden":"true"}),l&&t.jsx("span",{className:"hn-bl-stage-label",children:r.label})]},r.key)})})}function ep({label:e,value:a}){return t.jsxs("div",{className:"hn-bl-field",children:[t.jsx("div",{className:"hn-eyebrow",children:e}),t.jsx("div",{className:"hn-bl-field-value",children:a||"—"})]})}const PI={qa:"Finding QA — ada yang perlu diperbaiki.",brief:"Feature brief — kebutuhan yang bentuknya sudah jelas.",prd:"PRD — kebutuhan produk yang perlu didefinisikan dulu."},id=(e,a)=>e&&e.target===a?"primary":"secondary",ap=e=>e==="audit";function MI({spec:e,onClose:a,onEditBranch:n,onRevertStage:i,onMarkDone:r,onOpenReview:s,onStart:o,onIntegrate:l,onEditSpec:c,onPromoteToQa:u,onPromoteToBrief:m,onPromoteToPrd:h,onEditDeps:p,onEditAutoMerge:g,onChangeSource:f,onRequestDelete:b,onUndoable:v,projectPolicy:x,allSpecs:y,onAttachmentToast:T,running:S,onOpenRun:E,projectName:w,presenceOn:N}){var dt,qa,Xe;const[R,L]=d.useState([]),[I,B]=d.useState(new Set),[A,M]=d.useState(null),[K,O]=d.useState(""),[J,Z]=d.useState(!1),[H,te]=d.useState(!1),ae=d.useRef(!1),[F,fe]=d.useState(!1),[_e,ee]=d.useState(!1),[X,ce]=d.useState(!1),[se,Ce]=d.useState(!1),[Te,le]=d.useState({}),ya=(e==null?void 0:e.stage)==="brainstorming"&&(e==null?void 0:e.baseSha)==null&&!!c&&e.payload!==void 0,Ze=()=>{if(!e)return;const ge=e.payload||{};le({title:e.title,priority:e.priority,...ge}),Ce(!0)},He=ge=>be=>le(ua=>({...ua,[ge]:be.target.value})),[Ke,ga]=d.useState(null),Ge=e&&ap(e.source)?e.id:null;d.useEffect(()=>{var be;if(ga(null),!Ge)return;let ge=!0;return(be=ne.getEscalation)==null||be.call(ne,Ge).then(ua=>{ge&&ga(ua.escalation)}).catch(()=>{ge&&ga(null)}),()=>{ge=!1}},[Ge]);const ba=()=>{if(!e||!c)return;const ge=e.source==="qa"?{title:Te.title,payload:{severity:Te.severity,steps:Te.steps,expected:Te.expected,actual:Te.actual,env:Te.env,constraints:Te.constraints??""}}:Ti(e.source)==="goal"?{title:Te.title,priority:Te.priority,payload:{goal:Te.goal,done:Te.done??"",constraints:Te.constraints??"",priority:Te.priority}}:{title:Te.title,priority:Te.priority,payload:{context:Te.context,outcome:Te.outcome,constraints:Te.constraints,priority:Te.priority}};c(e,ge),Ce(!1)},Ta=ge=>{if(!e||!c||ge===e.priority)return;const be=e.priority;c(e,{priority:ge}),v==null||v(`Prioritas ${e.id} diubah ke ${Ho(ge).label}`,()=>c(e,{priority:be}))},va=e==null?void 0:e.projectId;d.useEffect(()=>{if(!va){L([]),B(new Set);return}let ge=!0;return ne.listBranches(va).then(be=>{if(ge){const ua=[...new Set([...be.branches,...be.remotes])].sort();L(ua),B(new Set(be.remotes.filter(Da=>!be.branches.includes(Da))))}}).catch(()=>{ge&&(L([]),B(new Set))}),()=>{ge=!1}},[va]),d.useEffect(()=>{K&&O(""),A&&M(null)},[e==null?void 0:e.id,e==null?void 0:e.stage]);async function we(ge){if(!ae.current){ae.current=!0,te(!0);try{return await ge()}finally{ae.current=!1,te(!1)}}}async function Je(){if(!e||!i||!K)return;const ge=await we(()=>i(e,K));ge&&ge.pending?M({target:K,files:ge.wouldDelete}):ge&&O("")}async function U(){if(!e||!i||!A)return;await we(()=>i(e,A.target,!0))&&(M(null),O(""))}function Be(){A||ae.current||(Ce(!1),a())}if(!e)return null;const ue=kn.slice(0,uf(e.stage)),We=((dt=kn.find(ge=>ge.key===e.stage))==null?void 0:dt.label)??e.stage,sa=((qa=kn.find(ge=>ge.key===K))==null?void 0:qa.label)??K,ye=e.source==="qa",la=Ti(e.source),Se=e.payload||{},xe=(y??[]).filter(ge=>ge.projectId===e.projectId&&ge.id!==e.id),aa=tc[la],Ea=ai(e.source);return t.jsxs(da,{open:!0,title:e.title,eyebrow:e.id,icon:Ea.icon,onClose:Be,width:600,children:[t.jsxs("div",{className:"hn-bl-detail",children:[t.jsxs("section",{className:"hn-bl-section","aria-labelledby":"bl-sec-ringkasan",children:[t.jsx("h3",{id:"bl-sec-ringkasan",className:"hn-bl-section-title",children:"Ringkasan"}),t.jsxs("div",{className:"hn-bl-summary-meta",children:[t.jsx(bf,{stage:e.stage}),t.jsxs("span",{className:"hn-bl-prio-text",children:[t.jsx(hu,{priority:e.priority}),Ho(e.priority).label]}),t.jsx(mu,{spec:e}),t.jsx(dl,{names:N})]}),t.jsx(CI,{stage:e.stage}),se?t.jsx(oe,{label:"Judul",children:t.jsx(Oe,{value:Te.title??"",onChange:He("title"),placeholder:"mis. Jadwal invoice berulang",className:"hn-bl-full"})}):t.jsx(ep,{label:"Tujuan",value:e.objective}),t.jsxs("dl",{className:"hn-bl-facts",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Project"}),t.jsx("dd",{children:w??e.projectId})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Penulis"}),t.jsx("dd",{children:e.author||"—"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Dibuat"}),t.jsx("dd",{children:II(e.createdAt)||"—"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Branch asal"}),t.jsx("dd",{children:e.branchFrom||"—"})]})]}),ya&&!se&&t.jsxs("div",{className:"hn-bl-inline-row",children:[t.jsx($e,{size:"sm","aria-label":"Prioritas item ini",value:e.priority,onChange:ge=>Ta(ge.target.value),options:nc}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"pencil",onClick:Ze,children:"Edit"})]}),se?t.jsxs(t.Fragment,{children:[!ye&&t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{value:Te.priority??"sedang",onChange:He("priority"),options:nc,className:"hn-bl-full"})}),aa.map(([ge,be,ua])=>t.jsx(oe,{label:be,children:ge==="severity"?t.jsx($e,{value:Te[ge]??"major",onChange:He(ge),options:df,className:"hn-bl-full"}):t.jsx(Ia,{value:Te[ge]??"",onChange:He(ge),rows:2,placeholder:ua})},ge)),t.jsxs("div",{className:"hn-bl-inline-row hn-bl-end",children:[t.jsx(q,{size:"sm",variant:"secondary",onClick:()=>Ce(!1),children:"Batal"}),t.jsx(q,{size:"sm",variant:"primary",leftIcon:"check",onClick:ba,children:"Simpan"})]})]}):aa.map(([ge,be])=>t.jsx(ep,{label:be,value:Se[ge]??""},ge)),e.manualDone&&t.jsxs("div",{className:"hn-bl-field","data-testid":"manual-done-trail",children:[t.jsx("div",{className:"hn-eyebrow",children:"Ditandai selesai manual"}),t.jsxs("div",{className:"hn-bl-field-value hn-bl-muted",children:[e.manualDone.by," · ",new Date(e.manualDone.at).toLocaleString("id-ID"),e.manualDone.reason?t.jsx("div",{className:"hn-bl-gap-top",children:e.manualDone.reason}):null]})]})]}),t.jsxs("div",{className:"hn-bl-cta",children:[S&&E&&t.jsx(q,{variant:"primary",leftIcon:"terminal",onClick:()=>E(e),children:"Buka sesi"}),!S&&o&&t.jsx(q,{variant:"primary",leftIcon:"play",onClick:()=>o(e),children:"Jalankan"}),e.stage==="done"&&t.jsx("span",{className:"hn-bl-hint",children:"Sesi baru melanjutkan sisa kerja item ini."})]}),t.jsxs("section",{className:"hn-bl-section","aria-labelledby":"bl-sec-review",children:[t.jsx("h3",{id:"bl-sec-review",className:"hn-bl-section-title",children:"Review, dokumen, dan lampiran"}),t.jsxs("div",{className:"hn-bl-inline-row",children:[s&&t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"git-compare",onClick:()=>{s(e),a()},children:"Review perubahan"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"file-text",onClick:()=>ee(!0),children:"Lihat dokumen"})]}),ap(e.source)&&(u||m||h)&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Tindak lanjut"}),Ke&&t.jsxs("div",{className:"hn-bl-hint",children:[Ke.target==="none"?t.jsxs("span",{children:["Audit menilai ",t.jsx("strong",{children:"cukup jawaban"})," — tak perlu perbaikan."]}):t.jsxs("span",{children:[t.jsx(oa,{tone:"brass",size:"sm",children:"direkomendasikan hanoman"})," ",PI[Ke.target]]}),Ke.reason?t.jsx("div",{className:"hn-bl-gap-top",children:Ke.reason}):null]}),t.jsxs("div",{className:"hn-bl-inline-row",children:[u&&t.jsx(q,{size:"sm",variant:id(Ke,"qa"),leftIcon:"bug",onClick:()=>u(e,Ke),children:"Jadikan Finding QA"}),m&&t.jsx(q,{size:"sm",variant:id(Ke,"brief"),leftIcon:"lightbulb",onClick:()=>m(e,Ke),children:"Jadikan Feature brief"}),h&&t.jsx(q,{size:"sm",variant:id(Ke,"prd"),leftIcon:"scroll-text",onClick:()=>h(e,Ke),children:"Jadikan PRD"})]})]}),t.jsx(iT,{specId:e.id,onToast:T??(()=>{})})]}),t.jsxs("details",{className:"hn-bl-advanced","data-testid":"spec-advanced",children:[t.jsx("summary",{children:"Lanjutan"}),t.jsxs("div",{className:"hn-bl-advanced-body",children:[t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Branch worktree"}),t.jsx($e,{size:"sm",value:e.branchFrom??"",disabled:!R.length,onChange:ge=>n&&n(e,ge.target.value||null),options:cb(R,I)})]}),t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Bergantung pada"}),(e.dependsOn??[]).length===0?t.jsx("div",{className:"hn-bl-hint",children:"— berdiri sendiri"}):t.jsx("div",{className:"hn-bl-stack-list",children:(e.dependsOn??[]).map(ge=>{const be=(e.blockedBy??[]).find(ua=>ua.id===ge);return t.jsxs("div",{className:"hn-bl-dep",children:[t.jsx("span",{className:"hn-bl-id",children:ge}),be?t.jsx(oa,{tone:"warn",size:"sm",children:gf(be.reason)}):t.jsx(oa,{tone:"ok",size:"sm",icon:"check",children:"selesai & ter-merge"})]},ge)})}),p&&xe.length>0&&t.jsx("div",{className:"hn-bl-checklist",children:xe.map(ge=>{const be=(e.dependsOn??[]).includes(ge.id);return t.jsx(vs,{"aria-label":`Bergantung pada ${ge.id}`,checked:be,label:`${ge.id} · ${ge.title}`,onChange:()=>p(e,be?(e.dependsOn??[]).filter(ua=>ua!==ge.id):[...e.dependsOn??[],ge.id])},ge.id)})})]}),g&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Auto-merge saat selesai"}),t.jsx($e,{size:"sm","aria-label":"Auto-merge item ini",value:e.autoMerge?e.autoMerge.mode:"inherit",onChange:ge=>{var ua;const be=ge.target.value;if(be==="inherit")return g(e,null);if(be==="off")return g(e,{...ls});g(e,{...e.autoMerge??ls,mode:be,branch:be==="branch"?((ua=e.autoMerge)==null?void 0:ua.branch)??R[0]??null:null})},options:[{value:"inherit",label:`Ikut project (${Ip(Ny(x,null))})`},{value:"off",label:"Tanpa auto-merge untuk item ini"},{value:"default-branch",label:"Auto-merge ke default branch repo"},{value:"branch",label:"Auto-merge ke branch tujuan…"}]}),((Xe=e.autoMerge)==null?void 0:Xe.mode)==="branch"&&t.jsx("div",{className:"hn-bl-gap-top",children:t.jsx($e,{size:"sm","aria-label":"Branch tujuan item ini",value:e.autoMerge.branch??"",onChange:ge=>g(e,{...e.autoMerge,branch:ge.target.value||null}),options:[{value:"",label:"Pilih branch…"},...R.map(ge=>({value:ge,label:ge}))]})})]}),(i||r)&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Ubah status"}),t.jsx("div",{className:"hn-bl-status-now",children:`Status saat ini: ${We}`}),e.stage!=="done"&&r&&t.jsx("div",{className:"hn-bl-gap-bottom",children:t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"circle-check",onClick:()=>Z(!0),children:"Tandai selesai"})}),i?ue.length>0?t.jsxs(t.Fragment,{children:[t.jsx($e,{size:"sm","aria-label":"Kembalikan stage",value:K,onChange:ge=>O(ge.target.value),disabled:H,placeholder:"Pilih status lebih awal…",options:ue.map(ge=>({value:ge.key,label:"← "+ge.label}))}),t.jsx("div",{className:"hn-bl-hint hn-bl-gap-top",children:"Status saat ini dan status berikutnya tidak dapat dipilih. Kemajuan hanya berasal dari fase sesi."}),K&&t.jsxs("div",{className:"hn-bl-callout",children:[t.jsxs("div",{className:"hn-bl-callout-title",children:[We," → ",sa]}),"Fase sesi yang sudah berjalan tidak dibatalkan. Dokumen Spec/Plan di atas target mungkin perlu dihapus setelah konfirmasi; kode dan commit tidak disentuh."]}),t.jsx("div",{className:"hn-bl-gap-top",children:t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"rotate-ccw",disabled:!K,loading:H,onClick:Je,children:"Simpan status"})})]}):t.jsxs("div",{className:"hn-bl-hint",children:[We," adalah status paling awal. Kemajuan hanya berasal dari fase sesi."]}):null]}),e.stage==="done"&&l&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Integrasi"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"git-merge",onClick:()=>fe(!0),children:"Rebase / Merge"})]}),f&&t.jsxs("div",{className:"hn-bl-subsection",children:[t.jsx("div",{className:"hn-eyebrow",children:"Type"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"shuffle",onClick:()=>ce(!0),children:"Ubah type"})]}),(e.sourceHistory??[]).length>0&&t.jsxs("div",{className:"hn-bl-subsection","data-testid":"source-trail",children:[t.jsx("div",{className:"hn-eyebrow",children:"Jejak konversi type"}),t.jsx("div",{className:"hn-bl-stack-list",children:(e.sourceHistory??[]).map((ge,be)=>t.jsxs("div",{className:"hn-bl-trail",children:[t.jsxs("span",{className:"hn-bl-id",children:[ge.from," → ",ge.to]})," · ",new Date(ge.at).toLocaleString("id-ID")," · ",ge.by]},`${ge.at}-${be}`))})]})]})]}),b&&t.jsxs("section",{className:"hn-bl-danger","aria-labelledby":"bl-sec-bahaya",children:[t.jsx("h3",{id:"bl-sec-bahaya",className:"hn-bl-section-title",children:"Zona berbahaya"}),t.jsx("div",{className:"hn-bl-hint",children:"Menghapus item tak bisa dibatalkan. Kode dan commit di repo tidak disentuh."}),t.jsx("div",{className:"hn-bl-gap-top",children:t.jsx(q,{size:"sm",variant:"danger",leftIcon:"trash-2",onClick:()=>b(e),children:"Hapus spec"})})]})]}),A&&t.jsxs(da,{open:!0,title:"Kembalikan status & hapus dokumen fase",icon:"rotate-ccw",eyebrow:e.id+" → "+A.target,onClose:H?void 0:()=>M(null),children:[t.jsxs("div",{className:"hn-bl-confirm-lead",children:[A.files.length," berkas docs akan dihapus dari disk (kode & commit tak disentuh):"]}),t.jsx("ul",{className:"hn-bl-file-list",children:A.files.map(ge=>t.jsx("li",{children:ge},ge))}),t.jsxs("div",{className:"hn-bl-inline-row hn-bl-end",children:[t.jsx(q,{size:"sm",variant:"secondary",disabled:H,onClick:()=>M(null),children:"Batal"}),t.jsx(q,{size:"sm",variant:"danger",leftIcon:"trash-2",loading:H,onClick:U,children:"Hapus & kembalikan"})]})]}),F&&l&&t.jsx(pI,{projectId:e.projectId,ownBranch:`hanoman/${e.id.toLowerCase().replace(/[^a-z0-9_-]/g,"_")}`,eyebrow:e.id,onClose:()=>fe(!1),onIntegrate:(ge,be)=>{fe(!1),l(e,ge,be)}}),J&&r&&t.jsx(cf,{spec:e,onClose:()=>Z(!1),onSubmit:r}),_e&&t.jsx(ou,{specId:e.id,onClose:()=>ee(!1)}),X&&f&&e.payload!==void 0&&t.jsx(AI,{spec:e,onClose:()=>ce(!1),onSubmit:(ge,be,ua)=>Promise.resolve(f(e,ge,be,ua)??null)})]})}function ff({spec:e,onStart:a,onDelete:n,onOpenRun:i,onOpenReview:r,onMarkDone:s,onMarkReviewed:o,running:l}){const[c,u]=d.useState(!1),[m,h]=d.useState(!1),p=e.stage!=="done",g=l?i?{label:"Buka sesi",icon:"terminal",run:()=>i(e)}:null:p?a?{label:EI(e.stage),icon:"play",run:()=>a(e)}:null:r?{label:"Review perubahan",icon:"git-compare",run:()=>r(e)}:null,b=[...!!r&&(g==null?void 0:g.label)!=="Review perubahan"&&r?[{key:"review",label:"Review perubahan",icon:"git-compare",onSelect:()=>r(e)}]:[],{key:"docs",label:"Lihat dokumen",icon:"file-text",onSelect:()=>u(!0)},...!p&&a?[{key:"rerun",label:"Jalankan lagi",icon:"play",onSelect:()=>a(e)}]:[],...p&&s?[{key:"done",label:"Tandai selesai",icon:"circle-check",onSelect:()=>h(!0)}]:[],...!p&&o?[{key:"reviewed",label:e.reviewedAt?"Batalkan tanda ditinjau":"Tandai ditinjau",icon:e.reviewedAt?"rotate-ccw":"circle-check",onSelect:()=>void o(e,!e.reviewedAt)}]:[],...n?[{key:"delete",label:"Hapus spec",icon:"trash-2",tone:"danger",onSelect:()=>n(e)}]:[]];return t.jsxs("div",{className:"hn-bl-actions",children:[g&&t.jsx(q,{size:"sm",variant:g.label==="Review perubahan"?"secondary":"primary",leftIcon:g.icon,onClick:g.run,children:g.label}),t.jsx(rn,{label:`Aksi lain ${e.id}`,items:b}),m&&s&&t.jsx(cf,{spec:e,onClose:()=>h(!1),onSubmit:s}),c&&t.jsx(ou,{specId:e.id,onClose:()=>u(!1)})]})}const II=e=>{const a=e?new Date(e):null;return a&&!Number.isNaN(a.getTime())?a.toLocaleDateString("id-ID",{day:"numeric",month:"short",year:"numeric"}):""};function NI({spec:e,onOpenDetail:a,className:n="hn-bl-title"}){return t.jsx("button",{type:"button",className:n,onClick:()=>a&&a(e),children:e.title})}function RI({spec:e,presenceOn:a,onOpenDetail:n,projectName:i,...r}){return t.jsxs(an,{onClick:n?()=>n(e):void 0,actions:t.jsx(ff,{spec:e,...r}),children:[t.jsx(hu,{priority:e.priority,stage:e.stage}),t.jsxs("span",{className:"hn-bl-row-body",children:[t.jsx("span",{className:"hn-bl-row-title",children:e.title}),t.jsxs("span",{className:"hn-bl-row-meta",children:[t.jsx("span",{className:"hn-bl-id",children:e.id}),i&&t.jsx("span",{className:"hn-bl-proj",title:`Project: ${i}`,children:i}),t.jsx(kf,{source:e.source}),t.jsx(bf,{stage:e.stage}),t.jsx(mu,{spec:e}),t.jsx(dl,{names:a})]})]})]})}const cl="backlog",yf="success",LI=kn[0].key,tp=[{key:cl,label:"Backlog",icon:"inbox"},...kn.slice(0,5).map(e=>({key:e.key,label:e.label})),{key:yf,label:"Success",icon:"check-circle-2"}];function BI(e,a){return e.stage==="done"?yf:!a&&e.stage==="brainstorming"?cl:e.stage}const np=(e,a)=>e===cl&&a===LI;function $I({spec:e,col:a,onOpenDetail:n,presenceOn:i,projectName:r,onDragStart:s,onDragEnd:o,dragging:l,...c}){const u=a===cl;return t.jsxs("div",{draggable:u,className:"hn-bl-card","data-dragging":l||void 0,onDragStart:m=>{m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",e.id),s()},onDragEnd:o,title:u?"Seret ke Brainstorm untuk memulai sesi":"Stage mengikuti fase yang dilaporkan agen — kartu tak bisa dipindah","data-draggable":u||void 0,children:[t.jsxs("div",{className:"hn-bl-card-head",children:[t.jsx(hu,{priority:e.priority,stage:e.stage}),t.jsx("span",{className:"hn-bl-id",children:e.id}),t.jsx(kf,{source:e.source})]}),t.jsx(NI,{spec:e,onOpenDetail:n}),r&&t.jsx("span",{className:"hn-bl-proj",title:`Project: ${r}`,children:r}),(e.blockedBy??[]).length>0||i!=null&&i.length?t.jsxs("div",{className:"hn-bl-card-badges",children:[t.jsx(mu,{spec:e}),t.jsx(dl,{names:i})]}):null,t.jsx("div",{className:"hn-bl-card-foot",children:t.jsx(ff,{spec:e,...c})})]})}function DI({specs:e,activeSpecs:a,presenceBySpec:n,onOpenDetail:i,projectNameOf:r,...s}){const[o,l]=d.useState(null),[c,u]=d.useState(null),m=d.useMemo(()=>{var g;const p=new Map(tp.map(f=>[f.key,[]]));for(const f of e)(g=p.get(BI(f,a==null?void 0:a.has(f.id))))==null||g.push(f);return p},[e,a]),h=p=>{o&&np(o.from,p)&&s.onStart&&s.onStart(o.spec),l(null),u(null)};return t.jsx("div",{"data-testid":"backlog-board",className:"hn-board-local-overflow hn-bl-board",children:tp.map(p=>{const g=m.get(p.key),f=!!o&&np(o.from,p.key),b=f&&c===p.key;return t.jsxs("div",{className:"hn-bl-col","data-active":f||void 0,"data-hot":b||void 0,"data-dimmed":o&&!f||void 0,onDragOver:v=>{f&&(v.preventDefault(),v.dataTransfer.dropEffect="move",u(p.key))},onDragLeave:()=>u(v=>v===p.key?null:v),onDrop:v=>{v.preventDefault(),h(p.key)},children:[t.jsxs("div",{className:"hn-bl-col-head",children:[p.icon&&t.jsx(Re,{name:p.icon,size:13,color:"var(--text-muted)"}),t.jsx("span",{className:"hn-eyebrow",children:p.label}),t.jsx("span",{className:"hn-bl-col-count",children:g.length})]}),t.jsx("div",{className:"hn-bl-col-body",children:g.map(v=>t.jsx($I,{spec:v,col:p.key,onOpenDetail:i,projectName:r==null?void 0:r(v.projectId),presenceOn:n==null?void 0:n.get(v.id),...s,dragging:(o==null?void 0:o.spec.id)===v.id,running:a==null?void 0:a.has(v.id),onDragStart:()=>l({spec:v,from:p.key}),onDragEnd:()=>{l(null),u(null)}},v.id))})]},p.key)})})}const OI=[{value:"list",label:"Daftar",icon:"list"},{value:"board",label:"Papan",icon:"kanban"}];function HI({value:e,onChange:a}){return t.jsx("div",{className:"hn-bl-view-toggle",role:"group","aria-label":"Mode tampilan",children:OI.map(n=>t.jsx("button",{type:"button",className:"hn-bl-view-btn hn-touch-target","aria-pressed":e===n.value,"aria-label":n.label,title:n.label,onClick:()=>a(n.value),children:t.jsx(Re,{name:n.icon,size:15})},n.value))})}const qI=5,UI=new Set;function zI({backlog:e,projects:a,pageSize:n=20,onStart:i,activeSpecs:r,presenceBySpec:s,reviewSpecIds:o=UI,onDelete:l,onOpenRun:c,onOpenReview:u,onNew:m,onEditBranch:h,onRevertStage:p,onMarkDone:g,onMarkReviewed:f,onIntegrate:b,onEditSpec:v,onEditDeps:x,onEditAutoMerge:y,onChangeSource:T,onPromoteToQa:S,onPromoteToBrief:E,onPromoteToPrd:w,projectFilter:N,onProjectFilter:R,dataVersion:L,onToast:I,initialDetailId:B}){var Gt,ln,jt,wn,Kt;const[A,M]=Ba("backlog","tab","all",Dn),[K,O]=d.useState(0),[J,Z]=Ba("backlog","view","list",bi("list","board")),[H,te]=Ba("backlog","stageGroup","all",bi("all","brainstorm","spec","doing","done")),[ae,F]=Ba("backlog","q","",Dn),[fe,_e]=Ba("backlog","prio","all",Dn),[ee,X]=Ba("backlog","worktree","all",bi("all","worktree")),[ce,se]=Ba("backlog","review","all",bi("all","review")),[Ce,Te]=Ba("backlog","dateField","created",bi("created","started")),[le,ya]=Ba("backlog","from","",Dn),[Ze,He]=Ba("backlog","to","",Dn),Ke=N,ga=R,[Ge,ba]=Ba("backlog","detailId",null,Nk);d.useEffect(()=>{B&&ba(B)},[B]);const Ta=d.useCallback(me=>{var ia;return(ia=(a??[]).find(Fa=>Fa.id===me))==null?void 0:ia.name},[a]),va=a||[...new Set(e.map(me=>me.projectId))].map(me=>({id:me,name:me})),[we,Je]=d.useState(()=>e.map(me=>({objective:"",...me}))),[U,Be]=Ba("backlog","page",1,Wc),[ue,We]=d.useState(()=>ae.trim()),[sa,ye]=d.useState(!1),[la,Se]=d.useState(!1),[xe,aa]=d.useState(!1),Ea=d.useRef(!1),[dt,qa]=mk(),Xe=d.useCallback((me,ia)=>{qa(me,"ok",void 0,{action:{label:"Urungkan",onAction:ia}})},[qa]),ge=[A!=="all",Ke!=="all",ae.trim()!=="",H!=="all",fe!=="all",le!=="",Ze!=="",ee!=="all",ce!=="all"].filter(Boolean).length,be=Vc("backlog","scroll",we.length>0);d.useEffect(()=>{const me=setTimeout(()=>We(ae.trim()),250);return()=>clearTimeout(me)},[ae]),Lk(JSON.stringify([A,Ke,H,fe,ue,Ce,le,Ze,ee,ce]),()=>Be(1)),d.useEffect(()=>{var Fa;let me=!0;const ia=(Fa=ne.listSpecs)==null?void 0:Fa.call(ne,{project:Ke==="all"?void 0:Ke,source:A==="all"?void 0:A,q:ue||void 0,priority:fe==="all"?void 0:fe,dateField:le||Ze?Ce:void 0,from:le||void 0,to:Ze||void 0});return Se(!!ia),ia==null||ia.then(Ya=>{me&&(Je(Ya.items),aa(!0),Ea.current=!1,ye(!1),Se(!1))}).catch(()=>{me&&(Ea.current||(Ea.current=!0,I==null||I("Gagal menyegarkan backlog — data di layar mungkin usang","warn")),ye(!0),Se(!1))}),()=>{me=!1}},[A,Ke,fe,ue,Ce,le,Ze,L,K]);const ua=d.useMemo(()=>new Map(e.map(me=>[me.id,me])),[e]),Da=d.useMemo(()=>we.map(me=>Jl(me,ua.get(me.id))),[we,ua]),it=d.useMemo(()=>hI(dI(Da,ee),ce,o),[Da,ee,ce,o]),It=d.useMemo(()=>{const me={};for(const ia of lr)me[ia.key]=it.filter(Fa=>Jh(Fa.stage,ia.key)).length;return me},[it]),pt=d.useMemo(()=>it.filter(me=>Jh(me.stage,H)),[it,H]),_a=xr(pt.length,U,n),Nt=pt.slice((_a.page-1)*n,_a.page*n),[Rt,st]=d.useState(null);d.useEffect(()=>{if(!Ge||!ne.getSpec){st(null);return}let me=!0;return ne.getSpec(Ge).then(ia=>{me&&st(ia)}).catch(ia=>{!me||!(ia instanceof ha)||ia.status!==404||(ba(null),I==null||I(`${Ge} sudah tidak ada`,"warn"))}),()=>{me=!1}},[Ge,L]);const Ua=d.useMemo(()=>{if(!Ge)return null;const me=ua.get(Ge);if((Rt==null?void 0:Rt.id)===Ge)return Jl(Rt,me);const ia=we.find(Fa=>Fa.id===Ge);return ia?Jl(ia,me):me?{objective:"",...me}:null},[Ge,Rt,we,ua]),{confirm:Ja,dialog:Et}=lt(),Tt=l?me=>{var Fa;const ia=((Fa=a.find(Ya=>Ya.id===me.projectId))==null?void 0:Fa.name)??me.projectId;Ja({title:`Hapus ${me.id}?`,message:`"${me.title}" dihapus dari backlog ${ia}.`,impact:["Tindakan ini tidak bisa dibatalkan.","Lampiran item ini ikut dihapus dari disk.","Sesi yang masih berjalan untuk item ini tidak ikut dihentikan.","Item lain yang menunggu item ini tidak lagi bergantung padanya.","Kode dan commit di repo tidak disentuh."],confirmLabel:"Hapus spec",tone:"danger",icon:"trash-2",run:async()=>{await l(me),Ge===me.id&&ba(null)}}).catch(Ya=>I==null?void 0:I(ka(`menghapus ${me.id}`,Ya),"err","x-circle"))}:void 0,Ct=()=>{M("all"),ga("all"),F(""),te("all"),_e("all"),Te("created"),ya(""),He(""),X("all"),se("all"),Be(1)},jn=[...A!=="all"?[{key:"tab",label:`Sumber: ${((Gt=Zh.find(me=>me.value===A))==null?void 0:Gt.label)??A}`,onRemove:()=>M("all")}]:[],...Ke!=="all"?[{key:"proj",label:`Project: ${((ln=va.find(me=>me.id===Ke))==null?void 0:ln.name)??Ke}`,onRemove:()=>ga("all")}]:[],...fe!=="all"?[{key:"prio",label:`Prioritas: ${Ho(fe).label}`,onRemove:()=>_e("all")}]:[],...le||Ze?[{key:"date",label:`Tanggal ${Ce==="created"?"dibuat":"dikerjakan"}: ${le||"…"} – ${Ze||"…"}`,onRemove:()=>{ya(""),He("")}}]:[],...ee!=="all"?[{key:"wt",label:Cd.worktree,onRemove:()=>X("all")}]:[],...ce!=="all"?[{key:"review",label:Pd.review,onRemove:()=>se("all")}]:[]],Pt=t.jsxs(S2,{gap:3,children:[t.jsx(oe,{label:"Sumber",children:t.jsx($e,{size:"sm","aria-label":"Filter sumber",value:A,onChange:me=>M(me.target.value),options:Zh})}),t.jsx(oe,{label:"Project",children:t.jsx($e,{size:"sm","aria-label":"Filter project",value:Ke,onChange:me=>ga(me.target.value),options:[{value:"all",label:"Semua project"}].concat(va.map(me=>({value:me.id,label:me.name})))})}),t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{size:"sm","aria-label":"Filter prioritas",value:fe,onChange:me=>_e(me.target.value),options:TI})}),t.jsx(oe,{label:"Worktree",hint:"Hanya item yang pernah dibuatkan worktree oleh hanoman. Pekerjaan di luar hanoman tidak terhitung.",children:t.jsx($e,{size:"sm","aria-label":"Filter worktree",value:ee,onChange:me=>X(me.target.value),options:oI.map(me=>({value:me.value,label:me.label}))})}),t.jsx(oe,{label:"Tinjauan",hint:"Item yang sesinya menunggu jawabanmu, dan item selesai yang belum kamu tandai sudah ditinjau. Tandai lewat menu item atau di Review perubahan.",children:t.jsx($e,{size:"sm","aria-label":"Filter perlu ditinjau",value:ce,onChange:me=>se(me.target.value),options:cI.map(me=>({value:me.value,label:me.label}))})}),t.jsx(oe,{label:"Tanggal",children:t.jsxs("div",{className:"hn-bl-date-row",children:[t.jsx($e,{size:"sm","aria-label":"Filter tanggal berdasarkan",value:Ce,onChange:me=>Te(me.target.value),options:[{value:"created",label:"Dibuat"},{value:"started",label:"Dikerjakan"}]}),t.jsx(Oe,{size:"sm",type:"date","aria-label":"Tanggal dari",value:le,onChange:me=>ya(me.target.value)}),t.jsx("span",{className:"hn-eyebrow","aria-hidden":"true",children:"→"}),t.jsx(Oe,{size:"sm",type:"date","aria-label":"Tanggal sampai",value:Ze,onChange:me=>He(me.target.value)})]})})]}),xt=!xe&&Da.length===0&&la,za={onStart:i,onDelete:Tt,onOpenRun:c,onOpenReview:u,onMarkDone:g,onMarkReviewed:f},on=me=>ba(me.id),xa=((jt=lr.find(me=>me.key===H))==null?void 0:jt.label)??"";return t.jsxs("div",{className:"hn-bl-screen",children:[t.jsxs("section",{className:"hn-bl-toolbar",role:"region","aria-label":"Kontrol backlog",children:[t.jsx(w2,{label:"Penyaring backlog",search:{value:ae,onChange:F,label:"Cari backlog",placeholder:"mis. invoice atau SPEC-412"},chips:jn,filters:Pt,filtersLabel:"Filter",onReset:ge>0?Ct:void 0,resetLabel:"Reset filter",actions:t.jsxs(t.Fragment,{children:[t.jsx(HI,{value:J,onChange:Z}),t.jsx(xI,{onDone:()=>O(me=>me+1),onToast:I??(()=>{})})]})}),t.jsx(_t,{variant:"pill","aria-label":"Tahap backlog",value:H,onChange:me=>te(me),className:"hn-bl-stage-tabs",tabs:lr.map(me=>({value:me.key,label:me.label,count:It[me.key]}))}),Xh[A]&&t.jsx("p",{className:"hn-bl-hint","data-testid":"backlog-tab-hint",children:Xh[A]}),t.jsxs("div",{className:"hn-bl-status-line",children:[sa&&t.jsx("span",{role:"status",className:"hn-bl-stale",title:"Server tak menjawab saat menyegarkan — angka ini dari muatan terakhir yang berhasil",children:"Data mungkin usang: server tak menjawab saat menyegarkan."}),la&&t.jsx("span",{"data-testid":"backlog-refreshing",className:"hn-bl-muted",children:"Memuat…"})]})]}),xt?t.jsx(bk,{rows:qI,label:"Memuat backlog"}):it.length===0?e.length===0?t.jsx(he,{kind:"empty",illustration:"PST-002",title:"Backlog masih kosong",hint:"Ajukan feature brief atau Finding QA — hanoman menjalankannya dari brainstorm sampai execute.",action:m,actionLabel:"Tambah spec"}):t.jsx(he,{kind:"empty",icon:"filter",title:"Tidak ada spec untuk filter ini",hint:`${e.length} spec ada di backlog, tapi tak ada yang cocok dengan filter aktif.`,action:Ct,actionLabel:"Reset filter",actionIcon:"rotate-ccw"}):pt.length===0?t.jsx(he,{kind:"empty",compact:!0,icon:"filter",title:`Tidak ada spec di tahap ${xa}`,hint:"Tahap lain tetap memuat item yang sama.",action:()=>te("all"),actionLabel:"Tampilkan semua",actionIcon:"x"}):J==="board"?t.jsxs("div",{className:"hn-bl-body",children:[t.jsx("p",{"data-testid":"board-drag-hint",className:"hn-bl-hint",children:"Seret kartu dari kolom Backlog ke Brainstorm untuk memulai sesi. Tombol di kartu melakukan hal yang sama."}),t.jsx(DI,{specs:pt,activeSpecs:r,presenceBySpec:s,projectNameOf:Ta,onOpenDetail:on,...za})]}):t.jsxs("div",{className:"hn-bl-body",children:[t.jsx("div",{ref:be,"data-testid":"backlog-scroll","aria-busy":la||void 0,className:"hn-bl-list-scroll",children:t.jsx(Xt,{label:"Daftar backlog",children:Nt.map(me=>t.jsx(RI,{spec:me,presenceOn:s==null?void 0:s.get(me.id),projectName:Ta(me.projectId),running:r==null?void 0:r.has(me.id),onOpenDetail:on,...za},me.id))})}),t.jsx("div",{className:"hn-bl-pager",children:t.jsx(jr,{page:_a.page,pageCount:_a.pageCount,total:pt.length,from:_a.from,to:_a.to,onPage:Be,unit:"spec"})})]}),t.jsx(MI,{spec:Ua,onClose:()=>ba(null),running:!!Ge&&!!(r!=null&&r.has(Ge)),onOpenRun:c,presenceOn:Ge?s==null?void 0:s.get(Ge):void 0,onEditBranch:h,onRevertStage:p,onMarkDone:g,onOpenReview:u,onStart:i,onIntegrate:b,onEditSpec:v,onPromoteToQa:S,onPromoteToBrief:E,onPromoteToPrd:w,onEditDeps:x,onEditAutoMerge:y,onChangeSource:T,onRequestDelete:Tt,onUndoable:Xe,projectPolicy:(wn=a.find(me=>{var ia;return me.id===((ia=e.find(Fa=>Fa.id===Ge))==null?void 0:ia.projectId)}))==null?void 0:wn.autoMerge,projectName:(Kt=a.find(me=>me.id===(Ua==null?void 0:Ua.projectId)))==null?void 0:Kt.name,allSpecs:e,onAttachmentToast:(me,ia)=>I==null?void 0:I(me,ia??"ok","paperclip")}),t.jsx(Hc,{toast:dt}),Et]})}const ip=20,sp=Rj,sd=e=>e?new Date(e).toLocaleDateString("id-ID",{day:"numeric",month:"short",year:"numeric"}):"—";function FI({projectId:e}){const[a,n]=d.useState(null),[i,r]=d.useState(0),[s,o]=d.useState(null),[l,c]=d.useState(1),[u,m]=d.useState(null),[h,p]=d.useState(""),[g,f]=d.useState(null),b=d.useCallback(()=>{El.listSessions(e,{page:l,limit:ip}).then(T=>{n(T.items),r(T.total),o(T.kuota)}).catch(()=>{n([]),r(0),o(null)})},[e,l]);d.useEffect(()=>{m(null),b()},[b]),d.useEffect(()=>{c(1)},[e]);const v=T=>{f(null),p(""),El.getSession(T).then(m).catch(()=>m(null))},x=async()=>{if(!(!u||!h.trim()))try{const T=await El.materializePrd(u.id,h.trim());f(`PRD tersimpan di ${T.path}. Ia BELUM jadi backlog — eskalasi tetap keputusan Anda.`),b()}catch(T){f(T instanceof Error?T.message:"gagal menulis PRD")}};if(a===null)return t.jsx(he,{kind:"loading",title:"Memuat obrolan…"});const y=xr(i,l,ip);return t.jsxs("div",{className:"hn-pc",children:[s&&t.jsxs("div",{"data-testid":"portal-chat-kuota",className:"hn-pc-kuota",children:["Jatah bulan ini — Brainstorming ",t.jsxs("b",{children:[s.brainstorm.terpakai," / ",s.brainstorm.jatah]})," · ","Bertanya ",t.jsxs("b",{children:[s.tanya.terpakai," / ",s.tanya.jatah]})," · ","reset ",sd(s.resetPada),!s.enabled&&" · obrolan portal sedang MATI di Settings"]}),a.length===0?t.jsx(he,{kind:"empty",icon:"messages-square",title:"Belum ada obrolan",hint:"Begitu klien memulai obrolan di portal, sesinya muncul di sini."}):t.jsxs(t.Fragment,{children:[t.jsx(Sa,{padding:0,children:a.map(T=>t.jsxs("button",{type:"button","data-testid":`portal-chat-row-${T.id}`,onClick:()=>v(T.id),className:"hn-pc-row",children:[t.jsx("span",{className:"hn-pc-type",children:sp[T.type]??T.type}),t.jsx("span",{className:"hn-pc-summary",children:T.summary||"Belum ada ringkasan"}),T.prdSiap&&t.jsx(ht,{status:T.prdDocPath?"ok":"warn",size:"sm",children:T.prdDocPath?"PRD dokumen":"PRD draft"}),t.jsx("span",{className:"hn-pc-meta",children:T.clientEmail}),t.jsx("span",{className:"hn-pc-meta",children:sd(T.createdAt)})]},T.id))}),t.jsx(jr,{page:y.page,pageCount:y.pageCount,total:i,from:y.from,to:y.to,onPage:c,unit:"obrolan"})]}),u&&t.jsxs(Sa,{eyebrow:`${sp[u.type]??u.type} · ${u.clientEmail}`,title:u.summary||"Obrolan",children:[t.jsx("div",{"data-testid":"portal-chat-transkrip",className:"hn-pc-transcript",children:u.messages.map(T=>t.jsxs("div",{className:"hn-pc-msg","data-role":T.role,"data-blocked":T.blocked?"true":"false",children:[t.jsxs("div",{className:"hn-pc-msg-meta",children:[T.role==="klien"?"Klien":"hanoman"," · ",sd(T.createdAt)]}),t.jsx("div",{className:"hn-pc-msg-text",children:T.text}),T.blocked&&t.jsxs("div",{className:"hn-pc-blocked",children:[t.jsx("b",{children:"Diblokir"})," (",(T.blockReasons??[]).join(", "),") — teks asli agen:",t.jsx("div",{className:"hn-pc-raw",children:T.rawText})]})]},T.id))}),u.prdMarkdown&&t.jsxs(t.Fragment,{children:[t.jsx("div",{"data-testid":"portal-chat-prd",className:"hn-pc-prd",children:t.jsx(ws,{text:u.prdMarkdown,name:"prd-draft.md"})}),t.jsxs("div",{className:"hn-pc-prd-actions",children:[t.jsx(Oe,{"data-testid":"portal-chat-slug","aria-label":"Slug dokumen PRD",placeholder:"nama-dokumen",value:h,className:"hn-pc-slug",onChange:T=>p(T.target.value)}),t.jsx(q,{"data-testid":"portal-chat-jadikan-prd",disabled:!h.trim(),onClick:()=>void x(),children:"Jadikan dokumen PRD"}),t.jsxs("span",{className:"hn-pc-meta",children:["Menyimpan ke ",t.jsx("code",{children:"docs/prd/"}),". Tidak membuat backlog."]})]})]}),g&&t.jsx("p",{className:"hn-pc-note",children:g})]})]})}function vf({projects:e,defaultProject:a,onClose:n,onCreate:i,prefill:r,lockProject:s}){var f;const[o,l]=d.useState(a||((f=e[0])==null?void 0:f.id)||""),[c,u]=d.useState({title:(r==null?void 0:r.title)??"",context:(r==null?void 0:r.context)??"",outcome:(r==null?void 0:r.outcome)??"",constraints:(r==null?void 0:r.constraints)??""}),m=b=>v=>u(x=>({...x,[b]:v.target.value})),h=!!c.title.trim()&&!!o,p=()=>{h&&i(o,{title:c.title.trim(),context:c.context,outcome:c.outcome,constraints:c.constraints||void 0})},g=t.jsx("span",{"aria-hidden":"true",className:"hn-prj-required",children:"*"});return t.jsxs(da,{open:!0,onClose:n,icon:"scroll-text",eyebrow:"PM → hanoman",title:"PRD baru",footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:n,children:"Batal"}),t.jsx(q,{size:"sm",leftIcon:"messages-square",onClick:p,disabled:!h,children:"Buat brief → brainstorm PRD"})]}),children:[t.jsxs("p",{className:"hn-prj-note",children:["hanoman membuka sesi brainstorm interaktif di terminal, lalu menulis dokumen PRD ke ",t.jsx("code",{children:"docs/prd/"}),"."]}),t.jsxs("p",{className:"hn-prj-note",children:[t.jsx("span",{"aria-hidden":"true",className:"hn-prj-required",children:"*"})," wajib diisi"]}),t.jsx(oe,{label:t.jsxs(t.Fragment,{children:["Project",g]}),hint:"Tujuan penulisan docs/prd/ — pilih di sini, tak perlu memfilter daftar dulu",children:t.jsx($e,{"aria-label":"Project untuk PRD baru",value:o,disabled:s,onChange:b=>l(b.target.value),className:"hn-prj-full",options:e.map(b=>({value:b.id,label:b.name}))})}),t.jsx(oe,{label:t.jsxs(t.Fragment,{children:["Judul",g]}),hint:c.title.trim()?void 0:"Wajib diisi — tanpa judul, brief tak bisa dibuat.",children:t.jsx(Oe,{value:c.title,onChange:m("title"),placeholder:"mis. Jadwal Invoice Berulang",className:"hn-prj-full"})}),t.jsx(oe,{label:"Konteks",hint:"Latar belakang & alasan fitur ini dibutuhkan",children:t.jsx(Ia,{value:c.context,onChange:m("context"),rows:3,placeholder:"mis. operator harus membuka tiga layar untuk tahu sesi mana yang menunggu"})}),t.jsx(oe,{label:"Hasil yang diharapkan",children:t.jsx(Ia,{value:c.outcome,onChange:m("outcome"),rows:2,placeholder:"mis. satu badge di Overview menunjukkan jumlah sesi yang menunggu"})}),t.jsx(oe,{label:"Batasan",hint:"opsional",children:t.jsx(Oe,{value:c.constraints,onChange:m("constraints"),placeholder:"mis. reuse queue yang ada",className:"hn-prj-full"})})]})}const GI={draft:"neutral",dieskalasi:"info",terwujud:"ok"};function KI({prd:e}){const a=Id[e.status]??e.status;return t.jsx(oa,{tone:GI[e.status],size:"sm",children:e.specCount>0?`${a} ${e.doneCount}/${e.specCount}`:a})}function WI({open:e,onClose:a,prd:n,takeBase:i,items:r,include:s,setInclude:o,busy:l,onTake:c,onStartBreakdown:u,onMaterialize:m,projectId:h}){const p=r.filter((g,f)=>s[f]).length;return t.jsxs(da,{open:e,onClose:a,icon:"list-checks",width:600,eyebrow:"PRD → backlog",title:"Jadikan backlog",footer:t.jsx(q,{variant:"ghost",size:"sm",onClick:a,children:"Batal"}),children:[t.jsxs("p",{className:"hn-prj-note",children:["Pilih bentuk backlog untuk ",t.jsx("b",{children:n.title}),". Manusia yang memutuskan."]}),t.jsxs("div",{className:"hn-prj-sheet-options",children:[t.jsxs("div",{className:"hn-prj-sheet-option",children:[t.jsx(q,{leftIcon:"lightbulb",onClick:()=>{a(),c({...i,kind:"brief",context:`Dari PRD: ${n.path}`,outcome:""})},children:"Sebagai feature brief"}),t.jsx("p",{className:"hn-prj-hint",children:"Sesi menjalankan pipeline penuh: brainstorm → objective → spec → plan → execute."})]}),t.jsxs("div",{className:"hn-prj-sheet-option",children:[t.jsx(q,{leftIcon:"target",variant:"secondary",onClick:()=>{a(),c({...i,kind:"goal",context:"",outcome:"",goal:`Wujudkan PRD ${n.path}`})},children:"Sebagai goal"}),t.jsx("p",{className:"hn-prj-hint",children:"Sesi dua fase (Goal → Verifikasi) yang langsung mengejar goal-nya, tanpa brainstorm, spec, maupun plan. Mode goal selalu aktif."})]}),t.jsx("div",{className:"hn-prj-sheet-option",children:r.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hn-prj-sheet-head",children:[t.jsxs("span",{className:"hn-prj-sheet-title",children:["Breakdown · ",r.length," item"]}),t.jsxs("span",{className:"hn-prj-hint",children:[p,"/",r.length," dipilih"]})]}),t.jsx("ul",{className:"hn-prj-checklist",children:r.map((g,f)=>t.jsx("li",{children:t.jsxs("label",{className:"hn-prj-check",children:[t.jsx("input",{type:"checkbox",checked:s[f]??!1,className:"hn-prj-check-input",onChange:b=>o(v=>v.map((x,y)=>y===f?b.target.checked:x))}),t.jsxs("span",{className:"hn-prj-check-text",children:[t.jsxs("span",{className:"hn-prj-check-title",children:[g.title," ",t.jsx(oa,{tone:"brass",size:"sm",children:g.priority})]}),g.outcome&&t.jsx("span",{className:"hn-prj-hint",children:g.outcome})]})]})},f))}),t.jsx(q,{size:"sm",leftIcon:"plus",disabled:!p||l,onClick:m,children:l?"Membuat…":`Buat ${p} backlog`})]}):t.jsxs(t.Fragment,{children:[t.jsx(q,{leftIcon:"split",variant:"secondary",onClick:()=>{a(),u(h,n.path)},children:"Breakdown ke backlog"}),t.jsx("p",{className:"hn-prj-hint",children:"Mulai sesi breakdown yang menulis usulan backlog paralel dari PRD ini."})]})})]})]})}function VI({prd:e,projectId:a,dataVersion:n,onTake:i,onStartBreakdown:r,onMaterialize:s}){const[o,l]=d.useState(null),[c,u]=d.useState(""),[m,h]=d.useState(0),[p,g]=d.useState([]),[f,b]=d.useState([]),[v,x]=d.useState(""),[y,T]=d.useState(0),[S,E]=d.useState(!1),[w,N]=d.useState(!1);d.useEffect(()=>{let B=!0;return l(null),u(""),ne.getPrd(a,e.path).then(A=>{B&&l(A.content)}).catch(A=>{B&&u(xs(A,"tidak diketahui"))}),()=>{B=!1}},[a,e.path,m]),d.useEffect(()=>{let B=!0;return ne.getBreakdown(a,e.path).then(A=>{B&&(g(A.items),b(A.items.map(()=>!0)),x(""))}).catch(A=>{if(B){if((A==null?void 0:A.status)===404){g([]),b([]),x("");return}x(xs(A,"tidak diketahui"))}}),()=>{B=!1}},[a,e.path,n,y]);const R={project:a,title:e.title,prdPath:e.path,branchFrom:AT(e.path)},L=p.filter((B,A)=>f[A]),I=async()=>{if(L.length){E(!0);try{await s(a,e.path,L),N(!1)}finally{E(!1)}}};return t.jsxs("div",{className:"hn-prd-pane",children:[t.jsxs("div",{className:"hn-prd-actionbar",role:"toolbar","aria-label":"Aksi PRD",children:[t.jsx("span",{className:"hn-prd-actionbar-title",children:e.title}),t.jsx(q,{size:"sm",leftIcon:"list-checks",onClick:()=>N(!0),children:"Jadikan backlog"}),t.jsx(rn,{label:"Aksi lain PRD",icon:"ellipsis",items:[],children:t.jsx(Kk,{href:B=>ne.prdDownloadUrl(a,e.path,B),disabled:o===null})})]}),t.jsxs("div",{className:"hn-prd-read",children:[t.jsxs("header",{className:"hn-prd-head",children:[t.jsx("div",{className:"hn-prj-mono hn-prd-path",children:e.path}),t.jsxs("div",{className:"hn-prd-head-row",children:[t.jsx("h2",{className:"hn-prd-title",children:e.title}),t.jsx(KI,{prd:e})]})]}),v&&t.jsxs("div",{role:"alert",className:"hn-prj-stale",children:[t.jsxs("span",{className:"hn-prj-stale-text",children:["Usulan breakdown gagal dimuat: ",v]}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"rotate-ccw",onClick:()=>T(B=>B+1),children:"Coba lagi"})]}),p.length>0&&t.jsxs("details",{className:"hn-prd-breakdown",children:[t.jsxs("summary",{className:"hn-prd-breakdown-summary",children:["Usulan breakdown · ",p.length," item"]}),t.jsx("ul",{className:"hn-prd-breakdown-list",children:p.map((B,A)=>t.jsxs("li",{children:[t.jsx("span",{className:"hn-prd-breakdown-item",children:B.title}),t.jsx(oa,{tone:"brass",size:"sm",children:B.priority})]},A))}),t.jsx("p",{className:"hn-prj-hint",children:"Pilih item yang dibuat lewat “Jadikan backlog”."})]}),c?t.jsx(he,{kind:"error",title:"Gagal memuat isi PRD",hint:c,action:()=>h(B=>B+1)}):o===null?t.jsx(he,{kind:"loading",title:"Memuat PRD…"}):t.jsx("div",{className:"hn-prd-doc",children:t.jsx(ws,{text:o,name:e.name})})]}),t.jsx(WI,{open:w,onClose:()=>N(!1),prd:e,takeBase:R,items:p,include:f,setInclude:b,busy:S,onTake:i,onStartBreakdown:r,onMaterialize:()=>{I()},projectId:a})]})}function YI(e){const a=[],n=new Map;for(const i of e){let r=n.get(i.projectId);r||(r={projectId:i.projectId,projectName:i.projectName,items:[]},n.set(i.projectId,r),a.push(i.projectId)),r.items.push(i)}return a.map(i=>n.get(i))}function JI({prd:e,active:a,showProject:n,onSelect:i}){return t.jsxs("button",{type:"button",onClick:i,"aria-current":a?"true":void 0,className:`hn-prd-item${a?" is-active":""}`,children:[t.jsxs("span",{className:"hn-prd-item-head",children:[t.jsx(Re,{name:"scroll-text",size:13,color:a?"var(--brass-700)":"var(--brass-500)"}),t.jsx("span",{className:"hn-prd-item-title",children:e.title}),e.live&&t.jsx(oa,{tone:"brass",size:"sm",children:"sesi hidup"})]}),t.jsxs("span",{className:"hn-prd-item-meta",children:[n&&t.jsxs("span",{children:[e.projectName," · "]}),e.specCount>0&&t.jsxs("span",{children:[e.doneCount,"/",e.specCount," item selesai · "]}),t.jsx("span",{className:"hn-prj-mono",children:e.path})]})]})}function QI({projects:e,projectFilter:a,onProjectFilter:n,onNewPrd:i,onTakeToBacklog:r,onStartBreakdown:s,onMaterialize:o,dataVersion:l}){const[c,u]=d.useState([]),[m,h]=d.useState("loading"),[p,g]=d.useState(""),[f,b]=d.useState(0),[v,x]=Ba("prd","sel",null,Nk),[y,T]=d.useState("list"),S=d.useMemo(()=>c.find(H=>H.slug===v)??null,[c,v]),E=d.useCallback(H=>x(H?H.slug:null),[x]),[w,N]=d.useState(!1),R=a==="all",L=R?"":a,I=d.useRef(null);d.useEffect(()=>{I.current!==null&&I.current!==a&&E(null),I.current=a},[a,E]),d.useEffect(()=>{let H=!0;return(R?ne.listAllPrds():L?ne.listPrds(L):Promise.resolve({items:[]})).then(ae=>{H&&(u(ae.items),h("ready"),g(""))}).catch(ae=>{H&&(h("error"),g(xs(ae,"tidak diketahui")))}),()=>{H=!1}},[a,l,f]);const[B,A]=d.useState(!1),M=S?S.projectId||L:"",K=[{value:"all",label:"Semua project"}].concat(e.map(H=>({value:H.id,label:H.name}))),O=[...yd],J=[...yd.map(H=>({status:H,label:Kn(Id,H),items:c.filter(te=>te.status===H)})),...Array.from(new Set(c.map(H=>H.status).filter(H=>!O.includes(H)))).map(H=>({status:H,label:Kn(Id,H),items:c.filter(te=>te.status===H)}))],Z=m==="loading"&&c.length===0?t.jsx(he,{kind:"loading",compact:!0,title:"Memuat daftar PRD…"}):m==="error"&&c.length===0?t.jsx(he,{kind:"error",compact:!0,title:"Gagal memuat daftar PRD",hint:p,action:()=>b(H=>H+1)}):c.length===0?t.jsx(he,{kind:"empty",icon:"scroll-text",title:"Belum ada PRD",hint:"Buat PRD dari brief + brainstorm; hanoman menulisnya ke docs/prd/ lalu bisa di-take jadi backlog.",action:()=>N(!0),actionLabel:"PRD baru"}):t.jsxs(t.Fragment,{children:[m==="error"&&t.jsxs("div",{role:"alert",className:"hn-prj-stale hn-prd-stale",children:[t.jsx("span",{className:"hn-prj-stale-text",children:"Gagal memuat ulang — daftar dari muatan terakhir."}),t.jsx(q,{size:"sm",variant:"secondary",onClick:()=>b(H=>H+1),children:"Coba lagi"})]}),J.filter(H=>H.items.length>0).map(H=>t.jsxs("details",{open:!0,className:"hn-prd-group",children:[t.jsxs("summary",{className:"hn-prd-group-summary",children:[H.label,t.jsx("span",{className:"hn-prj-chip-count",children:H.items.length})]}),YI(H.items).map(te=>t.jsxs("div",{className:"hn-prd-group-body",children:[R&&t.jsx("div",{className:"hn-eyebrow hn-prd-project-label",children:te.projectName}),te.items.map(ae=>t.jsx(JI,{prd:ae,showProject:!1,active:(S==null?void 0:S.path)===ae.path&&(S==null?void 0:S.projectId)===ae.projectId,onSelect:()=>{E(ae),T("detail")}},`${ae.projectId}:${ae.path}`))]},te.projectId))]},H.status))]});return t.jsxs("div",{style:pk,children:[t.jsxs("div",{style:Ao,className:"hn-prd-toolbar",children:[t.jsx($e,{size:"sm",value:a,"aria-label":"Project",onChange:H=>n(H.target.value),options:K}),t.jsx(zE,{screen:"prd",active:R?0:1}),t.jsx("span",{className:"hn-prd-toolbar-spacer"}),!R&&t.jsx(q,{size:"sm",variant:B?"primary":"ghost",leftIcon:"messages-square","aria-expanded":B,onClick:()=>A(H=>!H),children:"Draft dari portal klien"}),t.jsx(q,{size:"sm",leftIcon:"plus",onClick:()=>N(!0),children:"PRD baru"})]}),B&&!R&&t.jsx("div",{style:Ao,className:"hn-prd-portal",children:t.jsx(FI,{projectId:a})}),t.jsx(tl,{ariaLabel:"Panel PRD",active:y,onActiveChange:H=>T(H),masterWidth:288,panels:[{id:"list",label:"Indeks",className:"hn-panel-flex",content:t.jsx("aside",{"aria-label":"Indeks PRD",className:"hn-prd-index",children:Z})},{id:"detail",label:"Isi",className:"hn-panel-flex",content:t.jsx("section",{"aria-label":"Isi PRD",className:"hn-prd-detail",children:S?t.jsx(VI,{prd:S,projectId:M,dataVersion:l,onTake:H=>r(H),onStartBreakdown:s,onMaterialize:o}):t.jsx(he,{kind:"empty",icon:"scroll-text",title:"Pilih PRD",hint:"Klik dokumen di indeks kiri untuk membacanya, lalu jadikan backlog."})})}]}),w&&t.jsx(vf,{projects:e,defaultProject:L,onClose:()=>N(!1),onCreate:(H,te)=>{N(!1),i(H,te)}})]})}const rp=5e3,ZI=12e3,XI=5*6e4,eN=new Set(["shipped","docs-updated","waiting","offline"]),aN={shipped:"selesai","docs-updated":"dokumen terbit",waiting:"butuh jawabanmu"},tN={shipped:"kabar","docs-updated":"dokumen",waiting:"sesi"},xf=(e,a)=>e.kind==="waiting"&&e.since!==null&&a-e.since>=Ud;function nN(e){const a=Math.floor(e/6e4);if(a<1)return`${Math.max(0,Math.floor(e/1e3))} detik`;if(a<60)return`${a} menit`;const n=Math.floor(a/60),i=a%60;return i>0?`${n} jam ${i} menit`:`${n} jam`}function iN(e,a){if(!eN.has(e.kind))return null;if(e.kind==="offline")return{kind:"pose",text:"Aku kehilangan sambungan",ttl:rp};let n=`${e.subject??"Backlog"} ${aN[e.kind]}`;return e.count>1&&(n+=` · ${e.count} ${tN[e.kind]}`),xf(e,a)&&(n+=` — ${nN(a-e.since)}`),{kind:"pose",text:n,ttl:rp}}function jf(e){const a=rl(e.backlog),n={};for(const i of e.sessions){const r=Ar(i,a);r&&(n[i.id]=r)}return{at:e.now,sessions:n,notifiedAt:Xk(e.notifications)}}function sN(e,a){const n=jf(a),i=c=>Object.entries(n.sessions).filter(([u,m])=>m===c&&e.sessions[u]!==c).length,r=a.notifications.filter(c=>Qk.has(c.type)&&c.createdAt>e.notifiedAt).length,s=i("waiting"),o=i("failed"),l=[r>0?`${r} selesai`:"",s>0?`${s} menunggu`:"",o>0?`${o} gagal`:""].filter(Boolean);return l.length>0?{kind:"recap",text:l.join(" · "),ttl:ZI}:null}const rN="PET-001",oN=2,lN={w:192,h:208},dN=8,cN={x:.62,baseline:202},uN={h:168},mN=[{key:"idle",fps:6,loop:!0},{key:"walk-right",fps:10,loop:!0,dir:"right"},{key:"walk-left",fps:10,loop:!0,dir:"left"},{key:"working",fps:8,loop:!0},{key:"waiting",fps:6,loop:!0},{key:"blocked",fps:4,loop:!0},{key:"review",fps:6,loop:!0},{key:"shipped",fps:10,loop:!1,then:"idle"},{key:"docs-updated",fps:6,loop:!0},{key:"wave",fps:10,loop:!1,then:"idle"},{key:"deciding",fps:6,loop:!0},{key:"sleep",fps:4,loop:!0},{key:"thanks",fps:10,loop:!1,then:"idle"},{key:"held",fps:8,loop:!0},{key:"falling",fps:8,loop:!0},{key:"dizzy",fps:8,loop:!1,then:"idle"}],hN={idle:"4a0f06cacdad0fa8e0b0a369628e383fc2cb54cbdd5297285c88d1a33bd686ac","walk-right":"7bdfb2786b2b1c899fb7b170ce2cf5d1e3a922e251cbaca9600c210262629a52","walk-left":"c53c6f7b980d4179b45d55160145df73eb629ccbb809ce2b19946045e388ce60",working:"2ec0d0d4565eced3c55c32603c2b1c6fe9ff93f13f2a1061bc7d2e8d8864aa6f",waiting:"8bb1595bf280040e101949392c1048330c19142d7b5a1d6b74918734f72287e3",blocked:"134f48c60fa6fef038da266be7fb2a69755ecb9123d23dc4e270b14d7d077da6",review:"77c865ff6d49a8bbf3db4e0d7b91ce4663a1e3acef5d072ddd65eac9479b232c",shipped:"d32653efa6a64eb4d00fb63a6e8c0a7dc24de63ecd5a6cfda36f32b584de00b8","docs-updated":"2b3a01ddd640efd6e65d61c6ad4980da3a9fbceff251f1b42ce13389c02bb19c",wave:"4153420063211e6d196219b89c572f43f96ec32f28c63a1159e6d98630e0ed73",deciding:"6309ab706c8430cf97b187f353fd2d447ba729f6e0764efef1b75a3c96168984",sleep:"40f1fd6e27ddddb13a5702c05a03f5e015e44e7e77e96c4e1ed52a5d7741f2ec",thanks:"0f59f2c042b25ff47a7022d4452bf0dc433dcea796d90bf47d95a5c8ca359d8d",held:"8de04ba258b30acb105a27a81ed400b66f3b68953042957a75e63ebe8efe7c89",falling:"8bc3429c44ef4ba257da895080fa6458c3a66e51cebe103e09cd8bac25be5363",dizzy:"3e8c2072e2aa652e204e3c6b041cb6c9487d8dca1649b52f9695600880a94e49"},pN={id:rN,version:oN,cell:lN,columns:dN,anchor:cN,character:uN,rows:mN,sources:hN},gN="/assets/hnm-pet-anoman-atlas-v02-ClJhW17L.webp",ir=["idle","walk-right","walk-left","working","waiting","blocked","review","shipped","docs-updated","wave","deciding","sleep","thanks","held","falling","dizzy"],kN=e=>typeof e=="string"&&ir.includes(e),gi=e=>typeof e=="number"&&Number.isInteger(e)&&e>0,Zi=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function bN(e){const a=h=>{throw new Error(`pet.json tidak sah: ${h}`)};if(!Zi(e))return a("bukan objek");const{id:n,version:i,cell:r,columns:s,anchor:o,character:l,rows:c,sources:u}=e;if(typeof n!="string"||!n)return a("id");if(!gi(i))return a("version");if(!Zi(r)||!gi(r.w)||!gi(r.h))return a("cell");if(!gi(s))return a("columns");if(!Zi(o)||typeof o.x!="number"||!(o.x>0&&o.x<1)||!gi(o.baseline)||o.baseline>r.h)return a("anchor");if(!Zi(l)||!gi(l.h)||l.h>r.h)return a("character");if(!Array.isArray(c)||c.length!==ir.length)return a(`rows: butuh ${ir.length} baris`);const m=c.map((h,p)=>{const g=ir[p];if(!Zi(h)||h.key!==g)return a(`rows[${p}]: harus "${g}"`);if(!gi(h.fps))return a(`rows[${p}].fps`);if(typeof h.loop!="boolean")return a(`rows[${p}].loop`);const f={key:g,fps:h.fps,loop:h.loop};if(h.then!==void 0){if(!kN(h.then)||h.loop)return a(`rows[${p}].then hanya untuk baris loop:false`);f.then=h.then}else if(!h.loop)return a(`rows[${p}] loop:false tanpa then`);if(h.dir!==void 0){if(h.dir!=="right"&&h.dir!=="left")return a(`rows[${p}].dir`);f.dir=h.dir}return f});return!Zi(u)||ir.some(h=>typeof u[h]!="string")?a("sources"):{id:n,version:i,cell:{w:r.w,h:r.h},columns:s,anchor:{x:o.x,baseline:o.baseline},character:{h:l.h},rows:m,sources:u}}const Er=bN(pN),fN=gN,qo={ready:"idle",sleeping:"sleep",offline:"idle",working:"working",deciding:"deciding",waiting:"waiting",blocked:"blocked",review:"review",shipped:"shipped","docs-updated":"docs-updated"};function pu(e,a=Er){const n=a.rows.find(i=>i.key===e);if(!n)throw new Error(`baris ${e} tak ada di manifest`);return n}const yN=(e,a=Er)=>a.rows.findIndex(n=>n.key===e),wf=(e,a=Er)=>Math.round(a.columns/pu(e,a).fps*1e3),vN=(e,a=Er)=>pu(e,a).then??null,op=40,dr=[1200,4500],xN=[5e3,14e3],ic=16,lp=24,jN=240,wN=220,SN=new Set(["waiting","blocked"]),_N=new Set(["offline","sleeping"]),ao=(e,[a,n])=>a+e()*(n-a),rd=e=>e==="right"?"walk-right":"walk-left",gu=(e,a)=>Math.max(ic,e-a-ic),ti=(e,a,n)=>Math.min(Math.max(e,ic),gu(a,n)),Sf=(e,a,n)=>Math.min(Math.max(e,0),Math.max(0,a-n)),dp=e=>e==="held"||e==="falling"||e==="dizzy",AN=e=>!e.roam||e.reduced||e.tier==="mobile";function cp(e,a,n){return{x:gu(e,a),y:0,facing:"right",mode:"stand",until:n+dr[0],parkedX:null}}function EN(e,a){const{now:n,laneWidth:i,petWidth:r,pose:s}=a,o=ti(a.currentX,i,r);return{state:{x:o,y:0,facing:e.facing,mode:"stand",until:n+dr[0],parkedX:e.parkedX===null?null:ti(e.parkedX,i,r)},row:qo[s],move:{x:o,y:0,durationMs:0,ease:"linear"}}}const TN=(e,a,n,i,r)=>({...e,x:ti(e.x,a,i),y:Sf(e.y,n,r)});function CN(e,a,n){const{now:i,laneWidth:r,laneHeight:s,petWidth:o,petHeight:l,pose:c}=a,u=gu(r,o),m=qo[c],h=ti(a.currentX,r,o),p=e.mode==="walk"||e.mode==="home",g=e.mode==="dizzy",f=(E,w,N=e.facing)=>({x:E,y:0,facing:N,mode:"stand",until:w,parkedX:e.parkedX}),b=E=>p||Math.abs(h-E)>.5?{x:E,y:0,durationMs:0,ease:"linear"}:null,v=(E,w)=>{const N=Math.round(Math.abs(E-h)/op*1e3),R=E>=h?"right":"left";return{state:{x:E,y:0,facing:R,mode:w,until:i+N,parkedX:e.parkedX},row:rd(R),move:{x:E,y:0,durationMs:N,ease:"linear"}}},x=E=>{const w={x:E,y:0,durationMs:0,ease:"linear"};return a.reduced?{state:{...f(E,1/0),parkedX:E},row:m,move:w}:{state:{x:E,y:0,facing:e.facing,mode:"dizzy",until:i+wf("dizzy"),parkedX:E},row:"dizzy",move:w}};if(a.dragging){const E=ti(a.pointerX,r,o),w=Sf(a.pointerY,s,l);return{state:{x:E,y:w,facing:e.facing,mode:"held",until:1/0,parkedX:e.parkedX},row:"held",move:{x:E,y:w,durationMs:0,ease:"linear"}}}if(e.mode==="held"){if(a.reduced||e.y===0)return x(e.x);const E=Math.max(wN,Math.round(e.y/jN*1e3));return{state:{x:e.x,y:0,facing:e.facing,mode:"falling",until:i+E,parkedX:e.x},row:"falling",move:{x:e.x,y:0,durationMs:E,ease:"fall"}}}if(e.mode==="falling")return i<e.until?{state:e,row:"falling",move:null}:x(e.x);if(e.mode==="dizzy"&&i<e.until)return{state:e,row:"dizzy",move:null};if(AN(a)){const E=ti(e.parkedX??u,r,o);return{state:f(E,1/0,"right"),row:m,move:b(E)}}if(a.hovered||a.panelOpen||a.documentHidden)return{state:f(h,1/0),row:m,move:b(h)};if(_N.has(c))return{state:f(h,1/0),row:m,move:b(h)};if(SN.has(c))return Math.abs(h-u)>1?e.mode==="home"&&i<e.until?{state:e,row:rd(e.facing),move:null}:v(u,"home"):{state:f(u,1/0,"right"),row:m,move:b(u)};if(c==="shipped")return{state:f(h,1/0),row:m,move:b(h)};if(p)return i<e.until?{state:e,row:rd(e.facing),move:null}:{state:f(e.x,i+ao(n,dr)),row:m,move:null};if(g||e.until===1/0)return{state:f(h,i+ao(n,dr)),row:m,move:null};if(i<e.until)return{state:e,row:m,move:null};const y=ao(n,xN)*op/1e3;let T=n()<.5?-1:1,S=ti(h+T*y,r,o);return Math.abs(S-h)<lp&&(T=-T,S=ti(h+T*y,r,o)),Math.abs(S-h)<lp?{state:f(h,i+ao(n,dr)),row:m,move:null}:v(S,"walk")}const Ln={loading:"Membaca layar sesi…",none:"Pertanyaannya tak terbaca dari sini — buka Terminal untuk menjawabnya.",stale:"Layarnya sudah berubah — pertanyaannya dimuat ulang.",deciding:"hanoman-lead sedang menyusun keputusan untuk sesi ini.",failed:"Jawaban tak terkirim. Buka Terminal untuk menjawabnya.",answering:"hanoman-lead sudah mengirim jawabannya ke pane — terlambat mengambil alih.",taken:"Kamu mengambil alih sesi ini. hanoman-lead berhenti menjawabnya.",preparing:"Kotak jawabnya sedang disiapkan — dialognya belum tergambar di pane."},PN={queued:"hanoman-lead mengantre untuk sesi ini",deciding:"hanoman-lead sedang menyusun keputusan",answered:"hanoman-lead sudah menjawab","taken-over":"Kamu yang menjawab sesi ini",failed:"hanoman-lead tak sanggup menjawab sesi ini"},up=e=>{var a;return e instanceof ha?(a=e.detail)==null?void 0:a.reason:void 0};function mp({sessionId:e,label:a,reduced:n,ask:i}){const[r,s]=d.useState(void 0),[o,l]=d.useState([]),[c,u]=d.useState(""),[m,h]=d.useState(!1),[p,g]=d.useState(!1),[f,b]=d.useState(null),[v,x]=d.useState(0);d.useEffect(()=>{let I=!0;return s(void 0),ne.sessionDialog(e).then(B=>{I&&(s(B),l(B?B.dialog.options.filter(A=>A.checked).map(A=>A.n):[]))}).catch(()=>{I&&s(null)}),()=>{I=!1}},[e,v]);async function y(){if(!m){h(!0),b(null);try{await ne.takeoverSessionDialog(e),b(Ln.taken),x(I=>I+1)}catch(I){b(up(I)==="answering"?Ln.answering:Ln.failed)}finally{h(!1)}}}async function T(I){if(!(!r||m)){h(!0),b(null);try{await ne.answerSessionDialog(e,{screenHash:r.screenHash,...I}),g(!0)}catch(B){const A=up(B);A==="stale"?(b(Ln.stale),x(M=>M+1)):b(A==="deciding"?Ln.deciding:Ln.failed)}finally{h(!1)}}}const S=n?{transition:"none",transform:"none"}:void 0,E=I=>t.jsx("div",{"data-testid":"pet-answer-note",className:"hn-pet-note",children:I});if(p)return t.jsx("div",{className:"hn-pet-box",children:t.jsxs("div",{"data-testid":"pet-answer-sent",className:"hn-pet-sent",children:["Terkirim — menunggu ",a," bergerak"]})});const w=i==null?void 0:i.questions[Math.min(i.at,Math.max(0,i.questions.length-1))],N=i?t.jsxs("div",{className:"hn-pet-head",children:[t.jsx("div",{"data-testid":"pet-answer-lead-state",className:"hn-eyebrow",children:PN[i.state]}),i.total>1&&t.jsxs("div",{className:"hn-eyebrow hn-pet-eyebrow-top",children:["Pertanyaan ",Math.min(i.at+1,i.total)," dari ",i.total]}),i.source==="turn-end"&&t.jsx("div",{"data-testid":"pet-answer-source",className:"hn-eyebrow hn-pet-eyebrow-top",children:"Giliran terakhir sesi"}),((w==null?void 0:w.question)||i.message)&&t.jsx("div",{className:"hn-pet-question",children:(w==null?void 0:w.question)||i.message}),i.state!=="taken-over"&&t.jsx("div",{className:"hn-pet-mt-6",children:t.jsx(q,{"data-testid":"pet-answer-takeover",size:"sm",variant:"ghost",disabled:m,style:S,onClick:()=>{y()},children:"Ambil alih"})})]}):null;if(r===void 0)return t.jsxs("div",{className:"hn-pet-box",children:[N,E(Ln.loading)]});if(r===null)return t.jsxs("div",{className:"hn-pet-box",children:[N,E(f??(i?Ln.preparing:Ln.none))]});const{dialog:R}=r,L=R.tabs.filter(I=>I.answered).length;return t.jsxs("div",{"data-testid":"pet-answer","data-session":e,className:"hn-pet-box",children:[N,!i&&R.tabs.length>1&&t.jsxs("div",{className:"hn-eyebrow hn-pet-eyebrow-bottom",children:["Pertanyaan ",Math.min(L+1,R.tabs.length)," dari ",R.tabs.length]}),!i&&R.title&&t.jsx("div",{className:"hn-pet-title",children:R.title}),R.multi?t.jsx("div",{className:"hn-pet-stack",children:R.options.map(I=>t.jsx(vs,{label:I.label,checked:o.includes(I.n),disabled:m,onChange:B=>l(A=>(B?[...A,I.n]:A.filter(M=>M!==I.n)).sort((M,K)=>M-K))},I.n))}):t.jsx("div",{className:"hn-pet-wrap",children:R.options.map(I=>t.jsx(q,{"data-testid":"pet-answer-option",size:"sm",variant:"ghost",disabled:m,style:S,onClick:()=>{T({choice:I.n})},children:I.label},I.n))}),(R.freeIndex!==null||R.notes)&&t.jsxs("div",{className:"hn-pet-free",children:[t.jsx(Oe,{"data-testid":"pet-answer-text",size:"sm",value:c,disabled:m,placeholder:"Jawab dengan kalimatmu sendiri",className:"hn-grow-min",onChange:I=>u(I.target.value)}),!R.multi&&t.jsx(q,{size:"sm",variant:"ghost",disabled:m||!c.trim(),style:S,onClick:()=>{T({text:c.trim()})},children:"Kirim"})]}),R.multi&&t.jsx("div",{className:"hn-pet-mt-8",children:t.jsx(q,{"data-testid":"pet-answer-submit",size:"sm",variant:"primary",disabled:m,style:S,onClick:()=>{T({choices:o,...c.trim()?{text:c.trim()}:{}})},children:"Submit"})}),f&&t.jsx("div",{className:"hn-pet-mt-6",children:E(f)})]})}const MN={mobile:96,tablet:112,desktop:112},ts=44,_f=22,IN=_f+ts,NN=56,RN=6,od=268,LN=10,to=12,no=200,ld=8,BN=5e3,$N=1.5,DN=2e3,ON=3,HN=6,qN={linear:"linear",fall:"var(--ease-fall)"};function UN(){const e="(prefers-reduced-motion: reduce)",[a,n]=d.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return d.useEffect(()=>{var s;if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=window.matchMedia(e),r=()=>n(i.matches);return(s=i.addEventListener)==null||s.call(i,"change",r),()=>{var o;return(o=i.removeEventListener)==null?void 0:o.call(i,"change",r)}},[]),a}function zN(){const[e,a]=d.useState(()=>typeof document<"u"&&document.hidden);return d.useEffect(()=>{const n=()=>a(document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),e}function FN(e,a,n){const i=d.useCallback(()=>{var o;return Math.round(((o=e.current)==null?void 0:o.getBoundingClientRect().width)??0)},[e]),[r,s]=d.useState(0);return d.useLayoutEffect(()=>{n&&s(i())},[i,a,n]),d.useEffect(()=>{const o=e.current;if(!n||!o)return;if(typeof ResizeObserver<"u"){const u=new ResizeObserver(()=>s(i()));return u.observe(o),()=>u.disconnect()}let l;const c=()=>{clearTimeout(l),l=setTimeout(()=>s(i()),150)};return window.addEventListener("resize",c),()=>{clearTimeout(l),window.removeEventListener("resize",c)}},[i,n,e]),r}const GN="(min-width: 1200px) and (max-height: 760px)";function KN(e){const a=d.useCallback(i=>{var s;if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const r=window.matchMedia(e);return(s=r.addEventListener)==null||s.call(r,"change",i),()=>{var o;return(o=r.removeEventListener)==null?void 0:o.call(r,"change",i)}},[e]),n=d.useCallback(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches,[e]);return d.useSyncExternalStore(a,n,()=>!1)}function WN({sessions:e,backlog:a,asks:n=[],onOpen:i}){const{items:r}=Dc(),[s,o]=d.useState(OE),[l,c]=d.useState(qE),[u,m]=d.useState(!1),[h,p]=d.useState(!1),[g,f]=d.useState(to),[b,v]=d.useState(!1),[x,y]=d.useState(!1),[T,S]=d.useState(0),[E,w]=d.useState(null),N=UN(),[R,L]=d.useState(!1);d.useEffect(()=>{const ie=window;if(ie.requestIdleCallback){const qe=ie.requestIdleCallback(()=>L(!0),{timeout:1500});return()=>{var ra;return(ra=ie.cancelIdleCallback)==null?void 0:ra.call(ie,qe)}}const De=window.setTimeout(()=>L(!0),1);return()=>window.clearTimeout(De)},[]);const I=al(),B=zN(),A=KN(GN)&&I==="desktop",M=I!=="desktop",[K,O]=d.useState(!1),J=d.useRef(null),Z=d.useRef(null),H=d.useRef(null),te=FN(J,I,R),[,ae]=tb(),F=c2(),fe=RE(e,r),[_e,ee]=d.useState(fe),[X,ce]=d.useState(()=>Date.now());_e!==fe&&(ee(fe),ce(Date.now()));const se=d.useMemo(()=>DE({sessions:e,backlog:a,notifications:r,now:Date.now(),connection:F,quietSince:X}),[e,a,r,F,X,T]),Ce=d.useMemo(()=>eb(e,a),[e,a]),Te=d.useMemo(()=>LE(e,a),[e,a]);d.useEffect(()=>{if(se.recheckAt===null)return;const ie=setTimeout(()=>S(De=>De+1),Math.max(0,se.recheckAt-Date.now()));return()=>clearTimeout(ie)},[se.recheckAt]),d.useEffect(()=>{if(!E)return;const ie=setTimeout(()=>w(null),E.ttl);return()=>clearTimeout(ie)},[E]);const le=d.useRef(null),ya=d.useRef(null);d.useEffect(()=>{const ie={sessions:e,backlog:a,notifications:r,now:Date.now()};if(B){le.current||(le.current=jf(ie)),ya.current=null;return}const De=le.current;if(!De)return;if(ya.current===null&&(ya.current=ie.now),ie.now-De.at<XI){le.current=null;return}const qe=sN(De,ie);if(qe){le.current=null,w({...qe,id:ie.now});return}ie.now-ya.current>BN&&(le.current=null)},[B,e,a,r]);const Ze=iN(se,Date.now()),[He,Ke]=d.useState((Ze==null?void 0:Ze.text)??null);((Ze==null?void 0:Ze.text)??null)!==He&&(Ke((Ze==null?void 0:Ze.text)??null),Ze&&w({...Ze,id:Date.now()}));const{cell:ga,columns:Ge,anchor:ba,character:Ta,rows:va}=Er,we=MN[I]/Ta.h,Je=Math.round(ga.w*we),U=Math.round(ga.h*we),Be=d.useRef(cp(te,Je,Date.now())),[ue,We]=d.useState(Be.current),[sa,ye]=d.useState(qo[se.pose]),[la,Se]=d.useState({x:Be.current.x,y:0,durationMs:0,ease:"linear"}),[xe,aa]=d.useState(null),Ea=d.useRef(null),dt=d.useRef(!1),qa=d.useCallback(()=>{var qe,ra;const ie=(qe=Z.current)==null?void 0:qe.getBoundingClientRect(),De=(ra=J.current)==null?void 0:ra.getBoundingClientRect();return ie&&De&&ie.width>0?ie.left-De.left:Be.current.x},[]),Xe=d.useCallback(()=>typeof window<"u"?window.innerHeight:U,[U]),ge=d.useMemo(()=>{const ie=la.x+ba.x*Je-no/2,De=Math.min(Math.max(ie,ld),Math.max(ld,te-no-ld));return Math.round(ba.x*Je-no/2+(De-ie))},[la.x,Je,ba.x,te]);d.useEffect(()=>{if(!E||u)return;const ie=qe=>{J.current&&!J.current.contains(qe.target)&&w(null)},De=qe=>{qe.key==="Escape"&&w(null)};return document.addEventListener("mousedown",ie),document.addEventListener("keydown",De),()=>{document.removeEventListener("mousedown",ie),document.removeEventListener("keydown",De)}},[E,u]);const be=d.useRef(0),ua=d.useCallback(()=>{if(te<=0)return;const ie=Date.now();if(be.current===0){be.current=te;const Ga=cp(te,Je,ie);Be.current=Ga,We(Ga),ye(qo[se.pose]),Se({x:Ga.x,y:0,durationMs:0,ease:"linear"});return}const De=be.current!==te;be.current=te;const qe=qa(),ra=De&&xe===null&&!dp(Be.current.mode)?EN(Be.current,{now:ie,currentX:qe,laneWidth:te,petWidth:Je,pose:se.pose}):CN(Be.current,{now:ie,currentX:qe,laneWidth:te,laneHeight:Xe(),petWidth:Je,petHeight:U,pose:se.pose,hovered:x,panelOpen:u,documentHidden:B,roam:l,reduced:N,tier:I,dragging:xe!==null,pointerX:(xe==null?void 0:xe.x)??0,pointerY:(xe==null?void 0:xe.y)??0},Math.random);Be.current=ra.state,We(ra.state),ye(ra.row),ra.move&&Se(ra.move)},[qa,Xe,te,Je,U,se.pose,x,u,B,l,N,I,xe]);d.useEffect(()=>{ua()},[ua]),d.useEffect(()=>{if(!Number.isFinite(ue.until))return;const ie=setTimeout(ua,Math.max(0,ue.until-Date.now()));return()=>clearTimeout(ie)},[ue.until,ua]);const[Da,it]=d.useState(null),It=d.useRef(0),pt=d.useRef([]),[_a,Nt]=d.useState(0),[Rt,st]=d.useState(!1);d.useEffect(()=>{st(!1)},[se.pose]);const Ua=sa==="shipped"&&Rt?vN("shipped")??"idle":sa,Ja=(Da==null?void 0:Da.row)??Ua,Et=pu(Ja),Tt=d.useCallback(()=>!N&&se.pose!=="offline"&&se.pose!=="sleeping"&&xe===null&&!dp(Be.current.mode),[N,se.pose,xe]),Ct=d.useCallback(()=>{Tt()&&it(ie=>ie??{row:"wave",id:++It.current})},[Tt]),jn=d.useCallback(()=>{N||(it({row:"thanks",id:++It.current}),Nt(ie=>ie+1))},[N]);d.useEffect(()=>{if(!u)return;const ie=qe=>{J.current&&!J.current.contains(qe.target)&&xt()},De=qe=>{qe.key==="Escape"&&xt()};return document.addEventListener("mousedown",ie),document.addEventListener("keydown",De),()=>{document.removeEventListener("mousedown",ie),document.removeEventListener("keydown",De)}},[u,N]),d.useEffect(()=>{N&&(v(!1),it(null),u||p(!1))},[N,u]),d.useEffect(()=>{var ie;(ie=H.current)==null||ie.toggleAttribute("inert",!u)},[u,h]);function Pt(){var dn,Lt;const ie=typeof window<"u"?window.innerWidth:te,De=(dn=Z.current)==null?void 0:dn.getBoundingClientRect(),qe=((Lt=J.current)==null?void 0:Lt.getBoundingClientRect().left)??0,Ga=(De&&De.width>0?De.left:qe+Be.current.x)+ba.x*Je,Sn=Math.min(Math.max(Ga-od/2,to),Math.max(to,ie-od-to));f(Math.round(Sn-qe)),p(!0),m(!0)}function xt(){m(!1),N&&p(!1)}function za(){u?xt():Pt()}function on(){const ie=Date.now(),De=[...pt.current.filter(qe=>ie-qe<DN),ie];if(De.length>=ON){pt.current=[],jn();return}pt.current=De,N||v(!0),Ct(),za()}function xa(ie){var De,qe;(qe=(De=ie.currentTarget).setPointerCapture)==null||qe.call(De,ie.pointerId),Ea.current={id:ie.pointerId,dx:ie.clientX-qa(),dy:ie.clientY+Be.current.y,x0:ie.clientX,y0:ie.clientY,moved:!1}}function Gt(ie){const De=Ea.current;if(!(!De||De.id!==ie.pointerId)){if(!De.moved){if(Math.hypot(ie.clientX-De.x0,ie.clientY-De.y0)<=HN)return;De.moved=!0,u&&xt(),it(null)}aa({x:ie.clientX-De.dx,y:De.dy-ie.clientY})}}function ln(ie){var qe,ra;const De=Ea.current;!De||De.id!==ie.pointerId||(Ea.current=null,(ra=(qe=ie.currentTarget).releasePointerCapture)==null||ra.call(qe,ie.pointerId),De.moved&&(dt.current=!0,aa(null)))}function jt(ie){o(ie),HE(ie),ie&&(m(!1),p(!1))}function wn(){if(I==="desktop"&&A){m(!1),p(!1),O(!1);return}I==="desktop"?jt(!0):(m(!1),p(!1),ae(!1))}function Kt(ie){c(ie),UE(ie)}const me=ue.mode==="held"||ue.mode==="falling",ia=s||(A||M)&&!K,Fa=M?NN:ia?IN:U,Ya=TN(la,te,Xe(),Je,U);d.useEffect(()=>{ia&&u&&(m(!1),p(!1))},[ia,u]),d.useEffect(()=>{if(!M||!K)return;const ie=qe=>{J.current&&!J.current.contains(qe.target)&&O(!1)},De=qe=>{qe.key==="Escape"&&!u&&O(!1)};return document.addEventListener("mousedown",ie),document.addEventListener("keydown",De),()=>{document.removeEventListener("mousedown",ie),document.removeEventListener("keydown",De)}},[M,K,u]);const ri={position:"relative",width:"100%",height:Fa,zIndex:80,pointerEvents:"none"},Vn=R?Fa:0;if(d.useLayoutEffect(()=>{const ie=document.documentElement;return ie.style.setProperty("--pet-h",`${Vn}px`),()=>{ie.style.removeProperty("--pet-h")}},[Vn]),!R)return null;if(ia)return t.jsx("div",{"data-testid":"pet-root",ref:J,style:ri,children:t.jsx("button",{"aria-label":"Tampilkan pet Hanoman",onClick:()=>{s&&jt(!1),O(!0)},style:{pointerEvents:"auto",position:"absolute",width:ts,height:ts,padding:0,right:M?"max(var(--page-gutter-x), var(--safe-right))":"max(22px, var(--safe-right))",bottom:M?RN:_f,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",border:"1px solid var(--text-muted)",borderRadius:"var(--radius-pill)",background:"var(--surface-card)",color:"var(--text-strong)",boxShadow:"var(--shadow-sm)"},children:t.jsx(qc,{id:"buntut",size:15})})});const oi=se.pose==="offline",Ni=`Hanoman ${qm[se.pose]} · ${se.headline}`+(se.count>1?` · ${se.count} ${Il[se.kind]}`:""),_s=Ja==="waiting"&&xf(se,Date.now()),ta=Math.round(wf(Ja)/(_s?$N:1)),Ri=N?"none":`hn-pet-frames ${ta}ms steps(${Ge}, end) ${Et.loop?"infinite":"1 forwards"}`;return t.jsxs("div",{"data-testid":"pet-root",ref:J,style:ri,children:[h&&t.jsxs("div",{ref:H,"data-testid":"pet-panel","aria-hidden":!u||void 0,onAnimationEnd:ie=>{ie.animationName==="hn-pet-panel-out"&&!u&&p(!1)},style:{pointerEvents:u?"auto":"none",position:"absolute",left:g,bottom:U+LN,width:od,maxWidth:"calc(100vw - var(--safe-left) - var(--safe-right) - 24px)",maxHeight:"calc(100dvh - var(--safe-top) - var(--safe-bottom) - 120px)",overflowY:"auto",boxSizing:"border-box",padding:14,background:"var(--surface-card)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-lg)",transformOrigin:"center bottom",animation:N?"none":`${u?"hn-pet-panel-in":"hn-pet-panel-out"} var(--dur-slow) var(--ease-out) both`},children:[t.jsx("div",{className:"hn-eyebrow",style:{marginBottom:8},children:qm[se.pose]}),t.jsx("ul",{"data-testid":"pet-conditions",style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:10},children:se.conditions.map((ie,De)=>t.jsxs("li",{"data-testid":"pet-condition","data-kind":ie.kind,style:De>0?{borderTop:"1px solid var(--border-hair)",paddingTop:10}:void 0,children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[t.jsx("span",{style:De===0?{fontFamily:"var(--font-display)",fontSize:15,fontWeight:600,color:"var(--text-strong)",lineHeight:1.25}:{fontFamily:"var(--font-ui)",fontSize:13,fontWeight:600,color:"var(--text-strong)",lineHeight:1.3},children:ie.headline}),ie.count>1&&t.jsx("span",{"data-testid":"pet-condition-count",title:`${ie.count} ${Il[ie.kind]}`,style:{flex:"0 0 auto",padding:"2px 6px",fontFamily:"var(--font-ui)",fontSize:11,fontWeight:700,lineHeight:1,color:"var(--action-on)",background:"var(--action-bg)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-pill)"},children:ie.count})]}),t.jsx("div",{style:{marginTop:3,fontFamily:"var(--font-ui)",fontSize:12.5,color:"var(--text-muted)",lineHeight:1.45},children:ie.detail}),ie.target&&t.jsx("div",{style:{marginTop:7},children:t.jsx(q,{size:"sm",variant:De===0?"primary":"ghost",leftIcon:ie.target.section==="terminal"?"terminal":"list-checks",style:N?{transition:"none",transform:"none"}:void 0,onClick:()=>{const qe=ie.target;xt(),i(qe)},children:ie.target.section==="terminal"?"Buka Terminal":"Buka Backlog"})}),ie.kind==="waiting"&&u&&Ce.map(qe=>t.jsx(mp,{sessionId:qe.id,label:qe.specId??qe.id,reduced:N,ask:n.find(ra=>ra.sessionId===qe.id)},qe.id)),ie.kind==="deciding"&&u&&Te.map(qe=>{const ra=n.find(Ga=>Ga.sessionId===qe.id);return ra?t.jsx(mp,{sessionId:qe.id,label:qe.specId??qe.id,reduced:N,ask:ra},qe.id):null})]},`${ie.kind}:${De}`))}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:12,borderTop:"1px solid var(--border-hair)",paddingTop:10},children:[I!=="mobile"&&t.jsx(q,{size:"sm",variant:"ghost",style:N?{transition:"none",transform:"none"}:void 0,onClick:()=>Kt(!l),children:l?ue.parkedX===null?"Diam di pojok":"Diam di sini":"Berkeliaran"}),t.jsx(q,{size:"sm",variant:"ghost",style:N?{transition:"none",transform:"none"}:void 0,onClick:wn,children:"Sembunyikan"})]})]}),te>0&&t.jsxs("div",{"data-testid":"pet-actor",ref:Z,"data-facing":ue.facing,"data-mode":ue.mode,onTransitionEnd:ie=>{ie.propertyName==="transform"&&ua()},style:{position:"absolute",left:0,bottom:0,width:Je,height:U,transform:`translate(${Ya.x}px, ${-Ya.y}px)`,transition:N||la.durationMs===0?"none":`transform ${la.durationMs}ms ${qN[la.ease]}`,willChange:!N&&la.durationMs>0?"transform":void 0},children:[E&&!u&&t.jsxs("div",{"data-testid":"pet-bubble","data-kind":E.kind,"aria-hidden":E.kind==="pose"&&se.kind!=="waiting"?"true":void 0,style:{pointerEvents:"none",position:"absolute",left:ge,bottom:U-6,width:"max-content",maxWidth:no,boxSizing:"border-box",padding:"6px 10px",fontFamily:"var(--font-ui)",fontSize:12.5,lineHeight:1.35,color:"var(--text-strong)",background:"var(--surface-card)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-sm)",animation:N?"none":"hn-pet-bubble-in var(--dur-base) var(--ease-out) both"},children:[t.jsx("span",{"data-testid":"pet-bubble-text","aria-hidden":E.kind==="pose"?"true":void 0,children:E.text}),(E.kind==="recap"||se.kind==="waiting")&&t.jsx("div",{style:{marginTop:6,pointerEvents:"auto"},children:t.jsx(q,{size:"sm",variant:"ghost",leftIcon:E.kind==="recap"?"list-checks":"terminal","aria-label":E.kind==="recap"?`${E.text} — buka ringkasan pet`:`${E.text} — jawab di sini`,style:N?{transition:"none",transform:"none"}:void 0,onClick:()=>{w(null),Pt()},children:E.kind==="recap"?"Lihat":"Jawab di sini"})})]}),t.jsxs("div",{"data-testid":"pet-stage",className:"hn-pet-stage","data-reduced-motion":N?"true":void 0,style:{position:"relative",width:Je,height:U,animation:N?"none":"hn-pet-reveal var(--dur-slow) var(--ease-out) both"},children:[t.jsx("span",{className:"hn-sr-only",role:"status","aria-live":"polite","data-testid":"pet-status",children:Ni}),se.count>1&&t.jsx("span",{"data-testid":"pet-badge","aria-hidden":"true",title:`${se.count} ${Il[se.kind]}`,style:{pointerEvents:"none",position:"absolute",top:4,right:8,zIndex:2,minWidth:18,height:18,padding:"0 5px",boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",fontFamily:"var(--font-ui)",fontSize:11,fontWeight:700,lineHeight:1,color:"var(--action-on)",background:"var(--action-bg)",border:"1px solid var(--border-hair)",borderRadius:"var(--radius-pill)",boxShadow:"var(--shadow-sm)"},children:se.count}),_a>0&&!N&&t.jsx("span",{"data-testid":"pet-hearts","aria-hidden":"true",style:{pointerEvents:"none",position:"absolute",zIndex:2,left:Math.round(ba.x*Je),bottom:Math.round(U*.55)},onAnimationEnd:ie=>{ie.target.dataset.last==="1"&&Nt(0)},children:[0,1,2].map(ie=>t.jsx("span",{"data-last":ie===2?"1":void 0,style:{position:"absolute",left:ie*9-9,fontFamily:"var(--font-ui)",fontSize:12,color:"var(--accent)",animation:`hn-pet-heart 900ms var(--ease-out) ${ie*120}ms both`},children:"♥"},ie))},_a),t.jsx("div",{"data-testid":"pet-reactor",className:"hn-pet-reactor",style:{position:"relative",width:"100%",height:"100%",transition:N?"none":"transform var(--dur-base) var(--ease-out)",animation:N||!b?"none":"hn-pet-click var(--dur-slow) var(--ease-out) both"},onAnimationEnd:ie=>{ie.animationName==="hn-pet-click"&&v(!1)},children:t.jsx("div",{"data-testid":"pet-viewport","data-offline":oi?"true":void 0,style:{position:"relative",overflow:"hidden",width:Je,height:U,opacity:oi?.45:1,transition:N?"none":"opacity var(--dur-slow) var(--ease-out)"},children:t.jsx("div",{"data-testid":"pet-rowshift",className:"hn-pet-rowshift","data-row":Ja,style:{width:Je,height:U,"--row":yN(Ja)},children:t.jsx("img",{"data-testid":"pet-atlas",src:fN,alt:"","aria-hidden":"true",draggable:!1,decoding:"async",onAnimationEnd:ie=>{if(ie.animationName==="hn-pet-frames"){if(Da){Da.row==="wave"&&x&&Tt()?it({row:"wave",id:++It.current}):it(null);return}Ja==="shipped"&&st(!0)}},style:{display:"block",width:Je*Ge,height:U*va.length,animation:Ri}},`${Ja}:${(Da==null?void 0:Da.id)??0}`)})})}),t.jsx("button",{"data-testid":"pet-hit",className:"hn-pet-hit","aria-label":"Ringkasan status Hanoman",title:`${se.headline} — ${se.detail}`,onClick:()=>{if(dt.current){dt.current=!1;return}on()},onPointerDown:xa,onPointerMove:Gt,onPointerUp:ln,onPointerCancel:ln,onPointerEnter:()=>{y(!0),Ct()},onPointerLeave:()=>y(!1),onFocus:()=>y(!0),onBlur:()=>y(!1),style:{pointerEvents:"auto",position:"absolute",zIndex:3,left:Math.round(ba.x*Je-ts/2),bottom:0,width:ts,height:ts,padding:0,border:"none",background:"transparent",cursor:me?"grabbing":"grab"}})]})]})]})}const VN=d.lazy(()=>nn(()=>import("./DalangHanomanScreen-wJskhX1_.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.DalangHanomanScreen}))),YN=d.lazy(()=>nn(()=>import("./TeamScreen-CS9osC8I.js"),__vite__mapDeps([5,1,6,2,3,7])).then(e=>({default:e.TeamScreen}))),JN=d.lazy(()=>nn(()=>import("./TriageScreen-Eh8BoPTm.js"),__vite__mapDeps([8,1,6,2,3,9])).then(e=>({default:e.TriageScreen}))),QN=d.lazy(()=>nn(()=>import("./TerminalScreen-C0fHHsUa.js"),__vite__mapDeps([10,1,2,3,11])).then(e=>({default:e.TerminalScreen}))),ZN=d.lazy(()=>nn(()=>import("./IdeScreen-CfX1HEtj.js"),__vite__mapDeps([12,1,13,14,6,2,3,15])).then(e=>({default:e.IdeScreen}))),XN=d.lazy(()=>nn(()=>import("./VpsScreen-CweCi934.js"),__vite__mapDeps([16,1,2,3,17])).then(e=>({default:e.VpsScreen}))),eR=d.lazy(()=>nn(()=>import("./SchedulerScreen-CSaFiXc9.js"),__vite__mapDeps([18,1,6,2,19,20,21,3])).then(e=>({default:e.SchedulerScreen}))),aR=d.lazy(()=>nn(()=>import("./LeadScreen-BIpisTdG.js"),__vite__mapDeps([22,1,6,2,19,20,3,23])).then(e=>({default:e.LeadScreen}))),tR=d.lazy(()=>nn(()=>import("./DocsWorkspace-Db_g219X.js"),__vite__mapDeps([24,1,2,3,25])).then(e=>({default:e.DocsWorkspace}))),nR=d.lazy(()=>nn(()=>import("./ReviewScreen-DMGTLCki.js"),__vite__mapDeps([26,1,14,2,3])).then(e=>({default:e.ReviewScreen}))),iR=d.lazy(()=>nn(()=>import("./SettingsScreen-C4chALvS.js"),__vite__mapDeps([27,1,2,21,20,14,3,28])).then(e=>({default:e.SettingsScreen}))),sR=[{value:"critical",label:"Critical"},{value:"major",label:"Major"},{value:"minor",label:"Minor"}],hp=[{value:"tinggi",label:"Tinggi"},{value:"sedang",label:"Sedang"},{value:"rendah",label:"Rendah"}];function rR(e){switch(e){case"offline":return"offline";case"control-off":return"kendali jarak jauh mati";case"protocol-mismatch":return"versi tak cocok";case"no-spawn":return"tanpa izin mulai sesi";case"capacity-full":return"kapasitas penuh";default:return"tak tersedia"}}function oR({open:e,spec:a,onClose:n,onStarted:i,onError:r}){var Je,U,Be;const[s,o]=d.useState("sonnet"),[l,c]=d.useState("medium"),[u,m]=d.useState("claude"),[h,p]=d.useState({claude:{model:"sonnet",effort:"medium"},codex:{...bd}}),[g,f]=d.useState({}),[b,v]=d.useState(!1),[x,y]=d.useState(""),[T,S]=d.useState("changed"),[E,w]=d.useState(Mu().id),[N,R]=d.useState(!1),[L,I]=d.useState(null);d.useEffect(()=>{I(null)},[e,a==null?void 0:a.id]);const[B,A]=d.useState([{deviceId:mn,name:"hub ini",eligible:!0}]),[M,K]=d.useState(mn),[O,J]=d.useState(null),[Z,H]=d.useState(null),[te,ae]=d.useState(void 0),[F,fe]=d.useState(!1),[_e,ee]=d.useState(!1),[X,ce]=d.useState(!1),[se,Ce]=d.useState(null);d.useEffect(()=>{e&&(fe(!1),ee(!1),ce(!1),f({}),ne.getSettings().then(ue=>{const We={claude:{model:ue.model,effort:ue.effort},codex:{...bd,...ue.codex??{}}},sa=ue.agent==="codex"?"codex":"claude";p(We),m(sa),o(We[sa].model),c(We[sa].effort);const ye=!!a&&Gu(ur(a.source));v(ye||ue.goal.enabled),y(ye?"":ue.goal.condition),S(ue.verifyScope??"changed"),w(Mu(ue.method).id),ae(ue.orchestration),fe(!0)}).catch(()=>{ee(!0),fe(!0)}),ne.getCodexVersion().then(ue=>{H(ue.version),ce(!0)}).catch(()=>{ce(!0)}),ne.getMethodStatus().then(ue=>Ce(ue.methods)).catch(()=>Ce(null)))},[e,a]),d.useEffect(()=>{if(!e||!a)return;let ue=!1;return(async()=>{try{const[We,sa]=await Promise.all([typeof ne.presence=="function"?ne.presence():Promise.resolve({enabled:!1,devices:[],hubVersion:""}),typeof ne.getProject=="function"?ne.getProject(a.projectId).then(Se=>Se.handledBy??[]).catch(()=>[]):Promise.resolve([])]);if(ue)return;const ye=JE(We,sa);A(ye);const la=ye.find(Se=>Se.deviceId!==mn&&Se.eligible);K((la==null?void 0:la.deviceId)??mn)}catch{if(ue)return;A([{deviceId:mn,name:"hub ini",eligible:!0}]),K(mn)}})(),()=>{ue=!0}},[e,a==null?void 0:a.id]);const Te=M!==mn,le=d.useMemo(()=>Te?Nc({base:`/api/devices/${M}/relay`}):ne,[Te,M]),ya=ue=>{m(ue),f({});const We=eT(h,ue);o(We.model),c(We.effort)},Ze=ue=>{o(ue),c(We=>u==="codex"?Jo(ue,We):Vo(ue,We))},He=nb(u,s);if(!a)return null;const Ke=a,ga=ur(Ke.source),Ge=Gu(ga),ba=Ke.blockedBy??[],Ta=ba.length>0,va=(se==null?void 0:se.find(ue=>ue.method===E&&ue.agent===u))??null;async function we(ue=!1,We=!1){R(!0),I(null),J(null);try{const{id:sa,resumed:ye}=await le.startSession({spec:Ke.id,flow:ga,model:s,effort:l,agent:u,...Object.keys(g).length?{phaseOverrides:g}:{},goal:b,goalCondition:b&&x.trim()?x.trim():void 0,verifyScope:T,method:E,...Ta||ue?{force:!0}:{},...We?{confirmRemote:!0}:{}});i(sa,ye),n()}catch(sa){if(sa instanceof ha&&sa.status===409&&sa.detail&&typeof sa.detail=="object"&&(sa.detail.error==="remote-session"||sa.detail.error==="confirm-required")){J(sa.detail);return}const ye=sa instanceof ha&&sa.status===409?vg.safeParse(sa.detail):null;ye!=null&&ye.success?I(ye.data):r==null||r(sa)}finally{R(!1)}}return t.jsxs(da,{open:e,onClose:n,icon:"play",eyebrow:`${Ke.id} · ${ga}`,title:"Mulai sesi",footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",onClick:n,children:"Batal"}),t.jsx(q,{leftIcon:Ta?"lock":"play",variant:Ta?"danger":"primary",disabled:N,onClick:()=>void we(),children:Ta?"Mulai tetap":L?"Coba lagi":"Mulai"}),L&&!Ta&&!Te&&t.jsx(q,{leftIcon:"lock",variant:"danger",disabled:N,onClick:()=>void we(!0),children:"Mulai tetap"})]}),children:[t.jsxs("div",{className:"hn-sheet-lead",children:["Agen, model & effort ",t.jsx("b",{children:"orchestrator"})," sesi ini. Default dari setelan global; ubah bila perlu. Bila orkestrasi flow ini aktif, tiap fase dikerjakan subagent dengan model & effort di bawah (Settings › Orkestrasi). Override di bawah hanya berlaku untuk sesi ini dan tidak mengubah Settings."]}),L&&t.jsxs("div",{role:"alert",className:"hn-sheet-alert",children:[t.jsx("b",{children:L.error}),t.jsxs("div",{children:[L.admission.liveCount," sesi hidup · ",L.admission.liveAgentCount," agen terstruktur · cap ",L.admission.maxConcurrent]}),t.jsxs("div",{children:["Load per core: ",L.admission.loadStatus==="available"&&L.admission.loadPerCore!==null?L.admission.loadPerCore.toFixed(2):"tidak tersedia",L.admission.loadStatus==="unsupported"?" (tidak didukung platform)":""," · ambang ",L.admission.maxLoadPerCore]}),t.jsx("div",{children:"Coba lagi setelah beban turun, atau pilih Mulai tetap untuk melewati cap dan pemeriksaan beban host."})]}),Ta&&t.jsxs("div",{"data-testid":"dep-blocked-note",className:"hn-sheet-alert",children:["Backlog ini menunggu"," ",t.jsx("b",{children:ba.map(ue=>`${ue.id} (${ue.reason==="missing"?"tak ditemukan":ue.reason==="unmerged"?"belum ter-merge":"belum selesai"})`).join(", ")}),". Sesi tetap bisa dimulai, tapi worktree-nya lahir dari basis yang belum memuat pekerjaan itu."," ","Mulai tetap juga melewati cap sesi dan pemeriksaan beban host."]}),t.jsx(oe,{label:"Target",hint:"Mesin yang menjalankan sesi ini. Tak terpilih tetap tampil beserta alasannya.",children:t.jsx($e,{"aria-label":"target",value:M,className:"hn-w-full",options:B.map(ue=>({value:ue.deviceId,label:ue.eligible?ue.name:`${ue.name} — ${rR(ue.reason)}`,disabled:!ue.eligible})),onChange:ue=>{K(ue.target.value),J(null)}})}),(O==null?void 0:O.error)==="remote-session"&&O.remoteSession&&t.jsxs("div",{role:"alert",className:"hn-sheet-notice",children:["Sesi ini sudah berjalan di ",t.jsx("b",{children:O.remoteSession.name}),"."]}),(O==null?void 0:O.error)==="confirm-required"&&t.jsxs("div",{role:"alert",className:"hn-sheet-notice",children:[t.jsx("div",{children:"Device terakhir yang mengerjakan ini sudah offline."}),t.jsx(q,{variant:"danger",disabled:N,onClick:()=>void we(!1,!0),children:"Tetap mulai"})]}),t.jsx(oe,{label:"Agen",hint:"Mesin yang menjalankan sesi ini. Perilaku sesi sama; hanya CLI-nya berbeda.",children:t.jsx($e,{"aria-label":"Agen",value:u,className:"hn-w-full",options:[{value:"claude",label:"Claude Code"},{value:"codex",label:"Codex CLI"}],onChange:ue=>ya(ue.target.value)})}),t.jsx(oe,{label:"Model",children:t.jsx($e,{"aria-label":"Model",value:s,className:"hn-w-full",options:XE(u,s),onChange:ue=>Ze(ue.target.value)})}),t.jsx(oe,{label:"Effort",children:t.jsx($e,{"aria-label":"Effort",value:l,className:"hn-w-full",options:He.map(ue=>({value:ue,label:ue})),onChange:ue=>c(ue.target.value)})}),u==="codex"&&jv(s,Z)&&t.jsxs("div",{"data-testid":"codex-version-note",className:"hn-sheet-note",children:["Codex CLI terpasang ",t.jsx("b",{children:Z}),", sedangkan ",t.jsx("b",{children:s})," butuh ",t.jsx("b",{children:(Je=Yo(s))==null?void 0:Je.minClient}),". Sesi tetap boleh dijalankan, tapi modelnya belum tentu dikenali CLI ini."]}),t.jsx(oT,{flow:ga,agent:u,model:s,effort:l,orchestration:te,codexVersion:Z,phaseOverrides:g,onPhaseOverridesChange:f,loadError:_e,remoteTarget:Te?((U=B.find(ue=>ue.deviceId===M))==null?void 0:U.name)??M:null,loading:!F||u==="codex"&&!X}),t.jsxs(oe,{label:"Mode goal",hint:Ge?"Backlog goal selalu berjalan dalam mode goal — sesi menolak berhenti sampai goal item ini terbukti tercapai. Kosongkan kondisi untuk memakai goal item apa adanya.":"Sesi menolak berhenti sampai kondisinya terbukti. Kosongkan kondisi untuk memakai bawaan hanoman: semua fase tercatat, plan tak menyisakan task, push sukses.",children:[t.jsxs("div",{className:b?"hn-goal-row hn-goal-row--on":"hn-goal-row",children:[t.jsx(el,{"aria-label":"Mode goal",checked:b,disabled:Ge,onChange:ue=>{Ge||v(ue)}}),t.jsx("span",{className:"hn-sheet-meta",children:Ge?"aktif · terkunci":b?"aktif":"nonaktif"})]}),b&&t.jsx(Ia,{value:x,rows:4,mono:!0,placeholder:Ge?"Kosong = goal backlog item ini · mis. semua fase tercatat & plan tanpa - [ ]":"Kosong = kondisi bawaan hanoman · mis. semua fase tercatat & plan tanpa - [ ]",onChange:ue=>y(ue.target.value)})]}),t.jsx(oe,{label:"Scope verifikasi",hint:"Hanya yang berubah = test/typecheck/lint hanya menyentuh berkas yang disentuh sesi ini. Suite penuh tetap dijalankan manusia sebelum merge.",children:t.jsx($e,{"aria-label":"Scope verifikasi",value:T,className:"hn-w-full",options:[{value:"changed",label:"Hanya yang berubah — hemat RAM & CPU"},{value:"full",label:"Seluruh project"}],onChange:ue=>S(ue.target.value)})}),t.jsxs(oe,{label:"Metode",hint:"Metodologi kerja sesi ini: skill per fase + direktori plan/spec. Fase-fasenya sendiri tak berubah. Item yang sudah pernah dijalankan memakai metode tercatatnya saat dilanjutkan.",children:[t.jsx($e,{"aria-label":"Metode",value:E,className:"hn-w-full",options:cc.map(ue=>({value:ue,label:Ci[ue].label})),onChange:ue=>w(ue.target.value)}),t.jsxs("div",{"data-testid":"method-requires",className:"hn-sheet-foot",children:["Butuh terpasang: ",((Be=Ci[E])==null?void 0:Be.requires.join(" · "))??"—"]}),va&&!va.ready&&t.jsxs("div",{"data-testid":"method-status-note",className:"hn-sheet-status",children:[t.jsx("b",{children:va.label})," belum siap untuk ",t.jsx("b",{children:u==="codex"?"Codex CLI":"Claude Code"})," di mesin ini",va.missingPackages.length>0&&t.jsxs(t.Fragment,{children:[" · paket kurang: ",t.jsx("code",{children:va.missingPackages.join(" · ")})]}),va.missingSkills.length>0&&t.jsxs(t.Fragment,{children:[" · skill kurang: ",t.jsx("code",{children:va.missingSkills.join(" · ")})]}),"."," ","Sesi tetap boleh dijalankan, tapi gerbang yang disebut prompt tak akan ada. Pasang dari Settings → Sesi."]})]})]})}function lR({open:e,onClose:a,projects:n,defaultProject:i,onCreate:r,prefill:s,specs:o}){const l={kind:(s==null?void 0:s.kind)??"brief",project:(s==null?void 0:s.project)||i,title:(s==null?void 0:s.title)??"",context:(s==null?void 0:s.context)??"",outcome:(s==null?void 0:s.outcome)??"",constraints:(s==null?void 0:s.constraints)??"",priority:"sedang",severity:(s==null?void 0:s.severity)??"major",steps:(s==null?void 0:s.steps)??"",expected:"",actual:(s==null?void 0:s.actual)??"",env:"",branchFrom:(s==null?void 0:s.branchFrom)??"",fromAudit:(s==null?void 0:s.fromAudit)??"",goal:(s==null?void 0:s.goal)??"",done:(s==null?void 0:s.done)??"",dependsOn:[],attachments:[]},[c,u]=d.useState(l);d.useEffect(()=>{e&&u({...l,project:(s==null?void 0:s.project)||i})},[e,i,s]);const[m,h]=d.useState([]),[p,g]=d.useState(new Set);d.useEffect(()=>{if(!e||!c.project){h([]),g(new Set);return}let N=!0;return ne.listBranches(c.project).then(R=>{if(!N)return;const L=[...new Set([...R.branches,...R.remotes])].sort();h(L),g(new Set(R.remotes.filter(I=>!R.branches.includes(I)))),u(I=>I.branchFrom&&!L.includes(I.branchFrom)?{...I,branchFrom:""}:I)}).catch(()=>{N&&(h([]),g(new Set))}),()=>{N=!1}},[e,c.project]);const f=N=>R=>u(L=>({...L,[N]:R.target.value})),b=c.kind==="qa",v=c.kind==="audit",x=c.kind==="goal",y=c.kind==="no_effort",T=Ti(c.kind)==="goal",S=(o??[]).filter(N=>N.projectId===c.project),E=N=>u(R=>({...R,dependsOn:R.dependsOn.includes(N)?R.dependsOn.filter(L=>L!==N):[...R.dependsOn,N]})),w=()=>{!c.title.trim()||T&&!c.goal.trim()||r(c)};return t.jsxs(da,{open:e,onClose:a,icon:b?"bug":v?"search":y?"zap":x?"target":"lightbulb",eyebrow:"human → hanoman",title:b?"QA finding baru":v?"Audit baru":y?"Task remeh baru":x?"Goal baru":"Feature brief baru",footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:a,children:"Batal"}),t.jsx(q,{size:"sm",leftIcon:b?"radar":v?"search":y?"zap":x?"target":"messages-square",onClick:w,children:b?"Filekan finding → audit":v?"Buat audit → investigasi":y?"Buat task → sesi satu fase":x?"Buat goal → sesi goal":"Buat brief → brainstorm"})]}),children:[t.jsxs("div",{className:"hn-sheet-block",children:[t.jsx(_t,{variant:"pill",className:"hn-sheet-kinds",value:c.kind,onChange:N=>u(R=>({...R,kind:N})),tabs:[{value:"brief",label:"Feature brief",icon:"lightbulb"},{value:"qa",label:"QA finding",icon:"bug"},{value:"audit",label:"Audit",icon:"search"},{value:"goal",label:"Goal",icon:"target"},{value:"no_effort",label:"Tanpa effort",icon:"zap"}]}),t.jsx("div",{className:"hn-sheet-hint",children:y?"Sesi satu fase (Kerjakan): langsung mengerjakan lalu berhenti — tanpa brainstorm, spec, plan, maupun fase pembuktian terpisah. Untuk ganti copy, bump konstanta, perbaiki typo docs, tambah satu baris allowlist.":x?"Sesi goal langsung mengejar goal-nya — tanpa brainstorm, spec, atau plan (fase: Goal → Verifikasi). Sesi lahir dengan mode goal aktif dan menolak berhenti sampai buktinya ada di transkrip.":b?"Finding masuk lewat alur audit → spec → plan → execute. hanoman menelusuri akar masalah dulu.":v?"Audit HANYA menghasilkan dokumen (audit → laporan) — tanpa perbaikan kode. Bisa dinaikkan jadi Finding QA bila perlu diperbaiki.":"Brief masuk lewat alur brainstorm → objective → spec → plan → execute."})]}),t.jsx(oe,{label:"Project",children:t.jsx($e,{value:c.project,onChange:f("project"),className:"hn-w-full",options:n.map(N=>({value:N.id,label:N.name}))})}),t.jsx(oe,{label:"Branch",hint:"branch yang disalin ke worktree (salinan kerja terpisah untuk sesi ini) saat sesi dimulai",children:t.jsx($e,{value:c.branchFrom,onChange:f("branchFrom"),disabled:!m.length,className:"hn-w-full",options:cb(m,p)})}),t.jsx(oe,{label:"Bergantung pada",hint:"Backlog yang harus selesai & ter-merge lebih dulu. Kosongkan bila item ini berdiri sendiri.",children:S.length===0?t.jsx("div",{className:"hn-sheet-empty",children:"Belum ada backlog lain di project ini."}):t.jsx("div",{className:"hn-dep-list",children:S.map(N=>t.jsx(vs,{"aria-label":`Bergantung pada ${N.id}`,checked:c.dependsOn.includes(N.id),onChange:()=>E(N.id),label:`${N.id} · ${N.title}`},N.id))})}),t.jsx(oe,{label:"Judul",children:t.jsx(Oe,{"aria-label":"Judul",value:c.title,onChange:f("title"),placeholder:b?"mis. Funnel double-count sesi lintas tengah malam":y?"mis. Label tombol Simpan di form backlog":x?"mis. Latensi daftar backlog":"mis. Jadwal invoice berulang",className:"hn-w-full"})}),T?t.jsxs(t.Fragment,{children:[t.jsx(oe,{label:"Goal",hint:"Keadaan yang harus tercapai — inilah yang dikejar sesi sampai terbukti",children:t.jsx(Ia,{"aria-label":"Goal",value:c.goal,onChange:f("goal"),rows:3,placeholder:"mis. p95 GET /api/specs di bawah 200 ms"})}),t.jsx(oe,{label:"Selesai bila",hint:"Bukti yang harus muncul di transkrip; kosongkan bila goal-nya sudah jadi buktinya sendiri",children:t.jsx(Ia,{"aria-label":"Selesai bila",value:c.done,onChange:f("done"),rows:2,placeholder:"mis. output benchmark menunjukkan < 200 ms"})}),t.jsxs("div",{className:"hn-grid-mobile hn-grid-split",children:[t.jsx(oe,{label:"Batasan",hint:"opsional",children:t.jsx(Oe,{"aria-label":"Batasan",value:c.constraints,onChange:f("constraints"),placeholder:"mis. tanpa cache eksternal",className:"hn-w-full"})}),t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{"aria-label":"Prioritas",value:c.priority,onChange:f("priority"),className:"hn-w-full",options:hp})})]})]}):b?t.jsxs(t.Fragment,{children:[t.jsx(oe,{label:"Severity",children:t.jsx($e,{value:c.severity,onChange:f("severity"),className:"hn-w-full",options:sR})}),t.jsx(oe,{label:"Langkah reproduksi",children:t.jsx(Ia,{value:c.steps,onChange:f("steps"),rows:3,mono:!0,placeholder:`1. Buka …
|
|
1011
1011
|
2. Lakukan …
|
|
1012
1012
|
3. Amati …`})}),t.jsxs("div",{className:"hn-grid-mobile hn-grid-even",children:[t.jsx(oe,{label:"Diharapkan",children:t.jsx(Ia,{value:c.expected,onChange:f("expected"),rows:2,placeholder:"mis. total funnel sama dengan jumlah baris laporan harian"})}),t.jsx(oe,{label:"Aktual",children:t.jsx(Ia,{value:c.actual,onChange:f("actual"),rows:2,placeholder:"mis. total funnel dua kali lipat untuk sesi yang melewati tengah malam"})})]}),t.jsx(oe,{label:"Environment",hint:"build / kanal tempat finding muncul",children:t.jsx(Oe,{value:c.env,onChange:f("env"),placeholder:"prod · web · v0.9.2",className:"hn-w-full"})}),t.jsx(oe,{label:"Batasan",hint:"opsional — batasan pengerjaan yang sudah kamu ketahui",children:t.jsx(Oe,{"aria-label":"Batasan",value:c.constraints,onChange:f("constraints"),placeholder:"mis. jangan ubah kontrak API",className:"hn-w-full"})})]}):t.jsxs(t.Fragment,{children:[t.jsx(oe,{label:v?"Apa yang diaudit / pertanyaan":"Konteks",hint:v?"Isu atau pertanyaan yang mau ditelusuri":"Latar belakang & alasan fitur ini dibutuhkan",children:t.jsx(Ia,{value:c.context,onChange:f("context"),rows:3,placeholder:v?"mis. apakah funnel double-count? cek log sesi lintas tengah malam…":"mis. operator harus membuka tiga layar untuk tahu sesi mana yang menunggu"})}),t.jsx(oe,{label:v?"Temuan/jawaban yang diharapkan":"Hasil yang diharapkan",children:t.jsx(Ia,{value:c.outcome,onChange:f("outcome"),rows:2,placeholder:v?"Jawaban/kepastian yang dicari…":"mis. satu badge di Overview menunjukkan jumlah sesi yang menunggu"})}),t.jsxs("div",{className:"hn-grid-mobile hn-grid-split",children:[t.jsx(oe,{label:"Batasan",hint:"opsional",children:t.jsx(Oe,{value:c.constraints,onChange:f("constraints"),placeholder:"mis. reuse queue yang ada",className:"hn-w-full"})}),t.jsx(oe,{label:"Prioritas",children:t.jsx($e,{value:c.priority,onChange:f("priority"),className:"hn-w-full",options:hp})})]})]}),t.jsx(oe,{label:"Lampiran",hint:"Gambar, log, CSV, JSON, atau PDF — sesi agen membacanya sebagai konteks",children:t.jsx(nT,{files:c.attachments,onChange:N=>u(R=>({...R,attachments:N}))})})]})}function dR({open:e,onClose:a,onCreate:n}){const i={kind:"from-scratch",mode:"local",name:"",desc:"",dir:"",gitRemote:"",objective:""},[r,s]=d.useState(i),[o,l]=d.useState(!1);d.useEffect(()=>{e&&(s(i),l(!1))},[e]);const c=v=>x=>s(y=>({...y,[v]:x.target.value})),u=r.kind==="from-scratch",m=!u&&r.mode==="clone",h=u?!!r.name.trim()&&!!r.dir.trim():m?!!r.gitRemote.trim()&&!!r.dir.trim():!!r.name.trim()||!!r.dir.trim(),p=async()=>{if(!(!h||o)){l(!0);try{await n(r)}finally{l(!1)}}},[g,f]=d.useState(!1),b=u?"Buat dan susun tujuan":m?o?"Menyalin repo…":"Salin repo dan susun dokumen":"Tambah dan susun dokumen";return t.jsxs(da,{open:e,onClose:a,icon:"box",eyebrow:"workspace",title:"Project baru",footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:a,disabled:o,children:"Batal"}),t.jsx(q,{size:"sm",leftIcon:u?"messages-square":m?"git-branch":"radar",onClick:p,disabled:!h||o,children:b})]}),children:[t.jsxs("div",{className:"hn-sheet-block",children:[t.jsx(_t,{variant:"pill",value:r.kind,onChange:v=>s(x=>({...x,kind:v})),tabs:[{value:"from-scratch",label:"Dari nol",icon:"sparkles"},{value:"existing",label:"Kode yang sudah ada",icon:"folder-git-2"}]}),t.jsx("div",{className:"hn-sheet-hint",children:u?"hanoman menggali ide sampai tujuan MVP disepakati (brainstorm), lalu membuat kerangka dokumen acuan (Source of Truth).":"hanoman membaca kode yang sudah ada, lalu menyusun dokumen acuan (Source of Truth) dari kode itu."})]}),u?t.jsxs(t.Fragment,{children:[t.jsx(oe,{label:"Nama project",hint:"lowercase, tanpa spasi",children:t.jsx(Oe,{value:r.name,onChange:c("name"),placeholder:"mis. kirana",className:"hn-w-full"})}),t.jsx(oe,{label:"Direktori",hint:"folder tempat repo baru dibuat (mesin ini)",children:t.jsxs("div",{className:"hn-row-8",children:[t.jsx(Oe,{value:r.dir,onChange:c("dir"),leftIcon:"folder",mono:!0,placeholder:"/path/ke/project-baru",className:"hn-grow"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"folder-open",onClick:()=>f(!0),children:"Pilih folder"})]})}),t.jsx(hr,{open:g,onClose:()=>f(!1),start:r.dir,onPick:v=>s(x=>({...x,dir:v}))}),t.jsx(oe,{label:"Ide awal",hint:"bahan awal brainstorm tujuan; menjadi deskripsi dan kerangka dokumen",children:t.jsx(Ia,{value:r.objective,onChange:c("objective"),rows:2,placeholder:"mis. POS ritel dengan stok multi-gudang dan laporan harian"})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"hn-mb-12",children:t.jsx(_t,{variant:"pill",value:r.mode,onChange:v=>s(x=>({...x,mode:v})),tabs:[{value:"local",label:"Dari folder lokal",icon:"folder"},{value:"clone",label:"Salin dari URL git",icon:"git-branch"}]})}),m?t.jsx(oe,{label:"URL repository",hint:"GitHub/GitLab · https atau ssh",children:t.jsx(Oe,{value:r.gitRemote,onChange:c("gitRemote"),leftIcon:"git-branch",mono:!0,placeholder:"https://github.com/org/repo.git",className:"hn-w-full"})}):null,t.jsx(oe,{label:m?"Folder tujuan salinan":"Direktori",hint:m?"folder lokal tempat repo disalin (git clone) di mesin ini":"opsional · folder checkout lokal (bisa diedit belakangan per-mesin)",children:t.jsxs("div",{className:"hn-row-8",children:[t.jsx(Oe,{value:r.dir,onChange:c("dir"),leftIcon:"folder",mono:!0,placeholder:"/path/ke/repo",className:"hn-grow"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"folder-open",onClick:()=>f(!0),children:"Pilih folder"})]})}),t.jsx(hr,{open:g,onClose:()=>f(!1),start:r.dir,onPick:v=>s(x=>({...x,dir:v}))}),t.jsx(oe,{label:"Deskripsi",hint:"opsional",children:t.jsx(Oe,{value:r.desc,onChange:c("desc"),placeholder:"mis. POS ritel + inventori",className:"hn-w-full"})})]})]})}function cR({open:e,project:a,onClose:n,onSave:i}){const[r,s]=d.useState({id:"",name:"",desc:"",dir:"",gitRemote:""}),[o,l]=d.useState(!1),[c,u]=d.useState(null),[m,h]=d.useState([]),p=!!(c!=null&&c.length);d.useEffect(()=>{e&&a&&(s({id:a.id,name:a.name,desc:a.desc,dir:a.binding??"",gitRemote:a.gitRemote??""}),h((a.handledBy??[]).map(b=>({deviceId:b.deviceId,name:b.name}))))},[e,a]),d.useEffect(()=>{var v;if(!e)return;let b=!0;return(v=ne.listDeviceTokens)==null||v.call(ne).then(x=>{b&&u(x)}).catch(()=>{b&&u([])}),()=>{b=!1}},[e]);const g=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(r.id.trim()),f=!!r.name.trim()&&g;return t.jsxs(da,{open:e,onClose:n,icon:"pencil",eyebrow:a?a.id:"project",title:"Edit project",footer:t.jsxs(t.Fragment,{children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:n,children:"Batal"}),t.jsx(q,{size:"sm",leftIcon:"check",onClick:()=>f&&i({...r,handledBy:p?m:void 0}),children:"Simpan"})]}),children:[t.jsx(oe,{label:"ID project",hint:"slug unik · huruf-kecil/angka/hubung · ganti = pengaruh Help Center & sync ke server",children:t.jsx(Oe,{value:r.id,onChange:b=>s(v=>({...v,id:b.target.value})),leftIcon:"hash",mono:!0,placeholder:"mis. erp-tumbuh-ai",className:"hn-w-full"})}),t.jsx(oe,{label:"Nama project",hint:"label tampilan — boleh berbeda dari id",children:t.jsx(Oe,{value:r.name,onChange:b=>s(v=>({...v,name:b.target.value})),placeholder:"mis. ERP Tumbuh AI",className:"hn-w-full"})}),t.jsx(oe,{label:"Deskripsi",children:t.jsx(Oe,{value:r.desc,onChange:b=>s(v=>({...v,desc:b.target.value})),placeholder:"mis. ERP manufaktur + inventori",className:"hn-w-full"})}),t.jsx(oe,{label:"Path (mesin ini)",hint:"opsional · disimpan lokal, tak disync · kosongkan = pakai default",children:t.jsxs("div",{className:"hn-row-8",children:[t.jsx(Oe,{value:r.dir,onChange:b=>s(v=>({...v,dir:b.target.value})),leftIcon:"folder",mono:!0,placeholder:"/path/ke/repo (mesin ini)",className:"hn-grow-min"}),t.jsx(q,{size:"sm",variant:"secondary",leftIcon:"folder-open",onClick:()=>l(!0),children:"Pilih folder"})]})}),t.jsx(hr,{open:o,onClose:()=>l(!1),start:r.dir,onPick:b=>s(v=>({...v,dir:b}))}),t.jsx(oe,{label:"Git remote",hint:"opsional · remote resmi agar device lain bisa clone project ini · disync antar-device",children:t.jsx(Oe,{value:r.gitRemote,onChange:b=>s(v=>({...v,gitRemote:b.target.value})),leftIcon:"git-branch",mono:!0,placeholder:"https://github.com/org/repo.git",className:"hn-w-full"})}),t.jsx(oe,{label:"Ditangani oleh",hint:p?"hanoman client yang memegang project ini · disync ke semua mesin · boleh kosong":"disync ke semua mesin · hanya bisa diubah dari instance yang memegang katalog device",children:p?t.jsx(Nd,{"aria-label":"Pilih hanoman client",placeholder:"Pilih client…",searchPlaceholder:"mis. mac-mini atau vps-jakarta",emptyText:"Tak ada device terdaftar yang cocok.",value:m.map(b=>b.deviceId),invalidValues:m.filter(b=>!c.some(v=>v.id===b.deviceId&&!v.revokedAt)).map(b=>b.deviceId),options:c.filter(b=>!b.revokedAt).map(b=>({value:b.id,label:b.lastSeenAt?`${b.name} · terakhir ${new Date(b.lastSeenAt).toLocaleDateString("id-ID")}`:b.name})),onChange:b=>h(b.map(v=>{var x;return m.find(y=>y.deviceId===v)??{deviceId:v,name:((x=c.find(y=>y.id===v))==null?void 0:x.name)??v}}))}):t.jsx(ub,{list:a==null?void 0:a.handledBy})})]})}function uR(){return t.jsx(Pf,{children:t.jsx(mR,{})})}function mR(){var Es,Ts,Cs,Ps,Ms;const e=Mf(),a=If(),n=d.useMemo(()=>_j(e.pathname,Ml),[e.pathname]),[i,r]=Ba("app","section","overview",bi(...Ml)),s=(n==null?void 0:n.section)??i;d.useEffect(()=>{n&&Ml.includes(n.section)&&r(n.section)},[n==null?void 0:n.section]);const o=d.useCallback(_=>a(Jt({section:_})),[a]),l=d.useCallback(_=>a(Jt({section:"project",projectId:_})),[a]),[c,u]=d.useState(null),[m,h]=d.useState([]),[p,g]=d.useState([]),f=d.useRef(""),[b,v]=d.useState(0),[x,y]=d.useState([]),[T,S]=d.useState([]),[E,w]=Ba("app","projectId","",Dn),[N,R]=d.useState(null),[L,I]=Ba("app","projectFilter","all",Dn),[B,A]=d.useState(null),[M,K]=d.useState(null),[O,J]=d.useState(null);d.useEffect(()=>{s!=="terminal"&&A(null)},[s]);const Z=d.useCallback(_=>{A(_??null),o("terminal")},[o]),[H,te]=Ba("projects","q","",Dn),[ae,F]=d.useState(null),{confirm:fe,dialog:_e}=lt(),ee=aT(),[X,ce]=d.useState(null),[se,Ce]=d.useState(null),[Te,le]=mk(),[ya,Ze]=d.useState("loading"),[He,Ke]=d.useState(null),ga=d.useCallback(()=>Ke({needsSetup:!1,user:null}),[]);d.useEffect(()=>{ne.authStatus().then(Ke).catch(()=>Ke({needsSetup:!1,user:null}))},[]);const Ge=(He==null?void 0:He.user)!=null&&He.user.role!=="client";ek(Ge);const[ba,Ta]=tb(),va=al(),we=Ge&&VE(ba,va),[Je,U]=d.useState(null),[Be,ue]=d.useState(!1);d.useEffect(()=>{(He!=null&&He.needsSetup||Ge)&&ne.setupStatus().then(U).catch(()=>U(null))},[He==null?void 0:He.needsSetup,Ge,(Es=He==null?void 0:He.user)==null?void 0:Es.id]),d.useEffect(()=>{PA()},[]),d.useEffect(()=>{const _=iM(window.location.hash);if(_){a(Jt({section:"backlog",specId:_}),{replace:!0});return}n||a(Jt({section:i}),{replace:!0})},[n]),d.useEffect(()=>{(n==null?void 0:n.section)==="project"&&n.projectId&&w(n.projectId),(n==null?void 0:n.section)==="backlog"&&u(n.specId??null)},[n==null?void 0:n.section,n==null?void 0:n.projectId,n==null?void 0:n.specId]);const[We,sa]=d.useState({enabled:!1,devices:[],hubVersion:""}),[ye,la]=d.useState(null),Se=d.useRef({sessions:x,leadAsks:T,pending:ye});Se.current={sessions:x,leadAsks:T,pending:ye};const xe=d.useCallback(()=>{Ze("loading"),Promise.all([ne.listProjects(),ne.listSpecs(),ne.listTerminals()]).then(([_,W,Y])=>{h(_.items),g(W.items.map(aM)),y(Y),f.current=Hh(W.items),w(je=>{var V;return je||((V=_.items[0])==null?void 0:V.id)||""}),v(je=>je+1),Ze("ready")}).catch(_=>{if(_ instanceof ha&&_.status===401){ga();return}Ze("error"),le("Gagal memuat data dari server","err","x-circle")})},[le,ga]);d.useEffect(()=>{Ge&&xe()},[xe,Ge,(Ts=He==null?void 0:He.user)==null?void 0:Ts.id]);const aa=m,Ea=d.useCallback(async _=>{try{const W=await ne.getProject(_);h(Y=>Y.map(je=>je.id===W.id?W:je))}catch{}},[]),dt=d.useMemo(()=>new Set(x.filter(_=>_.specId&&!_.exited).map(_=>_.specId)),[x]),qa=d.useMemo(()=>mI(x,p),[x,p]),Xe=d.useMemo(()=>X5(We),[We]),ge=d.useMemo(()=>Object.fromEntries(p.map(_=>[_.id,_.title])),[p]);d.useEffect(()=>{if(Ge)return Ii(_=>{if(_.t==="specs"){const W=Hh(_.specs);W!==f.current&&(f.current=W,g(_.specs),v(Y=>Y+1))}else if(_.t==="sessions")Ql(Se.current.sessions,_.sessions,y);else if(_.t==="leadAsks")Ql(Se.current.leadAsks,_.asks,S);else if(_.t==="presence"){const W={enabled:_.enabled,devices:_.devices,hubVersion:_.hubVersion};sa(Y=>qh(Y)===qh(W)?Y:W)}else _.t==="pending"&&Ql(Se.current.pending,_.counts,la)})},[Ge]);const be=aa.find(_=>_.id===E)||aa[0];function ua(_){w(_.id),l(_.id)}const Da=(_,W)=>a(Jt({section:"review",kind:_,id:W}));function it(_){R({id:_.id,kind:"spec",title:_.title}),Da("spec",_.id)}function It(_){var W;R({id:_,kind:"spec",title:((W=p.find(Y=>Y.id===_))==null?void 0:W.title)??_}),Da("spec",_)}function pt(_,W){R({id:_,kind:"session",title:W}),Da("session",_)}const _a=(n==null?void 0:n.section)==="review"?N&&N.id===n.id&&N.kind===n.kind?N:{id:n.id,kind:n.kind,title:((Cs=p.find(_=>_.id===n.id))==null?void 0:Cs.title)??n.id}:null,Nt=d.useMemo(()=>oo.filter(_=>!_.gate||We.enabled),[We.enabled]),Rt=d.useMemo(()=>Nt.map(_=>_.key),[Nt]);ME({enabled:!!(He!=null&&He.user)&&He.user.role!=="client",navKeys:Rt,go:o});const st=d.useMemo(()=>aa.map(_=>({id:_.id,name:_.name})),[m]),Ua=d.useMemo(()=>({value:L,projects:st,onChange:I}),[L,st,I]),Ja=d.useMemo(()=>vE({nav:oo,gates:{clients:We.enabled},projects:st,specs:p,waiting:eb(x,p).map(_=>{const W=_.specId?ge[_.specId]:void 0;return{id:_.id,label:`${_.specId??_.id}${W?` · ${W}`:""}`}}),scope:L,go:o,openSpec:_=>a(Jt({section:"backlog",specId:_})),openSession:_=>Z(_),newSpec:()=>F("brief"),newProject:()=>F("project"),setScope:I,petOn:we,setPetOn:Ta}),[p,x,st,We.enabled,L,ge,o,a,Z,we,Ta]),Et=d.useRef(null);d.useEffect(()=>{s!=="dalang"&&(Et.current=s)},[s]);const Tt=d.useCallback(_=>s==="terminal"&&!!_.sessionId&&B===_.sessionId,[s,B]),Ct=d.useCallback(_=>{const W=o2(_,x);W.projectFilter&&I(W.projectFilter),W.focus&&A(W.focus),o(W.section)},[x]);async function jn(_){if(!be)return;const W=_.id.trim();try{if(W&&W!==be.id){if(!await fe({title:`Ganti ID project "${be.id}" → "${W}"?`,message:"Ini berpengaruh ke SEMUA yang terkait project:",impact:[t.jsxs(t.Fragment,{children:["Link Help Center publik berubah jadi ",t.jsxs("code",{children:["/help/",W]})," — tautan lama rusak."]}),"Perubahan dirambatkan (sync) ke server; server ikut berganti id."],confirmLabel:"Ganti ID",icon:"pencil"}))return;const re=await ne.renameProject(be.id,W);re.helpUrl&&le("Help Center baru: "+re.helpUrl,"ok","life-buoy")}const Y=W&&W!==be.id?W:be.id;await ne.updateProject(Y,{name:_.name.trim(),desc:_.desc.trim(),gitRemote:_.gitRemote.trim(),..._.handledBy?{handledBy:_.handledBy}:{}});const je=_.dir.trim();je!==(be.binding??"")&&(je?await ne.putBinding(Y,je):await ne.deleteBinding(Y));const V=await ne.getProject(Y);h(re=>[...re.filter(Ue=>Ue.id!==be.id&&Ue.id!==V.id),V]),w(V.id),F(null),le("Project "+V.name+" diperbarui","ok","box")}catch{le("Gagal memperbarui project","err","x-circle")}}async function Pt(_){var Ue;const W=_.kind==="from-scratch",Y=!W&&_.mode==="clone",je=du(_.gitRemote),V=_.name.trim()||(Y?je:_.dir.split("/").filter(Boolean).pop()||"repo");let re;try{re=await ne.createProject({name:V,kind:_.kind,desc:W&&_.objective.trim()||_.desc.trim(),repoDir:W?_.dir.trim():Y?void 0:_.dir,gitRemote:Y?_.gitRemote.trim():void 0})}catch{le("Gagal membuat project","err","x-circle");return}if(Y)try{await ne.cloneProject(re.id,_.dir.trim()),re=await ne.getProject(re.id)}catch(na){const{error:Ka}=ef(na);h(Za=>[re,...Za]),w(re.id),F(null),l(re.id),le(`Project ${re.id} dibuat, tapi clone gagal · ${Ka} · clone ulang dari detail project`,"warn","git-branch");return}if(h(na=>[re,...na]),F(null),W){let na=!0;try{na=(await ne.getSettings()).autoScaffold}catch{}if(na)try{const{id:Ka}=await ne.scaffoldDocs(re.id);w(re.id),Z(Ka),le(`Project ${re.id} dibuat · buat kerangka dokumen · sesi ${Ka} dimulai`,"ok","sparkles");return}catch{}w(re.id),l(re.id),le(`Project ${re.id} dibuat · tekan "Scaffold docs" untuk menyusun SoT`,"ok","box");return}w(re.id);try{const{id:na}=await ne.reverseDocs(re.id);Z(na),le(`Project ${re.id} dibuat · susun dokumen · sesi ${na} dimulai`,"ok","radar")}catch(na){const Ka=(Ue=na.detail)==null?void 0:Ue.error;l(re.id),le(`Project ${re.id} dibuat, tapi susun dokumen gagal dimulai`+(Ka?` · ${Ka}`:"")+' · ulangi lewat "Reverse docs"',"warn","radar")}}async function xt(_){try{if(!await fe({title:`Hapus project "${_.name}"?`,message:`Project "${_.id}" dan seluruh isinya dihapus dari dashboard ini.`,impact:["Semua backlog item project ini ikut terhapus.","Tindakan ini tak bisa dibatalkan."],confirmLabel:"Hapus project",run:()=>ne.deleteProject(_.id)}))return;h(W=>W.filter(Y=>Y.id!==_.id)),g(W=>W.filter(Y=>Y.projectId!==_.id)),y(W=>W.filter(Y=>Y.projectId!==_.id)),w(W=>W===_.id?"":W),I(W=>W===_.id?"all":W),(s==="docs"||s==="project")&&o("projects"),le("Project "+_.id+" dihapus","warn","trash-2")}catch(W){const Y=W instanceof ha&&W.status===409;le("Gagal hapus "+_.id+(Y?" · masih ada sesi aktif":""),"err","x-circle")}}const[za,on]=d.useState(null);function xa(_){J("backlog"),on(_)}function Gt(_){J("terminal"),on(_)}const ln=d.useCallback(()=>K(null),[]);async function jt(_,W,Y){try{const je=await ne.integrateSpec(_.id,W,Y);je.status==="conflict"?(Z(je.sessionId),le(`${_.id} · konflik ${W} — selesaikan di Terminal`,"warn","git-merge")):le(`${_.id} · ${W} berhasil · ${je.detail}`,"ok","git-merge")}catch(je){const V=je instanceof ha?je.status:0;le(`${_.id} · gagal ${W}`+(V===409?" · cek target/branch":""),"err","x-circle")}}async function wn(_,W,Y){try{const je=await ne.sessionIntegrate(_.id,W,Y);je.status==="conflict"?(Z(je.sessionId),le(`${_.id} · konflik ${W} — selesaikan di Terminal`,"warn","git-merge")):le(`${_.id} · ${W} berhasil · ${je.detail}`,"ok","git-merge")}catch(je){const V=je instanceof ha?je.status:0;le(`${_.id} · gagal ${W}`+(V===409?" · cek target/branch":""),"err","x-circle")}}async function Kt(_,W){try{const{id:Y}=await(W?ne.reverseDocs(_.id,{force:W}):ne.reverseDocs(_.id));Z(Y),le(_.id+" · susun dokumen · sesi "+Y+" dimulai","info","radar")}catch(Y){if(ee.offerRetry(Y,`${_.id} · susun dokumen`,V=>Kt(_,V)))return;const je=Y instanceof ha&&(Y.status===422||Y.status===400);le(_.id+" · gagal mulai reverse"+(je?" · project belum punya repoDir":""),"warn","x-circle")}}async function me(_,W){try{const{id:Y}=await(W?ne.scaffoldDocs(_.id,{force:W}):ne.scaffoldDocs(_.id));Z(Y),le(_.id+" · buat kerangka dokumen · sesi "+Y+" dimulai","info","sparkles")}catch(Y){if(ee.offerRetry(Y,`${_.id} · buat kerangka dokumen`,V=>me(_,V)))return;const je=Y instanceof ha&&(Y.status===422||Y.status===400);le(_.id+" · gagal mulai scaffold"+(je?" · project belum punya repoDir":""),"warn","x-circle")}}async function ia(_,W,Y,je){try{const{id:V}=await ne.startPrd(_,W,je?{...Y,force:je}:Y);Z(V),le(`PRD · sesi ${V} dimulai`,"info","scroll-text")}catch(V){if(ee.offerRetry(V,`${_} · PRD`,Ue=>ia(_,W,Y,Ue)))return;const re=V instanceof ha&&(V.status===422||V.status===400);le("gagal mulai PRD"+(re?" · project belum punya repoDir":""),"warn","x-circle")}}function Fa(_){ce(_),F("brief")}async function Ya(_,W,Y){try{const{id:je}=await(Y?ne.startBreakdown(_,W,{force:Y}):ne.startBreakdown(_,W));Z(je),le(`Breakdown · sesi ${je} dimulai`,"info","split")}catch(je){if(ee.offerRetry(je,`${_} · pecah jadi backlog`,re=>Ya(_,W,re)))return;const V=je instanceof ha&&(je.status===422||je.status===400);le("gagal mulai breakdown"+(V?" · project belum punya repoDir/PRD":""),"warn","x-circle")}}async function ri(_,W,Y){try{const{created:je}=await ne.createSpecsBatch({project:_,items:Y,prdPath:W});return g(V=>[...je,...V]),o("backlog"),le(`${je.length} backlog dibuat dari PRD`,"ok","list-checks"),je.length}catch{return le("Gagal membuat backlog dari PRD","err","x-circle"),0}}function Vn(_,W){const Y=W==null?void 0:W.prefill,je=`Dari audit ${_.id}: ${_.objective}`;ce({project:_.projectId,kind:"qa",title:(Y==null?void 0:Y.title)||_.title,steps:((Y==null?void 0:Y.steps)||je).slice(0,500),actual:(Y==null?void 0:Y.context)||_.objective,severity:Y!=null&&Y.severity&&["critical","major","minor"].includes(Y.severity)?Y.severity:"major",constraints:(Y==null?void 0:Y.constraints)??"",branchFrom:`hanoman/${_.id.toLowerCase()}`,fromAudit:_.id}),F("brief")}function oi(_,W){const Y=W==null?void 0:W.prefill;ce({project:_.projectId,kind:"brief",title:(Y==null?void 0:Y.title)||_.title,context:(Y==null?void 0:Y.context)||`Dari audit ${_.id}: ${_.objective}`,outcome:(Y==null?void 0:Y.outcome)||"",branchFrom:`hanoman/${_.id.toLowerCase()}`,fromAudit:_.id}),F("brief")}function Ni(_,W){const Y=W==null?void 0:W.prefill;Ce({project:_.projectId,branchFrom:`hanoman/${_.id.toLowerCase()}`,fromAudit:_.id,title:(Y==null?void 0:Y.title)||_.title,context:(Y==null?void 0:Y.context)||`Dari audit ${_.id}: ${_.objective}`,outcome:(Y==null?void 0:Y.outcome)||""})}async function _s(_,W){try{const Y=await ne.patchSpec(_.id,{branchFrom:W});if("pending"in Y)return;g(je=>je.map(V=>V.id===Y.id?Y:V)),le(_.id+" · branch "+(W??"main (default project)"),"ok","git-branch")}catch{le("Gagal mengubah branch "+_.id,"err","x-circle")}}async function ta(_,W){try{const Y=await ne.patchSpec(_.id,W);if("pending"in Y)return;g(je=>je.map(V=>V.id===Y.id?Y:V)),le(_.id+" diperbarui","ok","check")}catch(Y){const je=Y instanceof ha&&Y.status===409;le(je?_.id+" sudah dimulai — tak bisa diedit":"Gagal menyimpan "+_.id,"warn","x-circle")}}async function Ri(_,W,Y,je){try{const V=await ne.changeSpecSource(_.id,{source:W,payload:Y,confirmReset:je});return"pending"in V?V:(g(re=>re.map(Ue=>Ue.id===V.id?V:Ue)),le(`${_.id} · type ${_.source} → ${W}`,"ok","shuffle"),null)}catch(V){const re=V instanceof ha&&V.status===409;return le(re?`${_.id} punya sesi yang masih berjalan — tutup dulu sesinya`:`Gagal mengubah type ${_.id}`,"warn","x-circle"),null}}async function ie(_,W){try{const Y=await ne.patchSpec(_.id,{dependsOn:W});if("pending"in Y)return;g(je=>je.map(V=>V.id===Y.id?Y:V)),le(_.id+" · dependency diperbarui","ok","lock")}catch(Y){const je=Y instanceof ha&&Y.status===400;le(je?"Dependency ditolak server":"Gagal menyimpan dependency "+_.id,"warn","x-circle")}}async function De(_,W){try{const Y=await ne.patchSpec(_.id,{autoMerge:W});if("pending"in Y)return;g(je=>je.map(V=>V.id===Y.id?Y:V)),le(_.id+" · auto-merge diperbarui","ok","git-merge")}catch(Y){const je=Y instanceof ha?Y.message:"Gagal menyimpan auto-merge "+_.id;le(je,"warn","x-circle")}}async function qe(_,W,Y){try{const je=await ne.patchSpec(_.id,{stage:W,confirmDelete:Y});return"pending"in je||(g(V=>V.map(re=>re.id===je.id?je:re)),le(_.id+" dikembalikan ke "+(Lc[W]??W),"warn","rotate-ccw")),je}catch{le("Gagal mengembalikan stage "+_.id,"err","x-circle");return}}async function ra(_){const{defaultBranch:W}=await ne.listBranches(_.projectId),Y=_.branchFrom??W;if(!Y){le(_.id+" · cabang tujuan belum diketahui","err","x-circle");return}await jt(_,"merge","local:"+Y)}async function Ga(_){const W=await ne.deleteSpecWorktree(_.id);if(!W.ok)throw new Error(W.error??"worktree tidak ditemukan");le(_.id+" · worktree dihapus","ok","trash-2")}async function Sn(_,W,Y){var je;try{const V=await ne.markSpecDone(_.id,{reason:W||void 0,confirm:Y});return g(re=>re.map(Ue=>Ue.id===V.id?V:Ue)),le(_.id+" ditandai selesai","ok","circle-check"),V}catch(V){const re=V instanceof ha?V.detail:null;if((re==null?void 0:re.error)==="confirm-required")return{needConfirm:!0,sessionId:(je=re.session)==null?void 0:je.id};le((re==null?void 0:re.error)==="backlog item sudah selesai"?_.id+" sudah selesai":"Gagal menandai selesai "+_.id,"warn","x-circle");return}}async function dn(_,W){const Y=await ne.markSpecReviewed(_.id,W);g(je=>je.map(V=>V.id===Y.id?{...V,reviewedAt:Y.reviewedAt}:V)),le(_.id+(W?" ditandai sudah ditinjau":" tanda ditinjau dibatalkan"),"ok",W?"circle-check":"rotate-ccw")}async function Lt(_){await ne.deleteSpec(_.id),g(W=>W.filter(Y=>Y.id!==_.id)),le(_.id+" dihapus dari backlog","warn","trash-2")}async function li(_){const W=_.kind==="qa",Y=Ti(_.kind)==="goal",je=W?{severity:_.severity,steps:_.steps,expected:_.expected,actual:_.actual,env:_.env,constraints:_.constraints,..._.fromAudit?{fromAudit:_.fromAudit}:{}}:Y?{goal:_.goal.trim(),done:_.done,constraints:_.constraints,priority:_.priority}:{context:_.context,outcome:_.outcome,constraints:_.constraints,priority:_.priority,..._.fromAudit?{fromAudit:_.fromAudit}:{}};try{const V=await ne.createSpec({project:_.project,source:_.kind,title:_.title.trim(),priority:_.priority,payload:je,branchFrom:_.branchFrom||void 0,..._.dependsOn.length?{dependsOn:_.dependsOn}:{}});if(g(Ue=>[V,...Ue]),_.attachments.length){const Ue=await ne.uploadSpecAttachments(V.id,_.attachments).catch(()=>null);Ue?Ue.rejected.length&&le(`${Ue.rejected.length} lampiran ditolak: ${Ue.rejected.map(na=>na.filename).join(", ")}`,"warn","paperclip"):le("Item dibuat, tapi lampiran gagal diunggah","warn","paperclip")}F(null),ce(null),o("backlog");const re=_.kind==="audit"?" dibuat · audit-only (dokumen)":_.kind==="no_effort"?" dibuat · sesi satu fase (Kerjakan)":_.kind==="goal"?" dibuat · sesi goal (Goal → Verifikasi)":W?" difilekan · masuk audit":" dibuat · masuk brainstorm";le(V.id+re,"ok",_.kind==="audit"?"search":_.kind==="no_effort"?"zap":_.kind==="goal"?"target":W?"bug":"lightbulb")}catch{le("Gagal membuat spec","err","x-circle")}}const di=_=>t.jsx(e2,{children:t.jsx(d.Suspense,{fallback:t.jsx(he,{kind:"loading",title:"Memuat halaman…"}),children:_})}),Qa=_=>ya==="loading"?t.jsx(he,{kind:"loading",title:"Memuat workspace…"}):ya==="error"?t.jsx(he,{kind:"error",illustration:"PST-006",title:"Gagal memuat data dari server",hint:"Pastikan server hanoman berjalan, lalu coba lagi.",action:xe}):di(_),Oa=t.jsx(hE,{section:s,onNavigate:o});if(!He)return t.jsx(he,{kind:"loading",title:"Memuat hanoman…"});if(He.needsSetup&&(Je!=null&&Je.needed)&&!Be)return t.jsx(hT,{status:Je,onDone:()=>ue(!0)});if(!He.user)return t.jsx(mT,{needsSetup:He.needsSetup,setupTokenRequired:He.setupTokenRequired??!1,setupTokenPath:He.setupTokenPath,setupStep:He.needsSetup&&Be?2:void 0,onDone:_=>Ke({needsSetup:!1,user:_})});if(He.user.role==="client")return t.jsx(_T,{user:He.user,onLoggedOut:ga});const As=He.user;let Ra=null;if(s==="overview")Ra=t.jsx(Xa,{active:"overview",title:"Overview",breadcrumb:"nafanesia.id · ringkasan workspace",onNavigate:o,children:Qa(t.jsx(hM,{projects:aa,backlog:p,sessions:x,onOpenProject:ua,onGoto:o,onCreateProject:()=>F("project"),onOpenSession:_=>{A(_),o("terminal")}}))});else if(s==="dalang"){const _=Et.current,W=(Ps=oo.find(Y=>Y.key===_))==null?void 0:Ps.label;Ra=Qa(t.jsx(VN,{projects:aa,backlog:p,sessions:x,onOpenProject:ua,onGoto:o,onOpenSession:Y=>{A(Y),o("terminal")},previous:_&&W?{label:W,onBack:()=>o(_)}:void 0,onExit:()=>o("overview")}))}else if(s==="projects")Ra=t.jsxs(Xa,{active:"projects",title:"Projects",breadcrumb:"nafanesia.id · workspace",showSearch:!0,searchValue:H,onSearchChange:te,onNavigate:o,actions:t.jsx(q,{size:"sm",leftIcon:"plus",onClick:()=>F("project"),children:"Project baru"}),children:[Oa,Qa(aa.length===0?t.jsx(he,{kind:"empty",icon:"box",title:"Belum ada project",hint:"Mulai dari nol atau tambahkan codebase yang sudah ada — hanoman menyusun Source of Truth-nya.",action:()=>F("project"),actionLabel:"Project baru"}):t.jsx(bM,{projects:aa,variant:"list",onOpen:ua,onDelete:xt,pageSize:20,search:H,dataVersion:b,onClearSearch:()=>te(""),presenceByProject:Xe.byProject}))]});else if(s==="project")Ra=t.jsxs(Xa,{active:"projects",title:be?be.name:"Project",breadcrumb:be?"projects · "+be.id:"projects",onNavigate:o,children:[Oa,Qa(be?t.jsx(PM,{p:be,onEdit:()=>F("project-edit"),onToast:le,onProjectChanged:Ea,onGotoDocs:()=>o("docs"),onGotoTerminal:()=>{I(be.id),Z()},onGotoBacklog:()=>{I(be.id),o("backlog")},onGotoSkills:()=>a(Jt({section:"skills",projectId:be.id})),onReverse:be.kind==="existing"&&(be.binding??be.repoDir)?()=>Kt(be):void 0,onScaffold:be.kind==="from-scratch"&&(be.binding??be.repoDir)?()=>me(be):void 0,onDelete:()=>xt(be)}):t.jsx(he,{kind:"empty",icon:"box",title:"Belum ada project",hint:"Mulai dari nol atau tambahkan codebase yang sudah ada.",action:()=>F("project"),actionLabel:"Project baru"}))]});else if(s==="backlog")Ra=t.jsxs(Xa,{active:"backlog",title:"Backlog",breadcrumb:"specs · brainstorm → execute",onNavigate:o,actions:t.jsx(q,{size:"sm",leftIcon:"plus",onClick:()=>F("brief"),children:"Tambah"}),children:[Oa,Qa(t.jsx(zI,{backlog:p,projects:aa,pageSize:20,onStart:xa,activeSpecs:dt,presenceBySpec:Xe.bySpec,reviewSpecIds:qa,onNew:()=>F("brief"),onDelete:Lt,onOpenRun:_=>{var W;return Z((W=x.find(Y=>Y.specId===_.id&&!Y.exited))==null?void 0:W.id)},onOpenReview:it,onEditBranch:_s,onRevertStage:qe,onMarkDone:Sn,onMarkReviewed:(_,W)=>dn(_,W).catch(()=>le(_.id+" gagal diperbarui","warn","x-circle")),onIntegrate:jt,onEditSpec:ta,onEditDeps:ie,onEditAutoMerge:De,onChangeSource:Ri,onPromoteToQa:Vn,onPromoteToBrief:oi,onPromoteToPrd:Ni,onToast:le,initialDetailId:c,projectFilter:L,onProjectFilter:I,dataVersion:b}))]});else if(s==="team")Ra=t.jsxs(Xa,{active:"team",title:"Tim",breadcrumb:"tugas manusia · backlog → selesai",onNavigate:o,children:[Oa,t.jsx(YN,{projects:aa,projectFilter:L,onProjectFilter:I,onToast:le,onOpenSpec:_=>a(Jt({section:"backlog",specId:_}))})]});else if(s==="triage")Ra=t.jsx(Xa,{active:"triage",title:"Triase",breadcrumb:"keluhan · lapor → triase → backlog",onNavigate:o,children:t.jsx(JN,{projects:aa,onToast:le,onAccepted:(_,W)=>{le(W?`Tiket sudah jadi ${_.id}`:`Diterima → ${_.id}`,"ok","arrow-up-right"),I(_.projectId),o("backlog")}})});else if(s==="prd")Ra=t.jsxs(Xa,{active:"prd",title:"PRD",breadcrumb:"brief → brainstorm → dokumen",onNavigate:o,children:[Oa,Qa(aa.length===0?t.jsx(he,{kind:"empty",icon:"box",title:"Belum ada project",hint:"PRD butuh project dengan repoDir untuk menulis docs/prd/.",action:()=>F("project"),actionLabel:"Project baru"}):t.jsx(QI,{projects:aa,projectFilter:L,onProjectFilter:I,onNewPrd:ia,onTakeToBacklog:Fa,onStartBreakdown:Ya,onMaterialize:ri,dataVersion:b}))]});else if(s==="terminal")Ra=t.jsxs(Xa,{active:"terminal",title:"Terminal",breadcrumb:"Claude Code · sesi interaktif",onNavigate:o,wide:!0,children:[Oa,Qa(aa.length===0?t.jsx(he,{kind:"empty",icon:"box",title:"Belum ada project",hint:"Terminal butuh project dengan repoDir untuk dijalankan.",action:()=>F("project"),actionLabel:"Project baru"}):t.jsx(QN,{userId:As.id,projects:aa,backlog:p,focusSession:B,sessions:x,setSessions:y,startedSession:M,onStartedSessionHandled:ln,onStartBacklog:Gt,onOpenProject:l,onOpenReview:It,onOpenSessionReview:pt,titleOf:_=>{var W;return(W=p.find(Y=>Y.id===_))==null?void 0:W.title},onIntegrate:jt,onIntegrateSession:wn,specOf:_=>p.find(W=>W.id===_)}))]});else if(s==="ide")Ra=t.jsxs(Xa,{active:"ide",title:"IDE",breadcrumb:be?be.name:"workspace",onNavigate:o,wide:!0,children:[Oa,Qa(aa.length===0?t.jsx(he,{kind:"empty",icon:"box",title:"Belum ada project",hint:"IDE butuh project dengan repoDir.",action:()=>F("project"),actionLabel:"Project baru"}):t.jsx(ZN,{projects:aa,projectId:be?be.id:aa[0].id,onProject:_=>w(_),onToast:le,onGotoTerminal:Z}))]});else if(s==="vps")Ra=t.jsxs(Xa,{active:"vps",title:"VPS",breadcrumb:"infra · audit → harden",onNavigate:o,children:[Oa,t.jsx(XN,{onToast:le,onGotoTerminal:Z})]});else if(s==="clients")Ra=t.jsxs(Xa,{active:"clients",title:"Klien",breadcrumb:"device · sesi yang sedang berjalan",onNavigate:o,children:[Oa,t.jsx(Z5,{view:We,specTitles:ge,onOpenSpec:It,onToast:le})]});else if(s==="scheduler")Ra=t.jsxs(Xa,{active:"scheduler",title:"Scheduler",breadcrumb:"otonom · jadwal → antrean → sesi",onNavigate:o,children:[Oa,t.jsx(eR,{projects:aa,backlog:p,onProjectChanged:Ea,onToast:le,onGotoTerminal:Z})]});else if(s==="lead")Ra=t.jsxs(Xa,{active:"lead",title:"Lead",breadcrumb:"otonom · keputusan → jejak → kendali",onNavigate:o,children:[Oa,t.jsx(aR,{projects:aa,onProjectChanged:Ea,onToast:le,onGotoTerminal:Z})]});else if(s==="docs")Ra=t.jsxs(Xa,{active:"docs",title:"Source of Truth",breadcrumb:be?be.name:"workspace",onNavigate:o,wide:!0,actions:be&&t.jsxs(t.Fragment,{children:[t.jsx($e,{size:"sm","aria-label":"Pilih project",value:be.id,onChange:_=>w(_.target.value),options:aa.map(_=>({value:_.id,label:_.name}))}),t.jsx(rn,{label:`Aksi untuk project ${be.name}`,icon:"ellipsis",items:[{key:"delete",label:"Hapus project…",icon:"trash-2",tone:"danger",onSelect:()=>xt(be)}]})]}),children:[Oa,Qa(be?t.jsx(tR,{projectId:be.id,projectName:be.name,docStatus:be.docStatus}):t.jsx(he,{kind:"empty",icon:"book-open",title:"Belum ada project",hint:"Source of Truth muncul setelah ada project yang dipantau.",action:()=>F("project"),actionLabel:"Project baru"}))]});else if(s==="review"){const _=(_a==null?void 0:_a.kind)==="session"?"terminal":"backlog",W=(_a==null?void 0:_a.kind)==="spec"?p.find(Y=>Y.id===_a.id):void 0;Ra=t.jsxs(Xa,{active:"backlog",title:"Review",wide:!0,onNavigate:o,breadcrumb:_a?(_a.kind==="session"?"terminal · ":"backlog · ")+_a.id:"review",actions:t.jsx(q,{size:"sm",variant:"ghost",leftIcon:"arrow-left",onClick:()=>o(_),children:"Kembali"}),children:[Oa,Qa(_a?t.jsx(nR,{specId:_a.id,kind:_a.kind,title:_a.title,onBack:()=>o(_),onGoto:Y=>a(Jt(Y)),...(W==null?void 0:W.stage)==="done"?{onIntegrate:()=>ra(W),integrateTarget:W.branchFrom??void 0,onRevert:async(Y,je)=>{const V=await qe(W,"executing",je);return V&&"pending"in V?V:void 0},reviewed:!!W.reviewedAt,onMarkReviewed:(Y,je)=>dn(W,je)}:{},...W&&W.stage!=="done"?{onDiscard:()=>Ga(W)}:{}}):t.jsx(he,{kind:"empty",icon:"git-compare",title:"Pilih item untuk di-review",hint:"Buka Review dari Backlog atau dari sel sesi di Terminal.",action:()=>o("backlog"),actionLabel:"Ke Backlog"}))]})}else if(s==="qa"){const _=(n==null?void 0:n.projectId)??((Ms=m[0])==null?void 0:Ms.id);Ra=t.jsxs(Xa,{active:"qa",title:"QA",wide:!0,onNavigate:o,breadcrumb:"qa · laporan per project",children:[Oa,Qa(t.jsx(rI,{projects:m,projectId:_,onSelectProject:W=>a(Jt({section:"qa",projectId:W})),onToast:le,onOpenSession:W=>{A(W),o("terminal")}},_??"none"))]})}else if(s==="skills"){const _=n!=null&&n.projectId?m.find(W=>W.id===n.projectId):void 0;Ra=t.jsx(Xa,{active:"skills",title:"Skills",wide:!0,onNavigate:o,breadcrumb:n!=null&&n.projectId?`skills · ${(_==null?void 0:_.name)??n.projectId}`:"skills · global & project",actions:n!=null&&n.projectId?t.jsx(q,{size:"sm",variant:"ghost",leftIcon:"arrow-left",onClick:()=>l(n.projectId),children:"Kembali ke project"}):void 0,children:Qa(t.jsx(qM,{projectId:n==null?void 0:n.projectId,projectName:_==null?void 0:_.name,onToast:le},(n==null?void 0:n.projectId)??"all"))})}else s==="settings"&&(Ra=t.jsxs(Xa,{active:"settings",title:"Settings",breadcrumb:"nafanesia.id · workspace",onNavigate:o,children:[Oa,di(t.jsx(iR,{onToast:le,me:As,onLoggedOut:ga}))]}));return t.jsx(jA,{user:As,onLoggedOut:ga,children:t.jsxs(r2,{showToast:le,onOpen:Ct,isViewing:Tt,children:[t.jsx(pT,{status:Je}),t.jsx(Ok.Provider,{value:Ua,children:t.jsx(Qc.Provider,{value:{clients:We.enabled},children:t.jsx(Jc.Provider,{value:ye,children:t.jsx(Fk.Provider,{value:we?t.jsx(WN,{sessions:x,backlog:p,asks:T,onOpen:_=>{_.sessionId&&A(_.sessionId),o(_.section)}}):null,children:Ra})})})}),t.jsx(lR,{open:ae==="brief",onClose:()=>{F(null),ce(null)},projects:aa,defaultProject:be?be.id:"",onCreate:li,prefill:X??void 0,specs:p})," ",se&&t.jsx(vf,{projects:aa,defaultProject:se.project,lockProject:!0,prefill:{title:se.title,context:se.context,outcome:se.outcome},onClose:()=>Ce(null),onCreate:(_,W)=>{ia(_,W,{branchFrom:se.branchFrom,fromAudit:se.fromAudit}),Ce(null)}}),t.jsx(dR,{open:ae==="project",onClose:()=>F(null),onCreate:Pt}),t.jsx(cR,{open:ae==="project-edit",project:be,onClose:()=>F(null),onSave:jn}),t.jsx(oR,{open:!!za,spec:za,onClose:()=>{on(null),J(null)},onStarted:(_,W)=>{const Y=za;if(O==="terminal"&&Y){const je={id:_,projectId:Y.projectId,specId:Y.id,flow:ur(Y.source),cwd:"",exited:!1};K(je),A(_),y(V=>V.some(re=>re.id===_)?V:[...V,je])}le(((Y==null?void 0:Y.id)??"")+" · sesi "+_+(W?" dilanjutkan":" dimulai"),"info","play")},onError:_=>{const W=_ instanceof ha&&(_.status===400||_.status===422);le(((za==null?void 0:za.id)??"")+" · gagal mulai sesi"+(W?" · project belum punya repoDir":""),"warn","x-circle")}}),_e,ee.dialog,t.jsx(SE,{commands:Ja}),t.jsx(AE,{nav:Nt}),t.jsx(Hc,{toast:Te})]})})}const sc={async getInfo(e){const a=await fetch(C.help(e));if(!a.ok)throw new Error("Help Center tak tersedia untuk project ini.");return a.json()},async submit(e,a){const n=await fetch(C.helpTickets(e),{method:"POST",body:a});if(n.status===429)throw new Error("Terlalu banyak permintaan. Coba lagi beberapa saat lagi.");if(n.status===404)throw new Error("Help Center tidak aktif untuk project ini.");if(!n.ok)throw new Error("Gagal mengirim keluhan. Pastikan semua isian wajib terisi.");const i=await n.json();if(typeof i.number!="number"||typeof i.statusPath!="string")throw new Error("Gagal mengirim keluhan. Silakan coba lagi.");return i},async status(e,a){const n=await fetch(C.helpStatus(e,a));if(!n.ok)throw new Error("Tiket tidak ditemukan.");return n.json()}},dd=3;function hR(e){const a=e.replace(/^\/+|\/+$/g,"").split("/");return a[0]!=="help"||!a[1]?null:a[2]==="status"&&a[3]?{slug:decodeURIComponent(a[1]),key:decodeURIComponent(a[3])}:{slug:decodeURIComponent(a[1])}}function os({children:e}){return t.jsx("div",{"data-testid":"public-help-scroll",className:"hn-dynamic-viewport hn-public",style:{height:"100dvh",minHeight:0,overflowY:"auto",overscrollBehavior:"contain",boxSizing:"border-box",background:"var(--bone-100)",padding:"max(40px, var(--safe-top)) max(16px, var(--safe-right)) max(40px, var(--safe-bottom)) max(16px, var(--safe-left))"},children:t.jsx("div",{className:"hn-public-page",children:e})})}function pR({slug:e,statusKey:a}){const[n,i]=d.useState(null),[r,s]=d.useState("loading"),o=d.useCallback(()=>{s("loading"),sc.status(e,a).then(l=>{i(l),s("ready")}).catch(()=>s("error"))},[e,a]);return d.useEffect(()=>{o()},[o]),t.jsx(os,{children:t.jsx(Sa,{eyebrow:"status keluhan",title:n?`Tiket #${n.number}`:"Status tiket",children:r==="loading"?t.jsx(he,{kind:"loading"}):r==="error"||!n?t.jsx(he,{kind:"error",title:"Status belum bisa dimuat",hint:"Periksa kembali link status Anda, lalu coba lagi.",action:o,actionLabel:"Coba lagi"}):t.jsxs("div",{className:"hn-public-form",children:[t.jsx("div",{children:t.jsx(ht,{status:Gd(n.status),size:"sm",children:n.status})}),t.jsx(Kd,{status:n.status}),t.jsx(db,{status:n.status}),t.jsxs("dl",{className:"hn-public-status-dl",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Kategori"}),t.jsx("dd",{children:js(n.category)})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Judul"}),t.jsx("dd",{children:n.title})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Dilaporkan"}),t.jsx("dd",{children:new Date(n.createdAt).toLocaleString("id-ID")})]})]})]})})})}function gR({slug:e}){const[a,n]=d.useState(null),[i,r]=d.useState("loading"),[s,o]=d.useState("bug"),[l,c]=d.useState(""),[u,m]=d.useState(""),[h,p]=d.useState(""),[g,f]=d.useState(""),[b,v]=d.useState([]),[x,y]=d.useState(!1),[T,S]=d.useState(null),[E,w]=d.useState(null),[N,R]=d.useState(!1),L=d.useCallback(()=>{r("loading"),sc.getInfo(e).then(O=>{n(O),o(O.categories[0]??"bug"),r("ready")}).catch(()=>r("error"))},[e]);d.useEffect(()=>{L()},[L]);const[I,B]=d.useState("");function A(O){O.preventDefault();const J=I.trim().split("/").pop()??I.trim();J&&(window.location.href=`/help/${encodeURIComponent(e)}/status/${encodeURIComponent(J)}`)}const M=async O=>{if(!navigator.clipboard){S("Salin tidak tersedia di browser ini. Pilih linknya lalu salin manual.");return}try{await navigator.clipboard.writeText(O),R(!0),window.setTimeout(()=>R(!1),2e3)}catch(J){S(or(J,"Link belum bisa disalin. Pilih linknya lalu salin manual."))}};async function K(O){O.preventDefault(),S(null),y(!0);try{const J=new FormData;J.set("category",s),J.set("title",l),J.set("detail",u),J.set("email",h),J.set("hc_trap",g);for(const te of b.slice(0,dd))J.append("files",te,te.name);const Z=await sc.submit(e,J),H=`${window.location.origin}${Z.statusPath}`;w({number:Z.number,statusUrl:H})}catch(J){S(or(J,"Keluhan belum terkirim. Coba lagi sebentar."))}finally{y(!1)}}return i==="loading"?t.jsx(os,{children:t.jsx(he,{kind:"loading"})}):i==="error"||!a?t.jsx(os,{children:t.jsx(Sa,{title:"Help Center",children:t.jsx(he,{kind:"error",title:"Belum bisa dibuka",hint:"Coba lagi sebentar. Jika tetap gagal, Help Center untuk project ini mungkin tidak aktif.",action:L,actionLabel:"Coba lagi"})})}):E?t.jsx(os,{children:t.jsx(Sa,{eyebrow:"terkirim",title:`Terima kasih — tiket #${E.number}`,children:t.jsxs("div",{className:"hn-public-form",children:[t.jsx("p",{className:"hn-public-lead",children:"Keluhan Anda sudah kami terima. Simpan link berikut untuk memantau perkembangannya."}),t.jsxs("div",{className:"hn-public-linkbox",children:[t.jsx("code",{className:"hn-public-code",children:E.statusUrl}),t.jsxs("div",{className:"hn-public-actions",children:[t.jsx(q,{size:"sm",leftIcon:"copy",onClick:()=>void M(E.statusUrl),children:N?"Tersalin":"Salin link"}),t.jsx(q,{size:"sm",variant:"ghost",onClick:()=>window.location.assign(E.statusUrl),children:"Buka status"})]})]})]})})}):t.jsxs(os,{children:[t.jsx(Sa,{eyebrow:"help center",title:`Lapor keluhan · ${a.projectName}`,children:t.jsxs("form",{onSubmit:K,className:"hn-public-form",children:[t.jsxs("div",{className:"hn-public-field",children:[t.jsx("label",{htmlFor:"hc-cat",className:"hn-public-label",children:"Kategori"}),t.jsx($e,{id:"hc-cat",size:"lg",value:s,onChange:O=>o(O.target.value),options:a.categories.map(O=>({value:O,label:js(O)}))})]}),t.jsxs("div",{className:"hn-public-field",children:[t.jsx("label",{htmlFor:"hc-title",className:"hn-public-label",children:"Judul"}),t.jsx("input",{id:"hc-title",className:"hn-public-input",value:l,onChange:O=>c(O.target.value),required:!0,maxLength:200,placeholder:"mis. Tombol Simpan tidak berfungsi di HP"})]}),t.jsxs("div",{className:"hn-public-field",children:[t.jsx("label",{htmlFor:"hc-detail",className:"hn-public-label",children:"Detail"}),t.jsx("textarea",{id:"hc-detail",className:"hn-public-input",value:u,onChange:O=>m(O.target.value),required:!0,maxLength:1e4,rows:6,placeholder:"mis. Buka halaman Pesanan di HP, tekan Simpan — layar diam dan datanya tidak tersimpan. Jangan sertakan data sensitif (kata sandi, dsb)."})]}),t.jsxs("div",{className:"hn-public-field",children:[t.jsx("label",{htmlFor:"hc-email",className:"hn-public-label",children:"Email Anda"}),t.jsx("input",{id:"hc-email",className:"hn-public-input",type:"email",value:h,onChange:O=>p(O.target.value),required:!0,maxLength:200,placeholder:"nama@contoh.id"})]}),t.jsxs("div",{className:"hn-public-field",children:[t.jsxs("label",{htmlFor:"hc-files",className:"hn-public-label",children:["Lampiran gambar (opsional, maks ",dd,")"]}),t.jsxs("div",{className:"hn-public-file",children:[t.jsx("input",{id:"hc-files",className:"hn-public-file-input",type:"file",accept:"image/png,image/jpeg,image/webp",multiple:!0,onChange:O=>v(Array.from(O.target.files??[]).slice(0,dd))}),t.jsx("label",{htmlFor:"hc-files",className:"hn-public-file-btn","aria-hidden":"true",children:"Pilih berkas"}),t.jsx("span",{className:"hn-public-files","aria-live":"polite",children:b.length>0?b.map(O=>O.name).join(", "):"Belum ada berkas dipilih"})]})]}),t.jsx("input",{tabIndex:-1,autoComplete:"new-password","aria-hidden":!0,value:g,onChange:O=>f(O.target.value),name:"hc_trap",style:{position:"absolute",left:"-9999px",width:1,height:1}}),T&&t.jsx("p",{role:"alert",className:"hn-portal-error",children:T}),t.jsx("div",{className:"hn-portal-foot",children:t.jsx(q,{type:"submit",disabled:x,loading:x,leftIcon:"send",children:"Kirim keluhan"})})]})}),t.jsx(Sa,{eyebrow:"sudah pernah lapor?",title:"Cek status keluhan",children:t.jsxs("form",{onSubmit:A,className:"hn-public-check",children:[t.jsxs("div",{className:"hn-public-field",children:[t.jsx("label",{htmlFor:"hc-check",className:"hn-public-label",children:"Kode status atau link"}),t.jsx("input",{id:"hc-check",className:"hn-public-input",value:I,onChange:O=>B(O.target.value),placeholder:"mis. a1b2c3d4e5f6, atau tempel link statusnya"})]}),t.jsx(q,{type:"submit",variant:"secondary",disabled:!I.trim(),children:"Cek status"})]})})]})}function kR(){const e=hR(window.location.pathname);return e?e.key?t.jsx(pR,{slug:e.slug,statusKey:e.key}):t.jsx(gR,{slug:e.slug}):t.jsx(os,{children:t.jsx(Sa,{title:"Help Center",children:t.jsx(he,{kind:"error",title:"Halaman tidak ditemukan",hint:"Link Help Center tidak valid."})})})}const bR=window.location.pathname.startsWith("/help/");yp(document.getElementById("root")).render(t.jsx(d.StrictMode,{children:bR?t.jsx(kR,{}):t.jsx(uR,{})}));export{C as $,_A as A,q as B,bt as C,Dn as D,Cg as E,tk as F,EL as G,Ia as H,Re as I,Vc as J,Lk as K,bk as L,da as M,uL as N,rn as O,ms as P,zE as Q,Xt as R,Lc as S,Tg as T,tl as U,Wc as V,Nk as W,an as X,ht as Y,xr as Z,HL as _,mL as a,AR as a$,C2 as a0,vt as a1,jr as a2,Tx as a3,ER as a4,TR as a5,bd as a6,eT as a7,XE as a8,nb as a9,NL as aA,S5 as aB,kn as aC,ur as aD,ou as aE,pI as aF,rk as aG,Sa as aH,vs as aI,ML as aJ,Wb as aK,Bo as aL,ll as aM,Gk as aN,Kk as aO,C5 as aP,ws as aQ,dL as aR,PL as aS,IL as aT,gL as aU,cL as aV,ps as aW,Mi as aX,kL as aY,bg as aZ,SR as a_,jv as aa,Yo as ab,Jo as ac,Vo as ad,Hg as ae,lL as af,ha as ag,oL as ah,wr as ai,sT as aj,Zc as ak,LL as al,Fc as am,aT as an,DL as ao,Ii as ap,_L as aq,AL as ar,xP as as,jP as at,TL as au,RL as av,wP as aw,Ah as ax,$L as ay,Ob as az,al as b,tb as b$,sx as b0,el as b1,QE as b2,ix as b3,_R as b4,pL as b5,Oc as b6,X2 as b7,eA as b8,hL as b9,ZR as bA,XR as bB,eL as bC,aL as bD,tL as bE,nL as bF,iL as bG,sL as bH,rL as bI,bL as bJ,hv as bK,tv as bL,ev as bM,By as bN,bc as bO,Tv as bP,Ay as bQ,Ev as bR,_v as bS,Tp as bT,Sv as bU,Qp as bV,ys as bW,Jp as bX,xv as bY,fn as bZ,ek as b_,wv as ba,vr as bb,SL as bc,yL as bd,vL as be,wL as bf,fL as bg,xL as bh,jL as bi,CL as bj,Rh as bk,Jt as bl,DR as bm,OR as bn,HR as bo,qR as bp,UR as bq,zR as br,FR as bs,GR as bt,KR as bu,WR as bv,VR as bw,YR as bx,JR as by,QR as bz,_t as c,Mu as c0,t2 as c1,cc as c2,Ci as c3,Eg as c4,Tc as c5,qx as c6,Ox as c7,BR as c8,LR as c9,RR as ca,PR as cb,Hx as cc,MR as cd,NR as ce,IR as cf,CR as cg,wR as ch,nf as ci,hT as cj,OL as ck,N5 as cl,Fp as cm,jR as cn,hc as co,ZE as cp,lt as d,oe as e,Oe as f,$e as g,ne as h,ka as i,t as j,nc as k,Kn as l,he as m,oa as n,yr as o,mk as p,Ba as q,bi as r,ai as s,$R as t,c2 as u,xs as v,S2 as w,w2 as x,xI as y,Hc as z};
|