hanoman 0.9.0 → 0.9.2

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.0",
3
- "sha": "0a931198",
4
- "builtAt": "2026-09-20T03:31:13.694Z"
2
+ "version": "0.9.2",
3
+ "sha": "3a7265e1",
4
+ "builtAt": "2026-09-22T07:25:44.525Z"
5
5
  }
package/dist/server.js CHANGED
@@ -16293,7 +16293,8 @@ __export(config_exports, {
16293
16293
  rawDbValue: () => rawDbValue,
16294
16294
  setConfig: () => setConfig,
16295
16295
  setConfigsAtomic: () => setConfigsAtomic,
16296
- sourceOf: () => sourceOf
16296
+ sourceOf: () => sourceOf,
16297
+ suppressedInheritKeys: () => suppressedInheritKeys
16297
16298
  });
16298
16299
  async function loadConfig() {
16299
16300
  const rows = await prisma.runtimeConfig.findMany();
@@ -16315,6 +16316,9 @@ async function loadConfig() {
16315
16316
  function rawDbValue(key) {
16316
16317
  return cache.get(key);
16317
16318
  }
16319
+ function suppressedInheritKeys() {
16320
+ return CONFIG_REGISTRY.filter((e) => e.inheritEnv && cache.get(e.key) === "").map((e) => e.key);
16321
+ }
16318
16322
  function effectiveStr(key) {
16319
16323
  return cache.get(key) ?? process.env[key] ?? configEntry(key)?.default;
16320
16324
  }
@@ -17444,7 +17448,8 @@ function createSession(projectId, cwd, opts = {}) {
17444
17448
  }
17445
17449
  if (opts.attachmentsDir) envPairs.push(`HANOMAN_ATTACHMENTS_DIR=${sq(opts.attachmentsDir)}`);
17446
17450
  for (const [k, v] of Object.entries(opts.env ?? {})) envPairs.push(`${k}=${sq(v)}`);
17447
- let cmd = envPairs.length ? `${envPairs.join(" ")} ${argv}` : argv;
17451
+ const unsets = opts.command ? [] : suppressedInheritKeys().flatMap((k) => ["-u", k]);
17452
+ let cmd = unsets.length ? ["env", ...unsets, ...envPairs, argv].join(" ") : envPairs.length ? `${envPairs.join(" ")} ${argv}` : argv;
17448
17453
  if (!opts.command) {
17449
17454
  const wrapped = sandboxCommand({
17450
17455
  command: cmd,
@@ -27640,7 +27645,7 @@ function ensureSnapshot(key) {
27640
27645
  function mirrorInheritEnv(key) {
27641
27646
  ensureSnapshot(key);
27642
27647
  const v = rawDbValue(key) ?? ORIGINAL_ENV.get(key);
27643
- if (v === void 0) delete process.env[key];
27648
+ if (v === void 0 || v === "") delete process.env[key];
27644
27649
  else process.env[key] = v;
27645
27650
  }
27646
27651
  async function applyConfigSideEffect(key) {
@@ -41226,6 +41231,14 @@ async function reconcileHistory(liveSessionIds) {
41226
41231
  }
41227
41232
  return closed;
41228
41233
  }
41234
+ async function reconciledSpecIdsSince(cutoff) {
41235
+ const rows = await prisma.sessionHistory.findMany({
41236
+ where: { endedReason: RECONCILED, reconciledAt: { gte: cutoff }, specId: { not: null } },
41237
+ select: { specId: true },
41238
+ distinct: ["specId"]
41239
+ });
41240
+ return rows.map((r) => r.specId);
41241
+ }
41229
41242
  function installSessionHistory() {
41230
41243
  registerSessionHooks({
41231
41244
  onBirth: (b) => {
@@ -41933,7 +41946,7 @@ function buildResumeCtx(repoDir, id2, flow2, worktreeKept) {
41933
41946
  }
41934
41947
  async function startSpecSession(spec, opts) {
41935
41948
  const id2 = sessionIdForSpec(spec.id);
41936
- return withSessionAdmission({ id: id2, force: opts.force }, async () => {
41949
+ return withSessionAdmission({ id: id2, force: opts.force || opts.bypassCapacity }, async () => {
41937
41950
  const pane = await getSessionAsync(id2);
41938
41951
  if (!pane) {
41939
41952
  const view13 = await presenceView();
@@ -44791,7 +44804,8 @@ async function terminal_default(app3, opts) {
44791
44804
  return;
44792
44805
  }
44793
44806
  void refreshPhaseInvocations(id2);
44794
- })().catch(() => {
44807
+ })().catch((err) => {
44808
+ req.log.error({ err, sessionId: id2 }, "attach terminal gagal");
44795
44809
  socket2.close(1011, "attach failed");
44796
44810
  });
44797
44811
  const watch = isClientRemote ? null : createPrincipalWatch({
@@ -48303,7 +48317,8 @@ async function config_default(app3) {
48303
48317
  if (!entry) return reply.code(400).send({ error: "key tak dikenal" });
48304
48318
  if (entry.category === "bootstrap") return reply.code(400).send({ error: "bootstrap read-only" });
48305
48319
  if (agentBlocked(req, entry)) return reply.code(403).send({ error: "cookie session required" });
48306
- await clearConfig(key);
48320
+ if (entry.inheritEnv) await setConfig(key, "");
48321
+ else await clearConfig(key);
48307
48322
  await applyConfigSideEffect(key);
48308
48323
  return reply.code(204).send();
48309
48324
  });
@@ -52762,6 +52777,28 @@ function buildApp({ requireAuth = true, agentDocFile, env = process.env } = {})
52762
52777
  return app3;
52763
52778
  }
52764
52779
 
52780
+ // src/services/graceful-shutdown.ts
52781
+ var DEFAULT_TIMEOUT_MS = 5e3;
52782
+ function createShutdown(o) {
52783
+ const log = o.log ?? ((m) => console.log(m));
52784
+ let running;
52785
+ return (sig) => running ??= (async () => {
52786
+ log(`${sig} \u2014 menutup`);
52787
+ const timer10 = setTimeout(() => {
52788
+ log(`penutupan melewati ${o.timeoutMs ?? DEFAULT_TIMEOUT_MS} ms \u2014 keluar paksa`);
52789
+ o.exit(1);
52790
+ }, o.timeoutMs ?? DEFAULT_TIMEOUT_MS);
52791
+ timer10.unref?.();
52792
+ try {
52793
+ await o.close();
52794
+ } catch (e) {
52795
+ log(`penutupan gagal: ${e.message}`);
52796
+ }
52797
+ clearTimeout(timer10);
52798
+ o.exit(0);
52799
+ })();
52800
+ }
52801
+
52765
52802
  // src/server.ts
52766
52803
  init_db();
52767
52804
 
@@ -53117,6 +53154,36 @@ function registerTriaseSource() {
53117
53154
  registerSchedulerSource({ id: "triase", check: checkTriase });
53118
53155
  }
53119
53156
 
53157
+ // src/services/session-boot-resume.ts
53158
+ init_src();
53159
+ init_db();
53160
+ init_notifications2();
53161
+ var prodDeps2 = {
53162
+ // ADR-0169 · `bypassCapacity: true` — SATU-SATUNYA jalur yang melewati cap ADR-0161; gerbang
53163
+ // dependency ADR-0093 TETAP berlaku (tak diberi `force`). Keputusan sadar risiko: mesin 8 GB
53164
+ // operator sudah pernah kernel panic akibat sesi paralel berlebih (memori
53165
+ // mac-mini-8gb-panic-agen-paralel) — operator memilih "semua kembali" di atas throttle.
53166
+ startSpec: (spec) => startSpecSession(spec, { flow: flowForSource(spec.source), bypassCapacity: true }),
53167
+ recordFail: recordFailure
53168
+ };
53169
+ async function resumeReconciledSessions(cutoff, deps = prodDeps2) {
53170
+ const report = { resumed: [], failed: [] };
53171
+ const specIds = await reconciledSpecIdsSince(cutoff);
53172
+ if (!specIds.length) return report;
53173
+ const specs = await prisma.spec.findMany({ where: { id: { in: specIds }, stage: { not: "done" } } });
53174
+ for (const spec of specs) {
53175
+ try {
53176
+ await deps.startSpec(spec);
53177
+ report.resumed.push(spec.id);
53178
+ } catch (e) {
53179
+ const reason = e instanceof Error ? e.message : String(e);
53180
+ await deps.recordFail(spec.id, spec.title, spec.projectId, `gagal dilanjutkan otomatis \u2014 ${reason}`);
53181
+ report.failed.push(spec.id);
53182
+ }
53183
+ }
53184
+ return report;
53185
+ }
53186
+
53120
53187
  // src/server.ts
53121
53188
  init_event_log();
53122
53189
  init_settings3();
@@ -53832,15 +53899,13 @@ app2.addHook("onClose", async () => {
53832
53899
  });
53833
53900
  process.on("unhandledRejection", (err) => console.error("unhandledRejection:", err));
53834
53901
  process.on("uncaughtException", (err) => console.error("uncaughtException:", err));
53835
- async function shutdown(sig) {
53836
- console.log(`${sig} \u2014 menutup`);
53837
- try {
53902
+ var shutdown = createShutdown({
53903
+ close: async () => {
53838
53904
  await app2.close();
53839
53905
  await prisma.$disconnect();
53840
- } finally {
53841
- process.exit(0);
53842
- }
53843
- }
53906
+ },
53907
+ exit: (code) => process.exit(code)
53908
+ });
53844
53909
  process.on("SIGTERM", () => void shutdown("SIGTERM"));
53845
53910
  process.on("SIGINT", () => void shutdown("SIGINT"));
53846
53911
  var home2 = resolveHome();
@@ -53878,11 +53943,19 @@ bootstrapReady.then(async () => {
53878
53943
  if (bootSetting.logShipping.server) installConsoleTap();
53879
53944
  try {
53880
53945
  const liveIds = listSessions().map((s2) => s2.id);
53946
+ const reconcileCutoff = /* @__PURE__ */ new Date();
53881
53947
  void reconcileHistory(liveIds).then(async (n2) => {
53882
53948
  if (n2) console.log(`riwayat sesi: ${n2} baris berjalan direkonsiliasi`);
53883
53949
  for (const row of await detectOrphanWorktrees()) {
53884
53950
  console.log(`worktree yatim: ${row.projectId} \u2014 ${row.count} menunggu konfirmasi di tab Worktrees`);
53885
53951
  }
53952
+ if (n2) {
53953
+ const { resumed, failed } = await resumeReconciledSessions(reconcileCutoff);
53954
+ if (resumed.length)
53955
+ console.log(`auto-resume: ${resumed.length} sesi dilanjutkan otomatis (${resumed.join(", ")})`);
53956
+ if (failed.length)
53957
+ console.log(`auto-resume: ${failed.length} sesi gagal dilanjutkan otomatis, lihat notifikasi (${failed.join(", ")})`);
53958
+ }
53886
53959
  }).catch((e) => console.error("rekonsiliasi riwayat sesi:", e));
53887
53960
  void reconcileAgentInvocations(liveIds).then((n2) => {
53888
53961
  if (n2) console.log(`custom agent: ${n2} invocation ditandai abandoned`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanoman",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Orchestrator + dashboard workflow docs-driven untuk sesi Claude Code / Codex",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1 +1 @@
1
- import{e as C,j as a,ao as P,a as y,c as b,d as w,S as H,N as V,ay as q,h as F,u as K,f as M,w as N,aw as O,A as _,aL as U,y as Q,x as Y,p as Z,B as G,D as J}from"./index-DqFaLJVc.js";import{R as n}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";const X=[{mode:"backlog",label:"Rentang tanggal",hint:"backlog yang selesai di rentang itu"},{mode:"commit",label:"Rentang commit",hint:"perubahan repo antara dua revisi"},{mode:"version",label:"Versi rilis",hint:"perubahan yang masuk ke sebuah versi"}];function ee({p:t,onToast:o,onGenerated:g}){const[i,D]=n.useState("backlog"),[s,I]=n.useState(null),[h,f]=n.useState(""),[p,d]=n.useState(""),[x,B]=n.useState(""),[v,c]=n.useState(""),[j,u]=n.useState(""),[S,l]=n.useState(""),[m,R]=n.useState(!1);n.useEffect(()=>{let e=!0;return(async()=>{try{const r=await C.changelogSources(t.id);if(!e)return;I(r),f(r.defaultRange.from),d(r.defaultRange.to),r.tags[0]&&l(r.tags[0]),r.head&&c(r.head)}catch{}})(),()=>{e=!1}},[t.id]);const T=()=>i==="backlog"?{mode:i,from:h||void 0,to:p||void 0}:i==="commit"?{mode:i,fromSha:x,toSha:v}:{mode:i,fromTag:j||void 0,toTag:S},k=i==="backlog"?!0:i==="commit"?x.trim().length>=4&&v.trim().length>=4:S.trim().length>0;async function L(){R(!0);try{const e=await C.generateChangelog(t.id,T());o(e.generator==="agent"?"Changelog dibangkitkan":"Changelog dibangkitkan (draf ringkas)",e.generator==="agent"?"ok":"warn","file-text"),g==null||g(e)}catch(e){o(e.message||"Gagal membangkitkan changelog","err","x-circle")}finally{R(!1)}}const E=i==="version"&&s!==null&&s.tags.length===0,z=i==="commit"&&s!==null&&!!s.reason&&s.tags.length===0;return a.jsxs(P,{eyebrow:"changelog",title:"Ringkasan perubahan untuk pemakai",children:[a.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:"Teks pendek berorientasi pemakai — apa yang berubah bagi mereka, bukan apa yang disentuh di dalam kode."}),a.jsx("div",{style:{display:"flex",gap:6,marginBottom:12,flexWrap:"wrap"},children:X.map(e=>a.jsx(y,{size:"sm",variant:i===e.mode?"primary":"ghost",onClick:()=>D(e.mode),title:e.hint,children:e.label},e.mode))}),a.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-end",flexWrap:"wrap",marginBottom:12},children:[i==="backlog"&&a.jsxs(a.Fragment,{children:[a.jsx(b,{label:"Dari tanggal",children:a.jsx(w,{"aria-label":"Dari tanggal",type:"date",value:h,onChange:e=>f(e.target.value)})}),a.jsx(b,{label:"Sampai tanggal",children:a.jsx(w,{"aria-label":"Sampai tanggal",type:"date",value:p,onChange:e=>d(e.target.value)})})]}),i==="commit"&&a.jsxs(a.Fragment,{children:[a.jsx(b,{label:"Dari revisi",children:a.jsx(w,{"aria-label":"Dari revisi",mono:!0,placeholder:"mis. v1.0.0 atau 4f2a1c9",value:x,onChange:e=>B(e.target.value)})}),a.jsx(b,{label:"Sampai revisi",children:a.jsx(w,{"aria-label":"Sampai revisi",mono:!0,placeholder:"mis. HEAD atau 9d3b77e",value:v,onChange:e=>c(e.target.value)})})]}),i==="version"&&a.jsxs(a.Fragment,{children:[a.jsx(b,{label:"Sejak versi",children:a.jsx(H,{"aria-label":"Sejak versi",value:j,onChange:e=>u(e.target.value),options:[{value:"",label:"versi sebelumnya"},...((s==null?void 0:s.tags)??[]).map(e=>({value:e,label:e}))]})}),a.jsx(b,{label:"Versi",children:a.jsx(H,{"aria-label":"Versi",value:S,onChange:e=>l(e.target.value),options:((s==null?void 0:s.tags)??[]).map(e=>({value:e,label:e}))})})]}),a.jsx(y,{leftIcon:"sparkles",onClick:()=>void L(),disabled:m||!k||E||z,children:m?"Membangkitkan…":"Bangkitkan"})]}),(E||z)&&a.jsx(V,{tone:"warn",children:s==null?void 0:s.reason})]})}const $=12,W={backlog:"rentang tanggal",commit:"rentang commit",version:"versi rilis"},ae=t=>new Date(t).toLocaleDateString("id-ID",{day:"numeric",month:"short",year:"numeric"});function te({c:t,active:o,onOpen:g}){return a.jsxs("div",{role:"button",tabIndex:0,onClick:g,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),g())},style:{display:"flex",alignItems:"center",gap:10,padding:"9px 10px",cursor:"pointer",borderRadius:"var(--radius-sm)",borderBottom:"1px solid var(--border-hair)",background:o?"var(--brass-100)":"transparent"},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:13.5,fontWeight:500,color:"var(--text-strong)"},children:t.title}),a.jsxs("div",{style:{fontSize:11.5,color:"var(--text-subtle)",marginTop:2},children:[W[t.mode]??t.mode," · ",ae(t.createdAt)," · ",t.itemCount," perubahan"]})]}),a.jsx(G,{tone:t.generator==="agent"?"ok":"warn",size:"sm",children:t.generator==="agent"?"naratif":"draf ringkas"})]})}function re({p:t,onToast:o,initialChangelogId:g}){const[i,D]=n.useState([]),[s,I]=n.useState(0),h=q("changelog",t.id),[f,p]=F(h,"page",1,Y),[d,x]=F(h,"q","",Z),[B,v]=n.useState(!0),[c,j]=F(h,"selectedId",null,Q),[u,S]=n.useState(null),l=n.useMemo(()=>i.find(e=>e.id===c)??((u==null?void 0:u.id)===c?u:null),[i,c,u]),m=n.useCallback(e=>{j(e?e.id:null),S(e)},[j]),[R,T]=n.useState(0);n.useEffect(()=>{let e=!0;const r=setTimeout(()=>{v(!0),C.listChangelogs(t.id,{q:d,page:f,limit:$}).then(A=>{e&&(D(A.items),I(A.total))}).catch(()=>{e&&(D([]),I(0))}).finally(()=>{e&&v(!1)})},d?220:0);return()=>{e=!1,clearTimeout(r)}},[t.id,d,f,R]),n.useEffect(()=>{if(!g)return;let e=!0;return C.getChangelog(t.id,g).then(r=>{e&&m(r)}).catch(()=>{e&&o("Rilis yang ditautkan tak ditemukan","warn","link-2-off")}),()=>{e=!1}},[t.id,g,o]);const k=J(s,f,$),{confirm:L,dialog:E}=K();async function z(e){try{if(!await L({title:`Hapus changelog "${e.title}"?`,message:"Rilis ini hilang dari riwayat project.",confirmLabel:"Hapus rilis",run:()=>C.deleteChangelog(t.id,e.id)}))return;c===e.id&&m(null),T(r=>r+1),o("Changelog dihapus","ok","trash-2")}catch{o("Gagal menghapus changelog","err","x-circle")}}return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[a.jsx(ee,{p:t,onToast:o,onGenerated:e=>{m(e),p(1),T(r=>r+1)}}),a.jsxs(P,{eyebrow:"rilis",title:"Riwayat changelog",actions:a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11.5,color:"var(--text-subtle)"},children:[s," rilis"]}),children:[a.jsx(w,{"aria-label":"Cari rilis",leftIcon:"search",placeholder:"cari judul atau isi rilis…",value:d,style:{width:"100%"},onChange:e=>{p(1),x(e.target.value)}}),a.jsxs("div",{"data-testid":"changelog-list",style:{maxHeight:340,overflowY:"auto",marginTop:10},children:[B&&i.length===0&&a.jsx(M,{kind:"loading",compact:!0}),!B&&i.length===0&&(d.trim()?a.jsx(M,{kind:"empty",icon:"search",compact:!0,title:"Tak ada rilis yang cocok",hint:`Tak ada rilis yang memuat “${d.trim()}”.`,action:()=>x(""),actionLabel:"Bersihkan pencarian",actionIcon:"x"}):a.jsx(M,{kind:"empty",icon:"megaphone",compact:!0,title:"Belum ada rilis",hint:"Bangkitkan changelog pertama project ini lewat kartu di atas."})),i.map(e=>a.jsx(te,{c:e,active:(l==null?void 0:l.id)===e.id,onOpen:()=>m(e)},e.id))]}),a.jsx(N,{page:k.page,pageCount:k.pageCount,total:s,from:k.from,to:k.to,onPage:p,unit:"rilis"})]}),l&&a.jsxs(P,{eyebrow:`rilis · ${W[l.mode]??l.mode}`,title:l.title,actions:a.jsxs("div",{className:"hn-row-actions",style:{display:"flex",gap:6},children:[a.jsx(y,{size:"sm",variant:"ghost",leftIcon:"copy",onClick:()=>{var e;(e=navigator.clipboard)==null||e.writeText(l.body),o("Changelog disalin","ok","copy")},children:"Salin"}),a.jsx(y,{as:"a",size:"sm",variant:"ghost",leftIcon:"download",download:!0,href:`${_.changelogItem(t.id,l.id)}?download=md`,"aria-label":"Unduh .md",children:"Unduh .md"}),a.jsx(y,{size:"sm",variant:"ghost",leftIcon:"link",onClick:()=>{var e;(e=navigator.clipboard)==null||e.writeText(U(t.id,l.id)),o("Link changelog disalin","ok","link")},children:"Salin link"}),a.jsx(y,{size:"sm",variant:"ghost",leftIcon:"trash-2","aria-label":`Hapus ${l.title}`,onClick:()=>void z(l)})]}),children:[l.warning&&a.jsx(V,{tone:"warn",children:l.warning}),a.jsx(O,{text:l.body,name:"changelog.md"})]}),E]})}export{re as ChangelogScreen};
1
+ import{e as C,j as a,ao as P,a as y,c as b,d as w,S as H,N as V,ay as q,h as F,u as K,f as M,w as N,aw as O,A as _,aL as U,y as Q,x as Y,p as Z,B as G,D as J}from"./index-Cl9u81Cr.js";import{R as n}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";const X=[{mode:"backlog",label:"Rentang tanggal",hint:"backlog yang selesai di rentang itu"},{mode:"commit",label:"Rentang commit",hint:"perubahan repo antara dua revisi"},{mode:"version",label:"Versi rilis",hint:"perubahan yang masuk ke sebuah versi"}];function ee({p:t,onToast:o,onGenerated:g}){const[i,D]=n.useState("backlog"),[s,I]=n.useState(null),[h,f]=n.useState(""),[p,d]=n.useState(""),[x,B]=n.useState(""),[v,c]=n.useState(""),[j,u]=n.useState(""),[S,l]=n.useState(""),[m,R]=n.useState(!1);n.useEffect(()=>{let e=!0;return(async()=>{try{const r=await C.changelogSources(t.id);if(!e)return;I(r),f(r.defaultRange.from),d(r.defaultRange.to),r.tags[0]&&l(r.tags[0]),r.head&&c(r.head)}catch{}})(),()=>{e=!1}},[t.id]);const T=()=>i==="backlog"?{mode:i,from:h||void 0,to:p||void 0}:i==="commit"?{mode:i,fromSha:x,toSha:v}:{mode:i,fromTag:j||void 0,toTag:S},k=i==="backlog"?!0:i==="commit"?x.trim().length>=4&&v.trim().length>=4:S.trim().length>0;async function L(){R(!0);try{const e=await C.generateChangelog(t.id,T());o(e.generator==="agent"?"Changelog dibangkitkan":"Changelog dibangkitkan (draf ringkas)",e.generator==="agent"?"ok":"warn","file-text"),g==null||g(e)}catch(e){o(e.message||"Gagal membangkitkan changelog","err","x-circle")}finally{R(!1)}}const E=i==="version"&&s!==null&&s.tags.length===0,z=i==="commit"&&s!==null&&!!s.reason&&s.tags.length===0;return a.jsxs(P,{eyebrow:"changelog",title:"Ringkasan perubahan untuk pemakai",children:[a.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginBottom:12,lineHeight:1.5},children:"Teks pendek berorientasi pemakai — apa yang berubah bagi mereka, bukan apa yang disentuh di dalam kode."}),a.jsx("div",{style:{display:"flex",gap:6,marginBottom:12,flexWrap:"wrap"},children:X.map(e=>a.jsx(y,{size:"sm",variant:i===e.mode?"primary":"ghost",onClick:()=>D(e.mode),title:e.hint,children:e.label},e.mode))}),a.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-end",flexWrap:"wrap",marginBottom:12},children:[i==="backlog"&&a.jsxs(a.Fragment,{children:[a.jsx(b,{label:"Dari tanggal",children:a.jsx(w,{"aria-label":"Dari tanggal",type:"date",value:h,onChange:e=>f(e.target.value)})}),a.jsx(b,{label:"Sampai tanggal",children:a.jsx(w,{"aria-label":"Sampai tanggal",type:"date",value:p,onChange:e=>d(e.target.value)})})]}),i==="commit"&&a.jsxs(a.Fragment,{children:[a.jsx(b,{label:"Dari revisi",children:a.jsx(w,{"aria-label":"Dari revisi",mono:!0,placeholder:"mis. v1.0.0 atau 4f2a1c9",value:x,onChange:e=>B(e.target.value)})}),a.jsx(b,{label:"Sampai revisi",children:a.jsx(w,{"aria-label":"Sampai revisi",mono:!0,placeholder:"mis. HEAD atau 9d3b77e",value:v,onChange:e=>c(e.target.value)})})]}),i==="version"&&a.jsxs(a.Fragment,{children:[a.jsx(b,{label:"Sejak versi",children:a.jsx(H,{"aria-label":"Sejak versi",value:j,onChange:e=>u(e.target.value),options:[{value:"",label:"versi sebelumnya"},...((s==null?void 0:s.tags)??[]).map(e=>({value:e,label:e}))]})}),a.jsx(b,{label:"Versi",children:a.jsx(H,{"aria-label":"Versi",value:S,onChange:e=>l(e.target.value),options:((s==null?void 0:s.tags)??[]).map(e=>({value:e,label:e}))})})]}),a.jsx(y,{leftIcon:"sparkles",onClick:()=>void L(),disabled:m||!k||E||z,children:m?"Membangkitkan…":"Bangkitkan"})]}),(E||z)&&a.jsx(V,{tone:"warn",children:s==null?void 0:s.reason})]})}const $=12,W={backlog:"rentang tanggal",commit:"rentang commit",version:"versi rilis"},ae=t=>new Date(t).toLocaleDateString("id-ID",{day:"numeric",month:"short",year:"numeric"});function te({c:t,active:o,onOpen:g}){return a.jsxs("div",{role:"button",tabIndex:0,onClick:g,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),g())},style:{display:"flex",alignItems:"center",gap:10,padding:"9px 10px",cursor:"pointer",borderRadius:"var(--radius-sm)",borderBottom:"1px solid var(--border-hair)",background:o?"var(--brass-100)":"transparent"},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:13.5,fontWeight:500,color:"var(--text-strong)"},children:t.title}),a.jsxs("div",{style:{fontSize:11.5,color:"var(--text-subtle)",marginTop:2},children:[W[t.mode]??t.mode," · ",ae(t.createdAt)," · ",t.itemCount," perubahan"]})]}),a.jsx(G,{tone:t.generator==="agent"?"ok":"warn",size:"sm",children:t.generator==="agent"?"naratif":"draf ringkas"})]})}function re({p:t,onToast:o,initialChangelogId:g}){const[i,D]=n.useState([]),[s,I]=n.useState(0),h=q("changelog",t.id),[f,p]=F(h,"page",1,Y),[d,x]=F(h,"q","",Z),[B,v]=n.useState(!0),[c,j]=F(h,"selectedId",null,Q),[u,S]=n.useState(null),l=n.useMemo(()=>i.find(e=>e.id===c)??((u==null?void 0:u.id)===c?u:null),[i,c,u]),m=n.useCallback(e=>{j(e?e.id:null),S(e)},[j]),[R,T]=n.useState(0);n.useEffect(()=>{let e=!0;const r=setTimeout(()=>{v(!0),C.listChangelogs(t.id,{q:d,page:f,limit:$}).then(A=>{e&&(D(A.items),I(A.total))}).catch(()=>{e&&(D([]),I(0))}).finally(()=>{e&&v(!1)})},d?220:0);return()=>{e=!1,clearTimeout(r)}},[t.id,d,f,R]),n.useEffect(()=>{if(!g)return;let e=!0;return C.getChangelog(t.id,g).then(r=>{e&&m(r)}).catch(()=>{e&&o("Rilis yang ditautkan tak ditemukan","warn","link-2-off")}),()=>{e=!1}},[t.id,g,o]);const k=J(s,f,$),{confirm:L,dialog:E}=K();async function z(e){try{if(!await L({title:`Hapus changelog "${e.title}"?`,message:"Rilis ini hilang dari riwayat project.",confirmLabel:"Hapus rilis",run:()=>C.deleteChangelog(t.id,e.id)}))return;c===e.id&&m(null),T(r=>r+1),o("Changelog dihapus","ok","trash-2")}catch{o("Gagal menghapus changelog","err","x-circle")}}return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[a.jsx(ee,{p:t,onToast:o,onGenerated:e=>{m(e),p(1),T(r=>r+1)}}),a.jsxs(P,{eyebrow:"rilis",title:"Riwayat changelog",actions:a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11.5,color:"var(--text-subtle)"},children:[s," rilis"]}),children:[a.jsx(w,{"aria-label":"Cari rilis",leftIcon:"search",placeholder:"cari judul atau isi rilis…",value:d,style:{width:"100%"},onChange:e=>{p(1),x(e.target.value)}}),a.jsxs("div",{"data-testid":"changelog-list",style:{maxHeight:340,overflowY:"auto",marginTop:10},children:[B&&i.length===0&&a.jsx(M,{kind:"loading",compact:!0}),!B&&i.length===0&&(d.trim()?a.jsx(M,{kind:"empty",icon:"search",compact:!0,title:"Tak ada rilis yang cocok",hint:`Tak ada rilis yang memuat “${d.trim()}”.`,action:()=>x(""),actionLabel:"Bersihkan pencarian",actionIcon:"x"}):a.jsx(M,{kind:"empty",icon:"megaphone",compact:!0,title:"Belum ada rilis",hint:"Bangkitkan changelog pertama project ini lewat kartu di atas."})),i.map(e=>a.jsx(te,{c:e,active:(l==null?void 0:l.id)===e.id,onOpen:()=>m(e)},e.id))]}),a.jsx(N,{page:k.page,pageCount:k.pageCount,total:s,from:k.from,to:k.to,onPage:p,unit:"rilis"})]}),l&&a.jsxs(P,{eyebrow:`rilis · ${W[l.mode]??l.mode}`,title:l.title,actions:a.jsxs("div",{className:"hn-row-actions",style:{display:"flex",gap:6},children:[a.jsx(y,{size:"sm",variant:"ghost",leftIcon:"copy",onClick:()=>{var e;(e=navigator.clipboard)==null||e.writeText(l.body),o("Changelog disalin","ok","copy")},children:"Salin"}),a.jsx(y,{as:"a",size:"sm",variant:"ghost",leftIcon:"download",download:!0,href:`${_.changelogItem(t.id,l.id)}?download=md`,"aria-label":"Unduh .md",children:"Unduh .md"}),a.jsx(y,{size:"sm",variant:"ghost",leftIcon:"link",onClick:()=>{var e;(e=navigator.clipboard)==null||e.writeText(U(t.id,l.id)),o("Link changelog disalin","ok","link")},children:"Salin link"}),a.jsx(y,{size:"sm",variant:"ghost",leftIcon:"trash-2","aria-label":`Hapus ${l.title}`,onClick:()=>void z(l)})]}),children:[l.warning&&a.jsx(V,{tone:"warn",children:l.warning}),a.jsx(O,{text:l.body,name:"changelog.md"})]}),E]})}export{re as ChangelogScreen};
@@ -1 +1 @@
1
- import{i as ie,j as e,b as re,I as E}from"./index-DqFaLJVc.js";import{R as g}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";const de="/assets/hnm-hero-rig-body-v01-DmbKJJHB.webp",ce="/assets/hnm-hero-rig-arm-ul-v01-CIAWAxFe.webp",he="/assets/hnm-hero-rig-arm-ur-v01-C0R0CZnp.webp",oe="/assets/hnm-hero-rig-arm-ml-v01-Kts3pjTf.webp",ge="/assets/hnm-hero-rig-arm-mr-v01-DQgnE6bD.webp",me="/assets/hnm-wayang-satria-alus-v01-CpfoXKTy.webp",ue="/assets/hnm-wayang-satria-gagah-v01-bLfIYAsv.webp",pe="/assets/hnm-wayang-putri-v01-F6p69kHq.webp",xe="/assets/hnm-wayang-panakawan-v01-1LGv-V8N.webp",q=[me,ue,pe,xe],z=a=>q[[...a].reduce((t,o)=>t+o.charCodeAt(0),0)%q.length],V=["Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des"],C=a=>String(a).padStart(2,"0");function je(){return g.useMemo(()=>typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function Ne(){const[a,t]=g.useState(()=>new Date);return g.useEffect(()=>{const o=setInterval(()=>t(new Date),1e3);return()=>clearInterval(o)},[]),a}function ye(a,t){const[o,m]=g.useState(""),p=a.join("|");return g.useEffect(()=>{if(t||a.length===0){m(a[0]??"");return}let x=0,h=0,r=null,d=null;const l=()=>{const y=a[x%a.length]??"";h=0,r=setInterval(()=>{h++,m(y.slice(0,h)),h>=y.length&&r&&(clearInterval(r),r=null,d=setTimeout(()=>{x++,l()},3200))},26)};return l(),()=>{r&&clearInterval(r),d&&clearTimeout(d)}},[p,t]),o}function S(a,t){const[o,m]=g.useState(t?a:0);return g.useEffect(()=>{if(t){m(a);return}const p=performance.now(),x=900;let h=0;const r=d=>{const l=Math.min(1,(d-p)/x);m(Math.round(a*(1-Math.pow(1-l,3)))),l<1&&(h=requestAnimationFrame(r))};return h=requestAnimationFrame(r),()=>cancelAnimationFrame(h)},[a,t]),o}function M({icon:a,tone:t,label:o,value:m,sub:p}){return e.jsxs("div",{className:"hn-dlg-kpi",children:[e.jsx("span",{className:`hn-dlg-kpi-ic hn-dlg-tone-${t}`,children:e.jsx(E,{name:a,size:17})}),e.jsxs("span",{style:{minWidth:0},children:[e.jsx("span",{className:"hn-dlg-kpi-l",children:o}),e.jsx("span",{className:"hn-dlg-kpi-v",children:m}),e.jsx("span",{className:"hn-dlg-kpi-s",children:p})]})]})}function ke({projects:a,backlog:t,sessions:o,onOpenSession:m,onOpenProject:p,onGoto:x,onExit:h}){const r=je(),d=Ne();g.useEffect(()=>{const n=s=>{s.key==="Escape"&&h()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[h]);const l=o.filter(n=>!n.exited).sort((n,s)=>n.id.localeCompare(s.id)),y=new Set(l.map(n=>n.projectId)),f=a.filter(n=>!y.has(n.id)),R=l.filter(n=>!!n.decision&&!n.deciding).length,F=t.filter(n=>ie(n.startedAt)).length,Q=S(a.length,r),X=S(F,r),Z=S(l.length,r),_=S(R,r),ee=ye([l.length>0?`HANOMAN ONLINE · ${l.length} SESI HIDUP`:"HANOMAN ONLINE · KELIR SUNYI",`${F} TASK DIKERJAKAN HARI INI`,R>0?`${R} SESI MENUNGGU JAWABANMU`:"SEMUA SISTEM NORMAL",`${a.length} PROYEK DALAM PANTAUAN`],r),j={done:0,executing:0,planned:0,spec:0};for(const n of t)n.stage==="done"?j.done++:n.stage==="executing"?j.executing++:n.stage==="planned"?j.planned++:j.spec++;const D=t.length,ne=[{key:"executing",cls:"wind",label:"Execute"},{key:"done",cls:"leaf",label:"Done"},{key:"planned",cls:"amber",label:"Plan"},{key:"spec",cls:"brass",label:"Spec"}];let L=0;const O=ne.map(n=>{const s=D?j[n.key]/D*100:0,u={...n,n:j[n.key],frac:s,offset:25-L};return L+=s,u}),v=[];for(let n=6;n>=0;n--){const s=new Date(d.getFullYear(),d.getMonth(),d.getDate()-n),u=t.filter(i=>{if(!i.startedAt)return!1;const c=new Date(i.startedAt);return c.getFullYear()===s.getFullYear()&&c.getMonth()===s.getMonth()&&c.getDate()===s.getDate()}).length;v.push({label:`${s.getDate()} ${V[s.getMonth()]}`,n:u})}const $=Math.max(1,...v.map(n=>n.n)),se=v.map((n,s)=>`${32+s*35},${78-n.n/$*60}`).join(" "),ae=`${l.map(n=>n.id).join("|")}#${f.map(n=>n.id).join("|")}`,H=g.useRef(null),[P,W]=g.useState([]);g.useLayoutEffect(()=>{const n=H.current;if(!n||l.length===0&&f.length===0){W([]);return}const s=()=>{var J;const i=n.getBoundingClientRect();if(i.width<60)return;const c=(J=n.querySelector(".hn-dlg-hero-art"))==null?void 0:J.getBoundingClientRect(),b=c?c.left+c.width/2-i.left:i.width/2,w={};n.querySelectorAll("[data-hand]").forEach(N=>{const A=N.getBoundingClientRect();w[N.dataset.hand??""]={x:A.left+A.width/2-i.left,y:A.top+A.height/2-i.top}});const k={x:b,y:c?c.top-i.top+c.height*.36:i.height*.35},G=[];n.querySelectorAll(".hn-dlg-prj").forEach(N=>{const U=(N.querySelector(".hn-dlg-puppet img")??N).getBoundingClientRect(),T=U.left+U.width/2-i.left,K=U.top-i.top+1,B=!N.hasAttribute("data-puppet"),te=T<b?"l":"r",I=w[(B?"m":"u")+te]??k,le=B?Math.max(I.y,K)+26:Math.min(I.y,K)-16;G.push({d:`M ${I.x.toFixed(1)} ${I.y.toFixed(1)} Q ${((I.x+T)/2).toFixed(1)} ${le.toFixed(1)}, ${T.toFixed(1)} ${K.toFixed(1)}`,slack:B})}),W(G)};if(s(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(s);return u.observe(n),()=>u.disconnect()},[ae,l.length,f.length]);const Y=a.slice(0,6).map(n=>({id:n.id,name:n.name,text:n.activity,commit:n.commit,live:y.has(n.id)}));return e.jsxs("div",{className:"hn-dlg",children:[e.jsxs("div",{className:"hn-dlg-top hn-wrap-mobile",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[e.jsx("img",{className:"hn-dlg-blencong",src:re,alt:"","aria-hidden":"true","data-lit":l.length>0||void 0}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("h2",{className:"hn-dlg-title",children:"Dalang Hanoman"}),e.jsx("p",{className:"hn-dlg-boot","aria-live":"off",children:ee})]})]}),e.jsxs("div",{className:"hn-dlg-chips",children:[e.jsxs("span",{className:"hn-dlg-chip",children:[e.jsx(E,{name:"calendar",size:13}),d.getDate()," ",V[d.getMonth()]," ",d.getFullYear()]}),e.jsxs("span",{className:"hn-dlg-chip",children:[e.jsx(E,{name:"clock",size:13}),C(d.getHours()),":",C(d.getMinutes()),":",C(d.getSeconds())]}),e.jsx("button",{type:"button",className:"hn-dlg-exit",onClick:h,"aria-label":"Keluar dari panggung (Esc)",children:e.jsx(E,{name:"x",size:14})})]})]}),e.jsxs("div",{className:"hn-dlg-kpis",children:[e.jsx(M,{icon:"layout-grid",tone:"wind",label:"TOTAL PROYEK",value:Q,sub:"dalam pantauan"}),e.jsx(M,{icon:"check-circle-2",tone:"leaf",label:"TASK HARI INI",value:X,sub:"mulai dikerjakan"}),e.jsx(M,{icon:"activity",tone:"brass",label:"SESI BERJALAN",value:Z,sub:"wayang dimainkan"}),e.jsx(M,{icon:"hand",tone:"amber",label:"MENUNGGU KAMU",value:_,sub:"butuh keputusan"})]}),e.jsxs("div",{className:"hn-dlg-grid hn-grid-mobile",children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{className:"hn-dlg-hero",ref:H,children:[e.jsxs("svg",{className:"hn-dlg-hud",viewBox:"0 0 330 330","aria-hidden":"true",children:[e.jsx("g",{className:"hn-dlg-hud-a",children:e.jsx("circle",{cx:"165",cy:"165",r:"150",strokeDasharray:"3 14"})}),e.jsx("g",{className:"hn-dlg-hud-b",children:e.jsx("circle",{cx:"165",cy:"165",r:"126",strokeDasharray:"40 22"})})]}),P.length>0&&e.jsx("svg",{className:"hn-dlg-threads","aria-hidden":"true",focusable:"false",children:P.map((n,s)=>e.jsx("path",{d:n.d,className:n.slack?"hn-dlg-thread--slack":void 0,style:n.slack?void 0:{animationDelay:`${s%6*.3}s`}},s))}),e.jsx("div",{className:"hn-dlg-scan","aria-hidden":"true"}),e.jsxs("div",{className:"hn-dlg-hero-art","aria-hidden":"true",children:[e.jsx("img",{className:"hn-dlg-rig-arm hn-dlg-rig-arm--ul",src:ce,alt:""}),e.jsx("img",{className:"hn-dlg-rig-arm hn-dlg-rig-arm--ur",src:he,alt:""}),e.jsx("img",{className:"hn-dlg-rig-arm hn-dlg-rig-arm--ml",src:oe,alt:""}),e.jsx("img",{className:"hn-dlg-rig-arm hn-dlg-rig-arm--mr",src:ge,alt:""}),e.jsx("img",{className:"hn-dlg-rig-body",src:de,alt:""}),e.jsx("span",{className:"hn-dlg-hand","data-hand":"ul"}),e.jsx("span",{className:"hn-dlg-hand","data-hand":"ur"}),e.jsx("span",{className:"hn-dlg-hand","data-hand":"ml"}),e.jsx("span",{className:"hn-dlg-hand","data-hand":"mr"})]}),l.length>0||f.length>0?e.jsxs("div",{className:"hn-dlg-cards",role:"list","aria-label":"Wayang project",children:[l.map((n,s)=>{var w;const u=((w=a.find(k=>k.id===n.projectId))==null?void 0:w.name)??n.projectId,i=n.specId?t.find(k=>k.id===n.specId):void 0,c=!!n.decision&&!n.deciding,b=c?"menunggu jawabanmu":i?`${i.id} · ${i.stage}`:n.flow??"sesi terminal";return e.jsxs("button",{type:"button",className:"hn-dlg-prj","data-puppet":!0,"data-waiting":c||void 0,onClick:()=>m(n.id),"aria-label":`Buka terminal — ${u}, ${b}`,children:[e.jsx("span",{className:c?"hn-dlg-puppet hn-dlg-puppet--still":"hn-dlg-puppet",style:{animationDelay:`${s%6*.6}s`},children:e.jsx("img",{src:z(n.projectId),alt:"","aria-hidden":"true"})}),e.jsx("span",{className:"hn-dlg-prj-name",children:u}),e.jsx("span",{className:c?"hn-dlg-prj-sub hn-dlg-prj-sub--amber":"hn-dlg-prj-sub",children:b})]},n.id)}),f.map(n=>e.jsxs("button",{type:"button",className:"hn-dlg-prj hn-dlg-prj--off",onClick:()=>p(n),"aria-label":`Buka project ${n.name}`,children:[e.jsx("span",{className:"hn-dlg-puppet hn-dlg-puppet--still",children:e.jsx("img",{src:z(n.id),alt:"","aria-hidden":"true"})}),e.jsx("span",{className:"hn-dlg-prj-name",children:n.name}),e.jsx("span",{className:"hn-dlg-prj-sub hn-dlg-prj-sub--off",children:"tersandar di debog"})]},n.id))]}):e.jsxs("div",{className:"hn-dlg-empty",children:[e.jsx("div",{children:"Panggung sunyi — belum ada project di workspace."}),e.jsx("div",{children:"Tambahkan project dan sang dalang mengangkat wayangnya."})]})]}),e.jsxs("button",{type:"button",className:"hn-dlg-cmd",onClick:()=>x("terminal"),"aria-label":"Buka terminal — pusat kendali sesi",children:[e.jsx("span",{className:"hn-dlg-mic","aria-hidden":"true"}),e.jsxs("span",{className:"hn-dlg-cmd-t",children:[e.jsx("b",{children:"Perintah dalang"})," — buka Terminal untuk mengarahkan sesi yang berjalan…"]}),e.jsx("span",{className:"hn-dlg-cmd-k",children:"Terminal"})]})]}),e.jsxs("aside",{className:"hn-dlg-rail",children:[e.jsxs("div",{className:"hn-dlg-card",children:[e.jsx("div",{className:"hn-dlg-rt",children:"AKTIVITAS TERAKHIR"}),Y.length===0?e.jsx("div",{className:"hn-dlg-mut",children:"Belum ada project."}):Y.map(n=>e.jsxs("div",{className:"hn-dlg-act",children:[e.jsx("span",{className:n.live?"hn-dlg-dot hn-dlg-dot--on":"hn-dlg-dot"}),e.jsxs("span",{className:"hn-dlg-act-x",children:[e.jsx("b",{children:n.name})," ",n.text]})]},n.id))]}),e.jsxs("div",{className:"hn-dlg-card",children:[e.jsx("div",{className:"hn-dlg-rt",children:"DISTRIBUSI BACKLOG"}),e.jsxs("div",{className:"hn-dlg-donut-wrap",children:[e.jsxs("div",{className:"hn-dlg-donut",children:[e.jsxs("svg",{viewBox:"0 0 42 42",width:"112",height:"112","aria-hidden":"true",children:[e.jsx("circle",{className:"hn-dlg-ring",cx:"21",cy:"21",r:"15.9",strokeWidth:"5"}),O.map(n=>n.frac>0&&e.jsx("circle",{className:`hn-dlg-seg hn-dlg-seg--${n.cls}`,cx:"21",cy:"21",r:"15.9",strokeWidth:"5",strokeDasharray:`${n.frac} ${100-n.frac}`,strokeDashoffset:n.offset},n.key))]}),e.jsxs("div",{className:"hn-dlg-donut-c",children:[e.jsx("b",{children:D}),e.jsx("span",{children:"backlog"})]})]}),e.jsx("div",{className:"hn-dlg-leg",children:O.map(n=>e.jsxs("span",{children:[e.jsx("i",{className:`hn-dlg-seg--${n.cls}`}),n.label," ",e.jsx("b",{children:n.n})]},n.key))})]})]}),e.jsxs("div",{className:"hn-dlg-card",children:[e.jsx("div",{className:"hn-dlg-rt",children:"DIMULAI · 7 HARI"}),e.jsxs("svg",{viewBox:"0 0 260 100",className:"hn-dlg-chart","aria-hidden":"true",children:[e.jsx("line",{x1:"24",y1:"18",x2:"252",y2:"18"}),e.jsx("line",{x1:"24",y1:"48",x2:"252",y2:"48"}),e.jsx("line",{x1:"24",y1:"78",x2:"252",y2:"78"}),e.jsx("text",{x:"8",y:"21",children:$}),e.jsx("text",{x:"10",y:"81",children:"0"}),e.jsx("polyline",{className:"hn-dlg-trend",points:se}),v.map((n,s)=>e.jsx("circle",{cx:32+s*35,cy:78-n.n/$*60,r:"2.4"},s)),v.map((n,s)=>s%2===0?e.jsx("text",{x:22+s*35,y:"94",children:n.label},`l${s}`):null)]})]})]})]}),e.jsx("div",{className:"hn-dlg-foot",children:"◈  HANOMAN · ORKESTRASI CERDAS · EKSEKUSI SEMPURNA  ◈"})]})}export{ke as DalangHanomanScreen};
1
+ import{i as ie,j as e,b as re,I as E}from"./index-Cl9u81Cr.js";import{R as g}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";const de="/assets/hnm-hero-rig-body-v01-DmbKJJHB.webp",ce="/assets/hnm-hero-rig-arm-ul-v01-CIAWAxFe.webp",he="/assets/hnm-hero-rig-arm-ur-v01-C0R0CZnp.webp",oe="/assets/hnm-hero-rig-arm-ml-v01-Kts3pjTf.webp",ge="/assets/hnm-hero-rig-arm-mr-v01-DQgnE6bD.webp",me="/assets/hnm-wayang-satria-alus-v01-CpfoXKTy.webp",ue="/assets/hnm-wayang-satria-gagah-v01-bLfIYAsv.webp",pe="/assets/hnm-wayang-putri-v01-F6p69kHq.webp",xe="/assets/hnm-wayang-panakawan-v01-1LGv-V8N.webp",q=[me,ue,pe,xe],z=a=>q[[...a].reduce((t,o)=>t+o.charCodeAt(0),0)%q.length],V=["Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des"],C=a=>String(a).padStart(2,"0");function je(){return g.useMemo(()=>typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function Ne(){const[a,t]=g.useState(()=>new Date);return g.useEffect(()=>{const o=setInterval(()=>t(new Date),1e3);return()=>clearInterval(o)},[]),a}function ye(a,t){const[o,m]=g.useState(""),p=a.join("|");return g.useEffect(()=>{if(t||a.length===0){m(a[0]??"");return}let x=0,h=0,r=null,d=null;const l=()=>{const y=a[x%a.length]??"";h=0,r=setInterval(()=>{h++,m(y.slice(0,h)),h>=y.length&&r&&(clearInterval(r),r=null,d=setTimeout(()=>{x++,l()},3200))},26)};return l(),()=>{r&&clearInterval(r),d&&clearTimeout(d)}},[p,t]),o}function S(a,t){const[o,m]=g.useState(t?a:0);return g.useEffect(()=>{if(t){m(a);return}const p=performance.now(),x=900;let h=0;const r=d=>{const l=Math.min(1,(d-p)/x);m(Math.round(a*(1-Math.pow(1-l,3)))),l<1&&(h=requestAnimationFrame(r))};return h=requestAnimationFrame(r),()=>cancelAnimationFrame(h)},[a,t]),o}function M({icon:a,tone:t,label:o,value:m,sub:p}){return e.jsxs("div",{className:"hn-dlg-kpi",children:[e.jsx("span",{className:`hn-dlg-kpi-ic hn-dlg-tone-${t}`,children:e.jsx(E,{name:a,size:17})}),e.jsxs("span",{style:{minWidth:0},children:[e.jsx("span",{className:"hn-dlg-kpi-l",children:o}),e.jsx("span",{className:"hn-dlg-kpi-v",children:m}),e.jsx("span",{className:"hn-dlg-kpi-s",children:p})]})]})}function ke({projects:a,backlog:t,sessions:o,onOpenSession:m,onOpenProject:p,onGoto:x,onExit:h}){const r=je(),d=Ne();g.useEffect(()=>{const n=s=>{s.key==="Escape"&&h()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[h]);const l=o.filter(n=>!n.exited).sort((n,s)=>n.id.localeCompare(s.id)),y=new Set(l.map(n=>n.projectId)),f=a.filter(n=>!y.has(n.id)),R=l.filter(n=>!!n.decision&&!n.deciding).length,F=t.filter(n=>ie(n.startedAt)).length,Q=S(a.length,r),X=S(F,r),Z=S(l.length,r),_=S(R,r),ee=ye([l.length>0?`HANOMAN ONLINE · ${l.length} SESI HIDUP`:"HANOMAN ONLINE · KELIR SUNYI",`${F} TASK DIKERJAKAN HARI INI`,R>0?`${R} SESI MENUNGGU JAWABANMU`:"SEMUA SISTEM NORMAL",`${a.length} PROYEK DALAM PANTAUAN`],r),j={done:0,executing:0,planned:0,spec:0};for(const n of t)n.stage==="done"?j.done++:n.stage==="executing"?j.executing++:n.stage==="planned"?j.planned++:j.spec++;const D=t.length,ne=[{key:"executing",cls:"wind",label:"Execute"},{key:"done",cls:"leaf",label:"Done"},{key:"planned",cls:"amber",label:"Plan"},{key:"spec",cls:"brass",label:"Spec"}];let L=0;const O=ne.map(n=>{const s=D?j[n.key]/D*100:0,u={...n,n:j[n.key],frac:s,offset:25-L};return L+=s,u}),v=[];for(let n=6;n>=0;n--){const s=new Date(d.getFullYear(),d.getMonth(),d.getDate()-n),u=t.filter(i=>{if(!i.startedAt)return!1;const c=new Date(i.startedAt);return c.getFullYear()===s.getFullYear()&&c.getMonth()===s.getMonth()&&c.getDate()===s.getDate()}).length;v.push({label:`${s.getDate()} ${V[s.getMonth()]}`,n:u})}const $=Math.max(1,...v.map(n=>n.n)),se=v.map((n,s)=>`${32+s*35},${78-n.n/$*60}`).join(" "),ae=`${l.map(n=>n.id).join("|")}#${f.map(n=>n.id).join("|")}`,H=g.useRef(null),[P,W]=g.useState([]);g.useLayoutEffect(()=>{const n=H.current;if(!n||l.length===0&&f.length===0){W([]);return}const s=()=>{var J;const i=n.getBoundingClientRect();if(i.width<60)return;const c=(J=n.querySelector(".hn-dlg-hero-art"))==null?void 0:J.getBoundingClientRect(),b=c?c.left+c.width/2-i.left:i.width/2,w={};n.querySelectorAll("[data-hand]").forEach(N=>{const A=N.getBoundingClientRect();w[N.dataset.hand??""]={x:A.left+A.width/2-i.left,y:A.top+A.height/2-i.top}});const k={x:b,y:c?c.top-i.top+c.height*.36:i.height*.35},G=[];n.querySelectorAll(".hn-dlg-prj").forEach(N=>{const U=(N.querySelector(".hn-dlg-puppet img")??N).getBoundingClientRect(),T=U.left+U.width/2-i.left,K=U.top-i.top+1,B=!N.hasAttribute("data-puppet"),te=T<b?"l":"r",I=w[(B?"m":"u")+te]??k,le=B?Math.max(I.y,K)+26:Math.min(I.y,K)-16;G.push({d:`M ${I.x.toFixed(1)} ${I.y.toFixed(1)} Q ${((I.x+T)/2).toFixed(1)} ${le.toFixed(1)}, ${T.toFixed(1)} ${K.toFixed(1)}`,slack:B})}),W(G)};if(s(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(s);return u.observe(n),()=>u.disconnect()},[ae,l.length,f.length]);const Y=a.slice(0,6).map(n=>({id:n.id,name:n.name,text:n.activity,commit:n.commit,live:y.has(n.id)}));return e.jsxs("div",{className:"hn-dlg",children:[e.jsxs("div",{className:"hn-dlg-top hn-wrap-mobile",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[e.jsx("img",{className:"hn-dlg-blencong",src:re,alt:"","aria-hidden":"true","data-lit":l.length>0||void 0}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("h2",{className:"hn-dlg-title",children:"Dalang Hanoman"}),e.jsx("p",{className:"hn-dlg-boot","aria-live":"off",children:ee})]})]}),e.jsxs("div",{className:"hn-dlg-chips",children:[e.jsxs("span",{className:"hn-dlg-chip",children:[e.jsx(E,{name:"calendar",size:13}),d.getDate()," ",V[d.getMonth()]," ",d.getFullYear()]}),e.jsxs("span",{className:"hn-dlg-chip",children:[e.jsx(E,{name:"clock",size:13}),C(d.getHours()),":",C(d.getMinutes()),":",C(d.getSeconds())]}),e.jsx("button",{type:"button",className:"hn-dlg-exit",onClick:h,"aria-label":"Keluar dari panggung (Esc)",children:e.jsx(E,{name:"x",size:14})})]})]}),e.jsxs("div",{className:"hn-dlg-kpis",children:[e.jsx(M,{icon:"layout-grid",tone:"wind",label:"TOTAL PROYEK",value:Q,sub:"dalam pantauan"}),e.jsx(M,{icon:"check-circle-2",tone:"leaf",label:"TASK HARI INI",value:X,sub:"mulai dikerjakan"}),e.jsx(M,{icon:"activity",tone:"brass",label:"SESI BERJALAN",value:Z,sub:"wayang dimainkan"}),e.jsx(M,{icon:"hand",tone:"amber",label:"MENUNGGU KAMU",value:_,sub:"butuh keputusan"})]}),e.jsxs("div",{className:"hn-dlg-grid hn-grid-mobile",children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{className:"hn-dlg-hero",ref:H,children:[e.jsxs("svg",{className:"hn-dlg-hud",viewBox:"0 0 330 330","aria-hidden":"true",children:[e.jsx("g",{className:"hn-dlg-hud-a",children:e.jsx("circle",{cx:"165",cy:"165",r:"150",strokeDasharray:"3 14"})}),e.jsx("g",{className:"hn-dlg-hud-b",children:e.jsx("circle",{cx:"165",cy:"165",r:"126",strokeDasharray:"40 22"})})]}),P.length>0&&e.jsx("svg",{className:"hn-dlg-threads","aria-hidden":"true",focusable:"false",children:P.map((n,s)=>e.jsx("path",{d:n.d,className:n.slack?"hn-dlg-thread--slack":void 0,style:n.slack?void 0:{animationDelay:`${s%6*.3}s`}},s))}),e.jsx("div",{className:"hn-dlg-scan","aria-hidden":"true"}),e.jsxs("div",{className:"hn-dlg-hero-art","aria-hidden":"true",children:[e.jsx("img",{className:"hn-dlg-rig-arm hn-dlg-rig-arm--ul",src:ce,alt:""}),e.jsx("img",{className:"hn-dlg-rig-arm hn-dlg-rig-arm--ur",src:he,alt:""}),e.jsx("img",{className:"hn-dlg-rig-arm hn-dlg-rig-arm--ml",src:oe,alt:""}),e.jsx("img",{className:"hn-dlg-rig-arm hn-dlg-rig-arm--mr",src:ge,alt:""}),e.jsx("img",{className:"hn-dlg-rig-body",src:de,alt:""}),e.jsx("span",{className:"hn-dlg-hand","data-hand":"ul"}),e.jsx("span",{className:"hn-dlg-hand","data-hand":"ur"}),e.jsx("span",{className:"hn-dlg-hand","data-hand":"ml"}),e.jsx("span",{className:"hn-dlg-hand","data-hand":"mr"})]}),l.length>0||f.length>0?e.jsxs("div",{className:"hn-dlg-cards",role:"list","aria-label":"Wayang project",children:[l.map((n,s)=>{var w;const u=((w=a.find(k=>k.id===n.projectId))==null?void 0:w.name)??n.projectId,i=n.specId?t.find(k=>k.id===n.specId):void 0,c=!!n.decision&&!n.deciding,b=c?"menunggu jawabanmu":i?`${i.id} · ${i.stage}`:n.flow??"sesi terminal";return e.jsxs("button",{type:"button",className:"hn-dlg-prj","data-puppet":!0,"data-waiting":c||void 0,onClick:()=>m(n.id),"aria-label":`Buka terminal — ${u}, ${b}`,children:[e.jsx("span",{className:c?"hn-dlg-puppet hn-dlg-puppet--still":"hn-dlg-puppet",style:{animationDelay:`${s%6*.6}s`},children:e.jsx("img",{src:z(n.projectId),alt:"","aria-hidden":"true"})}),e.jsx("span",{className:"hn-dlg-prj-name",children:u}),e.jsx("span",{className:c?"hn-dlg-prj-sub hn-dlg-prj-sub--amber":"hn-dlg-prj-sub",children:b})]},n.id)}),f.map(n=>e.jsxs("button",{type:"button",className:"hn-dlg-prj hn-dlg-prj--off",onClick:()=>p(n),"aria-label":`Buka project ${n.name}`,children:[e.jsx("span",{className:"hn-dlg-puppet hn-dlg-puppet--still",children:e.jsx("img",{src:z(n.id),alt:"","aria-hidden":"true"})}),e.jsx("span",{className:"hn-dlg-prj-name",children:n.name}),e.jsx("span",{className:"hn-dlg-prj-sub hn-dlg-prj-sub--off",children:"tersandar di debog"})]},n.id))]}):e.jsxs("div",{className:"hn-dlg-empty",children:[e.jsx("div",{children:"Panggung sunyi — belum ada project di workspace."}),e.jsx("div",{children:"Tambahkan project dan sang dalang mengangkat wayangnya."})]})]}),e.jsxs("button",{type:"button",className:"hn-dlg-cmd",onClick:()=>x("terminal"),"aria-label":"Buka terminal — pusat kendali sesi",children:[e.jsx("span",{className:"hn-dlg-mic","aria-hidden":"true"}),e.jsxs("span",{className:"hn-dlg-cmd-t",children:[e.jsx("b",{children:"Perintah dalang"})," — buka Terminal untuk mengarahkan sesi yang berjalan…"]}),e.jsx("span",{className:"hn-dlg-cmd-k",children:"Terminal"})]})]}),e.jsxs("aside",{className:"hn-dlg-rail",children:[e.jsxs("div",{className:"hn-dlg-card",children:[e.jsx("div",{className:"hn-dlg-rt",children:"AKTIVITAS TERAKHIR"}),Y.length===0?e.jsx("div",{className:"hn-dlg-mut",children:"Belum ada project."}):Y.map(n=>e.jsxs("div",{className:"hn-dlg-act",children:[e.jsx("span",{className:n.live?"hn-dlg-dot hn-dlg-dot--on":"hn-dlg-dot"}),e.jsxs("span",{className:"hn-dlg-act-x",children:[e.jsx("b",{children:n.name})," ",n.text]})]},n.id))]}),e.jsxs("div",{className:"hn-dlg-card",children:[e.jsx("div",{className:"hn-dlg-rt",children:"DISTRIBUSI BACKLOG"}),e.jsxs("div",{className:"hn-dlg-donut-wrap",children:[e.jsxs("div",{className:"hn-dlg-donut",children:[e.jsxs("svg",{viewBox:"0 0 42 42",width:"112",height:"112","aria-hidden":"true",children:[e.jsx("circle",{className:"hn-dlg-ring",cx:"21",cy:"21",r:"15.9",strokeWidth:"5"}),O.map(n=>n.frac>0&&e.jsx("circle",{className:`hn-dlg-seg hn-dlg-seg--${n.cls}`,cx:"21",cy:"21",r:"15.9",strokeWidth:"5",strokeDasharray:`${n.frac} ${100-n.frac}`,strokeDashoffset:n.offset},n.key))]}),e.jsxs("div",{className:"hn-dlg-donut-c",children:[e.jsx("b",{children:D}),e.jsx("span",{children:"backlog"})]})]}),e.jsx("div",{className:"hn-dlg-leg",children:O.map(n=>e.jsxs("span",{children:[e.jsx("i",{className:`hn-dlg-seg--${n.cls}`}),n.label," ",e.jsx("b",{children:n.n})]},n.key))})]})]}),e.jsxs("div",{className:"hn-dlg-card",children:[e.jsx("div",{className:"hn-dlg-rt",children:"DIMULAI · 7 HARI"}),e.jsxs("svg",{viewBox:"0 0 260 100",className:"hn-dlg-chart","aria-hidden":"true",children:[e.jsx("line",{x1:"24",y1:"18",x2:"252",y2:"18"}),e.jsx("line",{x1:"24",y1:"48",x2:"252",y2:"48"}),e.jsx("line",{x1:"24",y1:"78",x2:"252",y2:"78"}),e.jsx("text",{x:"8",y:"21",children:$}),e.jsx("text",{x:"10",y:"81",children:"0"}),e.jsx("polyline",{className:"hn-dlg-trend",points:se}),v.map((n,s)=>e.jsx("circle",{cx:32+s*35,cy:78-n.n/$*60,r:"2.4"},s)),v.map((n,s)=>s%2===0?e.jsx("text",{x:22+s*35,y:"94",children:n.label},`l${s}`):null)]})]})]})]}),e.jsx("div",{className:"hn-dlg-foot",children:"◈  HANOMAN · ORKESTRASI CERDAS · EKSEKUSI SEMPURNA  ◈"})]})}export{ke as DalangHanomanScreen};
@@ -1 +1 @@
1
- import{j as e,M as r,au as d,aw as a,f as x}from"./index-DqFaLJVc.js";import"./react-DfGhg7ZW.js";function m({path:i,text:o,eyebrow:n,download:t,onClose:s}){const l=i.slice(i.lastIndexOf("/")+1)||i;return e.jsx(r,{open:!0,title:l,eyebrow:n??i,icon:"book-open",onClose:s,width:980,fillHeight:!0,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[t&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",paddingBottom:6,borderBottom:"1px solid var(--border-hair)",marginBottom:8},children:e.jsx(d,{href:t})}),e.jsx("div",{"data-testid":"doc-preview-scroll",style:{flex:"1 1 0",minHeight:0,overflow:"auto",padding:"0 4px 8px"},children:o?e.jsx(a,{text:o,name:i}):e.jsx(x,{kind:"empty",icon:"file-text",title:"Berkas kosong",hint:i})})]})})}export{m as D};
1
+ import{j as e,M as r,au as d,aw as a,f as x}from"./index-Cl9u81Cr.js";import"./react-DfGhg7ZW.js";function m({path:i,text:o,eyebrow:n,download:t,onClose:s}){const l=i.slice(i.lastIndexOf("/")+1)||i;return e.jsx(r,{open:!0,title:l,eyebrow:n??i,icon:"book-open",onClose:s,width:980,fillHeight:!0,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[t&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",paddingBottom:6,borderBottom:"1px solid var(--border-hair)",marginBottom:8},children:e.jsx(d,{href:t})}),e.jsx("div",{"data-testid":"doc-preview-scroll",style:{flex:"1 1 0",minHeight:0,overflow:"auto",padding:"0 4px 8px"},children:o?e.jsx(a,{text:o,name:i}):e.jsx(x,{kind:"empty",icon:"file-text",title:"Berkas kosong",hint:i})})]})})}export{m as D};
@@ -1,3 +1,3 @@
1
- import{h as re,u as oe,e as y,j as e,v as le,ao as T,ak as de,a as j,f as b,aK as ce,I as k,B as $,au as xe,aw as A,p as pe,ay as ue}from"./index-DqFaLJVc.js";import{R as l}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";function O(s){let a={...s,kids:s.kids.map(O)};for(;!a.cat&&a.kids.length===1;){const i=a.kids[0];a={...i,label:a.label+"/"+i.label}}return a}function G(s){const a={path:"",kids:[]};for(const i of s){if(i.cat==="."){a.kids.push({path:".",label:".",cat:i,kids:[]});continue}let r=a;for(const x of i.cat.split("/")){const g=r.path?r.path+"/"+x:x;let d=r.kids.find(t=>t.path===g);d||(d={path:g,label:x,kids:[]},r.kids.push(d)),r=d}r.cat=i}return a.kids.map(O)}function K(s){const a=s.find(i=>i.scored&&i.linked)??s.find(i=>i.scored)??s[0];return a&&a.files[0]?`${a.cat}/${a.files[0]}`:""}function I({node:s,selected:a,onSelect:i,depth:r=0}){var h,u,p;const[x,g]=l.useState(!1),d=((h=s.cat)==null?void 0:h.scored)??!0,t=((u=s.cat)==null?void 0:u.linked)??!0;return e.jsxs("div",{style:r===0?{borderBottom:"1px solid var(--border-hair)"}:void 0,children:[e.jsxs("button",{onClick:()=>g(c=>!c),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"9px 6px",paddingLeft:6+r*12,border:"none",background:"transparent",cursor:"pointer",textAlign:"left"},children:[e.jsx(k,{name:x?"chevron-down":"chevron-right",size:14,color:"var(--text-subtle)"}),e.jsx(k,{name:"folder",size:15,color:d?t?"var(--brass-500)":"var(--clay-500)":"var(--text-subtle)"}),e.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:12.5,color:"var(--text-strong)",fontWeight:500},children:[s.label,"/"]}),e.jsx("span",{style:{flex:1}}),s.cat&&d&&(s.cat.linked?e.jsx(k,{name:"link",size:13,color:"var(--leaf-600)"}):e.jsx(k,{name:"unlink",size:13,color:"var(--clay-500)"}))]}),x&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1,paddingBottom:4},children:[s.kids.map(c=>e.jsx(I,{node:c,selected:a,onSelect:i,depth:r+1},c.path)),(p=s.cat)==null?void 0:p.files.map(c=>{const f=s.path+"/"+c,v=f===a;return e.jsxs("button",{onClick:()=>i(f),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 8px",paddingLeft:18+r*12,borderRadius:"var(--radius-sm)",border:"none",cursor:"pointer",textAlign:"left",background:v?"var(--brass-100)":"transparent"},children:[e.jsx(k,{name:"file-text",size:13,color:v?"var(--brass-700)":"var(--text-subtle)"}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:v?"var(--brass-700)":!d||t?"var(--text-body)":"var(--text-muted)",fontWeight:v?600:400},children:c})]},c)})]})]})}function ve({projectId:s,projectName:a,docStatus:i}){const[r,x]=l.useState([]),[g,d]=l.useState(0),[t,h]=re(ue("docs",s),"selected","",pe),[u,p]=l.useState({}),[c,f]=l.useState("preview"),[v,F]=l.useState("tree"),[w,M]=l.useState(""),[S,P]=l.useState(!1),{confirm:J,dialog:U}=oe(),[H,z]=l.useState("loading"),[V,q]=l.useState(0);l.useEffect(()=>{let n=!0;return z("loading"),y.getDocs(s).then(o=>{if(!n)return;const m=o.tree;x(m),d(o.coverage),p({}),f("preview"),z("ready"),h(K(m))}).catch(()=>{n&&(x([]),h(""),z("error"))}),()=>{n=!1}},[s,V]),l.useEffect(()=>{if(!t||t in u)return;let n=!0;return y.getDoc(s,t).then(o=>{n&&p(m=>({...m,[t]:o.content}))}).catch(()=>{n&&p(o=>({...o,[t]:null}))}),()=>{n=!1}},[t,s,u]);const D=!!t&&!(t in u),C=t?u[t]===null:!1,Q=()=>p(n=>{const o={...n};return delete o[t],o}),X=l.useMemo(()=>G(r.filter(n=>n.scored)),[r]),L=l.useMemo(()=>G(r.filter(n=>!n.scored)),[r]),N=u[t]??"",Y=t.includes("/")?t.slice(0,t.lastIndexOf("/")):".",B=r.find(n=>n.cat===Y),Z=t,_=i==="broken"?"err":i==="drift"?"warn":"ok",ee=i==="broken"?"broken":i==="drift"?"drift":"ok";function te(){M(N),f("edit")}function ne(){f("preview")}async function se(){await y.putDoc(s,t,w),p(n=>({...n,[t]:w})),f("preview")}function E(n){h(n),f("preview"),F("viewer")}async function R(){const n=await y.getDocs(s),o=n.tree;x(o),d(n.coverage),o.some(m=>m.files.some(ie=>`${m.cat}/${ie}`===t))||h(K(o))}async function W(){if(!S){P(!0);try{await R()}finally{P(!1)}}}async function ae(){t&&await J({title:`Hapus ${t}?`,message:"Berkas aslinya di disk ikut dihapus — dokumen ini adalah Source of Truth project.",confirmLabel:"Hapus dokumen",run:()=>y.deleteDoc(s,t)})&&(p(n=>{const o={...n};return delete o[t],o}),await R())}return e.jsxs(e.Fragment,{children:[e.jsx(le,{ariaLabel:"Panel Docs",active:v,onActiveChange:n=>F(n),masterWidth:288,className:"hn-workspace-panels",panels:[{id:"tree",label:"Files",className:"hn-panel-flex",content:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16,minHeight:0,overflow:"auto"},children:[e.jsxs(T,{padding:0,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"12px 14px",borderBottom:"1px solid var(--border-hair)"},children:[e.jsxs("span",{className:"hn-eyebrow",children:["docs · ",a]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(de,{status:ee,size:"sm"}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:S?"loader":"radar",onClick:W,disabled:S,children:S?"…":"Muat ulang"})]})]}),e.jsx("div",{style:{padding:"4px 8px"},children:H==="loading"?e.jsx(b,{kind:"loading",compact:!0,title:"Memuat index…"}):H==="error"?e.jsx(b,{kind:"error",compact:!0,title:"Gagal memuat index docs",hint:a,action:()=>q(n=>n+1)}):r.length===0?e.jsx(b,{kind:"empty",compact:!0,icon:"folder-open",title:"Belum ada docs",hint:"Belum ada Markdown di repo ini.",action:W,actionLabel:"Muat ulang",actionIcon:"radar"}):e.jsxs(e.Fragment,{children:[X.map(n=>e.jsx(I,{node:n,selected:t,onSelect:E},n.path)),L.length>0&&e.jsxs("div",{style:{marginTop:8,paddingTop:8,borderTop:"1px solid var(--border-hair)"},children:[e.jsx("div",{className:"hn-eyebrow",style:{padding:"4px 6px",color:"var(--text-subtle)"},children:"Lainnya (tidak dinilai)"}),L.map(n=>e.jsx(I,{node:n,selected:t,onSelect:E},n.path))]})]})})]}),e.jsxs(T,{padding:16,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("span",{className:"hn-eyebrow",children:"SoT coverage"}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-muted)"},children:a})]}),e.jsx(ce,{value:g,showLabel:!0,label:"Kategori ter-index",tone:_})]})]})},{id:"viewer",label:"Dokumen",className:"hn-panel-flex",content:e.jsxs(T,{padding:0,fill:!0,children:[e.jsxs("div",{style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderBottom:"1px solid var(--border-hair)",flexWrap:"wrap"},children:[e.jsx(k,{name:"file-text",size:15,color:"var(--text-muted)"}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-strong)",fontWeight:500},children:Z}),B&&B.scored&&(B.linked?e.jsx($,{tone:"ok",size:"sm",icon:"link",children:"indexed"}):e.jsx($,{tone:"err",size:"sm",icon:"unlink",children:"unlinked"})),e.jsx("span",{style:{flex:1}}),c==="preview"?e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx(xe,{href:n=>y.docDownloadUrl(s,t,n),disabled:!t||D||C}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",onClick:ae,disabled:!t,children:"Hapus"}),e.jsx(j,{size:"sm",variant:"secondary",leftIcon:"pencil",onClick:te,disabled:!t||D||C,children:"Edit"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(j,{size:"sm",variant:"ghost",onClick:ne,children:"Batal"}),e.jsx(j,{size:"sm",leftIcon:"check",onClick:se,children:"Simpan"})]})]}),c==="preview"?e.jsx("div",{"data-testid":"doc-preview-scroll",style:{padding:"8px 30px 34px",flex:"1 1 auto",minHeight:0,overflow:"auto"},children:t?D?e.jsx(b,{kind:"loading",title:"Memuat dokumen…",hint:t}):C?e.jsx(b,{kind:"error",title:"Gagal memuat dokumen",hint:t,action:Q}):e.jsx(A,{text:N,name:t}):e.jsx(b,{kind:"empty",icon:"file-text",title:"Tidak ada dokumen dipilih",hint:"Pilih file dari pohon docs di kiri."})}):e.jsxs("div",{className:"hn-grid-mobile",style:{display:"grid",gridTemplateColumns:"1fr 1fr",flex:"1 1 auto",minHeight:0},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-hair)",minHeight:0},children:[e.jsx("div",{style:{padding:"8px 14px",borderBottom:"1px solid var(--border-hair)",background:"var(--bone-100)"},children:e.jsx("span",{className:"hn-eyebrow",children:"Markdown"})}),e.jsx("textarea",{value:w,onChange:n=>M(n.target.value),spellCheck:!1,placeholder:`# Judul dokumen
1
+ import{h as re,u as oe,e as y,j as e,v as le,ao as T,ak as de,a as j,f as b,aK as ce,I as k,B as $,au as xe,aw as A,p as pe,ay as ue}from"./index-Cl9u81Cr.js";import{R as l}from"./react-DfGhg7ZW.js";import"./markdown-CWEY34jk.js";import"./xterm-3VOAfa_q.js";function O(s){let a={...s,kids:s.kids.map(O)};for(;!a.cat&&a.kids.length===1;){const i=a.kids[0];a={...i,label:a.label+"/"+i.label}}return a}function G(s){const a={path:"",kids:[]};for(const i of s){if(i.cat==="."){a.kids.push({path:".",label:".",cat:i,kids:[]});continue}let r=a;for(const x of i.cat.split("/")){const g=r.path?r.path+"/"+x:x;let d=r.kids.find(t=>t.path===g);d||(d={path:g,label:x,kids:[]},r.kids.push(d)),r=d}r.cat=i}return a.kids.map(O)}function K(s){const a=s.find(i=>i.scored&&i.linked)??s.find(i=>i.scored)??s[0];return a&&a.files[0]?`${a.cat}/${a.files[0]}`:""}function I({node:s,selected:a,onSelect:i,depth:r=0}){var h,u,p;const[x,g]=l.useState(!1),d=((h=s.cat)==null?void 0:h.scored)??!0,t=((u=s.cat)==null?void 0:u.linked)??!0;return e.jsxs("div",{style:r===0?{borderBottom:"1px solid var(--border-hair)"}:void 0,children:[e.jsxs("button",{onClick:()=>g(c=>!c),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"9px 6px",paddingLeft:6+r*12,border:"none",background:"transparent",cursor:"pointer",textAlign:"left"},children:[e.jsx(k,{name:x?"chevron-down":"chevron-right",size:14,color:"var(--text-subtle)"}),e.jsx(k,{name:"folder",size:15,color:d?t?"var(--brass-500)":"var(--clay-500)":"var(--text-subtle)"}),e.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:12.5,color:"var(--text-strong)",fontWeight:500},children:[s.label,"/"]}),e.jsx("span",{style:{flex:1}}),s.cat&&d&&(s.cat.linked?e.jsx(k,{name:"link",size:13,color:"var(--leaf-600)"}):e.jsx(k,{name:"unlink",size:13,color:"var(--clay-500)"}))]}),x&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1,paddingBottom:4},children:[s.kids.map(c=>e.jsx(I,{node:c,selected:a,onSelect:i,depth:r+1},c.path)),(p=s.cat)==null?void 0:p.files.map(c=>{const f=s.path+"/"+c,v=f===a;return e.jsxs("button",{onClick:()=>i(f),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 8px",paddingLeft:18+r*12,borderRadius:"var(--radius-sm)",border:"none",cursor:"pointer",textAlign:"left",background:v?"var(--brass-100)":"transparent"},children:[e.jsx(k,{name:"file-text",size:13,color:v?"var(--brass-700)":"var(--text-subtle)"}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:v?"var(--brass-700)":!d||t?"var(--text-body)":"var(--text-muted)",fontWeight:v?600:400},children:c})]},c)})]})]})}function ve({projectId:s,projectName:a,docStatus:i}){const[r,x]=l.useState([]),[g,d]=l.useState(0),[t,h]=re(ue("docs",s),"selected","",pe),[u,p]=l.useState({}),[c,f]=l.useState("preview"),[v,F]=l.useState("tree"),[w,M]=l.useState(""),[S,P]=l.useState(!1),{confirm:J,dialog:U}=oe(),[H,z]=l.useState("loading"),[V,q]=l.useState(0);l.useEffect(()=>{let n=!0;return z("loading"),y.getDocs(s).then(o=>{if(!n)return;const m=o.tree;x(m),d(o.coverage),p({}),f("preview"),z("ready"),h(K(m))}).catch(()=>{n&&(x([]),h(""),z("error"))}),()=>{n=!1}},[s,V]),l.useEffect(()=>{if(!t||t in u)return;let n=!0;return y.getDoc(s,t).then(o=>{n&&p(m=>({...m,[t]:o.content}))}).catch(()=>{n&&p(o=>({...o,[t]:null}))}),()=>{n=!1}},[t,s,u]);const D=!!t&&!(t in u),C=t?u[t]===null:!1,Q=()=>p(n=>{const o={...n};return delete o[t],o}),X=l.useMemo(()=>G(r.filter(n=>n.scored)),[r]),L=l.useMemo(()=>G(r.filter(n=>!n.scored)),[r]),N=u[t]??"",Y=t.includes("/")?t.slice(0,t.lastIndexOf("/")):".",B=r.find(n=>n.cat===Y),Z=t,_=i==="broken"?"err":i==="drift"?"warn":"ok",ee=i==="broken"?"broken":i==="drift"?"drift":"ok";function te(){M(N),f("edit")}function ne(){f("preview")}async function se(){await y.putDoc(s,t,w),p(n=>({...n,[t]:w})),f("preview")}function E(n){h(n),f("preview"),F("viewer")}async function R(){const n=await y.getDocs(s),o=n.tree;x(o),d(n.coverage),o.some(m=>m.files.some(ie=>`${m.cat}/${ie}`===t))||h(K(o))}async function W(){if(!S){P(!0);try{await R()}finally{P(!1)}}}async function ae(){t&&await J({title:`Hapus ${t}?`,message:"Berkas aslinya di disk ikut dihapus — dokumen ini adalah Source of Truth project.",confirmLabel:"Hapus dokumen",run:()=>y.deleteDoc(s,t)})&&(p(n=>{const o={...n};return delete o[t],o}),await R())}return e.jsxs(e.Fragment,{children:[e.jsx(le,{ariaLabel:"Panel Docs",active:v,onActiveChange:n=>F(n),masterWidth:288,className:"hn-workspace-panels",panels:[{id:"tree",label:"Files",className:"hn-panel-flex",content:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16,minHeight:0,overflow:"auto"},children:[e.jsxs(T,{padding:0,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"12px 14px",borderBottom:"1px solid var(--border-hair)"},children:[e.jsxs("span",{className:"hn-eyebrow",children:["docs · ",a]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(de,{status:ee,size:"sm"}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:S?"loader":"radar",onClick:W,disabled:S,children:S?"…":"Muat ulang"})]})]}),e.jsx("div",{style:{padding:"4px 8px"},children:H==="loading"?e.jsx(b,{kind:"loading",compact:!0,title:"Memuat index…"}):H==="error"?e.jsx(b,{kind:"error",compact:!0,title:"Gagal memuat index docs",hint:a,action:()=>q(n=>n+1)}):r.length===0?e.jsx(b,{kind:"empty",compact:!0,icon:"folder-open",title:"Belum ada docs",hint:"Belum ada Markdown di repo ini.",action:W,actionLabel:"Muat ulang",actionIcon:"radar"}):e.jsxs(e.Fragment,{children:[X.map(n=>e.jsx(I,{node:n,selected:t,onSelect:E},n.path)),L.length>0&&e.jsxs("div",{style:{marginTop:8,paddingTop:8,borderTop:"1px solid var(--border-hair)"},children:[e.jsx("div",{className:"hn-eyebrow",style:{padding:"4px 6px",color:"var(--text-subtle)"},children:"Lainnya (tidak dinilai)"}),L.map(n=>e.jsx(I,{node:n,selected:t,onSelect:E},n.path))]})]})})]}),e.jsxs(T,{padding:16,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("span",{className:"hn-eyebrow",children:"SoT coverage"}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-muted)"},children:a})]}),e.jsx(ce,{value:g,showLabel:!0,label:"Kategori ter-index",tone:_})]})]})},{id:"viewer",label:"Dokumen",className:"hn-panel-flex",content:e.jsxs(T,{padding:0,fill:!0,children:[e.jsxs("div",{style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderBottom:"1px solid var(--border-hair)",flexWrap:"wrap"},children:[e.jsx(k,{name:"file-text",size:15,color:"var(--text-muted)"}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-strong)",fontWeight:500},children:Z}),B&&B.scored&&(B.linked?e.jsx($,{tone:"ok",size:"sm",icon:"link",children:"indexed"}):e.jsx($,{tone:"err",size:"sm",icon:"unlink",children:"unlinked"})),e.jsx("span",{style:{flex:1}}),c==="preview"?e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx(xe,{href:n=>y.docDownloadUrl(s,t,n),disabled:!t||D||C}),e.jsx(j,{size:"sm",variant:"ghost",leftIcon:"trash-2",onClick:ae,disabled:!t,children:"Hapus"}),e.jsx(j,{size:"sm",variant:"secondary",leftIcon:"pencil",onClick:te,disabled:!t||D||C,children:"Edit"})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(j,{size:"sm",variant:"ghost",onClick:ne,children:"Batal"}),e.jsx(j,{size:"sm",leftIcon:"check",onClick:se,children:"Simpan"})]})]}),c==="preview"?e.jsx("div",{"data-testid":"doc-preview-scroll",style:{padding:"8px 30px 34px",flex:"1 1 auto",minHeight:0,overflow:"auto"},children:t?D?e.jsx(b,{kind:"loading",title:"Memuat dokumen…",hint:t}):C?e.jsx(b,{kind:"error",title:"Gagal memuat dokumen",hint:t,action:Q}):e.jsx(A,{text:N,name:t}):e.jsx(b,{kind:"empty",icon:"file-text",title:"Tidak ada dokumen dipilih",hint:"Pilih file dari pohon docs di kiri."})}):e.jsxs("div",{className:"hn-grid-mobile",style:{display:"grid",gridTemplateColumns:"1fr 1fr",flex:"1 1 auto",minHeight:0},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-hair)",minHeight:0},children:[e.jsx("div",{style:{padding:"8px 14px",borderBottom:"1px solid var(--border-hair)",background:"var(--bone-100)"},children:e.jsx("span",{className:"hn-eyebrow",children:"Markdown"})}),e.jsx("textarea",{value:w,onChange:n=>M(n.target.value),spellCheck:!1,placeholder:`# Judul dokumen
2
2
 
3
3
  Paragraf pembuka…`,style:{flex:1,width:"100%",boxSizing:"border-box",resize:"none",border:"none",outline:"none",padding:"16px 18px",fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.7,color:"var(--text-body)",background:"var(--surface-card)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",minHeight:0},children:[e.jsx("div",{style:{padding:"8px 14px",borderBottom:"1px solid var(--border-hair)",background:"var(--bone-100)"},children:e.jsx("span",{className:"hn-eyebrow",children:"Preview langsung"})}),e.jsx("div",{style:{flex:1,overflow:"auto",padding:"4px 24px 24px"},children:e.jsx(A,{text:w,name:t})})]})]})]})}]}),U]})}export{ve as DocsWorkspace,G as buildTree,K as firstDoc};