ltcai 10.6.0 → 10.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +61 -52
  2. package/docs/CHANGELOG.md +126 -0
  3. package/docs/COMMUNITY_AND_PLUGINS.md +1 -1
  4. package/docs/DEVELOPMENT.md +1 -1
  5. package/docs/ONBOARDING.md +1 -1
  6. package/docs/OPERATIONS.md +1 -1
  7. package/docs/TRUST_MODEL.md +1 -1
  8. package/docs/WHY_LATTICE.md +1 -1
  9. package/docs/kg-schema.md +1 -1
  10. package/lattice_brain/__init__.py +1 -1
  11. package/lattice_brain/graph/_kg_contract.py +15 -0
  12. package/lattice_brain/graph/provenance.py +61 -5
  13. package/lattice_brain/graph/retrieval.py +16 -4
  14. package/lattice_brain/graph/retrieval_reads.py +136 -23
  15. package/lattice_brain/graph/retrieval_vector.py +156 -8
  16. package/lattice_brain/ingestion.py +14 -1
  17. package/lattice_brain/ingestion_jobs.py +255 -5
  18. package/lattice_brain/portability.py +5 -2
  19. package/lattice_brain/runtime/multi_agent.py +1 -1
  20. package/latticeai/__init__.py +1 -1
  21. package/latticeai/api/browser.py +8 -14
  22. package/latticeai/api/knowledge_graph.py +46 -16
  23. package/latticeai/api/workspace.py +4 -11
  24. package/latticeai/api/workspace_scope.py +125 -0
  25. package/latticeai/core/agent.py +68 -3
  26. package/latticeai/core/config.py +6 -0
  27. package/latticeai/core/csrf.py +293 -0
  28. package/latticeai/core/legacy_compatibility.py +1 -1
  29. package/latticeai/core/marketplace.py +1 -1
  30. package/latticeai/core/workspace_os_constants.py +1 -1
  31. package/latticeai/models/router.py +61 -16
  32. package/latticeai/runtime/build_phases.py +2 -0
  33. package/latticeai/runtime/config_runtime.py +2 -0
  34. package/latticeai/runtime/runtime_context.py +1 -0
  35. package/latticeai/runtime/web_runtime.py +31 -4
  36. package/latticeai/services/architecture_readiness.py +1 -1
  37. package/latticeai/services/product_readiness.py +1 -1
  38. package/latticeai/services/search_service.py +9 -1
  39. package/latticeai/services/tool_dispatch.py +13 -7
  40. package/latticeai/tools/__init__.py +1 -0
  41. package/latticeai/tools/documents.py +44 -13
  42. package/package.json +1 -1
  43. package/scripts/build_frontend_assets.mjs +21 -4
  44. package/scripts/check_current_release_docs.mjs +1 -1
  45. package/scripts/check_frontend_build_freshness.mjs +170 -0
  46. package/src-tauri/Cargo.lock +1 -1
  47. package/src-tauri/Cargo.toml +1 -1
  48. package/src-tauri/tauri.conf.json +1 -1
  49. package/static/app/asset-manifest.json +39 -39
  50. package/static/app/assets/{Act-B3MSgNsJ.js → Act-aNud-lKL.js} +1 -1
  51. package/static/app/assets/{AdminConsole-Ds8u36lf.js → AdminConsole-QiCTH68K.js} +1 -1
  52. package/static/app/assets/{Brain-XdHCIB6a.js → Brain-CMFh5q6k.js} +1 -1
  53. package/static/app/assets/{BrainHome-Dp8gzQoF.js → BrainHome-B4Ar3atu.js} +2 -2
  54. package/static/app/assets/{BrainSignals-D4yZflVt.js → BrainSignals-RVMlmTGC.js} +1 -1
  55. package/static/app/assets/{Capture-BwSZmiZ8.js → Capture-DEBo-0vZ.js} +1 -1
  56. package/static/app/assets/{CommandPalette-Ds0DnRSC.js → CommandPalette-bW5WxWWZ.js} +1 -1
  57. package/static/app/assets/{Library-SqzHjyfx.js → Library-5gFexm83.js} +1 -1
  58. package/static/app/assets/{LivingBrain-DpKt-NKE.js → LivingBrain-FlHFfu9i.js} +1 -1
  59. package/static/app/assets/ProductFlow-CFUNDOHu.js +1 -0
  60. package/static/app/assets/{ReviewCard-DVPi1LPZ.js → ReviewCard-BHj86h2Z.js} +2 -2
  61. package/static/app/assets/{System-w-9miIG8.js → System-CeNHoZRu.js} +1 -1
  62. package/static/app/assets/{activity-C0QavXjd.js → activity-7_ZmZqN0.js} +1 -1
  63. package/static/app/assets/arrow-left-Dv2Tiwhe.js +1 -0
  64. package/static/app/assets/{bot-C1-MbzCF.js → bot-D1gX4xks.js} +1 -1
  65. package/static/app/assets/{brain-CeRqzJVc.js → brain-Dn_bDfl4.js} +1 -1
  66. package/static/app/assets/{button-Z-2N8PUb.js → button-DPFZ9lGw.js} +1 -1
  67. package/static/app/assets/{circle-pause-CgjCLdmO.js → circle-pause-B2P72YOO.js} +1 -1
  68. package/static/app/assets/{circle-play-Bj45uClm.js → circle-play-BiC8z2vg.js} +1 -1
  69. package/static/app/assets/{cpu-B-2Chwfy.js → cpu-Cx-wRR_V.js} +1 -1
  70. package/static/app/assets/{download-CKmiOG3C.js → download-CKxlzxsK.js} +1 -1
  71. package/static/app/assets/{folder-open-fE7lLvhZ.js → folder-open-Bbjju0tt.js} +1 -1
  72. package/static/app/assets/{hard-drive-rDl1xsJ1.js → hard-drive-Bon1VBvq.js} +1 -1
  73. package/static/app/assets/index-DYUs0cWy.css +2 -0
  74. package/static/app/assets/{index-AEIqmjwZ.js → index-mLP0-YNO.js} +3 -3
  75. package/static/app/assets/{input-BflJYT5-.js → input-DrMc0Xns.js} +1 -1
  76. package/static/app/assets/{permissionCopy-BNNvkXSX.js → permissionCopy-BGUsI7vw.js} +1 -1
  77. package/static/app/assets/{primitives-CP68OWk2.js → primitives-CEMTjBz1.js} +1 -1
  78. package/static/app/assets/search-HsIji1wY.js +1 -0
  79. package/static/app/assets/{share-2-CyjG2_yY.js → share-2-D7THHq5K.js} +1 -1
  80. package/static/app/assets/{shield-alert-C_JBPWYd.js → shield-alert-BoU4_8r9.js} +1 -1
  81. package/static/app/assets/{textarea-Ds1Exelb.js → textarea-rU1Lb7ia.js} +1 -1
  82. package/static/app/assets/{useFocusTrap-BgIZQ4if.js → useFocusTrap-BgvK4Nkx.js} +1 -1
  83. package/static/app/assets/{useQuery-6Bu27NQe.js → useQuery-CT2ChyuU.js} +1 -1
  84. package/static/app/assets/{users-31lxlciQ.js → users-DlbfHBQV.js} +1 -1
  85. package/static/app/assets/{utils-C0-C5mZc.js → utils-fEGWreKB.js} +1 -1
  86. package/static/app/assets/workspace-ClDBz_0f.js +1 -0
  87. package/static/app/index.html +4 -4
  88. package/static/sw.js +1 -1
  89. package/static/app/assets/ProductFlow-BimeVtWH.js +0 -1
  90. package/static/app/assets/arrow-left-TsAKz-s_.js +0 -1
  91. package/static/app/assets/index-DcMODGjM.css +0 -2
  92. package/static/app/assets/search-B4O4iIgg.js +0 -1
  93. package/static/app/assets/workspace-DAB-urHL.js +0 -1
