forge-openclaw-plugin 0.3.5 → 0.3.8
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/assets/{action-bar-DBZ38L_6.js → action-bar-BFjWjRIM.js} +1 -1
- package/dist/assets/{activity-page-BJxUR9bD.js → activity-page-D-6yBWuZ.js} +1 -1
- package/dist/assets/{ai-surface-workspace-ehzBjTsW.js → ai-surface-workspace-BEfo9bRO.js} +1 -1
- package/dist/assets/{atlas-panel-BFUeVT69.js → atlas-panel-BfMyJXxQ.js} +1 -1
- package/dist/assets/{board-CLOHbg6t.js → board-CuxQRKPJ.js} +1 -1
- package/dist/assets/{calendar-page-Bg8W-YQ-.js → calendar-page-D4tQNJ2V.js} +1 -1
- package/dist/assets/{calendar-rules-9XQLoI96.js → calendar-rules-C-6O_uGU.js} +1 -1
- package/dist/assets/{calendar-week-toolbar-BeYnx1pE.js → calendar-week-toolbar-_NzeKsYx.js} +1 -1
- package/dist/assets/{charts-DwTguE_x.js → charts-BzT4pUPg.js} +1 -1
- package/dist/assets/{companion-sync-lab-page-BRKYkIrs.js → companion-sync-lab-page-D1Oqsf6M.js} +1 -1
- package/dist/assets/{daily-metrics-dashboard-Jt0nAHU5.js → daily-metrics-dashboard-DtE3pVOl.js} +1 -1
- package/dist/assets/date-keys-BnZV4PNO.js +1 -0
- package/dist/assets/{define-workbench-box-5h-dyvJY.js → define-workbench-box-D-32C8nM.js} +1 -1
- package/dist/assets/{entity-link-multiselect-Bb4De_e3.js → entity-link-multiselect-DcCvkesQ.js} +1 -1
- package/dist/assets/{entity-note-count-link-BzWnsOmI.js → entity-note-count-link-Cjsk5oT2.js} +1 -1
- package/dist/assets/{entity-notes-surface-CagOwdng.js → entity-notes-surface-DQQPLjxd.js} +1 -1
- package/dist/assets/{execution-board-DTmAtmqZ.js → execution-board-agWQbN-y.js} +1 -1
- package/dist/assets/{faceted-token-search-DJPRm9AY.js → faceted-token-search-DldM3-ru.js} +1 -1
- package/dist/assets/{flagship-signal-deck-CJbGZF7I.js → flagship-signal-deck-BlLYW9Kz.js} +1 -1
- package/dist/assets/{floating-action-menu-K77jh8XZ.js → floating-action-menu-D9-psbha.js} +1 -1
- package/dist/assets/{forms-C5d5hTf2.js → forms-D1qJ3oOP.js} +1 -1
- package/dist/assets/{generic-node-view-p5ePSFuG.js → generic-node-view-CcepUVhP.js} +1 -1
- package/dist/assets/{goal-detail-page-DGu_khEK.js → goal-detail-page-DP1n5-Hk.js} +1 -1
- package/dist/assets/{goal-dialog-BWD7cOv9.js → goal-dialog-Oxx8WqbZ.js} +1 -1
- package/dist/assets/{goals-page-Bgj3sj0f.js → goals-page-CUt1a4Y2.js} +1 -1
- package/dist/assets/{graph-Cd5WF3lw.js → graph-BF4IsheG.js} +1 -1
- package/dist/assets/{habits-page-Ctut1tuX.js → habits-page-5REbWAlo.js} +1 -1
- package/dist/assets/{health-boxes-Ie3horXx.js → health-boxes-sHNML3tm.js} +1 -1
- package/dist/assets/index-CQ5r7ZUz.js +2 -0
- package/dist/assets/index-FxgNSuZX.css +1 -0
- package/dist/assets/{inline-note-fields-DE6WM9uM.js → inline-note-fields-Bql_KfR9.js} +1 -1
- package/dist/assets/{insight-flow-dialog-XL8I74eJ.js → insight-flow-dialog-CN-CMSB7.js} +1 -1
- package/dist/assets/{insights-page-Bz1FLbp5.js → insights-page-B1u6ONtQ.js} +1 -1
- package/dist/assets/{kanban-boxes-BBziel7P.js → kanban-boxes-DB1kuUlY.js} +1 -1
- package/dist/assets/{kanban-page-DdQP73I3.js → kanban-page-BBW9_vMu.js} +1 -1
- package/dist/assets/{knowledge-graph-page-DdHWj4Dj.js → knowledge-graph-page-CoJaydZb.js} +1 -1
- package/dist/assets/{life-force-page-BRN-93cI.js → life-force-page-DBYbA1GF.js} +1 -1
- package/dist/assets/{life-force-workspace-BowvP5R4.js → life-force-workspace-BiD9xOEt.js} +1 -1
- package/dist/assets/{maps-D0Mm6WPG.js → maps-BTVHALP8.js} +1 -1
- package/dist/assets/{metric-tile-B6aJueRo.js → metric-tile-CuP9DOYm.js} +1 -1
- package/dist/assets/{motion-DwjmC9aq.js → motion-DcgUnXhY.js} +1 -1
- package/dist/assets/{movement-boxes-5cjWjIdR.js → movement-boxes-DZg_qPPg.js} +1 -1
- package/dist/assets/{movement-page-Dy53RWtB.js → movement-page-CmwsQGR_.js} +1 -1
- package/dist/assets/{note-markdown-CvEQCfoi.js → note-markdown-B82ncnFt.js} +1 -1
- package/dist/assets/{note-tags-input-Cg5zBXos.js → note-tags-input-C_x5WdK5.js} +1 -1
- package/dist/assets/{notes-boxes-CgZyf7mV.js → notes-boxes-BEFlp9yd.js} +1 -1
- package/dist/assets/{notes-page-Cbdcv0Ej.js → notes-page-B6Vl-GPf.js} +1 -1
- package/dist/assets/{open-in-graph-button-D31ZOEhA.js → open-in-graph-button-C-bJekoH.js} +1 -1
- package/dist/assets/{orbit-map-8eNDWek8.js → orbit-map-DHeTM15g.js} +1 -1
- package/dist/assets/{overview-page-CZ6q52Qj.js → overview-page-BRWje1F9.js} +1 -1
- package/dist/assets/{page-hero-C0MpI3MM.js → page-hero-8bITsx_x.js} +1 -1
- package/dist/assets/pill-cluster-XQjm-wPc.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-CJhr5AXl.js → preference-entity-handoff-button-DwYF_5i3.js} +1 -1
- package/dist/assets/{preferences-page-8vszDNFX.js → preferences-page-C7DBPpNb.js} +1 -1
- package/dist/assets/{project-collections-sC7eAAhS.js → project-collections-mtxanSMf.js} +1 -1
- package/dist/assets/{project-detail-page-BKdnMjJy.js → project-detail-page-BT87Goqc.js} +1 -1
- package/dist/assets/{project-dialog-BiHZpOo1.js → project-dialog-DnZe757y.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-VW-hykAI.js → project-management-hierarchy-page-B3R2lNFI.js} +1 -1
- package/dist/assets/{project-management-section-nav-BEZ5zihs.js → project-management-section-nav-DyBWxHbe.js} +1 -1
- package/dist/assets/{projects-boxes-Ca6rpYeE.js → projects-boxes-CxZj3P29.js} +1 -1
- package/dist/assets/{projects-page-D86pjpTf.js → projects-page-Bec11c0x.js} +1 -1
- package/dist/assets/{psyche-behaviors-page-YLJB6CRU.js → psyche-behaviors-page-DWRpYvl1.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-D3gdHLUw.js → psyche-flashcards-page-CX4rcsXZ.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-DJiqSiCx.js → psyche-goal-map-page-Y6b3lCvV.js} +1 -1
- package/dist/assets/{psyche-graph-Tke0qFdt.js → psyche-graph-CQuCWKIp.js} +1 -1
- package/dist/assets/{psyche-metrics-page-DoLnvmC2.js → psyche-metrics-page-DadDJOnm.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-_Zbvg_HL.js → psyche-mode-guide-page-B1nz0uCg.js} +1 -1
- package/dist/assets/{psyche-modes-page-eAkaAzJc.js → psyche-modes-page-i3uSuhKA.js} +1 -1
- package/dist/assets/{psyche-page-CwmuBVjA.js → psyche-page-Y_s-BE2m.js} +1 -1
- package/dist/assets/{psyche-patterns-page-D7B4Ykjq.js → psyche-patterns-page-DaaOLIlN.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-CHJlvCzX.js → psyche-questionnaire-builder-page-CuF7rXOv.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-Bg3ll-D4.js → psyche-questionnaire-detail-page-BfFEMkRY.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-CIEerczF.js → psyche-questionnaire-run-detail-page-BoQTvd7Q.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-DyxIk6Qx.js → psyche-questionnaire-run-page-C0qKiNZN.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-ZlqUxuIl.js → psyche-questionnaires-page-B6hfD448.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-B2jgYnQ5.js → psyche-report-detail-page-BlFL8moM.js} +1 -1
- package/dist/assets/{psyche-reports-page-DlXr52yr.js → psyche-reports-page-DAAcYENp.js} +1 -1
- package/dist/assets/{psyche-schemas-Dtskzvv1.js → psyche-schemas-DDol0j-g.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-BhrTZN9B.js → psyche-schemas-beliefs-page-CsxKSrKM.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-WNGcdusx.js → psyche-screen-time-page-n4b0e58x.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-XsCOglo4.js → psyche-self-observation-page-BaxEQ2-3.js} +1 -1
- package/dist/assets/{psyche-values-page-NvHI6zWK.js → psyche-values-page-DTv5NMSU.js} +1 -1
- package/dist/assets/{question-flow-dialog-Bj4PxpjS.js → question-flow-dialog-CskCt5NZ.js} +1 -1
- package/dist/assets/{report-chain-fields-mWFikZzT.js → report-chain-fields-D132-EMh.js} +1 -1
- package/dist/assets/{rewards-page-DyjwXsQN.js → rewards-page-C533lVP-.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-C6FEYOxd.js → scheduling-rules-editor-CDpontGp.js} +1 -1
- package/dist/assets/{schema-badge-CCe4zkSN.js → schema-badge-B3DiMnjB.js} +1 -1
- package/dist/assets/{schemas-Cjwn6ooR.js → schemas-CH1_ngUX.js} +1 -1
- package/dist/assets/{select-menu-DeJhCsd8.js → select-menu-BOF-k4Ln.js} +1 -1
- package/dist/assets/{settings-agents-page-DYDxyKu-.js → settings-agents-page-B5OQtlZX.js} +1 -1
- package/dist/assets/{settings-bin-page-BWLfKVW1.js → settings-bin-page-D_bk3Kcu.js} +1 -1
- package/dist/assets/{settings-calendar-page-Ci-wXhCv.js → settings-calendar-page-PuSj9_kM.js} +1 -1
- package/dist/assets/{settings-data-page-DxIw-fWn.js → settings-data-page-EwFMaeq6.js} +1 -1
- package/dist/assets/{settings-logs-page-inpyIdu6.js → settings-logs-page-BKkse0DX.js} +1 -1
- package/dist/assets/{settings-mobile-page-BcJGLax8.js → settings-mobile-page-BrIVmdeB.js} +1 -1
- package/dist/assets/{settings-models-page-OWTRhfkj.js → settings-models-page-Mg84D_0K.js} +1 -1
- package/dist/assets/{settings-page-DXxF3qK2.js → settings-page-D-kul92f.js} +1 -1
- package/dist/assets/{settings-rewards-page-CCXin1n_.js → settings-rewards-page-waNyCcX_.js} +1 -1
- package/dist/assets/{settings-section-nav-CwSDNC3W.js → settings-section-nav-BmJWnrYk.js} +1 -1
- package/dist/assets/{settings-users-page-B4NEACwR.js → settings-users-page-DBgC6y56.js} +1 -1
- package/dist/assets/{settings-wiki-page-BNRK1SYc.js → settings-wiki-page-CM0te9dI.js} +1 -1
- package/dist/assets/sleep-page-C_krRE59.js +1 -0
- package/dist/assets/{sports-page-BawekFKD.js → sports-page-eg5Rfc_E.js} +1 -1
- package/dist/assets/{state-BtwEvpO6.js → state-Bpe5dF3T.js} +1 -1
- package/dist/assets/{strategies-page-BEl3NGAU.js → strategies-page-D4AqvFNW.js} +1 -1
- package/dist/assets/{strategy-detail-page-DPPI_8Ub.js → strategy-detail-page-BlYVkXaW.js} +1 -1
- package/dist/assets/{strategy-dialog-DU6wbBkQ.js → strategy-dialog-FO9Oa0dB.js} +1 -1
- package/dist/assets/{surface-BVYp-Wq9.js → surface-MVeeZGKB.js} +1 -1
- package/dist/assets/{table-BuONJH1s.js → table-U7otr5go.js} +1 -1
- package/dist/assets/{task-detail-page-BsMVAsbb.js → task-detail-page-Dy-aRyY6.js} +1 -1
- package/dist/assets/{task-dialog-BGzPc6TW.js → task-dialog-DrA9pba7.js} +1 -1
- package/dist/assets/{timebox-planning-dialog-4_XWuqkw.js → timebox-planning-dialog-C_gnfxFx.js} +1 -1
- package/dist/assets/{today-boxes-5pCvh5zS.js → today-boxes-BFOws_iC.js} +1 -1
- package/dist/assets/{today-page-BGurICpl.js → today-page-BoPj6a6q.js} +1 -1
- package/dist/assets/{training-load-page-BkoYKZ9_.js → training-load-page-DGU40Zfl.js} +1 -1
- package/dist/assets/{ui-B9O-eUim.js → ui-B9TWEtCx.js} +1 -1
- package/dist/assets/{use-anchored-overlay-position-BrQ4cqKn.js → use-anchored-overlay-position-BY4kNzPj.js} +1 -1
- package/dist/assets/{use-psyche-focus-target-Cuxni3SK.js → use-psyche-focus-target-BhNedCZB.js} +1 -1
- package/dist/assets/{user-badge-DfDv87j7.js → user-badge-CZWtYeMw.js} +1 -1
- package/dist/assets/{user-select-field-BNqv8-wd.js → user-select-field-fx129Uh6.js} +1 -1
- package/dist/assets/{utility-widgets-CbYj32he.js → utility-widgets-B3wWGxQc.js} +1 -1
- package/dist/assets/{vendor-Cpmju3nw.js → vendor-BwL6m4SE.js} +216 -211
- package/dist/assets/{vitals-page-DlxMk-L7.js → vitals-page-BXRZEP_8.js} +1 -1
- package/dist/assets/{weekly-review-page-VrEvAl1T.js → weekly-review-page-D5cebA5x.js} +1 -1
- package/dist/assets/weight-loss-page-BuUdFh9z.js +5 -0
- package/dist/assets/{wiki-article-markdown-DxTkiQRy.js → wiki-article-markdown-CvaCjg_t.js} +1 -1
- package/dist/assets/{wiki-editor-page-Beu92YnZ.js → wiki-editor-page-Dco79SLY.js} +1 -1
- package/dist/assets/{wiki-ingest-history-page-Cq_soygm.js → wiki-ingest-history-page-uvKRkRDF.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-D6xs2sEn.js → wiki-ingest-modal-BW6AJPea.js} +1 -1
- package/dist/assets/{wiki-page-yF3Flgtg.js → wiki-page-BIL5zMqv.js} +1 -1
- package/dist/assets/{workbench-flow-page-CZZGg3a8.js → workbench-flow-page-Dx_nq8R_.js} +1 -1
- package/dist/assets/{workbench-page-DKENZ5Nz.js → workbench-page-BJnt_Zzf.js} +1 -1
- package/dist/assets/{workout-detail-page-CeN4QiYQ.js → workout-detail-page-CKgqyB-y.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/server/migrations/070_health_mobile_sync_completion_index.sql +16 -0
- package/dist/server/server/src/app.js +139 -13
- package/dist/server/server/src/health-weight-loss.js +48 -6
- package/dist/server/server/src/health.js +345 -96
- package/dist/server/server/src/openapi.js +62 -0
- package/dist/server/server/src/repositories/gamification.js +25 -0
- package/dist/server/server/src/repositories/tasks.js +82 -17
- package/dist/server/server/src/services/dashboard.js +5 -4
- package/dist/server/server/src/services/gamification.js +47 -19
- package/dist/server/server/src/services/life-force.js +99 -0
- package/dist/server/src/lib/api.js +4 -0
- package/dist/server/src/lib/snapshot-normalizer.js +42 -23
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server/migrations/070_health_mobile_sync_completion_index.sql +16 -0
- package/skills/forge-openclaw/SKILL.md +1 -0
- package/skills/forge-openclaw/psyche_entity_playbooks.md +8 -0
- package/dist/assets/date-keys-Cj1G3TOn.js +0 -1
- package/dist/assets/index-BaiwtAgo.js +0 -2
- package/dist/assets/index-CEgIwgk9.css +0 -1
- package/dist/assets/pill-cluster-DGwKZQKF.js +0 -1
- package/dist/assets/sleep-page-Bara54nB.js +0 -1
- package/dist/assets/weight-loss-page-DJDnjxKF.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b6 as Pe,r as p,j as e,aK as se,dD as te,dE as Le,aN as Ke,dF as Fe,ca as Me,aG as G,dG as fe,bV as $e,b7 as he}from"./vendor-Cpmju3nw.js";import{R as qe,P as ze,O as De,C as Qe,T as Re,D as We,a as Ue}from"./ui-B9O-eUim.js";import{j as Oe,i as re,k as D}from"./state-BtwEvpO6.js";import{ep as Be,eq as Ge,er as ye,es as Ve,et as He,eu as Ze,c,I as je,T as Ye,B as C,b as ae,k as ie,g as Xe,s as Je,ev as et,ew as tt}from"./index-BaiwtAgo.js";const $=new Set(["queued","processing"]),Ne=15e3,j="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",z="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",q="border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]",V="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",at=["goal","project","task","habit","strategy","psyche_value","flashcard","note"];function ke(i){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(i))}function _(i,a){const r=i[a];return typeof r=="number"&&Number.isFinite(r)?r:null}function y(i,a){const r=i[a];return typeof r=="string"&&r.trim().length>0?r:null}function it(i,a){const r=y(i.metadata,"currentFileName")??y(i.metadata,"fileName")??"current source",f=y(i.metadata,"status")??"in_progress",o=_(i.metadata,"chunkIndex"),x=_(i.metadata,"chunkCount"),N=_(i.metadata,"currentFileIndex"),b=_(i.metadata,"currentFileTotal"),k=N!==null&&b!==null?`${r} (${N}/${b})`:r,u=o!==null&&x!==null&&x>1?` · chunk ${o}/${x}`:"";return`Waiting for OpenAI on ${k}${u}. ${a} polls · ${f}.`}function st(i){const a=[];for(const r of i){const f=y(r.metadata,"scope"),x=y(r.metadata,"eventKey")==="llm_compile_background_polled",N=y(r.metadata,"currentFileName")??y(r.metadata,"fileName"),b=_(r.metadata,"chunkIndex"),k=_(r.metadata,"chunkCount"),u=x?["poll",f??"",N??"",b??"",k??""].join(":"):null,m=a[a.length-1],A=m&&y(m.metadata,"eventKey"),w=m&&(y(m.metadata,"currentFileName")??y(m.metadata,"fileName")),E=m&&_(m.metadata,"chunkIndex"),h=m&&_(m.metadata,"chunkCount"),P=m&&A==="llm_compile_background_polled"?["poll",y(m.metadata,"scope")??"",w??"",E??"",h??""].join(":"):null;if(x&&m&&P===u){a[a.length-1]={...r,repetitionCount:m.repetitionCount+1,metadata:{...r.metadata,aggregatedPollCount:m.repetitionCount+1}};continue}a.push({...r,repetitionCount:1})}return a}function H(i){return Xe(i)}function we(i){return typeof i=="string"&&at.includes(i)}function rt(i,a){return typeof a.title=="string"&&a.title.trim().length>0?a.title:typeof a.displayName=="string"&&a.displayName.trim().length>0?a.displayName:typeof a.statement=="string"&&a.statement.trim().length>0?a.statement:`${i}:${String(a.id??"")}`}function nt(i,a){const f=[a.description,a.summary,a.overview,a.valuedDirection,a.whyItMatters,a.originNote].find(o=>typeof o=="string"&&o.trim().length>0);return f||(i==="note"&&typeof a.kind=="string"?a.kind:"")}function lt({candidate:i,decision:a,onDecisionChange:r,spaceId:f}){const o=we(i.payload.entityType)?i.payload.entityType:null,[x,N]=p.useState(a.mappedEntityLabel||i.title||""),[b,k]=p.useState(a.targetNoteLabel||i.title||""),u=typeof i.payload.contentMarkdown=="string"?i.payload.contentMarkdown:typeof i.payload.patchSummary=="string"?i.payload.patchSummary:typeof i.payload.rationale=="string"?i.payload.rationale:i.summary,m=re({queryKey:["forge-wiki-ingest-map-search",o,x.trim()],enabled:i.candidateType==="entity"&&a.action==="map_existing"&&o!==null&&x.trim().length>0,queryFn:async()=>{var F;const v=(await Je({searches:[{entityTypes:o?[o]:void 0,query:x.trim(),limit:8}]})).results[0];return((F=v==null?void 0:v.matches)==null?void 0:F.filter(g=>!!(g&&we(g.entityType)&&typeof g.id=="string"&&g.entity&&typeof g.entity=="object")).map(g=>({entityType:g.entityType,entityId:g.id,label:rt(g.entityType,g.entity),description:nt(g.entityType,g.entity),kind:H(g.entityType)})))??[]}}),A=m.data??[],w=re({queryKey:["forge-wiki-ingest-merge-search",f,b.trim()],enabled:i.candidateType==="page"&&a.action==="merge_existing"&&b.trim().length>0,queryFn:async()=>(await et({spaceId:f,kind:"wiki",mode:"text",query:b.trim(),limit:8})).results.map(v=>({noteId:v.page.id,title:v.page.title,slug:v.page.slug,summary:v.page.summary}))}),E=w.data??[],h=a.mappedEntityId&&a.mappedEntityType?A.find(s=>s.entityId===a.mappedEntityId&&s.entityType===a.mappedEntityType)??(a.mappedEntityLabel?{entityId:a.mappedEntityId,entityType:a.mappedEntityType,label:a.mappedEntityLabel,kind:H(a.mappedEntityType)}:null):null,P=a.targetNoteId?E.find(s=>s.noteId===a.targetNoteId)??(a.targetNoteLabel?{noteId:a.targetNoteId,title:a.targetNoteLabel}:null):null;return e.jsxs("div",{className:c("rounded-[24px] border p-4",j),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:i.candidateType.replaceAll("_"," ")}),e.jsx("div",{className:"mt-2 text-base font-semibold text-[var(--ui-ink-strong)]",children:i.title||i.targetKey||"Untitled candidate"}),o?e.jsx("div",{className:"mt-2",children:H(o)?e.jsx(ae,{kind:H(o),label:o.replaceAll("_"," "),compact:!0,gradient:!1}):e.jsx(ie,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:o.replaceAll("_"," ")})}):null,i.summary?e.jsx("div",{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.summary}):null]}),e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-1",children:[e.jsx("button",{type:"button",className:c("rounded-full px-3 py-1.5 text-xs font-medium transition",a.action==="keep"?"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({...a,action:"keep"}),children:"Keep"}),i.candidateType==="entity"&&o?e.jsx("button",{type:"button",className:c("rounded-full px-3 py-1.5 text-xs font-medium transition",a.action==="map_existing"?"bg-[var(--ui-info-soft)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({...a,action:"map_existing",mappedEntityType:o}),children:"Map existing"}):null,i.candidateType==="page"?e.jsx("button",{type:"button",className:c("rounded-full px-3 py-1.5 text-xs font-medium transition",a.action==="merge_existing"?"bg-[var(--ui-info-soft)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({...a,action:"merge_existing"}),children:"Merge existing"}):null,e.jsx("button",{type:"button",className:c("rounded-full px-3 py-1.5 text-xs font-medium transition",a.action==="discard"?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({...a,action:"discard"}),children:"Discard"})]})]}),i.candidateType==="entity"&&o&&a.action==="map_existing"?e.jsxs("div",{className:c("mt-4 grid gap-3 rounded-[18px] border p-4",z),children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Map to existing ",o.replaceAll("_"," ")]}),h?e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1.5",children:[h.kind?e.jsx(ae,{kind:h.kind,label:h.label,compact:!0,gradient:!1,className:"max-w-[20rem]"}):e.jsx(ie,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:h.label}),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-faint)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>r({...a,mappedEntityId:void 0,mappedEntityLabel:void 0}),"aria-label":"Clear mapped entity",children:e.jsx(se,{className:"size-3.5"})})]})}):null,e.jsxs("div",{className:c("flex items-center gap-3 rounded-[20px] border px-4 py-3",j),children:[e.jsx(he,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx("input",{value:x,onChange:s=>{N(s.target.value),a.mappedEntityId&&r({...a,mappedEntityId:void 0,mappedEntityLabel:void 0})},placeholder:`Search existing ${o.replaceAll("_"," ")}`,className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)] focus:outline-none"})]}),e.jsx("div",{className:"grid gap-2",children:m.isPending?e.jsx("div",{className:c("rounded-[16px] border px-3 py-3 text-sm text-[var(--ui-ink-faint)]",j),children:"Searching Forge…"}):A.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-[var(--ui-border-subtle)] px-3 py-3 text-sm text-[var(--ui-ink-faint)]",children:["No existing ",o.replaceAll("_"," ")," matches yet."]}):A.map(s=>{const v=a.mappedEntityType===s.entityType&&a.mappedEntityId===s.entityId;return e.jsx("button",{type:"button",className:c("flex w-full items-start justify-between gap-3 rounded-[18px] border px-3 py-3 text-left transition",v?q:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({action:"map_existing",mappedEntityType:s.entityType,mappedEntityId:s.entityId,mappedEntityLabel:s.label}),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.kind?e.jsx(ae,{kind:s.kind,label:s.label,compact:!0,gradient:!1}):s.label}),s.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:s.description}):null]})},`${s.entityType}:${s.entityId}`)})})]}):null,i.candidateType==="page"&&a.action==="merge_existing"?e.jsxs("div",{className:c("mt-4 grid gap-3 rounded-[18px] border p-4",z),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Merge into existing page"}),P?e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1.5",children:[e.jsx(ie,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:P.title}),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-faint)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>r({...a,targetNoteId:void 0,targetNoteLabel:void 0}),"aria-label":"Clear merge target",children:e.jsx(se,{className:"size-3.5"})})]})}):null,e.jsxs("div",{className:c("flex items-center gap-3 rounded-[20px] border px-4 py-3",j),children:[e.jsx(he,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx("input",{value:b,onChange:s=>{k(s.target.value),a.targetNoteId&&r({...a,targetNoteId:void 0,targetNoteLabel:void 0})},placeholder:"Search existing wiki pages",className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)] focus:outline-none"})]}),e.jsx("div",{className:"grid gap-2",children:w.isPending?e.jsx("div",{className:c("rounded-[16px] border px-3 py-3 text-sm text-[var(--ui-ink-faint)]",j),children:"Searching Forge…"}):E.length===0?e.jsx("div",{className:"rounded-[16px] border border-dashed border-[var(--ui-border-subtle)] px-3 py-3 text-sm text-[var(--ui-ink-faint)]",children:"No existing wiki pages match yet."}):E.map(s=>{const v=a.targetNoteId===s.noteId;return e.jsx("button",{type:"button",className:c("flex w-full items-start justify-between gap-3 rounded-[18px] border px-3 py-3 text-left transition",v?q:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({action:"merge_existing",targetNoteId:s.noteId,targetNoteLabel:s.title}),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.title}),e.jsxs("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:[s.slug?`${s.slug}`:"",s.summary?`${s.slug?" · ":""}${s.summary}`:""]})]})},s.noteId)})})]}):null,u?e.jsx("div",{className:c("mt-4 rounded-[18px] border px-4 py-3 text-sm leading-6 text-[var(--ui-ink-medium)]",z),children:e.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:u})}):null]})}function pt({open:i,onOpenChange:a,spaces:r,llmProfiles:f,initialSpaceId:o,selectedJobId:x,onJobSelected:N,linkedEntityHints:b=[]}){var ge;const k=Pe(),u=Oe(),[m,A]=p.useState("files"),[w,E]=p.useState(o),[h,P]=p.useState(""),[s,v]=p.useState(""),[F,g]=p.useState(""),[Q,Z]=p.useState([]),[Ee,R]=p.useState(!1),[Ie,Se]=p.useState(!1),I=p.useMemo(()=>f.filter(t=>t.enabled&&!!t.secretId),[f]),[W,ne]=p.useState(((ge=I[0])==null?void 0:ge.id)??""),[U,Te]=p.useState("auto"),[Y,le]=p.useState({}),[O,S]=p.useState(null),[B,T]=p.useState(null),oe=p.useRef({});p.useEffect(()=>{o&&E(o)},[o]),p.useEffect(()=>{var t;!W&&((t=I[0])!=null&&t.id)&&ne(I[0].id)},[W,I]);const M=I.find(t=>t.id===W)??I[0]??null,L=re({queryKey:["forge-wiki-ingest-job",x],queryFn:()=>tt(x),enabled:i&&!!x,refetchInterval:t=>{const d=t.state.data;return d&&$.has(d.job.status)?2e3:!1}});p.useEffect(()=>{const t=L.data;t&&le(d=>{const l={};for(const K of t.candidates)l[K.id]=d[K.id]??(K.status==="rejected"?{action:"discard"}:{action:"keep"});return l})},[L.data]),p.useEffect(()=>{B&&T(null)},[Y,B]);const X=D({mutationFn:async t=>Be(t),onSuccess:(t,d)=>{t.job&&u.setQueryData(["forge-wiki-ingest-job",d],t.job),u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]})}});p.useEffect(()=>{const t=L.data;if(!t||!$.has(t.job.status))return;const d=t.logs.reduce((ve,Ae)=>{const be=Number(new Date(Ae.createdAt));return Number.isFinite(be)?Math.max(ve,be):ve},0),l=Number(new Date(t.job.updatedAt)),K=Math.max(Number.isFinite(l)?l:0,d);if(!Number.isFinite(K)||K<=0)return;const ee=Date.now();if(!(ee-K>=Ne)||X.isPending)return;const _e=oe.current[t.job.id]??0;ee-_e<Ne||(oe.current[t.job.id]=ee,X.mutate(t.job.id))},[L.data,X]);const de=D({mutationFn:async()=>{if(!M)throw new Error("Set up an OpenAI wiki ingest profile first. Forge now requires an LLM profile before auto-ingest can turn source material into draft pages and entities.");if(m==="files"){if(Q.length===0)throw new Error("Select at least one file to ingest.");return Ge({files:Q,spaceId:w||void 0,titleHint:h.trim()||void 0,llmProfileId:M.id,parseStrategy:U,createAsKind:"wiki",linkedEntityHints:b})}if(m==="url"){if(!s.trim())throw new Error("Enter a URL to ingest.");return ye({spaceId:w||void 0,titleHint:h.trim()||void 0,sourceKind:"url",sourceUrl:s.trim(),llmProfileId:M.id,parseStrategy:U,createAsKind:"wiki",linkedEntityHints:b})}if(!F.trim())throw new Error("Paste some text to ingest.");return ye({spaceId:w||void 0,titleHint:h.trim()||void 0,sourceKind:"raw_text",sourceText:F,mimeType:"text/plain",llmProfileId:M.id,parseStrategy:U,createAsKind:"wiki",linkedEntityHints:b})},onSuccess:async t=>{var l;const d=((l=t.job)==null?void 0:l.job.id)??null;await u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),await u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),d&&N(d),S(null),T(null)},onError:t=>{S(t instanceof Error?t.message:"Unable to start ingest.")}}),ce=D({mutationFn:async()=>{if(!x||!L.data)throw new Error("Choose an ingest job first.");const t=L.data.candidates.map(d=>{const l=Y[d.id]??{action:"keep"};if(l.action==="map_existing"&&(!l.mappedEntityType||!l.mappedEntityId))throw new Error(`Choose an existing ${String(d.payload.entityType??"entity").replaceAll("_"," ")} before publishing the review.`);if(l.action==="merge_existing"&&!l.targetNoteId)throw new Error(`Choose an existing wiki page before publishing the review for ${d.title||"this page candidate"}.`);return l.action==="map_existing"?{candidateId:d.id,action:"map_existing",mappedEntityType:l.mappedEntityType,mappedEntityId:l.mappedEntityId}:l.action==="merge_existing"?{candidateId:d.id,action:"merge_existing",targetNoteId:l.targetNoteId}:{candidateId:d.id,action:l.action}});return Ve({jobId:x,decisions:t})},onSuccess:async t=>{T(null),u.setQueryData(["forge-wiki-ingest-job",t.job.job.id],t.job),await Promise.all([u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-job",t.job.job.id]}),u.invalidateQueries({queryKey:["forge-wiki-home"]}),u.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),u.invalidateQueries({queryKey:["forge-wiki-tree"]})])},onError:t=>{T(t instanceof Error?t.message:"Unable to publish review.")}}),ue=D({mutationFn:async()=>{if(!x)throw new Error("Choose an ingest job first.");return He(x)},onSuccess:async t=>{var l;const d=((l=t.job)==null?void 0:l.job.id)??null;await Promise.all([u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-job",x]})]),d&&N(d),S(null),T(null)},onError:t=>{S(t instanceof Error?t.message:"Unable to rerun ingest.")}}),me=D({mutationFn:async()=>{if(!x)throw new Error("Choose an ingest job first.");return Ze(x)},onSuccess:async()=>{await Promise.all([u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-job",x]})]),xe(),S(null),T(null)},onError:t=>{S(t instanceof Error?t.message:"Unable to delete ingest.")}}),n=L.data??null,Ce=n&&!$.has(n.job.status),J=p.useMemo(()=>(n==null?void 0:n.candidates.filter(t=>["suggested","rejected","failed"].includes(t.status)))??[],[n]),pe=p.useMemo(()=>st((n==null?void 0:n.logs)??[]),[n==null?void 0:n.logs]),xe=()=>{N(null),Z([]),v(""),g(""),P(""),S(null),T(null)};return e.jsx(qe,{open:i,onOpenChange:t=>{a(t),t||(S(null),T(null))},children:e.jsxs(ze,{children:[e.jsx(De,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(Qe,{className:"fixed inset-x-4 bottom-4 top-4 z-50 mx-auto flex max-w-[min(74rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] shadow-[var(--ui-shadow-floating)]",children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"KarpaWiki Ingest"}),e.jsx(Re,{className:"mt-2 font-display text-[1.5rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:n?"Ingest review and progress":"Build KarpaWiki memory from source files"}),e.jsx(We,{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Upload notes, media, ZIP archives, links, or pasted text. Forge will process them in the background, propose pages and entities, and let you keep only what belongs."})]}),e.jsx(Ue,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close ingest modal",children:e.jsx(se,{className:"size-4"})})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-5",children:n?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Job ",n.job.id]}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:n.job.latestMessage||"Ingest job"}),e.jsxs("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:[n.job.status," · ",n.job.phase," · started ",ke(n.job.createdAt)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{variant:"secondary",size:"sm",onClick:xe,children:"New ingest"}),Ce?e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"secondary",size:"sm",pending:ue.isPending,pendingLabel:"Rerunning",onClick:()=>void ue.mutateAsync(),children:[e.jsx(G,{className:"size-3.5"}),"Rerun"]}),e.jsx(C,{variant:"ghost",size:"sm",className:"border border-rose-300/18 bg-rose-400/10 text-rose-100 hover:bg-rose-400/16",pending:me.isPending,pendingLabel:"Deleting",onClick:()=>{window.confirm("Delete this ingest history entry? Published pages or entities will stay, but discarded or unreviewed ingest data will be removed.")&&me.mutateAsync()},children:"Delete"})]}):null]})]}),e.jsx("div",{className:"mt-5 grid gap-3 sm:grid-cols-4",children:[{label:"Progress",value:`${n.job.progressPercent}%`},{label:"Files",value:`${n.job.processedFiles}/${n.job.totalFiles}`},{label:"Pages",value:String(n.job.createdPageCount)},{label:"Entities",value:String(n.job.createdEntityCount)}].map(t=>e.jsxs("div",{className:c("rounded-[22px] border px-4 py-3",z),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.label}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:t.value})]},t.label))}),e.jsx("div",{className:"mt-5",children:e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:e.jsx("div",{className:"h-full rounded-full bg-[var(--primary)] transition-all duration-300",style:{width:`${n.job.progressPercent}%`}})})}),O?e.jsx("div",{className:"mt-4 rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:O}):null]}),e.jsxs("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Rich log"}),e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>k(`/settings/logs?jobId=${encodeURIComponent(n.job.id)}`),children:"Open full logs"})]}),e.jsx("div",{className:"mt-4 grid max-h-[28rem] gap-2 overflow-y-auto",children:pe.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm text-[var(--ui-ink-faint)]",children:"Waiting for the backend to emit progress."}):pe.map(t=>e.jsx("div",{className:c("rounded-[18px] border px-4 py-3",z),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--ui-ink-soft)]",children:t.level}),typeof t.metadata.scope=="string"?e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.metadata.scope}):null,typeof t.metadata.eventKey=="string"?e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.metadata.eventKey}):null]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-strong)]",children:y(t.metadata,"eventKey")==="llm_compile_background_polled"?it(t,t.repetitionCount):t.message}),t.repetitionCount>1?e.jsxs("div",{className:"mt-2 text-xs text-[var(--ui-ink-faint)]",children:["Combined ",t.repetitionCount," repeated polling updates."]}):null,Object.keys(t.metadata).length>0?e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-[var(--ui-ink-faint)]",children:"View metadata"}),e.jsx("pre",{className:"mt-2 max-w-full overflow-x-auto whitespace-pre-wrap rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-code)] px-3 py-3 text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:JSON.stringify(t.metadata,null,2)})]}):null]}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:ke(t.createdAt)})]})},t.id))})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Source files"}),e.jsx("div",{className:"mt-4 grid gap-2",children:n.assets.map(t=>e.jsxs("div",{className:c("flex min-w-0 items-center justify-between gap-3 rounded-[18px] border px-4 py-3",z),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:t.fileName||t.sourceLocator||"Source"}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:t.mimeType||t.sourceKind})]}),e.jsx("div",{className:"shrink-0 text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.status})]},t.id))})]}),e.jsxs("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Review"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Keep the candidates that belong in Forge and discard the rest."})]}),$.has(n.job.status)?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx($e,{className:"size-3.5 animate-spin"}),"Processing"]}):null]}),e.jsx("div",{className:"mt-4 grid gap-3",children:J.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm text-[var(--ui-ink-faint)]",children:$.has(n.job.status)?"Candidates will appear here while the job progresses.":"This job has no reviewable candidates left."}):J.map(t=>e.jsx(lt,{candidate:t,spaceId:n.job.spaceId,decision:Y[t.id]??{action:"keep"},onDecisionChange:d=>le(l=>({...l,[t.id]:d}))},t.id))}),B?e.jsx("div",{className:"mt-4 rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:B}):null,J.length>0&&!$.has(n.job.status)?e.jsx("div",{className:"mt-5",children:e.jsxs(C,{className:"min-h-12",pending:ce.isPending,pendingLabel:"Publishing review",onClick:()=>void ce.mutateAsync(),children:[e.jsx(fe,{className:"size-4"}),"Publish kept candidates"]})}):null]})]})]}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(18rem,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[{id:"files",label:"Files and ZIP",detail:"Drag many files or one archive.",icon:te},{id:"url",label:"URL",detail:"Pull a webpage or remote file.",icon:Le},{id:"text",label:"Paste text",detail:"Turn notes or transcripts into pages.",icon:Ke}].map(t=>{const d=t.icon,l=t.id===m;return e.jsxs("button",{type:"button",className:c("rounded-[24px] border px-4 py-4 text-left transition",l?q:V),onClick:()=>A(t.id),children:[e.jsx(d,{className:"size-4 text-[var(--secondary)]"}),e.jsx("div",{className:"mt-3 text-sm font-semibold",children:t.label}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:t.detail})]},t.id)})}),e.jsx("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(je,{value:h,onChange:t=>P(t.target.value),placeholder:"Optional title hint"}),m==="files"?e.jsxs("div",{className:c("rounded-[28px] border-2 border-dashed px-5 py-8 text-center transition",Ee?"border-[color-mix(in_srgb,var(--primary)_36%,transparent)] bg-[var(--ui-accent-soft)]":j),onDragEnter:t=>{t.preventDefault(),R(!0)},onDragLeave:t=>{t.preventDefault(),R(!1)},onDragOver:t=>{t.preventDefault(),R(!0)},onDrop:t=>{t.preventDefault(),R(!1);const d=Array.from(t.dataTransfer.files);Z(l=>[...l,...d])},children:[e.jsx("div",{className:"mx-auto flex size-14 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:e.jsx(te,{className:"size-5 text-[var(--ui-ink-medium)]"})}),e.jsx("div",{className:"mt-4 text-base font-semibold text-[var(--ui-ink-strong)]",children:"Drop files, media, notes, or ZIP archives here"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-faint)]",children:"Forge accepts many files at once and queues the ingest in the background so the UI stays responsive."}),e.jsxs("label",{className:"mt-5 inline-flex cursor-pointer items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-2 text-sm text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",children:[e.jsx(te,{className:"size-4"}),"Choose files",e.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:t=>Z(Array.from(t.target.files??[]))})]}),Q.length>0?e.jsx("div",{className:"mt-5 grid gap-2 text-left",children:Q.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] border ${INGEST_PANEL_CLASS} px-4 py-3 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx("span",{className:"truncate",children:t.name}),e.jsx("span",{className:"shrink-0 text-xs text-[var(--ui-ink-faint)]",children:t.name.toLowerCase().endsWith(".zip")?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Fe,{className:"size-3.5"}),"ZIP"]}):`${Math.max(1,Math.round(t.size/1024))} KB`})]},`${t.name}-${t.size}-${t.lastModified}`))}):null]}):null,m==="url"?e.jsx(je,{value:s,onChange:t=>v(t.target.value),placeholder:"https://example.com/source"}):null,m==="text"?e.jsx(Ye,{value:F,onChange:t=>g(t.target.value),placeholder:"Paste notes, transcripts, meeting writeups, or source material here…",className:"min-h-[18rem]"}):null]})})]}),e.jsxs("aside",{className:"grid h-fit gap-4",children:[M?null:e.jsxs("div",{className:"rounded-[30px] border border-[color-mix(in_srgb,var(--warning)_30%,transparent)] bg-[var(--ui-warning-soft)] p-5 shadow-[var(--ui-shadow-card)]",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-full border border-amber-200/20 bg-amber-300/12 text-amber-100",children:e.jsx(Me,{className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-amber-100/62",children:"OpenAI setup required for smart ingest"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Forge can only do a raw import without OpenAI"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Without an OpenAI ingest profile, Forge cannot extract key insights, split the source into draft wiki pages, or propose Forge entities. The fallback is just a direct text import or media reference with no structured synthesis."}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Set up the API key, model, thinking, and verbosity first, then come back here to build real draft pages and reviewable entity proposals."})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-2",children:[e.jsxs(C,{className:"w-full",onClick:()=>{a(!1),k("/settings/wiki?setupLlm=1")},children:[e.jsx(G,{className:"size-4"}),"Open OpenAI setup"]}),e.jsx(C,{variant:"secondary",className:"w-full",onClick:()=>{a(!1),k("/settings/wiki")},children:"Open KarpaWiki settings"})]})]}),e.jsxs("div",{className:"rounded-[28px] border ${INGEST_PANEL_CLASS} p-4",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-3 text-left",onClick:()=>Se(t=>!t),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Advanced"}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-medium)]",children:"Model, parse, and target controls."})]}),e.jsx(G,{className:"size-4 text-[var(--ui-ink-soft)]"})]}),Ie?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Space"}),e.jsx("div",{className:"grid gap-2",children:r.map(t=>e.jsxs("button",{type:"button",className:c("rounded-[18px] border px-3 py-3 text-left text-sm transition",w===t.id?q:V),onClick:()=>E(t.id),children:[e.jsx("div",{children:t.label}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:t.description||`/${t.slug}`})]},t.id))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"LLM profile"}),e.jsxs("div",{className:"grid gap-2",children:[I.map(t=>e.jsxs("button",{type:"button",className:c("rounded-[18px] border px-3 py-3 text-left text-sm transition",W===t.id?q:V),onClick:()=>ne(t.id),children:[e.jsx("div",{children:t.label}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:t.model})]},t.id)),I.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm text-[var(--ui-ink-faint)]",children:"No enabled profile with a saved key yet."}):null]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Parse mode"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:[{id:"auto",label:"Auto"},{id:"multimodal",label:"Multimodal"},{id:"text_only",label:"Text only"}].map(t=>e.jsx("button",{type:"button",className:c("rounded-[18px] border px-3 py-3 text-sm transition",U===t.id?q:V),onClick:()=>Te(t.id),children:t.label},t.id))})]})]}):null]}),e.jsxs("div",{className:"rounded-[28px] border border-[color-mix(in_srgb,var(--primary)_24%,transparent)] bg-[var(--ui-accent-soft)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(fe,{className:"size-4 text-[var(--secondary)]"}),e.jsx("span",{className:"text-sm font-semibold",children:"Publish only what belongs"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge stages candidate pages, proposed entity records, and page updates first. You review the output before anything is committed to the live memory graph."})]}),O?e.jsx("div",{className:"rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:O}):null,e.jsxs(C,{className:"min-h-12",pending:de.isPending,pendingLabel:"Starting ingest",disabled:!M,onClick:()=>void de.mutateAsync(),children:[e.jsx(G,{className:"size-4"}),"Start background ingest"]})]})]})})]})]})})}export{pt as W};
|
|
1
|
+
import{b6 as Pe,r as p,j as e,aK as se,dE as te,dF as Le,aN as Ke,dG as Fe,ca as Me,aG as G,dH as fe,bV as $e,b7 as he}from"./vendor-BwL6m4SE.js";import{R as qe,P as ze,O as De,C as Qe,T as Re,D as We,a as Ue}from"./ui-B9TWEtCx.js";import{j as Oe,i as re,k as D}from"./state-Bpe5dF3T.js";import{ep as Be,eq as Ge,er as ye,es as He,et as Ve,eu as Ze,c,I as je,T as Ye,B as C,b as ae,k as ie,g as Xe,s as Je,ev as et,ew as tt}from"./index-CQ5r7ZUz.js";const $=new Set(["queued","processing"]),Ne=15e3,j="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",z="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",q="border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]",H="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",at=["goal","project","task","habit","strategy","psyche_value","flashcard","note"];function ke(i){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(i))}function _(i,a){const r=i[a];return typeof r=="number"&&Number.isFinite(r)?r:null}function y(i,a){const r=i[a];return typeof r=="string"&&r.trim().length>0?r:null}function it(i,a){const r=y(i.metadata,"currentFileName")??y(i.metadata,"fileName")??"current source",f=y(i.metadata,"status")??"in_progress",o=_(i.metadata,"chunkIndex"),x=_(i.metadata,"chunkCount"),N=_(i.metadata,"currentFileIndex"),b=_(i.metadata,"currentFileTotal"),k=N!==null&&b!==null?`${r} (${N}/${b})`:r,u=o!==null&&x!==null&&x>1?` · chunk ${o}/${x}`:"";return`Waiting for OpenAI on ${k}${u}. ${a} polls · ${f}.`}function st(i){const a=[];for(const r of i){const f=y(r.metadata,"scope"),x=y(r.metadata,"eventKey")==="llm_compile_background_polled",N=y(r.metadata,"currentFileName")??y(r.metadata,"fileName"),b=_(r.metadata,"chunkIndex"),k=_(r.metadata,"chunkCount"),u=x?["poll",f??"",N??"",b??"",k??""].join(":"):null,m=a[a.length-1],A=m&&y(m.metadata,"eventKey"),w=m&&(y(m.metadata,"currentFileName")??y(m.metadata,"fileName")),E=m&&_(m.metadata,"chunkIndex"),h=m&&_(m.metadata,"chunkCount"),P=m&&A==="llm_compile_background_polled"?["poll",y(m.metadata,"scope")??"",w??"",E??"",h??""].join(":"):null;if(x&&m&&P===u){a[a.length-1]={...r,repetitionCount:m.repetitionCount+1,metadata:{...r.metadata,aggregatedPollCount:m.repetitionCount+1}};continue}a.push({...r,repetitionCount:1})}return a}function V(i){return Xe(i)}function we(i){return typeof i=="string"&&at.includes(i)}function rt(i,a){return typeof a.title=="string"&&a.title.trim().length>0?a.title:typeof a.displayName=="string"&&a.displayName.trim().length>0?a.displayName:typeof a.statement=="string"&&a.statement.trim().length>0?a.statement:`${i}:${String(a.id??"")}`}function nt(i,a){const f=[a.description,a.summary,a.overview,a.valuedDirection,a.whyItMatters,a.originNote].find(o=>typeof o=="string"&&o.trim().length>0);return f||(i==="note"&&typeof a.kind=="string"?a.kind:"")}function lt({candidate:i,decision:a,onDecisionChange:r,spaceId:f}){const o=we(i.payload.entityType)?i.payload.entityType:null,[x,N]=p.useState(a.mappedEntityLabel||i.title||""),[b,k]=p.useState(a.targetNoteLabel||i.title||""),u=typeof i.payload.contentMarkdown=="string"?i.payload.contentMarkdown:typeof i.payload.patchSummary=="string"?i.payload.patchSummary:typeof i.payload.rationale=="string"?i.payload.rationale:i.summary,m=re({queryKey:["forge-wiki-ingest-map-search",o,x.trim()],enabled:i.candidateType==="entity"&&a.action==="map_existing"&&o!==null&&x.trim().length>0,queryFn:async()=>{var F;const v=(await Je({searches:[{entityTypes:o?[o]:void 0,query:x.trim(),limit:8}]})).results[0];return((F=v==null?void 0:v.matches)==null?void 0:F.filter(g=>!!(g&&we(g.entityType)&&typeof g.id=="string"&&g.entity&&typeof g.entity=="object")).map(g=>({entityType:g.entityType,entityId:g.id,label:rt(g.entityType,g.entity),description:nt(g.entityType,g.entity),kind:V(g.entityType)})))??[]}}),A=m.data??[],w=re({queryKey:["forge-wiki-ingest-merge-search",f,b.trim()],enabled:i.candidateType==="page"&&a.action==="merge_existing"&&b.trim().length>0,queryFn:async()=>(await et({spaceId:f,kind:"wiki",mode:"text",query:b.trim(),limit:8})).results.map(v=>({noteId:v.page.id,title:v.page.title,slug:v.page.slug,summary:v.page.summary}))}),E=w.data??[],h=a.mappedEntityId&&a.mappedEntityType?A.find(s=>s.entityId===a.mappedEntityId&&s.entityType===a.mappedEntityType)??(a.mappedEntityLabel?{entityId:a.mappedEntityId,entityType:a.mappedEntityType,label:a.mappedEntityLabel,kind:V(a.mappedEntityType)}:null):null,P=a.targetNoteId?E.find(s=>s.noteId===a.targetNoteId)??(a.targetNoteLabel?{noteId:a.targetNoteId,title:a.targetNoteLabel}:null):null;return e.jsxs("div",{className:c("rounded-[24px] border p-4",j),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:i.candidateType.replaceAll("_"," ")}),e.jsx("div",{className:"mt-2 text-base font-semibold text-[var(--ui-ink-strong)]",children:i.title||i.targetKey||"Untitled candidate"}),o?e.jsx("div",{className:"mt-2",children:V(o)?e.jsx(ae,{kind:V(o),label:o.replaceAll("_"," "),compact:!0,gradient:!1}):e.jsx(ie,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:o.replaceAll("_"," ")})}):null,i.summary?e.jsx("div",{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.summary}):null]}),e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-1",children:[e.jsx("button",{type:"button",className:c("rounded-full px-3 py-1.5 text-xs font-medium transition",a.action==="keep"?"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({...a,action:"keep"}),children:"Keep"}),i.candidateType==="entity"&&o?e.jsx("button",{type:"button",className:c("rounded-full px-3 py-1.5 text-xs font-medium transition",a.action==="map_existing"?"bg-[var(--ui-info-soft)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({...a,action:"map_existing",mappedEntityType:o}),children:"Map existing"}):null,i.candidateType==="page"?e.jsx("button",{type:"button",className:c("rounded-full px-3 py-1.5 text-xs font-medium transition",a.action==="merge_existing"?"bg-[var(--ui-info-soft)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({...a,action:"merge_existing"}),children:"Merge existing"}):null,e.jsx("button",{type:"button",className:c("rounded-full px-3 py-1.5 text-xs font-medium transition",a.action==="discard"?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({...a,action:"discard"}),children:"Discard"})]})]}),i.candidateType==="entity"&&o&&a.action==="map_existing"?e.jsxs("div",{className:c("mt-4 grid gap-3 rounded-[18px] border p-4",z),children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Map to existing ",o.replaceAll("_"," ")]}),h?e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1.5",children:[h.kind?e.jsx(ae,{kind:h.kind,label:h.label,compact:!0,gradient:!1,className:"max-w-[20rem]"}):e.jsx(ie,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:h.label}),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-faint)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>r({...a,mappedEntityId:void 0,mappedEntityLabel:void 0}),"aria-label":"Clear mapped entity",children:e.jsx(se,{className:"size-3.5"})})]})}):null,e.jsxs("div",{className:c("flex items-center gap-3 rounded-[20px] border px-4 py-3",j),children:[e.jsx(he,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx("input",{value:x,onChange:s=>{N(s.target.value),a.mappedEntityId&&r({...a,mappedEntityId:void 0,mappedEntityLabel:void 0})},placeholder:`Search existing ${o.replaceAll("_"," ")}`,className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)] focus:outline-none"})]}),e.jsx("div",{className:"grid gap-2",children:m.isPending?e.jsx("div",{className:c("rounded-[16px] border px-3 py-3 text-sm text-[var(--ui-ink-faint)]",j),children:"Searching Forge…"}):A.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-[var(--ui-border-subtle)] px-3 py-3 text-sm text-[var(--ui-ink-faint)]",children:["No existing ",o.replaceAll("_"," ")," matches yet."]}):A.map(s=>{const v=a.mappedEntityType===s.entityType&&a.mappedEntityId===s.entityId;return e.jsx("button",{type:"button",className:c("flex w-full items-start justify-between gap-3 rounded-[18px] border px-3 py-3 text-left transition",v?q:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({action:"map_existing",mappedEntityType:s.entityType,mappedEntityId:s.entityId,mappedEntityLabel:s.label}),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.kind?e.jsx(ae,{kind:s.kind,label:s.label,compact:!0,gradient:!1}):s.label}),s.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:s.description}):null]})},`${s.entityType}:${s.entityId}`)})})]}):null,i.candidateType==="page"&&a.action==="merge_existing"?e.jsxs("div",{className:c("mt-4 grid gap-3 rounded-[18px] border p-4",z),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Merge into existing page"}),P?e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1.5",children:[e.jsx(ie,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:P.title}),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-faint)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>r({...a,targetNoteId:void 0,targetNoteLabel:void 0}),"aria-label":"Clear merge target",children:e.jsx(se,{className:"size-3.5"})})]})}):null,e.jsxs("div",{className:c("flex items-center gap-3 rounded-[20px] border px-4 py-3",j),children:[e.jsx(he,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx("input",{value:b,onChange:s=>{k(s.target.value),a.targetNoteId&&r({...a,targetNoteId:void 0,targetNoteLabel:void 0})},placeholder:"Search existing wiki pages",className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)] focus:outline-none"})]}),e.jsx("div",{className:"grid gap-2",children:w.isPending?e.jsx("div",{className:c("rounded-[16px] border px-3 py-3 text-sm text-[var(--ui-ink-faint)]",j),children:"Searching Forge…"}):E.length===0?e.jsx("div",{className:"rounded-[16px] border border-dashed border-[var(--ui-border-subtle)] px-3 py-3 text-sm text-[var(--ui-ink-faint)]",children:"No existing wiki pages match yet."}):E.map(s=>{const v=a.targetNoteId===s.noteId;return e.jsx("button",{type:"button",className:c("flex w-full items-start justify-between gap-3 rounded-[18px] border px-3 py-3 text-left transition",v?q:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>r({action:"merge_existing",targetNoteId:s.noteId,targetNoteLabel:s.title}),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.title}),e.jsxs("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:[s.slug?`${s.slug}`:"",s.summary?`${s.slug?" · ":""}${s.summary}`:""]})]})},s.noteId)})})]}):null,u?e.jsx("div",{className:c("mt-4 rounded-[18px] border px-4 py-3 text-sm leading-6 text-[var(--ui-ink-medium)]",z),children:e.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:u})}):null]})}function pt({open:i,onOpenChange:a,spaces:r,llmProfiles:f,initialSpaceId:o,selectedJobId:x,onJobSelected:N,linkedEntityHints:b=[]}){var ge;const k=Pe(),u=Oe(),[m,A]=p.useState("files"),[w,E]=p.useState(o),[h,P]=p.useState(""),[s,v]=p.useState(""),[F,g]=p.useState(""),[Q,Z]=p.useState([]),[Ee,R]=p.useState(!1),[Ie,Se]=p.useState(!1),I=p.useMemo(()=>f.filter(t=>t.enabled&&!!t.secretId),[f]),[W,ne]=p.useState(((ge=I[0])==null?void 0:ge.id)??""),[U,Te]=p.useState("auto"),[Y,le]=p.useState({}),[O,S]=p.useState(null),[B,T]=p.useState(null),oe=p.useRef({});p.useEffect(()=>{o&&E(o)},[o]),p.useEffect(()=>{var t;!W&&((t=I[0])!=null&&t.id)&&ne(I[0].id)},[W,I]);const M=I.find(t=>t.id===W)??I[0]??null,L=re({queryKey:["forge-wiki-ingest-job",x],queryFn:()=>tt(x),enabled:i&&!!x,refetchInterval:t=>{const d=t.state.data;return d&&$.has(d.job.status)?2e3:!1}});p.useEffect(()=>{const t=L.data;t&&le(d=>{const l={};for(const K of t.candidates)l[K.id]=d[K.id]??(K.status==="rejected"?{action:"discard"}:{action:"keep"});return l})},[L.data]),p.useEffect(()=>{B&&T(null)},[Y,B]);const X=D({mutationFn:async t=>Be(t),onSuccess:(t,d)=>{t.job&&u.setQueryData(["forge-wiki-ingest-job",d],t.job),u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]})}});p.useEffect(()=>{const t=L.data;if(!t||!$.has(t.job.status))return;const d=t.logs.reduce((ve,Ae)=>{const be=Number(new Date(Ae.createdAt));return Number.isFinite(be)?Math.max(ve,be):ve},0),l=Number(new Date(t.job.updatedAt)),K=Math.max(Number.isFinite(l)?l:0,d);if(!Number.isFinite(K)||K<=0)return;const ee=Date.now();if(!(ee-K>=Ne)||X.isPending)return;const _e=oe.current[t.job.id]??0;ee-_e<Ne||(oe.current[t.job.id]=ee,X.mutate(t.job.id))},[L.data,X]);const de=D({mutationFn:async()=>{if(!M)throw new Error("Set up an OpenAI wiki ingest profile first. Forge now requires an LLM profile before auto-ingest can turn source material into draft pages and entities.");if(m==="files"){if(Q.length===0)throw new Error("Select at least one file to ingest.");return Ge({files:Q,spaceId:w||void 0,titleHint:h.trim()||void 0,llmProfileId:M.id,parseStrategy:U,createAsKind:"wiki",linkedEntityHints:b})}if(m==="url"){if(!s.trim())throw new Error("Enter a URL to ingest.");return ye({spaceId:w||void 0,titleHint:h.trim()||void 0,sourceKind:"url",sourceUrl:s.trim(),llmProfileId:M.id,parseStrategy:U,createAsKind:"wiki",linkedEntityHints:b})}if(!F.trim())throw new Error("Paste some text to ingest.");return ye({spaceId:w||void 0,titleHint:h.trim()||void 0,sourceKind:"raw_text",sourceText:F,mimeType:"text/plain",llmProfileId:M.id,parseStrategy:U,createAsKind:"wiki",linkedEntityHints:b})},onSuccess:async t=>{var l;const d=((l=t.job)==null?void 0:l.job.id)??null;await u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),await u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),d&&N(d),S(null),T(null)},onError:t=>{S(t instanceof Error?t.message:"Unable to start ingest.")}}),ce=D({mutationFn:async()=>{if(!x||!L.data)throw new Error("Choose an ingest job first.");const t=L.data.candidates.map(d=>{const l=Y[d.id]??{action:"keep"};if(l.action==="map_existing"&&(!l.mappedEntityType||!l.mappedEntityId))throw new Error(`Choose an existing ${String(d.payload.entityType??"entity").replaceAll("_"," ")} before publishing the review.`);if(l.action==="merge_existing"&&!l.targetNoteId)throw new Error(`Choose an existing wiki page before publishing the review for ${d.title||"this page candidate"}.`);return l.action==="map_existing"?{candidateId:d.id,action:"map_existing",mappedEntityType:l.mappedEntityType,mappedEntityId:l.mappedEntityId}:l.action==="merge_existing"?{candidateId:d.id,action:"merge_existing",targetNoteId:l.targetNoteId}:{candidateId:d.id,action:l.action}});return He({jobId:x,decisions:t})},onSuccess:async t=>{T(null),u.setQueryData(["forge-wiki-ingest-job",t.job.job.id],t.job),await Promise.all([u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-job",t.job.job.id]}),u.invalidateQueries({queryKey:["forge-wiki-home"]}),u.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),u.invalidateQueries({queryKey:["forge-wiki-tree"]})])},onError:t=>{T(t instanceof Error?t.message:"Unable to publish review.")}}),ue=D({mutationFn:async()=>{if(!x)throw new Error("Choose an ingest job first.");return Ve(x)},onSuccess:async t=>{var l;const d=((l=t.job)==null?void 0:l.job.id)??null;await Promise.all([u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-job",x]})]),d&&N(d),S(null),T(null)},onError:t=>{S(t instanceof Error?t.message:"Unable to rerun ingest.")}}),me=D({mutationFn:async()=>{if(!x)throw new Error("Choose an ingest job first.");return Ze(x)},onSuccess:async()=>{await Promise.all([u.invalidateQueries({queryKey:["forge-wiki-ingest-jobs"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-history"]}),u.invalidateQueries({queryKey:["forge-wiki-ingest-job",x]})]),xe(),S(null),T(null)},onError:t=>{S(t instanceof Error?t.message:"Unable to delete ingest.")}}),n=L.data??null,Ce=n&&!$.has(n.job.status),J=p.useMemo(()=>(n==null?void 0:n.candidates.filter(t=>["suggested","rejected","failed"].includes(t.status)))??[],[n]),pe=p.useMemo(()=>st((n==null?void 0:n.logs)??[]),[n==null?void 0:n.logs]),xe=()=>{N(null),Z([]),v(""),g(""),P(""),S(null),T(null)};return e.jsx(qe,{open:i,onOpenChange:t=>{a(t),t||(S(null),T(null))},children:e.jsxs(ze,{children:[e.jsx(De,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(Qe,{className:"fixed inset-x-4 bottom-4 top-4 z-50 mx-auto flex max-w-[min(74rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] shadow-[var(--ui-shadow-floating)]",children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"KarpaWiki Ingest"}),e.jsx(Re,{className:"mt-2 font-display text-[1.5rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:n?"Ingest review and progress":"Build KarpaWiki memory from source files"}),e.jsx(We,{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Upload notes, media, ZIP archives, links, or pasted text. Forge will process them in the background, propose pages and entities, and let you keep only what belongs."})]}),e.jsx(Ue,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close ingest modal",children:e.jsx(se,{className:"size-4"})})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-5",children:n?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Job ",n.job.id]}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:n.job.latestMessage||"Ingest job"}),e.jsxs("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:[n.job.status," · ",n.job.phase," · started ",ke(n.job.createdAt)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{variant:"secondary",size:"sm",onClick:xe,children:"New ingest"}),Ce?e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"secondary",size:"sm",pending:ue.isPending,pendingLabel:"Rerunning",onClick:()=>void ue.mutateAsync(),children:[e.jsx(G,{className:"size-3.5"}),"Rerun"]}),e.jsx(C,{variant:"ghost",size:"sm",className:"border border-rose-300/18 bg-rose-400/10 text-rose-100 hover:bg-rose-400/16",pending:me.isPending,pendingLabel:"Deleting",onClick:()=>{window.confirm("Delete this ingest history entry? Published pages or entities will stay, but discarded or unreviewed ingest data will be removed.")&&me.mutateAsync()},children:"Delete"})]}):null]})]}),e.jsx("div",{className:"mt-5 grid gap-3 sm:grid-cols-4",children:[{label:"Progress",value:`${n.job.progressPercent}%`},{label:"Files",value:`${n.job.processedFiles}/${n.job.totalFiles}`},{label:"Pages",value:String(n.job.createdPageCount)},{label:"Entities",value:String(n.job.createdEntityCount)}].map(t=>e.jsxs("div",{className:c("rounded-[22px] border px-4 py-3",z),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.label}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:t.value})]},t.label))}),e.jsx("div",{className:"mt-5",children:e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:e.jsx("div",{className:"h-full rounded-full bg-[var(--primary)] transition-all duration-300",style:{width:`${n.job.progressPercent}%`}})})}),O?e.jsx("div",{className:"mt-4 rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:O}):null]}),e.jsxs("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Rich log"}),e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>k(`/settings/logs?jobId=${encodeURIComponent(n.job.id)}`),children:"Open full logs"})]}),e.jsx("div",{className:"mt-4 grid max-h-[28rem] gap-2 overflow-y-auto",children:pe.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm text-[var(--ui-ink-faint)]",children:"Waiting for the backend to emit progress."}):pe.map(t=>e.jsx("div",{className:c("rounded-[18px] border px-4 py-3",z),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--ui-ink-soft)]",children:t.level}),typeof t.metadata.scope=="string"?e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.metadata.scope}):null,typeof t.metadata.eventKey=="string"?e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.metadata.eventKey}):null]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-strong)]",children:y(t.metadata,"eventKey")==="llm_compile_background_polled"?it(t,t.repetitionCount):t.message}),t.repetitionCount>1?e.jsxs("div",{className:"mt-2 text-xs text-[var(--ui-ink-faint)]",children:["Combined ",t.repetitionCount," repeated polling updates."]}):null,Object.keys(t.metadata).length>0?e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-[var(--ui-ink-faint)]",children:"View metadata"}),e.jsx("pre",{className:"mt-2 max-w-full overflow-x-auto whitespace-pre-wrap rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-code)] px-3 py-3 text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:JSON.stringify(t.metadata,null,2)})]}):null]}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:ke(t.createdAt)})]})},t.id))})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Source files"}),e.jsx("div",{className:"mt-4 grid gap-2",children:n.assets.map(t=>e.jsxs("div",{className:c("flex min-w-0 items-center justify-between gap-3 rounded-[18px] border px-4 py-3",z),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:t.fileName||t.sourceLocator||"Source"}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:t.mimeType||t.sourceKind})]}),e.jsx("div",{className:"shrink-0 text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.status})]},t.id))})]}),e.jsxs("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Review"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Keep the candidates that belong in Forge and discard the rest."})]}),$.has(n.job.status)?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx($e,{className:"size-3.5 animate-spin"}),"Processing"]}):null]}),e.jsx("div",{className:"mt-4 grid gap-3",children:J.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm text-[var(--ui-ink-faint)]",children:$.has(n.job.status)?"Candidates will appear here while the job progresses.":"This job has no reviewable candidates left."}):J.map(t=>e.jsx(lt,{candidate:t,spaceId:n.job.spaceId,decision:Y[t.id]??{action:"keep"},onDecisionChange:d=>le(l=>({...l,[t.id]:d}))},t.id))}),B?e.jsx("div",{className:"mt-4 rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:B}):null,J.length>0&&!$.has(n.job.status)?e.jsx("div",{className:"mt-5",children:e.jsxs(C,{className:"min-h-12",pending:ce.isPending,pendingLabel:"Publishing review",onClick:()=>void ce.mutateAsync(),children:[e.jsx(fe,{className:"size-4"}),"Publish kept candidates"]})}):null]})]})]}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(18rem,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[{id:"files",label:"Files and ZIP",detail:"Drag many files or one archive.",icon:te},{id:"url",label:"URL",detail:"Pull a webpage or remote file.",icon:Le},{id:"text",label:"Paste text",detail:"Turn notes or transcripts into pages.",icon:Ke}].map(t=>{const d=t.icon,l=t.id===m;return e.jsxs("button",{type:"button",className:c("rounded-[24px] border px-4 py-4 text-left transition",l?q:H),onClick:()=>A(t.id),children:[e.jsx(d,{className:"size-4 text-[var(--secondary)]"}),e.jsx("div",{className:"mt-3 text-sm font-semibold",children:t.label}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:t.detail})]},t.id)})}),e.jsx("div",{className:c("rounded-[28px] border p-4 sm:p-5",j),children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(je,{value:h,onChange:t=>P(t.target.value),placeholder:"Optional title hint"}),m==="files"?e.jsxs("div",{className:c("rounded-[28px] border-2 border-dashed px-5 py-8 text-center transition",Ee?"border-[color-mix(in_srgb,var(--primary)_36%,transparent)] bg-[var(--ui-accent-soft)]":j),onDragEnter:t=>{t.preventDefault(),R(!0)},onDragLeave:t=>{t.preventDefault(),R(!1)},onDragOver:t=>{t.preventDefault(),R(!0)},onDrop:t=>{t.preventDefault(),R(!1);const d=Array.from(t.dataTransfer.files);Z(l=>[...l,...d])},children:[e.jsx("div",{className:"mx-auto flex size-14 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:e.jsx(te,{className:"size-5 text-[var(--ui-ink-medium)]"})}),e.jsx("div",{className:"mt-4 text-base font-semibold text-[var(--ui-ink-strong)]",children:"Drop files, media, notes, or ZIP archives here"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-faint)]",children:"Forge accepts many files at once and queues the ingest in the background so the UI stays responsive."}),e.jsxs("label",{className:"mt-5 inline-flex cursor-pointer items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-2 text-sm text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",children:[e.jsx(te,{className:"size-4"}),"Choose files",e.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:t=>Z(Array.from(t.target.files??[]))})]}),Q.length>0?e.jsx("div",{className:"mt-5 grid gap-2 text-left",children:Q.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] border ${INGEST_PANEL_CLASS} px-4 py-3 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx("span",{className:"truncate",children:t.name}),e.jsx("span",{className:"shrink-0 text-xs text-[var(--ui-ink-faint)]",children:t.name.toLowerCase().endsWith(".zip")?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Fe,{className:"size-3.5"}),"ZIP"]}):`${Math.max(1,Math.round(t.size/1024))} KB`})]},`${t.name}-${t.size}-${t.lastModified}`))}):null]}):null,m==="url"?e.jsx(je,{value:s,onChange:t=>v(t.target.value),placeholder:"https://example.com/source"}):null,m==="text"?e.jsx(Ye,{value:F,onChange:t=>g(t.target.value),placeholder:"Paste notes, transcripts, meeting writeups, or source material here…",className:"min-h-[18rem]"}):null]})})]}),e.jsxs("aside",{className:"grid h-fit gap-4",children:[M?null:e.jsxs("div",{className:"rounded-[30px] border border-[color-mix(in_srgb,var(--warning)_30%,transparent)] bg-[var(--ui-warning-soft)] p-5 shadow-[var(--ui-shadow-card)]",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-full border border-amber-200/20 bg-amber-300/12 text-amber-100",children:e.jsx(Me,{className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-amber-100/62",children:"OpenAI setup required for smart ingest"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Forge can only do a raw import without OpenAI"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Without an OpenAI ingest profile, Forge cannot extract key insights, split the source into draft wiki pages, or propose Forge entities. The fallback is just a direct text import or media reference with no structured synthesis."}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Set up the API key, model, thinking, and verbosity first, then come back here to build real draft pages and reviewable entity proposals."})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-2",children:[e.jsxs(C,{className:"w-full",onClick:()=>{a(!1),k("/settings/wiki?setupLlm=1")},children:[e.jsx(G,{className:"size-4"}),"Open OpenAI setup"]}),e.jsx(C,{variant:"secondary",className:"w-full",onClick:()=>{a(!1),k("/settings/wiki")},children:"Open KarpaWiki settings"})]})]}),e.jsxs("div",{className:"rounded-[28px] border ${INGEST_PANEL_CLASS} p-4",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-3 text-left",onClick:()=>Se(t=>!t),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Advanced"}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-medium)]",children:"Model, parse, and target controls."})]}),e.jsx(G,{className:"size-4 text-[var(--ui-ink-soft)]"})]}),Ie?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Space"}),e.jsx("div",{className:"grid gap-2",children:r.map(t=>e.jsxs("button",{type:"button",className:c("rounded-[18px] border px-3 py-3 text-left text-sm transition",w===t.id?q:H),onClick:()=>E(t.id),children:[e.jsx("div",{children:t.label}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:t.description||`/${t.slug}`})]},t.id))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"LLM profile"}),e.jsxs("div",{className:"grid gap-2",children:[I.map(t=>e.jsxs("button",{type:"button",className:c("rounded-[18px] border px-3 py-3 text-left text-sm transition",W===t.id?q:H),onClick:()=>ne(t.id),children:[e.jsx("div",{children:t.label}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:t.model})]},t.id)),I.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm text-[var(--ui-ink-faint)]",children:"No enabled profile with a saved key yet."}):null]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Parse mode"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:[{id:"auto",label:"Auto"},{id:"multimodal",label:"Multimodal"},{id:"text_only",label:"Text only"}].map(t=>e.jsx("button",{type:"button",className:c("rounded-[18px] border px-3 py-3 text-sm transition",U===t.id?q:H),onClick:()=>Te(t.id),children:t.label},t.id))})]})]}):null]}),e.jsxs("div",{className:"rounded-[28px] border border-[color-mix(in_srgb,var(--primary)_24%,transparent)] bg-[var(--ui-accent-soft)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(fe,{className:"size-4 text-[var(--secondary)]"}),e.jsx("span",{className:"text-sm font-semibold",children:"Publish only what belongs"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge stages candidate pages, proposed entity records, and page updates first. You review the output before anything is committed to the live memory graph."})]}),O?e.jsx("div",{className:"rounded-[20px] border border-rose-300/22 bg-rose-400/10 px-4 py-3 text-sm text-rose-100",children:O}):null,e.jsxs(C,{className:"min-h-12",pending:de.isPending,pendingLabel:"Starting ingest",disabled:!M,onClick:()=>void de.mutateAsync(),children:[e.jsx(G,{className:"size-4"}),"Start background ingest"]})]})]})})]})]})})}export{pt as W};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b6 as Se,c6 as Ee,bY as We,r as c,j as e,b7 as Pe,cs as O,aG as ie,cB as Re,cG as ze,c1 as Ke,bX as $e,aC as le,aK as ce,bG as Le,cv as qe}from"./vendor-Cpmju3nw.js";import{R as de,P as ue,O as pe,C as me,T as xe,a as ge,D as Te}from"./ui-B9O-eUim.js";import{j as Ue,i as K,k as Fe}from"./state-BtwEvpO6.js";import{d as Be,W as De,a_ as Oe,L as D,e as ne,h as Me,b as oe,V as Qe,B as T,c as w,c8 as Je,I as _e,k as Ae,ek as He,bn as Ge,el as Ye,em as Ve,en as Xe,eo as Ze}from"./index-BaiwtAgo.js";import{O as es}from"./open-in-graph-button-D31ZOEhA.js";import{W as ss}from"./wiki-article-markdown-DxTkiQRy.js";import{W as ts}from"./wiki-ingest-modal-D6xs2sEn.js";import"./motion-DwjmC9aq.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";function rs(a){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(new Date(a))}function as(a){return a.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function he({nodes:a,activeSlug:i,spaceId:u,depth:n=0}){return e.jsx("ul",{className:w("grid gap-1",n>0&&"mt-1"),children:a.map(d=>e.jsx(is,{node:d,activeSlug:i,spaceId:u,depth:n},d.page.id))})}function fe(a,i){return i?a.page.slug===i?!0:a.children.some(u=>fe(u,i)):!1}function is({node:a,activeSlug:i,spaceId:u,depth:n}){const d=a.children.length>0,f=a.page.slug===i,x=fe(a,i),[l,b]=c.useState(d&&(n===0||x));return c.useEffect(()=>{x&&b(!0)},[x]),e.jsxs("li",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex items-start gap-1",children:[d?e.jsx("button",{type:"button",className:w("mt-1 inline-flex size-5 shrink-0 items-center justify-center rounded-md text-[var(--ui-ink-faint)] transition hover:bg-[var(--ui-surface-1)] hover:text-[var(--ui-ink-strong)]",n>0&&"size-4"),style:{marginLeft:`${n*.7}rem`},"aria-label":l?`Collapse ${a.page.title}`:`Expand ${a.page.title}`,"aria-expanded":l,onClick:()=>b(N=>!N),children:l?e.jsx(O,{className:"size-3.5"}):e.jsx(qe,{className:"size-3.5"})}):e.jsx("span",{className:"mt-1 size-5 shrink-0",style:{marginLeft:`${n*.7}rem`}}),e.jsx(le,{to:{pathname:a.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(a.page.slug)}`,search:`?spaceId=${encodeURIComponent(u)}`},className:w("min-w-0 flex-1 rounded-lg px-2 py-1.5 text-[12px] leading-5 transition",f?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-1)] hover:text-[var(--ui-ink-strong)]"),children:e.jsx("span",{className:"line-clamp-2",children:a.page.title})})]}),d&&l?e.jsx(he,{nodes:a.children,activeSlug:i,spaceId:u,depth:n+1}):null]})}function ns({open:a,onOpenChange:i,spaces:u,activeSpaceId:n,onSelect:d}){var x;const f=((x=u.find(l=>l.visibility==="shared"))==null?void 0:x.id)??"";return e.jsx(de,{open:a,onOpenChange:i,children:e.jsxs(ue,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(me,{className:"fixed left-1/2 top-[14vh] z-50 w-[min(28rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-4 shadow-[var(--ui-shadow-floating)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"font-display text-[1.2rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:"Choose KarpaWiki space"}),e.jsx(Te,{className:"mt-1 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:"Switch the reading space without leaving the article surface."})]}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close space picker",children:e.jsx(ce,{className:"size-4"})})})]}),e.jsx("div",{className:"mt-4 grid gap-2",children:u.map(l=>{const b=l.id===n,N=l.id===f;return e.jsxs("button",{type:"button",className:w("flex items-center justify-between gap-3 rounded-[22px] border px-4 py-3 text-left transition",b?"border-[color-mix(in_srgb,var(--primary)_26%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>{d(l.id),i(!1)},children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[14px] font-semibold text-inherit",children:l.label}),e.jsx("span",{className:"mt-1 block text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:l.description||`/${l.slug}`}),N?e.jsx("span",{className:"mt-2 inline-flex rounded-full bg-amber-200/90 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-stone-950",children:"Recovered pages"}):null]}),b?e.jsx(Le,{className:"size-4 shrink-0 text-[var(--primary)]"}):null]},l.id)})})]})]})})}function fs(){var H,G,Y,V,X,Z,ee,se,te,re;const a=Be(),i=Se(),u=Ue(),{slug:n}=Ee(),[d,f]=We(),[x,l]=c.useState(!1),[b,N]=c.useState(!1),[U,E]=c.useState(!1),[v,be]=c.useState("hybrid"),[W,ve]=c.useState(""),[P,M]=c.useState(""),Q=c.useRef(null),F=d.get("spaceId")??"",ke=d.get("ingest")==="1",J=d.get("ingestJobId"),p=K({queryKey:["forge-wiki-settings"],queryFn:Ge}),t=F||((G=(H=p.data)==null?void 0:H.settings.spaces[0])==null?void 0:G.id)||"",R=((Y=p.data)==null?void 0:Y.settings.embeddingProfiles.filter(s=>s.enabled))??[];c.useEffect(()=>{var s;!P&&((s=R[0])!=null&&s.id)&&M(R[0].id)},[R,P]),c.useEffect(()=>{var s,o;if(!F&&((o=(s=p.data)==null?void 0:s.settings.spaces[0])!=null&&o.id)){const g=new URLSearchParams(d);g.set("spaceId",p.data.settings.spaces[0].id),f(g,{replace:!0})}},[d,F,f,p.data]);const I=K({queryKey:["forge-wiki-home",t],queryFn:()=>Ye({spaceId:t||void 0}),enabled:!!t&&!n}),h=K({queryKey:["forge-wiki-page-by-slug",t,n],queryFn:()=>Ve({slug:n??"index",spaceId:t||void 0}),enabled:!!t&&!!n}),z=K({queryKey:["forge-wiki-tree",t],queryFn:()=>Xe({spaceId:t||void 0,kind:"wiki"}),enabled:!!t}),C=K({queryKey:["forge-wiki-modal-search",t,v,W,P],queryFn:()=>Ze({spaceId:t||void 0,mode:v,query:W.trim(),profileId:(v==="semantic"||v==="hybrid")&&P||void 0,limit:30}),enabled:x&&!!t&&W.trim().length>0}),$=n?h.data??null:I.data??null,[ye,je]=c.useState(null);c.useEffect(()=>{$&&je($)},[$]);const L=!!t&&(n?h.isFetching:I.isFetching),k=$??(L?ye:null),r=(k==null?void 0:k.page)??null,m=((V=p.data)==null?void 0:V.settings.spaces.find(s=>s.id===t))??null,y=((X=p.data)==null?void 0:X.settings.spaces.find(s=>s.visibility==="shared"))??null,we=!!y&&!!m&&(m==null?void 0:m.id)!==(y==null?void 0:y.id)&&(m==null?void 0:m.visibility)==="personal",q=(r==null?void 0:r.slug)!=="index",j=n&&h.error instanceof De&&h.error.status===404?n.trim():null;c.useEffect(()=>{if(!t||!j)return;const s=new URLSearchParams;s.set("spaceId",t),s.set("title",j);const o=as(j);o&&s.set("slug",o),i(`/wiki/new?${s.toString()}`,{replace:!0})},[t,j,i]);const _=c.useMemo(()=>((r==null?void 0:r.links)??[]).map(s=>({id:`${s.entityType}:${s.entityId}`,href:Oe(s.entityType,s.entityId),label:`${s.entityType} · ${s.entityId}`})),[r==null?void 0:r.links]),S=Fe({mutationFn:async s=>He(s),onSuccess:async()=>{await Promise.all([u.invalidateQueries({queryKey:["forge-wiki-tree"]}),u.invalidateQueries({queryKey:["forge-wiki-home"]}),u.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),u.invalidateQueries({queryKey:["forge-wiki-modal-search"]})]),i(`/wiki${t?`?spaceId=${encodeURIComponent(t)}`:""}`)}}),B=(s,o=!1)=>{const g=new URLSearchParams(d);s(g),f(g,{replace:o})},A=s=>{B(o=>{o.set("ingest","1"),s?o.set("ingestJobId",s):o.delete("ingestJobId"),t&&o.set("spaceId",t)})},Ne=()=>{B(s=>{s.delete("ingest"),s.delete("ingestJobId")})},Ie=s=>{B(o=>{o.set("ingest","1"),s?o.set("ingestJobId",s):o.delete("ingestJobId"),t&&o.set("spaceId",t)})},Ce=()=>{!r||!q||S.isPending||!window.confirm(`Delete KarpaWiki page "${r.title}"? You can restore it later from the bin.`)||S.mutateAsync(r.id)};return c.useEffect(()=>{if(!U)return;const s=g=>{var ae;(ae=Q.current)!=null&&ae.contains(g.target)||E(!1)},o=g=>{g.key==="Escape"&&E(!1)};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",o)}},[U]),!r&&(p.isLoading||z.isLoading||!n&&I.isLoading||n&&h.isLoading)?e.jsx(D,{eyebrow:"KarpaWiki",title:"Loading the article",description:"Preparing the current space, article, and KarpaWiki index."}):!r&&!j&&(p.isError||I.isError||h.isError||z.isError)?e.jsx(ne,{eyebrow:"KarpaWiki",error:p.error??I.error??h.error??z.error,onRetry:()=>{p.refetch(),I.refetch(),h.refetch(),z.refetch()}}):r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-4 sm:px-5 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1680px] flex-col gap-4",children:[e.jsxs("section",{className:"wiki-frame px-3 py-3 sm:px-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(oe,{kind:"wiki_page",label:"KarpaWiki page",compact:!0,gradient:!1}),m?e.jsx(oe,{kind:"wiki_space",label:m.label,compact:!0,gradient:!1,wrap:!0,className:"max-w-[20rem]"}):null,e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:rs(r.updatedAt)}),e.jsx(Qe,{metrics:a.snapshot.metrics,className:"ml-auto"})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2 lg:flex-row lg:items-center",children:[e.jsxs("button",{type:"button",className:"wiki-search-launch flex min-h-[2.9rem] w-full items-center gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 text-left text-[14px] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)] lg:flex-1",onClick:()=>l(!0),children:[e.jsx(Pe,{className:"size-4 shrink-0 text-[var(--ui-ink-faint)]"}),e.jsx("span",{children:"Search KarpaWiki"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:shrink-0",children:[e.jsxs("button",{type:"button",className:"wiki-space-trigger inline-flex min-h-[2.9rem] items-center gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 text-[13px] font-medium text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",onClick:()=>N(!0),children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Space"}),e.jsx("span",{className:"max-w-[16rem] truncate",children:(m==null?void 0:m.label)??"KarpaWiki space"}),e.jsx(O,{className:"size-3.5 text-[var(--ui-ink-faint)]"})]}),e.jsxs("div",{className:"relative",ref:Q,children:[e.jsxs(T,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>E(s=>!s),children:[e.jsx(ie,{className:"size-3.5"}),"Ingest",e.jsx(O,{className:"size-3.5"})]}),U?e.jsxs("div",{className:"absolute right-0 top-[calc(100%+0.5rem)] z-20 grid min-w-[15rem] gap-2 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-floating)]",children:[e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{E(!1),A()},children:[e.jsx(ie,{className:"mt-0.5 size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--ui-ink-strong)]",children:"New ingest"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Start a fresh import from files, URLs, or pasted text."})]})]}),e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{E(!1),i(`/wiki/ingest-history${t?`?spaceId=${encodeURIComponent(t)}`:""}`)},children:[e.jsx(Re,{className:"mt-0.5 size-4 shrink-0 text-[var(--secondary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--ui-ink-strong)]",children:"History"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Browse prior ingests, reopen reviews, and delete old ingest records."})]})]})]}):null]}),e.jsxs(T,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>i(`/wiki/edit/${encodeURIComponent(r.id)}?spaceId=${encodeURIComponent(t)}`,{state:{initialPage:r}}),children:[e.jsx(ze,{className:"size-3.5"}),"Edit"]}),e.jsx(es,{entityType:"note",entityId:r.id,label:"Open in graph",size:"sm"}),e.jsxs(T,{variant:"secondary",size:"sm",className:w("min-h-[2.9rem] border border-rose-400/18 bg-rose-500/10 text-rose-100 hover:bg-rose-500/18",!q&&"opacity-60"),onClick:Ce,pending:S.isPending,pendingLabel:"Deleting",disabled:!q,title:q?"Delete this KarpaWiki page":"The KarpaWiki home page cannot be deleted",children:[e.jsx(Ke,{className:"size-3.5"}),"Delete"]}),e.jsxs(T,{size:"sm",className:"min-h-[2.9rem]",onClick:()=>i(`/wiki/new?spaceId=${encodeURIComponent(t)}`),children:[e.jsx($e,{className:"size-3.5"}),"New page"]})]})]}),we&&y?e.jsxs("div",{className:"mt-3 flex flex-col gap-3 rounded-[22px] border border-amber-300/20 bg-amber-300/[0.08] px-4 py-3 text-[13px] leading-6 text-amber-50 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["You are viewing the personal starter wiki. The recovered people, story, and conversation pages are in"," ",e.jsx("strong",{children:y.label}),"."]}),e.jsx("button",{type:"button",className:"inline-flex min-h-10 shrink-0 items-center justify-center rounded-2xl bg-amber-200 px-4 text-[12px] font-semibold uppercase tracking-[0.14em] text-stone-950 transition hover:bg-amber-100",onClick:()=>{i({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(y.id)}`})},children:"Open shared memory"})]}):null]}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[15rem_minmax(0,1fr)] xl:grid-cols-[16rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"wiki-frame h-fit px-2 py-3 sm:px-3 lg:sticky lg:top-[5.75rem]",children:[e.jsx("div",{className:"px-2 pb-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Index"}),e.jsx(he,{nodes:((Z=z.data)==null?void 0:Z.tree)??[],activeSlug:r.slug,spaceId:t})]}),e.jsxs("article",{"aria-busy":L,className:w("wiki-frame relative overflow-hidden px-4 py-5 transition-[opacity,transform] duration-200 sm:px-6 sm:py-6",L&&"opacity-[0.985]"),children:[L?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-[color-mix(in_srgb,var(--primary)_70%,transparent)] opacity-90"}):null,e.jsxs("div",{className:"wiki-reading-copy wiki-reading-flow mx-auto max-w-[76rem]",children:[S.isError?e.jsx("div",{className:"mb-4 rounded-[18px] border border-rose-400/20 bg-rose-500/10 px-4 py-3 text-sm text-rose-100",children:S.error instanceof Error?S.error.message:"Forge could not delete this KarpaWiki page."}):null,e.jsx(ss,{markdown:r.contentMarkdown,spaceId:t}),r.summary.trim()?e.jsx("p",{className:"mt-5 border-t border-[var(--ui-border-subtle)] pt-4 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:r.summary}):null,_.length>0?e.jsxs("section",{className:"mt-8 border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Forge links"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:_.map(s=>e.jsx("a",{href:s.href?Je(s.href):void 0,className:"rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-3)] hover:text-[var(--ui-ink-strong)]",children:s.label},s.id))})]}):null,k!=null&&k.backlinkSourceNotes.length?e.jsxs("section",{className:"mt-8 border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked here"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:k.backlinkSourceNotes.map(s=>e.jsxs(le,{to:{pathname:s.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(s.slug)}`,search:`?spaceId=${encodeURIComponent(s.spaceId)}`},className:"rounded-xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"text-[13px] font-semibold text-[var(--ui-ink-strong)]",children:s.title}),s.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:s.summary}):null]},s.id))})]}):null]})]})]})]})}),e.jsx(de,{open:x,onOpenChange:l,children:e.jsxs(ue,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(me,{className:"fixed left-1/2 top-[8vh] z-50 w-[min(54rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-4 shadow-[var(--ui-shadow-floating)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{children:e.jsx(xe,{className:"font-display text-[1.35rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:"Search the wiki"})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close search",children:e.jsx(ce,{className:"size-4"})})})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx(_e,{autoFocus:!0,value:W,onChange:s=>ve(s.target.value),placeholder:"Search KarpaWiki pages",className:"h-11 rounded-2xl border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[14px] text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)]"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[["text","hybrid","semantic","entity"].map(s=>e.jsx("button",{type:"button",className:w("rounded-full px-3 py-1.5 text-[12px] font-medium uppercase tracking-[0.14em] transition",v===s?"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>be(s),children:s},s)),(v==="semantic"||v==="hybrid")&&R.length>0?e.jsx("select",{className:"ml-auto rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-strong)]",value:P,onChange:s=>M(s.target.value),children:R.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))}):null]})]}),e.jsx("div",{className:"mt-4 max-h-[60vh] overflow-y-auto",children:W.trim()?C.isLoading?e.jsx(D,{eyebrow:"KarpaWiki search",title:"Searching",description:"Ranking matching pages for this query."}):C.isError?e.jsx(ne,{eyebrow:"KarpaWiki search",error:C.error,onRetry:()=>void C.refetch()}):(ee=C.data)!=null&&ee.results.length?e.jsx("div",{className:"grid gap-2",children:C.data.results.map(s=>e.jsx("button",{type:"button",className:"rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{l(!1),i({pathname:s.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(s.page.slug)}`,search:`?spaceId=${encodeURIComponent(s.page.spaceId)}`})},children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-semibold text-[var(--ui-ink-strong)]",children:s.page.title}),s.page.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:s.page.summary}):null]}),e.jsx(Ae,{size:"sm",tone:"meta",children:s.score.toFixed(2)})]})},s.page.id))}):e.jsx("div",{className:"rounded-2xl border border-dashed border-[var(--ui-border-subtle)] px-4 py-10 text-center text-[13px] leading-6 text-[var(--ui-ink-faint)]",children:"No pages matched this search."}):e.jsx("div",{className:"rounded-2xl border border-dashed border-[var(--ui-border-subtle)] px-4 py-10 text-center text-[13px] leading-6 text-[var(--ui-ink-faint)]",children:"Start typing to search the current KarpaWiki space."})})]})]})}),e.jsx(ns,{open:b,onOpenChange:N,spaces:((se=p.data)==null?void 0:se.settings.spaces)??[],activeSpaceId:t,onSelect:s=>{i({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(s)}`},{replace:!0})}}),e.jsx(ts,{open:ke,onOpenChange:s=>{if(s){A(J);return}Ne()},spaces:((te=p.data)==null?void 0:te.settings.spaces)??[],llmProfiles:((re=p.data)==null?void 0:re.settings.llmProfiles)??[],initialSpaceId:t,selectedJobId:J,onJobSelected:Ie,linkedEntityHints:r.links.map(s=>({entityType:s.entityType,entityId:s.entityId,anchorKey:null}))??[]})]}):j?e.jsx(D,{eyebrow:"KarpaWiki",title:"Opening a new page",description:`Creating a draft for ${j}.`}):e.jsx(Me,{eyebrow:"KarpaWiki",title:"Article not found",description:"This page does not exist in the selected space."})}export{fs as WikiPage};
|
|
1
|
+
import{b6 as Se,c6 as Ee,bY as We,r as c,j as e,b7 as Pe,cs as O,aG as ie,cB as Re,cG as ze,c1 as Ke,bX as $e,aC as le,aK as ce,bG as Le,cv as qe}from"./vendor-BwL6m4SE.js";import{R as de,P as ue,O as pe,C as me,T as xe,a as ge,D as Te}from"./ui-B9TWEtCx.js";import{j as Ue,i as K,k as Fe}from"./state-Bpe5dF3T.js";import{d as Be,W as De,a_ as Oe,L as D,e as ne,h as Me,b as oe,V as Qe,B as T,c as w,c8 as Je,I as _e,k as Ae,ek as He,bn as Ge,el as Ye,em as Ve,en as Xe,eo as Ze}from"./index-CQ5r7ZUz.js";import{O as es}from"./open-in-graph-button-C-bJekoH.js";import{W as ss}from"./wiki-article-markdown-CvaCjg_t.js";import{W as ts}from"./wiki-ingest-modal-BW6AJPea.js";import"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function rs(a){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(new Date(a))}function as(a){return a.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function he({nodes:a,activeSlug:i,spaceId:u,depth:n=0}){return e.jsx("ul",{className:w("grid gap-1",n>0&&"mt-1"),children:a.map(d=>e.jsx(is,{node:d,activeSlug:i,spaceId:u,depth:n},d.page.id))})}function fe(a,i){return i?a.page.slug===i?!0:a.children.some(u=>fe(u,i)):!1}function is({node:a,activeSlug:i,spaceId:u,depth:n}){const d=a.children.length>0,f=a.page.slug===i,x=fe(a,i),[l,b]=c.useState(d&&(n===0||x));return c.useEffect(()=>{x&&b(!0)},[x]),e.jsxs("li",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex items-start gap-1",children:[d?e.jsx("button",{type:"button",className:w("mt-1 inline-flex size-5 shrink-0 items-center justify-center rounded-md text-[var(--ui-ink-faint)] transition hover:bg-[var(--ui-surface-1)] hover:text-[var(--ui-ink-strong)]",n>0&&"size-4"),style:{marginLeft:`${n*.7}rem`},"aria-label":l?`Collapse ${a.page.title}`:`Expand ${a.page.title}`,"aria-expanded":l,onClick:()=>b(N=>!N),children:l?e.jsx(O,{className:"size-3.5"}):e.jsx(qe,{className:"size-3.5"})}):e.jsx("span",{className:"mt-1 size-5 shrink-0",style:{marginLeft:`${n*.7}rem`}}),e.jsx(le,{to:{pathname:a.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(a.page.slug)}`,search:`?spaceId=${encodeURIComponent(u)}`},className:w("min-w-0 flex-1 rounded-lg px-2 py-1.5 text-[12px] leading-5 transition",f?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-1)] hover:text-[var(--ui-ink-strong)]"),children:e.jsx("span",{className:"line-clamp-2",children:a.page.title})})]}),d&&l?e.jsx(he,{nodes:a.children,activeSlug:i,spaceId:u,depth:n+1}):null]})}function ns({open:a,onOpenChange:i,spaces:u,activeSpaceId:n,onSelect:d}){var x;const f=((x=u.find(l=>l.visibility==="shared"))==null?void 0:x.id)??"";return e.jsx(de,{open:a,onOpenChange:i,children:e.jsxs(ue,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(me,{className:"fixed left-1/2 top-[14vh] z-50 w-[min(28rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-4 shadow-[var(--ui-shadow-floating)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"font-display text-[1.2rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:"Choose KarpaWiki space"}),e.jsx(Te,{className:"mt-1 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:"Switch the reading space without leaving the article surface."})]}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close space picker",children:e.jsx(ce,{className:"size-4"})})})]}),e.jsx("div",{className:"mt-4 grid gap-2",children:u.map(l=>{const b=l.id===n,N=l.id===f;return e.jsxs("button",{type:"button",className:w("flex items-center justify-between gap-3 rounded-[22px] border px-4 py-3 text-left transition",b?"border-[color-mix(in_srgb,var(--primary)_26%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>{d(l.id),i(!1)},children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[14px] font-semibold text-inherit",children:l.label}),e.jsx("span",{className:"mt-1 block text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:l.description||`/${l.slug}`}),N?e.jsx("span",{className:"mt-2 inline-flex rounded-full bg-amber-200/90 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-stone-950",children:"Recovered pages"}):null]}),b?e.jsx(Le,{className:"size-4 shrink-0 text-[var(--primary)]"}):null]},l.id)})})]})]})})}function fs(){var H,G,Y,V,X,Z,ee,se,te,re;const a=Be(),i=Se(),u=Ue(),{slug:n}=Ee(),[d,f]=We(),[x,l]=c.useState(!1),[b,N]=c.useState(!1),[U,E]=c.useState(!1),[v,be]=c.useState("hybrid"),[W,ve]=c.useState(""),[P,M]=c.useState(""),Q=c.useRef(null),F=d.get("spaceId")??"",ke=d.get("ingest")==="1",J=d.get("ingestJobId"),p=K({queryKey:["forge-wiki-settings"],queryFn:Ge}),t=F||((G=(H=p.data)==null?void 0:H.settings.spaces[0])==null?void 0:G.id)||"",R=((Y=p.data)==null?void 0:Y.settings.embeddingProfiles.filter(s=>s.enabled))??[];c.useEffect(()=>{var s;!P&&((s=R[0])!=null&&s.id)&&M(R[0].id)},[R,P]),c.useEffect(()=>{var s,o;if(!F&&((o=(s=p.data)==null?void 0:s.settings.spaces[0])!=null&&o.id)){const g=new URLSearchParams(d);g.set("spaceId",p.data.settings.spaces[0].id),f(g,{replace:!0})}},[d,F,f,p.data]);const I=K({queryKey:["forge-wiki-home",t],queryFn:()=>Ye({spaceId:t||void 0}),enabled:!!t&&!n}),h=K({queryKey:["forge-wiki-page-by-slug",t,n],queryFn:()=>Ve({slug:n??"index",spaceId:t||void 0}),enabled:!!t&&!!n}),z=K({queryKey:["forge-wiki-tree",t],queryFn:()=>Xe({spaceId:t||void 0,kind:"wiki"}),enabled:!!t}),C=K({queryKey:["forge-wiki-modal-search",t,v,W,P],queryFn:()=>Ze({spaceId:t||void 0,mode:v,query:W.trim(),profileId:(v==="semantic"||v==="hybrid")&&P||void 0,limit:30}),enabled:x&&!!t&&W.trim().length>0}),$=n?h.data??null:I.data??null,[ye,je]=c.useState(null);c.useEffect(()=>{$&&je($)},[$]);const L=!!t&&(n?h.isFetching:I.isFetching),k=$??(L?ye:null),r=(k==null?void 0:k.page)??null,m=((V=p.data)==null?void 0:V.settings.spaces.find(s=>s.id===t))??null,y=((X=p.data)==null?void 0:X.settings.spaces.find(s=>s.visibility==="shared"))??null,we=!!y&&!!m&&(m==null?void 0:m.id)!==(y==null?void 0:y.id)&&(m==null?void 0:m.visibility)==="personal",q=(r==null?void 0:r.slug)!=="index",j=n&&h.error instanceof De&&h.error.status===404?n.trim():null;c.useEffect(()=>{if(!t||!j)return;const s=new URLSearchParams;s.set("spaceId",t),s.set("title",j);const o=as(j);o&&s.set("slug",o),i(`/wiki/new?${s.toString()}`,{replace:!0})},[t,j,i]);const _=c.useMemo(()=>((r==null?void 0:r.links)??[]).map(s=>({id:`${s.entityType}:${s.entityId}`,href:Oe(s.entityType,s.entityId),label:`${s.entityType} · ${s.entityId}`})),[r==null?void 0:r.links]),S=Fe({mutationFn:async s=>He(s),onSuccess:async()=>{await Promise.all([u.invalidateQueries({queryKey:["forge-wiki-tree"]}),u.invalidateQueries({queryKey:["forge-wiki-home"]}),u.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),u.invalidateQueries({queryKey:["forge-wiki-modal-search"]})]),i(`/wiki${t?`?spaceId=${encodeURIComponent(t)}`:""}`)}}),B=(s,o=!1)=>{const g=new URLSearchParams(d);s(g),f(g,{replace:o})},A=s=>{B(o=>{o.set("ingest","1"),s?o.set("ingestJobId",s):o.delete("ingestJobId"),t&&o.set("spaceId",t)})},Ne=()=>{B(s=>{s.delete("ingest"),s.delete("ingestJobId")})},Ie=s=>{B(o=>{o.set("ingest","1"),s?o.set("ingestJobId",s):o.delete("ingestJobId"),t&&o.set("spaceId",t)})},Ce=()=>{!r||!q||S.isPending||!window.confirm(`Delete KarpaWiki page "${r.title}"? You can restore it later from the bin.`)||S.mutateAsync(r.id)};return c.useEffect(()=>{if(!U)return;const s=g=>{var ae;(ae=Q.current)!=null&&ae.contains(g.target)||E(!1)},o=g=>{g.key==="Escape"&&E(!1)};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",o)}},[U]),!r&&(p.isLoading||z.isLoading||!n&&I.isLoading||n&&h.isLoading)?e.jsx(D,{eyebrow:"KarpaWiki",title:"Loading the article",description:"Preparing the current space, article, and KarpaWiki index."}):!r&&!j&&(p.isError||I.isError||h.isError||z.isError)?e.jsx(ne,{eyebrow:"KarpaWiki",error:p.error??I.error??h.error??z.error,onRetry:()=>{p.refetch(),I.refetch(),h.refetch(),z.refetch()}}):r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-4 sm:px-5 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1680px] flex-col gap-4",children:[e.jsxs("section",{className:"wiki-frame px-3 py-3 sm:px-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(oe,{kind:"wiki_page",label:"KarpaWiki page",compact:!0,gradient:!1}),m?e.jsx(oe,{kind:"wiki_space",label:m.label,compact:!0,gradient:!1,wrap:!0,className:"max-w-[20rem]"}):null,e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:rs(r.updatedAt)}),e.jsx(Qe,{metrics:a.snapshot.metrics,className:"ml-auto"})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2 lg:flex-row lg:items-center",children:[e.jsxs("button",{type:"button",className:"wiki-search-launch flex min-h-[2.9rem] w-full items-center gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 text-left text-[14px] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)] lg:flex-1",onClick:()=>l(!0),children:[e.jsx(Pe,{className:"size-4 shrink-0 text-[var(--ui-ink-faint)]"}),e.jsx("span",{children:"Search KarpaWiki"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:shrink-0",children:[e.jsxs("button",{type:"button",className:"wiki-space-trigger inline-flex min-h-[2.9rem] items-center gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 text-[13px] font-medium text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",onClick:()=>N(!0),children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Space"}),e.jsx("span",{className:"max-w-[16rem] truncate",children:(m==null?void 0:m.label)??"KarpaWiki space"}),e.jsx(O,{className:"size-3.5 text-[var(--ui-ink-faint)]"})]}),e.jsxs("div",{className:"relative",ref:Q,children:[e.jsxs(T,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>E(s=>!s),children:[e.jsx(ie,{className:"size-3.5"}),"Ingest",e.jsx(O,{className:"size-3.5"})]}),U?e.jsxs("div",{className:"absolute right-0 top-[calc(100%+0.5rem)] z-20 grid min-w-[15rem] gap-2 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-floating)]",children:[e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{E(!1),A()},children:[e.jsx(ie,{className:"mt-0.5 size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--ui-ink-strong)]",children:"New ingest"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Start a fresh import from files, URLs, or pasted text."})]})]}),e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{E(!1),i(`/wiki/ingest-history${t?`?spaceId=${encodeURIComponent(t)}`:""}`)},children:[e.jsx(Re,{className:"mt-0.5 size-4 shrink-0 text-[var(--secondary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--ui-ink-strong)]",children:"History"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Browse prior ingests, reopen reviews, and delete old ingest records."})]})]})]}):null]}),e.jsxs(T,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>i(`/wiki/edit/${encodeURIComponent(r.id)}?spaceId=${encodeURIComponent(t)}`,{state:{initialPage:r}}),children:[e.jsx(ze,{className:"size-3.5"}),"Edit"]}),e.jsx(es,{entityType:"note",entityId:r.id,label:"Open in graph",size:"sm"}),e.jsxs(T,{variant:"secondary",size:"sm",className:w("min-h-[2.9rem] border border-rose-400/18 bg-rose-500/10 text-rose-100 hover:bg-rose-500/18",!q&&"opacity-60"),onClick:Ce,pending:S.isPending,pendingLabel:"Deleting",disabled:!q,title:q?"Delete this KarpaWiki page":"The KarpaWiki home page cannot be deleted",children:[e.jsx(Ke,{className:"size-3.5"}),"Delete"]}),e.jsxs(T,{size:"sm",className:"min-h-[2.9rem]",onClick:()=>i(`/wiki/new?spaceId=${encodeURIComponent(t)}`),children:[e.jsx($e,{className:"size-3.5"}),"New page"]})]})]}),we&&y?e.jsxs("div",{className:"mt-3 flex flex-col gap-3 rounded-[22px] border border-amber-300/20 bg-amber-300/[0.08] px-4 py-3 text-[13px] leading-6 text-amber-50 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["You are viewing the personal starter wiki. The recovered people, story, and conversation pages are in"," ",e.jsx("strong",{children:y.label}),"."]}),e.jsx("button",{type:"button",className:"inline-flex min-h-10 shrink-0 items-center justify-center rounded-2xl bg-amber-200 px-4 text-[12px] font-semibold uppercase tracking-[0.14em] text-stone-950 transition hover:bg-amber-100",onClick:()=>{i({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(y.id)}`})},children:"Open shared memory"})]}):null]}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[15rem_minmax(0,1fr)] xl:grid-cols-[16rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"wiki-frame h-fit px-2 py-3 sm:px-3 lg:sticky lg:top-[5.75rem]",children:[e.jsx("div",{className:"px-2 pb-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Index"}),e.jsx(he,{nodes:((Z=z.data)==null?void 0:Z.tree)??[],activeSlug:r.slug,spaceId:t})]}),e.jsxs("article",{"aria-busy":L,className:w("wiki-frame relative overflow-hidden px-4 py-5 transition-[opacity,transform] duration-200 sm:px-6 sm:py-6",L&&"opacity-[0.985]"),children:[L?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-[color-mix(in_srgb,var(--primary)_70%,transparent)] opacity-90"}):null,e.jsxs("div",{className:"wiki-reading-copy wiki-reading-flow mx-auto max-w-[76rem]",children:[S.isError?e.jsx("div",{className:"mb-4 rounded-[18px] border border-rose-400/20 bg-rose-500/10 px-4 py-3 text-sm text-rose-100",children:S.error instanceof Error?S.error.message:"Forge could not delete this KarpaWiki page."}):null,e.jsx(ss,{markdown:r.contentMarkdown,spaceId:t}),r.summary.trim()?e.jsx("p",{className:"mt-5 border-t border-[var(--ui-border-subtle)] pt-4 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:r.summary}):null,_.length>0?e.jsxs("section",{className:"mt-8 border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Forge links"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:_.map(s=>e.jsx("a",{href:s.href?Je(s.href):void 0,className:"rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-3)] hover:text-[var(--ui-ink-strong)]",children:s.label},s.id))})]}):null,k!=null&&k.backlinkSourceNotes.length?e.jsxs("section",{className:"mt-8 border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked here"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:k.backlinkSourceNotes.map(s=>e.jsxs(le,{to:{pathname:s.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(s.slug)}`,search:`?spaceId=${encodeURIComponent(s.spaceId)}`},className:"rounded-xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"text-[13px] font-semibold text-[var(--ui-ink-strong)]",children:s.title}),s.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:s.summary}):null]},s.id))})]}):null]})]})]})]})}),e.jsx(de,{open:x,onOpenChange:l,children:e.jsxs(ue,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(me,{className:"fixed left-1/2 top-[8vh] z-50 w-[min(54rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-4 shadow-[var(--ui-shadow-floating)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{children:e.jsx(xe,{className:"font-display text-[1.35rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:"Search the wiki"})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close search",children:e.jsx(ce,{className:"size-4"})})})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx(_e,{autoFocus:!0,value:W,onChange:s=>ve(s.target.value),placeholder:"Search KarpaWiki pages",className:"h-11 rounded-2xl border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[14px] text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)]"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[["text","hybrid","semantic","entity"].map(s=>e.jsx("button",{type:"button",className:w("rounded-full px-3 py-1.5 text-[12px] font-medium uppercase tracking-[0.14em] transition",v===s?"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>be(s),children:s},s)),(v==="semantic"||v==="hybrid")&&R.length>0?e.jsx("select",{className:"ml-auto rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-strong)]",value:P,onChange:s=>M(s.target.value),children:R.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))}):null]})]}),e.jsx("div",{className:"mt-4 max-h-[60vh] overflow-y-auto",children:W.trim()?C.isLoading?e.jsx(D,{eyebrow:"KarpaWiki search",title:"Searching",description:"Ranking matching pages for this query."}):C.isError?e.jsx(ne,{eyebrow:"KarpaWiki search",error:C.error,onRetry:()=>void C.refetch()}):(ee=C.data)!=null&&ee.results.length?e.jsx("div",{className:"grid gap-2",children:C.data.results.map(s=>e.jsx("button",{type:"button",className:"rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{l(!1),i({pathname:s.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(s.page.slug)}`,search:`?spaceId=${encodeURIComponent(s.page.spaceId)}`})},children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-semibold text-[var(--ui-ink-strong)]",children:s.page.title}),s.page.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:s.page.summary}):null]}),e.jsx(Ae,{size:"sm",tone:"meta",children:s.score.toFixed(2)})]})},s.page.id))}):e.jsx("div",{className:"rounded-2xl border border-dashed border-[var(--ui-border-subtle)] px-4 py-10 text-center text-[13px] leading-6 text-[var(--ui-ink-faint)]",children:"No pages matched this search."}):e.jsx("div",{className:"rounded-2xl border border-dashed border-[var(--ui-border-subtle)] px-4 py-10 text-center text-[13px] leading-6 text-[var(--ui-ink-faint)]",children:"Start typing to search the current KarpaWiki space."})})]})]})}),e.jsx(ns,{open:b,onOpenChange:N,spaces:((se=p.data)==null?void 0:se.settings.spaces)??[],activeSpaceId:t,onSelect:s=>{i({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(s)}`},{replace:!0})}}),e.jsx(ts,{open:ke,onOpenChange:s=>{if(s){A(J);return}Ne()},spaces:((te=p.data)==null?void 0:te.settings.spaces)??[],llmProfiles:((re=p.data)==null?void 0:re.settings.llmProfiles)??[],initialSpaceId:t,selectedJobId:J,onJobSelected:Ie,linkedEntityHints:r.links.map(s=>({entityType:s.entityType,entityId:s.entityId,anchorKey:null}))??[]})]}):j?e.jsx(D,{eyebrow:"KarpaWiki",title:"Opening a new page",description:`Creating a draft for ${j}.`}):e.jsx(Me,{eyebrow:"KarpaWiki",title:"Article not found",description:"This page does not exist in the selected space."})}export{fs as WikiPage};
|