forge-openclaw-plugin 0.2.102 → 0.2.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
- package/dist/assets/{ai-surface-workspace-xtB5RFQu.js → ai-surface-workspace-CutiG6uS.js} +1 -1
- package/dist/assets/{atlas-panel-B3dPHCmZ.js → atlas-panel-jgMRyaHn.js} +1 -1
- package/dist/assets/{board-DqHzdCPQ.js → board-dIX6etHh.js} +1 -1
- package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
- package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
- package/dist/assets/{calendar-week-toolbar-BZ_-X3Wb.js → calendar-week-toolbar-nVhgB-0s.js} +1 -1
- package/dist/assets/{charts-FcU0F3XV.js → charts-DFnEuIMB.js} +1 -1
- package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
- package/dist/assets/{daily-metrics-dashboard-BMyL0Qr4.js → daily-metrics-dashboard-CiJkkkd1.js} +1 -1
- package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
- package/dist/assets/{entity-notes-surface-CBylYDwy.js → entity-notes-surface-Djz50HvD.js} +1 -1
- package/dist/assets/execution-board-CtPhI-58.js +1 -0
- package/dist/assets/{faceted-token-search-D7xPWfOl.js → faceted-token-search-DEC6ANa9.js} +1 -1
- package/dist/assets/{flagship-signal-deck-BEFKOhvx.js → flagship-signal-deck-CtHC3mql.js} +1 -1
- package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
- package/dist/assets/{forms-CmLAyGqz.js → forms-hB0SqEh-.js} +1 -1
- package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
- package/dist/assets/goals-page-fsY8NzGB.js +1 -0
- package/dist/assets/{graph-BTa79qum.js → graph-DDUZNRsO.js} +1 -1
- package/dist/assets/habits-page-COoGz4kj.js +1 -0
- package/dist/assets/index-BAXYM89v.css +1 -0
- package/dist/assets/index-EqQsXoat.js +19 -0
- package/dist/assets/{insight-flow-dialog-BtIQXXsS.js → insight-flow-dialog-DtX_5W7g.js} +1 -1
- package/dist/assets/insights-page-cBd74ObU.js +8 -0
- package/dist/assets/kanban-page-CYav9THw.js +1 -0
- package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
- package/dist/assets/{life-force-page-BGDkKfbJ.js → life-force-page-CACGlNhq.js} +1 -1
- package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
- package/dist/assets/{maps-CF1RagUX.js → maps-C-yOWiDN.js} +1 -1
- package/dist/assets/{metric-tile-4iMd_WnJ.js → metric-tile-CMadwnGz.js} +1 -1
- package/dist/assets/{motion-CfdU2F35.js → motion-Lt5B1XuE.js} +1 -1
- package/dist/assets/movement-page-D5VqFd2q.js +1 -0
- package/dist/assets/{note-markdown-CsGQhQXF.js → note-markdown-BzK2Qlgr.js} +1 -1
- package/dist/assets/{note-tags-input-DdZi93tj.js → note-tags-input-CZzqJMLc.js} +1 -1
- package/dist/assets/notes-page-D3Hsh90C.js +1 -0
- package/dist/assets/{open-in-graph-button-C0TGev7c.js → open-in-graph-button-BFPKfyK3.js} +1 -1
- package/dist/assets/{orbit-map-DVXkfQdd.js → orbit-map-CnyfSmOG.js} +1 -1
- package/dist/assets/{overview-page-BwMlFQKX.js → overview-page-CXdWrOV1.js} +1 -1
- package/dist/assets/{page-hero-oFHaAjtL.js → page-hero-ffKzgyW3.js} +1 -1
- package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-DOKV9bZc.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
- package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
- package/dist/assets/project-collections-qSqp90HN.js +1 -0
- package/dist/assets/{project-detail-page-DogvVNEn.js → project-detail-page-BifhiLQX.js} +1 -1
- package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
- package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
- package/dist/assets/projects-page-ptcx6H38.js +1 -0
- package/dist/assets/{psyche-behaviors-page-BeVlXvbj.js → psyche-behaviors-page-BDwXyDta.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-CqAWCO4E.js → psyche-flashcards-page-DL1BP1jX.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-IyNnbk_W.js → psyche-goal-map-page-ovcpisx1.js} +1 -1
- package/dist/assets/{psyche-graph-IkUQRaDK.js → psyche-graph-EP5GL612.js} +1 -1
- package/dist/assets/{psyche-metrics-page-uai0a7Lx.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-C7p-ABiF.js → psyche-mode-guide-page-C0g27Xpt.js} +1 -1
- package/dist/assets/{psyche-modes-page-CLQ5V3w0.js → psyche-modes-page-BjKjX5MR.js} +1 -1
- package/dist/assets/{psyche-page-NQBHkkpU.js → psyche-page-F4tF2W70.js} +1 -1
- package/dist/assets/{psyche-patterns-page-BkRiNpI_.js → psyche-patterns-page-B-14hukK.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-Du-7HwPC.js → psyche-questionnaire-builder-page-BdXmoHvK.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-C5-yf8MF.js → psyche-questionnaire-detail-page-Cu5uwlJu.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-CoSH5O6R.js → psyche-questionnaire-run-detail-page-C3R4PClg.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-ChI7c1wy.js → psyche-questionnaire-run-page-Div3iDdt.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-xUcJJzbI.js → psyche-questionnaires-page-DpqAPQCp.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-BPrZCFZS.js → psyche-report-detail-page-BvWVDKP3.js} +1 -1
- package/dist/assets/{psyche-reports-page-D2EXJmm6.js → psyche-reports-page-BrbWUlAq.js} +1 -1
- package/dist/assets/{psyche-schemas-RcZYaokx.js → psyche-schemas-Dxj554nU.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-h0ooZ1lp.js → psyche-schemas-beliefs-page-DYKvAtSD.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-_3-4LikV.js → psyche-screen-time-page-CAOKCyQw.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-BdbCsgR5.js → psyche-self-observation-page-F0MVA0UH.js} +1 -1
- package/dist/assets/{psyche-values-page-DuUVki5e.js → psyche-values-page-DyvX-d0o.js} +1 -1
- package/dist/assets/{report-chain-fields-BBMz0sGI.js → report-chain-fields-CeC1cJFS.js} +1 -1
- package/dist/assets/rewards-page-C2loyODo.js +1 -0
- package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
- package/dist/assets/{schema-badge-D93RcG36.js → schema-badge-FY7818qB.js} +1 -1
- package/dist/assets/{select-menu-Cdq7foRu.js → select-menu-DJsCG6rM.js} +1 -1
- package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
- package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
- package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
- package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
- package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
- package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
- package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
- package/dist/assets/settings-page-1cArlSPM.js +1 -0
- package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
- package/dist/assets/{settings-section-nav-Dc4IeVBt.js → settings-section-nav-DP9o4peU.js} +1 -1
- package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
- package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
- package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
- package/dist/assets/sports-page-BldIiclr.js +1 -0
- package/dist/assets/{state-VYvD1QVP.js → state-vCcAT5Hq.js} +1 -1
- package/dist/assets/strategies-page-CaTN99qj.js +1 -0
- package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
- package/dist/assets/{strategy-dialog-DMyRKrWf.js → strategy-dialog-7X7peRzu.js} +1 -1
- package/dist/assets/{surface-Bfz_sLX6.js → surface-CJI17F3n.js} +1 -1
- package/dist/assets/{table-C0VTeqw0.js → table-BNqMG3_S.js} +1 -1
- package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
- package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
- package/dist/assets/today-page-BjDijtn8.js +1 -0
- package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
- package/dist/assets/{ui-CsEkP2V8.js → ui-C1iwpj2-.js} +1 -1
- package/dist/assets/{use-psyche-focus-target-qxT5Oy_z.js → use-psyche-focus-target-Ct-acS9G.js} +1 -1
- package/dist/assets/{vendor-kIz9EZnX.js → vendor-Dnkkx2co.js} +3 -3
- package/dist/assets/{vitals-page-Dz1Jt5H8.js → vitals-page-CE9zdGLF.js} +1 -1
- package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
- package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
- package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
- package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
- package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
- package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
- package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
- package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
- package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
- package/dist/assets/{workout-detail-page-DD9IGN6l.js → workout-detail-page-DT-c5cHL.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/server/src/app.js +22 -3
- package/dist/server/server/src/health-weight-loss.js +114 -39
- package/dist/server/server/src/repositories/model-settings.js +9 -3
- package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
- package/dist/server/src/lib/api.js +10 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/assets/activity-page-CgF7K2ww.js +0 -1
- package/dist/assets/calendar-page-C1Wfd2Fy.js +0 -1
- package/dist/assets/calendar-rules-CaZXtlxt.js +0 -1
- package/dist/assets/companion-sync-lab-page-NgeK-O-P.js +0 -1
- package/dist/assets/entity-note-count-link-BrS1-O0o.js +0 -1
- package/dist/assets/execution-board-CpO2ch6v.js +0 -1
- package/dist/assets/floating-action-menu-zzC2r0Ob.js +0 -1
- package/dist/assets/goal-detail-page-JK_Nva8e.js +0 -1
- package/dist/assets/goals-page-yeoJ06Vw.js +0 -1
- package/dist/assets/habits-page-Dx5EhkJi.js +0 -1
- package/dist/assets/index-BHIKoiZ6.js +0 -19
- package/dist/assets/index-H8R-ABM3.css +0 -1
- package/dist/assets/insights-page-CujrosD_.js +0 -8
- package/dist/assets/kanban-page-Q9NuIz5w.js +0 -1
- package/dist/assets/knowledge-graph-page-DaJmlvvM.js +0 -1
- package/dist/assets/life-force-workspace-CLVexVnb.js +0 -1
- package/dist/assets/movement-page-ClaoTNuX.js +0 -1
- package/dist/assets/notes-page-DYI8s3NN.js +0 -1
- package/dist/assets/pill-cluster-7UZd_lHp.js +0 -1
- package/dist/assets/preferences-page-BrKEkmfD.js +0 -1
- package/dist/assets/project-collections-CZagCmeH.js +0 -1
- package/dist/assets/project-management-hierarchy-page-Dr7hW9PW.js +0 -1
- package/dist/assets/project-management-section-nav-BLdAgTge.js +0 -1
- package/dist/assets/projects-page-UKrby_5-.js +0 -1
- package/dist/assets/rewards-page-PZFPa6rR.js +0 -1
- package/dist/assets/scheduling-rules-editor-B9KNKsQz.js +0 -1
- package/dist/assets/settings-agents-page-DPx2F6wf.js +0 -6
- package/dist/assets/settings-bin-page-COwP3gjo.js +0 -1
- package/dist/assets/settings-calendar-page-C-ghE0YT.js +0 -5
- package/dist/assets/settings-data-page-CBubzKBw.js +0 -1
- package/dist/assets/settings-logs-page-uOuXMeBm.js +0 -1
- package/dist/assets/settings-mobile-page-C5rfj8_r.js +0 -1
- package/dist/assets/settings-models-page-DijmUWdU.js +0 -1
- package/dist/assets/settings-page-B4u5TR5g.js +0 -1
- package/dist/assets/settings-rewards-page-COiTwkMH.js +0 -1
- package/dist/assets/settings-users-page-DEGa5DNn.js +0 -1
- package/dist/assets/settings-wiki-page-Cvsiz5_e.js +0 -1
- package/dist/assets/sleep-page-BnSOwkEU.js +0 -1
- package/dist/assets/sports-page-l1RqXzA_.js +0 -1
- package/dist/assets/strategies-page-DEnPlpAs.js +0 -1
- package/dist/assets/strategy-detail-page-Ls8bxKeH.js +0 -1
- package/dist/assets/task-detail-page-CgrYgQLD.js +0 -1
- package/dist/assets/timebox-planning-dialog-Ww0NGLLo.js +0 -1
- package/dist/assets/today-page-CIuFHMi1.js +0 -1
- package/dist/assets/training-load-page-BIwc648i.js +0 -1
- package/dist/assets/weekly-review-page-BFpBe1kI.js +0 -1
- package/dist/assets/weight-loss-page-BgMoBpBt.js +0 -5
- package/dist/assets/wiki-article-markdown-gsPTXTg1.js +0 -4
- package/dist/assets/wiki-editor-page-BpAZHooY.js +0 -26
- package/dist/assets/wiki-ingest-history-page-C-ig8O22.js +0 -1
- package/dist/assets/wiki-ingest-modal-BK4eQgqs.js +0 -1
- package/dist/assets/wiki-page-CMTZ60Zt.js +0 -1
- package/dist/assets/workbench-flow-page-BIpWUcLJ.js +0 -5
- package/dist/assets/workbench-page-CtCjYSRe.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as yr,o as Wt,p as la,q as sn,v as an,x as ha,y as vr,A as wr,r as D,j as A,B as he,C as br,D as fa}from"./vendor-kIz9EZnX.js";import{u as ga,c as pa,s as ue}from"./state-VYvD1QVP.js";const Ne={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},wt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],xr=["Enter"," ","Escape"],Er={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var qe;(function(e){e.Strict="strict",e.Loose="loose"})(qe||(qe={}));var Ue;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ue||(Ue={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const Sr={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Fe;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Fe||(Fe={}));var Ot;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ot||(Ot={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const ci={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function Cr(e){return e===null?null:e?"valid":"invalid"}const _r=e=>"id"in e&&"source"in e&&"target"in e,ma=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ct=(e,t=[0,0])=>{const{width:n,height:i}=De(e),r=e.origin??t,o=n*r[0],s=i*r[1];return{x:e.position.x-o,y:e.position.y-s}},ya=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,r)=>{const o=typeof r=="string";let s=!t.nodeLookup&&!o?r:void 0;t.nodeLookup&&(s=o?t.nodeLookup.get(r):Gn(r)?r:t.nodeLookup.get(r.id));const a=s?Ut(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Yt(i,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Xt(n)},_t=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=Yt(n,Ut(r)),i=!0)}),i?Xt(n):{x:0,y:0,width:0,height:0}},Fn=(e,t,[n,i,r]=[0,0,1],o=!1,s=!1)=>{const a={...At(t,[n,i,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:l,selectable:d=!0,hidden:h=!1}=u;if(s&&!d||h)continue;const f=l.width??u.width??u.initialWidth??null,g=l.height??u.height??u.initialHeight??null,y=xt(a,Je(u)),m=(f??0)*(g??0),v=o&&y>0;(!u.internals.handleBounds||v||y>=m||u.dragging)&&c.push(u)}return c},va=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function wa(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function ba({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:o},s){if(e.size===0)return Promise.resolve(!0);const a=wa(e,s),c=_t(a),u=$n(c,t,n,(s==null?void 0:s.minZoom)??r,(s==null?void 0:s.maxZoom)??o,(s==null?void 0:s.padding)??.1);return await i.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Nr({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:o}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},l=s.origin??i;let d=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)o==null||o("005",Ne.error005());else{const f=a.measured.width,g=a.measured.height;f&&g&&(d=[[c,u],[c+f,u+g]])}else a&&et(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const h=et(d)?He(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(o==null||o("015",Ne.error015())),{position:{x:h.x-c+(s.measured.width??0)*l[0],y:h.y-u+(s.measured.height??0)*l[1]},positionAbsolute:h}}async function xa({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const o=new Set(e.map(h=>h.id)),s=[];for(const h of n){if(h.deletable===!1)continue;const f=o.has(h.id),g=!f&&h.parentId&&s.find(y=>y.id===h.parentId);(f||g)&&s.push(h)}const a=new Set(t.map(h=>h.id)),c=i.filter(h=>h.deletable!==!1),l=va(s,c);for(const h of c)a.has(h.id)&&!l.find(g=>g.id===h.id)&&l.push(h);if(!r)return{edges:l,nodes:s};const d=await r({nodes:s,edges:l});return typeof d=="boolean"?d?{edges:l,nodes:s}:{edges:[],nodes:[]}:d}const Qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),He=(e={x:0,y:0},t,n)=>({x:Qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ar(e,t,n){const{width:i,height:r}=De(n),{x:o,y:s}=n.internals.positionAbsolute;return He(e,[[o,s],[o+i,s+r]],t)}const ui=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,Tr=(e,t,n=15,i=40)=>{const r=ui(e.x,i,t.width-i)*n,o=ui(e.y,i,t.height-i)*n;return[r,o]},Yt=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Cn=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),Xt=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),Je=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Gn(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Ut=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Gn(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},kr=(e,t)=>Xt(Yt(Cn(e),Cn(t))),xt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},di=e=>Ce(e.width)&&Ce(e.height)&&Ce(e.x)&&Ce(e.y),Ce=e=>!isNaN(e)&&isFinite(e),Ea=(e,t)=>{},Nt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),At=({x:e,y:t},[n,i,r],o=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-i)/r};return o?Nt(a,s):a},Ht=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function We(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sa(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=We(e,n),r=We(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=We(e.top??e.y??0,n),r=We(e.bottom??e.y??0,n),o=We(e.left??e.x??0,t),s=We(e.right??e.x??0,t);return{top:i,right:s,bottom:r,left:o,x:o+s,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ca(e,t,n,i,r,o){const{x:s,y:a}=Ht(e,[t,n,i]),{x:c,y:u}=Ht({x:e.x+e.width,y:e.y+e.height},[t,n,i]),l=r-c,d=o-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(l),bottom:Math.floor(d)}}const $n=(e,t,n,i,r,o)=>{const s=Sa(o,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),l=Qe(u,i,r),d=e.x+e.width/2,h=e.y+e.height/2,f=t/2-d*l,g=n/2-h*l,y=Ca(e,f,g,l,t,n),m={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:f-m.left+m.right,y:g-m.top+m.bottom,zoom:l}},Et=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!=null&&e!=="parent"}function De(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Rr(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Dr(e,t={width:0,height:0},n,i,r){const o={...e},s=i.get(n);if(s){const a=s.origin||r;o.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],o.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return o}function li(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function _a(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function Na(e){return{...Er,...e||{}}}function yt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:o,y:s}=_e(e),a=At({x:o-((r==null?void 0:r.left)??0),y:s-((r==null?void 0:r.top)??0)},i),{x:c,y:u}=n?Nt(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const zn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Lr=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Aa=["INPUT","SELECT","TEXTAREA"];function Mr(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Aa.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Pr=e=>"clientX"in e,_e=(e,t)=>{var o,s;const n=Pr(e),i=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,r=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},hi=(e,t,n,i,r)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/i,y:(a.top-n.top)/i,...zn(s)}})};function Ir({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:o,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,u=t*.125+o*.375+a*.375+i*.125,l=Math.abs(c-e),d=Math.abs(u-t);return[c,u,l,d]}function Dt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fi({pos:e,x1:t,y1:n,x2:i,y2:r,c:o}){switch(e){case Y.Left:return[t-Dt(t-i,o),n];case Y.Right:return[t+Dt(i-t,o),n];case Y.Top:return[t,n-Dt(n-r,o)];case Y.Bottom:return[t,n+Dt(r-n,o)]}}function Gr({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top,curvature:s=.25}){const[a,c]=fi({pos:n,x1:e,y1:t,x2:i,y2:r,c:s}),[u,l]=fi({pos:o,x1:i,y1:r,x2:e,y2:t,c:s}),[d,h,f,g]=Ir({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:l});return[`M${e},${t} C${a},${c} ${u},${l} ${i},${r}`,d,h,f,g]}function Fr({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,o=n<e?n+r:n-r,s=Math.abs(i-t)/2,a=i<t?i+s:i-s;return[o,a,r,s]}function Ta({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const s=r&&n?i+1e3:i,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function ka({sourceNode:e,targetNode:t,width:n,height:i,transform:r}){const o=Yt(Ut(e),Ut(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:i/r[2]};return xt(s,Xt(o))>0}const Ra=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,Da=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),La=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||Ra;let r;return _r(e)?r={...e}:r={...e,id:i(e)},Da(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function $r({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,o,s,a]=Fr({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,o,s,a]}const gi={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},Ma=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},pi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Pa({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:i=Y.Top,center:r,offset:o,stepPosition:s}){const a=gi[t],c=gi[i],u={x:e.x+a.x*o,y:e.y+a.y*o},l={x:n.x+c.x*o,y:n.y+c.y*o},d=Ma({source:u,sourcePosition:t,target:l}),h=d.x!==0?"x":"y",f=d[h];let g=[],y,m;const v={x:0,y:0},w={x:0,y:0},[,,p,b]=Fr({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[h]*c[h]===-1){h==="x"?(y=r.x??u.x+(l.x-u.x)*s,m=r.y??(u.y+l.y)/2):(y=r.x??(u.x+l.x)/2,m=r.y??u.y+(l.y-u.y)*s);const k=[{x:y,y:u.y},{x:y,y:l.y}],N=[{x:u.x,y:m},{x:l.x,y:m}];a[h]===f?g=h==="x"?k:N:g=h==="x"?N:k}else{const k=[{x:u.x,y:l.y}],N=[{x:l.x,y:u.y}];if(h==="x"?g=a.x===f?N:k:g=a.y===f?k:N,t===i){const M=Math.abs(e[h]-n[h]);if(M<=o){const P=Math.min(o-1,o-M);a[h]===f?v[h]=(u[h]>e[h]?-1:1)*P:w[h]=(l[h]>n[h]?-1:1)*P}}if(t!==i){const M=h==="x"?"y":"x",P=a[h]===c[M],B=u[M]>l[M],$=u[M]<l[M];(a[h]===1&&(!P&&B||P&&$)||a[h]!==1&&(!P&&$||P&&B))&&(g=h==="x"?k:N)}const G={x:u.x+v.x,y:u.y+v.y},E={x:l.x+w.x,y:l.y+w.y},_=Math.max(Math.abs(G.x-g[0].x),Math.abs(E.x-g[0].x)),I=Math.max(Math.abs(G.y-g[0].y),Math.abs(E.y-g[0].y));_>=I?(y=(G.x+E.x)/2,m=g[0].y):(y=g[0].x,m=(G.y+E.y)/2)}const S={x:u.x+v.x,y:u.y+v.y},x={x:l.x+w.x,y:l.y+w.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...x.x!==g[g.length-1].x||x.y!==g[g.length-1].y?[x]:[],n],y,m,p,b]}function Ia(e,t,n,i){const r=Math.min(pi(e,t)/2,pi(t,n)/2,i),{x:o,y:s}=t;if(e.x===o&&o===n.x||e.y===s&&s===n.y)return`L${o} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,l=e.y<n.y?1:-1;return`L ${o+r*u},${s}Q ${o},${s} ${o},${s+r*l}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${s+r*c}Q ${o},${s} ${o+r*a},${s}`}function _n({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:l=.5}){const[d,h,f,g,y]=Pa({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:r},targetPosition:o,center:{x:a,y:c},offset:u,stepPosition:l});let m=`M${d[0].x} ${d[0].y}`;for(let v=1;v<d.length-1;v++)m+=Ia(d[v-1],d[v],d[v+1],s);return m+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[m,h,f,g,y]}function mi(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ga(e){var d;const{sourceNode:t,targetNode:n}=e;if(!mi(t)||!mi(n))return null;const i=t.internals.handleBounds||yi(t.handles),r=n.internals.handleBounds||yi(n.handles),o=vi((i==null?void 0:i.source)??[],e.sourceHandle),s=vi(e.connectionMode===qe.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!o||!s)return(d=e.onError)==null||d.call(e,"008",Ne.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(o==null?void 0:o.position)||Y.Bottom,c=(s==null?void 0:s.position)||Y.Top,u=je(t,o,a),l=je(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:l.x,targetY:l.y,sourcePosition:a,targetPosition:c}}function yi(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function je(e,t,n=Y.Left,i=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??De(e);if(i)return{x:r+s/2,y:o+a/2};switch((t==null?void 0:t.position)??n){case Y.Top:return{x:r+s/2,y:o};case Y.Right:return{x:r+s,y:o+a/2};case Y.Bottom:return{x:r+s/2,y:o+a};case Y.Left:return{x:r,y:o+a/2}}}function vi(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Nn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function Fa(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const o=new Set;return e.reduce((s,a)=>([a.markerStart||i,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=Nn(c,t);o.has(u)||(s.push({id:u,color:c.color||n,...c}),o.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const zr=1e3,$a=10,Bn={nodeOrigin:[0,0],nodeExtent:wt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},za={...Bn,checkEquality:!0};function On(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function Ba(e,t,n){const i=On(Bn,n);for(const r of e.values())if(r.parentId)Hn(r,e,t,i);else{const o=Ct(r,i.nodeOrigin),s=et(r.extent)?r.extent:i.nodeExtent,a=He(o,s,De(r));r.internals.positionAbsolute=a}}function Oa(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const o={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(o):r.type==="target"&&i.push(o)}return{source:n,target:i}}function Un(e){return e==="manual"}function An(e,t,n,i={}){var l,d;const r=On(za,i),o={i:0},s=new Map(t),a=r!=null&&r.elevateNodesOnSelect&&!Un(r.zIndexMode)?zr:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let f=s.get(h.id);if(r.checkEquality&&h===(f==null?void 0:f.internals.userNode))t.set(h.id,f);else{const g=Ct(h,r.nodeOrigin),y=et(h.extent)?h.extent:r.nodeExtent,m=He(g,y,De(h));f={...r.defaults,...h,measured:{width:(l=h.measured)==null?void 0:l.width,height:(d=h.measured)==null?void 0:d.height},internals:{positionAbsolute:m,handleBounds:Oa(h,f),z:Br(h,a,r.zIndexMode),userNode:h}},t.set(h.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),h.parentId&&Hn(f,t,n,i,o),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function Ua(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Hn(e,t,n,i,r){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=On(Bn,i),u=e.parentId,l=t.get(u);if(!l){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ua(e,n),r&&!l.parentId&&l.internals.rootParentIndex===void 0&&c==="auto"&&(l.internals.rootParentIndex=++r.i,l.internals.z=l.internals.z+r.i*$a),r&&l.internals.rootParentIndex!==void 0&&(r.i=l.internals.rootParentIndex);const d=o&&!Un(c)?zr:0,{x:h,y:f,z:g}=Ha(e,l,s,a,d,c),{positionAbsolute:y}=e.internals,m=h!==y.x||f!==y.y;(m||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:m?{x:h,y:f}:y,z:g}})}function Br(e,t,n){const i=Ce(e.zIndex)?e.zIndex:0;return Un(n)?i:i+(e.selected?t:0)}function Ha(e,t,n,i,r,o){const{x:s,y:a}=t.internals.positionAbsolute,c=De(e),u=Ct(e,n),l=et(e.extent)?He(u,e.extent,c):u;let d=He({x:s+l.x,y:a+l.y},i,c);e.extent==="parent"&&(d=Ar(d,c,t));const h=Br(e,r,o),f=t.internals.z??0;return{x:d.x,y:d.y,z:f>=h?f+1:h}}function jn(e,t,n,i=[0,0]){var s;const r=[],o=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=((s=o.get(a.parentId))==null?void 0:s.expandedRect)??Je(c),l=kr(u,a.rect);o.set(a.parentId,{expandedRect:l,parent:c})}return o.size>0&&o.forEach(({expandedRect:a,parent:c},u)=>{var p;const l=c.internals.positionAbsolute,d=De(c),h=c.origin??i,f=a.x<l.x?Math.round(Math.abs(l.x-a.x)):0,g=a.y<l.y?Math.round(Math.abs(l.y-a.y)):0,y=Math.max(d.width,Math.round(a.width)),m=Math.max(d.height,Math.round(a.height)),v=(y-d.width)*h[0],w=(m-d.height)*h[1];(f>0||g>0||v||w)&&(r.push({id:u,type:"position",position:{x:c.position.x-f+v,y:c.position.y-g+w}}),(p=n.get(u))==null||p.forEach(b=>{e.some(S=>S.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+g}})})),(d.width<a.width||d.height<a.height||f||g)&&r.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:y+(f?h[0]*f-v:0),height:m+(g?h[1]*g-w:0)}})}),r}function ja(e,t,n,i,r,o,s){const a=i==null?void 0:i.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const u=[],l=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(l.transform),h=[];for(const f of e.values()){const g=t.get(f.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const y=zn(f.nodeElement),m=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(m||!g.internals.handleBounds||f.force))){const w=f.nodeElement.getBoundingClientRect(),p=et(g.extent)?g.extent:o;let{positionAbsolute:b}=g.internals;g.parentId&&g.extent==="parent"?b=Ar(b,y,t.get(g.parentId)):p&&(b=He(b,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:b,handleBounds:{source:hi("source",f.nodeElement,w,d,g.id),target:hi("target",f.nodeElement,w,d,g.id)}}};t.set(g.id,S),g.parentId&&Hn(S,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,m&&(u.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&h.push({id:g.id,parentId:g.parentId,rect:Je(S,r)}))}}if(h.length>0){const f=jn(h,t,n,r);u.push(...f)}return{changes:u,updatedInternals:c}}async function Va({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,o]],i),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function wi(e,t,n,i,r,o){let s=r;const a=i.get(s)||new Map;i.set(s,a.set(n,t)),s=`${r}-${e}`;const c=i.get(s)||new Map;if(i.set(s,c.set(n,t)),o){s=`${r}-${e}-${o}`;const u=i.get(s)||new Map;i.set(s,u.set(n,t))}}function Or(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:o,sourceHandle:s=null,targetHandle:a=null}=i,c={edgeId:i.id,source:r,target:o,sourceHandle:s,targetHandle:a},u=`${r}-${s}--${o}-${a}`,l=`${o}-${a}--${r}-${s}`;wi("source",c,l,e,r,s),wi("target",c,u,e,o,a),t.set(i.id,i)}}function Ur(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ur(n,t):!1}function bi(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function Wa(e,t,n,i){const r=new Map;for(const[o,s]of e)if((s.selected||s.id===i)&&(!s.parentId||!Ur(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(o);a&&r.set(o,{id:o,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function cn({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var s,a,c;const r=[];for(const[u,l]of t){const d=(s=n.get(u))==null?void 0:s.internals.userNode;d&&r.push({...d,position:l.position,dragging:i})}if(!e)return[r[0],r];const o=(a=n.get(e))==null?void 0:a.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:i}:r[0],r]}function Ya({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const o={x:n-r.distance.x,y:i-r.distance.y},s=Nt(o,t);return{x:s.x-o.x,y:s.y-o.y}}function Xa({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let o={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},l=null,d=!1,h=null,f=!1,g=!1,y=null;function m({noDragClassName:w,handleSelector:p,domNode:b,isSelectable:S,nodeId:x,nodeClickDistance:C=0}){h=Wt(b);function k({x:_,y:I}){const{nodeLookup:M,nodeExtent:P,snapGrid:B,snapToGrid:$,nodeOrigin:R,onNodeDrag:T,onSelectionDrag:U,onError:z,updateNodePositions:F}=t();o={x:_,y:I};let V=!1;const q=a.size>1,J=q&&P?Cn(_t(a)):null,te=q&&$?Ya({dragItems:a,snapGrid:B,x:_,y:I}):null;for(const[ne,j]of a){if(!M.has(ne))continue;let Q={x:_-j.distance.x,y:I-j.distance.y};$&&(Q=te?{x:Math.round(Q.x+te.x),y:Math.round(Q.y+te.y)}:Nt(Q,B));let ie=null;if(q&&P&&!j.extent&&J){const{positionAbsolute:Z}=j.internals,se=Z.x-J.x+P[0][0],ce=Z.x+j.measured.width-J.x2+P[1][0],oe=Z.y-J.y+P[0][1],ge=Z.y+j.measured.height-J.y2+P[1][1];ie=[[se,oe],[ce,ge]]}const{position:ee,positionAbsolute:K}=Nr({nodeId:ne,nextPosition:Q,nodeLookup:M,nodeExtent:ie||P,nodeOrigin:R,onError:z});V=V||j.position.x!==ee.x||j.position.y!==ee.y,j.position=ee,j.internals.positionAbsolute=K}if(g=g||V,!!V&&(F(a,!0),y&&(i||T||!x&&U))){const[ne,j]=cn({nodeId:x,dragItems:a,nodeLookup:M});i==null||i(y,a,ne,j),T==null||T(y,ne,j),x||U==null||U(y,j)}}async function N(){if(!l)return;const{transform:_,panBy:I,autoPanSpeed:M,autoPanOnNodeDrag:P}=t();if(!P){c=!1,cancelAnimationFrame(s);return}const[B,$]=Tr(u,l,M);(B!==0||$!==0)&&(o.x=(o.x??0)-B/_[2],o.y=(o.y??0)-$/_[2],await I({x:B,y:$})&&k(o)),s=requestAnimationFrame(N)}function G(_){var q;const{nodeLookup:I,multiSelectionActive:M,nodesDraggable:P,transform:B,snapGrid:$,snapToGrid:R,selectNodesOnDrag:T,onNodeDragStart:U,onSelectionDragStart:z,unselectNodesAndEdges:F}=t();d=!0,(!T||!S)&&!M&&x&&((q=I.get(x))!=null&&q.selected||F()),S&&T&&x&&(e==null||e(x));const V=yt(_.sourceEvent,{transform:B,snapGrid:$,snapToGrid:R,containerBounds:l});if(o=V,a=Wa(I,P,V,x),a.size>0&&(n||U||!x&&z)){const[J,te]=cn({nodeId:x,dragItems:a,nodeLookup:I});n==null||n(_.sourceEvent,a,J,te),U==null||U(_.sourceEvent,J,te),x||z==null||z(_.sourceEvent,te)}}const E=vr().clickDistance(C).on("start",_=>{const{domNode:I,nodeDragThreshold:M,transform:P,snapGrid:B,snapToGrid:$}=t();l=(I==null?void 0:I.getBoundingClientRect())||null,f=!1,g=!1,y=_.sourceEvent,M===0&&G(_),o=yt(_.sourceEvent,{transform:P,snapGrid:B,snapToGrid:$,containerBounds:l}),u=_e(_.sourceEvent,l)}).on("drag",_=>{const{autoPanOnNodeDrag:I,transform:M,snapGrid:P,snapToGrid:B,nodeDragThreshold:$,nodeLookup:R}=t(),T=yt(_.sourceEvent,{transform:M,snapGrid:P,snapToGrid:B,containerBounds:l});if(y=_.sourceEvent,(_.sourceEvent.type==="touchmove"&&_.sourceEvent.touches.length>1||x&&!R.has(x))&&(f=!0),!f){if(!c&&I&&d&&(c=!0,N()),!d){const U=_e(_.sourceEvent,l),z=U.x-u.x,F=U.y-u.y;Math.sqrt(z*z+F*F)>$&&G(_)}(o.x!==T.xSnapped||o.y!==T.ySnapped)&&a&&d&&(u=_e(_.sourceEvent,l),k(T))}}).on("end",_=>{if(!(!d||f)&&(c=!1,d=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:I,updateNodePositions:M,onNodeDragStop:P,onSelectionDragStop:B}=t();if(g&&(M(a,!1),g=!1),r||P||!x&&B){const[$,R]=cn({nodeId:x,dragItems:a,nodeLookup:I,dragging:!1});r==null||r(_.sourceEvent,a,$,R),P==null||P(_.sourceEvent,$,R),x||B==null||B(_.sourceEvent,R)}}}).filter(_=>{const I=_.target;return!_.button&&(!w||!bi(I,`.${w}`,b))&&(!p||bi(I,p,b))});h.call(E)}function v(){h==null||h.on(".drag",null)}return{update:m,destroy:v}}function Za(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())xt(r,Je(o))>0&&i.push(o);return i}const Ka=250;function qa(e,t,n,i){var a,c;let r=[],o=1/0;const s=Za(e,n,t+Ka);for(const u of s){const l=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of l){if(i.nodeId===d.nodeId&&i.type===d.type&&i.id===d.id)continue;const{x:h,y:f}=je(u,d,d.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(f-e.y,2));g>t||(g<o?(r=[{...d,x:h,y:f}],o=g):g===o&&r.push({...d,x:h,y:f}))}}if(!r.length)return null;if(r.length>1){const u=i.type==="source"?"target":"source";return r.find(l=>l.type===u)??r[0]}return r[0]}function Hr(e,t,n,i,r,o=!1){var u,l,d;const s=i.get(e);if(!s)return null;const a=r==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((l=s.internals.handleBounds)==null?void 0:l.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(h=>h.id===n):a==null?void 0:a[0])??null;return c&&o?{...c,...je(s,c,c.position,!0)}:c}function jr(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Qa(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Vr=()=>!0;function Ja(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:l,flowId:d,panBy:h,cancelConnection:f,onConnectStart:g,onConnect:y,onConnectEnd:m,isValidConnection:v=Vr,onReconnectEnd:w,updateConnection:p,getTransform:b,getFromHandle:S,autoPanSpeed:x,dragThreshold:C=1,handleDomNode:k}){const N=Lr(e.target);let G=0,E;const{x:_,y:I}=_e(e),M=jr(o,k),P=a==null?void 0:a.getBoundingClientRect();let B=!1;if(!P||!M)return;const $=Hr(r,M,i,c,t);if(!$)return;let R=_e(e,P),T=!1,U=null,z=!1,F=null;function V(){if(!l||!P)return;const[ee,K]=Tr(R,P,x);h({x:ee,y:K}),G=requestAnimationFrame(V)}const q={...$,nodeId:r,type:M,position:$.position},J=c.get(r);let ne={inProgress:!0,isValid:null,from:je(J,q,Y.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:J,to:R,toHandle:null,toPosition:ci[q.position],toNode:null,pointer:R};function j(){B=!0,p(ne),g==null||g(e,{nodeId:r,handleId:i,handleType:M})}C===0&&j();function Q(ee){if(!B){const{x:ge,y:Me}=_e(ee),Ae=ge-_,ze=Me-I;if(!(Ae*Ae+ze*ze>C*C))return;j()}if(!S()||!q){ie(ee);return}const K=b();R=_e(ee,P),E=qa(At(R,K,!1,[1,1]),n,c,q),T||(V(),T=!0);const Z=Wr(ee,{handle:E,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:s?"target":"source",isValidConnection:v,doc:N,lib:u,flowId:d,nodeLookup:c});F=Z.handleDomNode,U=Z.connection,z=Qa(!!E,Z.isValid);const se=c.get(r),ce=se?je(se,q,Y.Left,!0):ne.from,oe={...ne,from:ce,isValid:z,to:Z.toHandle&&z?Ht({x:Z.toHandle.x,y:Z.toHandle.y},K):R,toHandle:Z.toHandle,toPosition:z&&Z.toHandle?Z.toHandle.position:ci[q.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:R};p(oe),ne=oe}function ie(ee){if(!("touches"in ee&&ee.touches.length>0)){if(B){(E||F)&&U&&z&&(y==null||y(U));const{inProgress:K,...Z}=ne,se={...Z,toPosition:ne.toHandle?ne.toPosition:null};m==null||m(ee,se),o&&(w==null||w(ee,se))}f(),cancelAnimationFrame(G),T=!1,z=!1,U=null,F=null,N.removeEventListener("mousemove",Q),N.removeEventListener("mouseup",ie),N.removeEventListener("touchmove",Q),N.removeEventListener("touchend",ie)}}N.addEventListener("mousemove",Q),N.addEventListener("mouseup",ie),N.addEventListener("touchmove",Q),N.addEventListener("touchend",ie)}function Wr(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:o,doc:s,lib:a,flowId:c,isValidConnection:u=Vr,nodeLookup:l}){const d=o==="target",h=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:f,y:g}=_e(e),y=s.elementFromPoint(f,g),m=y!=null&&y.classList.contains(`${a}-flow__handle`)?y:h,v={handleDomNode:m,isValid:!1,connection:null,toHandle:null};if(m){const w=jr(void 0,m),p=m.getAttribute("data-nodeid"),b=m.getAttribute("data-handleid"),S=m.classList.contains("connectable"),x=m.classList.contains("connectableend");if(!p||!w)return v;const C={source:d?p:i,sourceHandle:d?b:r,target:d?i:p,targetHandle:d?r:b};v.connection=C;const N=S&&x&&(n===qe.Strict?d&&w==="source"||!d&&w==="target":p!==i||b!==r);v.isValid=N&&u(C),v.toHandle=Hr(p,w,b,l,n,!0)}return v}const Tn={onPointerDown:Ja,isValid:Wr};function ec({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=Wt(e);function o({translateExtent:a,width:c,height:u,zoomStep:l=1,pannable:d=!0,zoomable:h=!0,inversePan:f=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const b=n(),S=p.sourceEvent.ctrlKey&&Et()?10:1,x=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*l,C=b[2]*Math.pow(2,x*S);t.scaleTo(C)};let y=[0,0];const m=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},v=p=>{const b=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],x=[S[0]-y[0],S[1]-y[1]];y=S;const C=i()*Math.max(b[2],Math.log(b[2]))*(f?-1:1),k={x:b[0]-x[0]*C,y:b[1]-x[1]*C},N=[[0,0],[c,u]];t.setViewportConstrained({x:k.x,y:k.y,zoom:b[2]},N,a)},w=yr().on("start",m).on("zoom",d?v:null).on("zoom.wheel",h?g:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:o,destroy:s,pointer:wr}}const Zt=e=>({x:e.x,y:e.y,zoom:e.k}),un=({x:e,y:t,zoom:n})=>la.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),Yr=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),tc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,dn=(e,t=0,n=tc,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},Xr=e=>{const t=e.ctrlKey&&Et()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return l=>{if(Xe(l,t))return l.ctrlKey&&l.preventDefault(),!1;l.preventDefault(),l.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(l.ctrlKey&&s){const m=wr(l),v=Xr(l),w=d*Math.pow(2,v);i.scaleTo(n,w,m,l);return}const h=l.deltaMode===1?20:1;let f=r===Ue.Vertical?0:l.deltaX*h,g=r===Ue.Horizontal?0:l.deltaY*h;!Et()&&l.shiftKey&&r!==Ue.Vertical&&(f=l.deltaY*h,g=0),i.translateBy(n,-(f/d)*o,-(g/d)*o,{internal:!0});const y=Zt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(l,y),e.panScrollTimeout=setTimeout(()=>{u==null||u(l,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(l,y))}}function ic({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const o=i.type==="wheel",s=!t&&o&&!i.ctrlKey,a=Xe(i,e);if(i.ctrlKey&&o&&a&&i.preventDefault(),s||a)return null;i.preventDefault(),n.call(this,i,r)}}function rc({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var o,s,a;if((o=i.sourceEvent)!=null&&o.internal)return;const r=Zt(i.transform);e.mouseButton=((s=i.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((a=i.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function oc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return o=>{var s,a;e.usedRightMouseButton=!!(n&&Yr(t,e.mouseButton??0)),(s=o.sourceEvent)!=null&&s.sync||i([o.transform.x,o.transform.y,o.transform.k]),r&&!((a=o.sourceEvent)!=null&&a.internal)&&(r==null||r(o.sourceEvent,Zt(o.transform)))}}function sc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:o}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,o&&Yr(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&o(s.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const c=Zt(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(s.sourceEvent,c)},n?150:0)}}}function ac({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:r,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:u,connectionInProgress:l}){return d=>{var m;const h=e||t,f=n&&d.ctrlKey,g=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${u}-flow__node`)||Xe(d,`${u}-flow__edge`)))return!0;if(!i&&!h&&!r&&!o&&!n||s||l&&!g||Xe(d,a)&&g||Xe(d,c)&&(!g||r&&g&&!e)||!n&&d.ctrlKey&&g)return!1;if(!n&&d.type==="touchstart"&&((m=d.touches)==null?void 0:m.length)>1)return d.preventDefault(),!1;if(!h&&!r&&!f&&g||!i&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(i)&&!i.includes(d.button)&&d.type==="mousedown")return!1;const y=Array.isArray(i)&&i.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||g)&&y}}function cc({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:o,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},l=e.getBoundingClientRect(),d=yr().scaleExtent([t,n]).translateExtent(i),h=Wt(e).call(d);w({x:r.x,y:r.y,zoom:Qe(r.zoom,t,n)},[[0,0],[l.width,l.height]],i);const f=h.on("wheel.zoom"),g=h.on("dblclick.zoom");d.wheelDelta(Xr);function y(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).transform(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function m({noWheelClassName:E,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:P,panOnDrag:B,panOnScrollMode:$,panOnScrollSpeed:R,preventScrolling:T,zoomOnPinch:U,zoomOnScroll:z,zoomOnDoubleClick:F,zoomActivationKeyPressed:V,lib:q,onTransformChange:J,connectionInProgress:te,paneClickDistance:ne,selectionOnDrag:j}){M&&!u.isZoomingOrPanning&&v();const Q=P&&!V&&!M;d.clickDistance(j?1/0:!Ce(ne)||ne<0?0:ne);const ie=Q?nc({zoomPanValues:u,noWheelClassName:E,d3Selection:h,d3Zoom:d,panOnScrollMode:$,panOnScrollSpeed:R,zoomOnPinch:U,onPanZoomStart:s,onPanZoom:o,onPanZoomEnd:a}):ic({noWheelClassName:E,preventScrolling:T,d3ZoomHandler:f});if(h.on("wheel.zoom",ie,{passive:!1}),!M){const K=rc({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});d.on("start",K);const Z=oc({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!I,onPanZoom:o,onTransformChange:J});d.on("zoom",Z);const se=sc({zoomPanValues:u,panOnDrag:B,panOnScroll:P,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});d.on("end",se)}const ee=ac({zoomActivationKeyPressed:V,panOnDrag:B,zoomOnScroll:z,panOnScroll:P,zoomOnDoubleClick:F,zoomOnPinch:U,userSelectionActive:M,noPanClassName:_,noWheelClassName:E,lib:q,connectionInProgress:te});d.filter(ee),F?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function v(){d.on("zoom",null)}async function w(E,_,I){const M=un(E),P=d==null?void 0:d.constrain()(M,_,I);return P&&await y(P),new Promise(B=>B(P))}async function p(E,_){const I=un(E);return await y(I,_),new Promise(M=>M(I))}function b(E){if(h){const _=un(E),I=h.property("__zoom");(I.k!==E.zoom||I.x!==E.x||I.y!==E.y)&&(d==null||d.transform(h,_,null,{sync:!0}))}}function S(){const E=h?ha(h.node()):{x:0,y:0,k:1};return{x:E.x,y:E.y,zoom:E.k}}function x(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).scaleTo(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function C(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).scaleBy(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function k(E){d==null||d.scaleExtent(E)}function N(E){d==null||d.translateExtent(E)}function G(E){const _=!Ce(E)||E<0?0:E;d==null||d.clickDistance(_)}return{update:m,destroy:v,setViewport:p,setViewportConstrained:w,getViewport:S,scaleTo:x,scaleBy:C,setScaleExtent:k,setTranslateExtent:N,syncViewport:b,setClickDistance:G}}var tt;(function(e){e.Line="line",e.Handle="handle"})(tt||(tt={}));function uc({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:o}){const s=e-t,a=n-i,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&o&&(c[1]=c[1]*-1),c}function xi(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function Pe(e,t){return Math.max(0,t-e)}function Ie(e,t){return Math.max(0,e-t)}function Lt(e,t,n){return Math.max(0,t-e,e-n)}function Ei(e,t){return e?!t:t}function dc(e,t,n,i,r,o,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:l,isVertical:d}=t,h=l&&d,{xSnapped:f,ySnapped:g}=n,{minWidth:y,maxWidth:m,minHeight:v,maxHeight:w}=i,{x:p,y:b,width:S,height:x,aspectRatio:C}=e;let k=Math.floor(l?f-e.pointerX:0),N=Math.floor(d?g-e.pointerY:0);const G=S+(c?-k:k),E=x+(u?-N:N),_=-o[0]*S,I=-o[1]*x;let M=Lt(G,y,m),P=Lt(E,v,w);if(s){let R=0,T=0;c&&k<0?R=Pe(p+k+_,s[0][0]):!c&&k>0&&(R=Ie(p+G+_,s[1][0])),u&&N<0?T=Pe(b+N+I,s[0][1]):!u&&N>0&&(T=Ie(b+E+I,s[1][1])),M=Math.max(M,R),P=Math.max(P,T)}if(a){let R=0,T=0;c&&k>0?R=Ie(p+k,a[0][0]):!c&&k<0&&(R=Pe(p+G,a[1][0])),u&&N>0?T=Ie(b+N,a[0][1]):!u&&N<0&&(T=Pe(b+E,a[1][1])),M=Math.max(M,R),P=Math.max(P,T)}if(r){if(l){const R=Lt(G/C,v,w)*C;if(M=Math.max(M,R),s){let T=0;!c&&!u||c&&!u&&h?T=Ie(b+I+G/C,s[1][1])*C:T=Pe(b+I+(c?k:-k)/C,s[0][1])*C,M=Math.max(M,T)}if(a){let T=0;!c&&!u||c&&!u&&h?T=Pe(b+G/C,a[1][1])*C:T=Ie(b+(c?k:-k)/C,a[0][1])*C,M=Math.max(M,T)}}if(d){const R=Lt(E*C,y,m)/C;if(P=Math.max(P,R),s){let T=0;!c&&!u||u&&!c&&h?T=Ie(p+E*C+_,s[1][0])/C:T=Pe(p+(u?N:-N)*C+_,s[0][0])/C,P=Math.max(P,T)}if(a){let T=0;!c&&!u||u&&!c&&h?T=Pe(p+E*C,a[1][0])/C:T=Ie(p+(u?N:-N)*C,a[0][0])/C,P=Math.max(P,T)}}}N=N+(N<0?P:-P),k=k+(k<0?M:-M),r&&(h?G>E*C?N=(Ei(c,u)?-k:k)/C:k=(Ei(c,u)?-N:N)*C:l?(N=k/C,u=c):(k=N*C,c=u));const B=c?p+k:p,$=u?b+N:b;return{width:S+(c?-k:k),height:x+(u?-N:N),x:o[0]*k*(c?-1:1)+B,y:o[1]*N*(u?-1:1)+$}}const Zr={width:0,height:0,x:0,y:0},lc={...Zr,pointerX:0,pointerY:0,aspectRatio:1};function hc(e){return[[0,0],[e.measured.width,e.measured.height]]}function fc(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,o=e.measured.width??0,s=e.measured.height??0,a=n[0]*o,c=n[1]*s;return[[i-a,r-c],[i+o-a,r+s-c]]}function gc({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const o=Wt(e);let s={controlDirection:xi("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:l,keepAspectRatio:d,resizeDirection:h,onResizeStart:f,onResize:g,onResizeEnd:y,shouldResize:m}){let v={...Zr},w={...lc};s={boundaries:l,resizeDirection:h,keepAspectRatio:d,controlDirection:xi(u)};let p,b=null,S=[],x,C,k,N=!1;const G=vr().on("start",E=>{const{nodeLookup:_,transform:I,snapGrid:M,snapToGrid:P,nodeOrigin:B,paneDomNode:$}=n();if(p=_.get(t),!p)return;b=($==null?void 0:$.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:T}=yt(E.sourceEvent,{transform:I,snapGrid:M,snapToGrid:P,containerBounds:b});v={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},w={...v,pointerX:R,pointerY:T,aspectRatio:v.width/v.height},x=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(x=_.get(p.parentId),C=x&&p.extent==="parent"?hc(x):void 0),S=[],k=void 0;for(const[U,z]of _)if(z.parentId===t&&(S.push({id:U,position:{...z.position},extent:z.extent}),z.extent==="parent"||z.expandParent)){const F=fc(z,p,z.origin??B);k?k=[[Math.min(F[0][0],k[0][0]),Math.min(F[0][1],k[0][1])],[Math.max(F[1][0],k[1][0]),Math.max(F[1][1],k[1][1])]]:k=F}f==null||f(E,{...v})}).on("drag",E=>{const{transform:_,snapGrid:I,snapToGrid:M,nodeOrigin:P}=n(),B=yt(E.sourceEvent,{transform:_,snapGrid:I,snapToGrid:M,containerBounds:b}),$=[];if(!p)return;const{x:R,y:T,width:U,height:z}=v,F={},V=p.origin??P,{width:q,height:J,x:te,y:ne}=dc(w,s.controlDirection,B,s.boundaries,s.keepAspectRatio,V,C,k),j=q!==U,Q=J!==z,ie=te!==R&&j,ee=ne!==T&&Q;if(!ie&&!ee&&!j&&!Q)return;if((ie||ee||V[0]===1||V[1]===1)&&(F.x=ie?te:v.x,F.y=ee?ne:v.y,v.x=F.x,v.y=F.y,S.length>0)){const ce=te-R,oe=ne-T;for(const ge of S)ge.position={x:ge.position.x-ce+V[0]*(q-U),y:ge.position.y-oe+V[1]*(J-z)},$.push(ge)}if((j||Q)&&(F.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?q:v.width,F.height=Q&&(!s.resizeDirection||s.resizeDirection==="vertical")?J:v.height,v.width=F.width,v.height=F.height),x&&p.expandParent){const ce=V[0]*(F.width??0);F.x&&F.x<ce&&(v.x=ce,w.x=w.x-(F.x-ce));const oe=V[1]*(F.height??0);F.y&&F.y<oe&&(v.y=oe,w.y=w.y-(F.y-oe))}const K=uc({width:v.width,prevWidth:U,height:v.height,prevHeight:z,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),Z={...v,direction:K};(m==null?void 0:m(E,Z))!==!1&&(N=!0,g==null||g(E,Z),i(F,$))}).on("end",E=>{N&&(y==null||y(E,{...v}),r==null||r({...v}),N=!1)});o.call(G)}function c(){o.on(".drag",null)}return{update:a,destroy:c}}const Kt=D.createContext(null),pc=Kt.Provider,Kr=Ne.error001();function re(e,t){const n=D.useContext(Kt);if(n===null)throw new Error(Kr);return ga(n,e,t)}function de(){const e=D.useContext(Kt);if(e===null)throw new Error(Kr);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Si={display:"none"},mc={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},qr="react-flow__node-desc",Qr="react-flow__edge-desc",yc="react-flow__aria-live",vc=e=>e.ariaLiveMessage,wc=e=>e.ariaLabelConfig;function bc({rfId:e}){const t=re(vc);return A.jsx("div",{id:`${yc}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mc,children:t})}function xc({rfId:e,disableKeyboardA11y:t}){const n=re(wc);return A.jsxs(A.Fragment,{children:[A.jsx("div",{id:`${qr}-${e}`,style:Si,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),A.jsx("div",{id:`${Qr}-${e}`,style:Si,children:n["edge.a11yDescription.default"]}),!t&&A.jsx(bc,{rfId:e})]})}const qt=D.forwardRef(({position:e="top-left",children:t,className:n,style:i,...r},o)=>{const s=`${e}`.split("-");return A.jsx("div",{className:he(["react-flow__panel",n,...s]),style:i,ref:o,...r,children:t})});qt.displayName="Panel";function Ec({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:A.jsx(qt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:A.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Sc=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},Mt=e=>e.id;function Cc(e,t){return ue(e.selectedNodes.map(Mt),t.selectedNodes.map(Mt))&&ue(e.selectedEdges.map(Mt),t.selectedEdges.map(Mt))}function _c({onSelectionChange:e}){const t=de(),{selectedNodes:n,selectedEdges:i}=re(Sc,Cc);return D.useEffect(()=>{const r={nodes:n,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(o=>o(r))},[n,i,e]),null}const Nc=e=>!!e.onSelectionChangeHandlers;function Ac({onSelectionChange:e}){const t=re(Nc);return e||t?A.jsx(_c,{onSelectionChange:e}):null}const kn=typeof window<"u"?D.useLayoutEffect:D.useEffect,Jr=[0,0],Tc={x:0,y:0,zoom:1},kc=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Ci=[...kc,"rfId"],Rc=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),_i={translateExtent:wt,nodeOrigin:Jr,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Dc(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=re(Rc,ue),u=de();kn(()=>(c(e.defaultNodes,e.defaultEdges),()=>{l.current=_i,a()}),[]);const l=D.useRef(_i);return kn(()=>{for(const d of Ci){const h=e[d],f=l.current[d];h!==f&&(typeof e[d]>"u"||(d==="nodes"?t(h):d==="edges"?n(h):d==="minZoom"?i(h):d==="maxZoom"?r(h):d==="translateExtent"?o(h):d==="nodeExtent"?s(h):d==="ariaLabelConfig"?u.setState({ariaLabelConfig:Na(h)}):d==="fitView"?u.setState({fitViewQueued:h}):d==="fitViewOptions"?u.setState({fitViewOptions:h}):u.setState({[d]:h})))}l.current=e},Ci.map(d=>e[d])),null}function Ni(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Lc(e){var i;const[t,n]=D.useState(e==="system"?null:e);return D.useEffect(()=>{if(e!=="system"){n(e);return}const r=Ni(),o=()=>n(r!=null&&r.matches?"dark":"light");return o(),r==null||r.addEventListener("change",o),()=>{r==null||r.removeEventListener("change",o)}},[e]),t!==null?t:(i=Ni())!=null&&i.matches?"dark":"light"}const Ai=typeof document<"u"?document:null;function St(e=null,t={target:Ai,actInsideInputWithModifier:!0}){const[n,i]=D.useState(!1),r=D.useRef(!1),o=D.useRef(new Set([])),[s,a]=D.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
1
|
+
import{z as yr,o as Wt,p as la,q as sn,v as an,x as ha,y as vr,A as wr,r as D,j as A,B as he,C as br,D as fa}from"./vendor-Dnkkx2co.js";import{u as ga,c as pa,s as ue}from"./state-vCcAT5Hq.js";const Ne={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},wt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],xr=["Enter"," ","Escape"],Er={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var qe;(function(e){e.Strict="strict",e.Loose="loose"})(qe||(qe={}));var Ue;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ue||(Ue={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const Sr={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Fe;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Fe||(Fe={}));var Ot;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ot||(Ot={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const ci={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function Cr(e){return e===null?null:e?"valid":"invalid"}const _r=e=>"id"in e&&"source"in e&&"target"in e,ma=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ct=(e,t=[0,0])=>{const{width:n,height:i}=De(e),r=e.origin??t,o=n*r[0],s=i*r[1];return{x:e.position.x-o,y:e.position.y-s}},ya=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,r)=>{const o=typeof r=="string";let s=!t.nodeLookup&&!o?r:void 0;t.nodeLookup&&(s=o?t.nodeLookup.get(r):Gn(r)?r:t.nodeLookup.get(r.id));const a=s?Ut(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Yt(i,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Xt(n)},_t=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=Yt(n,Ut(r)),i=!0)}),i?Xt(n):{x:0,y:0,width:0,height:0}},Fn=(e,t,[n,i,r]=[0,0,1],o=!1,s=!1)=>{const a={...At(t,[n,i,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:l,selectable:d=!0,hidden:h=!1}=u;if(s&&!d||h)continue;const f=l.width??u.width??u.initialWidth??null,g=l.height??u.height??u.initialHeight??null,y=xt(a,Je(u)),m=(f??0)*(g??0),v=o&&y>0;(!u.internals.handleBounds||v||y>=m||u.dragging)&&c.push(u)}return c},va=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function wa(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function ba({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:o},s){if(e.size===0)return Promise.resolve(!0);const a=wa(e,s),c=_t(a),u=$n(c,t,n,(s==null?void 0:s.minZoom)??r,(s==null?void 0:s.maxZoom)??o,(s==null?void 0:s.padding)??.1);return await i.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Nr({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:o}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},l=s.origin??i;let d=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)o==null||o("005",Ne.error005());else{const f=a.measured.width,g=a.measured.height;f&&g&&(d=[[c,u],[c+f,u+g]])}else a&&et(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const h=et(d)?He(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(o==null||o("015",Ne.error015())),{position:{x:h.x-c+(s.measured.width??0)*l[0],y:h.y-u+(s.measured.height??0)*l[1]},positionAbsolute:h}}async function xa({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const o=new Set(e.map(h=>h.id)),s=[];for(const h of n){if(h.deletable===!1)continue;const f=o.has(h.id),g=!f&&h.parentId&&s.find(y=>y.id===h.parentId);(f||g)&&s.push(h)}const a=new Set(t.map(h=>h.id)),c=i.filter(h=>h.deletable!==!1),l=va(s,c);for(const h of c)a.has(h.id)&&!l.find(g=>g.id===h.id)&&l.push(h);if(!r)return{edges:l,nodes:s};const d=await r({nodes:s,edges:l});return typeof d=="boolean"?d?{edges:l,nodes:s}:{edges:[],nodes:[]}:d}const Qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),He=(e={x:0,y:0},t,n)=>({x:Qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ar(e,t,n){const{width:i,height:r}=De(n),{x:o,y:s}=n.internals.positionAbsolute;return He(e,[[o,s],[o+i,s+r]],t)}const ui=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,Tr=(e,t,n=15,i=40)=>{const r=ui(e.x,i,t.width-i)*n,o=ui(e.y,i,t.height-i)*n;return[r,o]},Yt=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Cn=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),Xt=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),Je=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Gn(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Ut=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Gn(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},kr=(e,t)=>Xt(Yt(Cn(e),Cn(t))),xt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},di=e=>Ce(e.width)&&Ce(e.height)&&Ce(e.x)&&Ce(e.y),Ce=e=>!isNaN(e)&&isFinite(e),Ea=(e,t)=>{},Nt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),At=({x:e,y:t},[n,i,r],o=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-i)/r};return o?Nt(a,s):a},Ht=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function We(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sa(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=We(e,n),r=We(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=We(e.top??e.y??0,n),r=We(e.bottom??e.y??0,n),o=We(e.left??e.x??0,t),s=We(e.right??e.x??0,t);return{top:i,right:s,bottom:r,left:o,x:o+s,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ca(e,t,n,i,r,o){const{x:s,y:a}=Ht(e,[t,n,i]),{x:c,y:u}=Ht({x:e.x+e.width,y:e.y+e.height},[t,n,i]),l=r-c,d=o-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(l),bottom:Math.floor(d)}}const $n=(e,t,n,i,r,o)=>{const s=Sa(o,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),l=Qe(u,i,r),d=e.x+e.width/2,h=e.y+e.height/2,f=t/2-d*l,g=n/2-h*l,y=Ca(e,f,g,l,t,n),m={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:f-m.left+m.right,y:g-m.top+m.bottom,zoom:l}},Et=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!=null&&e!=="parent"}function De(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Rr(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Dr(e,t={width:0,height:0},n,i,r){const o={...e},s=i.get(n);if(s){const a=s.origin||r;o.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],o.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return o}function li(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function _a(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function Na(e){return{...Er,...e||{}}}function yt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:o,y:s}=_e(e),a=At({x:o-((r==null?void 0:r.left)??0),y:s-((r==null?void 0:r.top)??0)},i),{x:c,y:u}=n?Nt(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const zn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Lr=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Aa=["INPUT","SELECT","TEXTAREA"];function Mr(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Aa.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Pr=e=>"clientX"in e,_e=(e,t)=>{var o,s;const n=Pr(e),i=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,r=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},hi=(e,t,n,i,r)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/i,y:(a.top-n.top)/i,...zn(s)}})};function Ir({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:o,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,u=t*.125+o*.375+a*.375+i*.125,l=Math.abs(c-e),d=Math.abs(u-t);return[c,u,l,d]}function Dt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fi({pos:e,x1:t,y1:n,x2:i,y2:r,c:o}){switch(e){case Y.Left:return[t-Dt(t-i,o),n];case Y.Right:return[t+Dt(i-t,o),n];case Y.Top:return[t,n-Dt(n-r,o)];case Y.Bottom:return[t,n+Dt(r-n,o)]}}function Gr({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top,curvature:s=.25}){const[a,c]=fi({pos:n,x1:e,y1:t,x2:i,y2:r,c:s}),[u,l]=fi({pos:o,x1:i,y1:r,x2:e,y2:t,c:s}),[d,h,f,g]=Ir({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:l});return[`M${e},${t} C${a},${c} ${u},${l} ${i},${r}`,d,h,f,g]}function Fr({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,o=n<e?n+r:n-r,s=Math.abs(i-t)/2,a=i<t?i+s:i-s;return[o,a,r,s]}function Ta({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const s=r&&n?i+1e3:i,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function ka({sourceNode:e,targetNode:t,width:n,height:i,transform:r}){const o=Yt(Ut(e),Ut(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:i/r[2]};return xt(s,Xt(o))>0}const Ra=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,Da=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),La=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||Ra;let r;return _r(e)?r={...e}:r={...e,id:i(e)},Da(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function $r({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,o,s,a]=Fr({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,o,s,a]}const gi={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},Ma=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},pi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Pa({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:i=Y.Top,center:r,offset:o,stepPosition:s}){const a=gi[t],c=gi[i],u={x:e.x+a.x*o,y:e.y+a.y*o},l={x:n.x+c.x*o,y:n.y+c.y*o},d=Ma({source:u,sourcePosition:t,target:l}),h=d.x!==0?"x":"y",f=d[h];let g=[],y,m;const v={x:0,y:0},w={x:0,y:0},[,,p,b]=Fr({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[h]*c[h]===-1){h==="x"?(y=r.x??u.x+(l.x-u.x)*s,m=r.y??(u.y+l.y)/2):(y=r.x??(u.x+l.x)/2,m=r.y??u.y+(l.y-u.y)*s);const k=[{x:y,y:u.y},{x:y,y:l.y}],N=[{x:u.x,y:m},{x:l.x,y:m}];a[h]===f?g=h==="x"?k:N:g=h==="x"?N:k}else{const k=[{x:u.x,y:l.y}],N=[{x:l.x,y:u.y}];if(h==="x"?g=a.x===f?N:k:g=a.y===f?k:N,t===i){const M=Math.abs(e[h]-n[h]);if(M<=o){const P=Math.min(o-1,o-M);a[h]===f?v[h]=(u[h]>e[h]?-1:1)*P:w[h]=(l[h]>n[h]?-1:1)*P}}if(t!==i){const M=h==="x"?"y":"x",P=a[h]===c[M],B=u[M]>l[M],$=u[M]<l[M];(a[h]===1&&(!P&&B||P&&$)||a[h]!==1&&(!P&&$||P&&B))&&(g=h==="x"?k:N)}const G={x:u.x+v.x,y:u.y+v.y},E={x:l.x+w.x,y:l.y+w.y},_=Math.max(Math.abs(G.x-g[0].x),Math.abs(E.x-g[0].x)),I=Math.max(Math.abs(G.y-g[0].y),Math.abs(E.y-g[0].y));_>=I?(y=(G.x+E.x)/2,m=g[0].y):(y=g[0].x,m=(G.y+E.y)/2)}const S={x:u.x+v.x,y:u.y+v.y},x={x:l.x+w.x,y:l.y+w.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...x.x!==g[g.length-1].x||x.y!==g[g.length-1].y?[x]:[],n],y,m,p,b]}function Ia(e,t,n,i){const r=Math.min(pi(e,t)/2,pi(t,n)/2,i),{x:o,y:s}=t;if(e.x===o&&o===n.x||e.y===s&&s===n.y)return`L${o} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,l=e.y<n.y?1:-1;return`L ${o+r*u},${s}Q ${o},${s} ${o},${s+r*l}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${s+r*c}Q ${o},${s} ${o+r*a},${s}`}function _n({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:l=.5}){const[d,h,f,g,y]=Pa({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:r},targetPosition:o,center:{x:a,y:c},offset:u,stepPosition:l});let m=`M${d[0].x} ${d[0].y}`;for(let v=1;v<d.length-1;v++)m+=Ia(d[v-1],d[v],d[v+1],s);return m+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[m,h,f,g,y]}function mi(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ga(e){var d;const{sourceNode:t,targetNode:n}=e;if(!mi(t)||!mi(n))return null;const i=t.internals.handleBounds||yi(t.handles),r=n.internals.handleBounds||yi(n.handles),o=vi((i==null?void 0:i.source)??[],e.sourceHandle),s=vi(e.connectionMode===qe.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!o||!s)return(d=e.onError)==null||d.call(e,"008",Ne.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(o==null?void 0:o.position)||Y.Bottom,c=(s==null?void 0:s.position)||Y.Top,u=je(t,o,a),l=je(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:l.x,targetY:l.y,sourcePosition:a,targetPosition:c}}function yi(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function je(e,t,n=Y.Left,i=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??De(e);if(i)return{x:r+s/2,y:o+a/2};switch((t==null?void 0:t.position)??n){case Y.Top:return{x:r+s/2,y:o};case Y.Right:return{x:r+s,y:o+a/2};case Y.Bottom:return{x:r+s/2,y:o+a};case Y.Left:return{x:r,y:o+a/2}}}function vi(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Nn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function Fa(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const o=new Set;return e.reduce((s,a)=>([a.markerStart||i,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=Nn(c,t);o.has(u)||(s.push({id:u,color:c.color||n,...c}),o.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const zr=1e3,$a=10,Bn={nodeOrigin:[0,0],nodeExtent:wt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},za={...Bn,checkEquality:!0};function On(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function Ba(e,t,n){const i=On(Bn,n);for(const r of e.values())if(r.parentId)Hn(r,e,t,i);else{const o=Ct(r,i.nodeOrigin),s=et(r.extent)?r.extent:i.nodeExtent,a=He(o,s,De(r));r.internals.positionAbsolute=a}}function Oa(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const o={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(o):r.type==="target"&&i.push(o)}return{source:n,target:i}}function Un(e){return e==="manual"}function An(e,t,n,i={}){var l,d;const r=On(za,i),o={i:0},s=new Map(t),a=r!=null&&r.elevateNodesOnSelect&&!Un(r.zIndexMode)?zr:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let f=s.get(h.id);if(r.checkEquality&&h===(f==null?void 0:f.internals.userNode))t.set(h.id,f);else{const g=Ct(h,r.nodeOrigin),y=et(h.extent)?h.extent:r.nodeExtent,m=He(g,y,De(h));f={...r.defaults,...h,measured:{width:(l=h.measured)==null?void 0:l.width,height:(d=h.measured)==null?void 0:d.height},internals:{positionAbsolute:m,handleBounds:Oa(h,f),z:Br(h,a,r.zIndexMode),userNode:h}},t.set(h.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),h.parentId&&Hn(f,t,n,i,o),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function Ua(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Hn(e,t,n,i,r){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=On(Bn,i),u=e.parentId,l=t.get(u);if(!l){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ua(e,n),r&&!l.parentId&&l.internals.rootParentIndex===void 0&&c==="auto"&&(l.internals.rootParentIndex=++r.i,l.internals.z=l.internals.z+r.i*$a),r&&l.internals.rootParentIndex!==void 0&&(r.i=l.internals.rootParentIndex);const d=o&&!Un(c)?zr:0,{x:h,y:f,z:g}=Ha(e,l,s,a,d,c),{positionAbsolute:y}=e.internals,m=h!==y.x||f!==y.y;(m||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:m?{x:h,y:f}:y,z:g}})}function Br(e,t,n){const i=Ce(e.zIndex)?e.zIndex:0;return Un(n)?i:i+(e.selected?t:0)}function Ha(e,t,n,i,r,o){const{x:s,y:a}=t.internals.positionAbsolute,c=De(e),u=Ct(e,n),l=et(e.extent)?He(u,e.extent,c):u;let d=He({x:s+l.x,y:a+l.y},i,c);e.extent==="parent"&&(d=Ar(d,c,t));const h=Br(e,r,o),f=t.internals.z??0;return{x:d.x,y:d.y,z:f>=h?f+1:h}}function jn(e,t,n,i=[0,0]){var s;const r=[],o=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=((s=o.get(a.parentId))==null?void 0:s.expandedRect)??Je(c),l=kr(u,a.rect);o.set(a.parentId,{expandedRect:l,parent:c})}return o.size>0&&o.forEach(({expandedRect:a,parent:c},u)=>{var p;const l=c.internals.positionAbsolute,d=De(c),h=c.origin??i,f=a.x<l.x?Math.round(Math.abs(l.x-a.x)):0,g=a.y<l.y?Math.round(Math.abs(l.y-a.y)):0,y=Math.max(d.width,Math.round(a.width)),m=Math.max(d.height,Math.round(a.height)),v=(y-d.width)*h[0],w=(m-d.height)*h[1];(f>0||g>0||v||w)&&(r.push({id:u,type:"position",position:{x:c.position.x-f+v,y:c.position.y-g+w}}),(p=n.get(u))==null||p.forEach(b=>{e.some(S=>S.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+g}})})),(d.width<a.width||d.height<a.height||f||g)&&r.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:y+(f?h[0]*f-v:0),height:m+(g?h[1]*g-w:0)}})}),r}function ja(e,t,n,i,r,o,s){const a=i==null?void 0:i.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const u=[],l=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(l.transform),h=[];for(const f of e.values()){const g=t.get(f.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const y=zn(f.nodeElement),m=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(m||!g.internals.handleBounds||f.force))){const w=f.nodeElement.getBoundingClientRect(),p=et(g.extent)?g.extent:o;let{positionAbsolute:b}=g.internals;g.parentId&&g.extent==="parent"?b=Ar(b,y,t.get(g.parentId)):p&&(b=He(b,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:b,handleBounds:{source:hi("source",f.nodeElement,w,d,g.id),target:hi("target",f.nodeElement,w,d,g.id)}}};t.set(g.id,S),g.parentId&&Hn(S,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,m&&(u.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&h.push({id:g.id,parentId:g.parentId,rect:Je(S,r)}))}}if(h.length>0){const f=jn(h,t,n,r);u.push(...f)}return{changes:u,updatedInternals:c}}async function Va({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,o]],i),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function wi(e,t,n,i,r,o){let s=r;const a=i.get(s)||new Map;i.set(s,a.set(n,t)),s=`${r}-${e}`;const c=i.get(s)||new Map;if(i.set(s,c.set(n,t)),o){s=`${r}-${e}-${o}`;const u=i.get(s)||new Map;i.set(s,u.set(n,t))}}function Or(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:o,sourceHandle:s=null,targetHandle:a=null}=i,c={edgeId:i.id,source:r,target:o,sourceHandle:s,targetHandle:a},u=`${r}-${s}--${o}-${a}`,l=`${o}-${a}--${r}-${s}`;wi("source",c,l,e,r,s),wi("target",c,u,e,o,a),t.set(i.id,i)}}function Ur(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ur(n,t):!1}function bi(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function Wa(e,t,n,i){const r=new Map;for(const[o,s]of e)if((s.selected||s.id===i)&&(!s.parentId||!Ur(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(o);a&&r.set(o,{id:o,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function cn({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var s,a,c;const r=[];for(const[u,l]of t){const d=(s=n.get(u))==null?void 0:s.internals.userNode;d&&r.push({...d,position:l.position,dragging:i})}if(!e)return[r[0],r];const o=(a=n.get(e))==null?void 0:a.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:i}:r[0],r]}function Ya({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const o={x:n-r.distance.x,y:i-r.distance.y},s=Nt(o,t);return{x:s.x-o.x,y:s.y-o.y}}function Xa({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let o={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},l=null,d=!1,h=null,f=!1,g=!1,y=null;function m({noDragClassName:w,handleSelector:p,domNode:b,isSelectable:S,nodeId:x,nodeClickDistance:C=0}){h=Wt(b);function k({x:_,y:I}){const{nodeLookup:M,nodeExtent:P,snapGrid:B,snapToGrid:$,nodeOrigin:R,onNodeDrag:T,onSelectionDrag:U,onError:z,updateNodePositions:F}=t();o={x:_,y:I};let V=!1;const q=a.size>1,J=q&&P?Cn(_t(a)):null,te=q&&$?Ya({dragItems:a,snapGrid:B,x:_,y:I}):null;for(const[ne,j]of a){if(!M.has(ne))continue;let Q={x:_-j.distance.x,y:I-j.distance.y};$&&(Q=te?{x:Math.round(Q.x+te.x),y:Math.round(Q.y+te.y)}:Nt(Q,B));let ie=null;if(q&&P&&!j.extent&&J){const{positionAbsolute:Z}=j.internals,se=Z.x-J.x+P[0][0],ce=Z.x+j.measured.width-J.x2+P[1][0],oe=Z.y-J.y+P[0][1],ge=Z.y+j.measured.height-J.y2+P[1][1];ie=[[se,oe],[ce,ge]]}const{position:ee,positionAbsolute:K}=Nr({nodeId:ne,nextPosition:Q,nodeLookup:M,nodeExtent:ie||P,nodeOrigin:R,onError:z});V=V||j.position.x!==ee.x||j.position.y!==ee.y,j.position=ee,j.internals.positionAbsolute=K}if(g=g||V,!!V&&(F(a,!0),y&&(i||T||!x&&U))){const[ne,j]=cn({nodeId:x,dragItems:a,nodeLookup:M});i==null||i(y,a,ne,j),T==null||T(y,ne,j),x||U==null||U(y,j)}}async function N(){if(!l)return;const{transform:_,panBy:I,autoPanSpeed:M,autoPanOnNodeDrag:P}=t();if(!P){c=!1,cancelAnimationFrame(s);return}const[B,$]=Tr(u,l,M);(B!==0||$!==0)&&(o.x=(o.x??0)-B/_[2],o.y=(o.y??0)-$/_[2],await I({x:B,y:$})&&k(o)),s=requestAnimationFrame(N)}function G(_){var q;const{nodeLookup:I,multiSelectionActive:M,nodesDraggable:P,transform:B,snapGrid:$,snapToGrid:R,selectNodesOnDrag:T,onNodeDragStart:U,onSelectionDragStart:z,unselectNodesAndEdges:F}=t();d=!0,(!T||!S)&&!M&&x&&((q=I.get(x))!=null&&q.selected||F()),S&&T&&x&&(e==null||e(x));const V=yt(_.sourceEvent,{transform:B,snapGrid:$,snapToGrid:R,containerBounds:l});if(o=V,a=Wa(I,P,V,x),a.size>0&&(n||U||!x&&z)){const[J,te]=cn({nodeId:x,dragItems:a,nodeLookup:I});n==null||n(_.sourceEvent,a,J,te),U==null||U(_.sourceEvent,J,te),x||z==null||z(_.sourceEvent,te)}}const E=vr().clickDistance(C).on("start",_=>{const{domNode:I,nodeDragThreshold:M,transform:P,snapGrid:B,snapToGrid:$}=t();l=(I==null?void 0:I.getBoundingClientRect())||null,f=!1,g=!1,y=_.sourceEvent,M===0&&G(_),o=yt(_.sourceEvent,{transform:P,snapGrid:B,snapToGrid:$,containerBounds:l}),u=_e(_.sourceEvent,l)}).on("drag",_=>{const{autoPanOnNodeDrag:I,transform:M,snapGrid:P,snapToGrid:B,nodeDragThreshold:$,nodeLookup:R}=t(),T=yt(_.sourceEvent,{transform:M,snapGrid:P,snapToGrid:B,containerBounds:l});if(y=_.sourceEvent,(_.sourceEvent.type==="touchmove"&&_.sourceEvent.touches.length>1||x&&!R.has(x))&&(f=!0),!f){if(!c&&I&&d&&(c=!0,N()),!d){const U=_e(_.sourceEvent,l),z=U.x-u.x,F=U.y-u.y;Math.sqrt(z*z+F*F)>$&&G(_)}(o.x!==T.xSnapped||o.y!==T.ySnapped)&&a&&d&&(u=_e(_.sourceEvent,l),k(T))}}).on("end",_=>{if(!(!d||f)&&(c=!1,d=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:I,updateNodePositions:M,onNodeDragStop:P,onSelectionDragStop:B}=t();if(g&&(M(a,!1),g=!1),r||P||!x&&B){const[$,R]=cn({nodeId:x,dragItems:a,nodeLookup:I,dragging:!1});r==null||r(_.sourceEvent,a,$,R),P==null||P(_.sourceEvent,$,R),x||B==null||B(_.sourceEvent,R)}}}).filter(_=>{const I=_.target;return!_.button&&(!w||!bi(I,`.${w}`,b))&&(!p||bi(I,p,b))});h.call(E)}function v(){h==null||h.on(".drag",null)}return{update:m,destroy:v}}function Za(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())xt(r,Je(o))>0&&i.push(o);return i}const Ka=250;function qa(e,t,n,i){var a,c;let r=[],o=1/0;const s=Za(e,n,t+Ka);for(const u of s){const l=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of l){if(i.nodeId===d.nodeId&&i.type===d.type&&i.id===d.id)continue;const{x:h,y:f}=je(u,d,d.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(f-e.y,2));g>t||(g<o?(r=[{...d,x:h,y:f}],o=g):g===o&&r.push({...d,x:h,y:f}))}}if(!r.length)return null;if(r.length>1){const u=i.type==="source"?"target":"source";return r.find(l=>l.type===u)??r[0]}return r[0]}function Hr(e,t,n,i,r,o=!1){var u,l,d;const s=i.get(e);if(!s)return null;const a=r==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((l=s.internals.handleBounds)==null?void 0:l.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(h=>h.id===n):a==null?void 0:a[0])??null;return c&&o?{...c,...je(s,c,c.position,!0)}:c}function jr(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Qa(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Vr=()=>!0;function Ja(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:l,flowId:d,panBy:h,cancelConnection:f,onConnectStart:g,onConnect:y,onConnectEnd:m,isValidConnection:v=Vr,onReconnectEnd:w,updateConnection:p,getTransform:b,getFromHandle:S,autoPanSpeed:x,dragThreshold:C=1,handleDomNode:k}){const N=Lr(e.target);let G=0,E;const{x:_,y:I}=_e(e),M=jr(o,k),P=a==null?void 0:a.getBoundingClientRect();let B=!1;if(!P||!M)return;const $=Hr(r,M,i,c,t);if(!$)return;let R=_e(e,P),T=!1,U=null,z=!1,F=null;function V(){if(!l||!P)return;const[ee,K]=Tr(R,P,x);h({x:ee,y:K}),G=requestAnimationFrame(V)}const q={...$,nodeId:r,type:M,position:$.position},J=c.get(r);let ne={inProgress:!0,isValid:null,from:je(J,q,Y.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:J,to:R,toHandle:null,toPosition:ci[q.position],toNode:null,pointer:R};function j(){B=!0,p(ne),g==null||g(e,{nodeId:r,handleId:i,handleType:M})}C===0&&j();function Q(ee){if(!B){const{x:ge,y:Me}=_e(ee),Ae=ge-_,ze=Me-I;if(!(Ae*Ae+ze*ze>C*C))return;j()}if(!S()||!q){ie(ee);return}const K=b();R=_e(ee,P),E=qa(At(R,K,!1,[1,1]),n,c,q),T||(V(),T=!0);const Z=Wr(ee,{handle:E,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:s?"target":"source",isValidConnection:v,doc:N,lib:u,flowId:d,nodeLookup:c});F=Z.handleDomNode,U=Z.connection,z=Qa(!!E,Z.isValid);const se=c.get(r),ce=se?je(se,q,Y.Left,!0):ne.from,oe={...ne,from:ce,isValid:z,to:Z.toHandle&&z?Ht({x:Z.toHandle.x,y:Z.toHandle.y},K):R,toHandle:Z.toHandle,toPosition:z&&Z.toHandle?Z.toHandle.position:ci[q.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:R};p(oe),ne=oe}function ie(ee){if(!("touches"in ee&&ee.touches.length>0)){if(B){(E||F)&&U&&z&&(y==null||y(U));const{inProgress:K,...Z}=ne,se={...Z,toPosition:ne.toHandle?ne.toPosition:null};m==null||m(ee,se),o&&(w==null||w(ee,se))}f(),cancelAnimationFrame(G),T=!1,z=!1,U=null,F=null,N.removeEventListener("mousemove",Q),N.removeEventListener("mouseup",ie),N.removeEventListener("touchmove",Q),N.removeEventListener("touchend",ie)}}N.addEventListener("mousemove",Q),N.addEventListener("mouseup",ie),N.addEventListener("touchmove",Q),N.addEventListener("touchend",ie)}function Wr(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:o,doc:s,lib:a,flowId:c,isValidConnection:u=Vr,nodeLookup:l}){const d=o==="target",h=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:f,y:g}=_e(e),y=s.elementFromPoint(f,g),m=y!=null&&y.classList.contains(`${a}-flow__handle`)?y:h,v={handleDomNode:m,isValid:!1,connection:null,toHandle:null};if(m){const w=jr(void 0,m),p=m.getAttribute("data-nodeid"),b=m.getAttribute("data-handleid"),S=m.classList.contains("connectable"),x=m.classList.contains("connectableend");if(!p||!w)return v;const C={source:d?p:i,sourceHandle:d?b:r,target:d?i:p,targetHandle:d?r:b};v.connection=C;const N=S&&x&&(n===qe.Strict?d&&w==="source"||!d&&w==="target":p!==i||b!==r);v.isValid=N&&u(C),v.toHandle=Hr(p,w,b,l,n,!0)}return v}const Tn={onPointerDown:Ja,isValid:Wr};function ec({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=Wt(e);function o({translateExtent:a,width:c,height:u,zoomStep:l=1,pannable:d=!0,zoomable:h=!0,inversePan:f=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const b=n(),S=p.sourceEvent.ctrlKey&&Et()?10:1,x=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*l,C=b[2]*Math.pow(2,x*S);t.scaleTo(C)};let y=[0,0];const m=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},v=p=>{const b=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],x=[S[0]-y[0],S[1]-y[1]];y=S;const C=i()*Math.max(b[2],Math.log(b[2]))*(f?-1:1),k={x:b[0]-x[0]*C,y:b[1]-x[1]*C},N=[[0,0],[c,u]];t.setViewportConstrained({x:k.x,y:k.y,zoom:b[2]},N,a)},w=yr().on("start",m).on("zoom",d?v:null).on("zoom.wheel",h?g:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:o,destroy:s,pointer:wr}}const Zt=e=>({x:e.x,y:e.y,zoom:e.k}),un=({x:e,y:t,zoom:n})=>la.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),Yr=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),tc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,dn=(e,t=0,n=tc,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},Xr=e=>{const t=e.ctrlKey&&Et()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return l=>{if(Xe(l,t))return l.ctrlKey&&l.preventDefault(),!1;l.preventDefault(),l.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(l.ctrlKey&&s){const m=wr(l),v=Xr(l),w=d*Math.pow(2,v);i.scaleTo(n,w,m,l);return}const h=l.deltaMode===1?20:1;let f=r===Ue.Vertical?0:l.deltaX*h,g=r===Ue.Horizontal?0:l.deltaY*h;!Et()&&l.shiftKey&&r!==Ue.Vertical&&(f=l.deltaY*h,g=0),i.translateBy(n,-(f/d)*o,-(g/d)*o,{internal:!0});const y=Zt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(l,y),e.panScrollTimeout=setTimeout(()=>{u==null||u(l,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(l,y))}}function ic({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const o=i.type==="wheel",s=!t&&o&&!i.ctrlKey,a=Xe(i,e);if(i.ctrlKey&&o&&a&&i.preventDefault(),s||a)return null;i.preventDefault(),n.call(this,i,r)}}function rc({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var o,s,a;if((o=i.sourceEvent)!=null&&o.internal)return;const r=Zt(i.transform);e.mouseButton=((s=i.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((a=i.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function oc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return o=>{var s,a;e.usedRightMouseButton=!!(n&&Yr(t,e.mouseButton??0)),(s=o.sourceEvent)!=null&&s.sync||i([o.transform.x,o.transform.y,o.transform.k]),r&&!((a=o.sourceEvent)!=null&&a.internal)&&(r==null||r(o.sourceEvent,Zt(o.transform)))}}function sc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:o}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,o&&Yr(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&o(s.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const c=Zt(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(s.sourceEvent,c)},n?150:0)}}}function ac({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:r,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:u,connectionInProgress:l}){return d=>{var m;const h=e||t,f=n&&d.ctrlKey,g=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${u}-flow__node`)||Xe(d,`${u}-flow__edge`)))return!0;if(!i&&!h&&!r&&!o&&!n||s||l&&!g||Xe(d,a)&&g||Xe(d,c)&&(!g||r&&g&&!e)||!n&&d.ctrlKey&&g)return!1;if(!n&&d.type==="touchstart"&&((m=d.touches)==null?void 0:m.length)>1)return d.preventDefault(),!1;if(!h&&!r&&!f&&g||!i&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(i)&&!i.includes(d.button)&&d.type==="mousedown")return!1;const y=Array.isArray(i)&&i.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||g)&&y}}function cc({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:o,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},l=e.getBoundingClientRect(),d=yr().scaleExtent([t,n]).translateExtent(i),h=Wt(e).call(d);w({x:r.x,y:r.y,zoom:Qe(r.zoom,t,n)},[[0,0],[l.width,l.height]],i);const f=h.on("wheel.zoom"),g=h.on("dblclick.zoom");d.wheelDelta(Xr);function y(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).transform(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function m({noWheelClassName:E,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:P,panOnDrag:B,panOnScrollMode:$,panOnScrollSpeed:R,preventScrolling:T,zoomOnPinch:U,zoomOnScroll:z,zoomOnDoubleClick:F,zoomActivationKeyPressed:V,lib:q,onTransformChange:J,connectionInProgress:te,paneClickDistance:ne,selectionOnDrag:j}){M&&!u.isZoomingOrPanning&&v();const Q=P&&!V&&!M;d.clickDistance(j?1/0:!Ce(ne)||ne<0?0:ne);const ie=Q?nc({zoomPanValues:u,noWheelClassName:E,d3Selection:h,d3Zoom:d,panOnScrollMode:$,panOnScrollSpeed:R,zoomOnPinch:U,onPanZoomStart:s,onPanZoom:o,onPanZoomEnd:a}):ic({noWheelClassName:E,preventScrolling:T,d3ZoomHandler:f});if(h.on("wheel.zoom",ie,{passive:!1}),!M){const K=rc({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});d.on("start",K);const Z=oc({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!I,onPanZoom:o,onTransformChange:J});d.on("zoom",Z);const se=sc({zoomPanValues:u,panOnDrag:B,panOnScroll:P,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});d.on("end",se)}const ee=ac({zoomActivationKeyPressed:V,panOnDrag:B,zoomOnScroll:z,panOnScroll:P,zoomOnDoubleClick:F,zoomOnPinch:U,userSelectionActive:M,noPanClassName:_,noWheelClassName:E,lib:q,connectionInProgress:te});d.filter(ee),F?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function v(){d.on("zoom",null)}async function w(E,_,I){const M=un(E),P=d==null?void 0:d.constrain()(M,_,I);return P&&await y(P),new Promise(B=>B(P))}async function p(E,_){const I=un(E);return await y(I,_),new Promise(M=>M(I))}function b(E){if(h){const _=un(E),I=h.property("__zoom");(I.k!==E.zoom||I.x!==E.x||I.y!==E.y)&&(d==null||d.transform(h,_,null,{sync:!0}))}}function S(){const E=h?ha(h.node()):{x:0,y:0,k:1};return{x:E.x,y:E.y,zoom:E.k}}function x(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).scaleTo(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function C(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).scaleBy(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function k(E){d==null||d.scaleExtent(E)}function N(E){d==null||d.translateExtent(E)}function G(E){const _=!Ce(E)||E<0?0:E;d==null||d.clickDistance(_)}return{update:m,destroy:v,setViewport:p,setViewportConstrained:w,getViewport:S,scaleTo:x,scaleBy:C,setScaleExtent:k,setTranslateExtent:N,syncViewport:b,setClickDistance:G}}var tt;(function(e){e.Line="line",e.Handle="handle"})(tt||(tt={}));function uc({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:o}){const s=e-t,a=n-i,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&o&&(c[1]=c[1]*-1),c}function xi(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function Pe(e,t){return Math.max(0,t-e)}function Ie(e,t){return Math.max(0,e-t)}function Lt(e,t,n){return Math.max(0,t-e,e-n)}function Ei(e,t){return e?!t:t}function dc(e,t,n,i,r,o,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:l,isVertical:d}=t,h=l&&d,{xSnapped:f,ySnapped:g}=n,{minWidth:y,maxWidth:m,minHeight:v,maxHeight:w}=i,{x:p,y:b,width:S,height:x,aspectRatio:C}=e;let k=Math.floor(l?f-e.pointerX:0),N=Math.floor(d?g-e.pointerY:0);const G=S+(c?-k:k),E=x+(u?-N:N),_=-o[0]*S,I=-o[1]*x;let M=Lt(G,y,m),P=Lt(E,v,w);if(s){let R=0,T=0;c&&k<0?R=Pe(p+k+_,s[0][0]):!c&&k>0&&(R=Ie(p+G+_,s[1][0])),u&&N<0?T=Pe(b+N+I,s[0][1]):!u&&N>0&&(T=Ie(b+E+I,s[1][1])),M=Math.max(M,R),P=Math.max(P,T)}if(a){let R=0,T=0;c&&k>0?R=Ie(p+k,a[0][0]):!c&&k<0&&(R=Pe(p+G,a[1][0])),u&&N>0?T=Ie(b+N,a[0][1]):!u&&N<0&&(T=Pe(b+E,a[1][1])),M=Math.max(M,R),P=Math.max(P,T)}if(r){if(l){const R=Lt(G/C,v,w)*C;if(M=Math.max(M,R),s){let T=0;!c&&!u||c&&!u&&h?T=Ie(b+I+G/C,s[1][1])*C:T=Pe(b+I+(c?k:-k)/C,s[0][1])*C,M=Math.max(M,T)}if(a){let T=0;!c&&!u||c&&!u&&h?T=Pe(b+G/C,a[1][1])*C:T=Ie(b+(c?k:-k)/C,a[0][1])*C,M=Math.max(M,T)}}if(d){const R=Lt(E*C,y,m)/C;if(P=Math.max(P,R),s){let T=0;!c&&!u||u&&!c&&h?T=Ie(p+E*C+_,s[1][0])/C:T=Pe(p+(u?N:-N)*C+_,s[0][0])/C,P=Math.max(P,T)}if(a){let T=0;!c&&!u||u&&!c&&h?T=Pe(p+E*C,a[1][0])/C:T=Ie(p+(u?N:-N)*C,a[0][0])/C,P=Math.max(P,T)}}}N=N+(N<0?P:-P),k=k+(k<0?M:-M),r&&(h?G>E*C?N=(Ei(c,u)?-k:k)/C:k=(Ei(c,u)?-N:N)*C:l?(N=k/C,u=c):(k=N*C,c=u));const B=c?p+k:p,$=u?b+N:b;return{width:S+(c?-k:k),height:x+(u?-N:N),x:o[0]*k*(c?-1:1)+B,y:o[1]*N*(u?-1:1)+$}}const Zr={width:0,height:0,x:0,y:0},lc={...Zr,pointerX:0,pointerY:0,aspectRatio:1};function hc(e){return[[0,0],[e.measured.width,e.measured.height]]}function fc(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,o=e.measured.width??0,s=e.measured.height??0,a=n[0]*o,c=n[1]*s;return[[i-a,r-c],[i+o-a,r+s-c]]}function gc({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const o=Wt(e);let s={controlDirection:xi("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:l,keepAspectRatio:d,resizeDirection:h,onResizeStart:f,onResize:g,onResizeEnd:y,shouldResize:m}){let v={...Zr},w={...lc};s={boundaries:l,resizeDirection:h,keepAspectRatio:d,controlDirection:xi(u)};let p,b=null,S=[],x,C,k,N=!1;const G=vr().on("start",E=>{const{nodeLookup:_,transform:I,snapGrid:M,snapToGrid:P,nodeOrigin:B,paneDomNode:$}=n();if(p=_.get(t),!p)return;b=($==null?void 0:$.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:T}=yt(E.sourceEvent,{transform:I,snapGrid:M,snapToGrid:P,containerBounds:b});v={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},w={...v,pointerX:R,pointerY:T,aspectRatio:v.width/v.height},x=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(x=_.get(p.parentId),C=x&&p.extent==="parent"?hc(x):void 0),S=[],k=void 0;for(const[U,z]of _)if(z.parentId===t&&(S.push({id:U,position:{...z.position},extent:z.extent}),z.extent==="parent"||z.expandParent)){const F=fc(z,p,z.origin??B);k?k=[[Math.min(F[0][0],k[0][0]),Math.min(F[0][1],k[0][1])],[Math.max(F[1][0],k[1][0]),Math.max(F[1][1],k[1][1])]]:k=F}f==null||f(E,{...v})}).on("drag",E=>{const{transform:_,snapGrid:I,snapToGrid:M,nodeOrigin:P}=n(),B=yt(E.sourceEvent,{transform:_,snapGrid:I,snapToGrid:M,containerBounds:b}),$=[];if(!p)return;const{x:R,y:T,width:U,height:z}=v,F={},V=p.origin??P,{width:q,height:J,x:te,y:ne}=dc(w,s.controlDirection,B,s.boundaries,s.keepAspectRatio,V,C,k),j=q!==U,Q=J!==z,ie=te!==R&&j,ee=ne!==T&&Q;if(!ie&&!ee&&!j&&!Q)return;if((ie||ee||V[0]===1||V[1]===1)&&(F.x=ie?te:v.x,F.y=ee?ne:v.y,v.x=F.x,v.y=F.y,S.length>0)){const ce=te-R,oe=ne-T;for(const ge of S)ge.position={x:ge.position.x-ce+V[0]*(q-U),y:ge.position.y-oe+V[1]*(J-z)},$.push(ge)}if((j||Q)&&(F.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?q:v.width,F.height=Q&&(!s.resizeDirection||s.resizeDirection==="vertical")?J:v.height,v.width=F.width,v.height=F.height),x&&p.expandParent){const ce=V[0]*(F.width??0);F.x&&F.x<ce&&(v.x=ce,w.x=w.x-(F.x-ce));const oe=V[1]*(F.height??0);F.y&&F.y<oe&&(v.y=oe,w.y=w.y-(F.y-oe))}const K=uc({width:v.width,prevWidth:U,height:v.height,prevHeight:z,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),Z={...v,direction:K};(m==null?void 0:m(E,Z))!==!1&&(N=!0,g==null||g(E,Z),i(F,$))}).on("end",E=>{N&&(y==null||y(E,{...v}),r==null||r({...v}),N=!1)});o.call(G)}function c(){o.on(".drag",null)}return{update:a,destroy:c}}const Kt=D.createContext(null),pc=Kt.Provider,Kr=Ne.error001();function re(e,t){const n=D.useContext(Kt);if(n===null)throw new Error(Kr);return ga(n,e,t)}function de(){const e=D.useContext(Kt);if(e===null)throw new Error(Kr);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Si={display:"none"},mc={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},qr="react-flow__node-desc",Qr="react-flow__edge-desc",yc="react-flow__aria-live",vc=e=>e.ariaLiveMessage,wc=e=>e.ariaLabelConfig;function bc({rfId:e}){const t=re(vc);return A.jsx("div",{id:`${yc}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mc,children:t})}function xc({rfId:e,disableKeyboardA11y:t}){const n=re(wc);return A.jsxs(A.Fragment,{children:[A.jsx("div",{id:`${qr}-${e}`,style:Si,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),A.jsx("div",{id:`${Qr}-${e}`,style:Si,children:n["edge.a11yDescription.default"]}),!t&&A.jsx(bc,{rfId:e})]})}const qt=D.forwardRef(({position:e="top-left",children:t,className:n,style:i,...r},o)=>{const s=`${e}`.split("-");return A.jsx("div",{className:he(["react-flow__panel",n,...s]),style:i,ref:o,...r,children:t})});qt.displayName="Panel";function Ec({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:A.jsx(qt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:A.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Sc=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},Mt=e=>e.id;function Cc(e,t){return ue(e.selectedNodes.map(Mt),t.selectedNodes.map(Mt))&&ue(e.selectedEdges.map(Mt),t.selectedEdges.map(Mt))}function _c({onSelectionChange:e}){const t=de(),{selectedNodes:n,selectedEdges:i}=re(Sc,Cc);return D.useEffect(()=>{const r={nodes:n,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(o=>o(r))},[n,i,e]),null}const Nc=e=>!!e.onSelectionChangeHandlers;function Ac({onSelectionChange:e}){const t=re(Nc);return e||t?A.jsx(_c,{onSelectionChange:e}):null}const kn=typeof window<"u"?D.useLayoutEffect:D.useEffect,Jr=[0,0],Tc={x:0,y:0,zoom:1},kc=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Ci=[...kc,"rfId"],Rc=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),_i={translateExtent:wt,nodeOrigin:Jr,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Dc(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=re(Rc,ue),u=de();kn(()=>(c(e.defaultNodes,e.defaultEdges),()=>{l.current=_i,a()}),[]);const l=D.useRef(_i);return kn(()=>{for(const d of Ci){const h=e[d],f=l.current[d];h!==f&&(typeof e[d]>"u"||(d==="nodes"?t(h):d==="edges"?n(h):d==="minZoom"?i(h):d==="maxZoom"?r(h):d==="translateExtent"?o(h):d==="nodeExtent"?s(h):d==="ariaLabelConfig"?u.setState({ariaLabelConfig:Na(h)}):d==="fitView"?u.setState({fitViewQueued:h}):d==="fitViewOptions"?u.setState({fitViewOptions:h}):u.setState({[d]:h})))}l.current=e},Ci.map(d=>e[d])),null}function Ni(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Lc(e){var i;const[t,n]=D.useState(e==="system"?null:e);return D.useEffect(()=>{if(e!=="system"){n(e);return}const r=Ni(),o=()=>n(r!=null&&r.matches?"dark":"light");return o(),r==null||r.addEventListener("change",o),()=>{r==null||r.removeEventListener("change",o)}},[e]),t!==null?t:(i=Ni())!=null&&i.matches?"dark":"light"}const Ai=typeof document<"u"?document:null;function St(e=null,t={target:Ai,actInsideInputWithModifier:!0}){const[n,i]=D.useState(!1),r=D.useRef(!1),o=D.useRef(new Set([])),[s,a]=D.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,j as e,c2 as Ye,aG as Ze,cd as Je,aV as Ve,ce as es,c7 as ss,c5 as Ce,bO as Ie,cf as Pe,cg as as,aK as De,ch as ts,ci as rs,cj as is,ck as ns}from"./vendor-Dnkkx2co.js";import{R as Le,P as Se,O as Te,C as He,T as Ee,D as Ae,a as Be}from"./ui-C1iwpj2-.js";import{j as ls,i as me,k as ge}from"./state-vCcAT5Hq.js";import{E as os}from"./entity-note-count-link-RzBB6ujx.js";import{N as ds}from"./note-markdown-BzK2Qlgr.js";import{Q as cs,$ as us,F as b,I as q,T as ve,a0 as ms,a1 as gs,j as oe,b as F,u as xs,a2 as hs,s as bs,a3 as vs,a4 as ps,a5 as fs,a6 as ks,a7 as xe,a8 as ys,B as L,V as Fe,C as A,h as U,d as Me,a as js,_ as ws,Z as P,U as _s,c as v,a9 as Ns,aa as Cs,ab as Ke,ac as Is,ad as Ps,O as Ds}from"./index-EqQsXoat.js";import{u as Ls,p as Ss}from"./use-psyche-focus-target-Ct-acS9G.js";import{P as Ts}from"./page-hero-ffKzgyW3.js";import{S as Hs}from"./select-menu-DJsCG6rM.js";import{f as Es}from"./date-keys-Cj1G3TOn.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const he={title:"",description:"",status:"active",userId:null,polarity:"positive",frequency:"daily",targetCount:1,weekDays:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedValueIds:[],linkedPatternIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedReportIds:[],linkedBehaviorId:"",rewardXp:12,penaltyXp:8,generatedHealthEventTemplate:{enabled:!1,workoutType:"workout",title:"",durationMinutes:45,xpReward:0,tags:[],links:[],notesTemplate:""}},As=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}];function Bs(s){return{title:s.title,description:s.description,status:s.status,userId:s.userId??null,polarity:s.polarity,frequency:s.frequency,targetCount:s.targetCount,weekDays:s.weekDays,linkedGoalIds:s.linkedGoalIds,linkedProjectIds:s.linkedProjectIds,linkedTaskIds:s.linkedTaskIds,linkedValueIds:s.linkedValueIds,linkedPatternIds:s.linkedPatternIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedBeliefIds:s.linkedBeliefIds,linkedModeIds:s.linkedModeIds,linkedReportIds:s.linkedReportIds,linkedBehaviorId:s.linkedBehaviorId??"",rewardXp:s.rewardXp,penaltyXp:s.penaltyXp,generatedHealthEventTemplate:s.generatedHealthEventTemplate}}function Fs({open:s,pending:o=!1,editingHabit:d,values:f,patterns:k,behaviors:T,beliefs:c,modes:y,reports:m,goals:j,projects:H,tasks:D,users:M,defaultUserId:w=null,onOpenChange:N,onSubmit:E}){const[R,S]=p.useState(he),[te,K]=p.useState(null),[C,Z]=p.useState({});p.useEffect(()=>{s&&(S(d?Bs(d):{...he,userId:w}),K(null),Z({}))},[w,d,s]);const O=M.find(r=>r.id===w)??null,z=p.useMemo(()=>T.slice().sort((r,i)=>r.title.localeCompare(i.title)),[T]),I=r=>({linkedBehaviorIds:r,linkedBehaviorId:r[0]??""}),_=(r,i)=>r.includes(i)?r.filter(t=>t!==i):[...r,i],G=[{id:"intent",eyebrow:"Habit",title:"Name the recurring move",description:"Use habits for recurring commitments and recurring slips. Keep the title concrete so the daily check-in never needs interpretation.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Title",error:C.title??null,children:e.jsx(q,{value:r.title,onChange:t=>i({title:t.target.value}),placeholder:"Train lower body"})}),e.jsx(b,{label:"Description",children:e.jsx(ve,{value:r.description,onChange:t=>i({description:t.target.value}),placeholder:"Write the habit description in Markdown. Define what counts, edge cases, and examples."})}),e.jsx(ms,{value:r.userId,users:M,onChange:t=>i({userId:t}),label:"Owner user",defaultLabel:gs(O),help:"Habits can be owned by humans or bots. When one scoped user is active, Forge uses that as the default."})]})},{id:"shape",eyebrow:"Shape",title:"Set direction and cadence",description:"Forge uses polarity to decide whether doing the habit is good or bad, and cadence to know when it should show up.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Polarity",children:e.jsx(oe,{value:r.polarity,onChange:t=>i({polarity:t}),options:[{value:"positive",label:"Positive",description:"Doing it is aligned and should award XP."},{value:"negative",label:"Negative",description:"Doing it is a slip and should cost XP."}],columns:2})}),e.jsx(b,{label:"Frequency",children:e.jsx(oe,{value:r.frequency,onChange:t=>i({frequency:t}),options:[{value:"daily",label:"Daily",description:"Track against each day."},{value:"weekly",label:"Weekly",description:"Track only on the selected weekdays."}],columns:2})}),r.frequency==="weekly"?e.jsx(b,{label:"Weekdays",error:C.weekDays??null,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:As.map(t=>{const n=r.weekDays.includes(t.value);return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${n?"border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>i({weekDays:n?r.weekDays.filter(J=>J!==t.value):[...r.weekDays,t.value].sort()}),children:t.label},t.value)})})}):null,e.jsx(b,{label:"Status",children:e.jsx(oe,{value:r.status,onChange:t=>i({status:t}),options:[{value:"active",label:"Active",description:"Show it in the daily operating flow."},{value:"paused",label:"Paused",description:"Keep it visible but not currently due."},{value:"archived",label:"Archived",description:"Keep the record but retire it from active work."}]})})]})},{id:"generation",eyebrow:"Generation",title:"Decide whether this habit should create a workout record",description:"Use this when a completed habit should generate a structured sports or recovery session in Forge, then reconcile with HealthKit later if the same session gets imported.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Generate workout record",children:e.jsx(oe,{value:r.generatedHealthEventTemplate.enabled?"enabled":"disabled",onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,enabled:t==="enabled"}}),options:[{value:"disabled",label:"Disabled",description:"This habit only affects the habit ledger."},{value:"enabled",label:"Enabled",description:"A completed check-in creates a workout or recovery session."}],columns:2})}),r.generatedHealthEventTemplate.enabled?e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Workout type",children:e.jsx(q,{value:r.generatedHealthEventTemplate.workoutType,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,workoutType:t.target.value}}),placeholder:"mobility, walk, strength, recovery"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(b,{label:"Duration (minutes)",children:e.jsx(q,{type:"number",min:1,max:1440,value:r.generatedHealthEventTemplate.durationMinutes,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,durationMinutes:Number(t.target.value)||45}})})}),e.jsx(b,{label:"Workout XP",children:e.jsx(q,{type:"number",min:0,max:500,value:r.generatedHealthEventTemplate.xpReward,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,xpReward:Number(t.target.value)||0}})})})]}),e.jsx(b,{label:"Generated session note",children:e.jsx(ve,{value:r.generatedHealthEventTemplate.notesTemplate,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,notesTemplate:t.target.value}}),placeholder:"Morning routine session generated from habit completion."})})]}):null]})},{id:"links",eyebrow:"Links",title:"Connect the habit to real Forge work",description:"Link habits to the goals, projects, and tasks they support so they stay anchored in the same operating graph as everything else.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Goals",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(t=>{const n=r.linkedGoalIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedGoalIds:_(r.linkedGoalIds,t.id)}),children:e.jsx(F,{kind:"goal",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Projects",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:H.map(t=>{const n=r.linkedProjectIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedProjectIds:_(r.linkedProjectIds,t.id)}),children:e.jsx(F,{kind:"project",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Tasks",children:e.jsx("div",{className:"flex max-h-48 flex-wrap gap-2 overflow-y-auto",children:D.map(t=>{const n=r.linkedTaskIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedTaskIds:_(r.linkedTaskIds,t.id)}),children:e.jsx(F,{kind:"task",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Values",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(t=>{const n=r.linkedValueIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedValueIds:_(r.linkedValueIds,t.id)}),children:e.jsx(F,{kind:"value",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Patterns",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:k.map(t=>{const n=r.linkedPatternIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedPatternIds:_(r.linkedPatternIds,t.id)}),children:e.jsx(F,{kind:"pattern",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})})]})},{id:"reward",eyebrow:"Reward",title:"Link the behavior and XP logic",description:"Habits can point back to a Psyche behavior. Reward XP is granted for aligned outcomes; penalty XP is applied for misaligned ones.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Linked behavior",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:z.map(t=>{const n=r.linkedBehaviorIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i(I(_(r.linkedBehaviorIds,t.id))),children:e.jsx(F,{kind:"behavior",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Beliefs",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:c.map(t=>{const n=r.linkedBeliefIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedBeliefIds:_(r.linkedBeliefIds,t.id)}),children:e.jsx(F,{kind:"belief",label:t.statement,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Modes",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:y.map(t=>{const n=r.linkedModeIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedModeIds:_(r.linkedModeIds,t.id)}),children:e.jsx(F,{kind:"mode",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Reports",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:m.map(t=>{const n=r.linkedReportIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedReportIds:_(r.linkedReportIds,t.id)}),children:e.jsx(F,{kind:"report",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(b,{label:"Target count",error:C.targetCount??null,children:e.jsx(q,{type:"number",value:r.targetCount,onChange:t=>i({targetCount:Number(t.target.value)||1})})}),e.jsx(b,{label:"Reward XP",error:C.rewardXp??null,children:e.jsx(q,{type:"number",value:r.rewardXp,onChange:t=>i({rewardXp:Number(t.target.value)||1})})}),e.jsx(b,{label:"Penalty XP",error:C.penaltyXp??null,children:e.jsx(q,{type:"number",value:r.penaltyXp,onChange:t=>i({penaltyXp:Number(t.target.value)||1})})})]})]})}];return e.jsx(cs,{open:s,onOpenChange:N,eyebrow:"Habit",title:d?"Edit habit":"Create habit",description:"Habits are recurring commitments or recurring slips with explicit XP consequences.",value:R,onChange:S,draftPersistenceKey:d?`habit.${d.id}`:"habit.new",steps:G,pending:o,pendingLabel:d?"Save habit":"Create habit",submitLabel:d?"Save habit":"Create habit",error:te,onSubmit:async()=>{K(null);const r=us.safeParse(R);if(!r.success){Z(Object.fromEntries(Object.entries(r.error.flatten().fieldErrors).map(([i,t])=>[i,t==null?void 0:t[0]]))),K("Some habit fields still need attention.");return}Z({});try{await E(r.data,d==null?void 0:d.id),S(he),N(!1)}catch(i){K(i instanceof Error?i.message:"Habit update failed.")}}})}const Ms=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ks=["S","M","T","W","T","F","S"],Xs=[{value:"name",label:"Name A-Z",description:"Keep the list stable alphabetically."},{value:"needs_attention",label:"Needs attention",description:"Bubble up habits still waiting on today."},{value:"streak",label:"Longest streak",description:"Put the strongest current streaks first."},{value:"created_at",label:"Newest created",description:"Show the most recently created habits first."},{value:"updated_at",label:"Recently updated",description:"Sort by the most recently changed habits."}];function Rs(s){return s.frequency==="daily"?`${s.targetCount}x daily`:`${s.targetCount}x weekly · ${s.weekDays.map(o=>Ms[o]).join(", ")}`}function W(s){return Es(s)}function ze(s){const[o,d,f]=s.split("-").map(Number);return new Date(o,d-1,f)}function $e(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate())}function de(s,o){const d=new Date(s);return d.setDate(d.getDate()+o),d}function Xe(s){const o=$e(s),d=(o.getDay()+6)%7;return o.setDate(o.getDate()-d),o}function ee(s){const o=typeof s=="string"?ze(s):s;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(o)}function ue(s,o){return s.polarity==="positive"&&o==="done"||s.polarity==="negative"&&o==="missed"}function pe(s,o){return s.polarity==="positive"?o==="done"?"Done":"Missed":o==="done"?"Performed":"Resisted"}function qe(s){const o=W(new Date),d=s.checkIns.find(f=>f.dateKey===o)??null;return s.dueToday?{tone:"pending",label:s.frequency==="daily"?"Waiting for today":"Awaiting this week's check-in",cardClass:"border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--warning)_18%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"}:d?ue(s,d.status)?{tone:"aligned",label:`${pe(s,d.status)} today`,cardClass:"border-[color-mix(in_srgb,var(--success)_24%,var(--ui-border-subtle)_76%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--success)_16%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]"}:{tone:"unaligned",label:`${pe(s,d.status)} today`,cardClass:"border-[color-mix(in_srgb,var(--danger)_24%,var(--ui-border-subtle)_76%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--danger)_16%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]"}:s.polarity==="positive"?{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--success)_9%,transparent),transparent_40%)]",pillClass:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"}:{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--danger)_9%,transparent),transparent_40%)]",pillClass:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"}}function Os(s){return s>=10?{Icon:ts,className:"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Celebration pace"}:s>=5?{Icon:rs,className:"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Locked in"}:s>=1?{Icon:is,className:"border border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Building rhythm"}:{Icon:ns,className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[var(--ui-ink-soft)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Cold start"}}function zs(s){return s>=80?"border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":s>=50?"border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]"}const se="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Re="border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",Oe="border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",ce="border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",be="border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",ae="border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] text-[color-mix(in_srgb,var(--primary)_72%,var(--ui-ink-strong)_28%)]";function $s(s){var T;const o=new Date;if(s.frequency==="daily"){const c=$e(o),y=[];for(let m=-6;m<=0;m+=1){const j=de(c,m),H=W(j),D=s.checkIns.find(N=>N.dateKey===H)??null,M=Ks[j.getDay()],w=m===0;y.push({id:H,label:M,current:w,actionDateKey:H,actionLabel:ee(j),state:D?ue(s,D.status)?"aligned":"unaligned":"unknown",title:`${ee(j)} · ${D?pe(s,D.status):"Not informed"}`})}return{caption:"7-day rhythm",rangeLabel:"Past 7 days",showLabels:!0,startLabel:"",endLabel:"",cells:y}}const d=Xe(o),f=new Map;for(const c of s.checkIns){const y=W(Xe(ze(c.dateKey))),m=f.get(y)??[];m.push(c),f.set(y,m)}const k=[];for(let c=-6;c<=0;c+=1){const y=de(d,c*7),m=W(y),j=f.get(m)??[],H=s.weekDays.length>0?[...s.weekDays].sort((E,R)=>R-E)[0]:0,D=W(de(y,H)),M=((T=j[0])==null?void 0:T.dateKey)??D,w=j.filter(E=>ue(s,E.status)).length,N=j.length-w;k.push({id:m,label:"",current:c===0,actionDateKey:M,actionLabel:`Week of ${ee(y)}`,state:j.length===0?"unknown":w>=N?"aligned":"unaligned",title:`${ee(y)} week · ${j.length===0?"Not informed":w>=N?"Mostly aligned":"Mostly off track"}`})}return{caption:"7-week rhythm",rangeLabel:"Past 7 weeks",showLabels:!1,startLabel:ee(de(d,-42)),endLabel:"This week",cells:k}}function qs(s,o){return P("h-8 w-full rounded-[10px] border transition",s==="aligned"&&"border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[color-mix(in_srgb,var(--success)_58%,var(--ui-surface-1)_42%)] shadow-[var(--ui-shadow-soft)]",s==="unaligned"&&"border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[color-mix(in_srgb,var(--danger)_54%,var(--ui-surface-1)_46%)] shadow-[var(--ui-shadow-soft)]",s==="unknown"&&"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",o&&"ring-1 ring-[color-mix(in_srgb,var(--primary)_34%,transparent)]")}function Ws({habit:s,onSelectCell:o}){const d=$s(s),f=qe(s);return e.jsxs("div",{className:"w-full rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2.5 shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:d.caption}),e.jsx("div",{className:"text-[11px] text-[var(--ui-ink-soft)]",children:d.rangeLabel})]}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:d.cells.map(k=>e.jsxs("button",{type:"button",className:"group flex min-w-0 flex-1 items-center gap-1 rounded-[10px] transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>o(s,k),title:`Log check-in for ${k.actionLabel}`,"aria-label":`Log check-in for ${k.actionLabel}`,children:[e.jsx("div",{className:P(qs(k.state,k.current),"h-6 min-w-0 flex-1 rounded-[8px] transition duration-150 group-hover:-translate-y-0.5 group-hover:shadow-[var(--ui-shadow-soft)]")}),d.showLabels?e.jsx("span",{className:"hidden text-[9px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)] transition group-hover:text-[var(--ui-ink-medium)] sm:inline",children:k.label}):null]},k.id))}),e.jsx("div",{className:P("shrink-0 rounded-full px-2.5 py-1 text-[10px] font-medium",f.pillClass),children:f.label})]}),d.showLabels?null:e.jsxs("div",{className:"mt-1 text-right text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:[d.startLabel," - ",d.endLabel]})]})}function Gs(s){return s.polarity==="positive"?{alignedLabel:"Done",alignedDescription:"Log that the intended habit happened.",unalignedLabel:"Missed",unalignedDescription:"Log that the habit did not happen."}:{alignedLabel:"Resisted",alignedDescription:"Log that the unwanted behavior was resisted.",unalignedLabel:"Performed",unalignedDescription:"Log that the unwanted behavior happened."}}function Q(s,o){return s.polarity==="positive"?o==="aligned"?"done":"missed":o==="aligned"?"missed":"done"}function Y(s,o){return ue(s,o)?"aligned":"unaligned"}function oa(){var ke,ye,je,we,_e,Ne;const s=xs(),o=ls(),[d,f]=Ye(),[k,T]=p.useState(null),[c,y]=p.useState(null),[m,j]=p.useState(null),[H,D]=p.useState(""),[M,w]=p.useState(!1),[N,E]=p.useState(null),[R,S]=p.useState(null),te=d.get("focus"),K=d.get("orderBy")??"name",C=hs(s.selectedUserIds),Z=bs(C),O=["forge-habits",K,...C];Ls(te);const z=me({queryKey:O,queryFn:async()=>(await Is({userIds:C,orderBy:K})).habits}),I=me({queryKey:["forge-psyche-overview",...C],queryFn:async()=>(await Ps(C)).overview}),_=me({queryKey:["forge-life-force",...C],queryFn:async()=>(await Ds(C)).lifeForce});p.useEffect(()=>{d.get("create")==="1"&&(T(null),w(!0),f(a=>{const h=new URLSearchParams(a);return h.delete("create"),h},{replace:!0}))},[d,f]);const G=async()=>{await o.invalidateQueries({queryKey:["forge-habits"]}),await s.refresh()},r=ge({mutationFn:async({input:a,habitId:h})=>h?(await vs(h,a)).habit:(await ps(a)).habit,onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit save failed.")}}),i=ge({mutationFn:async({habitId:a,status:h,dateKey:u,note:$})=>fs(a,{status:h,dateKey:u,note:$}),onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit check-in failed.")}}),t=ge({mutationFn:async a=>ks(a),onMutate:async a=>{await o.cancelQueries({queryKey:O});const h=o.getQueryData(O);return o.setQueryData(O,u=>(u==null?void 0:u.filter($=>$.id!==a))??[]),{previousHabits:h}},onSuccess:async()=>{S(null),E(null),await G()},onError:(a,h,u)=>{u!=null&&u.previousHabits&&o.setQueryData(O,u.previousHabits),S(a instanceof Error?a.message:"Habit delete failed.")}}),n=p.useMemo(()=>(z.data??[]).filter(a=>a.status!=="archived"),[z.data]),J=p.useMemo(()=>n.filter(a=>a.dueToday),[n]),We=p.useMemo(()=>J.reduce((a,h)=>{var re;const u=Ke().totalAp,$=((re=xe(h))==null?void 0:re.totalAp)??0;return a+u+$},0),[J]),Ge=p.useMemo(()=>n.reduce((a,h)=>{var u;return a+(((u=xe(h))==null?void 0:u.totalAp)??0)},0),[n]),X=p.useMemo(()=>c?c.habit.checkIns.find(a=>a.dateKey===c.cell.actionDateKey)??null:null,[c]);if(p.useEffect(()=>{if(!c){j(null),D("");return}j((X==null?void 0:X.status)??null),D((X==null?void 0:X.note)??"")},[c,X]),z.error)throw z.error;const Ue=a=>{f(h=>{const u=new URLSearchParams(h);return a==="name"?u.delete("orderBy"):u.set("orderBy",a),u},{replace:!0})},V=c?Gs(c.habit):null,fe=m==="done"||m==="missed"||X!==null;return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ts,{entityKind:"habit",title:e.jsx(Fe,{kind:"habit",label:"Habits",variant:"heading",size:"lg"}),titleText:"Habits",description:"Habits track recurring commitments and recurring slips with explicit daily consequences, linked behaviors, and real XP movement.",badge:`${n.length} habits`,actions:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(ys,{metrics:s.snapshot.metrics}),e.jsxs(L,{onClick:()=>{T(null),w(!0)},children:[e.jsx(Ze,{className:"size-4"}),"New habit"]})]})}),R?e.jsx(A,{className:"border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Je,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("div",{children:R})]})}):null,e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--warning)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Due today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:J.length}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habits that still need a check-in today."})]}),e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--primary)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Habit AP due"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:U(We)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Default Action Point load if every due habit is logged today."})]}),e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--success)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Best streak"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:Math.max(0,...n.map(a=>a.streakCount))}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Longest current aligned streak across active habits."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Average alignment"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:[n.length>0?Math.round(n.reduce((a,h)=>a+h.completionRate,0)/n.length):0,"%"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Share of recent habit check-ins that matched the intended direction."})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Life Force sync"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:_.data?`${U(_.data.spentTodayAp)} / ${U(_.data.dailyBudgetAp)}`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habit check-ins debit the same Action Point ledger as work, notes, movement, and workouts."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Instant headroom"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:_.data?Me(_.data.instantFreeApPerHour):"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Use this to tell whether now is a good moment for heavier habits or just a light check-in."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Workout-linked load"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:U(Ge)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habit-generated workout templates stay visible as Action Point cost instead of hiding behind the XP reward."})]})]}),z.isLoading?e.jsx(A,{children:"Loading habits..."}):n.length===0?e.jsx(js,{eyebrow:"Habits",title:"No recurring habits yet",description:"Create the recurring commitments or recurring slips you want Forge to track explicitly. Positive habits pay out when completed. Negative habits invert that logic.",action:e.jsx(L,{onClick:()=>{T(null),w(!0)},children:"Create habit"})}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 shadow-[var(--ui-shadow-soft)] sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"max-w-xl",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Habit list order"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Choose a stable ordering so the list does not reshuffle while you are logging check-ins."})]}),e.jsx(Hs,{label:"Order by",value:K,options:Xs,onChange:Ue,className:"w-full sm:w-[19rem]"})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:n.map(a=>{const h=qe(a),u=Os(a.streakCount),$=u.Icon,re=Ke(),ie=xe(a),Qe=ws(s.snapshot.dashboard.notesSummaryByEntity,"habit",a.id).count,ne=a.polarity==="positive"?{label:"Done",status:Q(a,"aligned"),Icon:Ie,className:"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--success)_24%,var(--ui-surface-hover)_76%)]"}:{label:"Resisted",status:Q(a,"aligned"),Icon:Ce,className:"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--success)_24%,var(--ui-surface-hover)_76%)]"},le=a.polarity==="positive"?{label:"Missed",status:Q(a,"unaligned"),Icon:Pe,className:"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]"}:{label:"Performed",status:Q(a,"unaligned"),Icon:as,className:"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]"};return e.jsxs(A,{className:P("relative flex h-full flex-col overflow-hidden",h.cardClass,Ss(te===a.id)),"data-psyche-focus-id":a.id,children:[e.jsx("div",{className:P("pointer-events-none absolute inset-0 opacity-100",h.overlayClass)}),e.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{kind:"habit",label:a.title,variant:"heading",size:"sm"}),e.jsx(_s,{user:a.user,compact:!0}),e.jsx(v,{className:se,children:a.status}),e.jsxs(v,{className:se,children:[e.jsx(Ve,{className:"mr-1 size-3.5"}),Rs(a)]}),e.jsx(v,{className:a.polarity==="positive"?Re:Oe,children:a.polarity==="positive"?"Positive":"Negative"}),a.dueToday?e.jsx(v,{className:ce,children:"Needs check-in"}):null,a.linkedGoalIds.slice(0,1).map(g=>{const l=s.snapshot.goals.find(x=>x.id===g);return l?e.jsxs(v,{className:ce,children:["Goal · ",l.title]},l.id):null}),a.linkedProjectIds.slice(0,1).map(g=>{const l=s.snapshot.dashboard.projects.find(x=>x.id===g);return l?e.jsxs(v,{className:be,children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(0,1).map(g=>{const l=s.snapshot.tasks.find(x=>x.id===g);return l?e.jsxs(v,{className:ae,children:["Task · ",l.title]},l.id):null})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:a.description?e.jsx(ds,{markdown:a.description,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):"No extra notes yet."})]}),e.jsxs("div",{className:"ml-auto inline-flex shrink-0 flex-col items-end gap-2 self-start text-right",children:[e.jsxs("div",{className:P("inline-flex flex-col self-end rounded-[20px] px-3 py-2.5 text-right",u.className),children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5 text-[10px] uppercase tracking-[0.16em]",children:[e.jsx("span",{children:"Streak"}),e.jsx($,{className:P("size-3.5 shrink-0",u.iconClass)})]}),e.jsx("div",{className:P("mt-1.5 font-display text-[2.75rem] leading-none",u.valueClass),children:a.streakCount}),e.jsx("div",{className:"mt-1 text-[11px] leading-tight text-[var(--ui-ink-soft)]",children:u.label})]}),e.jsxs("div",{className:"ml-auto grid grid-cols-2 gap-1.5",children:[e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:r.isPending,onClick:()=>{T(a),w(!0)},"aria-label":`Edit ${a.title}`,title:"Edit habit",children:e.jsx(es,{className:"size-4"})}),e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:t.isPending,onClick:()=>E(a),"aria-label":`Delete ${a.title}`,title:"Delete habit",children:e.jsx(ss,{className:"size-4"})})]})]})]}),e.jsxs("div",{className:"mt-auto grid gap-4 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(v,{className:P("",zs(a.completionRate)),children:["Alignment ",a.completionRate,"%"]}),e.jsx(v,{className:se,children:a.polarity==="positive"?`+${a.rewardXp} XP done`:`+${a.rewardXp} XP resisted`}),e.jsx(v,{className:se,children:a.polarity==="positive"?`-${a.penaltyXp} XP missed`:`-${a.penaltyXp} XP performed`}),e.jsxs(v,{className:ae,children:[U(re.totalAp)," check-in"]}),ie?e.jsxs(v,{className:ce,children:[U(ie.totalAp)," ","workout"]}):null,ie?e.jsx(v,{className:se,children:Me(ie.rateApPerHour)}):null,e.jsx(os,{entityType:"habit",entityId:a.id,count:Qe,className:"min-h-8 rounded-full border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"}),a.linkedBehaviorTitles.slice(0,2).map(g=>e.jsxs(v,{className:ce,children:[e.jsx(Ce,{className:"mr-1 size-3.5"}),g]},g)),a.linkedProjectIds.slice(1,2).map(g=>{const l=s.snapshot.dashboard.projects.find(x=>x.id===g);return l?e.jsxs(v,{className:be,children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(1,2).map(g=>{const l=s.snapshot.tasks.find(x=>x.id===g);return l?e.jsxs(v,{className:ae,children:["Task · ",l.title]},l.id):null}),a.linkedValueIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.values.find(B=>B.id===g);return l?e.jsxs(v,{className:Re,children:["Value · ",l.title]},l.id):null}),a.linkedPatternIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.patterns.find(B=>B.id===g);return l?e.jsxs(v,{className:be,children:["Pattern · ",l.title]},l.id):null}),a.linkedBeliefIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.beliefs.find(B=>B.id===g);return l?e.jsxs(v,{className:Oe,children:["Belief · ",l.statement]},l.id):null}),a.linkedModeIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.modes.find(B=>B.id===g);return l?e.jsxs(v,{className:ae,children:["Mode · ",l.title]},l.id):null}),a.linkedReportIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.reports.find(B=>B.id===g);return l?e.jsxs(v,{className:ae,children:["Report · ",l.title]},l.id):null})]}),e.jsx("div",{className:"grid gap-4",children:e.jsx(Ws,{habit:a,onSelectCell:(g,l)=>{y({habit:g,cell:l}),S(null)}})}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",ne.className),disabled:i.isPending,onClick:()=>void i.mutateAsync({habitId:a.id,status:ne.status,dateKey:W(new Date)}),children:[e.jsx(ne.Icon,{className:"size-4"}),ne.label]}),e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",le.className),disabled:i.isPending,onClick:()=>void i.mutateAsync({habitId:a.id,status:le.status,dateKey:W(new Date)}),children:[e.jsx(le.Icon,{className:"size-4"}),le.label]})]})]})]})]},a.id)})})]}),e.jsx(Fs,{open:M,pending:r.isPending,editingHabit:k,values:((ke=I.data)==null?void 0:ke.values)??[],patterns:((ye=I.data)==null?void 0:ye.patterns)??[],behaviors:((je=I.data)==null?void 0:je.behaviors)??[],beliefs:((we=I.data)==null?void 0:we.beliefs)??[],modes:((_e=I.data)==null?void 0:_e.modes)??[],reports:((Ne=I.data)==null?void 0:Ne.reports)??[],goals:s.snapshot.dashboard.goals,projects:s.snapshot.dashboard.projects,tasks:s.snapshot.tasks,users:s.snapshot.users,defaultUserId:(k==null?void 0:k.userId)??Z,onOpenChange:w,onSubmit:async(a,h)=>{try{await r.mutateAsync({input:a,habitId:h})}catch(u){throw u instanceof Ns,u}}}),e.jsx(Le,{open:N!==null,onOpenChange:a=>{!a&&!t.isPending&&E(null)},children:e.jsxs(Se,{children:[e.jsx(Te,{className:"surface-overlay fixed inset-0 z-40 backdrop-blur-xl"}),e.jsxs(He,{className:"surface-modal-panel fixed inset-x-4 top-1/2 z-50 mx-auto w-[min(30rem,calc(100vw-2rem))] max-w-[30rem] -translate-y-1/2 overflow-hidden rounded-[30px] border",children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Delete habit"}),e.jsx(Ee,{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:(N==null?void 0:N.title)??"Delete this habit?"}),e.jsx(Ae,{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:"Remove this habit from Forge. The habit card disappears immediately after delete succeeds."})]}),e.jsx(Be,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-0 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close delete habit modal",title:"Close",disabled:t.isPending,children:e.jsx(De,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsx("div",{className:"rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm leading-6 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"This removes the habit and its check-in history from the habits page."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(L,{variant:"secondary",onClick:()=>E(null),disabled:t.isPending,children:"Cancel"}),e.jsx(L,{className:"border border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]",pending:t.isPending,pendingLabel:"Deleting",onClick:()=>{N&&t.mutateAsync(N.id)},children:"Delete habit"})]})]})]})]})}),e.jsx(Le,{open:c!==null,onOpenChange:a=>{a||y(null)},children:e.jsxs(Se,{children:[e.jsx(Te,{className:"surface-overlay fixed inset-0 z-40 backdrop-blur-xl"}),e.jsxs(He,{className:"surface-modal-panel fixed inset-x-4 top-1/2 z-50 mx-auto w-[min(42rem,calc(100vw-2rem))] max-w-[42rem] -translate-y-1/2 overflow-hidden rounded-[30px] border",children:[e.jsx(Ee,{className:"sr-only",children:"Habit history"}),e.jsx(Ae,{className:"sr-only",children:"Log or revise a habit check-in for a selected history point."}),c&&V?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Habit history"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:c.habit.title}),e.jsx(v,{children:c.cell.actionLabel})]}),e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:c.habit.frequency==="daily"?"Log or revise the check-in for this specific day.":"Log or revise the representative check-in for this week."})]}),e.jsx(Be,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-0 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close history modal",title:"Close",children:e.jsx(De,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("button",{type:"button","aria-pressed":m!==null&&Y(c.habit,m)==="aligned",className:P("rounded-[22px] border px-4 py-4 text-left transition",m!==null&&Y(c.habit,m)==="aligned"?"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>j(a=>a!==null&&Y(c.habit,a)==="aligned"?null:Q(c.habit,"aligned")),children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Ie,{className:"size-4"}),V.alignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:V.alignedDescription})]}),e.jsxs("button",{type:"button","aria-pressed":m!==null&&Y(c.habit,m)==="unaligned",className:P("rounded-[22px] border px-4 py-4 text-left transition",m!==null&&Y(c.habit,m)==="unaligned"?"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>j(a=>a!==null&&Y(c.habit,a)==="unaligned"?null:Q(c.habit,"unaligned")),children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Pe,{className:"size-4"}),V.unalignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:V.unalignedDescription})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Optional note"}),e.jsx(ve,{value:H,onChange:a=>D(a.target.value),placeholder:"Add context for what happened on this day or week.",className:"min-h-24"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(L,{variant:"secondary",onClick:()=>y(null),disabled:i.isPending,children:"Cancel"}),e.jsx(L,{disabled:i.isPending||!fe,pending:i.isPending,pendingLabel:"Saving",onClick:async()=>{fe&&(m===null?(await Cs(c.habit.id,c.cell.actionDateKey),await G()):await i.mutateAsync({habitId:c.habit.id,status:m,dateKey:c.cell.actionDateKey,note:H.trim()||void 0}),y(null))},children:"Save check-in"})]})]})]}):null]})]})})]})}export{oa as HabitsPage};
|