@@ -1 +1 @@
1
- import{S as e,a as t,b as n,d as r,g as i,m as a,n as o,o as s,t as c,y as l}from"./utils-C0-C5mZc.js";import{r as u,t as d}from"./useQuery-6Bu27NQe.js";import{t as f}from"./workspace-DAB-urHL.js";import{n as p}from"./input-BflJYT5-.js";import{t as m}from"./circle-pause-CgjCLdmO.js";import{d as ee,l as h,s as g}from"./index-AEIqmjwZ.js";var te=i(`brain-circuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),_=i(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),v=i(`database-backup`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 12a9 3 0 0 0 5 2.69`,key:`1ui2ym`}],[`path`,{d:`M21 9.3V5`,key:`6k6cib`}],[`path`,{d:`M3 5v14a9 3 0 0 0 6.47 2.88`,key:`i62tjy`}],[`path`,{d:`M12 12v4h4`,key:`1bxaet`}],[`path`,{d:`M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16`,key:`1f4ei9`}]]),y=i(`folder-sync`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5`,key:`1dkoa9`}],[`path`,{d:`M12 10v4h4`,key:`1czhmt`}],[`path`,{d:`m12 14 1.535-1.605a5 5 0 0 1 8 1.5`,key:`lvuxfi`}],[`path`,{d:`M22 22v-4h-4`,key:`1ewp4q`}],[`path`,{d:`m22 18-1.535 1.605a5 5 0 0 1-8-1.5`,key:`14ync0`}]]),b=e(n());function ne(e){return c(e).flatMap(e=>{let t=V(e,[`id`,`conversation_id`]);return t?[{id:t,title:V(e,[`title`,`summary`,`last_message`],t).trim()||t,messageCount:Math.max(0,Math.round(G(e,[`message_count`,`messages`]))),updatedAt:U(e,[`updated_at`,`updatedAt`,`created_at`,`createdAt`])}]:[]}).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))}function re(e){return c((B(e)?e:{}).messages).flatMap(e=>{let t=V(e,[`role`]),n=typeof e.content==`string`?e.content:``;return t!==`user`&&t!==`assistant`||!n.trim()?[]:[{role:t,content:n}]})}function ie(e,t,n){let r=V(e,[`id`]);if(r){let e=`brain.memoryTier.${r}`,n=a(t,e);if(n!==e)return n}return n}function ae(e,t,n=`ko`){let r=B(e)?e:{},i=(c(r.sources).length?c(r.sources):c(r.tiers)).map((e,t)=>({id:V(e,[`id`,`source`,`label`],`memory-${t}`),title:ie(e,n,V(e,[`title`,`label`,`source`,`path`,`name`],`Workspace memory`)),kind:H(e,[`type`,`source_type`,`kind`,`health`],`Memory`),tags:[],agentGenerated:!1})),a=c(r.recent_memories||r.recentMemories).map((e,t)=>{let n=B(e.metadata)?e.metadata:{},r=W(e,[`tags`]),i=V(e,[`content`,`summary`,`detail`]),a=V(n,[`source`]),o=r.includes(`agent-synthesis`)||a===`agent_runtime`||a===`agent_runtime_synthesis`;return{id:V(e,[`id`],`recent-memory-${t}`),title:i?i.replace(/\s+/g,` `).slice(0,96):H(e,[`kind`],`Memory`),kind:H(e,[`kind`],`Memory`),detail:i,tags:r,agentGenerated:o}}),o=c(t).map((e,t)=>({id:V(e,[`id`,`conversation_id`],`conversation-${t}`),title:V(e,[`title`,`summary`,`id`],`Conversation`),kind:`Conversation`,tags:[],agentGenerated:!1}));return F([...a,...i,...o]).slice(0,12)}function oe(e){let t=B(e)?e:{},n=c(t.nodes),r=c(t.edges),i=n.flatMap(e=>{let t=V(e,[`id`,`node_id`,`title`,`label`]);if(!t)return[];let n=B(e.metadata)?e.metadata:{},r=H(e,[`type`,`kind`,`category`],`Concept`),i=V(e,[`title`,`label`,`name`],t.replace(/^[^:]+:/,``)),a=V(e,[`summary`,`description`,`snippet`])||V(n,[`summary`,`description`,`relative_path`,`filename`]),s=o(G(e,[`importance_norm`,`importance`,`score`])||.5,.08,1),c=U(e,[`created_at`,`createdAt`,`added_at`,`addedAt`,`timestamp`,`updated_at`,`updatedAt`])??U(n,[`created_at`,`createdAt`,`added_at`,`addedAt`,`timestamp`,`updated_at`,`updatedAt`]);return[{id:t,label:i,type:r,summary:a,importance:s,...c===void 0?{}:{createdAt:c}}]}).sort((e,t)=>t.importance-e.importance),a=new Set(i.map(e=>e.id));return{nodes:i,edges:r.flatMap((e,t)=>{let n=V(e,[`from`,`source`,`source_id`]),r=V(e,[`to`,`target`,`target_id`]);return!n||!r||!a.has(n)||!a.has(r)?[]:[{id:V(e,[`id`],`edge-${t}`),source:n,target:r,label:H(e,[`type`,`label`,`relationship`],`Relates`),weight:G(e,[`weight`,`score`,`confidence`])||1}]})}}function se(e){let t=B(e)?e:{},n=[t,t.knowledge_graph,t.ingestion,t.result].filter(B),r=new Set,i=0,a,o;for(let e of n){let t=V(e,[`node_id`,`graph_node`,`graph_node_id`]);t&&r.add(t);for(let t of c(e.indexed_nodes))if(typeof t==`string`&&t.trim())r.add(t.trim());else if(B(t)){let e=V(t,[`node_id`,`graph_node_id`,`id`]);e&&r.add(e)}i=Math.max(i,G(e,[`chunk_count`,`chunks`,`indexed_count`])),typeof e.duplicate==`boolean`&&(a=e.duplicate),o||=V(e,[`provenance_id`])}let s;for(let e of n){let t=ce(e);if(t){s=t;break}}return{nodeIds:Array.from(r),chunkCount:i,...a===void 0?{}:{duplicate:a},...o?{provenanceId:o}:{},...s?{extraction:s}:{}}}function ce(e){let t=B(e)?e:{},n=B(t.extraction_quality)?t.extraction_quality:null;if(!n)return null;let r=V(n,[`level`]);if(r!==`high`&&r!==`medium`&&r!==`low`)return null;let i=W(t,[`warnings`]).length?W(t,[`warnings`]):W(n,[`warnings`]);return{score:G(n,[`score`]),level:r,reasons:W(n,[`reasons`]),warnings:i}}function le(e){let t=B(e)?e:{},n=B(t.context_quality)?t.context_quality:null,r=!n&&B(t.trace)&&B(t.trace.context_quality)?t.trace.context_quality:null,i=n||r||(typeof t.mode==`string`&&typeof t.limited==`boolean`?t:null);if(!i)return null;let a=V(i,[`mode`]);if(!a)return null;let o=typeof i.reason==`string`&&i.reason.trim()?i.reason.trim():null;return{mode:a,nodes:Math.max(0,Math.round(G(i,[`nodes`]))),limited:K(i,[`limited`],!1),reason:o}}function ue(e){let t=B(e)?e:{},n=(B(t.grounding)?t.grounding:null)||(typeof t.status==`string`&&`label`in t?t:null);if(!n)return null;let r=V(n,[`status`]);return[`supported`,`unsupported`,`no_context`].includes(r)?{status:r,reason:typeof n.reason==`string`&&n.reason.trim()?n.reason.trim():null}:null}function x(e){if(!B(e))return null;let t=V(e,[`status`]);if(t!==`ok`&&t!==`pending`&&t!==`failed`)return null;let n=V(e,[`detail`]);return{status:t,...n?{detail:n}:{}}}function de(e){let t=!!e.generation?.repaired,n=new Map;for(let t of e.artifacts||[])t&&typeof t.path==`string`&&n.set(t.path,!!t.previewable);let r=new Map,i=null;if(Array.isArray(e.brain_ingest))for(let t of e.brain_ingest){let e=x(t);e&&B(t)&&typeof t.path==`string`&&r.set(t.path,e)}else i=x(e.brain_ingest);let a=e.created_files||[];return a.map(e=>{let o=r.get(e.path)||(a.length===1?i:null);return{path:e.path,filename:e.filename||e.path.split(`/`).pop()||e.path,bytes:e.bytes||0,repaired:t,...n.has(e.path)?{previewable:n.get(e.path)}:{},...o?{brainIngest:o}:{}}})}function fe(e){if(!B(e))return null;let t=V(e,[`phase`]),n=V(e,[`event`]);if(!t||!n)return null;let r=Number(e.step);return{phase:t,event:n,...V(e,[`action`])?{action:V(e,[`action`])}:{},...V(e,[`path`])?{path:V(e,[`path`])}:{},...Number.isFinite(r)?{step:Math.round(r)}:{},...typeof e.ok==`boolean`?{ok:e.ok}:{},...V(e,[`decision`])?{decision:V(e,[`decision`])}:{},...V(e,[`verdict`])?{verdict:V(e,[`verdict`])}:{},...V(e,[`state`])?{state:V(e,[`state`])}:{},...V(e,[`detail`,`error`])?{detail:V(e,[`detail`,`error`])}:{}}}function pe(e){return c(e).flatMap(e=>{if(!B(e))return[];let t=V(e,[`action`,`tool`]),n=V(e,[`state`]),r=V(e,[`error`]);if(!t&&!n&&!r)return[];let i=V(B(e.args)?e.args:{},[`path`,`target`,`file`]);return t?[{phase:`execute`,event:`tool`,action:t,...i?{path:i}:{},ok:!r,...r?{detail:r}:{}}]:r?[{phase:`execute`,event:`state`,...n?{state:n}:{},ok:!1,detail:r}]:[{phase:`terminal`,event:`state`,state:n}]})}function me(e){if(!B(e))return null;let t={};if(B(e.repairs))for(let[n,r]of Object.entries(e.repairs)){let e=Number(r);Number.isFinite(e)&&e>0&&(t[n]=Math.round(e))}let n=Math.max(0,Math.round(G(e,[`parse_errors`,`parseErrors`]))),r=Math.max(0,Math.round(G(e,[`parse_recovered`,`parseRecovered`]))),i=Object.values(t).reduce((e,t)=>e+t,0)+r;return i<1?null:{repairs:t,parseErrors:n,parseRecovered:r,total:i}}function S(e,t){if(!B(e))return null;let n=e=>{if(!B(e))return``;let n=e[t];return typeof n==`string`?n:``},r=n(e.headline),i=c(e.details).map(n).filter(Boolean),a=V(e,[`code`]);if(!r&&!i.length)return null;let o=B(e.model_strain)?V(e.model_strain,[`level`]):``,s=o===`light`||o===`moderate`||o===`heavy`?o:`none`,l=e.ok===!0;return l&&!i.length?null:{code:a,ok:l,headline:r,details:i,strainLevel:s}}function C(e){return c((B(e)?e:{}).pending).flatMap(e=>{let t=V(e,[`run_id`,`runId`]);return t?[{runId:t,goal:V(e,[`goal`]),expiresAt:V(e,[`expires_at`,`expiresAt`])}]:[]})}function w(e){let t=B(e)?e:{},n=c(t.watches).flatMap(e=>{if(!B(e))return[];let t=V(e,[`id`]),n=V(e,[`path`]);if(!t&&!n)return[];let r=B(e.last_result)?e.last_result:null,i=c(e.last_errors).flatMap(e=>{if(typeof e==`string`&&e.trim())return[{path:``,detail:e.trim()}];if(!B(e))return[];let t=V(e,[`detail`,`reason`,`error`]),n=V(e,[`path`,`source`,`file`]);return!t&&!n?[]:[{path:n,detail:t}]});return[{id:t||n,path:n,enabled:K(e,[`enabled`],!1),lastScanAt:V(e,[`last_scan_at`,`lastScanAt`]),lastResult:r?{status:V(r,[`status`]),ingested:Math.max(0,Math.round(G(r,[`ingested`]))),failed:Math.max(0,Math.round(G(r,[`failed`])))}:null,trackedFiles:Math.max(0,Math.round(G(e,[`tracked_files`,`trackedFiles`]))),lastErrors:i.slice(0,3)}]});return{enabledCount:Math.max(0,Math.round(G(t,[`enabled_count`,`enabledCount`]))),polling:K(t,[`polling`],!1),intervalSeconds:Math.max(0,Math.round(G(t,[`interval_seconds`,`intervalSeconds`]))),watches:n}}function T(e){let t=B(e)?e:{};return{status:V(t,[`status`],`unavailable`),pendingItems:Math.max(0,Math.round(G(t,[`pending_items`,`pendingItems`]))),totalItems:Math.max(0,Math.round(G(t,[`total_items`,`totalItems`]))),detail:V(t,[`detail`])}}function E(e){return typeof e==`string`?e.trim():B(e)?[V(e,[`source`,`path`,`file`]),V(e,[`detail`,`reason`,`error`])].filter(Boolean).join(` — `):``}function D(e){return c((B(e)?e:{}).jobs).flatMap(e=>{let t=V(e,[`job_id`,`jobId`,`id`]);if(!t)return[];let n=V(e,[`created_at`,`createdAt`]),r=V(e,[`updated_at`,`updatedAt`]);return[{jobId:t,status:V(e,[`status`],`queued`),total:Math.max(0,Math.round(G(e,[`total`]))),processed:Math.max(0,Math.round(G(e,[`processed`]))),failed:Math.max(0,Math.round(G(e,[`failed`]))),errors:c(e.errors).map(E).filter(Boolean).slice(0,10),...n?{createdAt:n}:{},...r?{updatedAt:r}:{}}]})}function O(e,t){for(let n of[`recommended`,`cloud`,`loaded`,`loaded_models`,`models`])for(let r of c(e[n])){if(V(r,[`id`,`model_id`,`name`])!==t)continue;let e=V(r,[`display_name`,`model_name`,`name`]);if(e&&e!==t)return e}return``}function k(e){let n=B(e)?e:{},r=V(n,[`current`,`current_model`,`local_model`]);if(r)return O(n,r)||t(r);let i=c(n.loaded||n.loaded_models).find(e=>e.id||e.name||e.model_id);if(!i)return`local mind`;let a=V(i,[`display_name`,`model_name`,`name`]),o=V(i,[`id`,`model_id`]);return a&&a!==o?a:o?O(n,o)||t(o):`local mind`}function A(e){let t=B(e)?e:{};return V(t,[`current`,`current_model`,`local_model`])?!0:c(t.loaded||t.loaded_models).some(e=>e.id||e.name||e.model_id)}function j(e,t,n){let r=B(e)?e:{},i=B(r.brain_readiness)?r.brain_readiness:{},a=V(i,[`state`]),s=G(i,[`depth`]),c=G(i,[`score`]);if((a===`quiet`||a===`forming`||a===`alive`)&&z(s)){let e=B(i.signals)?i.signals:{};return{score:o(Math.round(c||0),0,100),state:a,depth:s,titleKey:V(i,[`title_key`,`titleKey`],`brain.readiness.${a}`),actionKey:V(i,[`action_key`,`actionKey`],R(a)),source:`memory_service`,signals:{memoryCount:G(e,[`memory_count`,`memoryCount`]),conceptCount:G(e,[`concept_count`,`conceptCount`]),relationshipCount:G(e,[`relationship_count`,`relationshipCount`]),healthySources:G(e,[`healthy_sources`,`healthySources`])}}}return L(t,n)}function M(e,t=``){let n=B(e)&&typeof e.ok==`boolean`&&`data`in e?e:null;if(n&&!n.ok)return N(t);let r=n?n.data:e,i=B(r)?r:{},a=B(i.model_continuity)?i.model_continuity:{},o=B(i.proofs)?i.proofs:{},s=B(i.recall)?i.recall:{},l=B(i.claims)?i.claims:{},u=G(o,[`durable_items`,`durableItems`]);return{status:V(i,[`status`],`quiet`),modelContinuity:{activeModel:V(a,[`active_model`,`activeModel`],t),brainOwner:V(a,[`brain_owner`,`brainOwner`],`lattice_brain`),capability:K(a,[`capability`],!0),survivesModelSwitch:K(a,[`survives_model_switch`,`survivesModelSwitch`],!1),proven:K(a,[`proven`],!1),contextStore:V(a,[`context_store`,`contextStore`],`workspace + conversation + graph + vector`)},proofs:{durableItems:u,hasDurableEvidence:K(o,[`has_durable_evidence`,`hasDurableEvidence`],u>0),workspaceMemories:G(o,[`workspace_memories`,`workspaceMemories`]),conversations:G(o,[`conversations`]),graphConcepts:G(o,[`graph_concepts`,`graphConcepts`]),vectorItems:G(o,[`vector_items`,`vectorItems`]),healthySources:G(o,[`healthy_sources`,`healthySources`])},recall:{query:V(s,[`query`]),count:G(s,[`count`]),items:c(s.items).map((e,t)=>({id:V(e,[`id`],`recall-${t}`),source:H(e,[`source`],`Memory`),title:V(e,[`title`],`Memory`),snippet:V(e,[`snippet`]),score:G(e,[`score`]),matchedTerms:W(e,[`matched_terms`,`matchedTerms`]),confidence:he(e,G(e,[`score`])),locator:V(e,[`locator`])}))},claims:{canRecallUserContext:K(l,[`can_recall_user_context`,`canRecallUserContext`],!1),keepsContextAcrossModels:K(l,[`keeps_context_across_models`,`keepsContextAcrossModels`],!1),isKnowledgeStore:K(l,[`is_knowledge_store`,`isKnowledgeStore`],!1)}}}function N(e){return{status:`unavailable`,modelContinuity:{activeModel:e,brainOwner:``,capability:!1,survivesModelSwitch:!1,proven:!1,contextStore:``},proofs:{durableItems:0,hasDurableEvidence:!1,workspaceMemories:0,conversations:0,graphConcepts:0,vectorItems:0,healthySources:0},recall:{query:``,count:0,items:[]},claims:{canRecallUserContext:!1,keepsContextAcrossModels:!1,isKnowledgeStore:!1}}}function P(e){let t=B(e)?e:{},n=B(t.focus)?t.focus:{},r=c(t.next_actions||t.nextActions),i=c(t.suggested_questions||t.suggestedQuestions),a=c(t.proactive_actions||t.proactiveActions),s=c(t.evidence),l=r.length?r:[{id:`add_source`,label_key:`brain.brief.action.add`,detail_key:`brain.brief.action.add.detail`,route:`/capture`,priority:10},{id:`ask_brain`,label_key:`brain.brief.action.ask`,detail_key:`brain.brief.action.ask.detail`,route:``,priority:9}],u=s.length?s:[{id:`durable`,label_key:`brain.brief.evidence.durable`,value:0,detail_key:`brain.brief.evidence.durable.detail`},{id:`graph`,label_key:`brain.brief.evidence.graph`,value:0,detail_key:`brain.brief.evidence.graph.detail`},{id:`sources`,label_key:`brain.brief.evidence.sources`,value:0,detail_key:`brain.brief.evidence.sources.detail`}];return{status:V(t,[`status`],`quiet`),score:o(Math.round(G(t,[`score`])),0,100),headlineKey:V(t,[`headline_key`,`headlineKey`],`brain.brief.headline.quiet`),bodyKey:V(t,[`body_key`,`bodyKey`],`brain.brief.body.quiet`),focus:{kind:V(n,[`kind`],`empty`),title:V(n,[`title`]),detail:V(n,[`detail`]),source:H(n,[`source`],`Memory`),score:G(n,[`score`]),empty:K(n,[`empty`],!V(n,[`title`]))},nextActions:l.map(e=>({id:V(e,[`id`],`ask_brain`),labelKey:V(e,[`label_key`,`labelKey`],`brain.brief.action.ask`),detailKey:V(e,[`detail_key`,`detailKey`],`brain.brief.action.ask.detail`),route:V(e,[`route`]),priority:G(e,[`priority`])})),suggestedQuestions:i.map(e=>({id:V(e,[`id`],`suggested-question`),labelKey:V(e,[`label_key`,`labelKey`],`brain.suggestion.focus.label`),detailKey:V(e,[`detail_key`,`detailKey`],`brain.suggestion.focus.detail`),promptKey:V(e,[`prompt_key`,`promptKey`],`brain.suggestion.focus.prompt`),params:I(e.params),priority:G(e,[`priority`])})).sort((e,t)=>t.priority-e.priority),proactiveActions:a.map(e=>({id:V(e,[`id`],`proactive-action`),intent:V(e,[`intent`],`ask`),labelKey:V(e,[`label_key`,`labelKey`],`brain.proactive.evidence.label`),detailKey:V(e,[`detail_key`,`detailKey`],`brain.proactive.evidence.detail`),prompt:V(e,[`prompt`]),route:V(e,[`route`]),priority:G(e,[`priority`]),context:I(e.context)})).sort((e,t)=>t.priority-e.priority),evidence:u.map(e=>({id:V(e,[`id`],`evidence`),labelKey:V(e,[`label_key`,`labelKey`],`brain.brief.evidence.durable`),value:G(e,[`value`]),detailKey:V(e,[`detail_key`,`detailKey`],`brain.brief.evidence.durable.detail`)})),generatedAt:V(t,[`generated_at`,`generatedAt`])}}function F(e){let t=new Set;return e.filter(e=>t.has(e.id)?!1:(t.add(e.id),!0))}function I(e){return B(e)?Object.entries(e).reduce((e,[t,n])=>((typeof n==`string`||typeof n==`number`)&&(e[t]=n),e),{}):{}}function L(e,t){let n=Math.min(100,Math.round(e*12+t*10));return e<1?{score:Math.max(12,n),state:`quiet`,depth:2,titleKey:`brain.readiness.quiet`,actionKey:`brain.readiness.start`,source:`frontend_fallback`,signals:{memoryCount:e,conceptCount:t,relationshipCount:0,healthySources:0}}:t<3?{score:Math.max(38,n),state:`forming`,depth:3,titleKey:`brain.readiness.forming`,actionKey:`brain.readiness.grow`,source:`frontend_fallback`,signals:{memoryCount:e,conceptCount:t,relationshipCount:0,healthySources:0}}:{score:Math.max(72,n),state:`alive`,depth:5,titleKey:`brain.readiness.alive`,actionKey:`brain.readiness.map`,source:`frontend_fallback`,signals:{memoryCount:e,conceptCount:t,relationshipCount:0,healthySources:0}}}function R(e){return e===`quiet`?`brain.readiness.start`:e===`forming`?`brain.readiness.grow`:`brain.readiness.map`}function z(e){return e>=1&&e<=5&&Number.isInteger(e)}var B=s;function V(e,t,n=``){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t;if(typeof t==`number`&&Number.isFinite(t))return String(t)}return n}function H(e,t,n=``){return V(e,t,n).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function U(e,t){for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t<0xe8d4a51000?t*1e3:t;if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&/^\d+$/.test(t.trim()))return e<0xe8d4a51000?e*1e3:e;let n=Date.parse(t);if(Number.isFinite(n))return n}}}function W(e,t){for(let n of t){let t=e[n];if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&e.trim().length>0)}return[]}function he(e,t){let n=e.confidence;return n===`high`||n===`medium`||n===`low`?n:t>=.65?`high`:t>=.3?`medium`:`low`}function G(e,t){for(let n of t){let t=Number(e[n]);if(Number.isFinite(t))return t}return 0}function K(e,t,n){for(let n of t){let t=e[n];if(typeof t==`boolean`)return t}return n}var q=l();function J(){let e=d({queryKey:[`vectorFreshness`],queryFn:r.brainVectorFreshness,staleTime:6e4,refetchOnWindowFocus:!1,retry:!1});return b.useMemo(()=>e.data?.ok?T(e.data.data):null,[e.data])}function ge({language:e}){let t=u(),n=J(),i=f({mutationFn:()=>r.memoryRebuild(),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`vectorFreshness`]})}});if(!n||n.status!==`stale_embedder`)return null;let o=i.isSuccess&&i.data&&!i.data.ok;return(0,q.jsxs)(`div`,{className:`brain-stale-embedder`,role:`status`,"data-testid":`stale-embedder-notice`,children:[(0,q.jsx)(h,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`strong`,{children:a(e,`brain.freshness.staleEmbedder`)}),(0,q.jsx)(`small`,{children:a(e,`brain.freshness.staleEmbedder.detail`)}),o?(0,q.jsx)(`small`,{className:`is-error`,children:a(e,`brain.freshness.reindex.failed`)}):null]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`stale-embedder-reindex`,disabled:i.isPending,onClick:()=>i.mutate(),children:a(e,i.isPending?`brain.freshness.reindex.running`:`brain.freshness.reindex`)})]})}function _e({language:e}){let t=J();return!t||t.status!==`pending`||t.pendingItems<1?null:(0,q.jsxs)(`p`,{className:`brain-freshness-chip`,role:`status`,"data-testid":`vector-freshness-chip`,children:[(0,q.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:a(e,`brain.freshness.pending`,{count:t.pendingItems})})]})}var Y=new Set([`queued`,`running`]),X=new Set([`failed`,`partial`]);function Z(e){return Y.has(e.status)}function ve(e){return e===`queued`||e===`running`||e===`completed`||e===`failed`||e===`partial`?`brain.jobs.status.${e}`:`brain.jobs.status.queued`}var ye=new Set([`completed`,`partial`]),be=3;function xe({language:e,job:t,freshness:n,onDismiss:r}){let i=n&&n.totalItems>0&&(n.status===`ready`||n.status===`pending`)?Math.max(0,Math.min(100,Math.round((n.totalItems-n.pendingItems)/n.totalItems*100))):null,o=t.errors.slice(0,be);return(0,q.jsxs)(`div`,{className:`brain-jobs-report lattice-success-pulse is-${t.status}`,role:`status`,"data-testid":`ingestion-job-report`,children:[(0,q.jsxs)(`div`,{className:`brain-jobs-report-head`,children:[(0,q.jsx)(p,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,q.jsx)(`strong`,{children:a(e,t.status===`partial`?`brain.jobs.report.titlePartial`:`brain.jobs.report.title`)}),r?(0,q.jsx)(`button`,{type:`button`,className:`brain-jobs-report-dismiss`,"aria-label":a(e,`brain.jobs.report.dismiss`),onClick:r,children:(0,q.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}):null]}),(0,q.jsxs)(`div`,{className:`brain-jobs-report-stats`,children:[t.processed>0?(0,q.jsx)(`span`,{className:`brain-jobs-report-stat`,children:a(e,`brain.jobs.report.documents`,{count:t.processed})}):null,t.failed>0?(0,q.jsx)(`span`,{className:`brain-jobs-report-stat is-failed`,children:a(e,`brain.jobs.failedCount`,{count:t.failed})}):null,i===null?null:(0,q.jsx)(`span`,{className:`brain-jobs-report-stat`,children:a(e,`brain.jobs.report.vector`,{percent:i})})]}),o.length?(0,q.jsxs)(`div`,{className:`brain-jobs-report-samples`,children:[(0,q.jsx)(`small`,{children:a(e,`brain.jobs.report.skipped`)}),(0,q.jsx)(`ul`,{children:o.map(e=>(0,q.jsx)(`li`,{children:e},e))})]}):null]})}function Q({language:e}){let t=u(),n=J(),i=d({queryKey:[`ingestionJobs`],queryFn:r.ingestionJobs,refetchOnWindowFocus:!1,retry:!1,refetchInterval:e=>{let t=e.state.data;return t?.ok&&D(t.data).some(Z)?4e3:!1}}),o=f({mutationFn:e=>r.resumeIngestionJob(e),onSettled:()=>void t.invalidateQueries({queryKey:[`ingestionJobs`]})}),s=b.useMemo(()=>i.data?.ok?D(i.data.data):[],[i.data]),c=b.useRef(new Map),[l,p]=b.useState([]);b.useEffect(()=>{let e=c.current,t=[];for(let n of s){let r=e.get(n.jobId);r&&Y.has(r)&&ye.has(n.status)&&t.push(n.jobId),e.set(n.jobId,n.status)}t.length&&p(e=>[...t,...e.filter(e=>!t.includes(e))].slice(0,2))},[s]);let m=l.map(e=>s.find(t=>t.jobId===e)).filter(e=>!!e),g=s.filter(e=>Z(e)||X.has(e.status)).slice(0,4);return!g.length&&!m.length?null:(0,q.jsxs)(`section`,{className:`brain-jobs-panel`,"aria-label":a(e,`brain.jobs.aria`),"data-testid":`ingestion-jobs-panel`,children:[m.map(t=>(0,q.jsx)(xe,{language:e,job:t,freshness:n,onDismiss:()=>p(e=>e.filter(e=>e!==t.jobId))},t.jobId)),g.length?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`header`,{className:`brain-jobs-head`,children:(0,q.jsx)(`strong`,{children:a(e,`brain.jobs.title`)})}),(0,q.jsx)(`ul`,{className:`brain-jobs-list`,children:g.map(t=>{let n=Math.max(t.total,t.processed,1),r=Math.min(100,Math.round(t.processed/n*100)),i=X.has(t.status),s=o.isPending&&o.variables===t.jobId;return(0,q.jsxs)(`li`,{className:`brain-jobs-item is-${t.status}`,children:[(0,q.jsxs)(`div`,{className:`brain-jobs-item-row`,children:[(0,q.jsx)(`span`,{className:`brain-jobs-status`,children:a(e,ve(t.status))}),(0,q.jsx)(`span`,{className:`brain-jobs-counts`,children:a(e,`brain.jobs.progress`,{processed:t.processed,total:t.total})}),t.failed>0?(0,q.jsxs)(`span`,{className:`brain-jobs-failed`,children:[(0,q.jsx)(h,{className:`h-3 w-3`,"aria-hidden":`true`}),a(e,`brain.jobs.failedCount`,{count:t.failed})]}):null]}),(0,q.jsx)(`div`,{className:`brain-jobs-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,"aria-label":a(e,`brain.jobs.progressAria`,{processed:t.processed,total:t.total}),children:(0,q.jsx)(`span`,{className:`brain-jobs-bar-fill`,style:{width:`${r}%`}})}),i?(0,q.jsxs)(`button`,{type:`button`,className:`brain-jobs-resume`,disabled:o.isPending,onClick:()=>o.mutate(t.jobId),children:[(0,q.jsx)(ee,{className:`h-3 w-3`,"aria-hidden":`true`}),s?a(e,`brain.jobs.resuming`):a(e,`brain.jobs.resume`)]}):null]},t.jobId)})})]}):null]})}function $(e){return e.split(/[\\/]/).filter(Boolean).pop()||e}function Se(e,t){if(!t)return a(e,`brain.watch.scan.never`);let n=Date.parse(t);if(!Number.isFinite(n))return a(e,`brain.watch.scan.never`);let r=Math.max(0,Date.now()-n),i=Math.floor(r/6e4);if(i<1)return a(e,`brain.watch.scan.now`);if(i<60)return a(e,`brain.watch.scan.minutes`,{count:i});let o=Math.floor(i/60);return o<24?a(e,`brain.watch.scan.hours`,{count:o}):a(e,`brain.watch.scan.days`,{count:Math.floor(o/24)})}var Ce=4;function we({language:e}){let t=d({queryKey:[`ingestionWatch`],queryFn:r.ingestionWatchStatus,staleTime:3e4,refetchOnWindowFocus:!1,retry:!1}),n=b.useMemo(()=>t.data?.ok?w(t.data.data):null,[t.data]);if(!n||n.enabledCount<1)return null;let i=n.watches.filter(e=>e.enabled).slice(0,Ce);return i.length?(0,q.jsxs)(`section`,{className:`brain-watch-card`,"aria-label":a(e,`brain.watch.aria`),"data-testid":`watch-health-card`,children:[(0,q.jsxs)(`header`,{className:`brain-watch-head`,children:[(0,q.jsx)(y,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`strong`,{children:a(e,`brain.watch.title`)})]}),n.polling?null:(0,q.jsxs)(`p`,{className:`brain-watch-note`,role:`note`,"data-testid":`watch-polling-note`,children:[(0,q.jsx)(m,{className:`h-3 w-3`,"aria-hidden":`true`}),a(e,`brain.watch.notLive`)]}),(0,q.jsx)(`ul`,{className:`brain-watch-list`,children:i.map(t=>(0,q.jsx)(Te,{language:e,watch:t},t.id))})]}):null}function Te({language:e,watch:t}){return(0,q.jsxs)(`li`,{className:`brain-watch-item`,children:[(0,q.jsxs)(`div`,{className:`brain-watch-item-row`,children:[(0,q.jsx)(`span`,{className:`brain-watch-path`,title:t.path,children:$(t.path)}),(0,q.jsx)(`small`,{className:`brain-watch-scan`,children:Se(e,t.lastScanAt)})]}),(0,q.jsxs)(`div`,{className:`brain-watch-item-row`,children:[t.lastResult&&t.lastResult.ingested>0?(0,q.jsx)(`span`,{className:`brain-watch-stat`,children:a(e,`brain.watch.ingested`,{count:t.lastResult.ingested})}):null,t.lastResult&&t.lastResult.failed>0?(0,q.jsxs)(`span`,{className:`brain-watch-stat is-failed`,children:[(0,q.jsx)(h,{className:`h-3 w-3`,"aria-hidden":`true`}),a(e,`brain.jobs.failedCount`,{count:t.lastResult.failed})]}):null,t.trackedFiles>0?(0,q.jsx)(`small`,{className:`brain-watch-tracked`,children:a(e,`brain.watch.tracked`,{count:t.trackedFiles})}):null]}),t.lastErrors.length?(0,q.jsxs)(`div`,{className:`brain-watch-errors`,children:[(0,q.jsx)(`small`,{children:a(e,`brain.watch.errors`)}),(0,q.jsx)(`ul`,{children:t.lastErrors.slice(0,3).map((e,t)=>(0,q.jsx)(`li`,{children:[e.path?$(e.path):``,e.detail].filter(Boolean).join(` — `)},`${e.path}-${t}`))})]}):null]})}function Ee(e,t){if(!t)return``;let n=new Date(t);return Number.isNaN(n.getTime())?``:n.toLocaleTimeString(e===`ko`?`ko-KR`:`en-US`,{hour:`2-digit`,minute:`2-digit`})}function De({language:e,knownRunIds:t}){let n=d({queryKey:[`agentApprovals`],queryFn:r.agentApprovals,staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),i=b.useMemo(()=>n.data?.ok?C(n.data.data):[],[n.data]),o=b.useMemo(()=>new Set(t),[t]),s=i.filter(e=>!o.has(e.runId));return s.length?(0,q.jsx)(`aside`,{className:`brain-pending-approvals`,role:`note`,"aria-label":a(e,`brain.approval.pendingNotice.aria`),"data-testid":`pending-approvals-notice`,children:s.slice(0,2).map(t=>{let n=Ee(e,t.expiresAt);return(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{children:t.goal?a(e,`brain.approval.pendingNotice`,{goal:t.goal}):a(e,`brain.approval.pendingNotice.generic`)}),(0,q.jsx)(`small`,{children:n?a(e,`brain.approval.pendingNotice.expiry`,{time:n}):a(e,`brain.approval.pendingNotice.hint`)})]},t.runId)})}):null}export{S as C,te as E,me as S,v as T,pe as _,we as a,ue as b,M as c,ae as d,k as f,fe as g,B as h,_e as i,j as l,A as m,De as n,de as o,se as p,ge as r,P as s,Q as t,ne as u,le as v,V as w,oe as x,re as y};
1
+ import{S as e,a as t,b as n,d as r,g as i,m as a,n as o,o as s,t as c,y as l}from"./utils-fEGWreKB.js";import{r as u,t as d}from"./useQuery-CT2ChyuU.js";import{t as f}from"./workspace-ClDBz_0f.js";import{n as p}from"./input-DrMc0Xns.js";import{t as m}from"./circle-pause-B2P72YOO.js";import{d as ee,l as h,s as g}from"./index-mLP0-YNO.js";var te=i(`brain-circuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),_=i(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),v=i(`database-backup`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 12a9 3 0 0 0 5 2.69`,key:`1ui2ym`}],[`path`,{d:`M21 9.3V5`,key:`6k6cib`}],[`path`,{d:`M3 5v14a9 3 0 0 0 6.47 2.88`,key:`i62tjy`}],[`path`,{d:`M12 12v4h4`,key:`1bxaet`}],[`path`,{d:`M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16`,key:`1f4ei9`}]]),y=i(`folder-sync`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5`,key:`1dkoa9`}],[`path`,{d:`M12 10v4h4`,key:`1czhmt`}],[`path`,{d:`m12 14 1.535-1.605a5 5 0 0 1 8 1.5`,key:`lvuxfi`}],[`path`,{d:`M22 22v-4h-4`,key:`1ewp4q`}],[`path`,{d:`m22 18-1.535 1.605a5 5 0 0 1-8-1.5`,key:`14ync0`}]]),b=e(n());function ne(e){return c(e).flatMap(e=>{let t=V(e,[`id`,`conversation_id`]);return t?[{id:t,title:V(e,[`title`,`summary`,`last_message`],t).trim()||t,messageCount:Math.max(0,Math.round(G(e,[`message_count`,`messages`]))),updatedAt:U(e,[`updated_at`,`updatedAt`,`created_at`,`createdAt`])}]:[]}).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))}function re(e){return c((B(e)?e:{}).messages).flatMap(e=>{let t=V(e,[`role`]),n=typeof e.content==`string`?e.content:``;return t!==`user`&&t!==`assistant`||!n.trim()?[]:[{role:t,content:n}]})}function ie(e,t,n){let r=V(e,[`id`]);if(r){let e=`brain.memoryTier.${r}`,n=a(t,e);if(n!==e)return n}return n}function ae(e,t,n=`ko`){let r=B(e)?e:{},i=(c(r.sources).length?c(r.sources):c(r.tiers)).map((e,t)=>({id:V(e,[`id`,`source`,`label`],`memory-${t}`),title:ie(e,n,V(e,[`title`,`label`,`source`,`path`,`name`],`Workspace memory`)),kind:H(e,[`type`,`source_type`,`kind`,`health`],`Memory`),tags:[],agentGenerated:!1})),a=c(r.recent_memories||r.recentMemories).map((e,t)=>{let n=B(e.metadata)?e.metadata:{},r=W(e,[`tags`]),i=V(e,[`content`,`summary`,`detail`]),a=V(n,[`source`]),o=r.includes(`agent-synthesis`)||a===`agent_runtime`||a===`agent_runtime_synthesis`;return{id:V(e,[`id`],`recent-memory-${t}`),title:i?i.replace(/\s+/g,` `).slice(0,96):H(e,[`kind`],`Memory`),kind:H(e,[`kind`],`Memory`),detail:i,tags:r,agentGenerated:o}}),o=c(t).map((e,t)=>({id:V(e,[`id`,`conversation_id`],`conversation-${t}`),title:V(e,[`title`,`summary`,`id`],`Conversation`),kind:`Conversation`,tags:[],agentGenerated:!1}));return F([...a,...i,...o]).slice(0,12)}function oe(e){let t=B(e)?e:{},n=c(t.nodes),r=c(t.edges),i=n.flatMap(e=>{let t=V(e,[`id`,`node_id`,`title`,`label`]);if(!t)return[];let n=B(e.metadata)?e.metadata:{},r=H(e,[`type`,`kind`,`category`],`Concept`),i=V(e,[`title`,`label`,`name`],t.replace(/^[^:]+:/,``)),a=V(e,[`summary`,`description`,`snippet`])||V(n,[`summary`,`description`,`relative_path`,`filename`]),s=o(G(e,[`importance_norm`,`importance`,`score`])||.5,.08,1),c=U(e,[`created_at`,`createdAt`,`added_at`,`addedAt`,`timestamp`,`updated_at`,`updatedAt`])??U(n,[`created_at`,`createdAt`,`added_at`,`addedAt`,`timestamp`,`updated_at`,`updatedAt`]);return[{id:t,label:i,type:r,summary:a,importance:s,...c===void 0?{}:{createdAt:c}}]}).sort((e,t)=>t.importance-e.importance),a=new Set(i.map(e=>e.id));return{nodes:i,edges:r.flatMap((e,t)=>{let n=V(e,[`from`,`source`,`source_id`]),r=V(e,[`to`,`target`,`target_id`]);return!n||!r||!a.has(n)||!a.has(r)?[]:[{id:V(e,[`id`],`edge-${t}`),source:n,target:r,label:H(e,[`type`,`label`,`relationship`],`Relates`),weight:G(e,[`weight`,`score`,`confidence`])||1}]})}}function se(e){let t=B(e)?e:{},n=[t,t.knowledge_graph,t.ingestion,t.result].filter(B),r=new Set,i=0,a,o;for(let e of n){let t=V(e,[`node_id`,`graph_node`,`graph_node_id`]);t&&r.add(t);for(let t of c(e.indexed_nodes))if(typeof t==`string`&&t.trim())r.add(t.trim());else if(B(t)){let e=V(t,[`node_id`,`graph_node_id`,`id`]);e&&r.add(e)}i=Math.max(i,G(e,[`chunk_count`,`chunks`,`indexed_count`])),typeof e.duplicate==`boolean`&&(a=e.duplicate),o||=V(e,[`provenance_id`])}let s;for(let e of n){let t=ce(e);if(t){s=t;break}}return{nodeIds:Array.from(r),chunkCount:i,...a===void 0?{}:{duplicate:a},...o?{provenanceId:o}:{},...s?{extraction:s}:{}}}function ce(e){let t=B(e)?e:{},n=B(t.extraction_quality)?t.extraction_quality:null;if(!n)return null;let r=V(n,[`level`]);if(r!==`high`&&r!==`medium`&&r!==`low`)return null;let i=W(t,[`warnings`]).length?W(t,[`warnings`]):W(n,[`warnings`]);return{score:G(n,[`score`]),level:r,reasons:W(n,[`reasons`]),warnings:i}}function le(e){let t=B(e)?e:{},n=B(t.context_quality)?t.context_quality:null,r=!n&&B(t.trace)&&B(t.trace.context_quality)?t.trace.context_quality:null,i=n||r||(typeof t.mode==`string`&&typeof t.limited==`boolean`?t:null);if(!i)return null;let a=V(i,[`mode`]);if(!a)return null;let o=typeof i.reason==`string`&&i.reason.trim()?i.reason.trim():null;return{mode:a,nodes:Math.max(0,Math.round(G(i,[`nodes`]))),limited:K(i,[`limited`],!1),reason:o}}function ue(e){let t=B(e)?e:{},n=(B(t.grounding)?t.grounding:null)||(typeof t.status==`string`&&`label`in t?t:null);if(!n)return null;let r=V(n,[`status`]);return[`supported`,`unsupported`,`no_context`].includes(r)?{status:r,reason:typeof n.reason==`string`&&n.reason.trim()?n.reason.trim():null}:null}function x(e){if(!B(e))return null;let t=V(e,[`status`]);if(t!==`ok`&&t!==`pending`&&t!==`failed`)return null;let n=V(e,[`detail`]);return{status:t,...n?{detail:n}:{}}}function de(e){let t=!!e.generation?.repaired,n=new Map;for(let t of e.artifacts||[])t&&typeof t.path==`string`&&n.set(t.path,!!t.previewable);let r=new Map,i=null;if(Array.isArray(e.brain_ingest))for(let t of e.brain_ingest){let e=x(t);e&&B(t)&&typeof t.path==`string`&&r.set(t.path,e)}else i=x(e.brain_ingest);let a=e.created_files||[];return a.map(e=>{let o=r.get(e.path)||(a.length===1?i:null);return{path:e.path,filename:e.filename||e.path.split(`/`).pop()||e.path,bytes:e.bytes||0,repaired:t,...n.has(e.path)?{previewable:n.get(e.path)}:{},...o?{brainIngest:o}:{}}})}function fe(e){if(!B(e))return null;let t=V(e,[`phase`]),n=V(e,[`event`]);if(!t||!n)return null;let r=Number(e.step);return{phase:t,event:n,...V(e,[`action`])?{action:V(e,[`action`])}:{},...V(e,[`path`])?{path:V(e,[`path`])}:{},...Number.isFinite(r)?{step:Math.round(r)}:{},...typeof e.ok==`boolean`?{ok:e.ok}:{},...V(e,[`decision`])?{decision:V(e,[`decision`])}:{},...V(e,[`verdict`])?{verdict:V(e,[`verdict`])}:{},...V(e,[`state`])?{state:V(e,[`state`])}:{},...V(e,[`detail`,`error`])?{detail:V(e,[`detail`,`error`])}:{}}}function pe(e){return c(e).flatMap(e=>{if(!B(e))return[];let t=V(e,[`action`,`tool`]),n=V(e,[`state`]),r=V(e,[`error`]);if(!t&&!n&&!r)return[];let i=V(B(e.args)?e.args:{},[`path`,`target`,`file`]);return t?[{phase:`execute`,event:`tool`,action:t,...i?{path:i}:{},ok:!r,...r?{detail:r}:{}}]:r?[{phase:`execute`,event:`state`,...n?{state:n}:{},ok:!1,detail:r}]:[{phase:`terminal`,event:`state`,state:n}]})}function me(e){if(!B(e))return null;let t={};if(B(e.repairs))for(let[n,r]of Object.entries(e.repairs)){let e=Number(r);Number.isFinite(e)&&e>0&&(t[n]=Math.round(e))}let n=Math.max(0,Math.round(G(e,[`parse_errors`,`parseErrors`]))),r=Math.max(0,Math.round(G(e,[`parse_recovered`,`parseRecovered`]))),i=Object.values(t).reduce((e,t)=>e+t,0)+r;return i<1?null:{repairs:t,parseErrors:n,parseRecovered:r,total:i}}function S(e,t){if(!B(e))return null;let n=e=>{if(!B(e))return``;let n=e[t];return typeof n==`string`?n:``},r=n(e.headline),i=c(e.details).map(n).filter(Boolean),a=V(e,[`code`]);if(!r&&!i.length)return null;let o=B(e.model_strain)?V(e.model_strain,[`level`]):``,s=o===`light`||o===`moderate`||o===`heavy`?o:`none`,l=e.ok===!0;return l&&!i.length?null:{code:a,ok:l,headline:r,details:i,strainLevel:s}}function C(e){return c((B(e)?e:{}).pending).flatMap(e=>{let t=V(e,[`run_id`,`runId`]);return t?[{runId:t,goal:V(e,[`goal`]),expiresAt:V(e,[`expires_at`,`expiresAt`])}]:[]})}function w(e){let t=B(e)?e:{},n=c(t.watches).flatMap(e=>{if(!B(e))return[];let t=V(e,[`id`]),n=V(e,[`path`]);if(!t&&!n)return[];let r=B(e.last_result)?e.last_result:null,i=c(e.last_errors).flatMap(e=>{if(typeof e==`string`&&e.trim())return[{path:``,detail:e.trim()}];if(!B(e))return[];let t=V(e,[`detail`,`reason`,`error`]),n=V(e,[`path`,`source`,`file`]);return!t&&!n?[]:[{path:n,detail:t}]});return[{id:t||n,path:n,enabled:K(e,[`enabled`],!1),lastScanAt:V(e,[`last_scan_at`,`lastScanAt`]),lastResult:r?{status:V(r,[`status`]),ingested:Math.max(0,Math.round(G(r,[`ingested`]))),failed:Math.max(0,Math.round(G(r,[`failed`])))}:null,trackedFiles:Math.max(0,Math.round(G(e,[`tracked_files`,`trackedFiles`]))),lastErrors:i.slice(0,3)}]});return{enabledCount:Math.max(0,Math.round(G(t,[`enabled_count`,`enabledCount`]))),polling:K(t,[`polling`],!1),intervalSeconds:Math.max(0,Math.round(G(t,[`interval_seconds`,`intervalSeconds`]))),watches:n}}function T(e){let t=B(e)?e:{};return{status:V(t,[`status`],`unavailable`),pendingItems:Math.max(0,Math.round(G(t,[`pending_items`,`pendingItems`]))),totalItems:Math.max(0,Math.round(G(t,[`total_items`,`totalItems`]))),detail:V(t,[`detail`])}}function E(e){return typeof e==`string`?e.trim():B(e)?[V(e,[`source`,`path`,`file`]),V(e,[`detail`,`reason`,`error`])].filter(Boolean).join(` — `):``}function D(e){return c((B(e)?e:{}).jobs).flatMap(e=>{let t=V(e,[`job_id`,`jobId`,`id`]);if(!t)return[];let n=V(e,[`created_at`,`createdAt`]),r=V(e,[`updated_at`,`updatedAt`]);return[{jobId:t,status:V(e,[`status`],`queued`),total:Math.max(0,Math.round(G(e,[`total`]))),processed:Math.max(0,Math.round(G(e,[`processed`]))),failed:Math.max(0,Math.round(G(e,[`failed`]))),errors:c(e.errors).map(E).filter(Boolean).slice(0,10),...n?{createdAt:n}:{},...r?{updatedAt:r}:{}}]})}function O(e,t){for(let n of[`recommended`,`cloud`,`loaded`,`loaded_models`,`models`])for(let r of c(e[n])){if(V(r,[`id`,`model_id`,`name`])!==t)continue;let e=V(r,[`display_name`,`model_name`,`name`]);if(e&&e!==t)return e}return``}function k(e){let n=B(e)?e:{},r=V(n,[`current`,`current_model`,`local_model`]);if(r)return O(n,r)||t(r);let i=c(n.loaded||n.loaded_models).find(e=>e.id||e.name||e.model_id);if(!i)return`local mind`;let a=V(i,[`display_name`,`model_name`,`name`]),o=V(i,[`id`,`model_id`]);return a&&a!==o?a:o?O(n,o)||t(o):`local mind`}function A(e){let t=B(e)?e:{};return V(t,[`current`,`current_model`,`local_model`])?!0:c(t.loaded||t.loaded_models).some(e=>e.id||e.name||e.model_id)}function j(e,t,n){let r=B(e)?e:{},i=B(r.brain_readiness)?r.brain_readiness:{},a=V(i,[`state`]),s=G(i,[`depth`]),c=G(i,[`score`]);if((a===`quiet`||a===`forming`||a===`alive`)&&z(s)){let e=B(i.signals)?i.signals:{};return{score:o(Math.round(c||0),0,100),state:a,depth:s,titleKey:V(i,[`title_key`,`titleKey`],`brain.readiness.${a}`),actionKey:V(i,[`action_key`,`actionKey`],R(a)),source:`memory_service`,signals:{memoryCount:G(e,[`memory_count`,`memoryCount`]),conceptCount:G(e,[`concept_count`,`conceptCount`]),relationshipCount:G(e,[`relationship_count`,`relationshipCount`]),healthySources:G(e,[`healthy_sources`,`healthySources`])}}}return L(t,n)}function M(e,t=``){let n=B(e)&&typeof e.ok==`boolean`&&`data`in e?e:null;if(n&&!n.ok)return N(t);let r=n?n.data:e,i=B(r)?r:{},a=B(i.model_continuity)?i.model_continuity:{},o=B(i.proofs)?i.proofs:{},s=B(i.recall)?i.recall:{},l=B(i.claims)?i.claims:{},u=G(o,[`durable_items`,`durableItems`]);return{status:V(i,[`status`],`quiet`),modelContinuity:{activeModel:V(a,[`active_model`,`activeModel`],t),brainOwner:V(a,[`brain_owner`,`brainOwner`],`lattice_brain`),capability:K(a,[`capability`],!0),survivesModelSwitch:K(a,[`survives_model_switch`,`survivesModelSwitch`],!1),proven:K(a,[`proven`],!1),contextStore:V(a,[`context_store`,`contextStore`],`workspace + conversation + graph + vector`)},proofs:{durableItems:u,hasDurableEvidence:K(o,[`has_durable_evidence`,`hasDurableEvidence`],u>0),workspaceMemories:G(o,[`workspace_memories`,`workspaceMemories`]),conversations:G(o,[`conversations`]),graphConcepts:G(o,[`graph_concepts`,`graphConcepts`]),vectorItems:G(o,[`vector_items`,`vectorItems`]),healthySources:G(o,[`healthy_sources`,`healthySources`])},recall:{query:V(s,[`query`]),count:G(s,[`count`]),items:c(s.items).map((e,t)=>({id:V(e,[`id`],`recall-${t}`),source:H(e,[`source`],`Memory`),title:V(e,[`title`],`Memory`),snippet:V(e,[`snippet`]),score:G(e,[`score`]),matchedTerms:W(e,[`matched_terms`,`matchedTerms`]),confidence:he(e,G(e,[`score`])),locator:V(e,[`locator`])}))},claims:{canRecallUserContext:K(l,[`can_recall_user_context`,`canRecallUserContext`],!1),keepsContextAcrossModels:K(l,[`keeps_context_across_models`,`keepsContextAcrossModels`],!1),isKnowledgeStore:K(l,[`is_knowledge_store`,`isKnowledgeStore`],!1)}}}function N(e){return{status:`unavailable`,modelContinuity:{activeModel:e,brainOwner:``,capability:!1,survivesModelSwitch:!1,proven:!1,contextStore:``},proofs:{durableItems:0,hasDurableEvidence:!1,workspaceMemories:0,conversations:0,graphConcepts:0,vectorItems:0,healthySources:0},recall:{query:``,count:0,items:[]},claims:{canRecallUserContext:!1,keepsContextAcrossModels:!1,isKnowledgeStore:!1}}}function P(e){let t=B(e)?e:{},n=B(t.focus)?t.focus:{},r=c(t.next_actions||t.nextActions),i=c(t.suggested_questions||t.suggestedQuestions),a=c(t.proactive_actions||t.proactiveActions),s=c(t.evidence),l=r.length?r:[{id:`add_source`,label_key:`brain.brief.action.add`,detail_key:`brain.brief.action.add.detail`,route:`/capture`,priority:10},{id:`ask_brain`,label_key:`brain.brief.action.ask`,detail_key:`brain.brief.action.ask.detail`,route:``,priority:9}],u=s.length?s:[{id:`durable`,label_key:`brain.brief.evidence.durable`,value:0,detail_key:`brain.brief.evidence.durable.detail`},{id:`graph`,label_key:`brain.brief.evidence.graph`,value:0,detail_key:`brain.brief.evidence.graph.detail`},{id:`sources`,label_key:`brain.brief.evidence.sources`,value:0,detail_key:`brain.brief.evidence.sources.detail`}];return{status:V(t,[`status`],`quiet`),score:o(Math.round(G(t,[`score`])),0,100),headlineKey:V(t,[`headline_key`,`headlineKey`],`brain.brief.headline.quiet`),bodyKey:V(t,[`body_key`,`bodyKey`],`brain.brief.body.quiet`),focus:{kind:V(n,[`kind`],`empty`),title:V(n,[`title`]),detail:V(n,[`detail`]),source:H(n,[`source`],`Memory`),score:G(n,[`score`]),empty:K(n,[`empty`],!V(n,[`title`]))},nextActions:l.map(e=>({id:V(e,[`id`],`ask_brain`),labelKey:V(e,[`label_key`,`labelKey`],`brain.brief.action.ask`),detailKey:V(e,[`detail_key`,`detailKey`],`brain.brief.action.ask.detail`),route:V(e,[`route`]),priority:G(e,[`priority`])})),suggestedQuestions:i.map(e=>({id:V(e,[`id`],`suggested-question`),labelKey:V(e,[`label_key`,`labelKey`],`brain.suggestion.focus.label`),detailKey:V(e,[`detail_key`,`detailKey`],`brain.suggestion.focus.detail`),promptKey:V(e,[`prompt_key`,`promptKey`],`brain.suggestion.focus.prompt`),params:I(e.params),priority:G(e,[`priority`])})).sort((e,t)=>t.priority-e.priority),proactiveActions:a.map(e=>({id:V(e,[`id`],`proactive-action`),intent:V(e,[`intent`],`ask`),labelKey:V(e,[`label_key`,`labelKey`],`brain.proactive.evidence.label`),detailKey:V(e,[`detail_key`,`detailKey`],`brain.proactive.evidence.detail`),prompt:V(e,[`prompt`]),route:V(e,[`route`]),priority:G(e,[`priority`]),context:I(e.context)})).sort((e,t)=>t.priority-e.priority),evidence:u.map(e=>({id:V(e,[`id`],`evidence`),labelKey:V(e,[`label_key`,`labelKey`],`brain.brief.evidence.durable`),value:G(e,[`value`]),detailKey:V(e,[`detail_key`,`detailKey`],`brain.brief.evidence.durable.detail`)})),generatedAt:V(t,[`generated_at`,`generatedAt`])}}function F(e){let t=new Set;return e.filter(e=>t.has(e.id)?!1:(t.add(e.id),!0))}function I(e){return B(e)?Object.entries(e).reduce((e,[t,n])=>((typeof n==`string`||typeof n==`number`)&&(e[t]=n),e),{}):{}}function L(e,t){let n=Math.min(100,Math.round(e*12+t*10));return e<1?{score:Math.max(12,n),state:`quiet`,depth:2,titleKey:`brain.readiness.quiet`,actionKey:`brain.readiness.start`,source:`frontend_fallback`,signals:{memoryCount:e,conceptCount:t,relationshipCount:0,healthySources:0}}:t<3?{score:Math.max(38,n),state:`forming`,depth:3,titleKey:`brain.readiness.forming`,actionKey:`brain.readiness.grow`,source:`frontend_fallback`,signals:{memoryCount:e,conceptCount:t,relationshipCount:0,healthySources:0}}:{score:Math.max(72,n),state:`alive`,depth:5,titleKey:`brain.readiness.alive`,actionKey:`brain.readiness.map`,source:`frontend_fallback`,signals:{memoryCount:e,conceptCount:t,relationshipCount:0,healthySources:0}}}function R(e){return e===`quiet`?`brain.readiness.start`:e===`forming`?`brain.readiness.grow`:`brain.readiness.map`}function z(e){return e>=1&&e<=5&&Number.isInteger(e)}var B=s;function V(e,t,n=``){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t;if(typeof t==`number`&&Number.isFinite(t))return String(t)}return n}function H(e,t,n=``){return V(e,t,n).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function U(e,t){for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t<0xe8d4a51000?t*1e3:t;if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&/^\d+$/.test(t.trim()))return e<0xe8d4a51000?e*1e3:e;let n=Date.parse(t);if(Number.isFinite(n))return n}}}function W(e,t){for(let n of t){let t=e[n];if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&e.trim().length>0)}return[]}function he(e,t){let n=e.confidence;return n===`high`||n===`medium`||n===`low`?n:t>=.65?`high`:t>=.3?`medium`:`low`}function G(e,t){for(let n of t){let t=Number(e[n]);if(Number.isFinite(t))return t}return 0}function K(e,t,n){for(let n of t){let t=e[n];if(typeof t==`boolean`)return t}return n}var q=l();function J(){let e=d({queryKey:[`vectorFreshness`],queryFn:r.brainVectorFreshness,staleTime:6e4,refetchOnWindowFocus:!1,retry:!1});return b.useMemo(()=>e.data?.ok?T(e.data.data):null,[e.data])}function ge({language:e}){let t=u(),n=J(),i=f({mutationFn:()=>r.memoryRebuild(),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`vectorFreshness`]})}});if(!n||n.status!==`stale_embedder`)return null;let o=i.isSuccess&&i.data&&!i.data.ok;return(0,q.jsxs)(`div`,{className:`brain-stale-embedder`,role:`status`,"data-testid":`stale-embedder-notice`,children:[(0,q.jsx)(h,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`strong`,{children:a(e,`brain.freshness.staleEmbedder`)}),(0,q.jsx)(`small`,{children:a(e,`brain.freshness.staleEmbedder.detail`)}),o?(0,q.jsx)(`small`,{className:`is-error`,children:a(e,`brain.freshness.reindex.failed`)}):null]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`stale-embedder-reindex`,disabled:i.isPending,onClick:()=>i.mutate(),children:a(e,i.isPending?`brain.freshness.reindex.running`:`brain.freshness.reindex`)})]})}function _e({language:e}){let t=J();return!t||t.status!==`pending`||t.pendingItems<1?null:(0,q.jsxs)(`p`,{className:`brain-freshness-chip`,role:`status`,"data-testid":`vector-freshness-chip`,children:[(0,q.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:a(e,`brain.freshness.pending`,{count:t.pendingItems})})]})}var Y=new Set([`queued`,`running`]),X=new Set([`failed`,`partial`]);function Z(e){return Y.has(e.status)}function ve(e){return e===`queued`||e===`running`||e===`completed`||e===`failed`||e===`partial`?`brain.jobs.status.${e}`:`brain.jobs.status.queued`}var ye=new Set([`completed`,`partial`]),be=3;function xe({language:e,job:t,freshness:n,onDismiss:r}){let i=n&&n.totalItems>0&&(n.status===`ready`||n.status===`pending`)?Math.max(0,Math.min(100,Math.round((n.totalItems-n.pendingItems)/n.totalItems*100))):null,o=t.errors.slice(0,be);return(0,q.jsxs)(`div`,{className:`brain-jobs-report lattice-success-pulse is-${t.status}`,role:`status`,"data-testid":`ingestion-job-report`,children:[(0,q.jsxs)(`div`,{className:`brain-jobs-report-head`,children:[(0,q.jsx)(p,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,q.jsx)(`strong`,{children:a(e,t.status===`partial`?`brain.jobs.report.titlePartial`:`brain.jobs.report.title`)}),r?(0,q.jsx)(`button`,{type:`button`,className:`brain-jobs-report-dismiss`,"aria-label":a(e,`brain.jobs.report.dismiss`),onClick:r,children:(0,q.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}):null]}),(0,q.jsxs)(`div`,{className:`brain-jobs-report-stats`,children:[t.processed>0?(0,q.jsx)(`span`,{className:`brain-jobs-report-stat`,children:a(e,`brain.jobs.report.documents`,{count:t.processed})}):null,t.failed>0?(0,q.jsx)(`span`,{className:`brain-jobs-report-stat is-failed`,children:a(e,`brain.jobs.failedCount`,{count:t.failed})}):null,i===null?null:(0,q.jsx)(`span`,{className:`brain-jobs-report-stat`,children:a(e,`brain.jobs.report.vector`,{percent:i})})]}),o.length?(0,q.jsxs)(`div`,{className:`brain-jobs-report-samples`,children:[(0,q.jsx)(`small`,{children:a(e,`brain.jobs.report.skipped`)}),(0,q.jsx)(`ul`,{children:o.map(e=>(0,q.jsx)(`li`,{children:e},e))})]}):null]})}function Q({language:e}){let t=u(),n=J(),i=d({queryKey:[`ingestionJobs`],queryFn:r.ingestionJobs,refetchOnWindowFocus:!1,retry:!1,refetchInterval:e=>{let t=e.state.data;return t?.ok&&D(t.data).some(Z)?4e3:!1}}),o=f({mutationFn:e=>r.resumeIngestionJob(e),onSettled:()=>void t.invalidateQueries({queryKey:[`ingestionJobs`]})}),s=b.useMemo(()=>i.data?.ok?D(i.data.data):[],[i.data]),c=b.useRef(new Map),[l,p]=b.useState([]);b.useEffect(()=>{let e=c.current,t=[];for(let n of s){let r=e.get(n.jobId);r&&Y.has(r)&&ye.has(n.status)&&t.push(n.jobId),e.set(n.jobId,n.status)}t.length&&p(e=>[...t,...e.filter(e=>!t.includes(e))].slice(0,2))},[s]);let m=l.map(e=>s.find(t=>t.jobId===e)).filter(e=>!!e),g=s.filter(e=>Z(e)||X.has(e.status)).slice(0,4);return!g.length&&!m.length?null:(0,q.jsxs)(`section`,{className:`brain-jobs-panel`,"aria-label":a(e,`brain.jobs.aria`),"data-testid":`ingestion-jobs-panel`,children:[m.map(t=>(0,q.jsx)(xe,{language:e,job:t,freshness:n,onDismiss:()=>p(e=>e.filter(e=>e!==t.jobId))},t.jobId)),g.length?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`header`,{className:`brain-jobs-head`,children:(0,q.jsx)(`strong`,{children:a(e,`brain.jobs.title`)})}),(0,q.jsx)(`ul`,{className:`brain-jobs-list`,children:g.map(t=>{let n=Math.max(t.total,t.processed,1),r=Math.min(100,Math.round(t.processed/n*100)),i=X.has(t.status),s=o.isPending&&o.variables===t.jobId;return(0,q.jsxs)(`li`,{className:`brain-jobs-item is-${t.status}`,children:[(0,q.jsxs)(`div`,{className:`brain-jobs-item-row`,children:[(0,q.jsx)(`span`,{className:`brain-jobs-status`,children:a(e,ve(t.status))}),(0,q.jsx)(`span`,{className:`brain-jobs-counts`,children:a(e,`brain.jobs.progress`,{processed:t.processed,total:t.total})}),t.failed>0?(0,q.jsxs)(`span`,{className:`brain-jobs-failed`,children:[(0,q.jsx)(h,{className:`h-3 w-3`,"aria-hidden":`true`}),a(e,`brain.jobs.failedCount`,{count:t.failed})]}):null]}),(0,q.jsx)(`div`,{className:`brain-jobs-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,"aria-label":a(e,`brain.jobs.progressAria`,{processed:t.processed,total:t.total}),children:(0,q.jsx)(`span`,{className:`brain-jobs-bar-fill`,style:{width:`${r}%`}})}),i?(0,q.jsxs)(`button`,{type:`button`,className:`brain-jobs-resume`,disabled:o.isPending,onClick:()=>o.mutate(t.jobId),children:[(0,q.jsx)(ee,{className:`h-3 w-3`,"aria-hidden":`true`}),s?a(e,`brain.jobs.resuming`):a(e,`brain.jobs.resume`)]}):null]},t.jobId)})})]}):null]})}function $(e){return e.split(/[\\/]/).filter(Boolean).pop()||e}function Se(e,t){if(!t)return a(e,`brain.watch.scan.never`);let n=Date.parse(t);if(!Number.isFinite(n))return a(e,`brain.watch.scan.never`);let r=Math.max(0,Date.now()-n),i=Math.floor(r/6e4);if(i<1)return a(e,`brain.watch.scan.now`);if(i<60)return a(e,`brain.watch.scan.minutes`,{count:i});let o=Math.floor(i/60);return o<24?a(e,`brain.watch.scan.hours`,{count:o}):a(e,`brain.watch.scan.days`,{count:Math.floor(o/24)})}var Ce=4;function we({language:e}){let t=d({queryKey:[`ingestionWatch`],queryFn:r.ingestionWatchStatus,staleTime:3e4,refetchOnWindowFocus:!1,retry:!1}),n=b.useMemo(()=>t.data?.ok?w(t.data.data):null,[t.data]);if(!n||n.enabledCount<1)return null;let i=n.watches.filter(e=>e.enabled).slice(0,Ce);return i.length?(0,q.jsxs)(`section`,{className:`brain-watch-card`,"aria-label":a(e,`brain.watch.aria`),"data-testid":`watch-health-card`,children:[(0,q.jsxs)(`header`,{className:`brain-watch-head`,children:[(0,q.jsx)(y,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`strong`,{children:a(e,`brain.watch.title`)})]}),n.polling?null:(0,q.jsxs)(`p`,{className:`brain-watch-note`,role:`note`,"data-testid":`watch-polling-note`,children:[(0,q.jsx)(m,{className:`h-3 w-3`,"aria-hidden":`true`}),a(e,`brain.watch.notLive`)]}),(0,q.jsx)(`ul`,{className:`brain-watch-list`,children:i.map(t=>(0,q.jsx)(Te,{language:e,watch:t},t.id))})]}):null}function Te({language:e,watch:t}){return(0,q.jsxs)(`li`,{className:`brain-watch-item`,children:[(0,q.jsxs)(`div`,{className:`brain-watch-item-row`,children:[(0,q.jsx)(`span`,{className:`brain-watch-path`,title:t.path,children:$(t.path)}),(0,q.jsx)(`small`,{className:`brain-watch-scan`,children:Se(e,t.lastScanAt)})]}),(0,q.jsxs)(`div`,{className:`brain-watch-item-row`,children:[t.lastResult&&t.lastResult.ingested>0?(0,q.jsx)(`span`,{className:`brain-watch-stat`,children:a(e,`brain.watch.ingested`,{count:t.lastResult.ingested})}):null,t.lastResult&&t.lastResult.failed>0?(0,q.jsxs)(`span`,{className:`brain-watch-stat is-failed`,children:[(0,q.jsx)(h,{className:`h-3 w-3`,"aria-hidden":`true`}),a(e,`brain.jobs.failedCount`,{count:t.lastResult.failed})]}):null,t.trackedFiles>0?(0,q.jsx)(`small`,{className:`brain-watch-tracked`,children:a(e,`brain.watch.tracked`,{count:t.trackedFiles})}):null]}),t.lastErrors.length?(0,q.jsxs)(`div`,{className:`brain-watch-errors`,children:[(0,q.jsx)(`small`,{children:a(e,`brain.watch.errors`)}),(0,q.jsx)(`ul`,{children:t.lastErrors.slice(0,3).map((e,t)=>(0,q.jsx)(`li`,{children:[e.path?$(e.path):``,e.detail].filter(Boolean).join(` — `)},`${e.path}-${t}`))})]}):null]})}function Ee(e,t){if(!t)return``;let n=new Date(t);return Number.isNaN(n.getTime())?``:n.toLocaleTimeString(e===`ko`?`ko-KR`:`en-US`,{hour:`2-digit`,minute:`2-digit`})}function De({language:e,knownRunIds:t}){let n=d({queryKey:[`agentApprovals`],queryFn:r.agentApprovals,staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),i=b.useMemo(()=>n.data?.ok?C(n.data.data):[],[n.data]),o=b.useMemo(()=>new Set(t),[t]),s=i.filter(e=>!o.has(e.runId));return s.length?(0,q.jsx)(`aside`,{className:`brain-pending-approvals`,role:`note`,"aria-label":a(e,`brain.approval.pendingNotice.aria`),"data-testid":`pending-approvals-notice`,children:s.slice(0,2).map(t=>{let n=Ee(e,t.expiresAt);return(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`span`,{children:t.goal?a(e,`brain.approval.pendingNotice`,{goal:t.goal}):a(e,`brain.approval.pendingNotice.generic`)}),(0,q.jsx)(`small`,{children:n?a(e,`brain.approval.pendingNotice.expiry`,{time:n}):a(e,`brain.approval.pendingNotice.hint`)})]},t.runId)})}):null}export{S as C,te as E,me as S,v as T,pe as _,we as a,ue as b,M as c,ae as d,k as f,fe as g,B as h,_e as i,j as l,A as m,De as n,de as o,se as p,ge as r,P as s,Q as t,ne as u,le as v,V as w,oe as x,re as y};
@@ -1 +1 @@
1
- import{S as e,_ as t,b as n,d as r,g as i,i as a,m as o,o as s,t as c,y as l}from"./utils-C0-C5mZc.js";import{r as u,t as d}from"./useQuery-6Bu27NQe.js";import{t as f}from"./workspace-DAB-urHL.js";import{_ as p,b as m,c as h,g,h as _,i as v,m as y,n as b,p as x,t as S,u as C,v as w,x as T,y as E}from"./primitives-CP68OWk2.js";import{n as D,t as O}from"./input-BflJYT5-.js";import{n as k,r as A,t as ee}from"./hard-drive-rDl1xsJ1.js";import{t as j}from"./folder-open-fE7lLvhZ.js";import{t as M}from"./share-2-CyjG2_yY.js";import{d as te,i as N}from"./index-AEIqmjwZ.js";import{t as P}from"./button-Z-2N8PUb.js";var F=i(`clipboard-paste`,[[`path`,{d:`M11 14h10`,key:`1w8e9d`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v1.344`,key:`1e62lh`}],[`path`,{d:`m17 18 4-4-4-4`,key:`z2g111`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113`,key:`bjbb7m`}],[`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,key:`ublpy`}]]),I=i(`scan-line`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]),L=i(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),R=e(n()),z=l();function B(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t.trim()}return``}function V(e,t){let n=Number(e[t]);return Number.isFinite(n)&&n>0?Math.round(n):0}function ne(e){let t=s(e)?e:{},n=s(t.vector_freshness_global)?t.vector_freshness_global:{};return{vectorStatus:B(n,[`status`])||`unavailable`,vectorPending:V(n,`pending_items`),folders:c(t.folders).flatMap(e=>{let t=s(e)?e:{},n=B(t,[`id`]);if(!n)return[];let r=s(t.files)?t.files:{},i=t.coverage;return[{id:n,label:B(t,[`label`,`root_path`])||n,status:B(t,[`status`]),watchActive:t.watch_active===!0,total:V(r,`total`),indexed:V(r,`indexed`),failed:V(r,`failed`),coverage:typeof i==`number`&&Number.isFinite(i)?i:null,errors:c(t.recent_errors).flatMap(e=>{let t=s(e)?e:{},n=B(t,[`detail`]);return n?[{path:B(t,[`path`]),detail:n}]:[]})}]})}}function re({language:e}){let t=d({queryKey:[`folderMemoryHealth`],queryFn:()=>r.localFolderHealth(),staleTime:3e4}),n=R.useMemo(()=>t.data?.ok?ne(t.data.data):null,[t.data]);return!n||!n.folders.length?null:(0,z.jsxs)(`section`,{className:`folder-memory-health`,"data-testid":`folder-memory-health`,children:[(0,z.jsx)(`h3`,{children:o(e,`capture.folderHealth.title`)}),(0,z.jsx)(`ul`,{children:n.folders.map(t=>(0,z.jsxs)(`li`,{"data-testid":`folder-health-${t.id}`,children:[(0,z.jsxs)(`div`,{className:`folder-memory-head`,children:[(0,z.jsx)(`strong`,{children:t.label}),(0,z.jsx)(`span`,{className:`folder-memory-coverage`,children:t.coverage===null?o(e,`capture.folderHealth.unknown`):o(e,`capture.folderHealth.coverage`,{percent:Math.round(t.coverage*100),indexed:t.indexed,total:t.total})})]}),t.coverage===null?null:(0,z.jsx)(`div`,{className:`folder-memory-bar`,role:`progressbar`,"aria-valuenow":Math.round(t.coverage*100),"aria-valuemin":0,"aria-valuemax":100,children:(0,z.jsx)(`span`,{style:{width:`${Math.round(t.coverage*100)}%`}})}),t.watchActive?(0,z.jsx)(`small`,{children:o(e,`capture.folderHealth.watching`)}):null,t.failed>0?(0,z.jsxs)(`details`,{className:`folder-memory-errors`,children:[(0,z.jsx)(`summary`,{children:o(e,`capture.folderHealth.failed`,{count:t.failed})}),(0,z.jsx)(`ul`,{children:t.errors.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`code`,{children:e.path}),(0,z.jsx)(`span`,{children:e.detail})]},`${t.id}-${e.path}-${e.detail}`))})]}):null]},t.id))}),n.vectorPending>0?(0,z.jsx)(`small`,{className:`folder-memory-vector`,children:o(e,`capture.folderHealth.vectorGlobal`,{count:n.vectorPending})}):null]})}var H=[{id:`files`,labelKey:`capture.method.files`,icon:L,path:`capture`},{id:`local`,labelKey:`capture.method.local`,icon:k,path:`my-computer`},{id:`browser`,labelKey:`capture.method.browser`,icon:A,path:`capture-browser`}];function U(e){return H.some(t=>t.id===e)?e:`files`}function W({initialTab:e}){let n=t(e=>e.language),[r,i]=R.useState(()=>U(e));R.useEffect(()=>{i(U(e))},[e]);let a=e=>{i(e),N(`/`+(H.find(t=>t.id===e)?.path||`capture`))};return(0,z.jsxs)(`div`,{className:`product-page capture-page space-y-5`,children:[(0,z.jsxs)(`header`,{className:`page-hero`,children:[(0,z.jsxs)(`div`,{className:`page-kicker`,children:[(0,z.jsx)(L,{className:`h-4 w-4`}),` `,o(n,`capture.kicker`)]}),(0,z.jsx)(`h1`,{className:`page-title`,children:o(n,`capture.title`)}),(0,z.jsx)(`p`,{className:`page-copy`,children:o(n,`capture.body`)})]}),(0,z.jsxs)(`section`,{className:`capture-station`,"aria-label":o(n,`capture.station.aria`),children:[(0,z.jsxs)(`div`,{className:`capture-station-head`,children:[(0,z.jsx)(`h2`,{children:o(n,`capture.station.title`)}),(0,z.jsx)(`p`,{children:o(n,`capture.station.detail`)})]}),(0,z.jsx)(`div`,{className:`capture-method-switch`,role:`group`,"aria-label":o(n,`capture.method.aria`),children:H.map(({id:e,labelKey:t,icon:i})=>(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":r===e,className:r===e?`is-active`:``,"data-testid":`capture-method-${e}`,onClick:()=>a(e),children:[(0,z.jsx)(i,{className:`h-4 w-4`,"aria-hidden":`true`}),o(n,t)]},e))}),(0,z.jsxs)(`div`,{className:`capture-station-body`,children:[r===`files`?(0,z.jsx)(G,{}):null,r===`local`?(0,z.jsx)(ce,{}):null,r===`browser`?(0,z.jsx)(le,{}):null]})]}),(0,z.jsxs)(`div`,{className:`capture-secondary`,children:[(0,z.jsx)(de,{}),(0,z.jsx)(K,{})]})]})}function G(){let e=t(e=>e.language),n=u(),[r,i]=R.useState([]),a=f({mutationFn:e=>q(e,i),onSuccess:()=>{n.invalidateQueries({queryKey:[`documents`]}),n.invalidateQueries({queryKey:[`graphStats`]}),n.invalidateQueries({queryKey:[`memoryManager`]})}}),s=R.useCallback(e=>{let t=Array.from(e);t.length&&a.mutate(t)},[a]);return(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`label`,{className:`flex min-h-48 cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed border-primary/30 bg-muted/20 p-6 text-center transition hover:border-primary/60 hover:bg-muted/40`,onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),s(e.dataTransfer.files)},children:[(0,z.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,z.jsx)(L,{className:`h-6 w-6`})}),(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-lg font-semibold block`,children:o(e,`capture.files.drop`)}),(0,z.jsx)(`span`,{className:`max-w-md text-sm text-muted-foreground block`,children:o(e,`capture.files.dropDetail`)})]}),(0,z.jsx)(`input`,{type:`file`,multiple:!0,className:`sr-only`,onChange:e=>e.target.files&&s(e.target.files)})]}),(0,z.jsx)(J,{queue:r,onRetry:e=>s([e])})]})}function K(){let e=t(e=>e.language),n=t(e=>e.mode),i=d({queryKey:[`documents`],queryFn:()=>r.documents(200)}),a=d({queryKey:[`localSources`],queryFn:r.localSources}),s=d({queryKey:[`localAgent`],queryFn:r.localAgent});return(0,z.jsxs)(`div`,{className:`capture-secondary-column space-y-4`,children:[(0,z.jsx)(b,{title:o(e,`capture.files.uploaded`),result:i.data,children:t=>(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(v,{items:t.documents||t,titleKey:`filename`,metaKey:`ingest_state`,limit:12}),(0,z.jsx)(`div`,{className:`rounded-md border border-border bg-background/55 p-3 text-sm text-muted-foreground`,children:o(e,`capture.files.completed`)})]})}),(0,z.jsx)(re,{language:e}),(0,z.jsx)(b,{title:o(e,`capture.local.sources`),result:a.data,children:t=>(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(v,{items:t.sources,titleKey:`path`,metaKey:`status`}),c(t.sources).map(t=>(0,z.jsx)(S,{label:o(e,`capture.local.stop`,{source:String(t.path||t.id||o(e,`capture.local.source`))}),action:()=>r.localWatchStop(String(t.id||t.source_id)),invalidate:[`localSources`]},String(t.id||t.source_id||t.path)))]})}),n===`basic`?null:(0,z.jsx)(b,{title:o(e,`capture.local.access`),result:s.data,children:e=>(0,z.jsx)(C,{value:e})})]})}async function q(e,t){let n=e.map(e=>({id:`${e.name}-${e.size}-${e.lastModified}-${Date.now()}`,file:e,name:ae(e),size:e.size,status:`queued`}));t(e=>[...n,...e].slice(0,12));let i=[];for(let e of n){t(t=>t.map(t=>t.id===e.id?{...t,status:`uploading`}:t));let n=await r.uploadDocument(e.file);i.push(n),t(t=>t.map(t=>t.id===e.id?{...t,status:n.ok?`done`:`failed`,result:n}:t))}return i}function J({queue:e,onRetry:n}){let r=t(e=>e.language);return e.length?(0,z.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.map(e=>{let t=Y(e,r);return(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background/55 p-3 text-sm`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`done`?(0,z.jsx)(D,{className:`h-4 w-4 text-emerald-400`}):e.status===`failed`?(0,z.jsx)(T,{className:`h-4 w-4 text-amber-400`}):(0,z.jsx)(m,{className:`h-4 w-4 animate-spin text-primary`}),e.name]}),(0,z.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[Math.max(1,Math.round(e.size/1024)),` KB · `,t]})]}),e.status===`failed`?(0,z.jsxs)(P,{size:`sm`,variant:`outline`,onClick:()=>n(e.file),children:[(0,z.jsx)(te,{className:`h-3.5 w-3.5`}),` `,o(r,`capture.retry`)]}):null]}),e.result?(0,z.jsx)(h,{result:e.result,successLabel:o(r,`capture.files.success`)}):null]},e.id)})}):null}function Y(e,t){if(e.status===`queued`)return o(t,`capture.files.queued`);if(e.status===`uploading`)return o(t,`capture.files.uploading`);if(!e.result?.ok)return e.result?.error||o(t,`capture.files.failed`);let n=e.result.data||{},r=String(n.node_id||n.graph_node||n.provenance_id||``);return r?o(t,`capture.files.capturedWithNode`,{node:r}):o(t,`capture.files.captured`)}var ie={webkitdirectory:``,directory:``};function ae(e){return e.webkitRelativePath||e.name}function oe(e){return(e[0]?.webkitRelativePath||``).split(`/`).filter(Boolean)[0]||``}function X(){let e=window;return!!(e.__TAURI__?.core?.invoke||e.latticeDesktop?.selectFolder||e.__TAURI_INTERNALS__&&window.location.protocol===`tauri:`)}function se(e){return e instanceof DOMException&&e.name===`AbortError`}async function Z(e){let t=[];if(typeof e.values==`function`){for await(let n of e.values())t.push(n);return t}if(typeof e.entries==`function`)for await(let[,n]of e.entries())t.push(n);return t}async function Q(e){let t=[];for(let n of await Z(e)){if(n.kind===`file`){t.push(await n.getFile());continue}t.push(...await Q(n))}return t}function ce(){let e=t(e=>e.language),n=u(),i=R.useRef(null),[a,s]=R.useState(``),[c,l]=R.useState(null),[d,p]=R.useState(``),[g,_]=R.useState(!1),[v,y]=R.useState([]),b=f({mutationFn:e=>r.connectFolder((e||a).trim()),onSuccess:()=>{l(null),n.invalidateQueries({queryKey:[`localSources`]}),n.invalidateQueries({queryKey:[`graphStats`]}),n.invalidateQueries({queryKey:[`memoryManager`]})}}),x=f({mutationFn:e=>q(e,y),onSuccess:()=>{n.invalidateQueries({queryKey:[`documents`]}),n.invalidateQueries({queryKey:[`graphStats`]}),n.invalidateQueries({queryKey:[`memoryManager`]})}}),S=R.useCallback((t,n)=>{if(!t.length){l(o(e,`capture.local.emptyFolder`));return}l(null),p(n||oe(t)||o(e,`capture.local.browserFolder`)),x.mutate(t)},[x,e]),C=R.useCallback(async()=>{if(!g){_(!0),l(null);try{let t=window.showDirectoryPicker;if(!X()&&typeof t==`function`){let e=await t.call(window);S(await Q(e),e.name);return}if(X()){let e=await r.selectFolder();if(e){p(``),s(e),b.mutate(e);return}}if(typeof t==`function`){let e=await t.call(window);S(await Q(e),e.name);return}if(i.current){i.current.click();return}l(o(e,`capture.local.pickUnavailable`))}catch(t){se(t)||l(o(e,`capture.local.pickUnavailable`))}finally{_(!1)}}},[S,g,b,e]),w=R.useCallback(()=>{let e=a.trim();e&&(l(null),p(``),b.mutate(e))},[b,a]),T=(x.data||[]).find(e=>!e.ok)?.error,E=!!(x.error||T);return(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`capture-intake-lead`,children:[(0,z.jsx)(k,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(e,`capture.local.title`)}),(0,z.jsx)(`p`,{children:o(e,`capture.local.description`)})]})]}),(0,z.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),w()},children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,z.jsx)(O,{value:a,onChange:e=>s(e.target.value),placeholder:o(e,`capture.local.placeholder`)}),(0,z.jsxs)(P,{type:`button`,variant:`outline`,disabled:g||b.isPending||x.isPending,onClick:()=>void C(),children:[g?(0,z.jsx)(m,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(j,{className:`h-4 w-4`}),g?o(e,`capture.local.choosing`):o(e,`capture.local.choose`)]})]}),(0,z.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`sr-only`,"aria-hidden":`true`,tabIndex:-1,...ie,onChange:e=>{let t=Array.from(e.currentTarget.files||[]);e.currentTarget.value=``,S(t)}}),(0,z.jsxs)(P,{type:`submit`,disabled:!a.trim()||b.isPending,children:[b.isPending?(0,z.jsx)(m,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(I,{className:`h-4 w-4`}),o(e,`capture.local.connect`)]})]}),c?(0,z.jsx)(h,{result:{ok:!1,status:0,data:{},source:`unavailable`,error:c}}):null,b.data?(0,z.jsx)(h,{result:b.data,successLabel:o(e,`capture.local.success`)}):null,d?(0,z.jsx)(h,{result:{ok:x.isPending||!E,status:E?0:200,data:{folder:d},source:E?`unavailable`:`live`,error:x.error?o(e,`capture.local.browserImportFailed`):T},successLabel:x.isPending?o(e,`capture.local.browserImporting`):o(e,`capture.local.browserImportSuccess`,{folder:d})}):null,(0,z.jsx)(J,{queue:v,onRetry:e=>S([e],d)})]})}function le(){let e=t(e=>e.language),n=u(),[i,a]=R.useState(``),s=f({mutationFn:e=>r.browserReadUrl(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`graphStats`]}),n.invalidateQueries({queryKey:[`memoryManager`]})}}),c=R.useCallback(()=>{let e=$(i);e&&(a(e),s.mutate(e))},[s,i]),l=R.useCallback(async()=>{let e=$(await navigator.clipboard?.readText().catch(()=>``)||``);e&&(a(e),s.mutate(e))},[s]);return(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`capture-intake-lead`,children:[(0,z.jsx)(A,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(e,`capture.browser.title`)}),(0,z.jsx)(`p`,{children:o(e,`capture.browser.description`)})]})]}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,z.jsx)(O,{value:i,onChange:e=>a(e.target.value),placeholder:o(e,`capture.browser.placeholder`),inputMode:`url`}),(0,z.jsxs)(P,{type:`button`,variant:`outline`,disabled:s.isPending,onClick:()=>void l(),children:[(0,z.jsx)(F,{className:`h-4 w-4`}),` `,o(e,`capture.browser.paste`)]}),(0,z.jsxs)(P,{type:`submit`,disabled:!i.trim()||s.isPending,children:[s.isPending?(0,z.jsx)(m,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(I,{className:`h-4 w-4`}),o(e,`capture.browser.capture`)]})]}),s.data?(0,z.jsx)(h,{result:s.data,successLabel:o(e,`capture.browser.success`)}):null]})}function $(e){let t=e.trim();return t?/^https?:\/\//i.test(t)?t:/^[\w.-]+\.[a-z]{2,}([/:?#].*)?$/i.test(t)?`https://${t}`:t:``}function ue(e,t){let n=s(e)?e:{},r=s(t)?t:{},i=s(n.pipelines)?n.pipelines:{},a=e=>{let t=s(i[e])?i[e]:null;if(!t)return null;let n=String(t.state||t.status||``).toLowerCase();return/\b(ready|ok|complete(?:d)?|idle)\b/.test(n)?`done`:/\b(build(?:ing)?|index(?:ing)?|run(?:ning)?|pending|queue(?:d)?)\b/.test(n)?`working`:`waiting`},o=(...e)=>{for(let t of e){let e=Number(t);if(Number.isFinite(e)&&e>0)return Math.round(e)}return 0},c=o(n.total,n.total_items,r.nodes,r.total_nodes),l=o(r.edges,r.total_edges),u=o(n.pending,n.pending_items);return{remembered:c,connections:l,waiting:u,steps:[{key:`read`,state:u?`working`:c?`done`:`waiting`},{key:`understand`,state:a(`vector_index`)??(c?`done`:`waiting`)},{key:`connect`,state:a(`knowledge_graph`)??(l?`done`:`waiting`)}]}}function de(){let e=t(e=>e.language),n=t(e=>e.mode),i=d({queryKey:[`index`],queryFn:r.indexStatus}),s=d({queryKey:[`graphStats`],queryFn:r.graphStats}),c=ue(i.data?.data,s.data?.data),l={read:I,understand:E,connect:M};return(0,z.jsxs)(`div`,{className:`capture-secondary-column space-y-4`,children:[(0,z.jsxs)(x,{children:[(0,z.jsxs)(g,{children:[(0,z.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,z.jsx)(I,{className:`h-4 w-4`}),` `,o(e,`capture.pipeline.journey.title`)]}),(0,z.jsx)(_,{children:o(e,`capture.pipeline.journey.detail`)})]}),(0,z.jsxs)(y,{className:`space-y-4`,children:[(0,z.jsx)(`ol`,{className:`capture-journey`,"aria-label":o(e,`capture.pipeline.journey.aria`),children:c.steps.map(({key:t,state:n})=>{let r=l[t];return(0,z.jsxs)(`li`,{className:`capture-journey-step is-${n}`,children:[(0,z.jsx)(`span`,{className:`capture-journey-mark`,"aria-hidden":`true`,children:(0,z.jsx)(r,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`capture-journey-copy`,children:[(0,z.jsx)(`strong`,{children:o(e,`capture.pipeline.step.${t}`)}),(0,z.jsx)(`small`,{children:o(e,`capture.pipeline.step.${t}.detail`)})]}),(0,z.jsx)(`span`,{className:`capture-journey-state`,children:o(e,`capture.pipeline.step.${n}`)})]},t)})}),c.remembered||c.connections?(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-sm`,children:[(0,z.jsx)(w,{variant:`success`,children:o(e,`capture.pipeline.count.remembered`,{count:a(c.remembered)})}),(0,z.jsx)(w,{variant:`muted`,children:o(e,`capture.pipeline.count.connections`,{count:a(c.connections)})}),(0,z.jsx)(w,{variant:c.waiting?`warning`:`muted`,children:c.waiting?o(e,`capture.pipeline.count.waiting`,{count:a(c.waiting)}):o(e,`capture.pipeline.count.none`)})]}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(e,`capture.pipeline.empty`)})]})]}),(0,z.jsxs)(x,{children:[(0,z.jsxs)(g,{children:[(0,z.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,z.jsx)(ee,{className:`h-4 w-4`}),` `,o(e,`capture.pipeline.refresh`)]}),(0,z.jsx)(_,{children:o(e,`capture.pipeline.description`)})]}),(0,z.jsx)(y,{children:(0,z.jsx)(S,{label:o(e,`capture.pipeline.rebuild`),action:()=>r.rebuildIndex(),invalidate:[`index`]})})]}),n===`basic`?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(b,{title:o(e,`capture.pipeline.status`),result:i.data,children:e=>(0,z.jsx)(C,{value:e})}),(0,z.jsx)(b,{title:o(e,`capture.pipeline.growth`),result:s.data,children:e=>(0,z.jsx)(C,{value:e})})]})]})}export{W as CapturePage};
1
+ import{S as e,_ as t,b as n,d as r,g as i,i as a,m as o,o as s,t as c,y as l}from"./utils-fEGWreKB.js";import{r as u,t as d}from"./useQuery-CT2ChyuU.js";import{t as f}from"./workspace-ClDBz_0f.js";import{_ as p,b as m,c as h,g,h as _,i as v,m as y,n as b,p as x,t as S,u as C,v as w,x as T,y as E}from"./primitives-CEMTjBz1.js";import{n as D,t as O}from"./input-DrMc0Xns.js";import{n as k,r as A,t as ee}from"./hard-drive-Bon1VBvq.js";import{t as j}from"./folder-open-Bbjju0tt.js";import{t as M}from"./share-2-D7THHq5K.js";import{d as te,i as N}from"./index-mLP0-YNO.js";import{t as P}from"./button-DPFZ9lGw.js";var F=i(`clipboard-paste`,[[`path`,{d:`M11 14h10`,key:`1w8e9d`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v1.344`,key:`1e62lh`}],[`path`,{d:`m17 18 4-4-4-4`,key:`z2g111`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113`,key:`bjbb7m`}],[`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,key:`ublpy`}]]),I=i(`scan-line`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}]]),L=i(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),R=e(n()),z=l();function B(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t.trim()}return``}function V(e,t){let n=Number(e[t]);return Number.isFinite(n)&&n>0?Math.round(n):0}function ne(e){let t=s(e)?e:{},n=s(t.vector_freshness_global)?t.vector_freshness_global:{};return{vectorStatus:B(n,[`status`])||`unavailable`,vectorPending:V(n,`pending_items`),folders:c(t.folders).flatMap(e=>{let t=s(e)?e:{},n=B(t,[`id`]);if(!n)return[];let r=s(t.files)?t.files:{},i=t.coverage;return[{id:n,label:B(t,[`label`,`root_path`])||n,status:B(t,[`status`]),watchActive:t.watch_active===!0,total:V(r,`total`),indexed:V(r,`indexed`),failed:V(r,`failed`),coverage:typeof i==`number`&&Number.isFinite(i)?i:null,errors:c(t.recent_errors).flatMap(e=>{let t=s(e)?e:{},n=B(t,[`detail`]);return n?[{path:B(t,[`path`]),detail:n}]:[]})}]})}}function re({language:e}){let t=d({queryKey:[`folderMemoryHealth`],queryFn:()=>r.localFolderHealth(),staleTime:3e4}),n=R.useMemo(()=>t.data?.ok?ne(t.data.data):null,[t.data]);return!n||!n.folders.length?null:(0,z.jsxs)(`section`,{className:`folder-memory-health`,"data-testid":`folder-memory-health`,children:[(0,z.jsx)(`h3`,{children:o(e,`capture.folderHealth.title`)}),(0,z.jsx)(`ul`,{children:n.folders.map(t=>(0,z.jsxs)(`li`,{"data-testid":`folder-health-${t.id}`,children:[(0,z.jsxs)(`div`,{className:`folder-memory-head`,children:[(0,z.jsx)(`strong`,{children:t.label}),(0,z.jsx)(`span`,{className:`folder-memory-coverage`,children:t.coverage===null?o(e,`capture.folderHealth.unknown`):o(e,`capture.folderHealth.coverage`,{percent:Math.round(t.coverage*100),indexed:t.indexed,total:t.total})})]}),t.coverage===null?null:(0,z.jsx)(`div`,{className:`folder-memory-bar`,role:`progressbar`,"aria-valuenow":Math.round(t.coverage*100),"aria-valuemin":0,"aria-valuemax":100,children:(0,z.jsx)(`span`,{style:{width:`${Math.round(t.coverage*100)}%`}})}),t.watchActive?(0,z.jsx)(`small`,{children:o(e,`capture.folderHealth.watching`)}):null,t.failed>0?(0,z.jsxs)(`details`,{className:`folder-memory-errors`,children:[(0,z.jsx)(`summary`,{children:o(e,`capture.folderHealth.failed`,{count:t.failed})}),(0,z.jsx)(`ul`,{children:t.errors.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`code`,{children:e.path}),(0,z.jsx)(`span`,{children:e.detail})]},`${t.id}-${e.path}-${e.detail}`))})]}):null]},t.id))}),n.vectorPending>0?(0,z.jsx)(`small`,{className:`folder-memory-vector`,children:o(e,`capture.folderHealth.vectorGlobal`,{count:n.vectorPending})}):null]})}var H=[{id:`files`,labelKey:`capture.method.files`,icon:L,path:`capture`},{id:`local`,labelKey:`capture.method.local`,icon:k,path:`my-computer`},{id:`browser`,labelKey:`capture.method.browser`,icon:A,path:`capture-browser`}];function U(e){return H.some(t=>t.id===e)?e:`files`}function W({initialTab:e}){let n=t(e=>e.language),[r,i]=R.useState(()=>U(e));R.useEffect(()=>{i(U(e))},[e]);let a=e=>{i(e),N(`/`+(H.find(t=>t.id===e)?.path||`capture`))};return(0,z.jsxs)(`div`,{className:`product-page capture-page space-y-5`,children:[(0,z.jsxs)(`header`,{className:`page-hero`,children:[(0,z.jsxs)(`div`,{className:`page-kicker`,children:[(0,z.jsx)(L,{className:`h-4 w-4`}),` `,o(n,`capture.kicker`)]}),(0,z.jsx)(`h1`,{className:`page-title`,children:o(n,`capture.title`)}),(0,z.jsx)(`p`,{className:`page-copy`,children:o(n,`capture.body`)})]}),(0,z.jsxs)(`section`,{className:`capture-station`,"aria-label":o(n,`capture.station.aria`),children:[(0,z.jsxs)(`div`,{className:`capture-station-head`,children:[(0,z.jsx)(`h2`,{children:o(n,`capture.station.title`)}),(0,z.jsx)(`p`,{children:o(n,`capture.station.detail`)})]}),(0,z.jsx)(`div`,{className:`capture-method-switch`,role:`group`,"aria-label":o(n,`capture.method.aria`),children:H.map(({id:e,labelKey:t,icon:i})=>(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":r===e,className:r===e?`is-active`:``,"data-testid":`capture-method-${e}`,onClick:()=>a(e),children:[(0,z.jsx)(i,{className:`h-4 w-4`,"aria-hidden":`true`}),o(n,t)]},e))}),(0,z.jsxs)(`div`,{className:`capture-station-body`,children:[r===`files`?(0,z.jsx)(G,{}):null,r===`local`?(0,z.jsx)(ce,{}):null,r===`browser`?(0,z.jsx)(le,{}):null]})]}),(0,z.jsxs)(`div`,{className:`capture-secondary`,children:[(0,z.jsx)(de,{}),(0,z.jsx)(K,{})]})]})}function G(){let e=t(e=>e.language),n=u(),[r,i]=R.useState([]),a=f({mutationFn:e=>q(e,i),onSuccess:()=>{n.invalidateQueries({queryKey:[`documents`]}),n.invalidateQueries({queryKey:[`graphStats`]}),n.invalidateQueries({queryKey:[`memoryManager`]})}}),s=R.useCallback(e=>{let t=Array.from(e);t.length&&a.mutate(t)},[a]);return(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`label`,{className:`flex min-h-48 cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed border-primary/30 bg-muted/20 p-6 text-center transition hover:border-primary/60 hover:bg-muted/40`,onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),s(e.dataTransfer.files)},children:[(0,z.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,z.jsx)(L,{className:`h-6 w-6`})}),(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-lg font-semibold block`,children:o(e,`capture.files.drop`)}),(0,z.jsx)(`span`,{className:`max-w-md text-sm text-muted-foreground block`,children:o(e,`capture.files.dropDetail`)})]}),(0,z.jsx)(`input`,{type:`file`,multiple:!0,className:`sr-only`,onChange:e=>e.target.files&&s(e.target.files)})]}),(0,z.jsx)(J,{queue:r,onRetry:e=>s([e])})]})}function K(){let e=t(e=>e.language),n=t(e=>e.mode),i=d({queryKey:[`documents`],queryFn:()=>r.documents(200)}),a=d({queryKey:[`localSources`],queryFn:r.localSources}),s=d({queryKey:[`localAgent`],queryFn:r.localAgent});return(0,z.jsxs)(`div`,{className:`capture-secondary-column space-y-4`,children:[(0,z.jsx)(b,{title:o(e,`capture.files.uploaded`),result:i.data,children:t=>(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(v,{items:t.documents||t,titleKey:`filename`,metaKey:`ingest_state`,limit:12}),(0,z.jsx)(`div`,{className:`rounded-md border border-border bg-background/55 p-3 text-sm text-muted-foreground`,children:o(e,`capture.files.completed`)})]})}),(0,z.jsx)(re,{language:e}),(0,z.jsx)(b,{title:o(e,`capture.local.sources`),result:a.data,children:t=>(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(v,{items:t.sources,titleKey:`path`,metaKey:`status`}),c(t.sources).map(t=>(0,z.jsx)(S,{label:o(e,`capture.local.stop`,{source:String(t.path||t.id||o(e,`capture.local.source`))}),action:()=>r.localWatchStop(String(t.id||t.source_id)),invalidate:[`localSources`]},String(t.id||t.source_id||t.path)))]})}),n===`basic`?null:(0,z.jsx)(b,{title:o(e,`capture.local.access`),result:s.data,children:e=>(0,z.jsx)(C,{value:e})})]})}async function q(e,t){let n=e.map(e=>({id:`${e.name}-${e.size}-${e.lastModified}-${Date.now()}`,file:e,name:ae(e),size:e.size,status:`queued`}));t(e=>[...n,...e].slice(0,12));let i=[];for(let e of n){t(t=>t.map(t=>t.id===e.id?{...t,status:`uploading`}:t));let n=await r.uploadDocument(e.file);i.push(n),t(t=>t.map(t=>t.id===e.id?{...t,status:n.ok?`done`:`failed`,result:n}:t))}return i}function J({queue:e,onRetry:n}){let r=t(e=>e.language);return e.length?(0,z.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.map(e=>{let t=Y(e,r);return(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background/55 p-3 text-sm`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`done`?(0,z.jsx)(D,{className:`h-4 w-4 text-emerald-400`}):e.status===`failed`?(0,z.jsx)(T,{className:`h-4 w-4 text-amber-400`}):(0,z.jsx)(m,{className:`h-4 w-4 animate-spin text-primary`}),e.name]}),(0,z.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[Math.max(1,Math.round(e.size/1024)),` KB · `,t]})]}),e.status===`failed`?(0,z.jsxs)(P,{size:`sm`,variant:`outline`,onClick:()=>n(e.file),children:[(0,z.jsx)(te,{className:`h-3.5 w-3.5`}),` `,o(r,`capture.retry`)]}):null]}),e.result?(0,z.jsx)(h,{result:e.result,successLabel:o(r,`capture.files.success`)}):null]},e.id)})}):null}function Y(e,t){if(e.status===`queued`)return o(t,`capture.files.queued`);if(e.status===`uploading`)return o(t,`capture.files.uploading`);if(!e.result?.ok)return e.result?.error||o(t,`capture.files.failed`);let n=e.result.data||{},r=String(n.node_id||n.graph_node||n.provenance_id||``);return r?o(t,`capture.files.capturedWithNode`,{node:r}):o(t,`capture.files.captured`)}var ie={webkitdirectory:``,directory:``};function ae(e){return e.webkitRelativePath||e.name}function oe(e){return(e[0]?.webkitRelativePath||``).split(`/`).filter(Boolean)[0]||``}function X(){let e=window;return!!(e.__TAURI__?.core?.invoke||e.latticeDesktop?.selectFolder||e.__TAURI_INTERNALS__&&window.location.protocol===`tauri:`)}function se(e){return e instanceof DOMException&&e.name===`AbortError`}async function Z(e){let t=[];if(typeof e.values==`function`){for await(let n of e.values())t.push(n);return t}if(typeof e.entries==`function`)for await(let[,n]of e.entries())t.push(n);return t}async function Q(e){let t=[];for(let n of await Z(e)){if(n.kind===`file`){t.push(await n.getFile());continue}t.push(...await Q(n))}return t}function ce(){let e=t(e=>e.language),n=u(),i=R.useRef(null),[a,s]=R.useState(``),[c,l]=R.useState(null),[d,p]=R.useState(``),[g,_]=R.useState(!1),[v,y]=R.useState([]),b=f({mutationFn:e=>r.connectFolder((e||a).trim()),onSuccess:()=>{l(null),n.invalidateQueries({queryKey:[`localSources`]}),n.invalidateQueries({queryKey:[`graphStats`]}),n.invalidateQueries({queryKey:[`memoryManager`]})}}),x=f({mutationFn:e=>q(e,y),onSuccess:()=>{n.invalidateQueries({queryKey:[`documents`]}),n.invalidateQueries({queryKey:[`graphStats`]}),n.invalidateQueries({queryKey:[`memoryManager`]})}}),S=R.useCallback((t,n)=>{if(!t.length){l(o(e,`capture.local.emptyFolder`));return}l(null),p(n||oe(t)||o(e,`capture.local.browserFolder`)),x.mutate(t)},[x,e]),C=R.useCallback(async()=>{if(!g){_(!0),l(null);try{let t=window.showDirectoryPicker;if(!X()&&typeof t==`function`){let e=await t.call(window);S(await Q(e),e.name);return}if(X()){let e=await r.selectFolder();if(e){p(``),s(e),b.mutate(e);return}}if(typeof t==`function`){let e=await t.call(window);S(await Q(e),e.name);return}if(i.current){i.current.click();return}l(o(e,`capture.local.pickUnavailable`))}catch(t){se(t)||l(o(e,`capture.local.pickUnavailable`))}finally{_(!1)}}},[S,g,b,e]),w=R.useCallback(()=>{let e=a.trim();e&&(l(null),p(``),b.mutate(e))},[b,a]),T=(x.data||[]).find(e=>!e.ok)?.error,E=!!(x.error||T);return(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`capture-intake-lead`,children:[(0,z.jsx)(k,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(e,`capture.local.title`)}),(0,z.jsx)(`p`,{children:o(e,`capture.local.description`)})]})]}),(0,z.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),w()},children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,z.jsx)(O,{value:a,onChange:e=>s(e.target.value),placeholder:o(e,`capture.local.placeholder`)}),(0,z.jsxs)(P,{type:`button`,variant:`outline`,disabled:g||b.isPending||x.isPending,onClick:()=>void C(),children:[g?(0,z.jsx)(m,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(j,{className:`h-4 w-4`}),g?o(e,`capture.local.choosing`):o(e,`capture.local.choose`)]})]}),(0,z.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`sr-only`,"aria-hidden":`true`,tabIndex:-1,...ie,onChange:e=>{let t=Array.from(e.currentTarget.files||[]);e.currentTarget.value=``,S(t)}}),(0,z.jsxs)(P,{type:`submit`,disabled:!a.trim()||b.isPending,children:[b.isPending?(0,z.jsx)(m,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(I,{className:`h-4 w-4`}),o(e,`capture.local.connect`)]})]}),c?(0,z.jsx)(h,{result:{ok:!1,status:0,data:{},source:`unavailable`,error:c}}):null,b.data?(0,z.jsx)(h,{result:b.data,successLabel:o(e,`capture.local.success`)}):null,d?(0,z.jsx)(h,{result:{ok:x.isPending||!E,status:E?0:200,data:{folder:d},source:E?`unavailable`:`live`,error:x.error?o(e,`capture.local.browserImportFailed`):T},successLabel:x.isPending?o(e,`capture.local.browserImporting`):o(e,`capture.local.browserImportSuccess`,{folder:d})}):null,(0,z.jsx)(J,{queue:v,onRetry:e=>S([e],d)})]})}function le(){let e=t(e=>e.language),n=u(),[i,a]=R.useState(``),s=f({mutationFn:e=>r.browserReadUrl(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`graphStats`]}),n.invalidateQueries({queryKey:[`memoryManager`]})}}),c=R.useCallback(()=>{let e=$(i);e&&(a(e),s.mutate(e))},[s,i]),l=R.useCallback(async()=>{let e=$(await navigator.clipboard?.readText().catch(()=>``)||``);e&&(a(e),s.mutate(e))},[s]);return(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`capture-intake-lead`,children:[(0,z.jsx)(A,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(e,`capture.browser.title`)}),(0,z.jsx)(`p`,{children:o(e,`capture.browser.description`)})]})]}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,z.jsx)(O,{value:i,onChange:e=>a(e.target.value),placeholder:o(e,`capture.browser.placeholder`),inputMode:`url`}),(0,z.jsxs)(P,{type:`button`,variant:`outline`,disabled:s.isPending,onClick:()=>void l(),children:[(0,z.jsx)(F,{className:`h-4 w-4`}),` `,o(e,`capture.browser.paste`)]}),(0,z.jsxs)(P,{type:`submit`,disabled:!i.trim()||s.isPending,children:[s.isPending?(0,z.jsx)(m,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(I,{className:`h-4 w-4`}),o(e,`capture.browser.capture`)]})]}),s.data?(0,z.jsx)(h,{result:s.data,successLabel:o(e,`capture.browser.success`)}):null]})}function $(e){let t=e.trim();return t?/^https?:\/\//i.test(t)?t:/^[\w.-]+\.[a-z]{2,}([/:?#].*)?$/i.test(t)?`https://${t}`:t:``}function ue(e,t){let n=s(e)?e:{},r=s(t)?t:{},i=s(n.pipelines)?n.pipelines:{},a=e=>{let t=s(i[e])?i[e]:null;if(!t)return null;let n=String(t.state||t.status||``).toLowerCase();return/\b(ready|ok|complete(?:d)?|idle)\b/.test(n)?`done`:/\b(build(?:ing)?|index(?:ing)?|run(?:ning)?|pending|queue(?:d)?)\b/.test(n)?`working`:`waiting`},o=(...e)=>{for(let t of e){let e=Number(t);if(Number.isFinite(e)&&e>0)return Math.round(e)}return 0},c=o(n.total,n.total_items,r.nodes,r.total_nodes),l=o(r.edges,r.total_edges),u=o(n.pending,n.pending_items);return{remembered:c,connections:l,waiting:u,steps:[{key:`read`,state:u?`working`:c?`done`:`waiting`},{key:`understand`,state:a(`vector_index`)??(c?`done`:`waiting`)},{key:`connect`,state:a(`knowledge_graph`)??(l?`done`:`waiting`)}]}}function de(){let e=t(e=>e.language),n=t(e=>e.mode),i=d({queryKey:[`index`],queryFn:r.indexStatus}),s=d({queryKey:[`graphStats`],queryFn:r.graphStats}),c=ue(i.data?.data,s.data?.data),l={read:I,understand:E,connect:M};return(0,z.jsxs)(`div`,{className:`capture-secondary-column space-y-4`,children:[(0,z.jsxs)(x,{children:[(0,z.jsxs)(g,{children:[(0,z.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,z.jsx)(I,{className:`h-4 w-4`}),` `,o(e,`capture.pipeline.journey.title`)]}),(0,z.jsx)(_,{children:o(e,`capture.pipeline.journey.detail`)})]}),(0,z.jsxs)(y,{className:`space-y-4`,children:[(0,z.jsx)(`ol`,{className:`capture-journey`,"aria-label":o(e,`capture.pipeline.journey.aria`),children:c.steps.map(({key:t,state:n})=>{let r=l[t];return(0,z.jsxs)(`li`,{className:`capture-journey-step is-${n}`,children:[(0,z.jsx)(`span`,{className:`capture-journey-mark`,"aria-hidden":`true`,children:(0,z.jsx)(r,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`capture-journey-copy`,children:[(0,z.jsx)(`strong`,{children:o(e,`capture.pipeline.step.${t}`)}),(0,z.jsx)(`small`,{children:o(e,`capture.pipeline.step.${t}.detail`)})]}),(0,z.jsx)(`span`,{className:`capture-journey-state`,children:o(e,`capture.pipeline.step.${n}`)})]},t)})}),c.remembered||c.connections?(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-sm`,children:[(0,z.jsx)(w,{variant:`success`,children:o(e,`capture.pipeline.count.remembered`,{count:a(c.remembered)})}),(0,z.jsx)(w,{variant:`muted`,children:o(e,`capture.pipeline.count.connections`,{count:a(c.connections)})}),(0,z.jsx)(w,{variant:c.waiting?`warning`:`muted`,children:c.waiting?o(e,`capture.pipeline.count.waiting`,{count:a(c.waiting)}):o(e,`capture.pipeline.count.none`)})]}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(e,`capture.pipeline.empty`)})]})]}),(0,z.jsxs)(x,{children:[(0,z.jsxs)(g,{children:[(0,z.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,z.jsx)(ee,{className:`h-4 w-4`}),` `,o(e,`capture.pipeline.refresh`)]}),(0,z.jsx)(_,{children:o(e,`capture.pipeline.description`)})]}),(0,z.jsx)(y,{children:(0,z.jsx)(S,{label:o(e,`capture.pipeline.rebuild`),action:()=>r.rebuildIndex(),invalidate:[`index`]})})]}),n===`basic`?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(b,{title:o(e,`capture.pipeline.status`),result:i.data,children:e=>(0,z.jsx)(C,{value:e})}),(0,z.jsx)(b,{title:o(e,`capture.pipeline.growth`),result:s.data,children:e=>(0,z.jsx)(C,{value:e})})]})]})}export{W as CapturePage};
@@ -1 +1 @@
1
- import{S as e,b as t,d as n,g as r,m as i,t as a,y as o}from"./utils-C0-C5mZc.js";import{t as s}from"./useQuery-6Bu27NQe.js";import{t as c}from"./bot-C1-MbzCF.js";import{t as l}from"./search-B4O4iIgg.js";import{n as u,t as d}from"./useFocusTrap-BgIZQ4if.js";import{f,i as p,m,o as h}from"./index-AEIqmjwZ.js";var g=r(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),_=r(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),v=r(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),y=e(t()),b=o(),x=h.map(e=>{let t=e.icon;return{...e,icon:(0,b.jsx)(t,{className:`h-4 w-4`})}});function S(e,t){let[n,r]=y.useState(e);return y.useEffect(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function C({language:e,initialOpen:t=!1}){let[r,o]=y.useState(t),[h,C]=y.useState(``),[w,T]=y.useState(0),E=y.useRef(null),D=S(h.trim(),220);y.useEffect(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),o(e=>!e))},t=()=>o(!0);return window.addEventListener(`keydown`,e),window.addEventListener(`lattice:open-command`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`lattice:open-command`,t)}},[]),y.useEffect(()=>{r&&(C(``),T(0),window.setTimeout(()=>E.current?.focus(),0))},[r]);let O=s({queryKey:[`commandSearch`,D],queryFn:()=>n.commandSearch(D),enabled:r&&D.length>0}),k=s({queryKey:[`commandBriefing`],queryFn:n.commandBriefing,enabled:r,staleTime:6e4}),A=y.useMemo(()=>{let t=h.trim().toLowerCase(),n=[];if(!t&&k.data?.ok){let t=(k.data.data||{}).sections||{},r=t.review||{},a=t.suggestions||{},o=Number(a.count??0)||0,s=Number(r.pending??0)||0;n.push({id:`proactive-briefing`,group:`proactive`,title:i(e,`command.proactive.briefing`),detail:o>0?i(e,`command.proactive.suggestions`,{count:o}):void 0,icon:(0,b.jsx)(u,{className:`h-4 w-4`}),target:`/brain`,action:`open-briefing`}),n.push({id:`proactive-review`,group:`proactive`,title:i(e,`command.proactive.review`),detail:s>0?i(e,`command.proactive.pending`,{count:s}):void 0,icon:(0,b.jsx)(f,{className:`h-4 w-4`}),target:`/act/review`}),n.push({id:`proactive-ask`,group:`proactive`,title:i(e,`briefing.action.askBrain`),icon:(0,b.jsx)(v,{className:`h-4 w-4`}),target:`/brain`})}let r=x.map(t=>({id:t.id,group:`pages`,title:i(e,t.labelKey),icon:t.icon,target:t.target})).filter(e=>!t||e.title.toLowerCase().includes(t)),o=a(O.data?.data?.groups),s=[];for(let t of o)for(let n of a(t.items))t.kind===`knowledge`?s.push({id:`kg-${String(n.id??s.length)}`,group:`knowledge`,title:String(n.title||n.id||``),detail:String(n.summary||n.type||``),icon:(0,b.jsx)(m,{className:`h-4 w-4`}),target:`/brain/graph`}):t.kind===`conversation`?s.push({id:`conv-${String(n.conversation_id??s.length)}`,group:`conversation`,title:String(n.snippet||``),detail:String(n.timestamp||``).slice(0,10),icon:(0,b.jsx)(v,{className:`h-4 w-4`}),target:`/brain`}):t.kind===`automation`&&s.push({id:`wf-${String(n.id??s.length)}`,group:`automation`,title:String(n.name||``),detail:n.enabled?i(e,`command.automation.enabled`):i(e,`command.automation.draft`),icon:(0,b.jsx)(c,{className:`h-4 w-4`}),target:`/act/workflows`});return[...n,...s,...r]},[e,h,O.data,k.data]);y.useEffect(()=>{T(0)},[A.length,D]);let j=y.useCallback(()=>o(!1),[]),M=d(j,r),N=y.useCallback(e=>{e&&(j(),p(e.target),e.action===`open-briefing`&&window.dispatchEvent(new Event(`lattice:open-briefing`)))},[j]),P=e=>{e.key===`Escape`?(e.preventDefault(),j()):e.key===`ArrowDown`?(e.preventDefault(),T(e=>Math.min(e+1,Math.max(A.length-1,0)))):e.key===`ArrowUp`?(e.preventDefault(),T(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),N(A[w]))};if(!r)return null;let F={proactive:i(e,`command.proactive.title`),pages:i(e,`command.group.pages`),knowledge:i(e,`command.group.knowledge`),conversation:i(e,`command.group.conversation`),automation:i(e,`command.group.automation`)},I=null;return(0,b.jsx)(`div`,{className:`command-palette-backdrop`,role:`presentation`,onMouseDown:e=>{e.target===e.currentTarget&&j()},children:(0,b.jsxs)(`div`,{ref:M,className:`command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":i(e,`command.title`),"data-testid":`command-palette`,children:[(0,b.jsxs)(`div`,{className:`command-palette-input`,children:[(0,b.jsx)(l,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,b.jsx)(`input`,{ref:E,value:h,onChange:e=>C(e.target.value),onKeyDown:P,placeholder:i(e,`command.placeholder`),"aria-label":i(e,`command.title`),autoComplete:`off`,spellCheck:!1}),(0,b.jsxs)(`span`,{className:`command-palette-hint`,"aria-hidden":`true`,children:[(0,b.jsx)(g,{className:`h-3 w-3`}),i(e,`command.shortcutKey`)]})]}),(0,b.jsxs)(`div`,{className:`command-palette-results`,role:`listbox`,"aria-label":i(e,`command.results`),children:[O.isFetching?(0,b.jsx)(`p`,{className:`command-palette-note`,children:i(e,`command.searching`)}):null,A.length===0&&!O.isFetching?(0,b.jsx)(`p`,{className:`command-palette-note`,children:i(e,`command.empty`)}):null,A.map((e,t)=>{let n=e.group===I?null:(0,b.jsx)(`p`,{className:`command-palette-group`,children:F[e.group]},`h-${e.group}`);return I=e.group,(0,b.jsxs)(y.Fragment,{children:[n,(0,b.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===w,className:`command-palette-item ${t===w?`is-active`:``}`,onMouseEnter:()=>T(t),onClick:()=>N(e),children:[e.icon,(0,b.jsx)(`span`,{className:`command-palette-item-title`,children:e.title}),e.detail?(0,b.jsx)(`span`,{className:`command-palette-item-detail`,children:e.detail}):null,t===w?(0,b.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):null]})]},e.id)})]}),(0,b.jsx)(`p`,{className:`command-palette-footer`,children:i(e,`command.footer`)})]})})}export{C as CommandPalette};
1
+ import{S as e,b as t,d as n,g as r,m as i,t as a,y as o}from"./utils-fEGWreKB.js";import{t as s}from"./useQuery-CT2ChyuU.js";import{t as c}from"./bot-D1gX4xks.js";import{t as l}from"./search-HsIji1wY.js";import{n as u,t as d}from"./useFocusTrap-BgvK4Nkx.js";import{f,i as p,m,o as h}from"./index-mLP0-YNO.js";var g=r(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),_=r(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),v=r(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),y=e(t()),b=o(),x=h.map(e=>{let t=e.icon;return{...e,icon:(0,b.jsx)(t,{className:`h-4 w-4`})}});function S(e,t){let[n,r]=y.useState(e);return y.useEffect(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function C({language:e,initialOpen:t=!1}){let[r,o]=y.useState(t),[h,C]=y.useState(``),[w,T]=y.useState(0),E=y.useRef(null),D=S(h.trim(),220);y.useEffect(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),o(e=>!e))},t=()=>o(!0);return window.addEventListener(`keydown`,e),window.addEventListener(`lattice:open-command`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`lattice:open-command`,t)}},[]),y.useEffect(()=>{r&&(C(``),T(0),window.setTimeout(()=>E.current?.focus(),0))},[r]);let O=s({queryKey:[`commandSearch`,D],queryFn:()=>n.commandSearch(D),enabled:r&&D.length>0}),k=s({queryKey:[`commandBriefing`],queryFn:n.commandBriefing,enabled:r,staleTime:6e4}),A=y.useMemo(()=>{let t=h.trim().toLowerCase(),n=[];if(!t&&k.data?.ok){let t=(k.data.data||{}).sections||{},r=t.review||{},a=t.suggestions||{},o=Number(a.count??0)||0,s=Number(r.pending??0)||0;n.push({id:`proactive-briefing`,group:`proactive`,title:i(e,`command.proactive.briefing`),detail:o>0?i(e,`command.proactive.suggestions`,{count:o}):void 0,icon:(0,b.jsx)(u,{className:`h-4 w-4`}),target:`/brain`,action:`open-briefing`}),n.push({id:`proactive-review`,group:`proactive`,title:i(e,`command.proactive.review`),detail:s>0?i(e,`command.proactive.pending`,{count:s}):void 0,icon:(0,b.jsx)(f,{className:`h-4 w-4`}),target:`/act/review`}),n.push({id:`proactive-ask`,group:`proactive`,title:i(e,`briefing.action.askBrain`),icon:(0,b.jsx)(v,{className:`h-4 w-4`}),target:`/brain`})}let r=x.map(t=>({id:t.id,group:`pages`,title:i(e,t.labelKey),icon:t.icon,target:t.target})).filter(e=>!t||e.title.toLowerCase().includes(t)),o=a(O.data?.data?.groups),s=[];for(let t of o)for(let n of a(t.items))t.kind===`knowledge`?s.push({id:`kg-${String(n.id??s.length)}`,group:`knowledge`,title:String(n.title||n.id||``),detail:String(n.summary||n.type||``),icon:(0,b.jsx)(m,{className:`h-4 w-4`}),target:`/brain/graph`}):t.kind===`conversation`?s.push({id:`conv-${String(n.conversation_id??s.length)}`,group:`conversation`,title:String(n.snippet||``),detail:String(n.timestamp||``).slice(0,10),icon:(0,b.jsx)(v,{className:`h-4 w-4`}),target:`/brain`}):t.kind===`automation`&&s.push({id:`wf-${String(n.id??s.length)}`,group:`automation`,title:String(n.name||``),detail:n.enabled?i(e,`command.automation.enabled`):i(e,`command.automation.draft`),icon:(0,b.jsx)(c,{className:`h-4 w-4`}),target:`/act/workflows`});return[...n,...s,...r]},[e,h,O.data,k.data]);y.useEffect(()=>{T(0)},[A.length,D]);let j=y.useCallback(()=>o(!1),[]),M=d(j,r),N=y.useCallback(e=>{e&&(j(),p(e.target),e.action===`open-briefing`&&window.dispatchEvent(new Event(`lattice:open-briefing`)))},[j]),P=e=>{e.key===`Escape`?(e.preventDefault(),j()):e.key===`ArrowDown`?(e.preventDefault(),T(e=>Math.min(e+1,Math.max(A.length-1,0)))):e.key===`ArrowUp`?(e.preventDefault(),T(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),N(A[w]))};if(!r)return null;let F={proactive:i(e,`command.proactive.title`),pages:i(e,`command.group.pages`),knowledge:i(e,`command.group.knowledge`),conversation:i(e,`command.group.conversation`),automation:i(e,`command.group.automation`)},I=null;return(0,b.jsx)(`div`,{className:`command-palette-backdrop`,role:`presentation`,onMouseDown:e=>{e.target===e.currentTarget&&j()},children:(0,b.jsxs)(`div`,{ref:M,className:`command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":i(e,`command.title`),"data-testid":`command-palette`,children:[(0,b.jsxs)(`div`,{className:`command-palette-input`,children:[(0,b.jsx)(l,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,b.jsx)(`input`,{ref:E,value:h,onChange:e=>C(e.target.value),onKeyDown:P,placeholder:i(e,`command.placeholder`),"aria-label":i(e,`command.title`),autoComplete:`off`,spellCheck:!1}),(0,b.jsxs)(`span`,{className:`command-palette-hint`,"aria-hidden":`true`,children:[(0,b.jsx)(g,{className:`h-3 w-3`}),i(e,`command.shortcutKey`)]})]}),(0,b.jsxs)(`div`,{className:`command-palette-results`,role:`listbox`,"aria-label":i(e,`command.results`),children:[O.isFetching?(0,b.jsx)(`p`,{className:`command-palette-note`,children:i(e,`command.searching`)}):null,A.length===0&&!O.isFetching?(0,b.jsx)(`p`,{className:`command-palette-note`,children:i(e,`command.empty`)}):null,A.map((e,t)=>{let n=e.group===I?null:(0,b.jsx)(`p`,{className:`command-palette-group`,children:F[e.group]},`h-${e.group}`);return I=e.group,(0,b.jsxs)(y.Fragment,{children:[n,(0,b.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===w,className:`command-palette-item ${t===w?`is-active`:``}`,onMouseEnter:()=>T(t),onClick:()=>N(e),children:[e.icon,(0,b.jsx)(`span`,{className:`command-palette-item-title`,children:e.title}),e.detail?(0,b.jsx)(`span`,{className:`command-palette-item-detail`,children:e.detail}):null,t===w?(0,b.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):null]})]},e.id)})]}),(0,b.jsx)(`p`,{className:`command-palette-footer`,children:i(e,`command.footer`)})]})})}export{C as CommandPalette};
@@ -1 +1 @@
1
- import{S as e,_ as t,a as n,b as r,d as i,g as a,m as o,t as s,y as c}from"./utils-C0-C5mZc.js";import{r as l,t as u}from"./useQuery-6Bu27NQe.js";import{t as d}from"./workspace-DAB-urHL.js";import{_ as f,b as p,c as m,d as h,f as g,g as _,h as v,i as y,l as b,m as x,n as S,p as C,r as w,t as T,u as E,v as D}from"./primitives-CP68OWk2.js";import{n as O,t as k}from"./input-BflJYT5-.js";import{t as A}from"./circle-play-Bj45uClm.js";import{t as j}from"./cpu-B-2Chwfy.js";import{t as M}from"./download-CKmiOG3C.js";import{t as N}from"./shield-alert-C_JBPWYd.js";import{i as P}from"./index-AEIqmjwZ.js";import{t as F}from"./button-Z-2N8PUb.js";var I=a(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),L=a(`package-plus`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`M16 17h6`,key:`1ook5g`}],[`path`,{d:`M19 14v6`,key:`1ckrd5`}],[`path`,{d:`M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955`,key:`28k6lz`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),R=a(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),z=e(r()),B=c();function V(e,t){let n=String(e||``).toLowerCase();return n===`production`?o(t,`library.embedding.state.production`):n===`fallback`||n===`hash`||n===`local`?o(t,`library.embedding.state.fallback`):o(t,`library.embedding.state.unknown`)}function H(e,t){let n=String(e?.os||``).toLowerCase(),r=String(e?.arch||``).toLowerCase();return n?n===`darwin`&&r.startsWith(`arm`)?o(t,`library.runtime.appleSilicon`):n===`darwin`?`Mac`:n===`win32`||n.startsWith(`win`)?`Windows`:n===`linux`?`Linux`:o(t,`library.runtime.thisComputer`):o(t,`library.value.detected`)}function U(e){return/[ㄱ-힝]/u.test(e)?!1:e.trim().split(/\s+/).length>=6}var ee=new Set([`loaded`,`ready`,`download_required`,`unavailable`,`unsupported`]),W=[{id:`models`,labelKey:`library.tab.models`},{id:`skills`,labelKey:`library.tab.skills`},{id:`mcp`,labelKey:`library.tab.mcp`},{id:`marketplace`,labelKey:`library.tab.marketplace`}];function G({initialTab:e}){let n=t(e=>e.mode),r=t(e=>e.language),[i,a]=z.useState(e||`models`);z.useEffect(()=>{W.some(t=>t.id===e)&&a(e)},[e]);let s=(n===`basic`?W.filter(e=>e.id===`models`):W).map(e=>({id:e.id,label:o(r,e.labelKey)})),c=e=>{a(e),P(`/`+e)};return(0,B.jsxs)(`div`,{className:`product-page library-page space-y-5`,children:[(0,B.jsxs)(`header`,{className:`page-hero`,children:[(0,B.jsxs)(`div`,{className:`page-kicker`,children:[(0,B.jsx)(I,{className:`h-4 w-4`}),` `,o(r,`library.kicker`)]}),(0,B.jsx)(`h1`,{className:`page-title`,children:o(r,`library.title`)}),(0,B.jsx)(`p`,{className:`page-copy`,children:o(r,`library.body`)})]}),(0,B.jsx)(K,{}),(0,B.jsx)(h,{tabs:s,value:i,onChange:e=>c(e)}),i===`models`?(0,B.jsx)(q,{}):null,i===`skills`?(0,B.jsx)(Y,{}):null,i===`mcp`?(0,B.jsx)(X,{}):null,i===`marketplace`?(0,B.jsx)(Z,{}):null]})}function K(){let e=l(),r=t(e=>e.language),a=u({queryKey:[`models`],queryFn:i.models}),[c,d]=z.useState(null),[f,m]=z.useState(null),h=a.data?.data||{},g=s(h.loaded),_=String(h.current||g[0]||``),v=[...s(h.catalog),...s(h.recommended),...s(h.models)],y=e=>String(e.id||e.model_id||``),b=_?v.find(e=>y(e)===_):void 0,x=String(b?.name||``)||(_?n(_):``),S=v.filter(e=>{let t=y(e);return!t||t===_||g.includes(t)||e.download_required||J(e.runtime_compatibility).supported===!1||e.load_status===`unsupported`?!1:!!e.load_available||e.load_status===`ready`}).slice(0,3);async function C(t){let n=y(t);d(n),m(null);let a=String(t.recommended_engine||t.engine||``)||void 0,s=await i.loadModel(String(t.recommended_load_id||n),a,!1);d(null),s.ok||m(s.error||o(r,`library.active.switchFailed`)),await e.invalidateQueries({queryKey:[`models`]})}let w=!!(a.data&&!a.data.ok);return(0,B.jsxs)(`section`,{className:`library-active`,"aria-label":o(r,`library.active.title`),"data-testid":`library-active-model`,children:[(0,B.jsxs)(`div`,{className:`library-active-main`,children:[(0,B.jsx)(`span`,{className:`library-active-mark`,"aria-hidden":`true`,children:x&&!w?(0,B.jsx)(A,{className:`h-5 w-5`}):(0,B.jsx)(j,{className:`h-5 w-5`})}),(0,B.jsxs)(`div`,{className:`library-active-copy`,children:[(0,B.jsx)(`span`,{className:`library-active-kicker`,children:o(r,`library.active.title`)}),w?(0,B.jsx)(`strong`,{children:o(r,`library.active.unknown`)}):x?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`strong`,{children:x}),(0,B.jsx)(`small`,{children:o(r,`library.active.ready`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`strong`,{children:o(r,`library.active.none`)}),(0,B.jsx)(`small`,{children:o(r,`library.active.noneHint`)})]})]}),x&&!w?(0,B.jsx)(D,{variant:`success`,children:o(r,`library.model.loaded`)}):null]}),S.length&&!w?(0,B.jsxs)(`div`,{className:`library-active-switch`,children:[(0,B.jsxs)(`span`,{className:`library-active-switch-label`,children:[o(r,`library.active.switchTitle`),(0,B.jsx)(`small`,{children:o(r,`library.active.switchHint`)})]}),(0,B.jsx)(`div`,{className:`library-active-switch-options`,children:S.map(e=>{let t=y(e),i=String(e.name||``)||n(t);return(0,B.jsxs)(`button`,{type:`button`,disabled:!!c,"data-testid":`library-switch-${t}`,onClick:()=>void C(e),children:[c===t?(0,B.jsx)(p,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":`true`}):(0,B.jsx)(O,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),c===t?o(r,`library.active.switching`):i]},t)})})]}):null,f?(0,B.jsx)(`p`,{className:`library-active-error`,role:`status`,children:f}):null]})}function q(){let e=l(),n=t(e=>e.mode),r=t(e=>e.language),a=u({queryKey:[`models`],queryFn:i.models}),c=u({queryKey:[`modelRecommendations`,`local_mlx`],queryFn:()=>i.modelRecommendations(`local_mlx`)}),d=u({queryKey:[`embeddings`],queryFn:i.embeddingsStatus}),[f,p]=z.useState(!1),[m,h]=z.useState(null),[_,v]=z.useState([]),[b,x]=z.useState(null),[C,k]=z.useState(null),[P,I]=z.useState(!1),R=s(a.data?.data?.loaded),H=String(a.data?.data?.current||``),W=e=>{let t=String(e.id||e.model_id||``);return R.includes(t)||t===H?0:e.load_available||e.load_status===`ready`?1:e.pulled?2:3},G=[...s(a.data?.data?.catalog),...s(a.data?.data?.recommended)].map((e,t)=>({model:e,index:t})).sort((e,t)=>W(e.model)-W(t.model)||e.index-t.index).map(e=>e.model),K=s(c.data?.data?.recommendations?.models),q=new Map(K.map(e=>[String(e.id),e])),Y=G.find(e=>R.includes(String(e.id))||String(e.id)===H),X=c.data?.data?.recommendations?.top_pick||null,Z=_[_.length-1]||null,Q=z.useCallback((e,t=`library.model.notReady`)=>{let i=String(e||o(r,t));if(r===`ko`&&U(i))return o(r,t);if(n!==`basic`)return i;let a=i.replace(/gemma4_unified/gi,o(r,`library.model.localFormat`)).replace(/mlx[-_ ]?vlm|mlx[-_ ]?lm|local_mlx|\bmlx\b|\bgguf\b|\bollama\b|hugging face/gi,o(r,`library.model.localSupport`)).replace(/runtime/gi,o(r,`library.model.support`)).replace(/model_type/gi,o(r,`library.model.format`));return r===`en`?a.replace(/this local model format local model support format/gi,o(r,`library.model.localFormat`)).replace(/local model support model support/gi,o(r,`library.model.localSupport`)):a},[r,n]);async function $(t,n,r){I(!0),h(t),v([]),x(null),k(null);let a=await i.streamModelPrepare({model:t,engine:n||`local_mlx`,allow_download:r},{onProgress:e=>v(t=>[...t.slice(-8),e]),onDone:e=>x(e),onError:e=>k(e)});I(!1),await e.invalidateQueries({queryKey:[`models`]}),await e.invalidateQueries({queryKey:[`modelRecommendations`,`local_mlx`]}),!a.ok&&!C&&k(a.data)}return(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(S,{title:o(r,`library.models.setup.title`),description:o(r,`library.models.setup.desc`),result:c.data,children:t=>{let a=t.recommendations,s=t.profile;return(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(ne,{language:r,mode:n,profile:s||{},recommendation:a||{},current:Y,currentId:H,latestProgress:Z,lastResult:b,onReload:()=>{Y&&$(String(Y.recommended_load_id||Y.id||H),String(Y.recommended_engine||Y.engine||`local_mlx`),f)},onUnload:()=>{H&&i.unloadModel(H).then(()=>e.invalidateQueries({queryKey:[`models`]}))}}),(0,B.jsx)(`ol`,{className:`library-setup-track`,"aria-label":o(r,`library.steps.aria`),children:[[o(r,`library.step.environment`),!0,j],[o(r,`library.step.recommend`),!!(X||G.length),O],[o(r,`library.step.install`),!!(Y||Z?.stage===`engine`),L],[o(r,`library.step.download`),!!(Y||Z?.stage===`download`),M],[o(r,`library.step.validate`),!!(Y||Z?.stage===`smoke_test`),N],[o(r,`library.step.ready`),!!(Y||b),A]].map(([e,t,n])=>(0,B.jsxs)(`li`,{className:t?`is-done`:``,children:[(0,B.jsx)(`span`,{className:`library-setup-mark`,"aria-hidden":`true`,children:z.createElement(n,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(`span`,{className:`library-setup-label`,children:String(e)}),(0,B.jsx)(`span`,{className:`library-setup-state`,children:t?o(r,`library.step.done`):o(r,`library.step.pending`)})]},String(e)))}),(0,B.jsxs)(`label`,{className:`flex items-start gap-2 rounded-lg border border-border bg-background/55 p-3 text-sm leading-6`,children:[(0,B.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),(0,B.jsx)(`span`,{children:o(r,`library.consent`)})]}),Z?(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/55 p-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:String(Z.message||o(r,`library.preparing`))}),(0,B.jsx)(`div`,{className:`mt-2 h-2 overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{className:`h-full bg-primary`,style:{width:`${Number(Z.percent||8)}%`}})}),Z.detail?(0,B.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:String(Z.detail)}):null]}):null,C?(0,B.jsx)(re,{error:C}):null]})}}),(0,B.jsx)(S,{title:n===`basic`?o(r,`library.panel.recommended.basic`):o(r,`library.panel.recommended.other`),result:a.data,children:e=>(0,B.jsxs)(`div`,{className:`grid gap-2`,children:[(G.length?G:s(e.loaded)).slice(0,n===`basic`?3:14).map((t,a)=>{let c=String(t.id||t.model_id||t.name||a),l=s(e.loaded).includes(c)||e.current===c||t.state===`loaded`,u=String(t.recommended_load_id||c),d=String(t.recommended_engine||t.engine||``),p=q.get(c)||q.get(u)||{},h=J(t.verification),g=J(p.verification),_=J(t.hardware),v=J(p.hardware),y=!!t.download_required,b=_.recommended_ram_gb||v.recommended_ram_gb,x=b?o(r,`library.model.ramRecommended`,{ram:String(b)}):n===`basic`?``:String(_.notes||v.notes||``),S=t.safety_notes||p.safety_notes,C=t.license||p.license,w=t.runtime_compatibility||p.runtime_compatibility||{},E=String(w.status||``)===`fallback_available`,O=t.load_status===`unsupported`||w.supported===!1,k=(!!t.load_available||l)&&!O,A=String(t.load_status||(l?`loaded`:`unavailable`)),j=y?o(r,`library.model.needsDownloadFirst`):Q(t.unavailable_reason||o(r,`library.model.notReady`)),M=String(t.runtime_label||w.preferred_runtime||d||`local_mlx`),N=String(w.action||A.replace(/_/g,` `)),I=ee.has(A)?o(r,`library.model.status.${A}`):o(r,`library.model.status.unknown`),L=O&&n===`basic`?o(r,`library.model.needsAttention`):I,R=k||y,z=t.download_size||t.estimated_size||p.download_size||p.estimated_size||t.size||p.size,V=t.provider||p.provider||t.organization||p.organization;return(0,B.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-border bg-background/55 p-4 md:grid-cols-[1fr_auto]`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`text-base font-semibold`,children:String(t.name||c)}),X?.id===c||t.recommended_default?(0,B.jsx)(D,{variant:`success`,children:o(r,`library.model.recommended`)}):null,String(t.modality||p.modality||``).includes(`multi`)||String(t.modality||``)===`multimodal`?(0,B.jsx)(D,{variant:`muted`,children:o(r,`library.model.multimodal`)}):null,h.verified||g.verified?(0,B.jsx)(D,{variant:`success`,title:o(r,`library.model.hfVerified`),children:o(r,`library.model.sourceVerified`)}):null]}),(0,B.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:n===`basic`?[Q(t.family||p.family||o(r,`library.model.local`)),/mlx|gguf|ollama/i.test(String(t.size||p.size||``))?``:t.size||p.size].filter(Boolean).map(String).join(` · `):[t.family||p.family||o(r,`library.value.local`),t.size||p.size].filter(Boolean).map(String).join(` · `)}),t.hardware||p.hardware?(0,B.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground/80`,children:String(x)}):null,(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(D,{variant:`muted`,children:y?o(r,`library.model.downloadSize`,{size:String(z||o(r,`library.model.downloadRequired`))}):o(r,`library.model.noDownload`)}),(0,B.jsx)(D,{variant:`muted`,children:y?o(r,`library.model.internetDuringDownload`):o(r,`library.model.runsLocally`)}),V?(0,B.jsx)(D,{variant:`muted`,children:String(V)}):null]}),O?(0,B.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:n===`basic`?o(r,`library.model.attentionBeforeLoad`):N}),(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:Q(w.user_message||j,`library.model.unsupportedHere`)})]}):E?(0,B.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:n===`basic`?o(r,`library.model.compatiblePath`):o(r,`library.model.runtimeFallback`)}),(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:Q(w.user_message||o(r,`library.model.compatibilityFallback`),`library.model.compatibilityFallback`)})]}):!l&&!k?(0,B.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:j}):null,n===`basic`?null:(0,B.jsxs)(`div`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`div`,{children:[M,` · `,u,t.load_strategy||p.load_strategy?` · ${String(t.load_strategy||p.load_strategy)}`:``,h.notes?` · ${String(h.notes).slice(0,60)}`:``]}),S||C?(0,B.jsx)(`div`,{children:[C?o(r,`library.model.license`,{license:String(C)}):``,S?String(S):``].filter(Boolean).join(` · `)}):null]}),O||E?(0,B.jsx)(te,{compatibility:w}):null]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:justify-end`,children:[(0,B.jsx)(D,{variant:l?`success`:k?`muted`:`warning`,children:l?o(r,`library.model.loaded`):L}),l?(0,B.jsx)(T,{label:o(r,`library.runtime.unload`),action:()=>i.unloadModel(u),invalidate:[`models`]}):(0,B.jsx)(F,{variant:`outline`,disabled:P||O||!R||y&&!f,title:O?o(r,`library.model.status.unsupported`):y&&!f?o(r,`library.btn.needsConsent`):R?void 0:j,onClick:()=>$(u,d||`local_mlx`,f),children:m===u&&P?o(r,`library.btn.preparing`):y?o(r,`library.btn.installLoad`):o(r,`library.btn.validateLoad`)})]})]},c)}),n===`basic`&&G.length>3?(0,B.jsx)(`div`,{className:`rounded-lg border border-border bg-background/55 p-3 text-sm text-muted-foreground`,children:o(r,`library.model.shortListHint`)}):null]})})]}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(S,{title:n===`basic`?o(r,`library.models.embedding.basic`):o(r,`library.models.embedding.advanced`),result:d.data,children:e=>(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(g,{value:V(e.state,r)}),n===`basic`?null:(0,B.jsx)(E,{value:e})]})}),(0,B.jsx)(S,{title:n===`basic`?o(r,`library.models.validation`):o(r,`library.models.validationAdvanced`),result:a.data,children:e=>{let t=s(e.compat_profiles);return t.length?(0,B.jsx)(y,{items:t.map(e=>({...e,name:n===`basic`?e.name||e.display_name||o(r,`library.model.loadedName`):e.name||e.display_name||e.model_id,status:e.quality_status||e.load_status||o(r,`library.model.checked`)})),titleKey:`name`,metaKey:`status`,limit:6}):(0,B.jsx)(w,{title:o(r,`library.model.noneChecked`),detail:o(r,`library.model.noneCheckedHint`)})}})]})]})}function te({compatibility:e}){let n=t(e=>e.mode),r=t(e=>e.language),i=s(e.alternatives);return i.length?(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:i.slice(0,3).map(e=>(0,B.jsx)(D,{variant:`muted`,children:n===`basic`&&/mlx|gguf|ollama|lm studio/i.test(String(e.name||e.id))?o(r,`library.model.compatibleAlternative`):String(e.name||e.id)},String(e.id||e.name)))}):null}function ne({language:e=`en`,mode:t=`advanced`,profile:r,recommendation:i,current:a,currentId:s,latestProgress:c,lastResult:l,onReload:u,onUnload:d}){let f=String(a?.id||s||``),p=String(a?.name||``)||(f?n(f):``),m=String(a?.engine||a?.recommended_engine||c?.engine||`local_mlx`),h=String(a?.local_path||a?.storage_location||i.cache_path||i.storage_location||`~/.cache/huggingface / ~/.latticeai/models`),g=String(c?.stage||l?.stage||(p?o(e,`library.value.ready`):o(e,`library.value.idle`))),_=t===`basic`;return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(b,{stats:_?[{label:o(e,`library.runtime.computer`),value:H(r,e)},{label:o(e,`library.runtime.loaded`),value:p||o(e,`library.runtime.noneShort`)}]:[{label:o(e,`library.runtime.computer`),value:H(r,e)},{label:o(e,`library.runtime.engine`),value:m},{label:o(e,`library.runtime.loaded`),value:p||o(e,`library.runtime.noLoaded`)},{label:o(e,`library.runtime.state`),value:g}]}),(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/55 p-3 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-medium`,children:p?o(e,`library.models.runtime.available`):o(e,`library.models.runtime.none`)}),_?null:(0,B.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:o(e,`library.runtime.cacheStorage`,{path:h})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(F,{variant:`outline`,size:`sm`,disabled:!p,onClick:u,children:o(e,`library.runtime.reload`)}),(0,B.jsx)(F,{variant:`outline`,size:`sm`,disabled:!p,onClick:d,children:o(e,`library.runtime.unload`)})]})]}),c?(0,B.jsxs)(`div`,{className:`mt-3`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:String(c.message||o(e,`library.preparing`))}),(0,B.jsxs)(`span`,{children:[Number(c.percent||0),`%`]})]}),(0,B.jsx)(`div`,{className:`mt-1 h-2 overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{className:`h-full bg-primary`,style:{width:`${Number(c.percent||8)}%`}})})]}):null]})]})}function re({error:e}){let n=t(e=>e.language),r=s(e.recovery_guidance);return(0,B.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:String(e.user_message||o(n,`library.model.setupAttention`))}),r.length?(0,B.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-muted-foreground`,children:r.slice(0,3).map(e=>(0,B.jsx)(`li`,{children:e},e))}):null]})}function J(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(){let e=l(),n=t(e=>e.language),r=u({queryKey:[`skills`],queryFn:i.skills}),a=u({queryKey:[`skillsMarketplace`],queryFn:i.skillsMarketplace}),c=d({mutationFn:e=>i.skillInstall(String(e.name||e.id),String(e.plugin||``)),onSuccess:()=>e.invalidateQueries({queryKey:[`skills`]})});return(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,B.jsx)(S,{title:o(n,`library.skills.installed`),result:r.data,children:e=>(0,B.jsx)(`div`,{className:`grid gap-2`,children:s(e.skills).map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border p-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-medium`,children:String(e.name||e.id)}),(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:String(e.plugin||e.description||``)})]}),(0,B.jsx)(T,{label:o(n,e.enabled?`library.skills.disable`:`library.skills.enable`),action:()=>i.skillToggle(String(e.name||e.id),!!e.enabled),invalidate:[`skills`]})]},String(e.name||e.id)))})}),(0,B.jsx)(S,{title:o(n,`library.skills.marketplace`),result:a.data,children:e=>(0,B.jsx)(`div`,{className:`grid gap-2`,children:s(e.skills).slice(0,10).map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border p-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-medium`,children:String(e.name||e.id)}),(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:String(e.description||e.category||``)})]}),(0,B.jsx)(F,{variant:`outline`,disabled:c.isPending,onClick:()=>c.mutate(e),children:o(n,`library.skills.install`)})]},String(e.name||e.id)))})})]})}function X(){let e=t(e=>e.mode),n=t(e=>e.language),[r,a]=z.useState(`github`),s=u({queryKey:[`mcpTools`],queryFn:i.mcpTools}),c=d({mutationFn:()=>i.mcpRecommend(r)});return(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1fr_1fr]`,children:[(0,B.jsx)(S,{title:o(n,e===`basic`?`library.connector.connections`:`library.connector.mcpTools`),result:s.data,children:e=>(0,B.jsx)(y,{items:e.tools||e.installed_mcps,titleKey:`name`,metaKey:`status`})}),(0,B.jsxs)(C,{children:[(0,B.jsxs)(_,{children:[(0,B.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,B.jsx)(R,{className:`h-4 w-4`}),` `,o(n,`library.connector.recommend`)]}),(0,B.jsx)(v,{children:o(n,`library.connector.recommendHint`)})]}),(0,B.jsxs)(x,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(k,{value:r,onChange:e=>a(e.target.value)}),(0,B.jsx)(F,{onClick:()=>c.mutate(),disabled:!r.trim()||c.isPending,children:o(n,`library.connector.recommendAction`)})]}),c.data?(0,B.jsx)(m,{result:c.data,successLabel:o(n,`library.connector.recommendDone`)}):null]})]})]})}function Z(){let e=t(e=>e.language),n=u({queryKey:[`templates`],queryFn:i.templates}),r=u({queryKey:[`plugins`],queryFn:i.pluginsRegistry}),a=u({queryKey:[`pluginsDirectory`],queryFn:i.pluginsDirectory});return(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:[(0,B.jsx)(S,{title:o(e,`library.market.templates`),result:n.data,children:e=>(0,B.jsx)(y,{items:e.templates,titleKey:`name`,metaKey:`kind`})}),(0,B.jsx)(S,{title:o(e,`library.market.installedPlugins`),result:r.data,children:e=>(0,B.jsx)(y,{items:e.plugins,titleKey:`name`,metaKey:`status`})}),(0,B.jsx)(S,{title:o(e,`library.market.pluginDirectory`),result:a.data,children:e=>(0,B.jsx)(y,{items:e.plugins,titleKey:`name`,metaKey:`category`})}),(0,B.jsxs)(C,{className:`xl:col-span-3`,children:[(0,B.jsxs)(_,{children:[(0,B.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{className:`h-4 w-4`}),` `,o(e,`library.market.templateInstall`)]}),(0,B.jsx)(v,{children:o(e,`library.market.templateInstallHint`)})]}),(0,B.jsx)(x,{children:s(n.data?.data?.templates).length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:s(n.data?.data?.templates).slice(0,6).map(t=>(0,B.jsx)(T,{label:o(e,`library.market.installTemplate`,{name:String(t.name||t.id)}),action:()=>i.installTemplate(t)},String(t.id||t.name)))}):(0,B.jsx)(y,{items:[]})})]})]})}export{G as LibraryPage};
1
+ import{S as e,_ as t,a as n,b as r,d as i,g as a,m as o,t as s,y as c}from"./utils-fEGWreKB.js";import{r as l,t as u}from"./useQuery-CT2ChyuU.js";import{t as d}from"./workspace-ClDBz_0f.js";import{_ as f,b as p,c as m,d as h,f as g,g as _,h as v,i as y,l as b,m as x,n as S,p as C,r as w,t as T,u as E,v as D}from"./primitives-CEMTjBz1.js";import{n as O,t as k}from"./input-DrMc0Xns.js";import{t as A}from"./circle-play-BiC8z2vg.js";import{t as j}from"./cpu-Cx-wRR_V.js";import{t as M}from"./download-CKxlzxsK.js";import{t as N}from"./shield-alert-BoU4_8r9.js";import{i as P}from"./index-mLP0-YNO.js";import{t as F}from"./button-DPFZ9lGw.js";var I=a(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),L=a(`package-plus`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`M16 17h6`,key:`1ook5g`}],[`path`,{d:`M19 14v6`,key:`1ckrd5`}],[`path`,{d:`M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955`,key:`28k6lz`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),R=a(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),z=e(r()),B=c();function V(e,t){let n=String(e||``).toLowerCase();return n===`production`?o(t,`library.embedding.state.production`):n===`fallback`||n===`hash`||n===`local`?o(t,`library.embedding.state.fallback`):o(t,`library.embedding.state.unknown`)}function H(e,t){let n=String(e?.os||``).toLowerCase(),r=String(e?.arch||``).toLowerCase();return n?n===`darwin`&&r.startsWith(`arm`)?o(t,`library.runtime.appleSilicon`):n===`darwin`?`Mac`:n===`win32`||n.startsWith(`win`)?`Windows`:n===`linux`?`Linux`:o(t,`library.runtime.thisComputer`):o(t,`library.value.detected`)}function U(e){return/[ㄱ-힝]/u.test(e)?!1:e.trim().split(/\s+/).length>=6}var ee=new Set([`loaded`,`ready`,`download_required`,`unavailable`,`unsupported`]),W=[{id:`models`,labelKey:`library.tab.models`},{id:`skills`,labelKey:`library.tab.skills`},{id:`mcp`,labelKey:`library.tab.mcp`},{id:`marketplace`,labelKey:`library.tab.marketplace`}];function G({initialTab:e}){let n=t(e=>e.mode),r=t(e=>e.language),[i,a]=z.useState(e||`models`);z.useEffect(()=>{W.some(t=>t.id===e)&&a(e)},[e]);let s=(n===`basic`?W.filter(e=>e.id===`models`):W).map(e=>({id:e.id,label:o(r,e.labelKey)})),c=e=>{a(e),P(`/`+e)};return(0,B.jsxs)(`div`,{className:`product-page library-page space-y-5`,children:[(0,B.jsxs)(`header`,{className:`page-hero`,children:[(0,B.jsxs)(`div`,{className:`page-kicker`,children:[(0,B.jsx)(I,{className:`h-4 w-4`}),` `,o(r,`library.kicker`)]}),(0,B.jsx)(`h1`,{className:`page-title`,children:o(r,`library.title`)}),(0,B.jsx)(`p`,{className:`page-copy`,children:o(r,`library.body`)})]}),(0,B.jsx)(K,{}),(0,B.jsx)(h,{tabs:s,value:i,onChange:e=>c(e)}),i===`models`?(0,B.jsx)(q,{}):null,i===`skills`?(0,B.jsx)(Y,{}):null,i===`mcp`?(0,B.jsx)(X,{}):null,i===`marketplace`?(0,B.jsx)(Z,{}):null]})}function K(){let e=l(),r=t(e=>e.language),a=u({queryKey:[`models`],queryFn:i.models}),[c,d]=z.useState(null),[f,m]=z.useState(null),h=a.data?.data||{},g=s(h.loaded),_=String(h.current||g[0]||``),v=[...s(h.catalog),...s(h.recommended),...s(h.models)],y=e=>String(e.id||e.model_id||``),b=_?v.find(e=>y(e)===_):void 0,x=String(b?.name||``)||(_?n(_):``),S=v.filter(e=>{let t=y(e);return!t||t===_||g.includes(t)||e.download_required||J(e.runtime_compatibility).supported===!1||e.load_status===`unsupported`?!1:!!e.load_available||e.load_status===`ready`}).slice(0,3);async function C(t){let n=y(t);d(n),m(null);let a=String(t.recommended_engine||t.engine||``)||void 0,s=await i.loadModel(String(t.recommended_load_id||n),a,!1);d(null),s.ok||m(s.error||o(r,`library.active.switchFailed`)),await e.invalidateQueries({queryKey:[`models`]})}let w=!!(a.data&&!a.data.ok);return(0,B.jsxs)(`section`,{className:`library-active`,"aria-label":o(r,`library.active.title`),"data-testid":`library-active-model`,children:[(0,B.jsxs)(`div`,{className:`library-active-main`,children:[(0,B.jsx)(`span`,{className:`library-active-mark`,"aria-hidden":`true`,children:x&&!w?(0,B.jsx)(A,{className:`h-5 w-5`}):(0,B.jsx)(j,{className:`h-5 w-5`})}),(0,B.jsxs)(`div`,{className:`library-active-copy`,children:[(0,B.jsx)(`span`,{className:`library-active-kicker`,children:o(r,`library.active.title`)}),w?(0,B.jsx)(`strong`,{children:o(r,`library.active.unknown`)}):x?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`strong`,{children:x}),(0,B.jsx)(`small`,{children:o(r,`library.active.ready`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`strong`,{children:o(r,`library.active.none`)}),(0,B.jsx)(`small`,{children:o(r,`library.active.noneHint`)})]})]}),x&&!w?(0,B.jsx)(D,{variant:`success`,children:o(r,`library.model.loaded`)}):null]}),S.length&&!w?(0,B.jsxs)(`div`,{className:`library-active-switch`,children:[(0,B.jsxs)(`span`,{className:`library-active-switch-label`,children:[o(r,`library.active.switchTitle`),(0,B.jsx)(`small`,{children:o(r,`library.active.switchHint`)})]}),(0,B.jsx)(`div`,{className:`library-active-switch-options`,children:S.map(e=>{let t=y(e),i=String(e.name||``)||n(t);return(0,B.jsxs)(`button`,{type:`button`,disabled:!!c,"data-testid":`library-switch-${t}`,onClick:()=>void C(e),children:[c===t?(0,B.jsx)(p,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":`true`}):(0,B.jsx)(O,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),c===t?o(r,`library.active.switching`):i]},t)})})]}):null,f?(0,B.jsx)(`p`,{className:`library-active-error`,role:`status`,children:f}):null]})}function q(){let e=l(),n=t(e=>e.mode),r=t(e=>e.language),a=u({queryKey:[`models`],queryFn:i.models}),c=u({queryKey:[`modelRecommendations`,`local_mlx`],queryFn:()=>i.modelRecommendations(`local_mlx`)}),d=u({queryKey:[`embeddings`],queryFn:i.embeddingsStatus}),[f,p]=z.useState(!1),[m,h]=z.useState(null),[_,v]=z.useState([]),[b,x]=z.useState(null),[C,k]=z.useState(null),[P,I]=z.useState(!1),R=s(a.data?.data?.loaded),H=String(a.data?.data?.current||``),W=e=>{let t=String(e.id||e.model_id||``);return R.includes(t)||t===H?0:e.load_available||e.load_status===`ready`?1:e.pulled?2:3},G=[...s(a.data?.data?.catalog),...s(a.data?.data?.recommended)].map((e,t)=>({model:e,index:t})).sort((e,t)=>W(e.model)-W(t.model)||e.index-t.index).map(e=>e.model),K=s(c.data?.data?.recommendations?.models),q=new Map(K.map(e=>[String(e.id),e])),Y=G.find(e=>R.includes(String(e.id))||String(e.id)===H),X=c.data?.data?.recommendations?.top_pick||null,Z=_[_.length-1]||null,Q=z.useCallback((e,t=`library.model.notReady`)=>{let i=String(e||o(r,t));if(r===`ko`&&U(i))return o(r,t);if(n!==`basic`)return i;let a=i.replace(/gemma4_unified/gi,o(r,`library.model.localFormat`)).replace(/mlx[-_ ]?vlm|mlx[-_ ]?lm|local_mlx|\bmlx\b|\bgguf\b|\bollama\b|hugging face/gi,o(r,`library.model.localSupport`)).replace(/runtime/gi,o(r,`library.model.support`)).replace(/model_type/gi,o(r,`library.model.format`));return r===`en`?a.replace(/this local model format local model support format/gi,o(r,`library.model.localFormat`)).replace(/local model support model support/gi,o(r,`library.model.localSupport`)):a},[r,n]);async function $(t,n,r){I(!0),h(t),v([]),x(null),k(null);let a=await i.streamModelPrepare({model:t,engine:n||`local_mlx`,allow_download:r},{onProgress:e=>v(t=>[...t.slice(-8),e]),onDone:e=>x(e),onError:e=>k(e)});I(!1),await e.invalidateQueries({queryKey:[`models`]}),await e.invalidateQueries({queryKey:[`modelRecommendations`,`local_mlx`]}),!a.ok&&!C&&k(a.data)}return(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(S,{title:o(r,`library.models.setup.title`),description:o(r,`library.models.setup.desc`),result:c.data,children:t=>{let a=t.recommendations,s=t.profile;return(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(ne,{language:r,mode:n,profile:s||{},recommendation:a||{},current:Y,currentId:H,latestProgress:Z,lastResult:b,onReload:()=>{Y&&$(String(Y.recommended_load_id||Y.id||H),String(Y.recommended_engine||Y.engine||`local_mlx`),f)},onUnload:()=>{H&&i.unloadModel(H).then(()=>e.invalidateQueries({queryKey:[`models`]}))}}),(0,B.jsx)(`ol`,{className:`library-setup-track`,"aria-label":o(r,`library.steps.aria`),children:[[o(r,`library.step.environment`),!0,j],[o(r,`library.step.recommend`),!!(X||G.length),O],[o(r,`library.step.install`),!!(Y||Z?.stage===`engine`),L],[o(r,`library.step.download`),!!(Y||Z?.stage===`download`),M],[o(r,`library.step.validate`),!!(Y||Z?.stage===`smoke_test`),N],[o(r,`library.step.ready`),!!(Y||b),A]].map(([e,t,n])=>(0,B.jsxs)(`li`,{className:t?`is-done`:``,children:[(0,B.jsx)(`span`,{className:`library-setup-mark`,"aria-hidden":`true`,children:z.createElement(n,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(`span`,{className:`library-setup-label`,children:String(e)}),(0,B.jsx)(`span`,{className:`library-setup-state`,children:t?o(r,`library.step.done`):o(r,`library.step.pending`)})]},String(e)))}),(0,B.jsxs)(`label`,{className:`flex items-start gap-2 rounded-lg border border-border bg-background/55 p-3 text-sm leading-6`,children:[(0,B.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),(0,B.jsx)(`span`,{children:o(r,`library.consent`)})]}),Z?(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/55 p-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:String(Z.message||o(r,`library.preparing`))}),(0,B.jsx)(`div`,{className:`mt-2 h-2 overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{className:`h-full bg-primary`,style:{width:`${Number(Z.percent||8)}%`}})}),Z.detail?(0,B.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:String(Z.detail)}):null]}):null,C?(0,B.jsx)(re,{error:C}):null]})}}),(0,B.jsx)(S,{title:n===`basic`?o(r,`library.panel.recommended.basic`):o(r,`library.panel.recommended.other`),result:a.data,children:e=>(0,B.jsxs)(`div`,{className:`grid gap-2`,children:[(G.length?G:s(e.loaded)).slice(0,n===`basic`?3:14).map((t,a)=>{let c=String(t.id||t.model_id||t.name||a),l=s(e.loaded).includes(c)||e.current===c||t.state===`loaded`,u=String(t.recommended_load_id||c),d=String(t.recommended_engine||t.engine||``),p=q.get(c)||q.get(u)||{},h=J(t.verification),g=J(p.verification),_=J(t.hardware),v=J(p.hardware),y=!!t.download_required,b=_.recommended_ram_gb||v.recommended_ram_gb,x=b?o(r,`library.model.ramRecommended`,{ram:String(b)}):n===`basic`?``:String(_.notes||v.notes||``),S=t.safety_notes||p.safety_notes,C=t.license||p.license,w=t.runtime_compatibility||p.runtime_compatibility||{},E=String(w.status||``)===`fallback_available`,O=t.load_status===`unsupported`||w.supported===!1,k=(!!t.load_available||l)&&!O,A=String(t.load_status||(l?`loaded`:`unavailable`)),j=y?o(r,`library.model.needsDownloadFirst`):Q(t.unavailable_reason||o(r,`library.model.notReady`)),M=String(t.runtime_label||w.preferred_runtime||d||`local_mlx`),N=String(w.action||A.replace(/_/g,` `)),I=ee.has(A)?o(r,`library.model.status.${A}`):o(r,`library.model.status.unknown`),L=O&&n===`basic`?o(r,`library.model.needsAttention`):I,R=k||y,z=t.download_size||t.estimated_size||p.download_size||p.estimated_size||t.size||p.size,V=t.provider||p.provider||t.organization||p.organization;return(0,B.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-border bg-background/55 p-4 md:grid-cols-[1fr_auto]`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`text-base font-semibold`,children:String(t.name||c)}),X?.id===c||t.recommended_default?(0,B.jsx)(D,{variant:`success`,children:o(r,`library.model.recommended`)}):null,String(t.modality||p.modality||``).includes(`multi`)||String(t.modality||``)===`multimodal`?(0,B.jsx)(D,{variant:`muted`,children:o(r,`library.model.multimodal`)}):null,h.verified||g.verified?(0,B.jsx)(D,{variant:`success`,title:o(r,`library.model.hfVerified`),children:o(r,`library.model.sourceVerified`)}):null]}),(0,B.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:n===`basic`?[Q(t.family||p.family||o(r,`library.model.local`)),/mlx|gguf|ollama/i.test(String(t.size||p.size||``))?``:t.size||p.size].filter(Boolean).map(String).join(` · `):[t.family||p.family||o(r,`library.value.local`),t.size||p.size].filter(Boolean).map(String).join(` · `)}),t.hardware||p.hardware?(0,B.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground/80`,children:String(x)}):null,(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(D,{variant:`muted`,children:y?o(r,`library.model.downloadSize`,{size:String(z||o(r,`library.model.downloadRequired`))}):o(r,`library.model.noDownload`)}),(0,B.jsx)(D,{variant:`muted`,children:y?o(r,`library.model.internetDuringDownload`):o(r,`library.model.runsLocally`)}),V?(0,B.jsx)(D,{variant:`muted`,children:String(V)}):null]}),O?(0,B.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:n===`basic`?o(r,`library.model.attentionBeforeLoad`):N}),(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:Q(w.user_message||j,`library.model.unsupportedHere`)})]}):E?(0,B.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:n===`basic`?o(r,`library.model.compatiblePath`):o(r,`library.model.runtimeFallback`)}),(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:Q(w.user_message||o(r,`library.model.compatibilityFallback`),`library.model.compatibilityFallback`)})]}):!l&&!k?(0,B.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:j}):null,n===`basic`?null:(0,B.jsxs)(`div`,{className:`mt-2 space-y-1 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`div`,{children:[M,` · `,u,t.load_strategy||p.load_strategy?` · ${String(t.load_strategy||p.load_strategy)}`:``,h.notes?` · ${String(h.notes).slice(0,60)}`:``]}),S||C?(0,B.jsx)(`div`,{children:[C?o(r,`library.model.license`,{license:String(C)}):``,S?String(S):``].filter(Boolean).join(` · `)}):null]}),O||E?(0,B.jsx)(te,{compatibility:w}):null]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:justify-end`,children:[(0,B.jsx)(D,{variant:l?`success`:k?`muted`:`warning`,children:l?o(r,`library.model.loaded`):L}),l?(0,B.jsx)(T,{label:o(r,`library.runtime.unload`),action:()=>i.unloadModel(u),invalidate:[`models`]}):(0,B.jsx)(F,{variant:`outline`,disabled:P||O||!R||y&&!f,title:O?o(r,`library.model.status.unsupported`):y&&!f?o(r,`library.btn.needsConsent`):R?void 0:j,onClick:()=>$(u,d||`local_mlx`,f),children:m===u&&P?o(r,`library.btn.preparing`):y?o(r,`library.btn.installLoad`):o(r,`library.btn.validateLoad`)})]})]},c)}),n===`basic`&&G.length>3?(0,B.jsx)(`div`,{className:`rounded-lg border border-border bg-background/55 p-3 text-sm text-muted-foreground`,children:o(r,`library.model.shortListHint`)}):null]})})]}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(S,{title:n===`basic`?o(r,`library.models.embedding.basic`):o(r,`library.models.embedding.advanced`),result:d.data,children:e=>(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(g,{value:V(e.state,r)}),n===`basic`?null:(0,B.jsx)(E,{value:e})]})}),(0,B.jsx)(S,{title:n===`basic`?o(r,`library.models.validation`):o(r,`library.models.validationAdvanced`),result:a.data,children:e=>{let t=s(e.compat_profiles);return t.length?(0,B.jsx)(y,{items:t.map(e=>({...e,name:n===`basic`?e.name||e.display_name||o(r,`library.model.loadedName`):e.name||e.display_name||e.model_id,status:e.quality_status||e.load_status||o(r,`library.model.checked`)})),titleKey:`name`,metaKey:`status`,limit:6}):(0,B.jsx)(w,{title:o(r,`library.model.noneChecked`),detail:o(r,`library.model.noneCheckedHint`)})}})]})]})}function te({compatibility:e}){let n=t(e=>e.mode),r=t(e=>e.language),i=s(e.alternatives);return i.length?(0,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:i.slice(0,3).map(e=>(0,B.jsx)(D,{variant:`muted`,children:n===`basic`&&/mlx|gguf|ollama|lm studio/i.test(String(e.name||e.id))?o(r,`library.model.compatibleAlternative`):String(e.name||e.id)},String(e.id||e.name)))}):null}function ne({language:e=`en`,mode:t=`advanced`,profile:r,recommendation:i,current:a,currentId:s,latestProgress:c,lastResult:l,onReload:u,onUnload:d}){let f=String(a?.id||s||``),p=String(a?.name||``)||(f?n(f):``),m=String(a?.engine||a?.recommended_engine||c?.engine||`local_mlx`),h=String(a?.local_path||a?.storage_location||i.cache_path||i.storage_location||`~/.cache/huggingface / ~/.latticeai/models`),g=String(c?.stage||l?.stage||(p?o(e,`library.value.ready`):o(e,`library.value.idle`))),_=t===`basic`;return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(b,{stats:_?[{label:o(e,`library.runtime.computer`),value:H(r,e)},{label:o(e,`library.runtime.loaded`),value:p||o(e,`library.runtime.noneShort`)}]:[{label:o(e,`library.runtime.computer`),value:H(r,e)},{label:o(e,`library.runtime.engine`),value:m},{label:o(e,`library.runtime.loaded`),value:p||o(e,`library.runtime.noLoaded`)},{label:o(e,`library.runtime.state`),value:g}]}),(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/55 p-3 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-medium`,children:p?o(e,`library.models.runtime.available`):o(e,`library.models.runtime.none`)}),_?null:(0,B.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:o(e,`library.runtime.cacheStorage`,{path:h})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(F,{variant:`outline`,size:`sm`,disabled:!p,onClick:u,children:o(e,`library.runtime.reload`)}),(0,B.jsx)(F,{variant:`outline`,size:`sm`,disabled:!p,onClick:d,children:o(e,`library.runtime.unload`)})]})]}),c?(0,B.jsxs)(`div`,{className:`mt-3`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:String(c.message||o(e,`library.preparing`))}),(0,B.jsxs)(`span`,{children:[Number(c.percent||0),`%`]})]}),(0,B.jsx)(`div`,{className:`mt-1 h-2 overflow-hidden rounded-full bg-muted`,children:(0,B.jsx)(`div`,{className:`h-full bg-primary`,style:{width:`${Number(c.percent||8)}%`}})})]}):null]})]})}function re({error:e}){let n=t(e=>e.language),r=s(e.recovery_guidance);return(0,B.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:String(e.user_message||o(n,`library.model.setupAttention`))}),r.length?(0,B.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-muted-foreground`,children:r.slice(0,3).map(e=>(0,B.jsx)(`li`,{children:e},e))}):null]})}function J(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(){let e=l(),n=t(e=>e.language),r=u({queryKey:[`skills`],queryFn:i.skills}),a=u({queryKey:[`skillsMarketplace`],queryFn:i.skillsMarketplace}),c=d({mutationFn:e=>i.skillInstall(String(e.name||e.id),String(e.plugin||``)),onSuccess:()=>e.invalidateQueries({queryKey:[`skills`]})});return(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,B.jsx)(S,{title:o(n,`library.skills.installed`),result:r.data,children:e=>(0,B.jsx)(`div`,{className:`grid gap-2`,children:s(e.skills).map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border p-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-medium`,children:String(e.name||e.id)}),(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:String(e.plugin||e.description||``)})]}),(0,B.jsx)(T,{label:o(n,e.enabled?`library.skills.disable`:`library.skills.enable`),action:()=>i.skillToggle(String(e.name||e.id),!!e.enabled),invalidate:[`skills`]})]},String(e.name||e.id)))})}),(0,B.jsx)(S,{title:o(n,`library.skills.marketplace`),result:a.data,children:e=>(0,B.jsx)(`div`,{className:`grid gap-2`,children:s(e.skills).slice(0,10).map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border p-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-medium`,children:String(e.name||e.id)}),(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:String(e.description||e.category||``)})]}),(0,B.jsx)(F,{variant:`outline`,disabled:c.isPending,onClick:()=>c.mutate(e),children:o(n,`library.skills.install`)})]},String(e.name||e.id)))})})]})}function X(){let e=t(e=>e.mode),n=t(e=>e.language),[r,a]=z.useState(`github`),s=u({queryKey:[`mcpTools`],queryFn:i.mcpTools}),c=d({mutationFn:()=>i.mcpRecommend(r)});return(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1fr_1fr]`,children:[(0,B.jsx)(S,{title:o(n,e===`basic`?`library.connector.connections`:`library.connector.mcpTools`),result:s.data,children:e=>(0,B.jsx)(y,{items:e.tools||e.installed_mcps,titleKey:`name`,metaKey:`status`})}),(0,B.jsxs)(C,{children:[(0,B.jsxs)(_,{children:[(0,B.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,B.jsx)(R,{className:`h-4 w-4`}),` `,o(n,`library.connector.recommend`)]}),(0,B.jsx)(v,{children:o(n,`library.connector.recommendHint`)})]}),(0,B.jsxs)(x,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(k,{value:r,onChange:e=>a(e.target.value)}),(0,B.jsx)(F,{onClick:()=>c.mutate(),disabled:!r.trim()||c.isPending,children:o(n,`library.connector.recommendAction`)})]}),c.data?(0,B.jsx)(m,{result:c.data,successLabel:o(n,`library.connector.recommendDone`)}):null]})]})]})}function Z(){let e=t(e=>e.language),n=u({queryKey:[`templates`],queryFn:i.templates}),r=u({queryKey:[`plugins`],queryFn:i.pluginsRegistry}),a=u({queryKey:[`pluginsDirectory`],queryFn:i.pluginsDirectory});return(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:[(0,B.jsx)(S,{title:o(e,`library.market.templates`),result:n.data,children:e=>(0,B.jsx)(y,{items:e.templates,titleKey:`name`,metaKey:`kind`})}),(0,B.jsx)(S,{title:o(e,`library.market.installedPlugins`),result:r.data,children:e=>(0,B.jsx)(y,{items:e.plugins,titleKey:`name`,metaKey:`status`})}),(0,B.jsx)(S,{title:o(e,`library.market.pluginDirectory`),result:a.data,children:e=>(0,B.jsx)(y,{items:e.plugins,titleKey:`name`,metaKey:`category`})}),(0,B.jsxs)(C,{className:`xl:col-span-3`,children:[(0,B.jsxs)(_,{children:[(0,B.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{className:`h-4 w-4`}),` `,o(e,`library.market.templateInstall`)]}),(0,B.jsx)(v,{children:o(e,`library.market.templateInstallHint`)})]}),(0,B.jsx)(x,{children:s(n.data?.data?.templates).length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:s(n.data?.data?.templates).slice(0,6).map(t=>(0,B.jsx)(T,{label:o(e,`library.market.installTemplate`,{name:String(t.name||t.id)}),action:()=>i.installTemplate(t)},String(t.id||t.name)))}):(0,B.jsx)(y,{items:[]})})]})]})}export{G as LibraryPage};
@@ -1 +1 @@
1
- import{S as e,_ as t,b as n,g as r,m as i,r as a,y as o}from"./utils-C0-C5mZc.js";var s=r(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),c=r(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),l=e(n()),u=o(),d=Array.from({length:12},(e,t)=>t),f=[{x:22,y:32,delay:-.4,duration:5.8},{x:36,y:18,delay:-2.1,duration:6.4},{x:65,y:22,delay:-3.7,duration:5.4},{x:79,y:42,delay:-1.3,duration:6.8},{x:68,y:72,delay:-4.5,duration:5.9},{x:31,y:75,delay:-2.8,duration:6.2}];function p({state:e=`idle`,intensity:n=.6,onPulse:r,size:o=`large`,label:s,className:c,showLabel:p=!0,depth:h=0,onInteract:g}){let _=t(e=>e.language),v=l.useRef(null),y=l.useRef(null),b=l.useRef(null),x=l.useRef({x:0,y:0}),S=l.useId().replace(/:/g,``),C={left:`${S}-lobe-left`,right:`${S}-lobe-right`,bridge:`${S}-bridge`,stem:`${S}-stem`,sheen:`${S}-sheen`},w=l.useCallback(()=>{v.current&&(v.current.classList.add(`pulse`),y.current!==null&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{v.current&&v.current.classList.remove(`pulse`)},1350)),r?.()},[r]);l.useEffect(()=>{let e=()=>w();return window.addEventListener(`brain:recall`,e),()=>{window.removeEventListener(`brain:recall`,e),y.current!==null&&window.clearTimeout(y.current)}},[w]),l.useEffect(()=>{if(e===`recalling`||n>.82){let e=window.setTimeout(()=>w(),180);return()=>clearTimeout(e)}},[e,n,w]);let T=e,E=o===`large`,D=o===`trace`,O=Math.max(.35,Math.min(1,n)),k=Math.max(0,Math.min(5,h||0)),A=e===`thinking`||e===`recalling`||e===`synthesizing`||e===`acting`,j=()=>{w(),!A&&g?.()},M=l.useRef(!1);l.useEffect(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>{M.current=e.matches};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let N=l.useCallback(e=>{if(M.current||e.pointerType===`touch`)return;let t=v.current;if(!t)return;let n=t.getBoundingClientRect(),r=(e.clientX-n.left)/n.width*2-1;x.current={x:((e.clientY-n.top)/n.height*2-1)*-9,y:r*11},b.current===null&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=v.current;e&&(e.style.setProperty(`--tilt-y`,`${x.current.y.toFixed(2)}deg`),e.style.setProperty(`--tilt-x`,`${x.current.x.toFixed(2)}deg`))}))},[]),P=l.useCallback(()=>{b.current!==null&&(window.cancelAnimationFrame(b.current),b.current=null);let e=v.current;e&&(e.style.setProperty(`--tilt-y`,`0deg`),e.style.setProperty(`--tilt-x`,`0deg`))},[]);return l.useEffect(()=>()=>{b.current!==null&&window.cancelAnimationFrame(b.current)},[]),(0,u.jsxs)(`div`,{className:a(`brain-presence select-none`,E&&`large`,D&&`trace`,c,k>0&&`is-exploring`),"aria-label":i(_,`brain.living.aria`),role:`group`,"data-depth":k,children:[(0,u.jsxs)(`button`,{type:`button`,ref:v,className:a(`brain-organism`,`size-${o}`,`depth-${k}`),"data-state":T,"data-testid":`living-brain`,"aria-label":i(_,k<5?`brain.living.open`:`brain.living.graph`),"aria-busy":A,style:{"--brain-scale":`${.96+(O-.5)*.09+k*.015}`},onClick:j,onPointerMove:N,onPointerLeave:P,title:i(_,k<5?`brain.living.open`:`brain.living.graph`),children:[(0,u.jsxs)(`div`,{className:`brain-vital-field`,"aria-hidden":`true`,children:[(0,u.jsx)(`span`,{className:`brain-vital-ring is-primary`}),(0,u.jsx)(`span`,{className:`brain-vital-ring is-echo`}),(0,u.jsx)(`span`,{className:`brain-orbit is-near`,children:(0,u.jsx)(`i`,{})}),(0,u.jsx)(`span`,{className:`brain-orbit is-far`,children:(0,u.jsx)(`i`,{})}),f.map((e,t)=>(0,u.jsx)(`i`,{className:`brain-vital-spark`,style:{left:`${e.x}%`,top:`${e.y}%`,animationDelay:`${e.delay}s`,animationDuration:`${e.duration}s`,"--spark-index":t}},`${e.x}-${e.y}`))]}),(0,u.jsx)(`div`,{className:`brain-core`,style:{"--core-scale":`${1+k*.045}`},children:(0,u.jsx)(`div`,{className:`brain-body-motion`,children:(0,u.jsxs)(`svg`,{className:`brain-anatomy`,viewBox:`0 0 220 174`,"aria-hidden":!0,children:[(0,u.jsxs)(`defs`,{children:[(0,u.jsxs)(`radialGradient`,{id:C.left,cx:`34%`,cy:`26%`,r:`85%`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--brain-halo) / 0.8)`}),(0,u.jsx)(`stop`,{offset:`42%`,stopColor:`hsl(var(--brain-core) / 0.46)`}),(0,u.jsx)(`stop`,{offset:`78%`,stopColor:`hsl(var(--brain-core) / 0.2)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(228 30% 8% / 0.28)`})]}),(0,u.jsxs)(`radialGradient`,{id:C.right,cx:`62%`,cy:`24%`,r:`88%`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--connection) / 0.66)`}),(0,u.jsx)(`stop`,{offset:`46%`,stopColor:`hsl(var(--connection) / 0.32)`}),(0,u.jsx)(`stop`,{offset:`80%`,stopColor:`hsl(var(--connection) / 0.14)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(228 30% 8% / 0.3)`})]}),(0,u.jsxs)(`radialGradient`,{id:C.bridge,cx:`50%`,cy:`30%`,r:`80%`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--memory) / 0.55)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(var(--memory) / 0.1)`})]}),(0,u.jsxs)(`linearGradient`,{id:C.stem,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--knowledge) / 0.42)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(var(--knowledge) / 0.08)`})]}),(0,u.jsxs)(`linearGradient`,{id:C.sheen,x1:`0`,y1:`0`,x2:`0.4`,y2:`1`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(40 60% 98% / 0.5)`}),(0,u.jsx)(`stop`,{offset:`70%`,stopColor:`hsl(40 60% 98% / 0.06)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(40 60% 98% / 0)`})]})]}),(0,u.jsx)(`path`,{className:`brain-lobe brain-lobe-left`,style:{fill:`url(#${C.left})`},d:`M102 30c-13-20-44-19-55 1-18 1-29 16-28 33-13 8-18 25-11 39-9 16-1 36 17 42 5 19 27 26 43 15 13 10 33 8 43-5 5-7 8-16 8-27V52c0-8-6-17-17-22Z`}),(0,u.jsx)(`path`,{className:`brain-lobe brain-lobe-right`,style:{fill:`url(#${C.right})`},d:`M118 30c13-20 44-19 55 1 18 1 29 16 28 33 13 8 18 25 11 39 9 16 1 36-17 42-5 19-27 26-43 15-13 10-33 8-43-5-5-7-8-16-8-27V52c0-8 6-17 17-22Z`}),(0,u.jsx)(`path`,{className:`brain-bridge`,style:{fill:`url(#${C.bridge})`},d:`M103 48c9-8 24-8 33 0 7 6 9 16 5 25-5 11-16 15-31 12-15 3-26-1-31-12-4-9-2-19 5-25 5-4 12-6 19 0Z`}),(0,u.jsx)(`path`,{className:`brain-stem`,style:{fill:`url(#${C.stem})`},d:`M92 137c10 9 26 9 36 0 1 14 7 25 20 33H76c12-8 17-19 16-33Z`}),(0,u.jsx)(`path`,{className:`brain-fold fold-a`,d:`M48 50c18-11 38-8 47 8`}),(0,u.jsx)(`path`,{className:`brain-fold fold-b`,d:`M34 82c22-8 45-5 58 8`}),(0,u.jsx)(`path`,{className:`brain-fold fold-c`,d:`M43 119c18 5 35 2 49-11`}),(0,u.jsx)(`path`,{className:`brain-fold fold-d`,d:`M172 50c-18-11-38-8-47 8`}),(0,u.jsx)(`path`,{className:`brain-fold fold-e`,d:`M186 82c-22-8-45-5-58 8`}),(0,u.jsx)(`path`,{className:`brain-fold fold-f`,d:`M177 119c-18 5-35 2-49-11`}),(0,u.jsx)(`path`,{className:`brain-fold fold-mid`,d:`M110 38c-5 30-5 70 0 112`}),(0,u.jsx)(`path`,{className:`brain-sheen`,style:{fill:`url(#${C.sheen})`},d:`M58 38c22-16 52-20 78-10-30-2-58 6-74 22-8 8-16 6-4-12Z`})]})})}),(0,u.jsx)(`div`,{className:`brain-aura`,style:{animationDuration:e===`thinking`?`1.65s`:e===`recalling`?`2.4s`:`6.8s`,"--aura-scale":`${1+k*.12}`,opacity:.65+k*.05,boxShadow:k>2?`0 0 60px hsl(var(--brain-core) / 0.25)`:`none`}}),(0,u.jsx)(`div`,{className:`thought-activity`,"aria-hidden":!0,children:d.slice(0,Math.min(12,5+k*2)).map(e=>(0,u.jsx)(`div`,{className:a(`thought-particle`,k>=3&&`resolving`),style:{left:`${18+(e*13+k*4)%64}%`,top:`${22+e%5*14}%`,animationDelay:`-${e*.55+n*1.1-k*.2}s`,animationDuration:`${2.8+(1-O)*1.6-k*.15}s`}},e))}),Array.from({length:1+Math.floor(k/1.5)}).map((e,t)=>(0,u.jsx)(`div`,{className:`memory-ripple`,"aria-hidden":!0,style:{inset:`${18+t*6}%`,animationDelay:`${180+t*220}ms`,opacity:.55+k*.06}},t))]}),p&&!D&&(0,u.jsxs)(`div`,{className:`brain-presence-label`,"data-state":e,children:[(0,u.jsx)(`span`,{className:`dot`}),s||(k>0?i(_,`brain.living.depth`,{depth:k}):i(_,m(e)))]})]})}function m(e){switch(e){case`listening`:return`brain.living.state.listening`;case`thinking`:return`brain.living.state.thinking`;case`recalling`:return`brain.living.state.recalling`;case`synthesizing`:return`brain.living.state.synthesizing`;case`planning`:return`brain.living.state.planning`;case`acting`:return`brain.living.state.acting`;case`resting`:return`brain.living.state.resting`;default:return`brain.living.state.idle`}}function h(){typeof window<`u`&&window.dispatchEvent(new CustomEvent(`brain:recall`))}export{s as i,h as n,c as r,p as t};
1
+ import{S as e,_ as t,b as n,g as r,m as i,r as a,y as o}from"./utils-fEGWreKB.js";var s=r(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),c=r(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),l=e(n()),u=o(),d=Array.from({length:12},(e,t)=>t),f=[{x:22,y:32,delay:-.4,duration:5.8},{x:36,y:18,delay:-2.1,duration:6.4},{x:65,y:22,delay:-3.7,duration:5.4},{x:79,y:42,delay:-1.3,duration:6.8},{x:68,y:72,delay:-4.5,duration:5.9},{x:31,y:75,delay:-2.8,duration:6.2}];function p({state:e=`idle`,intensity:n=.6,onPulse:r,size:o=`large`,label:s,className:c,showLabel:p=!0,depth:h=0,onInteract:g}){let _=t(e=>e.language),v=l.useRef(null),y=l.useRef(null),b=l.useRef(null),x=l.useRef({x:0,y:0}),S=l.useId().replace(/:/g,``),C={left:`${S}-lobe-left`,right:`${S}-lobe-right`,bridge:`${S}-bridge`,stem:`${S}-stem`,sheen:`${S}-sheen`},w=l.useCallback(()=>{v.current&&(v.current.classList.add(`pulse`),y.current!==null&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{v.current&&v.current.classList.remove(`pulse`)},1350)),r?.()},[r]);l.useEffect(()=>{let e=()=>w();return window.addEventListener(`brain:recall`,e),()=>{window.removeEventListener(`brain:recall`,e),y.current!==null&&window.clearTimeout(y.current)}},[w]),l.useEffect(()=>{if(e===`recalling`||n>.82){let e=window.setTimeout(()=>w(),180);return()=>clearTimeout(e)}},[e,n,w]);let T=e,E=o===`large`,D=o===`trace`,O=Math.max(.35,Math.min(1,n)),k=Math.max(0,Math.min(5,h||0)),A=e===`thinking`||e===`recalling`||e===`synthesizing`||e===`acting`,j=()=>{w(),!A&&g?.()},M=l.useRef(!1);l.useEffect(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>{M.current=e.matches};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let N=l.useCallback(e=>{if(M.current||e.pointerType===`touch`)return;let t=v.current;if(!t)return;let n=t.getBoundingClientRect(),r=(e.clientX-n.left)/n.width*2-1;x.current={x:((e.clientY-n.top)/n.height*2-1)*-9,y:r*11},b.current===null&&(b.current=window.requestAnimationFrame(()=>{b.current=null;let e=v.current;e&&(e.style.setProperty(`--tilt-y`,`${x.current.y.toFixed(2)}deg`),e.style.setProperty(`--tilt-x`,`${x.current.x.toFixed(2)}deg`))}))},[]),P=l.useCallback(()=>{b.current!==null&&(window.cancelAnimationFrame(b.current),b.current=null);let e=v.current;e&&(e.style.setProperty(`--tilt-y`,`0deg`),e.style.setProperty(`--tilt-x`,`0deg`))},[]);return l.useEffect(()=>()=>{b.current!==null&&window.cancelAnimationFrame(b.current)},[]),(0,u.jsxs)(`div`,{className:a(`brain-presence select-none`,E&&`large`,D&&`trace`,c,k>0&&`is-exploring`),"aria-label":i(_,`brain.living.aria`),role:`group`,"data-depth":k,children:[(0,u.jsxs)(`button`,{type:`button`,ref:v,className:a(`brain-organism`,`size-${o}`,`depth-${k}`),"data-state":T,"data-testid":`living-brain`,"aria-label":i(_,k<5?`brain.living.open`:`brain.living.graph`),"aria-busy":A,style:{"--brain-scale":`${.96+(O-.5)*.09+k*.015}`},onClick:j,onPointerMove:N,onPointerLeave:P,title:i(_,k<5?`brain.living.open`:`brain.living.graph`),children:[(0,u.jsxs)(`div`,{className:`brain-vital-field`,"aria-hidden":`true`,children:[(0,u.jsx)(`span`,{className:`brain-vital-ring is-primary`}),(0,u.jsx)(`span`,{className:`brain-vital-ring is-echo`}),(0,u.jsx)(`span`,{className:`brain-orbit is-near`,children:(0,u.jsx)(`i`,{})}),(0,u.jsx)(`span`,{className:`brain-orbit is-far`,children:(0,u.jsx)(`i`,{})}),f.map((e,t)=>(0,u.jsx)(`i`,{className:`brain-vital-spark`,style:{left:`${e.x}%`,top:`${e.y}%`,animationDelay:`${e.delay}s`,animationDuration:`${e.duration}s`,"--spark-index":t}},`${e.x}-${e.y}`))]}),(0,u.jsx)(`div`,{className:`brain-core`,style:{"--core-scale":`${1+k*.045}`},children:(0,u.jsx)(`div`,{className:`brain-body-motion`,children:(0,u.jsxs)(`svg`,{className:`brain-anatomy`,viewBox:`0 0 220 174`,"aria-hidden":!0,children:[(0,u.jsxs)(`defs`,{children:[(0,u.jsxs)(`radialGradient`,{id:C.left,cx:`34%`,cy:`26%`,r:`85%`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--brain-halo) / 0.8)`}),(0,u.jsx)(`stop`,{offset:`42%`,stopColor:`hsl(var(--brain-core) / 0.46)`}),(0,u.jsx)(`stop`,{offset:`78%`,stopColor:`hsl(var(--brain-core) / 0.2)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(228 30% 8% / 0.28)`})]}),(0,u.jsxs)(`radialGradient`,{id:C.right,cx:`62%`,cy:`24%`,r:`88%`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--connection) / 0.66)`}),(0,u.jsx)(`stop`,{offset:`46%`,stopColor:`hsl(var(--connection) / 0.32)`}),(0,u.jsx)(`stop`,{offset:`80%`,stopColor:`hsl(var(--connection) / 0.14)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(228 30% 8% / 0.3)`})]}),(0,u.jsxs)(`radialGradient`,{id:C.bridge,cx:`50%`,cy:`30%`,r:`80%`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--memory) / 0.55)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(var(--memory) / 0.1)`})]}),(0,u.jsxs)(`linearGradient`,{id:C.stem,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(var(--knowledge) / 0.42)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(var(--knowledge) / 0.08)`})]}),(0,u.jsxs)(`linearGradient`,{id:C.sheen,x1:`0`,y1:`0`,x2:`0.4`,y2:`1`,children:[(0,u.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(40 60% 98% / 0.5)`}),(0,u.jsx)(`stop`,{offset:`70%`,stopColor:`hsl(40 60% 98% / 0.06)`}),(0,u.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(40 60% 98% / 0)`})]})]}),(0,u.jsx)(`path`,{className:`brain-lobe brain-lobe-left`,style:{fill:`url(#${C.left})`},d:`M102 30c-13-20-44-19-55 1-18 1-29 16-28 33-13 8-18 25-11 39-9 16-1 36 17 42 5 19 27 26 43 15 13 10 33 8 43-5 5-7 8-16 8-27V52c0-8-6-17-17-22Z`}),(0,u.jsx)(`path`,{className:`brain-lobe brain-lobe-right`,style:{fill:`url(#${C.right})`},d:`M118 30c13-20 44-19 55 1 18 1 29 16 28 33 13 8 18 25 11 39 9 16 1 36-17 42-5 19-27 26-43 15-13 10-33 8-43-5-5-7-8-16-8-27V52c0-8 6-17 17-22Z`}),(0,u.jsx)(`path`,{className:`brain-bridge`,style:{fill:`url(#${C.bridge})`},d:`M103 48c9-8 24-8 33 0 7 6 9 16 5 25-5 11-16 15-31 12-15 3-26-1-31-12-4-9-2-19 5-25 5-4 12-6 19 0Z`}),(0,u.jsx)(`path`,{className:`brain-stem`,style:{fill:`url(#${C.stem})`},d:`M92 137c10 9 26 9 36 0 1 14 7 25 20 33H76c12-8 17-19 16-33Z`}),(0,u.jsx)(`path`,{className:`brain-fold fold-a`,d:`M48 50c18-11 38-8 47 8`}),(0,u.jsx)(`path`,{className:`brain-fold fold-b`,d:`M34 82c22-8 45-5 58 8`}),(0,u.jsx)(`path`,{className:`brain-fold fold-c`,d:`M43 119c18 5 35 2 49-11`}),(0,u.jsx)(`path`,{className:`brain-fold fold-d`,d:`M172 50c-18-11-38-8-47 8`}),(0,u.jsx)(`path`,{className:`brain-fold fold-e`,d:`M186 82c-22-8-45-5-58 8`}),(0,u.jsx)(`path`,{className:`brain-fold fold-f`,d:`M177 119c-18 5-35 2-49-11`}),(0,u.jsx)(`path`,{className:`brain-fold fold-mid`,d:`M110 38c-5 30-5 70 0 112`}),(0,u.jsx)(`path`,{className:`brain-sheen`,style:{fill:`url(#${C.sheen})`},d:`M58 38c22-16 52-20 78-10-30-2-58 6-74 22-8 8-16 6-4-12Z`})]})})}),(0,u.jsx)(`div`,{className:`brain-aura`,style:{animationDuration:e===`thinking`?`1.65s`:e===`recalling`?`2.4s`:`6.8s`,"--aura-scale":`${1+k*.12}`,opacity:.65+k*.05,boxShadow:k>2?`0 0 var(--aura-blur, 60px) hsl(var(--brain-core) / 0.25)`:`none`}}),(0,u.jsx)(`div`,{className:`thought-activity`,"aria-hidden":!0,children:d.slice(0,Math.min(12,5+k*2)).map(e=>(0,u.jsx)(`div`,{className:a(`thought-particle`,k>=3&&`resolving`),style:{left:`${18+(e*13+k*4)%64}%`,top:`${22+e%5*14}%`,animationDelay:`-${e*.55+n*1.1-k*.2}s`,animationDuration:`${2.8+(1-O)*1.6-k*.15}s`}},e))}),Array.from({length:1+Math.floor(k/1.5)}).map((e,t)=>(0,u.jsx)(`div`,{className:`memory-ripple`,"aria-hidden":!0,style:{inset:`${18+t*6}%`,animationDelay:`${180+t*220}ms`,opacity:.55+k*.06}},t))]}),p&&!D&&(0,u.jsxs)(`div`,{className:`brain-presence-label`,"data-state":e,children:[(0,u.jsx)(`span`,{className:`dot`}),s||(k>0?i(_,`brain.living.depth`,{depth:k}):i(_,m(e)))]})]})}function m(e){switch(e){case`listening`:return`brain.living.state.listening`;case`thinking`:return`brain.living.state.thinking`;case`recalling`:return`brain.living.state.recalling`;case`synthesizing`:return`brain.living.state.synthesizing`;case`planning`:return`brain.living.state.planning`;case`acting`:return`brain.living.state.acting`;case`resting`:return`brain.living.state.resting`;default:return`brain.living.state.idle`}}function h(){typeof window<`u`&&window.dispatchEvent(new CustomEvent(`brain:recall`))}export{s as i,h as n,c as r,p as t};
@@ -0,0 +1 @@
1
+ import{S as e,_ as t,b as n,d as r,g as i,h as a,m as o,p as s,t as c,y as l}from"./utils-fEGWreKB.js";import{i as u,r as d,t as f}from"./LivingBrain-FlHFfu9i.js";import{n as p,t as m}from"./input-DrMc0Xns.js";import{t as h}from"./cpu-Cx-wRR_V.js";import{l as g,v as _}from"./index-mLP0-YNO.js";import"./brain-Dn_bDfl4.js";import{t as v}from"./button-DPFZ9lGw.js";var y=i(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),b=i(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),x=i(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),S=i(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),C=e(n());a({ko:{"flow.analysis.fact.computer":`컴퓨터`,"flow.analysis.fact.memory":`메모리`,"flow.analysis.fact.graphics":`그래픽`,"flow.analysis.fact.support":`로컬 지원`,"flow.analysis.fact.models":`모델`,"flow.analysis.checking":`확인 중`,"flow.analysis.fact.computerDetail":`운영체제와 칩`,"flow.analysis.fact.memoryDetail":`로컬 사고를 위한 여유 공간`,"flow.analysis.fact.graphicsDetail":`로컬 가속 지원`,"flow.analysis.fact.supportDetail":`설치된 모델 도우미`,"flow.analysis.fact.modelsDetail":`설치된 로컬 Brain`,"flow.analysis.apple":`Apple Silicon Mac`,"flow.analysis.detected":`감지됨`,"flow.analysis.localReady":`로컬 가속 준비됨`,"flow.analysis.standardLocal":`표준 로컬 모드`,"flow.analysis.supportReady":`준비됨`,"flow.analysis.supportInstall":`준비 예정`,"flow.analysis.modelsInstalled":`{count}개 이미 설치됨`,"flow.analysis.noModels":`아직 설치된 모델 없음`,"flow.analysis.readyDetail":`로컬 Digital Brain 사용 준비 완료`,"flow.analysis.memoryReadyDetail":`추천 모델에 충분한 컨텍스트`,"flow.analysis.graphicsReadyDetail":`Lattice가 가장 좋은 경로를 선택합니다.`,"flow.analysis.supportReadyDetail":`설치된 모델 도우미가 감지되었습니다.`,"flow.analysis.supportInstallDetail":`Lattice가 필요한 항목을 추가합니다.`,"flow.analysis.modelsReadyDetail":`즉시 로드할 수 있는 모델이 있습니다.`,"flow.analysis.modelsInstallDetail":`Lattice가 첫 설치를 안내합니다.`,"flow.recommend.reason.best":`최적 경험`,"flow.recommend.reason.faster":`빠른 선택`,"flow.recommend.reason.advanced":`고급 선택`,"flow.recommend.reason.default":`추천`,"flow.recommend.sizeReady":`준비됨`,"flow.recommend.fallbackName":`추천 Brain`,"flow.install.stage.download":`모델 파일을 받는 중입니다.`,"flow.install.stage.validate":`Brain이 응답할 수 있는지 확인 중입니다.`,"flow.install.stage.load":`Brain을 불러오는 중입니다.`,"flow.install.stage.error":`확인이 필요한 일이 있습니다.`,"flow.install.step.install":`준비`,"flow.install.step.download":`다운로드`,"flow.install.step.ready":`로컬 확인`,"flow.install.step.validate":`확인`,"flow.install.step.load":`로드`,"flow.analysis.hardware.icon.chip":`🖥️`,"flow.analysis.hardware.icon.ram":`🧠`,"flow.analysis.hardware.icon.gpu":`⚡`,"flow.analysis.hardware.icon.support":`🧩`,"flow.analysis.hardware.icon.models":`📦`,"flow.analysis.hardware.label.chip":`컴퓨터 (운영체제와 칩)`,"flow.analysis.hardware.label.ram":`메모리 (생각할 작업 공간, RAM)`,"flow.analysis.hardware.label.gpu":`그래픽 (계산을 도와주는 GPU)`,"flow.analysis.hardware.label.support":`로컬 지원 (모델 실행 도우미)`,"flow.analysis.hardware.label.models":`모델 (설치된 AI Brain)`,"flow.recommend.timeEstimate":`다운로드 약 {download} · 첫 응답 약 {response}초`,"flow.recommend.timeEstimate.ready":`다운로드 불필요 · 첫 응답 약 {response}초`,"flow.recommend.timeEstimate.unknown":`다운로드 시간 미확인 · 첫 응답 약 {response}초`,"flow.recommend.timeNote":`네트워크 속도에 따라 달라질 수 있어요.`,"flow.recommend.alternatives":`다른 선택지`,"flow.recommend.minutes":`{count}분`,"flow.recommend.comparison.faster":`(더 빠름)`,"flow.recommend.comparison.advanced":`(더 강력함)`,"flow.recommend.choose":`이 모델 선택`,"flow.recommend.primaryNote":`약 {time} 후 사용 준비 완료`,"flow.recommend.primaryNote.ready":`다운로드 없이 바로 사용 준비 완료`,"flow.recommend.primaryNote.unknown":`다운로드 시간 확인 후 사용 준비`,"flow.recommend.nextHint":`선택하면 다운로드와 준비 화면으로 넘어가고, 끝나면 바로 Brain이 열립니다.`,"flow.recommend.nextHint.ready":`선택하면 준비 확인 화면으로 넘어가고, 끝나면 바로 Brain이 열립니다.`,"flow.install.expectedTitle":`예상 진행`,"flow.install.expected":`약 {download} 다운로드 후 약 {response}초 안에 첫 응답`,"flow.install.expected.ready":`다운로드 없이 약 {response}초 안에 첫 응답`,"flow.install.expected.unknown":`다운로드 후 약 {response}초 안에 첫 응답`,"flow.install.timelineStep.download":`모델 다운로드`,"flow.install.timelineStep.ready":`로컬 모델 확인`,"flow.install.timelineStep.validate":`응답 확인`,"flow.install.timelineStep.load":`Brain에 로드`,"flow.install.timelineApprox":`약 {time}`,"flow.install.timelineQuick":`잠깐`,"flow.install.expectedCompletion":`끝나면 바로 Brain이 열립니다.`,"flow.shell":`내 로컬 AI 브레인 만들기`,"flow.wake.aria":`Brain 깨우기`,"flow.wake.title":`내 지식이 살아나는 Brain을 시작하세요.`,"flow.wake.body":`Lattice AI는 이 컴퓨터 안에서 내 대화, 문서, 결정이 오래 남는 작업 기억이 되게 합니다. 모델은 바꿔도 Brain은 계속 내 것입니다.`,"flow.wake.value.aria":`Brain 시작 가치`,"flow.wake.value.local.k":`완전 로컬`,"flow.wake.value.local.v":`지식과 대화는 이 컴퓨터에서 먼저 정리됩니다.`,"flow.wake.value.instant.k":`바로 이해`,"flow.wake.value.instant.v":`복잡한 설정 대신 3단계로 첫 대화를 엽니다.`,"flow.wake.value.brain.k":`지속되는 Brain`,"flow.wake.value.brain.v":`모델을 바꿔도 내 기억과 그래프는 이어집니다.`,"flow.wake.plan.aria":`Brain 시작 단계`,"flow.wake.step.identity":`주인 확인`,"flow.wake.step.check":`컴퓨터 확인`,"flow.wake.step.voice":`목소리 선택`,"flow.wake.primary":`Brain 지금 깨우기`,"flow.wake.existing":`기존 Brain 열기`,"flow.wake.startNote":`평균 2분 안에 첫 대화 시작 · 로컬 우선 · 사용자가 제어`,"flow.login.title":`이 Brain의 주인을 정합니다.`,"flow.login.body":`프로필은 로컬 Brain의 소유권을 묶는 기준입니다. 기존 Brain이 있으면 새로 만들기 전에 먼저 안전하게 확인합니다.`,"flow.name":`이름`,"flow.name.placeholder":`나`,"flow.email":`이메일`,"flow.email.placeholder":`you@local`,"flow.password":`비밀번호`,"flow.password.placeholder":`로컬 Brain 비밀번호`,"flow.login.busy":`Brain 여는 중...`,"flow.login.submit":`내 Brain 시작하기`,"flow.login.note":`이 프로필은 내 AI 브레인의 주인입니다. 기존 Brain과 다른 이메일이면 새로 만들지 않고 먼저 확인합니다.`,"flow.login.passwordLocal":`이 비밀번호는 이 컴퓨터의 Brain 전용입니다. 클라우드로 전송되지 않습니다.`,"flow.login.missing":`이름과 이메일, 비밀번호를 입력하면 기존 Brain을 안전하게 확인합니다.`,"flow.login.otherEmail":`이 컴퓨터의 기존 Brain과 다른 이메일입니다. 오타인지 확인해 주세요.`,"flow.login.wrongPassword":`기존 Brain 이메일은 맞지만 비밀번호가 다릅니다. 비밀번호를 다시 확인해 주세요.`,"flow.login.unavailable":`로컬 프로필을 열 수 없습니다. 이메일과 비밀번호를 확인해 주세요.`,"flow.promise.memory.k":`오래 남는 지식`,"flow.promise.memory.v":`내 일이 장기 기억이 됩니다.`,"flow.promise.model.k":`교체 가능한 모델`,"flow.promise.model.v":`모델은 목소리이고, 자산은 Brain입니다.`,"flow.promise.ownership.k":`사용자 소유`,"flow.promise.ownership.v":`백업, 복원, 이동을 직접 결정합니다.`,"flow.promise.aria":`Lattice AI 제품 약속`,"flow.analysis.title":`이 컴퓨터에 맞는 Brain 경험을 확인합니다.`,"flow.analysis.body":`스펙 점수가 아니라, 이 Mac에서 어떤 로컬 AI 브레인 경험이 편한지 보여드립니다. 확인은 로컬 상태를 읽는 것이고, 클라우드 모델은 선택 사항입니다.`,"flow.analysis.finding":`가장 편한 설정을 찾는 중...`,"flow.analysis.ready":`추천 모델을 바로 시작할 수 있게 준비했습니다.`,"flow.analysis.wait":`잠시만 기다리면 자동으로 정리됩니다.`,"flow.analysis.error":`Lattice가 이 컴퓨터를 끝까지 확인하지 못했습니다. 그래도 안전한 기본값으로 계속할 수 있습니다.`,"flow.analysis.continue":`추천 모델 보기`,"flow.analysis.bestFit":`{model}이 이 컴퓨터에 가장 잘 맞습니다.`,"flow.analysis.privateRecommended":`이 컴퓨터에는 개인 로컬 Brain을 추천합니다.`,"flow.analysis.os.windows":`Windows PC`,"flow.analysis.os.linux":`Linux 컴퓨터`,"flow.recommend.title":`추천대로 시작하세요.`,"flow.recommend.environment.apple":`컴퓨터 준비 완료: 로컬 MLX 지원(Apple Silicon, {ram}GB RAM 감지)`,"flow.recommend.environment.standard":`권장: 가벼운 로컬 모델로 시작하세요({ram}GB RAM 감지)`,"flow.recommend.body":`모델은 Brain의 현재 목소리입니다. 추천, 빠른 선택, 강한 선택만 먼저 보여드려 바로 결정할 수 있게 합니다.`,"flow.recommend.primary":`추천으로 바로 시작`,"flow.recommend.unsupported":`이 컴퓨터에서 추가 확인이 필요합니다`,"flow.recommend.back":`뒤로`,"flow.recommend.skip":`모델 없이 Brain 열기`,"flow.recommend.hint":`잘 모르겠다면 추천대로 시작하면 됩니다.`,"flow.recommend.loading":`이 컴퓨터에 맞는 모델을 확인하는 중...`,"flow.recommend.unavailable.aria":`로컬 모델 준비 상태`,"flow.recommend.unavailable.title":`지금은 이 컴퓨터에서 바로 쓸 로컬 모델을 준비하지 못했습니다.`,"flow.recommend.unavailable.probe":`Lattice가 이 컴퓨터의 로컬 환경을 확인하지 못했습니다. 네트워크와 로컬 서비스 상태를 확인한 뒤 다시 시도해 주세요.`,"flow.recommend.unavailable.empty":`이 컴퓨터에서 바로 실행할 수 있는 추천 모델을 찾지 못했습니다. 다시 확인하거나, 모델 없이 Brain을 먼저 열 수 있습니다.`,"flow.recommend.unavailable.retry":`다시 확인`,"flow.recommend.unavailable.hint":`모델은 나중에 라이브러리에서 언제든 추가할 수 있습니다.`,"flow.recommend.rank.best":`추천`,"flow.recommend.rank.faster":`빠른 선택`,"flow.recommend.rank.advanced":`고급 선택`,"flow.recommend.rank.choice":`선택 {index}`,"flow.install.title":`모델을 설치하고 시작합니다.`,"flow.install.title.ready":`모델을 준비하고 시작합니다.`,"flow.install.body":`이 모델이 Brain의 로컬 목소리가 됩니다. 다운로드는 사용자가 시작할 때만 진행되고, 실행과 기억은 이 컴퓨터에서 유지됩니다.`,"flow.install.body.ready":`이 모델이 Brain의 로컬 목소리가 됩니다. 이미 준비된 모델은 외부 다운로드 없이 응답 확인과 로드만 진행합니다.`,"flow.install.wait":`Brain이 사용할 모델을 기다리고 있습니다.`,"flow.install.prepare":`Brain 준비 중입니다.`,"flow.install.done":`Brain이 준비되었습니다.`,"flow.install.note":`큰 모델은 다운로드에 몇 분 이상 걸릴 수 있습니다. 진행률은 모델 런타임이 알려주는 만큼 표시하고, 멈춘 것처럼 보여도 현재 단계가 유지됩니다.`,"flow.install.note.ready":`로컬 응답 확인은 보통 잠깐이면 끝납니다. 실패하면 다른 모델을 고르거나 나중에 다시 시도할 수 있습니다.`,"flow.install.retry":`다른 모델을 고르거나 다시 시도할 수 있습니다.`,"flow.install.back":`다른 모델 고르기`,"flow.install.start":`다운로드하고 시작하기`,"flow.install.startReady":`준비하고 시작하기`,"flow.install.busy":`모델 준비 중...`,"flow.install.enter":`Brain으로 들어가기`,"flow.install.later":`나중에 하기`,"flow.install.local":`모델 다운로드와 외부 통신은 사용자가 시작할 때만 진행됩니다.`,"flow.install.local.ready":`이 선택은 외부 다운로드 없이 로컬 준비 상태만 확인합니다.`,"flow.consent.title":`다운로드 전 확인`,"flow.consent.readyTitle":`로컬 준비 상태`,"flow.consent.body":`시작하면 아래 모델 파일을 외부 저장소에서 받아 이 컴퓨터에 저장합니다.`,"flow.consent.ready":`이미 준비된 모델입니다. 시작해도 외부 다운로드를 요청하지 않고 로컬에서 응답 가능 여부만 확인합니다.`,"flow.consent.state":`다운로드 필요`,"flow.consent.stateReady":`없음`,"flow.consent.size":`다운로드 크기`,"flow.consent.sizeUnknown":`런타임 확인 후 표시`,"flow.consent.location":`저장 위치`,"flow.consent.external":`외부 접속 대상`,"flow.consent.externalUnknown":`런타임 확인 후 표시`,"flow.consent.externalNone":`선택 전 외부 접속 없음`},en:{"flow.analysis.fact.computer":`Computer`,"flow.analysis.fact.memory":`Memory`,"flow.analysis.fact.graphics":`Graphics`,"flow.analysis.fact.support":`Local Support`,"flow.analysis.fact.models":`Models`,"flow.analysis.checking":`Checking`,"flow.analysis.fact.computerDetail":`Operating system and chip`,"flow.analysis.fact.memoryDetail":`Available room for local thinking`,"flow.analysis.fact.graphicsDetail":`Local acceleration support`,"flow.analysis.fact.supportDetail":`Installed model helpers`,"flow.analysis.fact.modelsDetail":`Installed local Brains`,"flow.analysis.apple":`Apple Silicon Mac`,"flow.analysis.detected":`Detected`,"flow.analysis.localReady":`Local acceleration ready`,"flow.analysis.standardLocal":`Standard local mode`,"flow.analysis.supportReady":`Ready`,"flow.analysis.supportInstall":`Will be prepared`,"flow.analysis.modelsInstalled":`{count} already installed`,"flow.analysis.noModels":`None installed yet`,"flow.analysis.readyDetail":`Ready for local Digital Brain use`,"flow.analysis.memoryReadyDetail":`Enough context for the recommended model`,"flow.analysis.graphicsReadyDetail":`Lattice will choose the best available path`,"flow.analysis.supportReadyDetail":`Installed model helpers detected`,"flow.analysis.supportInstallDetail":`Lattice will add what is needed`,"flow.analysis.modelsReadyDetail":`One can be loaded immediately`,"flow.analysis.modelsInstallDetail":`Lattice will guide the first install`,"flow.recommend.reason.best":`Best Experience`,"flow.recommend.reason.faster":`Faster`,"flow.recommend.reason.advanced":`Advanced`,"flow.recommend.reason.default":`Recommended`,"flow.recommend.sizeReady":`ready`,"flow.recommend.fallbackName":`Recommended Brain`,"flow.install.stage.download":`Getting the model files.`,"flow.install.stage.validate":`Checking that the Brain can answer.`,"flow.install.stage.load":`Loading the Brain.`,"flow.install.stage.error":`Something needs attention.`,"flow.install.step.install":`Install`,"flow.install.step.download":`Download`,"flow.install.step.ready":`Local check`,"flow.install.step.validate":`Validate`,"flow.install.step.load":`Load`,"flow.analysis.hardware.icon.chip":`🖥️`,"flow.analysis.hardware.icon.ram":`🧠`,"flow.analysis.hardware.icon.gpu":`⚡`,"flow.analysis.hardware.icon.support":`🧩`,"flow.analysis.hardware.icon.models":`📦`,"flow.analysis.hardware.label.chip":`Computer (operating system and chip)`,"flow.analysis.hardware.label.ram":`Memory (working space to think, RAM)`,"flow.analysis.hardware.label.gpu":`Graphics (the GPU that speeds up math)`,"flow.analysis.hardware.label.support":`Local support (helpers that run models)`,"flow.analysis.hardware.label.models":`Models (AI Brains already installed)`,"flow.recommend.timeEstimate":`Download about {download} · first reply about {response}s`,"flow.recommend.timeEstimate.ready":`No download needed · first reply about {response}s`,"flow.recommend.timeEstimate.unknown":`Download time unknown · first reply about {response}s`,"flow.recommend.timeNote":`Actual time depends on your network speed.`,"flow.recommend.alternatives":`Other options`,"flow.recommend.minutes":`{count} min`,"flow.recommend.comparison.faster":`(faster)`,"flow.recommend.comparison.advanced":`(more capable)`,"flow.recommend.choose":`Choose this model`,"flow.recommend.primaryNote":`Ready to use in about {time}`,"flow.recommend.primaryNote.ready":`Ready with no download`,"flow.recommend.primaryNote.unknown":`Ready after download time is confirmed`,"flow.recommend.nextHint":`Choosing takes you to download and setup, then your Brain opens automatically.`,"flow.recommend.nextHint.ready":`Choosing takes you to a readiness check, then your Brain opens automatically.`,"flow.install.expectedTitle":`What to expect`,"flow.install.expected":`About {download} to download, then a first reply within about {response}s`,"flow.install.expected.ready":`No download — first reply within about {response}s`,"flow.install.expected.unknown":`After download, a first reply within about {response}s`,"flow.install.timelineStep.download":`Download model`,"flow.install.timelineStep.ready":`Check local model`,"flow.install.timelineStep.validate":`Check the reply`,"flow.install.timelineStep.load":`Load into Brain`,"flow.install.timelineApprox":`about {time}`,"flow.install.timelineQuick":`moment`,"flow.install.expectedCompletion":`When it finishes, your Brain opens right away.`,"flow.shell":`Create your local AI Brain`,"flow.wake.aria":`Wake your Brain`,"flow.wake.title":`Start the Brain where your knowledge comes alive.`,"flow.wake.body":`Lattice AI turns your conversations, documents, and decisions into durable working memory on this computer. Models can change while your Brain remains yours.`,"flow.wake.value.aria":`Brain startup value`,"flow.wake.value.local.k":`Fully local`,"flow.wake.value.local.v":`Knowledge and conversations are organized on this computer first.`,"flow.wake.value.instant.k":`Clear start`,"flow.wake.value.instant.v":`Open the first conversation in three guided steps.`,"flow.wake.value.brain.k":`Durable Brain`,"flow.wake.value.brain.v":`Your memories and graph continue even when models change.`,"flow.wake.plan.aria":`Brain start steps`,"flow.wake.step.identity":`Confirm owner`,"flow.wake.step.check":`Check computer`,"flow.wake.step.voice":`Choose voice`,"flow.wake.primary":`Wake Brain`,"flow.wake.existing":`Open existing Brain`,"flow.wake.startNote":`First conversation in about 2 minutes · local-first · user controlled`,"flow.login.title":`Choose the owner of this Brain.`,"flow.login.body":`Your profile anchors ownership of the local Brain. If a Brain already exists here, Lattice checks safely before creating anything new.`,"flow.name":`Name`,"flow.name.placeholder":`You`,"flow.email":`Email`,"flow.email.placeholder":`you@local`,"flow.password":`Password`,"flow.password.placeholder":`Local Brain password`,"flow.login.busy":`Opening Brain...`,"flow.login.submit":`Start my Brain`,"flow.login.note":`This profile owns your AI Brain. If the email differs from this computer's Brain, Lattice checks before creating anything new.`,"flow.login.passwordLocal":`This password is only for the Brain on this computer. It is not sent to the cloud.`,"flow.login.missing":`Enter your name, email, and password so Lattice can safely check your Brain.`,"flow.login.otherEmail":`This email differs from the Brain on this computer. Please check for a typo.`,"flow.login.wrongPassword":`The email matches this Brain, but the password is different. Please check it again.`,"flow.login.unavailable":`Could not open the local profile. Check your email and password.`,"flow.promise.memory.k":`Durable knowledge`,"flow.promise.memory.v":`Your work becomes long-term memory.`,"flow.promise.model.k":`Replaceable models`,"flow.promise.model.v":`The model is the voice; the Brain is the asset.`,"flow.promise.ownership.k":`User owned`,"flow.promise.ownership.v":`You decide when to back up, restore, or move it.`,"flow.promise.aria":`Lattice AI product promise`,"flow.analysis.title":`Checking the Brain experience for this computer.`,"flow.analysis.body":`This is not a spec score. Lattice reads local capability and explains which local AI Brain experience will feel comfortable on this Mac. Cloud models remain optional.`,"flow.analysis.finding":`Finding the easiest setup...`,"flow.analysis.ready":`Your recommended model is ready to start.`,"flow.analysis.wait":`This will be summarized automatically in a moment.`,"flow.analysis.error":`Lattice could not finish checking this computer. You can still continue with a safe default.`,"flow.analysis.continue":`View recommended models`,"flow.analysis.bestFit":`{model} looks like the best fit.`,"flow.analysis.privateRecommended":`A private local Brain is recommended for this computer.`,"flow.analysis.os.windows":`Windows PC`,"flow.analysis.os.linux":`Linux computer`,"flow.recommend.title":`Start with the recommendation.`,"flow.recommend.environment.apple":`Computer ready: local MLX supported (Apple Silicon, {ram}GB RAM detected)`,"flow.recommend.environment.standard":`Recommended: start with a lighter local model ({ram}GB RAM detected)`,"flow.recommend.body":`The model is your Brain's current voice. Lattice shows the recommendation, a faster choice, and a stronger choice first so you can decide quickly.`,"flow.recommend.primary":`Start with recommendation`,"flow.recommend.unsupported":`This computer needs one more check`,"flow.recommend.back":`Back`,"flow.recommend.skip":`Open Brain without a model`,"flow.recommend.hint":`If unsure, start with the recommendation.`,"flow.recommend.loading":`Checking which model fits this computer...`,"flow.recommend.unavailable.aria":`Local model readiness`,"flow.recommend.unavailable.title":`A local model isn't ready to run on this computer yet.`,"flow.recommend.unavailable.probe":`Lattice couldn't check this computer's local environment. Check your network and local services, then try again.`,"flow.recommend.unavailable.empty":`No recommended model can run on this computer right now. Try checking again, or open your Brain without a model first.`,"flow.recommend.unavailable.retry":`Check again`,"flow.recommend.unavailable.hint":`You can add a model anytime later from the library.`,"flow.recommend.rank.best":`Best Experience`,"flow.recommend.rank.faster":`Faster`,"flow.recommend.rank.advanced":`Advanced`,"flow.recommend.rank.choice":`Choice {index}`,"flow.install.title":`Install the model and start.`,"flow.install.title.ready":`Prepare the model and start.`,"flow.install.body":`This model becomes your Brain's local voice. Download starts only when you choose it; execution and memory stay on this computer.`,"flow.install.body.ready":`This model becomes your Brain's local voice. Because it is already ready, Lattice only checks the reply path and loads it locally.`,"flow.install.wait":`Waiting for the model your Brain will use.`,"flow.install.prepare":`Preparing your Brain.`,"flow.install.done":`Your Brain is ready.`,"flow.install.note":`Large models can take several minutes to download. Progress is shown when the model runtime reports it; a steady stage still means work is continuing.`,"flow.install.note.ready":`The local reply check usually takes a moment. If it fails, choose another model or try again later.`,"flow.install.retry":`Choose another model or try again.`,"flow.install.back":`Choose another model`,"flow.install.start":`Download and start`,"flow.install.startReady":`Check and start`,"flow.install.busy":`Preparing model...`,"flow.install.enter":`Enter Brain`,"flow.install.later":`Do later`,"flow.install.local":`Downloads and external communication start only when you choose them.`,"flow.install.local.ready":`This choice checks local readiness without starting an external download.`,"flow.consent.title":`Before downloading`,"flow.consent.readyTitle":`Local readiness`,"flow.consent.body":`Starting will fetch these model files from an external repository and store them on this computer.`,"flow.consent.ready":`This model is already ready. Starting checks whether it can answer locally without requesting an external download.`,"flow.consent.state":`Download needed`,"flow.consent.stateReady":`No`,"flow.consent.size":`Download size`,"flow.consent.sizeUnknown":`Reported by runtime`,"flow.consent.location":`Storage location`,"flow.consent.external":`External target`,"flow.consent.externalUnknown":`Reported by runtime`,"flow.consent.externalNone":`No external connection before selection`}});function ee(e){let t=j(e?.models),n=[...c(t.recommended),...c(t.catalog)],r=j(e?.recommendations?.recommendations),i=c(r.models),a=j(r.top_pick),o=new Map;for(let e of[...i,...n]){let t=String(e.id||e.model_id||e.recommended_load_id||``);t&&o.set(t,{...o.get(t)||{},...e})}a.id&&!o.has(String(a.id))&&o.set(String(a.id),a);let s=Array.from(o.values()).map(E).filter(e=>e.id),l=s.filter(e=>e.supported),u=l.length?l:s,d=(e=>u.find(t=>t.id===String(e)))(a.id)||(e=>u.find(t=>e.test(`${t.name} ${t.id}`)))(/gemma.*12|12b/i)||u[0],f=u.find(e=>e.id!==d?.id&&/qwen|8b|7b/i.test(`${e.name} ${e.id}`))||u.find(e=>e.id!==d?.id),p=u.find(e=>e.id!==d?.id&&e.id!==f?.id&&/26b|32b|70b|advanced/i.test(`${e.name} ${e.id}`))||u.find(e=>e.id!==d?.id&&e.id!==f?.id);return[d?{...d,role:`best`,reason:d.reason||`best`}:null,f?{...f,role:`faster`,reason:f.reason||`faster`}:null,p?{...p,role:`advanced`,reason:p.reason||`advanced`}:null].filter(Boolean)}function w(e){let{analysis:t,endpoints:n}=e;if(!n)return{status:`loading`,recommendations:[],reason:null,failedEndpoints:[]};let r=Object.keys(n).filter(e=>!n[e]);if(!(n.recommendations||n.models))return{status:`unavailable`,recommendations:[],reason:`probe_failed`,failedEndpoints:r};let i=ee(t).filter(e=>e.supported);return i.length?{status:`ready`,recommendations:i,reason:null,failedEndpoints:r}:{status:`unavailable`,recommendations:[],reason:`no_supported_model`,failedEndpoints:r}}function T(){return{id:`mlx-community/Qwen3-VL-8B-Instruct-4bit`,loadId:`mlx-community/Qwen3-VL-8B-Instruct-4bit`,engine:`local_mlx`,name:`Qwen3-VL 8B`,shortName:`Qwen 3`,family:`Qwen 3`,size:``,role:`best`,reason:`best`,supported:!0,downloadRequired:!1,downloadSize:``,storageLocation:`~/.latticeai/models`,externalHost:``,estimatedDownloadMinutes:0,estimatedFirstResponseSeconds:5,parameterBillions:8}}function E(e){let t=j(e.runtime_compatibility),n=String(e.id||e.model_id||e.recommended_load_id||``),r=String(e.recommended_load_id||e.load_id||n),i=String(e.display_name||e.name||n||`recommended_brain`),a=e.load_status!==`unsupported`&&e.load_status!==`runtime_update_needed`&&e.status!==`not_recommended`&&t.supported!==!1,o=!!e.download_required,s=o?String(e.download_size||e.size||``):``,c=D(`${i} ${n}`);return{id:n,loadId:r,engine:String(e.recommended_engine||e.engine||`local_mlx`),name:i,shortName:A(i||n),family:A(String(e.family||i||`local_brain`)),size:String(e.size||``),role:`best`,reason:String(e.reason||``),supported:a,downloadRequired:o,downloadSize:s,storageLocation:String(e.storage_location||e.local_path||`~/.latticeai/models`),externalHost:o?k(e):``,estimatedDownloadMinutes:o?ne(s):0,estimatedFirstResponseSeconds:O(c),parameterBillions:c}}function te(e){let t=String(e||``).match(/([\d.]+)\s*(t|g|m)?b?/i);if(!t)return null;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return null;let r=(t[2]||`g`).toLowerCase();return r===`t`?n*1024*1024:r===`m`?n:n*1024}function ne(e){let t=te(e);if(t===null)return null;let n=t/(15/8)/60;return Math.max(1,Math.round(n))}function D(e){let t=String(e||``).match(/(\d{1,3}(?:\.\d)?)\s*b\b/i);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)&&n>0?n:null}function O(e){return e===null?8:e<=9?5:e<=16?10:e<=40?18:30}function k(e){let t=String(e.source_url||e.download_url||e.repository||e.provider||e.id||``);return t?/huggingface|hf\\.co|mlx-community/i.test(t)?`huggingface`:/ollama/i.test(t)?`ollama`:t.replace(/^https?:\/\//,``).split(`/`)[0]||t:``}function A(e){return String(e||`recommended_brain`).replace(/^mlx-community\//i,``).replace(/[-_]?Instruct/gi,``).replace(/[-_]?4bit/gi,``).replace(/Qwen3[-_ ]?VL/gi,`Qwen 3`).replace(/Qwen3/gi,`Qwen 3`).replace(/Gemma[-_ ]?4/gi,`Gemma 4`).replace(/A4B/gi,``).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim()}function j(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}var M=l();function re({model:e}){let n=t(e=>e.language),r=e.downloadRequired?[{label:o(n,`flow.consent.size`),value:e.downloadSize||o(n,`flow.consent.sizeUnknown`)},{label:o(n,`flow.consent.location`),value:e.storageLocation},{label:o(n,`flow.consent.external`),value:e.externalHost||o(n,`flow.consent.externalUnknown`)}]:[{label:o(n,`flow.consent.state`),value:o(n,`flow.consent.stateReady`)},{label:o(n,`flow.consent.location`),value:e.storageLocation},{label:o(n,`flow.consent.external`),value:o(n,`flow.consent.externalNone`)}],i=e.downloadRequired?`flow.consent.title`:`flow.consent.readyTitle`;return(0,M.jsxs)(`section`,{className:`ritual-consent-panel`,"aria-label":o(n,i),children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`strong`,{children:o(n,i)}),(0,M.jsx)(`p`,{children:e.downloadRequired?o(n,`flow.consent.body`):o(n,`flow.consent.ready`)})]}),(0,M.jsx)(`dl`,{children:r.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:e.label}),(0,M.jsx)(`dd`,{children:e.value})]},e.label))})]})}function ie({model:e,onBack:n,onComplete:i,onLater:a}){let s=t(e=>e.language),[c,l]=C.useState(!1),[u,d]=C.useState(`idle`),[m,h]=C.useState(0),[g,_]=C.useState(o(s,`flow.install.wait`)),[y,b]=C.useState(null);async function x(){l(!0),b(null),d(`install`),h(8),_(o(s,`flow.install.prepare`));let t=await r.streamModelPrepare({model:e.loadId,engine:e.engine||`local_mlx`,allow_download:e.downloadRequired},{onProgress:e=>{let t=F(String(e.stage||``));d(t),h(Number(e.percent||I(t))),_(L(e,t,s))},onDone:()=>{d(`done`),h(100),_(o(s,`flow.install.done`))},onError:e=>{d(`error`),b(V(e))}});l(!1),t.ok?(d(`done`),h(100),_(o(s,`flow.install.done`)),window.setTimeout(i,700)):(d(`error`),b(V(t.data)))}let S=u===`download`?`thinking`:u===`validate`?`recalling`:u===`load`?`synthesizing`:u===`done`?`idle`:`listening`;return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`ritual-title`,children:o(s,e.downloadRequired?`flow.install.title`:`flow.install.title.ready`)}),(0,M.jsxs)(`div`,{className:`ritual-subtitle`,children:[(0,M.jsx)(`strong`,{children:e.shortName}),` — `,e.reason,`.`,(0,M.jsx)(`br`,{}),o(s,e.downloadRequired?`flow.install.body`:`flow.install.body.ready`)]}),(0,M.jsxs)(`section`,{className:`ritual-card ritual-expected-card`,"aria-label":o(s,`flow.install.expectedTitle`),children:[(0,M.jsx)(`div`,{className:`ritual-fact-label`,children:o(s,`flow.install.expectedTitle`)}),(0,M.jsx)(`div`,{className:`ritual-time-estimate ritual-expected-line`,children:N(e,s)}),(0,M.jsx)(`ol`,{className:`ritual-timeline`,children:P(e,s).map(e=>(0,M.jsxs)(`li`,{className:`ritual-timeline-step`,children:[(0,M.jsx)(`span`,{className:`ritual-timeline-name`,children:e.name}),(0,M.jsx)(`span`,{className:`ritual-timeline-time`,children:e.time})]},e.key))}),(0,M.jsx)(`div`,{className:`ritual-muted-hint`,children:o(s,`flow.install.expectedCompletion`)})]}),(0,M.jsx)(`div`,{className:`ritual-install-brain`,children:(0,M.jsx)(f,{state:S,intensity:u===`download`||u===`load`?.96:.82,size:`normal`})}),(0,M.jsx)(re,{model:e}),(0,M.jsxs)(`div`,{className:`ritual-progress`,children:[(0,M.jsx)(`div`,{className:`ritual-stage-list`,children:[`install`,`download`,`validate`,`load`].map(t=>(0,M.jsxs)(`div`,{className:`ritual-stage ${B(u,t)}`,children:[(0,M.jsx)(p,{className:`ritual-stage-icon`}),(0,M.jsx)(`span`,{children:R(t,s,e)})]},t))}),(0,M.jsx)(`div`,{className:`ritual-bar`,children:(0,M.jsx)(`span`,{className:`ritual-bar-fill ${z(m)}`})})]}),(0,M.jsx)(`div`,{className:`ritual-status`,children:g}),(0,M.jsx)(`div`,{className:`ritual-card ritual-status-card`,children:o(s,e.downloadRequired?`flow.install.note`:`flow.install.note.ready`)}),y&&(0,M.jsxs)(`div`,{className:`ritual-card ritual-error-card ritual-install-error`,role:`alert`,children:[y,(0,M.jsx)(`div`,{className:`ritual-error-detail`,children:o(s,`flow.install.retry`)})]}),(0,M.jsxs)(`div`,{className:`ritual-button-row`,children:[(0,M.jsx)(v,{variant:`ghost`,onClick:n,disabled:c,children:o(s,`flow.install.back`)}),(0,M.jsx)(v,{variant:`outline`,onClick:a,disabled:c,children:o(s,`flow.install.later`)}),u===`done`?(0,M.jsx)(v,{onClick:i,children:o(s,`flow.install.enter`)}):(0,M.jsx)(v,{onClick:x,disabled:c||!e.supported,children:c?o(s,`flow.install.busy`):o(s,e.downloadRequired?`flow.install.start`:`flow.install.startReady`)})]}),(0,M.jsx)(`div`,{className:`ritual-local-note`,children:o(s,e.downloadRequired?`flow.install.local`:`flow.install.local.ready`)})]})}function N(e,t){let n=e.estimatedFirstResponseSeconds;return!e.downloadRequired||e.estimatedDownloadMinutes===0?o(t,`flow.install.expected.ready`,{response:n}):e.estimatedDownloadMinutes===null?o(t,`flow.install.expected.unknown`,{response:n}):o(t,`flow.install.expected`,{download:o(t,`flow.recommend.minutes`,{count:e.estimatedDownloadMinutes}),response:n})}function P(e,t){let n=e.downloadRequired&&e.estimatedDownloadMinutes?o(t,`flow.install.timelineApprox`,{time:o(t,`flow.recommend.minutes`,{count:e.estimatedDownloadMinutes})}):o(t,`flow.install.timelineQuick`);return[{key:`download`,name:o(t,e.downloadRequired?`flow.install.timelineStep.download`:`flow.install.timelineStep.ready`),time:n},{key:`validate`,name:o(t,`flow.install.timelineStep.validate`),time:o(t,`flow.install.timelineQuick`)},{key:`load`,name:o(t,`flow.install.timelineStep.load`),time:o(t,`flow.install.timelineApprox`,{time:`${e.estimatedFirstResponseSeconds}s`})}]}function F(e){return/download|pull|weights/i.test(e)?`download`:/smoke|validate|verify|test/i.test(e)?`validate`:/load|ready/i.test(e)?`load`:/done|complete/i.test(e)?`done`:`install`}function I(e){return e===`install`?20:e===`download`?55:e===`validate`?82:e===`load`?94:e===`done`?100:8}function L(e,t,n){let r={install:o(n,`flow.install.prepare`),download:o(n,`flow.install.stage.download`),validate:o(n,`flow.install.stage.validate`),load:o(n,`flow.install.stage.load`),done:o(n,`flow.install.done`),idle:o(n,`flow.install.wait`),error:o(n,`flow.install.stage.error`)}[t];return H(String(e.user_message||e.message||r))}function R(e,t,n){return e===`download`&&!n.downloadRequired?o(t,`flow.install.step.ready`):o(t,`flow.install.step.${e}`)}function z(e){return`progress-${Math.max(0,Math.min(100,Math.round(e/10)*10))}`}function B(e,t){let n=[`idle`,`install`,`download`,`validate`,`load`,`done`],r=n.indexOf(e),i=n.indexOf(t);return e===`error`?`is-error`:e===`done`||r>i?`is-done`:e===t?`is-active`:``}function V(e){let t=j(e),n=c(t.recovery_guidance).map(H).filter(Boolean);return[H(String(t.user_message||t.reason||t.error||`The selected model could not be loaded.`)),...n.slice(0,2)].join(` `)}function H(e){return String(e||``).replace(/gemma4_unified/gi,`this model format`).replace(/mlx[-_ ]?vlm|mlx[-_ ]?lm|local_mlx|\bmlx\b|\bgguf\b|\bollama\b|huggingface|hugging face/gi,`local model support`).replace(/runtime/gi,`model support`).replace(/No module named ['\"][^'\"]+['\"]/gi,`A local support component is missing`).replace(/\s+/g,` `).trim()}function U(){let e=t(e=>e.language),n=t(e=>e.setLanguage);return(0,M.jsx)(`div`,{className:`language-switcher ritual-language`,"aria-label":o(e,`language.label`),children:[`ko`,`en`].map(t=>(0,M.jsx)(`button`,{type:`button`,className:e===t?`is-active`:``,onClick:()=>n(t),"aria-pressed":e===t,children:s[t]},t))})}var W=`lattice.productFlow.user`;function G(){try{let e=localStorage.getItem(W);return e?JSON.parse(e):null}catch{}return null}function K({onSuccess:e}){let n=t(e=>e.language),[i,a]=C.useState(()=>G()?.email||`you@local`),[s,c]=C.useState(``),[l,u]=C.useState(()=>G()?.name||`You`),[d,f]=C.useState(!1),[p,h]=C.useState(null);async function g(t){t.preventDefault();let a=i.trim(),c=s.trim(),u=l.trim()||a.split(`@`)[0]||`You`;if(!a||!c){h(o(n,`flow.login.missing`));return}f(!0),h(null);let d=G(),p=await r.login(a,c);if(!p.ok){if((await r.profile()).ok&&(!d?.email||d.email===a)){try{localStorage.setItem(W,JSON.stringify({email:a,name:u}))}catch{}f(!1),e();return}if(d?.email&&d.email!==a){f(!1),h(o(n,`flow.login.otherEmail`));return}if(d?.email===a){f(!1),h(o(n,`flow.login.wrongPassword`));return}(await r.register({email:a,password:c,name:u,nickname:u})).ok&&(p=await r.login(a,c))}if(!p.ok){f(!1),h(o(n,`flow.login.unavailable`));return}try{localStorage.setItem(W,JSON.stringify({email:a,name:u}))}catch{}f(!1),e()}return(0,M.jsxs)(`div`,{className:`ritual-login`,children:[(0,M.jsxs)(`header`,{children:[(0,M.jsx)(`h1`,{id:`login-title`,className:`ritual-title`,children:o(n,`flow.login.title`)}),(0,M.jsx)(`p`,{className:`ritual-subtitle`,children:o(n,`flow.login.body`)})]}),(0,M.jsx)(`div`,{className:`ritual-login-card`,children:(0,M.jsxs)(`form`,{onSubmit:g,className:`ritual-form`,"aria-labelledby":`login-title`,children:[(0,M.jsxs)(`div`,{className:`ritual-field-stack`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`label`,{htmlFor:`login-name`,className:`ritual-field-label`,children:o(n,`flow.name`)}),(0,M.jsx)(m,{id:`login-name`,value:l,onChange:e=>u(e.target.value),placeholder:o(n,`flow.name.placeholder`),autoComplete:`name`})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`label`,{htmlFor:`login-email`,className:`ritual-field-label`,children:o(n,`flow.email`)}),(0,M.jsx)(m,{id:`login-email`,value:i,onChange:e=>a(e.target.value),type:`email`,placeholder:o(n,`flow.email.placeholder`),autoComplete:`email`,required:!0,"aria-invalid":p?!0:void 0,"aria-describedby":p?`login-error`:void 0})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`label`,{htmlFor:`login-password`,className:`ritual-field-label`,children:o(n,`flow.password`)}),(0,M.jsx)(m,{id:`login-password`,value:s,onChange:e=>c(e.target.value),type:`password`,placeholder:o(n,`flow.password.placeholder`),autoComplete:`current-password`,required:!0,"aria-invalid":p?!0:void 0,"aria-describedby":p?`login-error`:void 0})]})]}),p&&(0,M.jsx)(`div`,{id:`login-error`,className:`ritual-error`,role:`alert`,children:p}),(0,M.jsx)(v,{type:`submit`,disabled:d||!i.trim()||!s.trim(),className:`ritual-full-button`,children:d?o(n,`flow.login.busy`):o(n,`flow.login.submit`)}),(0,M.jsxs)(`div`,{className:`ritual-login-footnotes`,children:[(0,M.jsx)(`div`,{className:`ritual-muted-hint`,children:o(n,`flow.login.passwordLocal`)}),(0,M.jsx)(`div`,{className:`ritual-note`,children:o(n,`flow.login.note`)})]})]})}),(0,M.jsx)(q,{})]})}function q(){let e=t(e=>e.language);return(0,M.jsxs)(`aside`,{className:`ritual-promise is-quiet`,"aria-label":o(e,`flow.promise.aria`),children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{children:o(e,`flow.promise.memory.k`)}),(0,M.jsx)(`strong`,{children:o(e,`flow.promise.memory.v`)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{children:o(e,`flow.promise.model.k`)}),(0,M.jsx)(`strong`,{children:o(e,`flow.promise.model.v`)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{children:o(e,`flow.promise.ownership.k`)}),(0,M.jsx)(`strong`,{children:o(e,`flow.promise.ownership.v`)})]})]})}function J({status:e,reason:n,recommendations:r,analysis:i,onBack:a,onRetry:s,onSkipModel:c,onSelect:l}){let f=t(e=>e.language);if(e===`loading`)return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`ritual-title`,children:o(f,`flow.recommend.title`)}),(0,M.jsx)(`div`,{className:`ritual-subtitle`,children:o(f,`flow.recommend.body`)}),(0,M.jsxs)(`div`,{className:`ritual-scan-banner is-loading`,role:`status`,children:[(0,M.jsx)(`span`,{className:`ritual-scan-dot pulsing`}),(0,M.jsx)(`span`,{children:o(f,`flow.recommend.loading`)})]}),(0,M.jsxs)(`div`,{className:`ritual-action-row`,children:[(0,M.jsx)(v,{variant:`ghost`,onClick:a,children:o(f,`flow.recommend.back`)}),(0,M.jsx)(v,{variant:`outline`,onClick:c,children:o(f,`flow.recommend.skip`)})]})]});if(e===`unavailable`){let e=n===`no_supported_model`?`flow.recommend.unavailable.empty`:`flow.recommend.unavailable.probe`;return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`ritual-title`,children:o(f,`flow.recommend.title`)}),(0,M.jsx)(`section`,{className:`ritual-card ritual-error-card ritual-unavailable-card`,role:`alert`,"aria-label":o(f,`flow.recommend.unavailable.aria`),children:(0,M.jsxs)(`div`,{className:`ritual-inline-row`,children:[(0,M.jsx)(g,{className:`ritual-core-icon`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`ritual-strong-text`,children:o(f,`flow.recommend.unavailable.title`)}),(0,M.jsx)(`div`,{className:`ritual-muted-text`,children:o(f,e)})]})]})}),(0,M.jsxs)(`div`,{className:`ritual-button-row ritual-button-row-primary`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`ritual-full-button ritual-full-button-primary`,onClick:s,children:[(0,M.jsx)(d,{size:16}),` `,o(f,`flow.recommend.unavailable.retry`)]}),(0,M.jsx)(`button`,{type:`button`,className:`ritual-secondary-button`,onClick:c,children:o(f,`flow.recommend.skip`)})]}),(0,M.jsxs)(`div`,{className:`ritual-action-row`,children:[(0,M.jsx)(v,{variant:`ghost`,onClick:a,children:o(f,`flow.recommend.back`)}),(0,M.jsx)(`div`,{className:`ritual-muted-hint`,children:o(f,`flow.recommend.unavailable.hint`)})]})]})}let p=r;function m(e,t){if(!e)return(0,M.jsxs)(`div`,{className:`ritual-scan-banner is-loading`,children:[(0,M.jsx)(`span`,{className:`ritual-scan-dot pulsing`}),(0,M.jsx)(`span`,{children:o(t,`flow.analysis.checking`)})]});let n=j(e.recommendations?.recommendations),r=j(e.setup?.environment),i=j(e.recommendations?.profile),a={...r,...i},s=Number(n.ram_gb||Number(a.ram_mb||0)/1024||0);return n.apple_silicon||String(a.arch||``).includes(`arm`)?(0,M.jsxs)(`div`,{className:`ritual-scan-banner is-success`,children:[(0,M.jsx)(`span`,{className:`ritual-scan-dot is-success`}),(0,M.jsx)(`span`,{children:o(t,`flow.recommend.environment.apple`,{ram:Math.round(s)})})]}):(0,M.jsxs)(`div`,{className:`ritual-scan-banner is-warning`,children:[(0,M.jsx)(`span`,{className:`ritual-scan-dot is-warning`}),(0,M.jsx)(`span`,{children:o(t,`flow.recommend.environment.standard`,{ram:Math.round(s)})})]})}return(0,M.jsxs)(`div`,{className:`ritual-recommend`,children:[(0,M.jsxs)(`header`,{children:[(0,M.jsx)(`h1`,{className:`ritual-title`,children:o(f,`flow.recommend.title`)}),(0,M.jsx)(`p`,{className:`ritual-subtitle`,children:o(f,`flow.recommend.body`)})]}),m(i,f),p[0]?(0,M.jsxs)(`section`,{className:`ritual-primary-hero-card`,"aria-labelledby":`recommend-primary-name`,children:[(0,M.jsxs)(`div`,{className:`ritual-hero-topline`,children:[(0,M.jsxs)(`span`,{className:`ritual-hero-rank`,children:[(0,M.jsx)(x,{size:16,"aria-hidden":`true`}),Q(p[0].role,0,f)]}),(0,M.jsx)(`span`,{className:`ritual-hero-size`,children:p[0].size||o(f,`flow.recommend.sizeReady`)})]}),(0,M.jsx)(`h2`,{id:`recommend-primary-name`,className:`ritual-hero-name`,children:p[0].shortName}),(0,M.jsxs)(`p`,{className:`ritual-hero-reason`,children:[p[0].reason,Z(p[0].role,f)?(0,M.jsxs)(`span`,{className:`ritual-model-comparison`,children:[` `,Z(p[0].role,f)]}):null]}),(0,M.jsxs)(`p`,{className:`ritual-hero-time`,children:[(0,M.jsx)(`span`,{className:`ritual-time-estimate`,children:X(p[0],f)}),(0,M.jsx)(`span`,{className:`ritual-time-note`,children:o(f,`flow.recommend.timeNote`)})]}),p[0].supported?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(v,{onClick:()=>l(p[0]),className:`ritual-primary-model-button`,children:[o(f,`flow.recommend.primary`),` `,(0,M.jsx)(u,{size:18,"aria-hidden":`true`})]}),(0,M.jsxs)(`p`,{className:`ritual-hero-next`,children:[ae(p[0],f),` · `,o(f,p[0].downloadRequired?`flow.recommend.nextHint`:`flow.recommend.nextHint.ready`)]})]}):(0,M.jsx)(`p`,{className:`ritual-model-warning`,children:o(f,`flow.recommend.unsupported`)})]}):null,p.length>1?(0,M.jsxs)(`section`,{className:`ritual-alternatives`,"aria-labelledby":`recommend-alternatives`,children:[(0,M.jsx)(`h2`,{id:`recommend-alternatives`,className:`ritual-alternatives-title`,children:o(f,`flow.recommend.alternatives`)}),(0,M.jsx)(`div`,{className:`ritual-alt-grid`,children:p.slice(1,3).map((e,t)=>{let n=e.role===`faster`?S:y;return(0,M.jsxs)(`button`,{type:`button`,className:`ritual-model-card is-compact`,onClick:()=>e.supported&&l(e),disabled:!e.supported,children:[(0,M.jsxs)(`span`,{className:`ritual-model-heading`,children:[(0,M.jsx)(n,{size:15,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`role`,children:Q(e.role,t+1,f)}),(0,M.jsx)(`span`,{className:`ritual-alt-size`,children:e.size||o(f,`flow.recommend.sizeReady`)})]}),(0,M.jsx)(`span`,{className:`name`,children:e.shortName}),(0,M.jsx)(`span`,{className:`reason`,children:e.reason}),(0,M.jsxs)(`span`,{className:`ritual-alt-footer`,children:[(0,M.jsx)(`span`,{className:`ritual-time-estimate`,children:X(e,f)}),e.supported?(0,M.jsxs)(`span`,{className:`ritual-model-choose`,children:[o(f,`flow.recommend.choose`),` `,(0,M.jsx)(u,{size:14,"aria-hidden":`true`})]}):(0,M.jsx)(`span`,{className:`ritual-model-warning`,children:o(f,`flow.recommend.unsupported`)})]})]},`${e.role}-${e.id}`)})})]}):null,(0,M.jsxs)(`footer`,{className:`ritual-action-row is-split`,children:[(0,M.jsx)(v,{variant:`ghost`,onClick:a,children:o(f,`flow.recommend.back`)}),(0,M.jsxs)(`span`,{className:`ritual-action-tail`,children:[(0,M.jsx)(`span`,{className:`ritual-muted-hint`,children:o(f,`flow.recommend.hint`)}),(0,M.jsx)(v,{variant:`outline`,onClick:c,children:o(f,`flow.recommend.skip`)})]})]})]})}function Y(e,t){return o(t,`flow.recommend.minutes`,{count:e})}function X(e,t){let n=e.estimatedFirstResponseSeconds;return!e.downloadRequired||e.estimatedDownloadMinutes===0?o(t,`flow.recommend.timeEstimate.ready`,{response:n}):e.estimatedDownloadMinutes===null?o(t,`flow.recommend.timeEstimate.unknown`,{response:n}):o(t,`flow.recommend.timeEstimate`,{download:Y(e.estimatedDownloadMinutes,t),response:n})}function ae(e,t){return!e.downloadRequired||e.estimatedDownloadMinutes===0?o(t,`flow.recommend.primaryNote.ready`):e.estimatedDownloadMinutes===null?o(t,`flow.recommend.primaryNote.unknown`):o(t,`flow.recommend.primaryNote`,{time:Y(e.estimatedDownloadMinutes,t)})}function Z(e,t){return e===`faster`?o(t,`flow.recommend.comparison.faster`):e===`advanced`?o(t,`flow.recommend.comparison.advanced`):``}function Q(e,t,n){return e===`best`?o(n,`flow.recommend.rank.best`):e===`faster`?o(n,`flow.recommend.rank.faster`):e===`advanced`?o(n,`flow.recommend.rank.advanced`):o(n,`flow.recommend.rank.choice`,{index:t+1})}function oe({onComplete:e}){let n=t(e=>e.language),[i,a]=C.useState(`wake`),[s,c]=C.useState(null),[l,u]=C.useState(null),[d,p]=C.useState(0),[m,h]=C.useState(null),g=C.useMemo(()=>w({analysis:s,endpoints:l}),[s,l]);C.useEffect(()=>{let e=!1;async function t(){let[t,n,i,a]=await Promise.all([r.setupScan(),r.modelRecommendations(`local_mlx`),r.models(),r.sysinfo()]);e||(c({setup:t.ok?t.data:null,recommendations:n.ok?n.data:null,models:i.ok?i.data:null,sysinfo:a.ok?a.data:null}),u({setup:t.ok,recommendations:n.ok,models:i.ok,sysinfo:a.ok}))}return t(),()=>{e=!0}},[d]);let _=C.useCallback(()=>{c(null),u(null),p(e=>e+1)},[]);return(0,M.jsx)(`div`,{className:`ritual-shell`,children:(0,M.jsxs)(`main`,{className:`ritual-container`,"aria-label":o(n,`flow.shell`),children:[(0,M.jsx)(U,{}),(0,M.jsxs)(`div`,{className:`ritual-brain`,children:[(0,M.jsx)(f,{state:ce(i),intensity:i===`install`?.92:.7,size:`large`,showLabel:!1}),(0,M.jsx)(`div`,{className:`ritual-edition`,title:o(n,`brain.edition.tip`),children:o(n,`brain.edition`)})]}),i===`wake`&&(0,M.jsx)(se,{onWake:()=>a(`login`),onUseExisting:()=>$(e)}),i===`login`&&(0,M.jsx)(K,{onSuccess:()=>a(`recommend`)}),i===`recommend`&&(0,M.jsx)(J,{status:g.status,reason:g.reason,recommendations:g.recommendations,analysis:s,onBack:()=>a(`login`),onRetry:_,onSkipModel:()=>$(e),onSelect:e=>{h(e),a(`install`)}}),i===`install`&&(0,M.jsx)(ie,{model:m||g.recommendations[0]||T(),onBack:()=>a(`recommend`),onComplete:()=>$(e),onLater:()=>$(e)})]})})}function se({onWake:e,onUseExisting:n}){let r=t(e=>e.language),i=[{icon:b,label:o(r,`flow.wake.value.local.k`),body:o(r,`flow.wake.value.local.v`)},{icon:S,label:o(r,`flow.wake.value.instant.k`),body:o(r,`flow.wake.value.instant.v`)},{icon:h,label:o(r,`flow.wake.value.brain.k`),body:o(r,`flow.wake.value.brain.v`)}];return(0,M.jsxs)(`section`,{className:`ritual-wake`,"aria-label":o(r,`flow.wake.aria`),children:[(0,M.jsx)(`div`,{className:`ritual-title`,children:o(r,`flow.wake.title`)}),(0,M.jsx)(`div`,{className:`ritual-subtitle`,children:o(r,`flow.wake.body`)}),(0,M.jsx)(`div`,{className:`ritual-value-grid`,"aria-label":o(r,`flow.wake.value.aria`),children:i.map(e=>{let t=e.icon;return(0,M.jsxs)(`div`,{className:`ritual-value-card`,children:[(0,M.jsxs)(`div`,{className:`ritual-value-label`,children:[(0,M.jsx)(t,{size:14}),` `,e.label]}),(0,M.jsx)(`div`,{className:`ritual-value-body`,children:e.body})]},e.label)})}),(0,M.jsxs)(`div`,{className:`ritual-wake-plan`,"aria-label":o(r,`flow.wake.plan.aria`),children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{children:`1`}),(0,M.jsx)(`strong`,{children:o(r,`flow.wake.step.identity`)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{children:`2`}),(0,M.jsx)(`strong`,{children:o(r,`flow.wake.step.check`)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{children:`3`}),(0,M.jsx)(`strong`,{children:o(r,`flow.wake.step.voice`)})]})]}),(0,M.jsxs)(`div`,{className:`ritual-button-row ritual-button-row-primary`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`ritual-full-button ritual-full-button-primary`,onClick:e,children:[o(r,`flow.wake.primary`),` `,(0,M.jsx)(u,{size:18})]}),(0,M.jsx)(`button`,{type:`button`,className:`ritual-secondary-button`,onClick:n,children:o(r,`flow.wake.existing`)})]}),(0,M.jsx)(`div`,{className:`ritual-start-note`,children:o(r,`flow.wake.startNote`)})]})}function $(e){_(),e()}function ce(e){return e===`wake`?`idle`:e===`analysis`?`listening`:e===`recommend`?`recalling`:e===`install`?`thinking`:`idle`}export{oe as ProductFlow};