@flexkit/studio 0.2.37 → 0.2.39
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/README.md +76 -7
- package/dist/{chat-page-XYQOQPMW.js → chat-page-2ES466GO.js} +3 -3
- package/dist/{chat-page-XYQOQPMW.js.map → chat-page-2ES466GO.js.map} +1 -1
- package/dist/{chunk-6NRMVVU4.js → chunk-7FYOLFHG.js} +3 -3
- package/dist/{chunk-6NRMVVU4.js.map → chunk-7FYOLFHG.js.map} +1 -1
- package/dist/{chunk-PNGPE7QM.js → chunk-CESG6WQB.js} +3 -3
- package/dist/{chunk-PNGPE7QM.js.map → chunk-CESG6WQB.js.map} +1 -1
- package/dist/{chunk-OWY5BQER.js → chunk-DQ2OVNOB.js} +2 -2
- package/dist/{chunk-OWY5BQER.js.map → chunk-DQ2OVNOB.js.map} +1 -1
- package/dist/{chunk-KOM7G7WT.js → chunk-DR36N2JC.js} +2 -2
- package/dist/{chunk-KOM7G7WT.js.map → chunk-DR36N2JC.js.map} +1 -1
- package/dist/{chunk-36YXPN42.js → chunk-DUS2CRB3.js} +2 -2
- package/dist/{chunk-36YXPN42.js.map → chunk-DUS2CRB3.js.map} +1 -1
- package/dist/{chunk-ND2RTUMM.js → chunk-JJFOUJMQ.js} +3 -3
- package/dist/{chunk-ND2RTUMM.js.map → chunk-JJFOUJMQ.js.map} +1 -1
- package/dist/chunk-KWE3LHFM.js +10 -0
- package/dist/chunk-KWE3LHFM.js.map +1 -0
- package/dist/{chunk-CRTUZ22E.js → chunk-MGCXYA2S.js} +3 -3
- package/dist/{chunk-CRTUZ22E.js.map → chunk-MGCXYA2S.js.map} +1 -1
- package/dist/{chunk-337GX2BR.js → chunk-PR3MTHFM.js} +2 -2
- package/dist/{chunk-337GX2BR.js.map → chunk-PR3MTHFM.js.map} +1 -1
- package/dist/{chunk-RX6QUDLZ.js → chunk-R7EOMV6C.js} +3 -3
- package/dist/{chunk-RX6QUDLZ.js.map → chunk-R7EOMV6C.js.map} +1 -1
- package/dist/{chunk-DO32GATF.js → chunk-SAVZBVP5.js} +3 -3
- package/dist/{chunk-DO32GATF.js.map → chunk-SAVZBVP5.js.map} +1 -1
- package/dist/{chunk-RGISZNQ2.js → chunk-SGQMQZIW.js} +2 -2
- package/dist/{chunk-RGISZNQ2.js.map → chunk-SGQMQZIW.js.map} +1 -1
- package/dist/{chunk-AQSL5HBZ.js → chunk-TOISBMRE.js} +2 -2
- package/dist/{chunk-AQSL5HBZ.js.map → chunk-TOISBMRE.js.map} +1 -1
- package/dist/{chunk-CC2U7ASG.js → chunk-TP6QGIJH.js} +3 -3
- package/dist/{chunk-CC2U7ASG.js.map → chunk-TP6QGIJH.js.map} +1 -1
- package/dist/{chunk-U4DUXPZV.js → chunk-U3PTPLSE.js} +2 -2
- package/dist/{chunk-U4DUXPZV.js.map → chunk-U3PTPLSE.js.map} +1 -1
- package/dist/{chunk-UULPCFWK.js → chunk-VR3LFFJ3.js} +3 -3
- package/dist/{chunk-UULPCFWK.js.map → chunk-VR3LFFJ3.js.map} +1 -1
- package/dist/{chunk-BHHLWGZ4.js → chunk-WSXNYZQC.js} +2 -2
- package/dist/{chunk-BHHLWGZ4.js.map → chunk-WSXNYZQC.js.map} +1 -1
- package/dist/{chunk-XV4QJKOJ.js → chunk-Z7JAN2UW.js} +2 -2
- package/dist/{chunk-XV4QJKOJ.js.map → chunk-Z7JAN2UW.js.map} +1 -1
- package/dist/{entry-6EWYXIS5.js → entry-ZYSQFFEW.js} +2 -2
- package/dist/{entry-6EWYXIS5.js.map → entry-ZYSQFFEW.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/{list-GBM53HFN.js → list-4EXGXJZA.js} +2 -2
- package/dist/{list-GBM53HFN.js.map → list-4EXGXJZA.js.map} +1 -1
- package/dist/{list-N5W7G3LD.js → list-XTC2OYA6.js} +3 -3
- package/dist/{list-N5W7G3LD.js.map → list-XTC2OYA6.js.map} +1 -1
- package/dist/{pages-HPR3UHT7.js → pages-HW4OCENA.js} +3 -3
- package/dist/{pages-HPR3UHT7.js.map → pages-HW4OCENA.js.map} +1 -1
- package/dist/{plugin-pages-VDRT7RLY.js → plugin-pages-CUTCB6NU.js} +2 -2
- package/dist/{plugin-pages-VDRT7RLY.js.map → plugin-pages-CUTCB6NU.js.map} +1 -1
- package/dist/{project-selector-RRG52TSX.js → project-selector-Z4Q6G6GM.js} +2 -2
- package/dist/{project-selector-RRG52TSX.js.map → project-selector-Z4Q6G6GM.js.map} +1 -1
- package/dist/record-links-DBU5G6ZH.js +2 -0
- package/dist/{record-links-CI4OJPWW.js.map → record-links-DBU5G6ZH.js.map} +1 -1
- package/dist/{root-IXK2ESCS.js → root-3Q44ISGQ.js} +3 -3
- package/dist/{root-IXK2ESCS.js.map → root-3Q44ISGQ.js.map} +1 -1
- package/dist/{root-DF2BNGOF.js → root-422O7YX5.js} +3 -3
- package/dist/{root-DF2BNGOF.js.map → root-422O7YX5.js.map} +1 -1
- package/dist/{root-KF6EFGM6.js → root-7FYWXLI6.js} +3 -3
- package/dist/{root-KF6EFGM6.js.map → root-7FYWXLI6.js.map} +1 -1
- package/dist/{root-LUWJS7SQ.js → root-7NZPP7IC.js} +2 -2
- package/dist/{root-LUWJS7SQ.js.map → root-7NZPP7IC.js.map} +1 -1
- package/dist/{root-RGAV2YAF.js → root-Q6SHODPG.js} +2 -2
- package/dist/{root-RGAV2YAF.js.map → root-Q6SHODPG.js.map} +1 -1
- package/dist/{root-JFYE2JRJ.js → root-SYRZ3UBN.js} +2 -2
- package/dist/{root-JFYE2JRJ.js.map → root-SYRZ3UBN.js.map} +1 -1
- package/dist/{search-DQLC3XDJ.js → search-X7F5JZOU.js} +2 -2
- package/dist/{search-DQLC3XDJ.js.map → search-X7F5JZOU.js.map} +1 -1
- package/dist/{skills-pages-Q4YUDTC2.js → skills-pages-X3DVZXY5.js} +2 -2
- package/dist/{skills-pages-Q4YUDTC2.js.map → skills-pages-X3DVZXY5.js.map} +1 -1
- package/dist/{source-J3ZCTEWZ.js → source-43PHAELP.js} +2 -2
- package/dist/{source-J3ZCTEWZ.js.map → source-43PHAELP.js.map} +1 -1
- package/package.json +6 -6
- package/dist/chunk-ZV7I5RUM.js +0 -10
- package/dist/chunk-ZV7I5RUM.js.map +0 -1
- package/dist/record-links-CI4OJPWW.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';export{b as CatalogHeader,d as InstalledPluginsPage,a as PluginConnectControl,e as PluginDetailPage,c as PluginsPage}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=plugin-pages-
|
|
1
|
+
import'./index.css';export{b as CatalogHeader,d as InstalledPluginsPage,a as PluginConnectControl,e as PluginDetailPage,c as PluginsPage}from'./chunk-DR36N2JC.js';import'./chunk-QSTWBKPN.js';import'./chunk-L5Z56DDM.js';import'./chunk-PLCI2RJA.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-TP6QGIJH.js';import'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import'./chunk-RULCANNM.js';import'./chunk-A4DPLZZF.js';import'./chunk-G5N6HEPW.js';import'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import'./chunk-N33S7BSG.js';import'./chunk-X3SHNHHM.js';//# sourceMappingURL=plugin-pages-CUTCB6NU.js.map
|
|
2
|
+
//# sourceMappingURL=plugin-pages-CUTCB6NU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"plugin-pages-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"plugin-pages-CUTCB6NU.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {a,b,d as d$1}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=project-selector-
|
|
1
|
+
import'./index.css';import {a,b,d as d$1}from'./chunk-TOISBMRE.js';export{a as getProjectLabel}from'./chunk-TOISBMRE.js';import'./chunk-JJFOUJMQ.js';import {f}from'./chunk-TP6QGIJH.js';import'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import'./chunk-G5N6HEPW.js';import {a as a$1,d,c,e,b as b$1,f as f$1,g,h,k,p,q as q$1,s,t}from'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import'./chunk-X3SHNHHM.js';import {useState}from'react';import {useNavigate}from'react-router-dom';import {Plus}from'lucide-react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';var _="__new_project__";function q({projectId:i,projectIds:v,projectSummaries:a$2=[],projects:s$1}){let L=useNavigate(),{mode:E,teams:V}=f(),[m,r]=useState(false),p$1=a(i,s$1,a$2),J=b(v,a$2),g$1=E==="hosted";return jsxs(Fragment,{children:[jsxs(a$1,{onValueChange:o=>{if(o===_){r(true);return}L(`/${o}`);},value:i,children:[jsx(d,{className:"fk:w-48! fk:h-9 fk:py-1",id:"project",children:jsx(c,{"aria-label":p$1,children:p$1})}),jsxs(e,{children:[J.map((o,U)=>jsxs(b$1,{children:[o.label?jsx(f$1,{children:o.label}):null,o.projectIds.map(c=>jsx(g,{value:c,children:a(c,s$1,a$2)},c))]},o.label??U)),g$1?jsxs(Fragment,{children:[jsx(h,{}),jsxs(g,{value:_,children:[jsx(Plus,{className:"fk:h-4 fk:w-4"}),"New project"]})]}):null]})]}),g$1?jsx(k,{onOpenChange:r,open:m,children:jsxs(p,{className:"fk:sm:max-w-md",children:[jsxs(q$1,{children:[jsx(s,{children:"New project"}),jsx(t,{children:"Projects start on the Free plan. Start from the commerce starter, or let the AI agent design the schema with you."})]}),m?jsx(d$1,{onCancel:()=>{r(false);},onCreated:()=>{r(false);},teams:V}):null]})}):null]})}export{q as ProjectSelector};//# sourceMappingURL=project-selector-Z4Q6G6GM.js.map
|
|
2
|
+
//# sourceMappingURL=project-selector-Z4Q6G6GM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ui/components/project-selector.tsx"],"names":["NEW_PROJECT_VALUE","ProjectSelector","projectId","projectIds","projectSummaries","projects","navigate","useNavigate","mode","teams","useConfig","isCreating","setIsCreating","useState","label","getProjectLabel","groups","groupProjectIdsByTeam","canCreate","jsxs","Fragment","Select","id","jsx","SelectTrigger","SelectValue","SelectContent","group","index","SelectGroup","SelectLabel","SelectItem","SelectSeparator","Plus","Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription","NewProjectFlow"],"mappings":"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","file":"project-selector-
|
|
1
|
+
{"version":3,"sources":["../src/ui/components/project-selector.tsx"],"names":["NEW_PROJECT_VALUE","ProjectSelector","projectId","projectIds","projectSummaries","projects","navigate","useNavigate","mode","teams","useConfig","isCreating","setIsCreating","useState","label","getProjectLabel","groups","groupProjectIdsByTeam","canCreate","jsxs","Fragment","Select","id","jsx","SelectTrigger","SelectValue","SelectContent","group","index","SelectGroup","SelectLabel","SelectItem","SelectSeparator","Plus","Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription","NewProjectFlow"],"mappings":"ujBAoBA,IAAMA,CAAAA,CAAoB,iBAAA,CAcnB,SAASC,CAAAA,CAAgB,CAAE,SAAA,CAAAC,CAAAA,CAAW,UAAA,CAAAC,CAAAA,CAAY,iBAAAC,GAAAA,CAAmB,EAAC,CAAG,QAAA,CAAAC,GAAS,CAAA,CAAuB,CAC9G,IAAMC,CAAAA,CAAWC,WAAAA,EAAY,CACvB,CAAE,IAAA,CAAAC,CAAAA,CAAM,KAAA,CAAAC,CAAM,CAAA,CAAIC,CAAAA,EAAU,CAC5B,CAACC,CAAAA,CAAYC,CAAa,CAAA,CAAIC,QAAAA,CAAS,KAAK,CAAA,CAC5CC,GAAAA,CAAQC,CAAAA,CAAgBb,CAAAA,CAAWG,GAAAA,CAAUD,GAAgB,CAAA,CAC7DY,CAAAA,CAASC,CAAAA,CAAsBd,CAAAA,CAAYC,GAAgB,CAAA,CAE3Dc,GAAAA,CAAYV,CAAAA,GAAS,QAAA,CAE3B,OACEW,IAAAA,CAAAC,QAAAA,CAAA,CACE,QAAA,CAAA,CAAAD,IAAAA,CAACE,GAAAA,CAAA,CACC,aAAA,CAAgBC,CAAAA,EAAO,CACrB,GAAIA,CAAAA,GAAOtB,CAAAA,CAAmB,CAC5BY,CAAAA,CAAc,IAAI,CAAA,CAElB,MACF,CAEAN,CAAAA,CAAS,IAAIgB,CAAE,CAAA,CAAE,EACnB,CAAA,CACA,KAAA,CAAOpB,CAAAA,CAEP,QAAA,CAAA,CAAAqB,GAAAA,CAACC,CAAAA,CAAA,CAAc,SAAA,CAAU,yBAAA,CAA0B,EAAA,CAAG,SAAA,CACpD,QAAA,CAAAD,GAAAA,CAACE,CAAAA,CAAA,CAAY,YAAA,CAAYX,GAAAA,CAAQ,QAAA,CAAAA,GAAAA,CAAM,CAAA,CACzC,CAAA,CACAK,IAAAA,CAACO,CAAAA,CAAA,CACE,QAAA,CAAA,CAAAV,CAAAA,CAAO,GAAA,CAAI,CAACW,CAAAA,CAAOC,CAAAA,GAClBT,IAAAA,CAACU,GAAAA,CAAA,CACE,QAAA,CAAA,CAAAF,CAAAA,CAAM,KAAA,CAAQJ,GAAAA,CAACO,GAAAA,CAAA,CAAa,QAAA,CAAAH,CAAAA,CAAM,KAAA,CAAM,CAAA,CAAiB,IAAA,CACzDA,CAAAA,CAAM,UAAA,CAAW,GAAA,CAAKL,CAAAA,EACrBC,GAAAA,CAACQ,CAAAA,CAAA,CAAoB,KAAA,CAAOT,CAAAA,CACzB,QAAA,CAAAP,CAAAA,CAAgBO,CAAAA,CAAIjB,GAAAA,CAAUD,GAAgB,GADhCkB,CAEjB,CACD,CAAA,CAAA,CAAA,CANeK,CAAAA,CAAM,KAAA,EAASC,CAOjC,CACD,CAAA,CACAV,GAAAA,CACCC,IAAAA,CAAAC,QAAAA,CAAA,CACE,QAAA,CAAA,CAAAG,GAAAA,CAACS,CAAAA,CAAA,EAAgB,CAAA,CACjBb,IAAAA,CAACY,CAAAA,CAAA,CAAW,KAAA,CAAO/B,CAAAA,CACjB,QAAA,CAAA,CAAAuB,GAAAA,CAACU,IAAAA,CAAA,CAAK,SAAA,CAAU,eAAA,CAAgB,CAAA,CAAE,aAAA,CAAA,CAEpC,GACF,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CACCf,GAAAA,CACCK,GAAAA,CAACW,CAAAA,CAAA,CAAO,YAAA,CAActB,CAAAA,CAAe,IAAA,CAAMD,CAAAA,CACzC,QAAA,CAAAQ,IAAAA,CAACgB,CAAAA,CAAA,CAAc,SAAA,CAAU,gBAAA,CACvB,QAAA,CAAA,CAAAhB,IAAAA,CAACiB,GAAAA,CAAA,CACC,QAAA,CAAA,CAAAb,GAAAA,CAACc,CAAAA,CAAA,CAAY,QAAA,CAAA,aAAA,CAAW,CAAA,CACxBd,GAAAA,CAACe,CAAAA,CAAA,CAAkB,QAAA,CAAA,mHAAA,CAGnB,CAAA,CAAA,CACF,CAAA,CACC3B,CAAAA,CACCY,GAAAA,CAACgB,GAAAA,CAAA,CACC,QAAA,CAAU,IAAM,CACd3B,CAAAA,CAAc,KAAK,EACrB,CAAA,CACA,SAAA,CAAW,IAAM,CACfA,CAAAA,CAAc,KAAK,EACrB,CAAA,CACA,KAAA,CAAOH,CAAAA,CACT,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CACF,CAAA,CACE,IAAA,CAAA,CACN,CAEJ","file":"project-selector-Z4Q6G6GM.js","sourcesContent":["import { useState, type JSX } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Plus } from 'lucide-react';\nimport { useConfig } from '../../core/config/config-context';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../primitives/dialog';\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n} from '../primitives/select';\nimport type { ProjectSummary, ProjectUiConfig } from '../../core/config/types';\nimport { NewProjectFlow } from './new-project-flow';\nimport { getProjectLabel, groupProjectIdsByTeam } from './project-label';\n\n/** Select value of the \"New project\" entry; project ids are ten lowercase characters, so it cannot collide. */\nconst NEW_PROJECT_VALUE = '__new_project__';\n\nexport { getProjectLabel } from './project-label';\n\ntype Props = {\n projectId: string;\n /** Every project the Studio can open, loaded or not. */\n projectIds: string[];\n /** Hosted mode: names and teams known before any schema loads. */\n projectSummaries?: ProjectSummary[];\n /** Projects whose schema has loaded; used for titles. */\n projects: ProjectUiConfig[];\n};\n\nexport function ProjectSelector({ projectId, projectIds, projectSummaries = [], projects }: Props): JSX.Element {\n const navigate = useNavigate();\n const { mode, teams } = useConfig();\n const [isCreating, setIsCreating] = useState(false);\n const label = getProjectLabel(projectId, projects, projectSummaries);\n const groups = groupProjectIdsByTeam(projectIds, projectSummaries);\n // Projects are created from the hosted Studio only; a self-hosted Studio lists fixed project ids.\n const canCreate = mode === 'hosted';\n\n return (\n <>\n <Select\n onValueChange={(id) => {\n if (id === NEW_PROJECT_VALUE) {\n setIsCreating(true);\n\n return;\n }\n\n navigate(`/${id}`);\n }}\n value={projectId}\n >\n <SelectTrigger className=\"fk:w-48! fk:h-9 fk:py-1\" id=\"project\">\n <SelectValue aria-label={label}>{label}</SelectValue>\n </SelectTrigger>\n <SelectContent>\n {groups.map((group, index) => (\n <SelectGroup key={group.label ?? index}>\n {group.label ? <SelectLabel>{group.label}</SelectLabel> : null}\n {group.projectIds.map((id) => (\n <SelectItem key={id} value={id}>\n {getProjectLabel(id, projects, projectSummaries)}\n </SelectItem>\n ))}\n </SelectGroup>\n ))}\n {canCreate ? (\n <>\n <SelectSeparator />\n <SelectItem value={NEW_PROJECT_VALUE}>\n <Plus className=\"fk:h-4 fk:w-4\" />\n New project\n </SelectItem>\n </>\n ) : null}\n </SelectContent>\n </Select>\n {canCreate ? (\n <Dialog onOpenChange={setIsCreating} open={isCreating}>\n <DialogContent className=\"fk:sm:max-w-md\">\n <DialogHeader>\n <DialogTitle>New project</DialogTitle>\n <DialogDescription>\n Projects start on the Free plan. Start from the commerce starter, or let the AI agent design the schema\n with you.\n </DialogDescription>\n </DialogHeader>\n {isCreating ? (\n <NewProjectFlow\n onCancel={() => {\n setIsCreating(false);\n }}\n onCreated={() => {\n setIsCreating(false);\n }}\n teams={teams}\n />\n ) : null}\n </DialogContent>\n </Dialog>\n ) : null}\n </>\n );\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'./index.css';export{a as EntityKnowledgeButton,c as LinkedRecordsSection,b as RecordKnowledgePanel}from'./chunk-WSXNYZQC.js';import'./chunk-DUS2CRB3.js';import'./chunk-4ZWQ44NZ.js';import'./chunk-PR3MTHFM.js';import'./chunk-DSLPTDZX.js';import'./chunk-VR3LFFJ3.js';import'./chunk-DQ2OVNOB.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-SAVZBVP5.js';import'./chunk-TP6QGIJH.js';import'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import'./chunk-RULCANNM.js';import'./chunk-A4DPLZZF.js';import'./chunk-G5N6HEPW.js';import'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import'./chunk-N33S7BSG.js';import'./chunk-X3SHNHHM.js';//# sourceMappingURL=record-links-DBU5G6ZH.js.map
|
|
2
|
+
//# sourceMappingURL=record-links-DBU5G6ZH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"record-links-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"record-links-DBU5G6ZH.js"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import'./index.css';import {a as a$3,b as b$6}from'./chunk-MLHXPTBT.js';import {b as b$5,c as c$4}from'./chunk-ELOJGLAR.js';import {e}from'./chunk-RX6QUDLZ.js';import {a as a$1}from'./chunk-U4DUXPZV.js';import {f as f$1,i,g as g$1,y,k,b as b$1,e as e$3,l,w,v,d,a,m,h,p,n as n$1,o as o$1,s as s$1,c as c$5,q as q$1,r as r$1,j as j$2,u,t}from'./chunk-6NRMVVU4.js';import {c as c$1}from'./chunk-2DXR5NJV.js';import {j,f as f$3}from'./chunk-UULPCFWK.js';import {c,e as e$1,f as f$2}from'./chunk-OWY5BQER.js';import'./chunk-HKN6BX5U.js';import {b as b$4}from'./chunk-DO32GATF.js';import {f}from'./chunk-CC2U7ASG.js';import {g}from'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import {I,K,O,M,ma,L,P,Q,R,T,U,V,n,N,ea,fa,ga,ha,Y,Z,aa,ba,_,ca}from'./chunk-RULCANNM.js';import {e as e$4,g as g$2,h as h$1,j as j$1,q,r,s,o}from'./chunk-A4DPLZZF.js';import {b as b$3,a as a$2}from'./chunk-G5N6HEPW.js';import {l as l$1}from'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import {b}from'./chunk-U45E5X3H.js';import {b as b$2,c as c$2,e as e$2}from'./chunk-N33S7BSG.js';import {c as c$3}from'./chunk-X3SHNHHM.js';import {useEffect,useMemo,useRef,useState,useCallback,useReducer}from'react';import {useLocation}from'react-router-dom';import Qn from'graphology';import zn from'graphology-layout-forceatlas2';import Hn from'graphology-layout-forceatlas2/worker';import jn,{DEFAULT_STYLES}from'sigma';import {jsxs,jsx}from'react/jsx-runtime';import {gql}from'@apollo/client';import {useApolloClient,useQuery}from'@apollo/client/react';import {formatDistance}from'date-fns';import {SearchIcon,ChevronDownIcon,LoaderCircleIcon,PlayIcon,ScanIcon,ExpandIcon,EyeOffIcon,EraserIcon,XIcon,SquareArrowOutUpRightIcon}from'lucide-react';import {closeBrackets,closeBracketsKeymap}from'@codemirror/autocomplete';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {foldGutter,indentOnInput,bracketMatching,foldKeymap}from'@codemirror/language';import {Compartment,EditorState,Prec}from'@codemirror/state';import {EditorView,lineNumbers,highlightActiveLineGutter,highlightSpecialChars,drawSelection,dropCursor,highlightActiveLine,keymap,placeholder}from'@codemirror/view';import {graphql,updateSchema}from'cm6-graphql';import {getIntrospectionQuery,buildClientSchema}from'graphql';import {useDebounce}from'use-debounce';function Ce(e){return Math.min(2e4,2e3+e*9)}function tn({mean:e,max:t,diagonal:n}){let r=Math.max(.05,n*.0015);return e<r&&t<r*20}var Bn=40,Xn=400,Fn=1200,$n=2;function Jn(e){return 5+Math.min(10,Math.sqrt(e)*2)}function on(e){return Bn*(.8+Math.sqrt(e)*.6)}function sn(e,t,n){let r=Math.random()*Math.PI*2;return Array.from({length:t},(i,a)=>{let o=r+a/t*Math.PI*2+Math.random()*.3,d=n*(.9+Math.random()*.2);return {x:e.x+Math.cos(o)*d,y:e.y+Math.sin(o)*d}})}function an(e,t){return !Number.isNaN(e.getNodeAttribute(t,"x"))}function Yn(e,t){if(t.length===0)return {center:{x:0,y:0},reach:0};let n=t.reduce((i,a)=>({x:i.x+e.getNodeAttribute(a,"x"),y:i.y+e.getNodeAttribute(a,"y")}),{x:0,y:0});n.x/=t.length,n.y/=t.length;let r=t.reduce((i,a)=>Math.max(i,Math.hypot(e.getNodeAttribute(a,"x")-n.x,e.getNodeAttribute(a,"y")-n.y)),0);return {center:n,reach:r}}function Kn(e,t){let n=new Map;t.forEach(r=>{let i=e.neighbors(r).find(a=>!t.has(a)&&an(e,a))??null;n.set(i,[...n.get(i)??[],r]);}),n.forEach((r,i)=>{let a;if(i){let o={x:e.getNodeAttribute(i,"x"),y:e.getNodeAttribute(i,"y")};a=sn(o,r.length,on(r.length));}else {let o=e.nodes().filter(b=>!t.has(b)&&an(e,b)),d=Yn(e,o);a=sn(d.center,r.length,d.reach+on(r.length));}a.forEach((o,d)=>e.mergeNodeAttributes(r[d],o));});}var Ue=class{constructor(t){this.graph=t;this.positions=new Float64Array(t.order*2);let n=0;this.graph.forEachNode((r,i)=>{this.positions[n]=i.x,this.positions[n+1]=i.y,n+=2;});}positions;measure(){let{graph:t,positions:n}=this,r=0,i=0,a=0,o=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY,k=0;return t.forEachNode((l,u)=>{let{x:g,y:f}=u;if(k+1<n.length&&!u.fixed){let E=Math.hypot(g-n[k],f-n[k+1]);r+=E,i=Math.max(i,E),a+=1;}n[k]=g,n[k+1]=f,k+=2,o=Math.min(o,g),d=Math.min(d,f),b=Math.max(b,g),C=Math.max(C,f);}),{mean:a>0?r/a:0,max:i,diagonal:t.order>0?Math.hypot(b-o,C-d):0}}};function Un(e,t,n){let r=false,i=new Set,a=e.order>0;return e.forEachNode(o=>{t.nodes[o]||(e.dropNode(o),r=true);}),Object.values(t.nodes).forEach(o=>{if(e.hasNode(o.key)){e.getNodeAttribute(o.key,"label")!==o.label&&e.setNodeAttribute(o.key,"label",o.label);return}e.addNode(o.key,{entity:o.entity,label:o.label,color:n[o.entity]??"#71717a",size:5,x:Number.NaN,y:Number.NaN}),i.add(o.key),r=true;}),e.forEachEdge(o=>{t.edges[o]||(e.dropEdge(o),r=true);}),Object.values(t.edges).forEach(o=>{e.hasEdge(o.key)||(e.addEdgeWithKey(o.key,o.source,o.target,{size:1}),r=true);}),Kn(e,i),r&&e.forEachNode(o=>{e.setNodeAttribute(o,"size",Jn(e.degree(o)));}),{changed:r,added:i,hadNodes:a}}function ln({scene:e,colors:t,theme:n,apiRef:r,onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b}){let C=useRef(null),k=useRef(null),l=useRef(null),u=useRef(null),g=useRef(null),f=useRef(null),E=useRef(null),p=useRef(null),S=useRef(null),s=useRef(new Set),N=useRef(e.pinned);N.current=e.pinned;let m=useRef({key:null,nodes:[]}),D=useRef({onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b}),[_,$]=useState(0);D.current={onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b},k.current||(k.current=new Qn({type:"undirected",multi:true}));let v=useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null),p.current!==null&&(window.clearInterval(p.current),p.current=null),u.current&&(u.current.kill(),u.current=null,S.current=null,D.current.onLayoutChange(false));let c=k.current;s.current.forEach(y=>{c?.hasNode(y)&&c.setNodeAttribute(y,"fixed",N.current[y]===true);}),s.current=new Set;},[]),A=useCallback((c,y=[])=>{let w=k.current;if(v(),!w||w.order===0)return;if(s.current=new Set(y.filter(T=>w.hasNode(T))),s.current.forEach(T=>w.setNodeAttribute(T,"fixed",true)),!w.someNode((T,L)=>!L.fixed)){v();return}let R=zn.inferSettings(w),G=new Hn(w,{settings:{...R,adjustSizes:true,gravity:.2,slowDown:(R.slowDown??1)*2},outputReducer:(T,L)=>{let oe=f.current;return oe&&oe.node===T&&(L.x=oe.x,L.y=oe.y),L}}),Q=performance.now(),Y=new Ue(w),V=false,K=0;u.current=G,S.current=Q+c,G.start(),D.current.onLayoutChange(true);let h=()=>{f.current?(S.current=performance.now()+c,g.current=window.setTimeout(h,c)):v();};g.current=window.setTimeout(h,c),p.current=window.setInterval(()=>{let T=Y.measure();if(f.current){K=0;return}V=V||T.max>0,K=V&&tn(T)?K+1:0,K>=$n&&performance.now()-Q>=Fn&&v();},Xn);},[v]),q=useCallback(c=>{let y=k.current,w=l.current;if(!y||!w)return;let R=m.current;if(w.setNodesState(R.nodes.filter(G=>y.hasNode(G)),{isNeighbour:false}),c&&y.hasNode(c)){let G=y.neighbors(c);w.setNodesState(G,{isNeighbour:true}),m.current={key:c,nodes:G};}else m.current={key:null,nodes:[]};},[]);return useEffect(()=>{let c=C.current,y=k.current;if(!c||!y)return;if(c.clientWidth===0||c.clientHeight===0){let h=new ResizeObserver(()=>{c.clientWidth>0&&c.clientHeight>0&&(h.disconnect(),$(T=>T+1));});return h.observe(c),()=>h.disconnect()}let w=n==="dark",R=new jn(y,c,{customNodeState:{isNeighbour:false},customEdgeState:{},customGraphState:{isDense:y.order>300,isZoomedIn:false},settings:{allowInvalidContainer:true,itemSizesReference:"screen",enableNodeDrag:true,renderEdgeLabels:false,labelRenderedSizeThreshold:7,labelDensity:.1,labelGridCellSize:80},styles:{nodes:[{...DEFAULT_STYLES.nodes,size:{whenState:"isHighlighted",then:h=>h.size+5,else:{whenState:"isHovered",then:h=>h.size+2,else:{attribute:"size"}}},cursor:"pointer",labelColor:w?"#e4e4e7":"#18181b",labelSize:12,labelFont:"ui-sans-serif, system-ui, sans-serif",labelVisibility:(h,T,L)=>T.isHovered||T.isHighlighted?"visible":L.isDense&&!L.isZoomedIn&&!T.isNeighbour?"hidden":"auto",backdropColor:w?"#27272a":"#ffffff",backdropShadowColor:w?"rgba(0, 0, 0, 0.6)":"rgba(0, 0, 0, 0.25)"}],edges:[{...DEFAULT_STYLES.edges,color:w?"#3f3f46":"#d4d4d8",size:1}]}});l.current=R,R.on("clickNode",({node:h})=>{D.current.onSelect(h);}),R.on("clickStage",()=>{D.current.onSelect(null);}),R.on("doubleClickNode",({node:h,event:T})=>{T.preventSigmaDefault(),D.current.onExpand(h);}),R.on("rightClickNode",({node:h,event:T})=>{T.preventSigmaDefault();let L=T.original;L.preventDefault(),D.current.onSelect(h),D.current.onContextMenu(h,{x:L.clientX,y:L.clientY});}),R.on("enterNode",({node:h})=>q(h)),R.on("leaveNode",()=>q(null));let G=h=>{let T=new Set([h,...y.neighbors(h)]);return y.nodes().filter(L=>L===h||!T.has(L))};R.on("nodeDragStart",({node:h})=>{f.current={node:h,x:y.getNodeAttribute(h,"x"),y:y.getNodeAttribute(h,"y")},y.size>0?(A(Ce(y.order),G(h)),E.current=u.current):(v(),y.setNodeAttribute(h,"fixed",true));}),R.on("nodeDrag",({node:h})=>{f.current?.node===h&&(f.current.x=y.getNodeAttribute(h,"x"),f.current.y=y.getNodeAttribute(h,"y"));}),R.on("nodeDragEnd",({node:h})=>{let T=f.current!==null&&u.current!==null&&u.current===E.current;f.current=null,E.current=null,D.current.onPin(h),T&&A(Ce(y.order),G(h));});let Q=R.getCamera(),Y=({ratio:h})=>{let T=h<.45;R.getGraphState().isZoomedIn!==T&&R.setGraphState({isZoomedIn:T});};Q.on("updated",Y);let V=h=>h.preventDefault();c.addEventListener("contextmenu",V);let K=new ResizeObserver(()=>{c.clientWidth>0&&c.clientHeight>0&&(R.resize(),R.scheduleRefresh());});return K.observe(c),r.current={fit:()=>{Q.reset({duration:300});}},()=>{K.disconnect(),Q.off("updated",Y),c.removeEventListener("contextmenu",V),r.current=null,l.current=null,m.current={key:null,nodes:[]},R.kill();}},[n,_,r,A,v,q]),useEffect(()=>{let c=k.current;if(!c)return;v();let{changed:y,added:w,hadNodes:R}=Un(c,e,t);if(!y)return;if(l.current?.setGraphState({isDense:c.order>300}),q(c.hasNode(m.current.key??"")?m.current.key:null),c.size===0){v();return}let G=R&&w.size>0?c.nodes().filter(Q=>!w.has(Q)):[];A(Ce(G.length>0?w.size:c.order),G);},[e.version]),useEffect(()=>{let c=k.current;c&&c.forEachNode((y,w)=>{c.setNodeAttribute(y,"color",t[w.entity]??"#71717a");});},[t]),useEffect(()=>{let c=k.current,y=l.current;if(!c||!y)return;let w=new Set(e.hiddenEntities),R=false;c.forEachNode((G,Q)=>{y.setNodeState(G,{isHidden:w.has(Q.entity),isHighlighted:G===e.selected});let Y=e.pinned[G]===true||s.current.has(G);(Q.fixed??false)!==Y&&(c.setNodeAttribute(G,"fixed",Y),R=true);}),R&&S.current!==null&&A(Math.max(500,S.current-performance.now()),[...s.current]),c.forEachEdge((G,Q,Y,V)=>{y.setEdgeState(G,{isHidden:w.has(c.getNodeAttribute(Y,"entity"))||w.has(c.getNodeAttribute(V,"entity"))});});},[e.hiddenEntities,e.selected,e.pinned,e.version,_,n,A]),useEffect(()=>v,[v]),jsx("div",{className:"fk:h-full fk:w-full fk:min-h-0",ref:C})}function un({menu:e,relationships:t,isPinned:n,onClose:r$1,onExpandAll:i,onExpandAttribute:a,onHide:o$1,onHideOthers:d,onTogglePin:b,onOpenRecord:C}){let k=e?.key??"";return jsxs(e$4,{onOpenChange:l=>{l||r$1();},open:e!==null,children:[jsx(g$2,{asChild:true,children:jsx("span",{"aria-hidden":"true",className:"fk:fixed fk:size-0",style:{left:e?.x??0,top:e?.y??0}})}),jsxs(h$1,{align:"start",className:"fk:w-52","data-testid":"graph-context-menu",side:"bottom",children:[jsx(j$1,{onSelect:()=>i(k),children:"Expand all"}),t.length>0?jsxs(q,{children:[jsx(r,{children:"Expand"}),jsx(s,{className:"fk:max-h-80 fk:overflow-y-auto",children:t.map(l=>jsx(j$1,{onSelect:()=>a(k,l),children:l.label},l.name))})]}):null,jsx(o,{}),jsx(j$1,{onSelect:()=>o$1(k),children:"Hide"}),jsx(j$1,{onSelect:()=>d(k),children:"Hide others"}),jsx(j$1,{onSelect:()=>b(k),children:n?"Unpin position":"Pin position"}),jsx(o,{}),jsx(j$1,{onSelect:()=>C(k),children:"Open record"})]})]})}var We={nodes:{},edges:{},counts:{},fetched:{},hiddenEntities:[],pinned:{},selected:null,notice:null,version:0};function Wn(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{n[r]={...n[r],...i};}),n}function Zn(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{let a={...n[r]};Object.entries(i).forEach(([o,d])=>{a[o]=Math.max(a[o]??0,d);}),n[r]=a;}),n}function cn(e,t){let n=Object.fromEntries(Object.entries(e.nodes).filter(([a])=>!t.has(a))),r=Object.fromEntries(Object.entries(e.edges).filter(([,a])=>!t.has(a.source)&&!t.has(a.target))),i=Object.fromEntries(Object.entries(e.pinned).filter(([a])=>!t.has(a)));return {...e,nodes:n,edges:r,pinned:i,selected:e.selected&&t.has(e.selected)?null:e.selected,version:e.version+1}}function dn(e,t){switch(t.type){case "merge":{let n={...e.nodes},r=Object.keys(n).length,i=0;t.data.nodes.forEach(o=>{let d=n[o.key];if(d){d.label===d.id&&o.label!==o.id&&(n[o.key]={...d,label:o.label});return}if(r>=c$5){i+=1;return}n[o.key]=o,r+=1;});let a={...e.edges};return t.data.edges.forEach(o=>{n[o.source]&&n[o.target]&&(a[o.key]=o);}),{...e,nodes:n,edges:a,counts:Wn(e.counts,t.data.counts),fetched:Zn(e.fetched,t.fetched),notice:i>0?`The canvas holds ${c$5.toLocaleString()} nodes at most; ${i.toLocaleString()} were left out. Hide some nodes to make room.`:e.notice,version:e.version+1}}case "remove":return cn(e,new Set(t.keys));case "keepOnly":{let n=new Set(t.keys);return cn(e,new Set(Object.keys(e.nodes).filter(r=>!n.has(r))))}case "clear":return {...We,hiddenEntities:e.hiddenEntities,version:e.version+1};case "toggleEntity":return {...e,hiddenEntities:e.hiddenEntities.includes(t.entity)?e.hiddenEntities.filter(n=>n!==t.entity):[...e.hiddenEntities,t.entity]};case "select":return e.selected===t.key?e:{...e,selected:t.key};case "togglePin":{let n={...e.pinned};return n[t.key]?delete n[t.key]:n[t.key]=true,{...e,pinned:n}}case "notice":return {...e,notice:t.message};default:return e}}function fn(e){return Object.values(e.nodes).reduce((t,n)=>(t[n.entity]=(t[n.entity]??0)+1,t),{})}function pn(e,t){return Object.values(e.edges).reduce((n,r)=>(r.source===t?n[r.sourceAttribute]=(n[r.sourceAttribute]??0)+1:r.target===t&&(n[r.targetAttribute]=(n[r.targetAttribute]??0)+1),n),{})}function mn(e,t){return Object.values(e.edges).flatMap(n=>n.source===t?[n.target]:n.target===t?[n.source]:[])}function sr(e){let[t,n,r]=[1,3,5].map(a=>{let o=parseInt(e.slice(a,a+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r>.3?"#0a0a0a":"#ffffff"}function kn({node:e,schema:t,scope:n,scene:r,colors:i,isLoading:a,onClose:o,onOpenRecord:d,onExpandAll:b,onExpandAttribute:C,onHide:k}){let l=g$1(t,e.entity),u=f$2(),g=useMemo(()=>gql(l?p({defaultScope:u,entity:l,scope:n}):"query GraphDetails { __typename }"),[u,l,n]),f=useMemo(()=>gql(l?n$1({entity:l}):"query GraphCounts { __typename }"),[l]),E=useQuery(g,{variables:{id:e.id},skip:!l}),p$1=useQuery(f,{variables:{id:e.id},skip:!l}),S=l?E.data?.[l.plural]?.[0]:void 0,s=l?p$1.data?.[l.plural]?.[0]:void 0,N=useMemo(()=>pn(r,e.key),[r,e.key]),m=l?e$3(l):[],D=l?o$1(l):[],_=S?._updatedAt?new Date(S._updatedAt):null,$=i[e.entity]??"#71717a";return jsxs("aside",{"aria-label":"Selected record",className:"fk:flex fk:w-72 fk:shrink-0 fk:flex-col fk:gap-5 fk:overflow-y-auto fk:border-l fk:bg-background fk:p-4 fk:text-sm","data-testid":"graph-inspector",children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2",children:[jsx("span",{className:"fk:inline-flex fk:items-center fk:rounded-full fk:px-2 fk:py-0.5 fk:text-xs fk:font-medium",style:{backgroundColor:$,color:sr($)},children:l?h(l):e.entity}),jsx(c$3,{"aria-label":"Close",className:"fk:size-7",onClick:o,size:"icon",variant:"ghost",children:jsx(XIcon,{className:"fk:size-4"})})]}),jsx("h2",{className:"fk:text-base fk:font-semibold fk:leading-snug fk:break-words",children:e.label}),jsxs("div",{className:"fk:flex fk:gap-1.5",children:[jsxs(c$3,{onClick:()=>d(e.key),size:"xs",children:[jsx(SquareArrowOutUpRightIcon,{}),"Open record"]}),jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(c$3,{"aria-label":"Expand every relationship",disabled:a,onClick:()=>b(e.key),size:"xs",variant:"outline",children:[a?jsx(LoaderCircleIcon,{className:"fk:animate-spin"}):jsx(ExpandIcon,{}),"Expand"]})}),jsx(e$2,{children:"Load the first related records of every relationship"})]}),jsxs(c$3,{"aria-label":"Hide this node",onClick:()=>k(e.key),size:"xs",variant:"outline",children:[jsx(EyeOffIcon,{}),"Hide"]})]})]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h3",{className:"fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Attributes"}),E.loading&&!S?jsx("span",{className:"fk:text-muted-foreground",children:"Loading\u2026"}):jsxs("dl",{className:"fk:grid fk:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] fk:gap-x-3 fk:gap-y-1.5",children:[D.map(v=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:truncate fk:text-muted-foreground",title:v.label,children:v.label}),jsx("dd",{className:"fk:min-w-0 fk:break-words",children:S&&s$1(S[v.name],n)||"\u2014"})]},v.name)),_?jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:"Updated"}),jsx("dd",{children:formatDistance(_,new Date,{addSuffix:true})})]}):null]})]}),m.length>0?jsxs("section",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("h3",{className:"fk:mb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Relationships"}),m.map(v=>{let A=g$1(t,v.relationship?.entity??""),q=s?.[`${v.name}Connection`]?.aggregate?.count?.nodes,c=N[v.name]??0,y=r.fetched[e.key]?.[v.name]??0,w=typeof q=="number"&&y>=q;return jsxs("div",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2 fk:shrink-0 fk:rounded-full",style:{backgroundColor:i[v.relationship?.entity??""]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",title:A?h(A):void 0,children:v.label}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:typeof q=="number"?`${c} of ${q.toLocaleString()}`:c}),q===0||w?null:jsx(c$3,{className:"fk:h-6 fk:px-2 fk:text-xs",disabled:a,onClick:()=>C(e.key,v),size:"xs",variant:"outline",children:y>0?"More":"Expand"})]},v.name)})]}):null]})}var bn=EditorView.theme({"&":{fontSize:"13px",height:"100%",minHeight:"0"},"&.cm-focused":{outline:"none"},".cm-scroller":{height:"100%",lineHeight:"1.6",minHeight:"0",overflow:"auto"},".cm-content":{fontSize:"13px",padding:"12px 0"},".cm-gutters":{borderRight:"1px solid transparent"}});function xn({ariaLabel:e,schema:t,theme:n,value:r,onChange:i,onRun:a}){let o=useRef(null),d=useRef(null),b=useRef(new Compartment),C=useRef(i),k=useRef(a),l=useRef(r);return C.current=i,k.current=a,l.current=r,useEffect(()=>{let u=o.current;if(!u)return;let g=new EditorView({parent:u,state:EditorState.create({doc:l.current,extensions:[lineNumbers(),highlightActiveLineGutter(),highlightSpecialChars(),history(),foldGutter(),drawSelection(),dropCursor(),indentOnInput(),bracketMatching(),closeBrackets(),highlightActiveLine(),Prec.highest(keymap.of([{key:"Mod-Enter",run:()=>(k.current(),true)}])),keymap.of([...closeBracketsKeymap,...defaultKeymap,...historyKeymap,...foldKeymap,indentWithTab]),graphql(void 0,{showErrorOnInvalidSchema:false}),EditorView.updateListener.of(f=>{f.docChanged&&C.current(f.state.doc.toString());}),EditorView.contentAttributes.of({"aria-label":e,"aria-multiline":"true",role:"textbox"}),placeholder(`query {
|
|
1
|
+
import'./index.css';import {a as a$3,b as b$6}from'./chunk-MLHXPTBT.js';import {b as b$5,c as c$4}from'./chunk-ELOJGLAR.js';import {e}from'./chunk-R7EOMV6C.js';import {a as a$1}from'./chunk-U3PTPLSE.js';import {f as f$1,i,g as g$1,y,k,b as b$1,e as e$3,l,w,v,d,a,m,h,p,n as n$1,o as o$1,s as s$1,c as c$5,q as q$1,r as r$1,j as j$2,u,t}from'./chunk-7FYOLFHG.js';import {c as c$1}from'./chunk-2DXR5NJV.js';import {j,f as f$3}from'./chunk-VR3LFFJ3.js';import {c,e as e$1,f as f$2}from'./chunk-DQ2OVNOB.js';import'./chunk-HKN6BX5U.js';import {b as b$4}from'./chunk-SAVZBVP5.js';import {f}from'./chunk-TP6QGIJH.js';import {g}from'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import {I,K,O,M,ma,L,P,Q,R,T,U,V,n,N,ea,fa,ga,ha,Y,Z,aa,ba,_,ca}from'./chunk-RULCANNM.js';import {e as e$4,g as g$2,h as h$1,j as j$1,q,r,s,o}from'./chunk-A4DPLZZF.js';import {b as b$3,a as a$2}from'./chunk-G5N6HEPW.js';import {l as l$1}from'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import {b}from'./chunk-U45E5X3H.js';import {b as b$2,c as c$2,e as e$2}from'./chunk-N33S7BSG.js';import {c as c$3}from'./chunk-X3SHNHHM.js';import {useEffect,useMemo,useRef,useState,useCallback,useReducer}from'react';import {useLocation}from'react-router-dom';import Qn from'graphology';import zn from'graphology-layout-forceatlas2';import Hn from'graphology-layout-forceatlas2/worker';import jn,{DEFAULT_STYLES}from'sigma';import {jsxs,jsx}from'react/jsx-runtime';import {gql}from'@apollo/client';import {useApolloClient,useQuery}from'@apollo/client/react';import {formatDistance}from'date-fns';import {SearchIcon,ChevronDownIcon,LoaderCircleIcon,PlayIcon,ScanIcon,ExpandIcon,EyeOffIcon,EraserIcon,XIcon,SquareArrowOutUpRightIcon}from'lucide-react';import {closeBrackets,closeBracketsKeymap}from'@codemirror/autocomplete';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {foldGutter,indentOnInput,bracketMatching,foldKeymap}from'@codemirror/language';import {Compartment,EditorState,Prec}from'@codemirror/state';import {EditorView,lineNumbers,highlightActiveLineGutter,highlightSpecialChars,drawSelection,dropCursor,highlightActiveLine,keymap,placeholder}from'@codemirror/view';import {graphql,updateSchema}from'cm6-graphql';import {getIntrospectionQuery,buildClientSchema}from'graphql';import {useDebounce}from'use-debounce';function Ce(e){return Math.min(2e4,2e3+e*9)}function tn({mean:e,max:t,diagonal:n}){let r=Math.max(.05,n*.0015);return e<r&&t<r*20}var Bn=40,Xn=400,Fn=1200,$n=2;function Jn(e){return 5+Math.min(10,Math.sqrt(e)*2)}function on(e){return Bn*(.8+Math.sqrt(e)*.6)}function sn(e,t,n){let r=Math.random()*Math.PI*2;return Array.from({length:t},(i,a)=>{let o=r+a/t*Math.PI*2+Math.random()*.3,d=n*(.9+Math.random()*.2);return {x:e.x+Math.cos(o)*d,y:e.y+Math.sin(o)*d}})}function an(e,t){return !Number.isNaN(e.getNodeAttribute(t,"x"))}function Yn(e,t){if(t.length===0)return {center:{x:0,y:0},reach:0};let n=t.reduce((i,a)=>({x:i.x+e.getNodeAttribute(a,"x"),y:i.y+e.getNodeAttribute(a,"y")}),{x:0,y:0});n.x/=t.length,n.y/=t.length;let r=t.reduce((i,a)=>Math.max(i,Math.hypot(e.getNodeAttribute(a,"x")-n.x,e.getNodeAttribute(a,"y")-n.y)),0);return {center:n,reach:r}}function Kn(e,t){let n=new Map;t.forEach(r=>{let i=e.neighbors(r).find(a=>!t.has(a)&&an(e,a))??null;n.set(i,[...n.get(i)??[],r]);}),n.forEach((r,i)=>{let a;if(i){let o={x:e.getNodeAttribute(i,"x"),y:e.getNodeAttribute(i,"y")};a=sn(o,r.length,on(r.length));}else {let o=e.nodes().filter(b=>!t.has(b)&&an(e,b)),d=Yn(e,o);a=sn(d.center,r.length,d.reach+on(r.length));}a.forEach((o,d)=>e.mergeNodeAttributes(r[d],o));});}var Ue=class{constructor(t){this.graph=t;this.positions=new Float64Array(t.order*2);let n=0;this.graph.forEachNode((r,i)=>{this.positions[n]=i.x,this.positions[n+1]=i.y,n+=2;});}positions;measure(){let{graph:t,positions:n}=this,r=0,i=0,a=0,o=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY,k=0;return t.forEachNode((l,u)=>{let{x:g,y:f}=u;if(k+1<n.length&&!u.fixed){let E=Math.hypot(g-n[k],f-n[k+1]);r+=E,i=Math.max(i,E),a+=1;}n[k]=g,n[k+1]=f,k+=2,o=Math.min(o,g),d=Math.min(d,f),b=Math.max(b,g),C=Math.max(C,f);}),{mean:a>0?r/a:0,max:i,diagonal:t.order>0?Math.hypot(b-o,C-d):0}}};function Un(e,t,n){let r=false,i=new Set,a=e.order>0;return e.forEachNode(o=>{t.nodes[o]||(e.dropNode(o),r=true);}),Object.values(t.nodes).forEach(o=>{if(e.hasNode(o.key)){e.getNodeAttribute(o.key,"label")!==o.label&&e.setNodeAttribute(o.key,"label",o.label);return}e.addNode(o.key,{entity:o.entity,label:o.label,color:n[o.entity]??"#71717a",size:5,x:Number.NaN,y:Number.NaN}),i.add(o.key),r=true;}),e.forEachEdge(o=>{t.edges[o]||(e.dropEdge(o),r=true);}),Object.values(t.edges).forEach(o=>{e.hasEdge(o.key)||(e.addEdgeWithKey(o.key,o.source,o.target,{size:1}),r=true);}),Kn(e,i),r&&e.forEachNode(o=>{e.setNodeAttribute(o,"size",Jn(e.degree(o)));}),{changed:r,added:i,hadNodes:a}}function ln({scene:e,colors:t,theme:n,apiRef:r,onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b}){let C=useRef(null),k=useRef(null),l=useRef(null),u=useRef(null),g=useRef(null),f=useRef(null),E=useRef(null),p=useRef(null),S=useRef(null),s=useRef(new Set),N=useRef(e.pinned);N.current=e.pinned;let m=useRef({key:null,nodes:[]}),D=useRef({onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b}),[_,$]=useState(0);D.current={onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b},k.current||(k.current=new Qn({type:"undirected",multi:true}));let v=useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null),p.current!==null&&(window.clearInterval(p.current),p.current=null),u.current&&(u.current.kill(),u.current=null,S.current=null,D.current.onLayoutChange(false));let c=k.current;s.current.forEach(y=>{c?.hasNode(y)&&c.setNodeAttribute(y,"fixed",N.current[y]===true);}),s.current=new Set;},[]),A=useCallback((c,y=[])=>{let w=k.current;if(v(),!w||w.order===0)return;if(s.current=new Set(y.filter(T=>w.hasNode(T))),s.current.forEach(T=>w.setNodeAttribute(T,"fixed",true)),!w.someNode((T,L)=>!L.fixed)){v();return}let R=zn.inferSettings(w),G=new Hn(w,{settings:{...R,adjustSizes:true,gravity:.2,slowDown:(R.slowDown??1)*2},outputReducer:(T,L)=>{let oe=f.current;return oe&&oe.node===T&&(L.x=oe.x,L.y=oe.y),L}}),Q=performance.now(),Y=new Ue(w),V=false,K=0;u.current=G,S.current=Q+c,G.start(),D.current.onLayoutChange(true);let h=()=>{f.current?(S.current=performance.now()+c,g.current=window.setTimeout(h,c)):v();};g.current=window.setTimeout(h,c),p.current=window.setInterval(()=>{let T=Y.measure();if(f.current){K=0;return}V=V||T.max>0,K=V&&tn(T)?K+1:0,K>=$n&&performance.now()-Q>=Fn&&v();},Xn);},[v]),q=useCallback(c=>{let y=k.current,w=l.current;if(!y||!w)return;let R=m.current;if(w.setNodesState(R.nodes.filter(G=>y.hasNode(G)),{isNeighbour:false}),c&&y.hasNode(c)){let G=y.neighbors(c);w.setNodesState(G,{isNeighbour:true}),m.current={key:c,nodes:G};}else m.current={key:null,nodes:[]};},[]);return useEffect(()=>{let c=C.current,y=k.current;if(!c||!y)return;if(c.clientWidth===0||c.clientHeight===0){let h=new ResizeObserver(()=>{c.clientWidth>0&&c.clientHeight>0&&(h.disconnect(),$(T=>T+1));});return h.observe(c),()=>h.disconnect()}let w=n==="dark",R=new jn(y,c,{customNodeState:{isNeighbour:false},customEdgeState:{},customGraphState:{isDense:y.order>300,isZoomedIn:false},settings:{allowInvalidContainer:true,itemSizesReference:"screen",enableNodeDrag:true,renderEdgeLabels:false,labelRenderedSizeThreshold:7,labelDensity:.1,labelGridCellSize:80},styles:{nodes:[{...DEFAULT_STYLES.nodes,size:{whenState:"isHighlighted",then:h=>h.size+5,else:{whenState:"isHovered",then:h=>h.size+2,else:{attribute:"size"}}},cursor:"pointer",labelColor:w?"#e4e4e7":"#18181b",labelSize:12,labelFont:"ui-sans-serif, system-ui, sans-serif",labelVisibility:(h,T,L)=>T.isHovered||T.isHighlighted?"visible":L.isDense&&!L.isZoomedIn&&!T.isNeighbour?"hidden":"auto",backdropColor:w?"#27272a":"#ffffff",backdropShadowColor:w?"rgba(0, 0, 0, 0.6)":"rgba(0, 0, 0, 0.25)"}],edges:[{...DEFAULT_STYLES.edges,color:w?"#3f3f46":"#d4d4d8",size:1}]}});l.current=R,R.on("clickNode",({node:h})=>{D.current.onSelect(h);}),R.on("clickStage",()=>{D.current.onSelect(null);}),R.on("doubleClickNode",({node:h,event:T})=>{T.preventSigmaDefault(),D.current.onExpand(h);}),R.on("rightClickNode",({node:h,event:T})=>{T.preventSigmaDefault();let L=T.original;L.preventDefault(),D.current.onSelect(h),D.current.onContextMenu(h,{x:L.clientX,y:L.clientY});}),R.on("enterNode",({node:h})=>q(h)),R.on("leaveNode",()=>q(null));let G=h=>{let T=new Set([h,...y.neighbors(h)]);return y.nodes().filter(L=>L===h||!T.has(L))};R.on("nodeDragStart",({node:h})=>{f.current={node:h,x:y.getNodeAttribute(h,"x"),y:y.getNodeAttribute(h,"y")},y.size>0?(A(Ce(y.order),G(h)),E.current=u.current):(v(),y.setNodeAttribute(h,"fixed",true));}),R.on("nodeDrag",({node:h})=>{f.current?.node===h&&(f.current.x=y.getNodeAttribute(h,"x"),f.current.y=y.getNodeAttribute(h,"y"));}),R.on("nodeDragEnd",({node:h})=>{let T=f.current!==null&&u.current!==null&&u.current===E.current;f.current=null,E.current=null,D.current.onPin(h),T&&A(Ce(y.order),G(h));});let Q=R.getCamera(),Y=({ratio:h})=>{let T=h<.45;R.getGraphState().isZoomedIn!==T&&R.setGraphState({isZoomedIn:T});};Q.on("updated",Y);let V=h=>h.preventDefault();c.addEventListener("contextmenu",V);let K=new ResizeObserver(()=>{c.clientWidth>0&&c.clientHeight>0&&(R.resize(),R.scheduleRefresh());});return K.observe(c),r.current={fit:()=>{Q.reset({duration:300});}},()=>{K.disconnect(),Q.off("updated",Y),c.removeEventListener("contextmenu",V),r.current=null,l.current=null,m.current={key:null,nodes:[]},R.kill();}},[n,_,r,A,v,q]),useEffect(()=>{let c=k.current;if(!c)return;v();let{changed:y,added:w,hadNodes:R}=Un(c,e,t);if(!y)return;if(l.current?.setGraphState({isDense:c.order>300}),q(c.hasNode(m.current.key??"")?m.current.key:null),c.size===0){v();return}let G=R&&w.size>0?c.nodes().filter(Q=>!w.has(Q)):[];A(Ce(G.length>0?w.size:c.order),G);},[e.version]),useEffect(()=>{let c=k.current;c&&c.forEachNode((y,w)=>{c.setNodeAttribute(y,"color",t[w.entity]??"#71717a");});},[t]),useEffect(()=>{let c=k.current,y=l.current;if(!c||!y)return;let w=new Set(e.hiddenEntities),R=false;c.forEachNode((G,Q)=>{y.setNodeState(G,{isHidden:w.has(Q.entity),isHighlighted:G===e.selected});let Y=e.pinned[G]===true||s.current.has(G);(Q.fixed??false)!==Y&&(c.setNodeAttribute(G,"fixed",Y),R=true);}),R&&S.current!==null&&A(Math.max(500,S.current-performance.now()),[...s.current]),c.forEachEdge((G,Q,Y,V)=>{y.setEdgeState(G,{isHidden:w.has(c.getNodeAttribute(Y,"entity"))||w.has(c.getNodeAttribute(V,"entity"))});});},[e.hiddenEntities,e.selected,e.pinned,e.version,_,n,A]),useEffect(()=>v,[v]),jsx("div",{className:"fk:h-full fk:w-full fk:min-h-0",ref:C})}function un({menu:e,relationships:t,isPinned:n,onClose:r$1,onExpandAll:i,onExpandAttribute:a,onHide:o$1,onHideOthers:d,onTogglePin:b,onOpenRecord:C}){let k=e?.key??"";return jsxs(e$4,{onOpenChange:l=>{l||r$1();},open:e!==null,children:[jsx(g$2,{asChild:true,children:jsx("span",{"aria-hidden":"true",className:"fk:fixed fk:size-0",style:{left:e?.x??0,top:e?.y??0}})}),jsxs(h$1,{align:"start",className:"fk:w-52","data-testid":"graph-context-menu",side:"bottom",children:[jsx(j$1,{onSelect:()=>i(k),children:"Expand all"}),t.length>0?jsxs(q,{children:[jsx(r,{children:"Expand"}),jsx(s,{className:"fk:max-h-80 fk:overflow-y-auto",children:t.map(l=>jsx(j$1,{onSelect:()=>a(k,l),children:l.label},l.name))})]}):null,jsx(o,{}),jsx(j$1,{onSelect:()=>o$1(k),children:"Hide"}),jsx(j$1,{onSelect:()=>d(k),children:"Hide others"}),jsx(j$1,{onSelect:()=>b(k),children:n?"Unpin position":"Pin position"}),jsx(o,{}),jsx(j$1,{onSelect:()=>C(k),children:"Open record"})]})]})}var We={nodes:{},edges:{},counts:{},fetched:{},hiddenEntities:[],pinned:{},selected:null,notice:null,version:0};function Wn(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{n[r]={...n[r],...i};}),n}function Zn(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{let a={...n[r]};Object.entries(i).forEach(([o,d])=>{a[o]=Math.max(a[o]??0,d);}),n[r]=a;}),n}function cn(e,t){let n=Object.fromEntries(Object.entries(e.nodes).filter(([a])=>!t.has(a))),r=Object.fromEntries(Object.entries(e.edges).filter(([,a])=>!t.has(a.source)&&!t.has(a.target))),i=Object.fromEntries(Object.entries(e.pinned).filter(([a])=>!t.has(a)));return {...e,nodes:n,edges:r,pinned:i,selected:e.selected&&t.has(e.selected)?null:e.selected,version:e.version+1}}function dn(e,t){switch(t.type){case "merge":{let n={...e.nodes},r=Object.keys(n).length,i=0;t.data.nodes.forEach(o=>{let d=n[o.key];if(d){d.label===d.id&&o.label!==o.id&&(n[o.key]={...d,label:o.label});return}if(r>=c$5){i+=1;return}n[o.key]=o,r+=1;});let a={...e.edges};return t.data.edges.forEach(o=>{n[o.source]&&n[o.target]&&(a[o.key]=o);}),{...e,nodes:n,edges:a,counts:Wn(e.counts,t.data.counts),fetched:Zn(e.fetched,t.fetched),notice:i>0?`The canvas holds ${c$5.toLocaleString()} nodes at most; ${i.toLocaleString()} were left out. Hide some nodes to make room.`:e.notice,version:e.version+1}}case "remove":return cn(e,new Set(t.keys));case "keepOnly":{let n=new Set(t.keys);return cn(e,new Set(Object.keys(e.nodes).filter(r=>!n.has(r))))}case "clear":return {...We,hiddenEntities:e.hiddenEntities,version:e.version+1};case "toggleEntity":return {...e,hiddenEntities:e.hiddenEntities.includes(t.entity)?e.hiddenEntities.filter(n=>n!==t.entity):[...e.hiddenEntities,t.entity]};case "select":return e.selected===t.key?e:{...e,selected:t.key};case "togglePin":{let n={...e.pinned};return n[t.key]?delete n[t.key]:n[t.key]=true,{...e,pinned:n}}case "notice":return {...e,notice:t.message};default:return e}}function fn(e){return Object.values(e.nodes).reduce((t,n)=>(t[n.entity]=(t[n.entity]??0)+1,t),{})}function pn(e,t){return Object.values(e.edges).reduce((n,r)=>(r.source===t?n[r.sourceAttribute]=(n[r.sourceAttribute]??0)+1:r.target===t&&(n[r.targetAttribute]=(n[r.targetAttribute]??0)+1),n),{})}function mn(e,t){return Object.values(e.edges).flatMap(n=>n.source===t?[n.target]:n.target===t?[n.source]:[])}function sr(e){let[t,n,r]=[1,3,5].map(a=>{let o=parseInt(e.slice(a,a+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r>.3?"#0a0a0a":"#ffffff"}function kn({node:e,schema:t,scope:n,scene:r,colors:i,isLoading:a,onClose:o,onOpenRecord:d,onExpandAll:b,onExpandAttribute:C,onHide:k}){let l=g$1(t,e.entity),u=f$2(),g=useMemo(()=>gql(l?p({defaultScope:u,entity:l,scope:n}):"query GraphDetails { __typename }"),[u,l,n]),f=useMemo(()=>gql(l?n$1({entity:l}):"query GraphCounts { __typename }"),[l]),E=useQuery(g,{variables:{id:e.id},skip:!l}),p$1=useQuery(f,{variables:{id:e.id},skip:!l}),S=l?E.data?.[l.plural]?.[0]:void 0,s=l?p$1.data?.[l.plural]?.[0]:void 0,N=useMemo(()=>pn(r,e.key),[r,e.key]),m=l?e$3(l):[],D=l?o$1(l):[],_=S?._updatedAt?new Date(S._updatedAt):null,$=i[e.entity]??"#71717a";return jsxs("aside",{"aria-label":"Selected record",className:"fk:flex fk:w-72 fk:shrink-0 fk:flex-col fk:gap-5 fk:overflow-y-auto fk:border-l fk:bg-background fk:p-4 fk:text-sm","data-testid":"graph-inspector",children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2",children:[jsx("span",{className:"fk:inline-flex fk:items-center fk:rounded-full fk:px-2 fk:py-0.5 fk:text-xs fk:font-medium",style:{backgroundColor:$,color:sr($)},children:l?h(l):e.entity}),jsx(c$3,{"aria-label":"Close",className:"fk:size-7",onClick:o,size:"icon",variant:"ghost",children:jsx(XIcon,{className:"fk:size-4"})})]}),jsx("h2",{className:"fk:text-base fk:font-semibold fk:leading-snug fk:break-words",children:e.label}),jsxs("div",{className:"fk:flex fk:gap-1.5",children:[jsxs(c$3,{onClick:()=>d(e.key),size:"xs",children:[jsx(SquareArrowOutUpRightIcon,{}),"Open record"]}),jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(c$3,{"aria-label":"Expand every relationship",disabled:a,onClick:()=>b(e.key),size:"xs",variant:"outline",children:[a?jsx(LoaderCircleIcon,{className:"fk:animate-spin"}):jsx(ExpandIcon,{}),"Expand"]})}),jsx(e$2,{children:"Load the first related records of every relationship"})]}),jsxs(c$3,{"aria-label":"Hide this node",onClick:()=>k(e.key),size:"xs",variant:"outline",children:[jsx(EyeOffIcon,{}),"Hide"]})]})]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h3",{className:"fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Attributes"}),E.loading&&!S?jsx("span",{className:"fk:text-muted-foreground",children:"Loading\u2026"}):jsxs("dl",{className:"fk:grid fk:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] fk:gap-x-3 fk:gap-y-1.5",children:[D.map(v=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:truncate fk:text-muted-foreground",title:v.label,children:v.label}),jsx("dd",{className:"fk:min-w-0 fk:break-words",children:S&&s$1(S[v.name],n)||"\u2014"})]},v.name)),_?jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:"Updated"}),jsx("dd",{children:formatDistance(_,new Date,{addSuffix:true})})]}):null]})]}),m.length>0?jsxs("section",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("h3",{className:"fk:mb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Relationships"}),m.map(v=>{let A=g$1(t,v.relationship?.entity??""),q=s?.[`${v.name}Connection`]?.aggregate?.count?.nodes,c=N[v.name]??0,y=r.fetched[e.key]?.[v.name]??0,w=typeof q=="number"&&y>=q;return jsxs("div",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2 fk:shrink-0 fk:rounded-full",style:{backgroundColor:i[v.relationship?.entity??""]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",title:A?h(A):void 0,children:v.label}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:typeof q=="number"?`${c} of ${q.toLocaleString()}`:c}),q===0||w?null:jsx(c$3,{className:"fk:h-6 fk:px-2 fk:text-xs",disabled:a,onClick:()=>C(e.key,v),size:"xs",variant:"outline",children:y>0?"More":"Expand"})]},v.name)})]}):null]})}var bn=EditorView.theme({"&":{fontSize:"13px",height:"100%",minHeight:"0"},"&.cm-focused":{outline:"none"},".cm-scroller":{height:"100%",lineHeight:"1.6",minHeight:"0",overflow:"auto"},".cm-content":{fontSize:"13px",padding:"12px 0"},".cm-gutters":{borderRight:"1px solid transparent"}});function xn({ariaLabel:e,schema:t,theme:n,value:r,onChange:i,onRun:a}){let o=useRef(null),d=useRef(null),b=useRef(new Compartment),C=useRef(i),k=useRef(a),l=useRef(r);return C.current=i,k.current=a,l.current=r,useEffect(()=>{let u=o.current;if(!u)return;let g=new EditorView({parent:u,state:EditorState.create({doc:l.current,extensions:[lineNumbers(),highlightActiveLineGutter(),highlightSpecialChars(),history(),foldGutter(),drawSelection(),dropCursor(),indentOnInput(),bracketMatching(),closeBrackets(),highlightActiveLine(),Prec.highest(keymap.of([{key:"Mod-Enter",run:()=>(k.current(),true)}])),keymap.of([...closeBracketsKeymap,...defaultKeymap,...historyKeymap,...foldKeymap,indentWithTab]),graphql(void 0,{showErrorOnInvalidSchema:false}),EditorView.updateListener.of(f=>{f.docChanged&&C.current(f.state.doc.toString());}),EditorView.contentAttributes.of({"aria-label":e,"aria-multiline":"true",role:"textbox"}),placeholder(`query {
|
|
2
2
|
\u2026
|
|
3
3
|
}`),b.current.of([n==="dark"?a$3:b$6,bn])]})});return d.current=g,()=>{g.destroy(),d.current=null;}},[]),useEffect(()=>{d.current?.dispatch({effects:b.current.reconfigure([n==="dark"?a$3:b$6,bn])});},[n]),useEffect(()=>{d.current&&updateSchema(d.current,t??void 0);},[t]),useEffect(()=>{let u=d.current;!u||u.state.doc.toString()===r||u.dispatch({changes:{from:0,to:u.state.doc.length,insert:r}});},[r]),jsx("div",{className:"fk:h-full fk:min-h-0 fk:w-full","data-testid":"graph-query-editor",ref:o})}var Ge=200,Mr=5,Gr=3;function Sn(e){return typeof e=="object"&&e!==null&&typeof e._id=="string"}function ge(e){if(Array.isArray(e))return e.flatMap(ge);if(typeof e!="object"||e===null)return [];if(Sn(e))return [e];let{edges:t}=e;return Array.isArray(t)?t.flatMap(n=>ge(n?.node)):[]}function Dr(e,t){let n=e.endsWith("Connection")?e.slice(0,-10):e;return t.find(r=>r.plural===n)}function Lr(e,t){let n=e.endsWith("Connection")?e.slice(0,-10):e;return e$3(t).find(r=>r.name===n)}function Ir(e,t){let n=e$3(e).filter(r=>r.relationship?.entity===t);return n.length===1?n[0]:void 0}function Pr(e,t,n){let r=e.__typename;return typeof r=="string"&&g$1(n,r)||t}function _r(e,t$1,n){let r=t(e,t$1,n);if(r!==e._id)return r;let i=Object.entries(e).find(([a,o])=>!a.startsWith("_")&&typeof o=="string"&&o.trim().length>0);return i?i[1]:e._id}function En({data:e,schema:t,scope:n}){let r=new Map,i=new Map,a=(o,d$1)=>{let b=Pr(o,d$1,t);if(!b)return null;let C=d(b.name,o._id),k=_r(o,b,n),l=r.get(C),u$1=l??{key:C,entity:b.name,id:o._id,label:k};return l?l.label===l.id&&k!==o._id&&(l.label=k):r.set(C,u$1),Object.entries(o).forEach(([g,f])=>{let E=Lr(g,b),p=E?g$1(t,E.relationship?.entity??""):void 0;ge(f).forEach(S=>{let s=a(S,p),N=E??(s?Ir(b,s.entity):void 0);if(s&&N&&s.key!==u$1.key){let m=u(u$1,s,N);i.has(m.key)||i.set(m.key,m);}});}),u$1};return Object.entries(e??{}).forEach(([o,d])=>{let b=Dr(o,t);ge(d).forEach(C=>a(C,b));}),{nodes:[...r.values()],edges:[...i.values()],counts:{}}}function Nn(e,t,n){return f$1(e).map(r=>{let i=e$3(r).slice(0,Gr).map(o=>{let d=g$1(e,o.relationship?.entity??"");return ` ${o.name}(limit: ${Mr}) {
|
|
4
4
|
_id
|
|
@@ -10,5 +10,5 @@ ${a?` ${a}
|
|
|
10
10
|
`:""}${i.join(`
|
|
11
11
|
`)}
|
|
12
12
|
}
|
|
13
|
-
}`}})}function Or(e,t){let n=ge(e);return n.length>0?`${n.length} ${n.length===1?"record":"records"}`:Array.isArray(e)&&!(typeof e[0]=="object"&&e[0]!==null)?e.map(r=>s$1(r,t)).join(", "):s$1(e,t)}function et(e){if(Array.isArray(e))return e.flatMap(et);if(typeof e!="object"||e===null)return [];let{edges:t}=e;return !Sn(e)&&Array.isArray(t)?t.flatMap(n=>et(n?.node)):[e]}function vn(e,t){let n=Object.values(e??{}).flatMap(et),r=n.slice(0,Ge),i=[];return r.forEach(a=>{Object.keys(a).forEach(o=>{o!=="__typename"&&!i.includes(o)&&i.push(o);});}),{columns:i,rows:r.map(a=>Object.fromEntries(i.map(o=>[o,Or(a[o],t)]))),total:n.length}}function Me(e){return Array.isArray(e)?e.map(Me):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).filter(([t])=>t!=="__typename").map(([t,n])=>[t,Me(n)])):e}function tt(e){return `flexkit-graph:query:${e}`}var De=new Map;function Xr(e,t,n){let r=De.get(t);if(r&&r.hash===n)return r.schema;let i=e.query({query:gql(getIntrospectionQuery()),fetchPolicy:"no-cache",context:f$3}).then(a=>{if(!a.data)throw new Error("The schema could not be introspected.");return buildClientSchema(a.data)});return i.catch(()=>{De.get(t)?.schema===i&&De.delete(t);}),De.set(t,{hash:n,schema:i}),i}function wn(e,t){let n=useApolloClient(),[r,i]=useState(null);return useEffect(()=>{if(!e)return;let a=false;return Xr(n,e,t??"").then(o=>{a||i(o);}).catch(()=>{}),()=>{a=true;}},[n,e,t]),r}function An({projectId:e,schemaHash:t,schema:n$1,scope:r,theme:i,isRunning:a,hidden:o,onRun:d}){let[b,C]=useState(!o),k=wn(b?e:void 0,t),l=f$2(),u=useMemo(()=>Nn(n$1,r,l),[l,n$1,r]),[g,f]=useState(()=>b$5(tt(e))||u[0]?.query||""),E=useRef(g!==""),[p,S]=useState(false),[s,N]=useState("graph"),[m,D]=useState(null),_$1=useMemo(()=>s==="table"&&m?.data?vn(m.data,r):null,[s,m,r]),$=useMemo(()=>s==="json"&&m?.data?JSON.stringify(Me(m.data),null,2):null,[s,m]);useEffect(()=>{o||C(true);},[o]),useEffect(()=>{let[A]=u;!E.current&&A&&(E.current=true,f(q=>q||A.query));},[u]),useEffect(()=>{c$4(tt(e),g);},[e,g]);let v=async()=>{!g.trim()||a||D(await d(g,{append:p}));};return jsxs("section",{"aria-label":"Query",className:`fk:w-[26rem] fk:shrink-0 fk:flex-col fk:border-r fk:bg-background ${o?"fk:hidden":"fk:flex"}`,"data-testid":"graph-query-pane",hidden:o,children:[jsxs("div",{className:"fk:flex fk:h-12 fk:shrink-0 fk:items-center fk:gap-2 fk:border-b fk:pl-4 fk:pr-3",children:[jsx("span",{className:"fk:text-sm fk:font-semibold",children:"Query"}),jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-1.5",children:[u.length>0?jsxs(e$4,{children:[jsx(g$2,{asChild:true,children:jsxs(c$3,{className:"fk:h-8",size:"sm",variant:"outline",children:["Examples",jsx(ChevronDownIcon,{className:"fk:size-3.5"})]})}),jsx(h$1,{align:"end",className:"fk:max-h-80 fk:overflow-y-auto",children:u.map(A=>jsx(j$1,{onSelect:()=>f(A.query),children:A.title},A.entity))})]}):null,jsxs(c$3,{className:"fk:h-8",disabled:a||!g.trim(),onClick:()=>{v();},size:"sm",children:[a?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(PlayIcon,{className:"fk:size-3.5"}),"Run"]})]})]}),jsx("div",{className:"fk:min-h-0 fk:flex-1",children:jsx(xn,{ariaLabel:"GraphQL query",onChange:f,onRun:()=>{v();},schema:k,theme:i,value:g})}),jsxs(ea,{className:"fk:flex fk:max-h-[45%] fk:shrink-0 fk:flex-col fk:gap-0 fk:border-t",onValueChange:A=>N(A),value:s,children:[jsxs("div",{className:"fk:flex fk:h-11 fk:shrink-0 fk:items-center fk:gap-3 fk:px-3",children:[jsxs(fa,{children:[jsx(ga,{value:"graph",children:"Graph"}),jsx(ga,{value:"table",children:"Table"}),jsx(ga,{value:"json",children:"JSON"})]}),jsx("span",{className:"fk:ml-auto fk:truncate fk:text-xs fk:text-muted-foreground","data-testid":"graph-query-stats",children:m&&!m.error?`${m.nodes.toLocaleString()} ${m.nodes===1?"node":"nodes"} \xB7 ${m.edges.toLocaleString()} ${m.edges===1?"relationship":"relationships"} \xB7 ${m.elapsedMs.toLocaleString()} ms`:null})]}),m?.error?jsx("pre",{className:"fk:m-3 fk:mt-0 fk:max-h-40 fk:shrink-0 fk:overflow-auto fk:whitespace-pre-wrap fk:rounded-md fk:border fk:border-destructive/40 fk:bg-destructive/5 fk:p-2 fk:text-xs fk:text-destructive","data-testid":"graph-query-error",children:m.error}):null,jsxs("div",{className:"fk:min-h-0 fk:overflow-auto",children:[jsxs(ha,{className:"fk:flex fk:flex-col fk:gap-3 fk:px-3 fk:pb-3 fk:text-xs fk:text-muted-foreground",value:"graph",children:[jsxs("span",{children:["Every object with an ",jsx("code",{className:"fk:font-mono",children:"_id"})," under an entity field becomes a node; a nested relationship selection becomes a line between them."]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(n,{checked:p,id:"graph-query-append",onCheckedChange:A=>S(A===true)}),jsx(a$2,{className:"fk:text-xs fk:font-normal",htmlFor:"graph-query-append",children:"Add to the current canvas instead of replacing it"})]})]}),jsx(ha,{className:"fk:px-3 fk:pb-3",value:"table",children:_$1&&_$1.columns.length>0?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("div",{className:"fk:overflow-x-auto fk:rounded-md fk:border",children:jsxs(Y,{children:[jsx(Z,{children:jsx(aa,{children:_$1.columns.map(A=>jsx(ba,{className:"fk:h-8 fk:text-xs",children:A},A))})}),jsx(_,{children:_$1.rows.map((A,q)=>jsx(aa,{children:_$1.columns.map(c=>jsx(ca,{className:"fk:max-w-56 fk:truncate fk:py-1.5 fk:text-xs",title:A[c],children:A[c]},c))},`${A._id??""}-${q}`))})]})}),_$1.total>Ge?jsxs("span",{className:"fk:text-xs fk:text-muted-foreground",children:["First ",Ge.toLocaleString()," of ",_$1.total.toLocaleString()," records."]}):null]}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:m?.data?"The response has no rows to show.":"Run a query to see its records."})}),jsx(ha,{className:"fk:px-3 fk:pb-3",value:"json",children:$?jsx("pre",{className:"fk:overflow-auto fk:rounded-md fk:border fk:bg-muted/40 fk:p-2 fk:font-mono fk:text-xs",children:$}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Run a query to see its response."})})]})]})]})}var eo=250,to=5;function no(e,t){let n=t.trim();return !n||e.length===0?null:{searchRequests:{searches:e.map(r=>({collection:r.plural}))},commonParams:{q:n,limit:to}}}function ro(e){let t=useMemo(()=>q$1(e),[e]),n=useMemo(()=>gql(t.length>0?r$1(t):"query GraphTotals { __typename }"),[t]),{data:r}=useQuery(n,{skip:t.length===0});return useMemo(()=>Object.fromEntries(t.map(i=>[i.plural,r?.[`${i.plural}Total`]]).filter(i=>typeof i[1]=="number")),[t,r])}function Cn({projectId:e,entities:t,colors:n$1,onCanvas:r,hiddenEntities:i,onStart:a,onHit:o,onToggleEntity:d}){let[b,C]=useState(""),[k]=useDebounce(b,eo),l=useMemo(()=>t.filter(s=>s.attributes.some(N=>N.searchable)),[t]),u=useMemo(()=>no(l,k),[l,k]),{results:g,isLoading:f}=a$1(e,u),E=ro(t),p=useMemo(()=>new Map(t.map(s=>[s.name,s])),[t]),S=Object.keys(r).sort();return jsxs(L,{collapsible:"icon",variant:"inset",children:[jsxs(P,{children:[jsxs(Q,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsxs("div",{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:pointer-events-none fk:absolute fk:left-2 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(b$3,{"aria-label":"Search records to add to the canvas",className:"fk:h-8 fk:bg-background fk:pl-8 fk:shadow-none",onChange:s=>C(s.target.value),placeholder:l.length>0?"Search records\u2026":"No searchable entity",disabled:l.length===0,value:b})]}),u?jsxs("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-0.5","data-testid":"graph-search-results",children:[g.map(s=>{let N=p.get(s._entityName),m=s[b$4(N)?.name??""];return jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-2 fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:text-sm fk:hover:bg-sidebar-accent",onClick:()=>o(s._entityName,s._id),type:"button",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s._entityName]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",children:String(m??s._id)})]})},`${s._entityName}:${s._id}`)}),!f&&g.length===0?jsx("li",{className:"fk:px-2 fk:py-1.5 fk:text-sm fk:text-muted-foreground",children:"Nothing found"}):null]}):null]}),jsxs(Q,{children:[jsx(R,{children:"Nodes"}),jsx(T,{children:t.map(s=>jsx(U,{children:jsxs(V,{onClick:()=>a(s),tooltip:h(s),children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s.name]??"#71717a"}}),jsx("span",{className:"fk:truncate",children:h(s)}),E[s.plural]!==void 0?jsx("span",{className:"fk:ml-auto fk:text-xs fk:text-muted-foreground",children:E[s.plural]?.toLocaleString()}):null]})},s.name))})]}),S.length>0?jsxs(Q,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsx(R,{children:"On canvas"}),jsx("ul",{className:"fk:flex fk:flex-col","data-testid":"graph-legend",children:S.map(s=>{let N=p.get(s),m=!i.includes(s),D=`graph-legend-${s}`;return jsxs("li",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2 fk:px-2 fk:text-sm",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s]??"#71717a",opacity:m?1:.35}}),jsx("label",{className:"fk:min-w-0 fk:flex-1 fk:cursor-pointer fk:truncate",htmlFor:D,children:N?h(N):s}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:r[s]?.toLocaleString()}),jsx(n,{"aria-label":`Show ${N?h(N):s}`,checked:m,id:D,onCheckedChange:()=>d(s)})]},s)})})]}):null]}),jsx(N,{})]})}function Le({label:e,icon:t,disabled:n,onClick:r}){return jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(c$3,{className:"fk:h-8 fk:gap-1.5 fk:px-2.5",disabled:n,onClick:r,size:"sm",variant:"ghost",children:[t,jsx("span",{className:"fk:text-xs",children:e})]})}),jsx(e$2,{children:e})]})}function Rn({hasSelection:e,hasNodes:t,isLoading:n,onFit:r,onExpand:i,onHide:a,onClear:o}){return jsxs("div",{className:"fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-1 fk:shadow-xs","data-testid":"graph-toolbar",children:[jsx(Le,{disabled:!t,icon:jsx(ScanIcon,{className:"fk:size-3.5"}),label:"Fit",onClick:r}),jsx(l$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!e||n,icon:n?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(ExpandIcon,{className:"fk:size-3.5"}),label:"Expand",onClick:i}),jsx(Le,{disabled:!e,icon:jsx(EyeOffIcon,{className:"fk:size-3.5"}),label:"Hide",onClick:a}),jsx(l$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!t,icon:jsx(EraserIcon,{className:"fk:size-3.5"}),label:"Clear",onClick:o})]})}function Pe(e,t="The records could not be loaded."){return e instanceof Error?e.message:t}function Tn({schema:e,scope:t}){let n=f$2(),r=useApolloClient(),[i,a$1]=useReducer(dn,We),[o,d$1]=useState(0),b=useRef(0),C=useCallback(async(g,f)=>{let E="ids"in f?f.ids:void 0,p="ids"in f?f.expand:false,S="limit"in f?f.limit:E?.length;d$1(s=>s+1);try{let N=(await r.query({query:gql(l({defaultScope:n,entity:g,schema:e,scope:t,expand:p})),variables:{where:E?{_id:{in:E}}:void 0,limit:S},fetchPolicy:"network-only"})).data?.[g.plural]??[];return b.current+=1,a$1({type:"merge",data:v({records:N,entity:g,schema:e,scope:t}),fetched:w(N,g)}),N.map(m=>d(g.name,m._id))}catch(s){return ma.error(Pe(s)),[]}finally{d$1(s=>s-1);}},[n,r,e,t]),k=useCallback(async g=>{let f=i.nodes[g],E=f?g$1(e,f.entity):void 0;!f||!E||await C(E,{ids:[f.id],expand:true});},[C,e,i.nodes]),l$1=useCallback(async(g,f)=>{let E=i.nodes[g],p=E?g$1(e,E.entity):void 0;if(!E||!p)return;let S=i.fetched[g]?.[f.name]??0;d$1(s=>s+1);try{let N=(await r.query({query:gql(m({defaultScope:n,entity:p,schema:e,scope:t,attribute:f})),variables:{id:E.id,offset:S,limit:a},fetchPolicy:"network-only"})).data?.[p.plural]??[];b.current+=1;let m$1=N.reduce((D,_)=>{let $=_[f.name];return D+(Array.isArray($)?$.length:0)},0);a$1({type:"merge",data:v({records:N,entity:p,schema:e,scope:t}),fetched:{[g]:{[f.name]:S+m$1}}});}catch(s){ma.error(Pe(s));}finally{d$1(s=>s-1);}},[n,r,e,t,i.fetched,i.nodes]),u=useCallback(async(g,{append:f})=>{let E=performance.now(),p;try{p=gql(g);}catch(s){return {data:null,error:Pe(s,"The query could not be parsed."),elapsedMs:0,nodes:0,edges:0}}let S=b.current;d$1(s=>s+1);try{let s=await r.query({query:p,fetchPolicy:"no-cache",errorPolicy:"all",context:f$3}),N=s.data??null,m=En({data:N,schema:e,scope:t});return m.nodes.length>0&&(!f&&!s.error&&b.current===S&&a$1({type:"clear"}),b.current+=1,a$1({type:"merge",data:m})),{data:N,error:s.error?s.error.message:null,elapsedMs:Math.round(performance.now()-E),nodes:m.nodes.length,edges:m.edges.length}}catch(s){return {data:null,error:Pe(s,"The query failed."),elapsedMs:Math.round(performance.now()-E),nodes:0,edges:0}}finally{d$1(s=>s-1);}},[r,e,t]);return {state:i,dispatch:a$1,isLoading:o>0,loadRecords:C,expandAll:k,expandAttribute:l$1,runQuery:u}}function is(){let{currentProjectId:e$4,currentProject:t,currentProjectSchema:n}=f();useEffect(()=>{e$4&&t&&e({event:"graph_opened",projectId:e$4});},[e$4,t]);let[,r]=g(),{scope:i$1}=c(),{resolvedTheme:a}=b(),o=useLocation(),d=j(),b$3=a==="dark"?"dark":"light",C=e$1(t?.scopes),k$1=i$1||C,l=r.user?.spaces,u=useMemo(()=>c$1(n,l),[n,l]),g$2=useMemo(()=>f$1(u),[u]),f$2=useMemo(()=>i(u,b$3),[u,b$3]),E=Tn({schema:u,scope:k$1}),{state:p,dispatch:S,isLoading:s,loadRecords:N,expandAll:m,expandAttribute:D,runQuery:_}=E,$=useRef(null),[v,A]=useState(null),[q,c$4]=useState(false),[y$1,w]=useState("explore"),R=useRef(null),G=useMemo(()=>fn(p),[p]),Q=p.selected?p.nodes[p.selected]:void 0,Y=v?p.nodes[v.key]:void 0,V=Y?g$1(u,Y.entity):void 0,K$1=Object.keys(p.nodes).length,h=Object.keys(p.edges).length,T=I(),L=useCallback(x=>S({type:"select",key:x}),[S]),oe=useCallback(x=>{let O=p.nodes[x],ie=O?g$1(u,O.entity):void 0;O&&ie&&d({type:"EditEntity",payload:{entityId:O.id,entityNamePlural:ie.plural}});},[d,u,p.nodes]),Oe=useCallback(x=>S({type:"remove",keys:[x]}),[S]),Dn=useCallback(x=>S({type:"keepOnly",keys:[x,...mn(p,x)]}),[S,p]),Ln=useCallback(x=>S({type:"togglePin",key:x}),[S]),In=useCallback(x=>{p.pinned[x]||S({type:"togglePin",key:x});},[S,p.pinned]),Pn=useCallback(async(x,O)=>{let ie=g$1(u,x);if(!ie)return;let[fe]=await N(ie,{ids:[O],expand:true});fe&&L(fe);},[N,u,L]),_n=useCallback((x,O)=>{A(null),D(x,O);},[D]);return useEffect(()=>{let x=y(o.search);if(!x||R.current===o.key)return;let O=g$1(u,x.entity);if(!O||u.length===0)return;R.current=o.key;let ie=x.ids.length>0?{ids:x.ids,expand:x.ids.length<=k}:{limit:b$1};N(O,ie).then(fe=>{x.ids.length===1&&fe[0]&&L(fe[0]);});},[o.key,o.search,u,N,L]),e$4?jsxs(K,{className:"fk:h-full",defaultOpen:T,children:[jsx(Cn,{colors:f$2,entities:g$2,hiddenEntities:p.hiddenEntities,onCanvas:G,onHit:(x,O)=>{Pn(x,O);},onStart:x=>{N(x,{limit:b$1});},onToggleEntity:x=>S({type:"toggleEntity",entity:x}),projectId:e$4}),jsx(O,{className:"fk:min-w-0",children:jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0","data-testid":"graph-app",children:[jsx(An,{hidden:y$1!=="query",isRunning:s,onRun:_,projectId:e$4,schema:u,schemaHash:t?.schemaHash??null,scope:k$1,theme:b$3},e$4),jsxs("div",{className:"fk:relative fk:min-w-0 fk:flex-1 fk:overflow-hidden fk:bg-background",children:[jsxs("div",{className:"fk:pointer-events-none fk:absolute fk:left-3 fk:right-3 fk:top-3 fk:z-10 fk:flex fk:flex-wrap fk:items-start fk:justify-between fk:gap-2",children:[jsxs("div",{className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsx(M,{className:"fk:h-8 fk:w-8 fk:rounded-lg fk:hover:bg-transparent fk:dark:hover:bg-transparent"})}),jsx(e$2,{children:"Toggle Sidebar"})]}),jsx(Rn,{hasNodes:K$1>0,hasSelection:Q!==void 0,isLoading:s,onClear:()=>S({type:"clear"}),onExpand:()=>{p.selected&&m(p.selected);},onFit:()=>$.current?.fit(),onHide:()=>{p.selected&&Oe(p.selected);}})]}),jsxs("div",{"aria-label":"View",className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-0.5 fk:shadow-xs","data-testid":"graph-mode",role:"group",children:[jsx(c$3,{"aria-pressed":y$1==="explore",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>w("explore"),size:"sm",variant:y$1==="explore"?"default":"ghost",children:"Explore"}),jsx(c$3,{"aria-pressed":y$1==="query",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>w("query"),size:"sm",variant:y$1==="query"?"default":"ghost",children:"Query"})]})]}),K$1>0?null:jsx("div",{className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground",children:s?"Loading records\u2026":y$1==="query"?"Run a query to draw its result.":"Search a record or start from an entity to draw its graph."}),jsx(ln,{apiRef:$,colors:f$2,onContextMenu:(x,O)=>A({key:x,...O}),onExpand:x=>{m(x);},onLayoutChange:c$4,onPin:In,onSelect:L,scene:p,theme:b$3}),jsxs("div",{className:"fk:absolute fk:bottom-3 fk:left-3 fk:flex fk:max-w-[calc(100%-1.5rem)] fk:items-center fk:gap-2 fk:rounded-lg fk:border fk:bg-background fk:px-2.5 fk:py-1.5 fk:text-xs fk:text-muted-foreground fk:shadow-xs","data-testid":"graph-status",children:[jsxs("span",{children:[K$1.toLocaleString()," ",K$1===1?"node":"nodes"," \xB7 ",h.toLocaleString()," ",h===1?"relationship":"relationships"]}),q?jsx("span",{children:"\xB7 laying out\u2026"}):null,p.notice?jsxs("span",{className:"fk:truncate fk:text-foreground",children:["\xB7 ",p.notice]}):null]}),jsx(un,{isPinned:v?p.pinned[v.key]===true:false,menu:v,onClose:()=>A(null),onExpandAll:x=>{m(x);},onExpandAttribute:_n,onHide:Oe,onHideOthers:Dn,onOpenRecord:oe,onTogglePin:Ln,relationships:V?e$3(V):[]})]}),Q?jsx(kn,{colors:f$2,isLoading:s,node:Q,onClose:()=>L(null),onExpandAll:x=>{m(x);},onExpandAttribute:(x,O)=>{D(x,O);},onHide:Oe,onOpenRecord:oe,scene:p,schema:u,scope:k$1}):null]})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to explore its graph."})}export{is as Root};//# sourceMappingURL=root-IXK2ESCS.js.map
|
|
14
|
-
//# sourceMappingURL=root-
|
|
13
|
+
}`}})}function Or(e,t){let n=ge(e);return n.length>0?`${n.length} ${n.length===1?"record":"records"}`:Array.isArray(e)&&!(typeof e[0]=="object"&&e[0]!==null)?e.map(r=>s$1(r,t)).join(", "):s$1(e,t)}function et(e){if(Array.isArray(e))return e.flatMap(et);if(typeof e!="object"||e===null)return [];let{edges:t}=e;return !Sn(e)&&Array.isArray(t)?t.flatMap(n=>et(n?.node)):[e]}function vn(e,t){let n=Object.values(e??{}).flatMap(et),r=n.slice(0,Ge),i=[];return r.forEach(a=>{Object.keys(a).forEach(o=>{o!=="__typename"&&!i.includes(o)&&i.push(o);});}),{columns:i,rows:r.map(a=>Object.fromEntries(i.map(o=>[o,Or(a[o],t)]))),total:n.length}}function Me(e){return Array.isArray(e)?e.map(Me):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).filter(([t])=>t!=="__typename").map(([t,n])=>[t,Me(n)])):e}function tt(e){return `flexkit-graph:query:${e}`}var De=new Map;function Xr(e,t,n){let r=De.get(t);if(r&&r.hash===n)return r.schema;let i=e.query({query:gql(getIntrospectionQuery()),fetchPolicy:"no-cache",context:f$3}).then(a=>{if(!a.data)throw new Error("The schema could not be introspected.");return buildClientSchema(a.data)});return i.catch(()=>{De.get(t)?.schema===i&&De.delete(t);}),De.set(t,{hash:n,schema:i}),i}function wn(e,t){let n=useApolloClient(),[r,i]=useState(null);return useEffect(()=>{if(!e)return;let a=false;return Xr(n,e,t??"").then(o=>{a||i(o);}).catch(()=>{}),()=>{a=true;}},[n,e,t]),r}function An({projectId:e,schemaHash:t,schema:n$1,scope:r,theme:i,isRunning:a,hidden:o,onRun:d}){let[b,C]=useState(!o),k=wn(b?e:void 0,t),l=f$2(),u=useMemo(()=>Nn(n$1,r,l),[l,n$1,r]),[g,f]=useState(()=>b$5(tt(e))||u[0]?.query||""),E=useRef(g!==""),[p,S]=useState(false),[s,N]=useState("graph"),[m,D]=useState(null),_$1=useMemo(()=>s==="table"&&m?.data?vn(m.data,r):null,[s,m,r]),$=useMemo(()=>s==="json"&&m?.data?JSON.stringify(Me(m.data),null,2):null,[s,m]);useEffect(()=>{o||C(true);},[o]),useEffect(()=>{let[A]=u;!E.current&&A&&(E.current=true,f(q=>q||A.query));},[u]),useEffect(()=>{c$4(tt(e),g);},[e,g]);let v=async()=>{!g.trim()||a||D(await d(g,{append:p}));};return jsxs("section",{"aria-label":"Query",className:`fk:w-[26rem] fk:shrink-0 fk:flex-col fk:border-r fk:bg-background ${o?"fk:hidden":"fk:flex"}`,"data-testid":"graph-query-pane",hidden:o,children:[jsxs("div",{className:"fk:flex fk:h-12 fk:shrink-0 fk:items-center fk:gap-2 fk:border-b fk:pl-4 fk:pr-3",children:[jsx("span",{className:"fk:text-sm fk:font-semibold",children:"Query"}),jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-1.5",children:[u.length>0?jsxs(e$4,{children:[jsx(g$2,{asChild:true,children:jsxs(c$3,{className:"fk:h-8",size:"sm",variant:"outline",children:["Examples",jsx(ChevronDownIcon,{className:"fk:size-3.5"})]})}),jsx(h$1,{align:"end",className:"fk:max-h-80 fk:overflow-y-auto",children:u.map(A=>jsx(j$1,{onSelect:()=>f(A.query),children:A.title},A.entity))})]}):null,jsxs(c$3,{className:"fk:h-8",disabled:a||!g.trim(),onClick:()=>{v();},size:"sm",children:[a?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(PlayIcon,{className:"fk:size-3.5"}),"Run"]})]})]}),jsx("div",{className:"fk:min-h-0 fk:flex-1",children:jsx(xn,{ariaLabel:"GraphQL query",onChange:f,onRun:()=>{v();},schema:k,theme:i,value:g})}),jsxs(ea,{className:"fk:flex fk:max-h-[45%] fk:shrink-0 fk:flex-col fk:gap-0 fk:border-t",onValueChange:A=>N(A),value:s,children:[jsxs("div",{className:"fk:flex fk:h-11 fk:shrink-0 fk:items-center fk:gap-3 fk:px-3",children:[jsxs(fa,{children:[jsx(ga,{value:"graph",children:"Graph"}),jsx(ga,{value:"table",children:"Table"}),jsx(ga,{value:"json",children:"JSON"})]}),jsx("span",{className:"fk:ml-auto fk:truncate fk:text-xs fk:text-muted-foreground","data-testid":"graph-query-stats",children:m&&!m.error?`${m.nodes.toLocaleString()} ${m.nodes===1?"node":"nodes"} \xB7 ${m.edges.toLocaleString()} ${m.edges===1?"relationship":"relationships"} \xB7 ${m.elapsedMs.toLocaleString()} ms`:null})]}),m?.error?jsx("pre",{className:"fk:m-3 fk:mt-0 fk:max-h-40 fk:shrink-0 fk:overflow-auto fk:whitespace-pre-wrap fk:rounded-md fk:border fk:border-destructive/40 fk:bg-destructive/5 fk:p-2 fk:text-xs fk:text-destructive","data-testid":"graph-query-error",children:m.error}):null,jsxs("div",{className:"fk:min-h-0 fk:overflow-auto",children:[jsxs(ha,{className:"fk:flex fk:flex-col fk:gap-3 fk:px-3 fk:pb-3 fk:text-xs fk:text-muted-foreground",value:"graph",children:[jsxs("span",{children:["Every object with an ",jsx("code",{className:"fk:font-mono",children:"_id"})," under an entity field becomes a node; a nested relationship selection becomes a line between them."]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(n,{checked:p,id:"graph-query-append",onCheckedChange:A=>S(A===true)}),jsx(a$2,{className:"fk:text-xs fk:font-normal",htmlFor:"graph-query-append",children:"Add to the current canvas instead of replacing it"})]})]}),jsx(ha,{className:"fk:px-3 fk:pb-3",value:"table",children:_$1&&_$1.columns.length>0?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("div",{className:"fk:overflow-x-auto fk:rounded-md fk:border",children:jsxs(Y,{children:[jsx(Z,{children:jsx(aa,{children:_$1.columns.map(A=>jsx(ba,{className:"fk:h-8 fk:text-xs",children:A},A))})}),jsx(_,{children:_$1.rows.map((A,q)=>jsx(aa,{children:_$1.columns.map(c=>jsx(ca,{className:"fk:max-w-56 fk:truncate fk:py-1.5 fk:text-xs",title:A[c],children:A[c]},c))},`${A._id??""}-${q}`))})]})}),_$1.total>Ge?jsxs("span",{className:"fk:text-xs fk:text-muted-foreground",children:["First ",Ge.toLocaleString()," of ",_$1.total.toLocaleString()," records."]}):null]}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:m?.data?"The response has no rows to show.":"Run a query to see its records."})}),jsx(ha,{className:"fk:px-3 fk:pb-3",value:"json",children:$?jsx("pre",{className:"fk:overflow-auto fk:rounded-md fk:border fk:bg-muted/40 fk:p-2 fk:font-mono fk:text-xs",children:$}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Run a query to see its response."})})]})]})]})}var eo=250,to=5;function no(e,t){let n=t.trim();return !n||e.length===0?null:{searchRequests:{searches:e.map(r=>({collection:r.plural}))},commonParams:{q:n,limit:to}}}function ro(e){let t=useMemo(()=>q$1(e),[e]),n=useMemo(()=>gql(t.length>0?r$1(t):"query GraphTotals { __typename }"),[t]),{data:r}=useQuery(n,{skip:t.length===0});return useMemo(()=>Object.fromEntries(t.map(i=>[i.plural,r?.[`${i.plural}Total`]]).filter(i=>typeof i[1]=="number")),[t,r])}function Cn({projectId:e,entities:t,colors:n$1,onCanvas:r,hiddenEntities:i,onStart:a,onHit:o,onToggleEntity:d}){let[b,C]=useState(""),[k]=useDebounce(b,eo),l=useMemo(()=>t.filter(s=>s.attributes.some(N=>N.searchable)),[t]),u=useMemo(()=>no(l,k),[l,k]),{results:g,isLoading:f}=a$1(e,u),E=ro(t),p=useMemo(()=>new Map(t.map(s=>[s.name,s])),[t]),S=Object.keys(r).sort();return jsxs(L,{collapsible:"icon",variant:"inset",children:[jsxs(P,{children:[jsxs(Q,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsxs("div",{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:pointer-events-none fk:absolute fk:left-2 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(b$3,{"aria-label":"Search records to add to the canvas",className:"fk:h-8 fk:bg-background fk:pl-8 fk:shadow-none",onChange:s=>C(s.target.value),placeholder:l.length>0?"Search records\u2026":"No searchable entity",disabled:l.length===0,value:b})]}),u?jsxs("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-0.5","data-testid":"graph-search-results",children:[g.map(s=>{let N=p.get(s._entityName),m=s[b$4(N)?.name??""];return jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-2 fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:text-sm fk:hover:bg-sidebar-accent",onClick:()=>o(s._entityName,s._id),type:"button",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s._entityName]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",children:String(m??s._id)})]})},`${s._entityName}:${s._id}`)}),!f&&g.length===0?jsx("li",{className:"fk:px-2 fk:py-1.5 fk:text-sm fk:text-muted-foreground",children:"Nothing found"}):null]}):null]}),jsxs(Q,{children:[jsx(R,{children:"Nodes"}),jsx(T,{children:t.map(s=>jsx(U,{children:jsxs(V,{onClick:()=>a(s),tooltip:h(s),children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s.name]??"#71717a"}}),jsx("span",{className:"fk:truncate",children:h(s)}),E[s.plural]!==void 0?jsx("span",{className:"fk:ml-auto fk:text-xs fk:text-muted-foreground",children:E[s.plural]?.toLocaleString()}):null]})},s.name))})]}),S.length>0?jsxs(Q,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsx(R,{children:"On canvas"}),jsx("ul",{className:"fk:flex fk:flex-col","data-testid":"graph-legend",children:S.map(s=>{let N=p.get(s),m=!i.includes(s),D=`graph-legend-${s}`;return jsxs("li",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2 fk:px-2 fk:text-sm",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s]??"#71717a",opacity:m?1:.35}}),jsx("label",{className:"fk:min-w-0 fk:flex-1 fk:cursor-pointer fk:truncate",htmlFor:D,children:N?h(N):s}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:r[s]?.toLocaleString()}),jsx(n,{"aria-label":`Show ${N?h(N):s}`,checked:m,id:D,onCheckedChange:()=>d(s)})]},s)})})]}):null]}),jsx(N,{})]})}function Le({label:e,icon:t,disabled:n,onClick:r}){return jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(c$3,{className:"fk:h-8 fk:gap-1.5 fk:px-2.5",disabled:n,onClick:r,size:"sm",variant:"ghost",children:[t,jsx("span",{className:"fk:text-xs",children:e})]})}),jsx(e$2,{children:e})]})}function Rn({hasSelection:e,hasNodes:t,isLoading:n,onFit:r,onExpand:i,onHide:a,onClear:o}){return jsxs("div",{className:"fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-1 fk:shadow-xs","data-testid":"graph-toolbar",children:[jsx(Le,{disabled:!t,icon:jsx(ScanIcon,{className:"fk:size-3.5"}),label:"Fit",onClick:r}),jsx(l$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!e||n,icon:n?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(ExpandIcon,{className:"fk:size-3.5"}),label:"Expand",onClick:i}),jsx(Le,{disabled:!e,icon:jsx(EyeOffIcon,{className:"fk:size-3.5"}),label:"Hide",onClick:a}),jsx(l$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!t,icon:jsx(EraserIcon,{className:"fk:size-3.5"}),label:"Clear",onClick:o})]})}function Pe(e,t="The records could not be loaded."){return e instanceof Error?e.message:t}function Tn({schema:e,scope:t}){let n=f$2(),r=useApolloClient(),[i,a$1]=useReducer(dn,We),[o,d$1]=useState(0),b=useRef(0),C=useCallback(async(g,f)=>{let E="ids"in f?f.ids:void 0,p="ids"in f?f.expand:false,S="limit"in f?f.limit:E?.length;d$1(s=>s+1);try{let N=(await r.query({query:gql(l({defaultScope:n,entity:g,schema:e,scope:t,expand:p})),variables:{where:E?{_id:{in:E}}:void 0,limit:S},fetchPolicy:"network-only"})).data?.[g.plural]??[];return b.current+=1,a$1({type:"merge",data:v({records:N,entity:g,schema:e,scope:t}),fetched:w(N,g)}),N.map(m=>d(g.name,m._id))}catch(s){return ma.error(Pe(s)),[]}finally{d$1(s=>s-1);}},[n,r,e,t]),k=useCallback(async g=>{let f=i.nodes[g],E=f?g$1(e,f.entity):void 0;!f||!E||await C(E,{ids:[f.id],expand:true});},[C,e,i.nodes]),l$1=useCallback(async(g,f)=>{let E=i.nodes[g],p=E?g$1(e,E.entity):void 0;if(!E||!p)return;let S=i.fetched[g]?.[f.name]??0;d$1(s=>s+1);try{let N=(await r.query({query:gql(m({defaultScope:n,entity:p,schema:e,scope:t,attribute:f})),variables:{id:E.id,offset:S,limit:a},fetchPolicy:"network-only"})).data?.[p.plural]??[];b.current+=1;let m$1=N.reduce((D,_)=>{let $=_[f.name];return D+(Array.isArray($)?$.length:0)},0);a$1({type:"merge",data:v({records:N,entity:p,schema:e,scope:t}),fetched:{[g]:{[f.name]:S+m$1}}});}catch(s){ma.error(Pe(s));}finally{d$1(s=>s-1);}},[n,r,e,t,i.fetched,i.nodes]),u=useCallback(async(g,{append:f})=>{let E=performance.now(),p;try{p=gql(g);}catch(s){return {data:null,error:Pe(s,"The query could not be parsed."),elapsedMs:0,nodes:0,edges:0}}let S=b.current;d$1(s=>s+1);try{let s=await r.query({query:p,fetchPolicy:"no-cache",errorPolicy:"all",context:f$3}),N=s.data??null,m=En({data:N,schema:e,scope:t});return m.nodes.length>0&&(!f&&!s.error&&b.current===S&&a$1({type:"clear"}),b.current+=1,a$1({type:"merge",data:m})),{data:N,error:s.error?s.error.message:null,elapsedMs:Math.round(performance.now()-E),nodes:m.nodes.length,edges:m.edges.length}}catch(s){return {data:null,error:Pe(s,"The query failed."),elapsedMs:Math.round(performance.now()-E),nodes:0,edges:0}}finally{d$1(s=>s-1);}},[r,e,t]);return {state:i,dispatch:a$1,isLoading:o>0,loadRecords:C,expandAll:k,expandAttribute:l$1,runQuery:u}}function is(){let{currentProjectId:e$4,currentProject:t,currentProjectSchema:n}=f();useEffect(()=>{e$4&&t&&e({event:"graph_opened",projectId:e$4});},[e$4,t]);let[,r]=g(),{scope:i$1}=c(),{resolvedTheme:a}=b(),o=useLocation(),d=j(),b$3=a==="dark"?"dark":"light",C=e$1(t?.scopes),k$1=i$1||C,l=r.user?.spaces,u=useMemo(()=>c$1(n,l),[n,l]),g$2=useMemo(()=>f$1(u),[u]),f$2=useMemo(()=>i(u,b$3),[u,b$3]),E=Tn({schema:u,scope:k$1}),{state:p,dispatch:S,isLoading:s,loadRecords:N,expandAll:m,expandAttribute:D,runQuery:_}=E,$=useRef(null),[v,A]=useState(null),[q,c$4]=useState(false),[y$1,w]=useState("explore"),R=useRef(null),G=useMemo(()=>fn(p),[p]),Q=p.selected?p.nodes[p.selected]:void 0,Y=v?p.nodes[v.key]:void 0,V=Y?g$1(u,Y.entity):void 0,K$1=Object.keys(p.nodes).length,h=Object.keys(p.edges).length,T=I(),L=useCallback(x=>S({type:"select",key:x}),[S]),oe=useCallback(x=>{let O=p.nodes[x],ie=O?g$1(u,O.entity):void 0;O&&ie&&d({type:"EditEntity",payload:{entityId:O.id,entityNamePlural:ie.plural}});},[d,u,p.nodes]),Oe=useCallback(x=>S({type:"remove",keys:[x]}),[S]),Dn=useCallback(x=>S({type:"keepOnly",keys:[x,...mn(p,x)]}),[S,p]),Ln=useCallback(x=>S({type:"togglePin",key:x}),[S]),In=useCallback(x=>{p.pinned[x]||S({type:"togglePin",key:x});},[S,p.pinned]),Pn=useCallback(async(x,O)=>{let ie=g$1(u,x);if(!ie)return;let[fe]=await N(ie,{ids:[O],expand:true});fe&&L(fe);},[N,u,L]),_n=useCallback((x,O)=>{A(null),D(x,O);},[D]);return useEffect(()=>{let x=y(o.search);if(!x||R.current===o.key)return;let O=g$1(u,x.entity);if(!O||u.length===0)return;R.current=o.key;let ie=x.ids.length>0?{ids:x.ids,expand:x.ids.length<=k}:{limit:b$1};N(O,ie).then(fe=>{x.ids.length===1&&fe[0]&&L(fe[0]);});},[o.key,o.search,u,N,L]),e$4?jsxs(K,{className:"fk:h-full",defaultOpen:T,children:[jsx(Cn,{colors:f$2,entities:g$2,hiddenEntities:p.hiddenEntities,onCanvas:G,onHit:(x,O)=>{Pn(x,O);},onStart:x=>{N(x,{limit:b$1});},onToggleEntity:x=>S({type:"toggleEntity",entity:x}),projectId:e$4}),jsx(O,{className:"fk:min-w-0",children:jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0","data-testid":"graph-app",children:[jsx(An,{hidden:y$1!=="query",isRunning:s,onRun:_,projectId:e$4,schema:u,schemaHash:t?.schemaHash??null,scope:k$1,theme:b$3},e$4),jsxs("div",{className:"fk:relative fk:min-w-0 fk:flex-1 fk:overflow-hidden fk:bg-background",children:[jsxs("div",{className:"fk:pointer-events-none fk:absolute fk:left-3 fk:right-3 fk:top-3 fk:z-10 fk:flex fk:flex-wrap fk:items-start fk:justify-between fk:gap-2",children:[jsxs("div",{className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsx(M,{className:"fk:h-8 fk:w-8 fk:rounded-lg fk:hover:bg-transparent fk:dark:hover:bg-transparent"})}),jsx(e$2,{children:"Toggle Sidebar"})]}),jsx(Rn,{hasNodes:K$1>0,hasSelection:Q!==void 0,isLoading:s,onClear:()=>S({type:"clear"}),onExpand:()=>{p.selected&&m(p.selected);},onFit:()=>$.current?.fit(),onHide:()=>{p.selected&&Oe(p.selected);}})]}),jsxs("div",{"aria-label":"View",className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-0.5 fk:shadow-xs","data-testid":"graph-mode",role:"group",children:[jsx(c$3,{"aria-pressed":y$1==="explore",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>w("explore"),size:"sm",variant:y$1==="explore"?"default":"ghost",children:"Explore"}),jsx(c$3,{"aria-pressed":y$1==="query",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>w("query"),size:"sm",variant:y$1==="query"?"default":"ghost",children:"Query"})]})]}),K$1>0?null:jsx("div",{className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground",children:s?"Loading records\u2026":y$1==="query"?"Run a query to draw its result.":"Search a record or start from an entity to draw its graph."}),jsx(ln,{apiRef:$,colors:f$2,onContextMenu:(x,O)=>A({key:x,...O}),onExpand:x=>{m(x);},onLayoutChange:c$4,onPin:In,onSelect:L,scene:p,theme:b$3}),jsxs("div",{className:"fk:absolute fk:bottom-3 fk:left-3 fk:flex fk:max-w-[calc(100%-1.5rem)] fk:items-center fk:gap-2 fk:rounded-lg fk:border fk:bg-background fk:px-2.5 fk:py-1.5 fk:text-xs fk:text-muted-foreground fk:shadow-xs","data-testid":"graph-status",children:[jsxs("span",{children:[K$1.toLocaleString()," ",K$1===1?"node":"nodes"," \xB7 ",h.toLocaleString()," ",h===1?"relationship":"relationships"]}),q?jsx("span",{children:"\xB7 laying out\u2026"}):null,p.notice?jsxs("span",{className:"fk:truncate fk:text-foreground",children:["\xB7 ",p.notice]}):null]}),jsx(un,{isPinned:v?p.pinned[v.key]===true:false,menu:v,onClose:()=>A(null),onExpandAll:x=>{m(x);},onExpandAttribute:_n,onHide:Oe,onHideOthers:Dn,onOpenRecord:oe,onTogglePin:Ln,relationships:V?e$3(V):[]})]}),Q?jsx(kn,{colors:f$2,isLoading:s,node:Q,onClose:()=>L(null),onExpandAll:x=>{m(x);},onExpandAttribute:(x,O)=>{D(x,O);},onHide:Oe,onOpenRecord:oe,scene:p,schema:u,scope:k$1}):null]})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to explore its graph."})}export{is as Root};//# sourceMappingURL=root-3Q44ISGQ.js.map
|
|
14
|
+
//# sourceMappingURL=root-3Q44ISGQ.js.map
|